Skip to content
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

Export Generated Types #252

Open
2 tasks done
wodka opened this issue Oct 29, 2024 · 4 comments
Open
2 tasks done

Export Generated Types #252

wodka opened this issue Oct 29, 2024 · 4 comments
Assignees
Labels
auth enhancement New feature or request login Login Application

Comments

@wodka
Copy link

wodka commented Oct 29, 2024

Preflight Checklist

  • I could not find a solution in the existing issues, docs, nor discussions
  • I have joined the ZITADEL chat

Describe your problem

I would like to type function that use part of the api response. when ie importing Profile the compile will crash:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/commonjs/api/generated/zitadel/user' is not defined by "exports"

Describe your ideal solution

export the generated types

    "./api/generated/*": {
      "import": "./dist/esm/api/generated/",
      "require": "./dist/commonjs/api/generated"
    },

Version

No response

Environment

Self-hosted

Additional Context

No response

@wodka wodka added the enhancement New feature or request label Oct 29, 2024
@hifabienne hifabienne added login Login Application auth labels Nov 18, 2024
@hifabienne hifabienne moved this to 🧐 Investigating in Product Management Nov 18, 2024
@livio-a
Copy link
Member

livio-a commented Nov 20, 2024

@peintnermax can you please have a look at this

@peintnermax
Copy link
Member

@wodka can you describe a little better what you try to achieve? How are you importing the types right now?

@wodka
Copy link
Author

wodka commented Nov 20, 2024

@peintnermax I would like to consume the generated types from the package as part of my implementation.

// this is the path where the file resides, but cannot import it
// import { Profile } from '@zitadel/node/dist/commonjs/api/generated/zitadel/user'

// this would be a nice import path that decides itself between commonjs and esm
// import { Profile } from '@zitadel/node/api/generated/zitadel/user'

function somewhere() {
  const response = await this.zitadel.getForOrg(user.zitadelResourceOwner).getHumanProfile({ userId: user.zitadel });

  return new UserDto(user, response.profile!);
}

class UserDto {
  constructor(user: UserEntity, p: Profile) {
    // beeing able to use the typed data in here!
  }
}

currently I am adding a copy of the zitadel profile type in my own code base, but it would be great to be able to use it from the package

@peintnermax
Copy link
Member

peintnermax commented Nov 20, 2024

@peintnermax I would like to consume the generated types from the package as part of my implementation.

// this is the path where the file resides, but cannot import it
// import { Profile } from '@zitadel/node/dist/commonjs/api/generated/zitadel/user'

// this would be a nice import path that decides itself between commonjs and esm
// import { Profile } from '@zitadel/node/api/generated/zitadel/user'

function somewhere() {
const response = await this.zitadel.getForOrg(user.zitadelResourceOwner).getHumanProfile({ userId: user.zitadel });

return new UserDto(user, response.profile!);
}

class UserDto {
constructor(user: UserEntity, p: Profile) {
// beeing able to use the typed data in here!
}
}
currently I am adding a copy of the zitadel profile type in my own code base, but it would be great to be able to use it from the package

Got it.. Types are exported by the package @zitadel/proto. Can you try if this fixes your issue?

import { User, UserState } from "@zitadel/proto/zitadel/user/v2/user_pb";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth enhancement New feature or request login Login Application
Projects
Status: 🧐 Investigating
Development

No branches or pull requests

4 participants