Skip to content

feat(zitadel-proto): add CJS and ESM support; export in Zitadel api s… #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tafaust
Copy link

@tafaust tafaust commented Mar 15, 2025

…tructure; add build configuration

Definition of Ready

  • I am happy with the code
  • Short description of the feature/issue is added in the pr description
  • PR is linked to the corresponding user story
  • Acceptance criteria are met
  • All open todos and follow ups are defined in a new ticket and justified
  • Deviations from the acceptance criteria and design are agreed with the PO and documented.
  • Vitest unit tests ensure that components produce expected outputs on different inputs.
  • Cypress integration tests ensure that login app pages work as expected on good and bad user inputs, ZITADEL responses or IDP redirects. The ZITADEL API is mocked, IDP redirects are simulated.
  • Playwright acceptances tests ensure that the happy paths of common user journeys work as expected. The ZITADEL API is not mocked but IDP redirects are simulated.
  • No debug or dead code
  • My code has no repetitions

Copy link

vercel bot commented Mar 15, 2025

@tafaust is attempting to deploy a commit to the zitadel Team on Vercel.

A member of the Team first needs to authorize it.

@muhlemmer muhlemmer requested a review from peintnermax March 17, 2025 10:32
@muhlemmer muhlemmer moved this to 📋 Sprint Backlog in Product Management Mar 17, 2025
Copy link

vercel bot commented Mar 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
typescript-login ❌ Failed (Inspect) Mar 18, 2025 7:12am

@peintnermax
Copy link
Member

Do you see a way to not have to map every service like we do in /src/v2.ts?
This breaks the client package and login completely as they rely on the old scheme 🤔

@tafaust
Copy link
Author

tafaust commented Mar 18, 2025

Ah, you're asking for an unstructured export on top of the structured export? Sure, I can add that!

@muhlemmer muhlemmer moved this from 📋 Sprint Backlog to 👀 In review in Product Management Mar 19, 2025
@tafaust
Copy link
Author

tafaust commented Mar 20, 2025

@peintnermax I added the required changes. Please be aware that apps/login/**/*.ts files sometimes do not respect ESM import syntax with .js (for example here:

import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
) and we thus end up with both of these entries in package.json:

https://github.com/tafaust/zitadel-typescript/blob/fbef66800ea6a32e82050dc72c7859e2e59eb1f8/packages/zitadel-proto/package.json#L32-L41

Side note: Import from "@zitadel/proto/zitadel/org/v2/org_pb" will be possible in ESM and CommonJS likewise even though imho it is discouraged and should be seen as legacy (and to be deprecated). CommonJS should import directly from the api versions and ESM should specify the file extension. The "./zitadel/*" export promotes bad coding behaviour imho. Interested in your opinion about deprecation efforts.

@tafaust
Copy link
Author

tafaust commented Mar 20, 2025

@peintnermax when writing a test for the legacy imports to work, I came across:

import { Organization as Org1 } from "@zitadel/proto/zitadel/org/v2/org_pb"; // does not work; has no exported member and defaults to the .d.ts file
import { Organization as Org2 } from "@zitadel/proto/zitadel/org/v2/org_pb.d.ts"; // works; exports the Organization type

Just to give you a taste what the omit of file ending (in a *.mjs file) will entail regarding my side note of the previous comment.

@tafaust
Copy link
Author

tafaust commented Mar 20, 2025

@peintnermax please let me know if you want me to drop commit 347b418.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

3 participants