From a987494300fc2d745efc4a6c675f86a8eedb797b Mon Sep 17 00:00:00 2001 From: Alex Morask <144709477+amorask-bitwarden@users.noreply.github.com> Date: Tue, 16 Dec 2025 10:13:18 -0600 Subject: [PATCH] [PM-29607] Create `@bitwarden/subscription` (#17997) * Create @bitwarden/subscription * Fix changed import in tsconfig.base.json --- .github/CODEOWNERS | 1 + jest.config.js | 1 + libs/subscription/README.md | 5 ++++ libs/subscription/eslint.config.mjs | 3 ++ libs/subscription/jest.config.js | 10 +++++++ libs/subscription/package.json | 11 +++++++ libs/subscription/project.json | 34 ++++++++++++++++++++++ libs/subscription/src/index.ts | 1 + libs/subscription/src/subscription.spec.ts | 8 +++++ libs/subscription/tsconfig.eslint.json | 6 ++++ libs/subscription/tsconfig.json | 13 +++++++++ libs/subscription/tsconfig.lib.json | 10 +++++++ libs/subscription/tsconfig.spec.json | 10 +++++++ package-lock.json | 9 ++++++ tsconfig.base.json | 1 + 15 files changed, 123 insertions(+) create mode 100644 libs/subscription/README.md create mode 100644 libs/subscription/eslint.config.mjs create mode 100644 libs/subscription/jest.config.js create mode 100644 libs/subscription/package.json create mode 100644 libs/subscription/project.json create mode 100644 libs/subscription/src/index.ts create mode 100644 libs/subscription/src/subscription.spec.ts create mode 100644 libs/subscription/tsconfig.eslint.json create mode 100644 libs/subscription/tsconfig.json create mode 100644 libs/subscription/tsconfig.lib.json create mode 100644 libs/subscription/tsconfig.spec.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 89fff27b217..99efec2fbbb 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -232,3 +232,4 @@ libs/pricing @bitwarden/team-billing-dev .claude/ @bitwarden/team-ai-sme .github/workflows/respond.yml @bitwarden/team-ai-sme .github/workflows/review-code.yml @bitwarden/team-ai-sme +libs/subscription @bitwarden/team-billing-dev diff --git a/jest.config.js b/jest.config.js index e5aeb536172..37d15eb8f92 100644 --- a/jest.config.js +++ b/jest.config.js @@ -59,6 +59,7 @@ module.exports = { "/libs/tools/send/send-ui/jest.config.js", "/libs/user-core/jest.config.js", "/libs/vault/jest.config.js", + "/libs/subscription/jest.config.js", ], // Workaround for a memory leak that crashes tests in CI: diff --git a/libs/subscription/README.md b/libs/subscription/README.md new file mode 100644 index 00000000000..be3d5044b4f --- /dev/null +++ b/libs/subscription/README.md @@ -0,0 +1,5 @@ +# Subscription + +Owned by: billing + +Components and services for managing Bitwarden subscriptions. diff --git a/libs/subscription/eslint.config.mjs b/libs/subscription/eslint.config.mjs new file mode 100644 index 00000000000..9c37d10e3ff --- /dev/null +++ b/libs/subscription/eslint.config.mjs @@ -0,0 +1,3 @@ +import baseConfig from "../../eslint.config.mjs"; + +export default [...baseConfig]; diff --git a/libs/subscription/jest.config.js b/libs/subscription/jest.config.js new file mode 100644 index 00000000000..a78ad5c2fc3 --- /dev/null +++ b/libs/subscription/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + displayName: "subscription", + preset: "../../jest.preset.js", + testEnvironment: "node", + transform: { + "^.+\\.[tj]s$": ["ts-jest", { tsconfig: "/tsconfig.spec.json" }], + }, + moduleFileExtensions: ["ts", "js", "html"], + coverageDirectory: "../../coverage/libs/subscription", +}; diff --git a/libs/subscription/package.json b/libs/subscription/package.json new file mode 100644 index 00000000000..67861a8891f --- /dev/null +++ b/libs/subscription/package.json @@ -0,0 +1,11 @@ +{ + "name": "@bitwarden/subscription", + "version": "0.0.1", + "description": "Components and services for managing Bitwarden subscriptions.", + "private": true, + "type": "commonjs", + "main": "index.js", + "types": "index.d.ts", + "license": "GPL-3.0", + "author": "billing" +} diff --git a/libs/subscription/project.json b/libs/subscription/project.json new file mode 100644 index 00000000000..ebd7b1cb73e --- /dev/null +++ b/libs/subscription/project.json @@ -0,0 +1,34 @@ +{ + "name": "subscription", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/subscription/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@nx/js:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/subscription", + "main": "libs/subscription/src/index.ts", + "tsConfig": "libs/subscription/tsconfig.lib.json", + "assets": ["libs/subscription/*.md"], + "rootDir": "libs/subscription/src" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/subscription/**/*.ts"] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/subscription/jest.config.js" + } + } + } +} diff --git a/libs/subscription/src/index.ts b/libs/subscription/src/index.ts new file mode 100644 index 00000000000..3deb7c89d41 --- /dev/null +++ b/libs/subscription/src/index.ts @@ -0,0 +1 @@ +export type Placeholder = unknown; diff --git a/libs/subscription/src/subscription.spec.ts b/libs/subscription/src/subscription.spec.ts new file mode 100644 index 00000000000..7f0836a5063 --- /dev/null +++ b/libs/subscription/src/subscription.spec.ts @@ -0,0 +1,8 @@ +import * as lib from "./index"; + +describe("subscription", () => { + // This test will fail until something is exported from index.ts + it("should work", () => { + expect(lib).toBeDefined(); + }); +}); diff --git a/libs/subscription/tsconfig.eslint.json b/libs/subscription/tsconfig.eslint.json new file mode 100644 index 00000000000..3daf120441a --- /dev/null +++ b/libs/subscription/tsconfig.eslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["**/build", "**/dist"] +} diff --git a/libs/subscription/tsconfig.json b/libs/subscription/tsconfig.json new file mode 100644 index 00000000000..62ebbd94647 --- /dev/null +++ b/libs/subscription/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/subscription/tsconfig.lib.json b/libs/subscription/tsconfig.lib.json new file mode 100644 index 00000000000..9cbf6736007 --- /dev/null +++ b/libs/subscription/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.js", "src/**/*.spec.ts"] +} diff --git a/libs/subscription/tsconfig.spec.json b/libs/subscription/tsconfig.spec.json new file mode 100644 index 00000000000..1275f148a18 --- /dev/null +++ b/libs/subscription/tsconfig.spec.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "moduleResolution": "node10", + "types": ["jest", "node"] + }, + "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"] +} diff --git a/package-lock.json b/package-lock.json index 879cda31ec7..6d67a0172bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -628,6 +628,11 @@ "version": "0.0.1", "license": "GPL-3.0" }, + "libs/subscription": { + "name": "@bitwarden/subscription", + "version": "0.0.1", + "license": "GPL-3.0" + }, "libs/tools/export/vault-export/vault-export-core": { "name": "@bitwarden/vault-export-core", "version": "0.0.0", @@ -5011,6 +5016,10 @@ "resolved": "libs/storage-test-utils", "link": true }, + "node_modules/@bitwarden/subscription": { + "resolved": "libs/subscription", + "link": true + }, "node_modules/@bitwarden/ui-common": { "resolved": "libs/ui/common", "link": true diff --git a/tsconfig.base.json b/tsconfig.base.json index ae4b9f5f601..2f6499eb374 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -58,6 +58,7 @@ "@bitwarden/state-test-utils": ["libs/state-test-utils/src/index.ts"], "@bitwarden/storage-core": ["libs/storage-core/src/index.ts"], "@bitwarden/storage-test-utils": ["libs/storage-test-utils/src/index.ts"], + "@bitwarden/subscription": ["libs/subscription/src/index.ts"], "@bitwarden/ui-common": ["./libs/ui/common/src"], "@bitwarden/ui-common/setup-jest": ["./libs/ui/common/src/setup-jest"], "@bitwarden/user-core": ["libs/user-core/src/index.ts"],