From 314379da0f53c44c7b504aea6ca232c44e84ffc8 Mon Sep 17 00:00:00 2001 From: Thomas Faust Date: Sat, 15 Mar 2025 18:18:05 +0100 Subject: [PATCH 01/10] feat(zitadel-proto): add CJS and ESM support; export in Zitadel api structure; add build configuration --- packages/zitadel-proto/README.md | 83 +++++++++++++++++++++--- packages/zitadel-proto/index.ts | 5 ++ packages/zitadel-proto/package.json | 28 ++++++-- packages/zitadel-proto/test/cjs-test.cjs | 28 ++++++++ packages/zitadel-proto/test/esm-test.mjs | 28 ++++++++ packages/zitadel-proto/tsup.config.ts | 13 ++++ packages/zitadel-proto/v1.ts | 53 +++++++++++++++ packages/zitadel-proto/v2.ts | 49 ++++++++++++++ packages/zitadel-proto/v3alpha.ts | 9 +++ 9 files changed, 282 insertions(+), 14 deletions(-) create mode 100644 packages/zitadel-proto/index.ts create mode 100644 packages/zitadel-proto/test/cjs-test.cjs create mode 100644 packages/zitadel-proto/test/esm-test.mjs create mode 100644 packages/zitadel-proto/tsup.config.ts create mode 100644 packages/zitadel-proto/v1.ts create mode 100644 packages/zitadel-proto/v2.ts create mode 100644 packages/zitadel-proto/v3alpha.ts diff --git a/packages/zitadel-proto/README.md b/packages/zitadel-proto/README.md index bf8a064c12..32bf3236c7 100644 --- a/packages/zitadel-proto/README.md +++ b/packages/zitadel-proto/README.md @@ -8,22 +8,87 @@ To install the package, use npm or yarn: ```sh npm install @zitadel/proto -``` - -or - -```sh +# or yarn add @zitadel/proto +# or +pnpm add @zitadel/proto ``` ## Usage -To use the proto definitions in your project, import the generated code: +This package supports both ESM and CommonJS imports. The API is organized into version-specific namespaces: `v1`, `v2`, and `v3alpha`. -```ts -import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb"; +### ESM (ECMAScript Modules) -const org: Organization | null = await getDefaultOrg(); +```typescript +// Import the entire package +import * as zitadel from "@zitadel/proto"; + +// Use the version-specific namespaces +const userRequest = new zitadel.v1.user.GetUserRequest(); + +// Or import specific versions +import { v2 } from "@zitadel/proto"; +const userServiceRequest = new v2.user_service.GetUserRequest(); +``` + +### CommonJS + +```typescript +// Import the entire package +const zitadel = require("@zitadel/proto"); + +// Use the version-specific namespaces +const userRequest = new zitadel.v1.user.GetUserRequest(); +``` + +## API Structure + +The package is organized into version-specific namespaces: + +- `v1`: Contains the original ZITADEL API +- `v2`: Contains the newer version of the API with improved organization +- `v3alpha`: Contains the alpha version of the upcoming API + +## Package Structure + +The package is organized as follows: + +- `index.ts`: Main entry point that exports the version-specific APIs +- `v1.ts`: Exports all v1 API modules +- `v2.ts`: Exports all v2 API modules +- `v3alpha.ts`: Exports all v3alpha API modules +- `zitadel/`: Contains the generated proto files + +## Development + +### Generating the proto files + +The proto files are generated from the ZITADEL API definitions using [buf](https://buf.build/). + +```sh +pnpm generate +``` + +### Building the package + +```sh +pnpm build +``` + +### Testing + +To test both ESM and CommonJS imports: + +```sh +pnpm test +``` + +Or test them individually: + +```bash +pnpm test:cjs # Test CommonJS imports +pnpm test:esm # Test ESM imports ``` ## Documentation diff --git a/packages/zitadel-proto/index.ts b/packages/zitadel-proto/index.ts new file mode 100644 index 0000000000..6b7b927f11 --- /dev/null +++ b/packages/zitadel-proto/index.ts @@ -0,0 +1,5 @@ +import * as v1 from "./v1.js"; +import * as v2 from "./v2.js"; +import * as v3alpha from "./v3alpha.js"; + +export { v1, v2, v3alpha }; diff --git a/packages/zitadel-proto/package.json b/packages/zitadel-proto/package.json index dcfa9b3f22..5a1b2fee1d 100644 --- a/packages/zitadel-proto/package.json +++ b/packages/zitadel-proto/package.json @@ -5,22 +5,40 @@ "publishConfig": { "access": "public" }, - "type": "module", + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } + }, "files": [ + "index.ts", + "v1.ts", + "v2.ts", + "v3alpha.ts", "zitadel/**", "validate/**", "google/**", - "protoc-gen-openapiv2/**" + "dist/**" ], "sideEffects": false, "scripts": { "generate": "buf generate https://github.com/zitadel/zitadel.git#tag=v2.71.1 --path ./proto/zitadel", - "clean": "rm -rf zitadel .turbo node_modules google protoc-gen-openapiv2 validate" + "clean": "rm -rf zitadel .turbo node_modules google protoc-gen-openapiv2 validate", + "build": "tsup", + "test:cjs": "node test/cjs-test.cjs", + "test:esm": "node test/esm-test.mjs", + "test": "pnpm build && pnpm test:cjs && pnpm test:esm" }, "dependencies": { "@bufbuild/protobuf": "^2.2.2" }, "devDependencies": { - "@bufbuild/buf": "^1.47.2" + "@bufbuild/buf": "^1.47.2", + "tsup": "^8.0.0" } -} +} \ No newline at end of file diff --git a/packages/zitadel-proto/test/cjs-test.cjs b/packages/zitadel-proto/test/cjs-test.cjs new file mode 100644 index 0000000000..87033cfd3b --- /dev/null +++ b/packages/zitadel-proto/test/cjs-test.cjs @@ -0,0 +1,28 @@ +// CommonJS import test +const zitadel = require("@zitadel/proto"); + +// Check if the import worked by accessing some properties +console.log("CommonJS import test:"); +console.log("- Has v1 API:", !!zitadel.v1); +console.log("- Has v2 API:", !!zitadel.v2); +console.log("- Has v3alpha API:", !!zitadel.v3alpha); + +// Test v1 API +console.log("- v1.user module:", !!zitadel.v1.user); +console.log("- v1.management module:", !!zitadel.v1.management); + +// Test v2 API +console.log("- v2.user module:", !!zitadel.v2.user); +console.log("- v2.user_service module:", !!zitadel.v2.user_service); + +// Test v3alpha API +console.log("- v3alpha.user module:", !!zitadel.v3alpha.user); +console.log("- v3alpha.user_service module:", !!zitadel.v3alpha.user_service); + +// Test successful if we can access these modules +if (zitadel.v1 && zitadel.v2 && zitadel.v3alpha) { + console.log("✅ CommonJS import test passed!"); +} else { + console.error("❌ CommonJS import test failed!"); + process.exit(1); +} diff --git a/packages/zitadel-proto/test/esm-test.mjs b/packages/zitadel-proto/test/esm-test.mjs new file mode 100644 index 0000000000..aafaf01df3 --- /dev/null +++ b/packages/zitadel-proto/test/esm-test.mjs @@ -0,0 +1,28 @@ +// ESM import test +import * as zitadel from "@zitadel/proto"; + +// Check if the import worked by accessing some properties +console.log("ESM import test:"); +console.log("- Has v1 API:", !!zitadel.v1); +console.log("- Has v2 API:", !!zitadel.v2); +console.log("- Has v3alpha API:", !!zitadel.v3alpha); + +// Test v1 API +console.log("- v1.user module:", !!zitadel.v1.user); +console.log("- v1.management module:", !!zitadel.v1.management); + +// Test v2 API +console.log("- v2.user module:", !!zitadel.v2.user); +console.log("- v2.user_service module:", !!zitadel.v2.user_service); + +// Test v3alpha API +console.log("- v3alpha.user module:", !!zitadel.v3alpha.user); +console.log("- v3alpha.user_service module:", !!zitadel.v3alpha.user_service); + +// Test successful if we can access these modules +if (zitadel.v1 && zitadel.v2 && zitadel.v3alpha) { + console.log("✅ ESM import test passed!"); +} else { + console.error("❌ ESM import test failed!"); + process.exit(1); +} diff --git a/packages/zitadel-proto/tsup.config.ts b/packages/zitadel-proto/tsup.config.ts new file mode 100644 index 0000000000..1fa9c664a7 --- /dev/null +++ b/packages/zitadel-proto/tsup.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from "tsup"; + +export default defineConfig({ + entry: ["index.ts"], + dts: true, + clean: true, + minify: false, + splitting: false, + sourcemap: true, + format: ["esm", "cjs"], + platform: "neutral", + target: "node16", +}); diff --git a/packages/zitadel-proto/v1.ts b/packages/zitadel-proto/v1.ts new file mode 100644 index 0000000000..bea11ca384 --- /dev/null +++ b/packages/zitadel-proto/v1.ts @@ -0,0 +1,53 @@ +import * as action from "./zitadel/action_pb.js"; +import * as admin from "./zitadel/admin_pb.js"; +import * as app from "./zitadel/app_pb.js"; +import * as auth_n_key from "./zitadel/auth_n_key_pb.js"; +import * as auth from "./zitadel/auth_pb.js"; +import * as change from "./zitadel/change_pb.js"; +import * as event from "./zitadel/event_pb.js"; +import * as feature from "./zitadel/feature_pb.js"; +import * as idp from "./zitadel/idp_pb.js"; +import * as instance from "./zitadel/instance_pb.js"; +import * as management from "./zitadel/management_pb.js"; +import * as member from "./zitadel/member_pb.js"; +import * as message from "./zitadel/message_pb.js"; +import * as metadata from "./zitadel/metadata_pb.js"; +import * as object from "./zitadel/object_pb.js"; +import * as options from "./zitadel/options_pb.js"; +import * as org from "./zitadel/org_pb.js"; +import * as policy from "./zitadel/policy_pb.js"; +import * as project from "./zitadel/project_pb.js"; +import * as quota from "./zitadel/quota_pb.js"; +import * as settings from "./zitadel/settings_pb.js"; +import * as system from "./zitadel/system_pb.js"; +import * as text from "./zitadel/text_pb.js"; +import * as user from "./zitadel/user_pb.js"; +import * as v1 from "./zitadel/v1_pb.js"; + +export { + action, + admin, + app, + auth, + auth_n_key, + change, + event, + feature, + idp, + instance, + management, + member, + message, + metadata, + object, + options, + org, + policy, + project, + quota, + settings, + system, + text, + user, + v1, +}; diff --git a/packages/zitadel-proto/v2.ts b/packages/zitadel-proto/v2.ts new file mode 100644 index 0000000000..532db0d82e --- /dev/null +++ b/packages/zitadel-proto/v2.ts @@ -0,0 +1,49 @@ +import * as feature from "./zitadel/feature/v2/feature_pb.js"; +import * as feature_service from "./zitadel/feature/v2/feature_service_pb.js"; +import * as idp from "./zitadel/idp/v2/idp_pb.js"; +import * as idp_service from "./zitadel/idp/v2/idp_service_pb.js"; +import * as object from "./zitadel/object/v2/object_pb.js"; +import * as oidc_authorization from "./zitadel/oidc/v2/authorization_pb.js"; +import * as oidc_service from "./zitadel/oidc/v2/oidc_service_pb.js"; +import * as org from "./zitadel/org/v2/org_pb.js"; +import * as org_service from "./zitadel/org/v2/org_service_pb.js"; +import * as saml_authorization from "./zitadel/saml/v2/authorization_pb.js"; +import * as saml_service from "./zitadel/saml/v2/saml_service_pb.js"; +import * as session from "./zitadel/session/v2/session_pb.js"; +import * as session_service from "./zitadel/session/v2/session_service_pb.js"; +import * as settings from "./zitadel/settings/v2/settings_pb.js"; +import * as settings_service from "./zitadel/settings/v2/settings_service_pb.js"; +import * as user_auth from "./zitadel/user/v2/auth_pb.js"; +import * as user_email from "./zitadel/user/v2/email_pb.js"; +import * as user_idp from "./zitadel/user/v2/idp_pb.js"; +import * as user_password from "./zitadel/user/v2/password_pb.js"; +import * as user_phone from "./zitadel/user/v2/phone_pb.js"; +import * as user_query from "./zitadel/user/v2/query_pb.js"; +import * as user from "./zitadel/user/v2/user_pb.js"; +import * as user_service from "./zitadel/user/v2/user_service_pb.js"; + +export { + feature, + feature_service, + idp, + idp_service, + object, + oidc_authorization, + oidc_service, + org, + org_service, + saml_authorization, + saml_service, + session, + session_service, + settings, + settings_service, + user, + user_auth, + user_email, + user_idp, + user_password, + user_phone, + user_query, + user_service, +}; diff --git a/packages/zitadel-proto/v3alpha.ts b/packages/zitadel-proto/v3alpha.ts new file mode 100644 index 0000000000..e6b2c33464 --- /dev/null +++ b/packages/zitadel-proto/v3alpha.ts @@ -0,0 +1,9 @@ +import * as user_authenticator from "./zitadel/resources/user/v3alpha/authenticator_pb.js"; +import * as user_communication from "./zitadel/resources/user/v3alpha/communication_pb.js"; +import * as user_query from "./zitadel/resources/user/v3alpha/query_pb.js"; +import * as user from "./zitadel/resources/user/v3alpha/user_pb.js"; +import * as user_service from "./zitadel/resources/user/v3alpha/user_service_pb.js"; +import * as user_schema from "./zitadel/resources/userschema/v3alpha/user_schema_pb.js"; +import * as user_schema_service from "./zitadel/resources/userschema/v3alpha/user_schema_service_pb.js"; + +export { user, user_authenticator, user_communication, user_query, user_schema, user_schema_service, user_service }; From 2c1939744b3b7d58ff97ee6eb0fee37f342f039c Mon Sep 17 00:00:00 2001 From: Thomas Faust Date: Sun, 16 Mar 2025 07:16:53 +0100 Subject: [PATCH 02/10] refactor(zitadel-proto): restructure package files and update entry points --- packages/zitadel-proto/package.json | 7 +-- packages/zitadel-proto/{ => src}/index.ts | 0 packages/zitadel-proto/src/v1.ts | 53 +++++++++++++++++++++++ packages/zitadel-proto/src/v2.ts | 49 +++++++++++++++++++++ packages/zitadel-proto/src/v3alpha.ts | 9 ++++ packages/zitadel-proto/tsup.config.ts | 3 +- packages/zitadel-proto/v1.ts | 53 ----------------------- packages/zitadel-proto/v2.ts | 49 --------------------- packages/zitadel-proto/v3alpha.ts | 9 ---- 9 files changed, 115 insertions(+), 117 deletions(-) rename packages/zitadel-proto/{ => src}/index.ts (100%) create mode 100644 packages/zitadel-proto/src/v1.ts create mode 100644 packages/zitadel-proto/src/v2.ts create mode 100644 packages/zitadel-proto/src/v3alpha.ts delete mode 100644 packages/zitadel-proto/v1.ts delete mode 100644 packages/zitadel-proto/v2.ts delete mode 100644 packages/zitadel-proto/v3alpha.ts diff --git a/packages/zitadel-proto/package.json b/packages/zitadel-proto/package.json index 5a1b2fee1d..cc3d37fdb6 100644 --- a/packages/zitadel-proto/package.json +++ b/packages/zitadel-proto/package.json @@ -16,10 +16,7 @@ } }, "files": [ - "index.ts", - "v1.ts", - "v2.ts", - "v3alpha.ts", + "src/**", "zitadel/**", "validate/**", "google/**", @@ -32,7 +29,7 @@ "build": "tsup", "test:cjs": "node test/cjs-test.cjs", "test:esm": "node test/esm-test.mjs", - "test": "pnpm build && pnpm test:cjs && pnpm test:esm" + "test": "pnpm test:cjs && pnpm test:esm" }, "dependencies": { "@bufbuild/protobuf": "^2.2.2" diff --git a/packages/zitadel-proto/index.ts b/packages/zitadel-proto/src/index.ts similarity index 100% rename from packages/zitadel-proto/index.ts rename to packages/zitadel-proto/src/index.ts diff --git a/packages/zitadel-proto/src/v1.ts b/packages/zitadel-proto/src/v1.ts new file mode 100644 index 0000000000..887df5ceb9 --- /dev/null +++ b/packages/zitadel-proto/src/v1.ts @@ -0,0 +1,53 @@ +import * as action from "../zitadel/action_pb.js"; +import * as admin from "../zitadel/admin_pb.js"; +import * as app from "../zitadel/app_pb.js"; +import * as auth_n_key from "../zitadel/auth_n_key_pb.js"; +import * as auth from "../zitadel/auth_pb.js"; +import * as change from "../zitadel/change_pb.js"; +import * as event from "../zitadel/event_pb.js"; +import * as feature from "../zitadel/feature_pb.js"; +import * as idp from "../zitadel/idp_pb.js"; +import * as instance from "../zitadel/instance_pb.js"; +import * as management from "../zitadel/management_pb.js"; +import * as member from "../zitadel/member_pb.js"; +import * as message from "../zitadel/message_pb.js"; +import * as metadata from "../zitadel/metadata_pb.js"; +import * as object from "../zitadel/object_pb.js"; +import * as options from "../zitadel/options_pb.js"; +import * as org from "../zitadel/org_pb.js"; +import * as policy from "../zitadel/policy_pb.js"; +import * as project from "../zitadel/project_pb.js"; +import * as quota from "../zitadel/quota_pb.js"; +import * as settings from "../zitadel/settings_pb.js"; +import * as system from "../zitadel/system_pb.js"; +import * as text from "../zitadel/text_pb.js"; +import * as user from "../zitadel/user_pb.js"; +import * as v1 from "../zitadel/v1_pb.js"; + +export { + action, + admin, + app, + auth, + auth_n_key, + change, + event, + feature, + idp, + instance, + management, + member, + message, + metadata, + object, + options, + org, + policy, + project, + quota, + settings, + system, + text, + user, + v1, +}; diff --git a/packages/zitadel-proto/src/v2.ts b/packages/zitadel-proto/src/v2.ts new file mode 100644 index 0000000000..e2167c4581 --- /dev/null +++ b/packages/zitadel-proto/src/v2.ts @@ -0,0 +1,49 @@ +import * as feature from "../zitadel/feature/v2/feature_pb.js"; +import * as feature_service from "../zitadel/feature/v2/feature_service_pb.js"; +import * as idp from "../zitadel/idp/v2/idp_pb.js"; +import * as idp_service from "../zitadel/idp/v2/idp_service_pb.js"; +import * as object from "../zitadel/object/v2/object_pb.js"; +import * as oidc_authorization from "../zitadel/oidc/v2/authorization_pb.js"; +import * as oidc_service from "../zitadel/oidc/v2/oidc_service_pb.js"; +import * as org from "../zitadel/org/v2/org_pb.js"; +import * as org_service from "../zitadel/org/v2/org_service_pb.js"; +import * as saml_authorization from "../zitadel/saml/v2/authorization_pb.js"; +import * as saml_service from "../zitadel/saml/v2/saml_service_pb.js"; +import * as session from "../zitadel/session/v2/session_pb.js"; +import * as session_service from "../zitadel/session/v2/session_service_pb.js"; +import * as settings from "../zitadel/settings/v2/settings_pb.js"; +import * as settings_service from "../zitadel/settings/v2/settings_service_pb.js"; +import * as user_auth from "../zitadel/user/v2/auth_pb.js"; +import * as user_email from "../zitadel/user/v2/email_pb.js"; +import * as user_idp from "../zitadel/user/v2/idp_pb.js"; +import * as user_password from "../zitadel/user/v2/password_pb.js"; +import * as user_phone from "../zitadel/user/v2/phone_pb.js"; +import * as user_query from "../zitadel/user/v2/query_pb.js"; +import * as user from "../zitadel/user/v2/user_pb.js"; +import * as user_service from "../zitadel/user/v2/user_service_pb.js"; + +export { + feature, + feature_service, + idp, + idp_service, + object, + oidc_authorization, + oidc_service, + org, + org_service, + saml_authorization, + saml_service, + session, + session_service, + settings, + settings_service, + user, + user_auth, + user_email, + user_idp, + user_password, + user_phone, + user_query, + user_service, +}; diff --git a/packages/zitadel-proto/src/v3alpha.ts b/packages/zitadel-proto/src/v3alpha.ts new file mode 100644 index 0000000000..9d787bdc5b --- /dev/null +++ b/packages/zitadel-proto/src/v3alpha.ts @@ -0,0 +1,9 @@ +import * as user_authenticator from "../zitadel/resources/user/v3alpha/authenticator_pb.js"; +import * as user_communication from "../zitadel/resources/user/v3alpha/communication_pb.js"; +import * as user_query from "../zitadel/resources/user/v3alpha/query_pb.js"; +import * as user from "../zitadel/resources/user/v3alpha/user_pb.js"; +import * as user_service from "../zitadel/resources/user/v3alpha/user_service_pb.js"; +import * as user_schema from "../zitadel/resources/userschema/v3alpha/user_schema_pb.js"; +import * as user_schema_service from "../zitadel/resources/userschema/v3alpha/user_schema_service_pb.js"; + +export { user, user_authenticator, user_communication, user_query, user_schema, user_schema_service, user_service }; diff --git a/packages/zitadel-proto/tsup.config.ts b/packages/zitadel-proto/tsup.config.ts index 1fa9c664a7..13a78084c6 100644 --- a/packages/zitadel-proto/tsup.config.ts +++ b/packages/zitadel-proto/tsup.config.ts @@ -1,11 +1,12 @@ import { defineConfig } from "tsup"; export default defineConfig({ - entry: ["index.ts"], + entry: ["src/index.ts", "src/v1.ts", "src/v2.ts", "src/v3alpha.ts"], dts: true, clean: true, minify: false, splitting: false, + treeshake: false, sourcemap: true, format: ["esm", "cjs"], platform: "neutral", diff --git a/packages/zitadel-proto/v1.ts b/packages/zitadel-proto/v1.ts deleted file mode 100644 index bea11ca384..0000000000 --- a/packages/zitadel-proto/v1.ts +++ /dev/null @@ -1,53 +0,0 @@ -import * as action from "./zitadel/action_pb.js"; -import * as admin from "./zitadel/admin_pb.js"; -import * as app from "./zitadel/app_pb.js"; -import * as auth_n_key from "./zitadel/auth_n_key_pb.js"; -import * as auth from "./zitadel/auth_pb.js"; -import * as change from "./zitadel/change_pb.js"; -import * as event from "./zitadel/event_pb.js"; -import * as feature from "./zitadel/feature_pb.js"; -import * as idp from "./zitadel/idp_pb.js"; -import * as instance from "./zitadel/instance_pb.js"; -import * as management from "./zitadel/management_pb.js"; -import * as member from "./zitadel/member_pb.js"; -import * as message from "./zitadel/message_pb.js"; -import * as metadata from "./zitadel/metadata_pb.js"; -import * as object from "./zitadel/object_pb.js"; -import * as options from "./zitadel/options_pb.js"; -import * as org from "./zitadel/org_pb.js"; -import * as policy from "./zitadel/policy_pb.js"; -import * as project from "./zitadel/project_pb.js"; -import * as quota from "./zitadel/quota_pb.js"; -import * as settings from "./zitadel/settings_pb.js"; -import * as system from "./zitadel/system_pb.js"; -import * as text from "./zitadel/text_pb.js"; -import * as user from "./zitadel/user_pb.js"; -import * as v1 from "./zitadel/v1_pb.js"; - -export { - action, - admin, - app, - auth, - auth_n_key, - change, - event, - feature, - idp, - instance, - management, - member, - message, - metadata, - object, - options, - org, - policy, - project, - quota, - settings, - system, - text, - user, - v1, -}; diff --git a/packages/zitadel-proto/v2.ts b/packages/zitadel-proto/v2.ts deleted file mode 100644 index 532db0d82e..0000000000 --- a/packages/zitadel-proto/v2.ts +++ /dev/null @@ -1,49 +0,0 @@ -import * as feature from "./zitadel/feature/v2/feature_pb.js"; -import * as feature_service from "./zitadel/feature/v2/feature_service_pb.js"; -import * as idp from "./zitadel/idp/v2/idp_pb.js"; -import * as idp_service from "./zitadel/idp/v2/idp_service_pb.js"; -import * as object from "./zitadel/object/v2/object_pb.js"; -import * as oidc_authorization from "./zitadel/oidc/v2/authorization_pb.js"; -import * as oidc_service from "./zitadel/oidc/v2/oidc_service_pb.js"; -import * as org from "./zitadel/org/v2/org_pb.js"; -import * as org_service from "./zitadel/org/v2/org_service_pb.js"; -import * as saml_authorization from "./zitadel/saml/v2/authorization_pb.js"; -import * as saml_service from "./zitadel/saml/v2/saml_service_pb.js"; -import * as session from "./zitadel/session/v2/session_pb.js"; -import * as session_service from "./zitadel/session/v2/session_service_pb.js"; -import * as settings from "./zitadel/settings/v2/settings_pb.js"; -import * as settings_service from "./zitadel/settings/v2/settings_service_pb.js"; -import * as user_auth from "./zitadel/user/v2/auth_pb.js"; -import * as user_email from "./zitadel/user/v2/email_pb.js"; -import * as user_idp from "./zitadel/user/v2/idp_pb.js"; -import * as user_password from "./zitadel/user/v2/password_pb.js"; -import * as user_phone from "./zitadel/user/v2/phone_pb.js"; -import * as user_query from "./zitadel/user/v2/query_pb.js"; -import * as user from "./zitadel/user/v2/user_pb.js"; -import * as user_service from "./zitadel/user/v2/user_service_pb.js"; - -export { - feature, - feature_service, - idp, - idp_service, - object, - oidc_authorization, - oidc_service, - org, - org_service, - saml_authorization, - saml_service, - session, - session_service, - settings, - settings_service, - user, - user_auth, - user_email, - user_idp, - user_password, - user_phone, - user_query, - user_service, -}; diff --git a/packages/zitadel-proto/v3alpha.ts b/packages/zitadel-proto/v3alpha.ts deleted file mode 100644 index e6b2c33464..0000000000 --- a/packages/zitadel-proto/v3alpha.ts +++ /dev/null @@ -1,9 +0,0 @@ -import * as user_authenticator from "./zitadel/resources/user/v3alpha/authenticator_pb.js"; -import * as user_communication from "./zitadel/resources/user/v3alpha/communication_pb.js"; -import * as user_query from "./zitadel/resources/user/v3alpha/query_pb.js"; -import * as user from "./zitadel/resources/user/v3alpha/user_pb.js"; -import * as user_service from "./zitadel/resources/user/v3alpha/user_service_pb.js"; -import * as user_schema from "./zitadel/resources/userschema/v3alpha/user_schema_pb.js"; -import * as user_schema_service from "./zitadel/resources/userschema/v3alpha/user_schema_service_pb.js"; - -export { user, user_authenticator, user_communication, user_query, user_schema, user_schema_service, user_service }; From eae0ce5680c1781721e1d08649e502ee20292aa1 Mon Sep 17 00:00:00 2001 From: Thomas Faust Date: Thu, 20 Mar 2025 07:22:43 +0100 Subject: [PATCH 03/10] fix(zitadel-proto): make build dependent on generate --- packages/zitadel-proto/turbo.json | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/zitadel-proto/turbo.json b/packages/zitadel-proto/turbo.json index bffd614f62..86d4f1e86c 100644 --- a/packages/zitadel-proto/turbo.json +++ b/packages/zitadel-proto/turbo.json @@ -1,9 +1,22 @@ { - "extends": ["//"], + "extends": [ + "//" + ], "tasks": { + "build": { + "dependsOn": [ + "generate" + ], + "outputs": [ + "dist/**" + ], + "cache": false + }, "generate": { - "outputs": ["zitadel/**"], + "outputs": [ + "zitadel/**" + ], "cache": true } } -} +} \ No newline at end of file From fbef66800ea6a32e82050dc72c7859e2e59eb1f8 Mon Sep 17 00:00:00 2001 From: Thomas Faust Date: Thu, 20 Mar 2025 07:23:57 +0100 Subject: [PATCH 04/10] feat(zitadel-proto): export api versions and zitadel *.{js,d.ts} for legacy imports --- packages/zitadel-proto/package.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/zitadel-proto/package.json b/packages/zitadel-proto/package.json index cc3d37fdb6..95ddccdc09 100644 --- a/packages/zitadel-proto/package.json +++ b/packages/zitadel-proto/package.json @@ -13,6 +13,31 @@ "types": "./dist/index.d.ts", "import": "./dist/index.mjs", "require": "./dist/index.js" + }, + "./v1": { + "types": "./dist/v1.d.ts", + "import": "./dist/v1.mjs", + "require": "./dist/v1.js" + }, + "./v2": { + "types": "./dist/v2.d.ts", + "import": "./dist/v2.mjs", + "require": "./dist/v2.js" + }, + "./v3alpha": { + "types": "./dist/v3alpha.d.ts", + "import": "./dist/v3alpha.mjs", + "require": "./dist/v3alpha.js" + }, + "./zitadel/*": { + "types": "./zitadel/*.d.ts", + "import": "./zitadel/*.js", + "require": "./zitadel/*.js" + }, + "./zitadel/*.js": { + "types": "./zitadel/*.d.ts", + "import": "./zitadel/*.js", + "require": "./zitadel/*.js" } }, "files": [ From 347b41823881899c8148c724f952d6c750970720 Mon Sep 17 00:00:00 2001 From: Thomas Faust Date: Thu, 20 Mar 2025 07:54:36 +0100 Subject: [PATCH 05/10] feat(zitadel-proto): add legacy test and update tsconfig for compatibility --- package.json | 2 +- packages/zitadel-proto/package.json | 7 +- packages/zitadel-proto/test/legacy-test.ts | 15 +++ packages/zitadel-proto/tsconfig.json | 5 + pnpm-lock.yaml | 146 +++++++++++++++++++-- 5 files changed, 158 insertions(+), 17 deletions(-) create mode 100644 packages/zitadel-proto/test/legacy-test.ts create mode 100644 packages/zitadel-proto/tsconfig.json diff --git a/package.json b/package.json index a824e47571..57326f73cd 100644 --- a/package.json +++ b/package.json @@ -55,4 +55,4 @@ "vite-tsconfig-paths": "^5.1.2", "vitest": "^2.1.4" } -} +} \ No newline at end of file diff --git a/packages/zitadel-proto/package.json b/packages/zitadel-proto/package.json index 95ddccdc09..fc2b15a37d 100644 --- a/packages/zitadel-proto/package.json +++ b/packages/zitadel-proto/package.json @@ -54,13 +54,16 @@ "build": "tsup", "test:cjs": "node test/cjs-test.cjs", "test:esm": "node test/esm-test.mjs", - "test": "pnpm test:cjs && pnpm test:esm" + "test:legacy": "ts-node test/legacy-test.ts", + "test": "pnpm test:cjs && pnpm test:esm && pnpm test:legacy" }, "dependencies": { "@bufbuild/protobuf": "^2.2.2" }, "devDependencies": { "@bufbuild/buf": "^1.47.2", - "tsup": "^8.0.0" + "tsup": "^8.0.0", + "ts-node": "^10.9.2", + "@zitadel/tsconfig": "workspace:*" } } \ No newline at end of file diff --git a/packages/zitadel-proto/test/legacy-test.ts b/packages/zitadel-proto/test/legacy-test.ts new file mode 100644 index 0000000000..ddf6def6b1 --- /dev/null +++ b/packages/zitadel-proto/test/legacy-test.ts @@ -0,0 +1,15 @@ +import { OrganizationSchema as OrgSchema1 } from "@zitadel/proto/zitadel/org/v2/org_pb"; +// FYI Reparsing as ES module because module syntax was detected. This incurs a performance overhead. +import { OrganizationSchema as OrgSchema2 } from "@zitadel/proto/zitadel/org/v2/org_pb.js"; + +console.log("Legacy import test:"); +console.log("- Generated zitadel/org/v2/org_pb import (discouraged):", !!OrgSchema1); +console.log("- Generated zitadel/org/v2/org_pb.js import (recommended):", !!OrgSchema2); + +// Test successful if we can access these modules and they are the same type +if (OrgSchema1 && OrgSchema2 && OrgSchema1 === OrgSchema2) { + console.log("✅ Legacy import test passed!"); +} else { + console.error("❌ Legacy import test failed!"); + process.exit(1); +} diff --git a/packages/zitadel-proto/tsconfig.json b/packages/zitadel-proto/tsconfig.json new file mode 100644 index 0000000000..bdc2eb95bd --- /dev/null +++ b/packages/zitadel-proto/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "@zitadel/tsconfig/tsup.json", + "include": ["./src/**/*", "./zitadel/**/*"], + "exclude": ["dist", "build", "node_modules"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b28520f9e2..738a8bacb1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,7 +82,7 @@ importers: version: 2.1.3(react@19.0.0) '@tailwindcss/forms': specifier: 0.5.7 - version: 0.5.7(tailwindcss@3.4.14) + version: 0.5.7(tailwindcss@3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3))) '@vercel/analytics': specifier: ^1.2.2 version: 1.3.1(next@15.2.0-canary.33(@babel/core@7.26.0)(@playwright/test@1.48.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.80.7))(react@19.0.0) @@ -227,7 +227,7 @@ importers: version: 2.0.8 tailwindcss: specifier: 3.4.14 - version: 3.4.14 + version: 3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)) ts-proto: specifier: ^2.2.7 version: 2.2.7 @@ -298,15 +298,24 @@ importers: '@bufbuild/buf': specifier: ^1.47.2 version: 1.47.2 + '@zitadel/tsconfig': + specifier: workspace:* + version: link:../zitadel-tsconfig + ts-node: + specifier: ^10.9.2 + version: 10.9.2(@types/node@20.17.17)(typescript@5.6.3) + tsup: + specifier: ^8.0.0 + version: 8.3.5(jiti@1.21.6)(postcss@8.4.49)(typescript@5.6.3)(yaml@2.5.0) packages/zitadel-tailwind-config: devDependencies: '@tailwindcss/forms': specifier: 0.5.3 - version: 0.5.3(tailwindcss@3.4.14) + version: 0.5.3(tailwindcss@3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3))) tailwindcss: specifier: ^3.4.14 - version: 3.4.14 + version: 3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)) packages/zitadel-tsconfig: {} @@ -593,6 +602,10 @@ packages: peerDependencies: '@bufbuild/protobuf': ^2.2.0 + '@cspotcode/source-map-support@0.8.1': + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + '@cypress/request@3.0.6': resolution: {integrity: sha512-fi0eVdCOtKu5Ed6+E8mYxUF6ZTFJDZvHogCBelM0xVXmrDEkyM22gRArQzq1YcHPm1V47Vf/iAD+WgVdUlJCGg==} engines: {node: '>= 6'} @@ -1123,6 +1136,9 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + '@jridgewell/trace-mapping@0.3.9': + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + '@js-sdsl/ordered-map@4.4.2': resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==} @@ -1530,6 +1546,18 @@ packages: '@types/react-dom': optional: true + '@tsconfig/node10@1.0.11': + resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} + + '@tsconfig/node12@1.0.11': + resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} + + '@tsconfig/node14@1.0.3': + resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} + + '@tsconfig/node16@1.0.4': + resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} + '@types/aria-query@5.0.4': resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==} @@ -1729,6 +1757,10 @@ packages: peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + acorn-walk@8.3.4: + resolution: {integrity: sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==} + engines: {node: '>=0.4.0'} + acorn@8.12.1: resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} engines: {node: '>=0.4.0'} @@ -1799,6 +1831,9 @@ packages: engines: {node: '>=10'} deprecated: This package is no longer supported. + arg@4.1.3: + resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} + arg@5.0.2: resolution: {integrity: sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==} @@ -2148,6 +2183,9 @@ packages: core-util-is@1.0.2: resolution: {integrity: sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==} + create-require@1.1.1: + resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + cross-spawn@5.1.0: resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} @@ -2284,6 +2322,10 @@ packages: didyoumean@1.2.2: resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==} + diff@4.0.2: + resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} + engines: {node: '>=0.3.1'} + dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -3359,6 +3401,9 @@ packages: resolution: {integrity: sha512-G0yBotnlWVonPClw+tq+xi4K7DZC9n96HjGTBDdHkstAVsDkfZhi1sTvZypXLpyQTbISBkDtK0E5XlUqDsShQg==} engines: {node: '>=18'} + make-error@1.3.6: + resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + map-stream@0.1.0: resolution: {integrity: sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==} @@ -4467,6 +4512,20 @@ packages: ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} + ts-node@10.9.2: + resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + ts-poet@6.9.0: resolution: {integrity: sha512-roe6W6MeZmCjRmppyfOURklO5tQFQ6Sg7swURKkwYJvV7dbGCrK28um5+51iW3twdPRKtwarqFAVMU6G1mvnuQ==} @@ -4649,6 +4708,9 @@ packages: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true + v8-compile-cache-lib@3.0.1: + resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} + verror@1.10.0: resolution: {integrity: sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==} engines: {'0': node >=0.6.0} @@ -4862,6 +4924,10 @@ packages: yauzl@2.10.0: resolution: {integrity: sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==} + yn@3.1.1: + resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} + engines: {node: '>=6'} + yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} @@ -5230,6 +5296,10 @@ snapshots: dependencies: '@bufbuild/protobuf': 2.2.2 + '@cspotcode/source-map-support@0.8.1': + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + '@cypress/request@3.0.6': dependencies: aws-sign2: 0.7.0 @@ -5634,6 +5704,11 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 + '@jridgewell/trace-mapping@0.3.9': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.0 + '@js-sdsl/ordered-map@4.4.2': {} '@manypkg/find-root@1.1.0': @@ -5938,15 +6013,15 @@ snapshots: '@swc/counter': 0.1.3 tslib: 2.8.1 - '@tailwindcss/forms@0.5.3(tailwindcss@3.4.14)': + '@tailwindcss/forms@0.5.3(tailwindcss@3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)))': dependencies: mini-svg-data-uri: 1.4.4 - tailwindcss: 3.4.14 + tailwindcss: 3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)) - '@tailwindcss/forms@0.5.7(tailwindcss@3.4.14)': + '@tailwindcss/forms@0.5.7(tailwindcss@3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)))': dependencies: mini-svg-data-uri: 1.4.4 - tailwindcss: 3.4.14 + tailwindcss: 3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)) '@tanstack/react-virtual@3.10.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: @@ -5987,6 +6062,14 @@ snapshots: '@types/react': 19.0.2 '@types/react-dom': 19.0.2(@types/react@19.0.2) + '@tsconfig/node10@1.0.11': {} + + '@tsconfig/node12@1.0.11': {} + + '@tsconfig/node14@1.0.3': {} + + '@tsconfig/node16@1.0.4': {} + '@types/aria-query@5.0.4': {} '@types/babel__core@7.20.5': @@ -6222,6 +6305,10 @@ snapshots: dependencies: acorn: 8.12.1 + acorn-walk@8.3.4: + dependencies: + acorn: 8.12.1 + acorn@8.12.1: {} agent-base@6.0.2: @@ -6286,6 +6373,8 @@ snapshots: delegates: 1.0.0 readable-stream: 3.6.2 + arg@4.1.3: {} + arg@5.0.2: {} argparse@1.0.10: @@ -6648,6 +6737,8 @@ snapshots: core-util-is@1.0.2: {} + create-require@1.1.1: {} + cross-spawn@5.1.0: dependencies: lru-cache: 4.1.5 @@ -6840,6 +6931,8 @@ snapshots: didyoumean@1.2.2: {} + diff@4.0.2: {} + dir-glob@3.0.1: dependencies: path-type: 4.0.0 @@ -7114,7 +7207,7 @@ snapshots: debug: 4.3.7(supports-color@5.5.0) enhanced-resolve: 5.17.1 eslint: 8.57.1 - eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.1))(eslint@8.57.1) fast-glob: 3.3.2 get-tsconfig: 4.8.0 is-bun-module: 1.1.0 @@ -7127,7 +7220,7 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1): + eslint-module-utils@2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.1))(eslint@8.57.1): dependencies: debug: 3.2.7(supports-color@8.1.1) optionalDependencies: @@ -7148,7 +7241,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.1))(eslint@8.57.1) hasown: 2.0.2 is-core-module: 2.15.1 is-glob: 4.0.3 @@ -8152,6 +8245,8 @@ snapshots: make-dir@5.0.0: {} + make-error@1.3.6: {} + map-stream@0.1.0: {} meow@13.2.0: {} @@ -8509,12 +8604,13 @@ snapshots: camelcase-css: 2.0.1 postcss: 8.4.49 - postcss-load-config@4.0.2(postcss@8.4.49): + postcss-load-config@4.0.2(postcss@8.4.49)(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)): dependencies: lilconfig: 3.1.2 yaml: 2.5.0 optionalDependencies: postcss: 8.4.49 + ts-node: 10.9.2(@types/node@20.17.17)(typescript@5.6.3) postcss-load-config@6.0.1(jiti@1.21.6)(postcss@8.4.49)(yaml@2.5.0): dependencies: @@ -9094,7 +9190,7 @@ snapshots: tabbable@6.2.0: {} - tailwindcss@3.4.14: + tailwindcss@3.4.14(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -9113,7 +9209,7 @@ snapshots: postcss: 8.4.49 postcss-import: 15.1.0(postcss@8.4.49) postcss-js: 4.0.1(postcss@8.4.49) - postcss-load-config: 4.0.2(postcss@8.4.49) + postcss-load-config: 4.0.2(postcss@8.4.49)(ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3)) postcss-nested: 6.2.0(postcss@8.4.49) postcss-selector-parser: 6.1.2 resolve: 1.22.8 @@ -9211,6 +9307,24 @@ snapshots: ts-interface-checker@0.1.13: {} + ts-node@10.9.2(@types/node@20.17.17)(typescript@5.6.3): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.11 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 20.17.17 + acorn: 8.12.1 + acorn-walk: 8.3.4 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.6.3 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + ts-poet@6.9.0: dependencies: dprint-node: 1.0.8 @@ -9394,6 +9508,8 @@ snapshots: uuid@8.3.2: {} + v8-compile-cache-lib@3.0.1: {} + verror@1.10.0: dependencies: assert-plus: 1.0.0 @@ -9632,4 +9748,6 @@ snapshots: buffer-crc32: 0.2.13 fd-slicer: 1.1.0 + yn@3.1.1: {} + yocto-queue@0.1.0: {} From a023c5c57bc7cf2099ab1ea530a1c23f37206414 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Tue, 22 Apr 2025 14:59:26 +0200 Subject: [PATCH 06/10] v2 utils, v3 protos --- packages/zitadel-client/src/v2.ts | 29 ++++++++++++++++------------- packages/zitadel-proto/package.json | 4 ++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/zitadel-client/src/v2.ts b/packages/zitadel-client/src/v2.ts index 49cf901734..28b7cd1721 100644 --- a/packages/zitadel-client/src/v2.ts +++ b/packages/zitadel-client/src/v2.ts @@ -1,4 +1,4 @@ -import { create } from "@bufbuild/protobuf"; +import { MessageInitShape } from "@bufbuild/protobuf"; import { FeatureService } from "@zitadel/proto/zitadel/feature/v2/feature_service_pb.js"; import { IdentityProviderService } from "@zitadel/proto/zitadel/idp/v2/idp_service_pb.js"; import { RequestContextSchema } from "@zitadel/proto/zitadel/object/v2/object_pb.js"; @@ -11,17 +11,20 @@ import { UserService } from "@zitadel/proto/zitadel/user/v2/user_service_pb.js"; import { createClientFor } from "./helpers.js"; -export const createUserServiceClient = createClientFor(UserService); -export const createSettingsServiceClient = createClientFor(SettingsService); -export const createSessionServiceClient = createClientFor(SessionService); -export const createOIDCServiceClient = createClientFor(OIDCService); -export const createSAMLServiceClient = createClientFor(SAMLService); -export const createOrganizationServiceClient = createClientFor(OrganizationService); -export const createFeatureServiceClient = createClientFor(FeatureService); -export const createIdpServiceClient = createClientFor(IdentityProviderService); +export const createUserServiceClient: ReturnType> = createClientFor(UserService); +export const createSettingsServiceClient: ReturnType> = + createClientFor(SettingsService); +export const createSessionServiceClient: ReturnType> = + createClientFor(SessionService); +export const createOIDCServiceClient: ReturnType> = createClientFor(OIDCService); +export const createSAMLServiceClient: ReturnType> = createClientFor(SAMLService); +export const createOrganizationServiceClient: ReturnType> = + createClientFor(OrganizationService); +export const createFeatureServiceClient: ReturnType> = + createClientFor(FeatureService); +export const createIdpServiceClient: ReturnType> = + createClientFor(IdentityProviderService); -export function makeReqCtx(orgId: string | undefined) { - return create(RequestContextSchema, { - resourceOwner: orgId ? { case: "orgId", value: orgId } : { case: "instance", value: true }, - }); +export function makeReqCtx(orgId: string | undefined): MessageInitShape { + return { resourceOwner: orgId ? { case: "orgId", value: orgId } : { case: "instance", value: true } }; } diff --git a/packages/zitadel-proto/package.json b/packages/zitadel-proto/package.json index b738a0a63b..75f487b618 100644 --- a/packages/zitadel-proto/package.json +++ b/packages/zitadel-proto/package.json @@ -49,7 +49,7 @@ ], "sideEffects": false, "scripts": { - "generate": "buf generate https://github.com/zitadel/zitadel.git#tag=v2.71.7 --path ./proto/zitadel", + "generate": "buf generate https://github.com/zitadel/zitadel.git#tag=v3.0.0-rc.1 --path ./proto/zitadel", "clean": "rm -rf zitadel .turbo node_modules google protoc-gen-openapiv2 validate", "build": "tsup", "test:cjs": "node test/cjs-test.cjs", @@ -66,4 +66,4 @@ "ts-node": "^10.9.2", "@zitadel/tsconfig": "workspace:*" } -} \ No newline at end of file +} From ec5ee7c7971cddae90d395f41dd37d9fdf6d2190 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Tue, 22 Apr 2025 15:07:41 +0200 Subject: [PATCH 07/10] fix implicit error type --- apps/login/src/lib/self.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/login/src/lib/self.ts b/apps/login/src/lib/self.ts index d1971c19b1..130bcd66bc 100644 --- a/apps/login/src/lib/self.ts +++ b/apps/login/src/lib/self.ts @@ -1,5 +1,6 @@ "use server"; +import { ConnectError } from "@zitadel/client"; import { createServerTransport } from "@zitadel/client/node"; import { createUserServiceClient } from "@zitadel/client/v2"; import { headers } from "next/headers"; @@ -54,7 +55,7 @@ export async function setMyPassword({ }, {}, ) - .catch((error) => { + .catch((error: ConnectError) => { console.log(error); if (error.code === 7) { return { error: "Session is not valid." }; From 33eb6ca51d73c6485e12d642ddd5d6feee043257 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Tue, 22 Apr 2025 15:34:58 +0200 Subject: [PATCH 08/10] typing --- packages/zitadel-client/src/v1.ts | 11 +++++++---- packages/zitadel-client/src/v3alpha.ts | 5 ++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/zitadel-client/src/v1.ts b/packages/zitadel-client/src/v1.ts index d04180cf88..d54ce619e7 100644 --- a/packages/zitadel-client/src/v1.ts +++ b/packages/zitadel-client/src/v1.ts @@ -5,7 +5,10 @@ import { AuthService } from "@zitadel/proto/zitadel/auth_pb.js"; import { ManagementService } from "@zitadel/proto/zitadel/management_pb.js"; import { SystemService } from "@zitadel/proto/zitadel/system_pb.js"; -export const createAdminServiceClient = createClientFor(AdminService); -export const createAuthServiceClient = createClientFor(AuthService); -export const createManagementServiceClient = createClientFor(ManagementService); -export const createSystemServiceClient = createClientFor(SystemService); +export const createAdminServiceClient: ReturnType> = + createClientFor(AdminService); +export const createAuthServiceClient: ReturnType> = createClientFor(AuthService); +export const createManagementServiceClient: ReturnType> = + createClientFor(ManagementService); +export const createSystemServiceClient: ReturnType> = + createClientFor(SystemService); diff --git a/packages/zitadel-client/src/v3alpha.ts b/packages/zitadel-client/src/v3alpha.ts index a5cc533ade..81b25c746c 100644 --- a/packages/zitadel-client/src/v3alpha.ts +++ b/packages/zitadel-client/src/v3alpha.ts @@ -1,6 +1,5 @@ -import { ZITADELUsers } from "@zitadel/proto/zitadel/resources/user/v3alpha/user_service_pb.js"; import { ZITADELUserSchemas } from "@zitadel/proto/zitadel/resources/userschema/v3alpha/user_schema_service_pb.js"; import { createClientFor } from "./helpers.js"; -export const createUserSchemaServiceClient = createClientFor(ZITADELUserSchemas); -export const createUserServiceClient = createClientFor(ZITADELUsers); +export const createUserSchemaServiceClient: ReturnType> = + createClientFor(ZITADELUserSchemas); From 940f6a6982c9032e8dd33b953fc18418de0cf79f Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Tue, 22 Apr 2025 15:38:49 +0200 Subject: [PATCH 09/10] changesets --- .changeset/pretty-insects-attend.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/pretty-insects-attend.md diff --git a/.changeset/pretty-insects-attend.md b/.changeset/pretty-insects-attend.md new file mode 100644 index 0000000000..be8380bd91 --- /dev/null +++ b/.changeset/pretty-insects-attend.md @@ -0,0 +1,6 @@ +--- +"@zitadel/client": minor +"@zitadel/proto": minor +--- + +CJS and ESM support for @zitadel/proto From 6eb72c9a974c2561bee0dfe24d33b1afe409f496 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Tue, 29 Apr 2025 09:20:33 +0200 Subject: [PATCH 10/10] use main --- packages/zitadel-proto/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zitadel-proto/package.json b/packages/zitadel-proto/package.json index 5c0eac42f4..e4926ffcda 100644 --- a/packages/zitadel-proto/package.json +++ b/packages/zitadel-proto/package.json @@ -49,7 +49,7 @@ ], "sideEffects": false, "scripts": { - "generate": "buf generate https://github.com/zitadel/zitadel.git#tag=v3.0.0-rc.1 --path ./proto/zitadel", + "generate": "buf generate https://github.com/zitadel/zitadel.git --path ./proto/zitadel", "clean": "rm -rf zitadel .turbo node_modules google protoc-gen-openapiv2 validate", "build": "tsup", "test:cjs": "node test/cjs-test.cjs",