@stackframe/react 2.8.43 → 2.8.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/esm/lib/hooks.js +3 -0
- package/dist/esm/lib/hooks.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +29 -34
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +31 -25
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +15 -2
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +30 -36
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js +16 -0
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/esm/providers/stack-provider.js +2 -6
- package/dist/esm/providers/stack-provider.js.map +1 -1
- package/dist/index.d.mts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/lib/hooks.js +3 -0
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +28 -33
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +29 -23
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +15 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +28 -34
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/users/index.js +17 -0
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/dist/providers/stack-provider.js +1 -5
- package/dist/providers/stack-provider.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/lib/stack-app/users/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { UsersCrud } from \"@stackframe/stack-shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { encodeBase64 } from \"@stackframe/stack-shared/dist/utils/bytes\";\nimport { GeoInfo } from \"@stackframe/stack-shared/dist/utils/geo\";\nimport { ReadonlyJson } from \"@stackframe/stack-shared/dist/utils/json\";\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { ApiKeyCreationOptions, UserApiKey, UserApiKeyFirstView } from \"../api-keys\";\nimport { AsyncStoreProperty } from \"../common\";\nimport { OAuthConnection } from \"../connected-accounts\";\nimport { ContactChannel, ContactChannelCreateOptions, ServerContactChannel, ServerContactChannelCreateOptions } from \"../contact-channels\";\nimport { Customer } from \"../customers\";\nimport { NotificationCategory } from \"../notification-categories\";\nimport { AdminTeamPermission, TeamPermission } from \"../permissions\";\nimport { AdminOwnedProject, AdminProjectCreateOptions } from \"../projects\";\nimport { EditableTeamMemberProfile, ServerTeam, ServerTeamCreateOptions, Team, TeamCreateOptions } from \"../teams\";\n\nexport type OAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId?: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\nexport type ServerOAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\n\nexport type Session = {\n getTokens(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n};\n\n/**\n * Contains everything related to the current user session.\n */\nexport type Auth = {\n readonly _internalSession: InternalSession,\n readonly currentSession: Session,\n signOut(options?: { redirectUrl?: URL | string }): Promise<void>,\n\n /**\n * Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin\n * requests. Similar to `getAuthJson`, but specifically for HTTP requests.\n *\n * If you are using `tokenStore: \"cookie\"`, you don't need this for same-origin requests. However, most\n * browsers now disable third-party cookies by default, so we must pass authentication tokens by header instead\n * if the client and server are on different origins.\n *\n * This function returns a header object that can be used with `fetch` or other HTTP request libraries to send\n * authenticated requests.\n *\n * On the server, you can then pass in the `Request` object to the `tokenStore` option\n * of your Stack app. Please note that CORS does not allow most headers by default, so you\n * must include `x-stack-auth` in the [`Access-Control-Allow-Headers` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)\n * of the CORS preflight response.\n *\n * If you are not using HTTP (and hence cannot set headers), you will need to use the `getAuthJson()` function\n * instead.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await fetch(\"https://api.example.com\", {\n * headers: {\n * ...await stackApp.getAuthHeaders()\n * // you can also add your own headers here\n * },\n * });\n *\n * // server\n * function handleRequest(req: Request) {\n * const user = await stackServerApp.getUser({ tokenStore: req });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthHeaders(): Promise<{ \"x-stack-auth\": string }>,\n\n /**\n * Creates a JSON-serializable object containing the information to authenticate a user on an external server.\n * Similar to `getAuthHeaders`, but returns an object that can be sent over any protocol instead of just\n * HTTP headers.\n *\n * While `getAuthHeaders` is the recommended way to send authentication tokens over HTTP, your app may use\n * a different protocol, for example WebSockets or gRPC. This function returns a token object that can be JSON-serialized and sent to the server in any way you like.\n *\n * On the server, you can pass in this token object into the `tokenStore` option to fetch user details.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await rpcCall(rpcEndpoint, {\n * data: {\n * auth: await stackApp.getAuthJson(),\n * },\n * });\n *\n * // server\n * function handleRequest(data) {\n * const user = await stackServerApp.getUser({ tokenStore: data.auth });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthJson(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n};\n\n/**\n * ```\n * +----------+-------------+-------------------+\n * | \\ | !Server | Server |\n * +----------+-------------+-------------------+\n * | !Session | User | ServerUser |\n * | Session | CurrentUser | CurrentServerUser |\n * +----------+-------------+-------------------+\n * ```\n *\n * The fields on each of these types are available iff:\n * BaseUser: true\n * Auth: Session\n * ServerBaseUser: Server\n * UserExtra: Session OR Server\n *\n * The types are defined as follows (in the typescript manner):\n * User = BaseUser\n * CurrentUser = BaseUser & Auth & UserExtra\n * ServerUser = BaseUser & ServerBaseUser & UserExtra\n * CurrentServerUser = BaseUser & ServerBaseUser & Auth & UserExtra\n **/\n\nexport type BaseUser = {\n readonly id: string,\n\n readonly displayName: string | null,\n\n /**\n * The user's email address.\n *\n * Note: This might NOT be unique across multiple users, so always use `id` for unique identification.\n */\n readonly primaryEmail: string | null,\n readonly primaryEmailVerified: boolean,\n readonly profileImageUrl: string | null,\n\n readonly signedUpAt: Date,\n\n readonly clientMetadata: any,\n readonly clientReadOnlyMetadata: any,\n\n /**\n * Whether the user has a password set.\n */\n readonly hasPassword: boolean,\n readonly otpAuthEnabled: boolean,\n readonly passkeyAuthEnabled: boolean,\n\n readonly isMultiFactorRequired: boolean,\n readonly isAnonymous: boolean,\n toClientJson(): CurrentUserCrud[\"Client\"][\"Read\"],\n\n /**\n * @deprecated, use contact channel's usedForAuth instead\n */\n readonly emailAuthEnabled: boolean,\n /**\n * @deprecated\n */\n readonly oauthProviders: readonly { id: string }[],\n}\n\nexport type UserExtra = {\n setDisplayName(displayName: string): Promise<void>,\n /** @deprecated Use contact channel's sendVerificationEmail instead */\n sendVerificationEmail(): Promise<KnownErrors[\"EmailAlreadyVerified\"] | void>,\n setClientMetadata(metadata: any): Promise<void>,\n updatePassword(options: { oldPassword: string, newPassword: string}): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n setPassword(options: { password: string }): Promise<KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n\n /**\n * A shorthand method to update multiple fields of the user at once.\n */\n update(update: UserUpdateOptions): Promise<void>,\n\n useContactChannels(): ContactChannel[], // THIS_LINE_PLATFORM react-like\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n useNotificationCategories(): NotificationCategory[], // THIS_LINE_PLATFORM react-like\n listNotificationCategories(): Promise<NotificationCategory[]>,\n\n delete(): Promise<void>,\n\n getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>,\n getConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): Promise<OAuthConnection | null>,\n\n useConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): OAuthConnection,\n useConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): OAuthConnection | null,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n usePermissions(scope: Team, options?: { recursive?: boolean }): TeamPermission[],\n usePermissions(options?: { recursive?: boolean }): TeamPermission[],\n\n usePermission(scope: Team, permissionId: string): TeamPermission | null,\n usePermission(permissionId: string): TeamPermission | null,\n\n readonly selectedTeam: Team | null,\n setSelectedTeam(team: Team | null): Promise<void>,\n createTeam(data: TeamCreateOptions): Promise<Team>,\n leaveTeam(team: Team): Promise<void>,\n\n getActiveSessions(): Promise<ActiveSession[]>,\n revokeSession(sessionId: string): Promise<void>,\n getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>,\n useTeamProfile(team: Team): EditableTeamMemberProfile, // THIS_LINE_PLATFORM react-like\n\n createApiKey(options: ApiKeyCreationOptions<\"user\">): Promise<UserApiKeyFirstView>,\n\n useOAuthProviders(): OAuthProvider[], // THIS_LINE_PLATFORM react-like\n listOAuthProviders(): Promise<OAuthProvider[]>,\n\n useOAuthProvider(id: string): OAuthProvider | null, // THIS_LINE_PLATFORM react-like\n getOAuthProvider(id: string): Promise<OAuthProvider | null>,\n}\n& AsyncStoreProperty<\"apiKeys\", [], UserApiKey[], true>\n& AsyncStoreProperty<\"team\", [id: string], Team | null, false>\n& AsyncStoreProperty<\"teams\", [], Team[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { recursive?: boolean }], TeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { recursive?: boolean }], TeamPermission[], true>;\n\nexport type InternalUserExtra =\n & {\n createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>,\n transferProject(projectIdToTransfer: string, newTeamId: string): Promise<void>,\n }\n & AsyncStoreProperty<\"ownedProjects\", [], AdminOwnedProject[], true>\n\nexport type User = BaseUser;\n\nexport type CurrentUser = BaseUser & Auth & UserExtra & Customer;\n\nexport type CurrentInternalUser = CurrentUser & InternalUserExtra;\n\nexport type ProjectCurrentUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalUser : CurrentUser;\n\nexport type TokenPartialUser = Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"isAnonymous\"\n>\n\nexport type SyncedPartialUser = TokenPartialUser & Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"profileImageUrl\"\n | \"signedUpAt\"\n | \"clientMetadata\"\n | \"clientReadOnlyMetadata\"\n | \"isAnonymous\"\n | \"hasPassword\"\n>;\n\n\nexport type ActiveSession = {\n id: string,\n userId: string,\n createdAt: Date,\n isImpersonation: boolean,\n lastUsedAt: Date | undefined,\n isCurrentSession: boolean,\n geoInfo?: GeoInfo,\n};\n\nexport type UserUpdateOptions = {\n displayName?: string,\n clientMetadata?: ReadonlyJson,\n selectedTeamId?: string | null,\n totpMultiFactorSecret?: Uint8Array | null,\n profileImageUrl?: string | null,\n otpAuthEnabled?: boolean,\n passkeyAuthEnabled?:boolean,\n}\nexport function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n client_metadata: options.clientMetadata,\n selected_team_id: options.selectedTeamId,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n profile_image_url: options.profileImageUrl,\n otp_auth_enabled: options.otpAuthEnabled,\n passkey_auth_enabled: options.passkeyAuthEnabled,\n };\n}\n\n\nexport type ServerBaseUser = {\n setPrimaryEmail(email: string | null, options?: { verified?: boolean | undefined }): Promise<void>,\n\n readonly lastActiveAt: Date,\n\n readonly serverMetadata: any,\n setServerMetadata(metadata: any): Promise<void>,\n setClientReadOnlyMetadata(metadata: any): Promise<void>,\n\n createTeam(data: Omit<ServerTeamCreateOptions, \"creatorUserId\">): Promise<ServerTeam>,\n\n useContactChannels(): ServerContactChannel[], // THIS_LINE_PLATFORM react-like\n listContactChannels(): Promise<ServerContactChannel[]>,\n createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>,\n\n update(user: ServerUserUpdateOptions): Promise<void>,\n\n grantPermission(scope: Team, permissionId: string): Promise<void>,\n grantPermission(permissionId: string): Promise<void>,\n\n revokePermission(scope: Team, permissionId: string): Promise<void>,\n revokePermission(permissionId: string): Promise<void>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n usePermissions(scope: Team, options?: { recursive?: boolean }): TeamPermission[],\n usePermissions(options?: { recursive?: boolean }): TeamPermission[],\n\n usePermission(scope: Team, permissionId: string): TeamPermission | null,\n usePermission(permissionId: string): TeamPermission | null,\n\n useOAuthProviders(): ServerOAuthProvider[], // THIS_LINE_PLATFORM react-like\n listOAuthProviders(): Promise<ServerOAuthProvider[]>,\n\n useOAuthProvider(id: string): ServerOAuthProvider | null, // THIS_LINE_PLATFORM react-like\n getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>,\n\n /**\n * Creates a new session object with a refresh token for this user. Can be used to impersonate them.\n */\n createSession(options?: { expiresInMillis?: number, isImpersonation?: boolean }): Promise<Session>,\n}\n& AsyncStoreProperty<\"team\", [id: string], ServerTeam | null, false>\n& AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { direct?: boolean }], AdminTeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { direct?: boolean }], AdminTeamPermission[], true>;\n\n/**\n * A user including sensitive fields that should only be used on the server, never sent to the client\n * (such as sensitive information and serverMetadata).\n */\nexport type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;\n\nexport type CurrentServerUser = Auth & ServerUser;\n\nexport type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;\n\nexport type ProjectCurrentServerUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalServerUser : CurrentServerUser;\n\nexport type SyncedPartialServerUser = SyncedPartialUser & Pick<\n ServerUser,\n | \"serverMetadata\"\n>;\n\nexport type ServerUserUpdateOptions = {\n primaryEmail?: string | null,\n primaryEmailVerified?: boolean,\n primaryEmailAuthEnabled?: boolean,\n clientReadOnlyMetadata?: ReadonlyJson,\n serverMetadata?: ReadonlyJson,\n password?: string,\n} & UserUpdateOptions;\nexport function serverUserUpdateOptionsToCrud(options: ServerUserUpdateOptions): CurrentUserCrud[\"Server\"][\"Update\"] {\n return {\n display_name: options.displayName,\n primary_email: options.primaryEmail,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n selected_team_id: options.selectedTeamId,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n primary_email_verified: options.primaryEmailVerified,\n password: options.password,\n profile_image_url: options.profileImageUrl,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n };\n}\n\n\nexport type ServerUserCreateOptions = {\n primaryEmail?: string | null,\n primaryEmailAuthEnabled?: boolean,\n password?: string,\n otpAuthEnabled?: boolean,\n displayName?: string,\n primaryEmailVerified?: boolean,\n clientMetadata?: any,\n clientReadOnlyMetadata?: any,\n serverMetadata?: any,\n}\nexport function serverUserCreateOptionsToCrud(options: ServerUserCreateOptions): UsersCrud[\"Server\"][\"Create\"] {\n return {\n primary_email: options.primaryEmail,\n password: options.password,\n otp_auth_enabled: options.otpAuthEnabled,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n display_name: options.displayName,\n primary_email_verified: options.primaryEmailVerified,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n };\n}\n"],"mappings":";AAQA,SAAS,oBAAoB;AA0TtB,SAAS,wBAAwB,SAAiE;AACvG,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,IAClH,mBAAmB,QAAQ;AAAA,IAC3B,kBAAkB,QAAQ;AAAA,IAC1B,sBAAsB,QAAQ;AAAA,EAChC;AACF;AAkFO,SAAS,8BAA8B,SAAuE;AACnH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,eAAe,QAAQ;AAAA,IACvB,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,wBAAwB,QAAQ;AAAA,IAChC,UAAU,QAAQ;AAAA,IAClB,mBAAmB,QAAQ;AAAA,IAC3B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,EACpH;AACF;AAcO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,eAAe,QAAQ;AAAA,IACvB,UAAU,QAAQ;AAAA,IAClB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,wBAAwB,QAAQ;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,EAC3B;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/lib/stack-app/users/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { UsersCrud } from \"@stackframe/stack-shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { encodeBase64 } from \"@stackframe/stack-shared/dist/utils/bytes\";\nimport { GeoInfo } from \"@stackframe/stack-shared/dist/utils/geo\";\nimport { ReadonlyJson } from \"@stackframe/stack-shared/dist/utils/json\";\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { ApiKeyCreationOptions, UserApiKey, UserApiKeyFirstView } from \"../api-keys\";\nimport { AsyncStoreProperty } from \"../common\";\nimport { OAuthConnection } from \"../connected-accounts\";\nimport { ContactChannel, ContactChannelCreateOptions, ServerContactChannel, ServerContactChannelCreateOptions } from \"../contact-channels\";\nimport { Customer } from \"../customers\";\nimport { NotificationCategory } from \"../notification-categories\";\nimport { AdminTeamPermission, TeamPermission } from \"../permissions\";\nimport { AdminOwnedProject, AdminProjectCreateOptions } from \"../projects\";\nimport { EditableTeamMemberProfile, ServerTeam, ServerTeamCreateOptions, Team, TeamCreateOptions } from \"../teams\";\n\nconst userGetterErrorMessage = \"Stack Auth: useUser() already returns the user object. Use `const user = useUser()` (or `const user = await app.getUser()`) instead of destructuring it like `const { user } = ...`.\";\n\nexport function attachUserDestructureGuard(target: object): void {\n const descriptor = Object.getOwnPropertyDescriptor(target, \"user\");\n if (descriptor?.get === guardGetter) {\n return;\n }\n\n Object.defineProperty(target, \"user\", {\n get: guardGetter,\n configurable: false,\n enumerable: false,\n });\n}\n\nfunction guardGetter(): never {\n throw new Error(userGetterErrorMessage);\n}\n\nexport type OAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId?: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\nexport type ServerOAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\n\nexport type Session = {\n getTokens(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n};\n\n/**\n * Contains everything related to the current user session.\n */\nexport type Auth = {\n readonly _internalSession: InternalSession,\n readonly currentSession: Session,\n signOut(options?: { redirectUrl?: URL | string }): Promise<void>,\n\n /**\n * Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin\n * requests. Similar to `getAuthJson`, but specifically for HTTP requests.\n *\n * If you are using `tokenStore: \"cookie\"`, you don't need this for same-origin requests. However, most\n * browsers now disable third-party cookies by default, so we must pass authentication tokens by header instead\n * if the client and server are on different origins.\n *\n * This function returns a header object that can be used with `fetch` or other HTTP request libraries to send\n * authenticated requests.\n *\n * On the server, you can then pass in the `Request` object to the `tokenStore` option\n * of your Stack app. Please note that CORS does not allow most headers by default, so you\n * must include `x-stack-auth` in the [`Access-Control-Allow-Headers` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)\n * of the CORS preflight response.\n *\n * If you are not using HTTP (and hence cannot set headers), you will need to use the `getAuthJson()` function\n * instead.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await fetch(\"https://api.example.com\", {\n * headers: {\n * ...await stackApp.getAuthHeaders()\n * // you can also add your own headers here\n * },\n * });\n *\n * // server\n * function handleRequest(req: Request) {\n * const user = await stackServerApp.getUser({ tokenStore: req });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthHeaders(): Promise<{ \"x-stack-auth\": string }>,\n\n /**\n * Creates a JSON-serializable object containing the information to authenticate a user on an external server.\n * Similar to `getAuthHeaders`, but returns an object that can be sent over any protocol instead of just\n * HTTP headers.\n *\n * While `getAuthHeaders` is the recommended way to send authentication tokens over HTTP, your app may use\n * a different protocol, for example WebSockets or gRPC. This function returns a token object that can be JSON-serialized and sent to the server in any way you like.\n *\n * On the server, you can pass in this token object into the `tokenStore` option to fetch user details.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await rpcCall(rpcEndpoint, {\n * data: {\n * auth: await stackApp.getAuthJson(),\n * },\n * });\n *\n * // server\n * function handleRequest(data) {\n * const user = await stackServerApp.getUser({ tokenStore: data.auth });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthJson(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n};\n\n/**\n * ```\n * +----------+-------------+-------------------+\n * | \\ | !Server | Server |\n * +----------+-------------+-------------------+\n * | !Session | User | ServerUser |\n * | Session | CurrentUser | CurrentServerUser |\n * +----------+-------------+-------------------+\n * ```\n *\n * The fields on each of these types are available iff:\n * BaseUser: true\n * Auth: Session\n * ServerBaseUser: Server\n * UserExtra: Session OR Server\n *\n * The types are defined as follows (in the typescript manner):\n * User = BaseUser\n * CurrentUser = BaseUser & Auth & UserExtra\n * ServerUser = BaseUser & ServerBaseUser & UserExtra\n * CurrentServerUser = BaseUser & ServerBaseUser & Auth & UserExtra\n **/\n\nexport type BaseUser = {\n readonly id: string,\n\n readonly displayName: string | null,\n\n /**\n * The user's email address.\n *\n * Note: This might NOT be unique across multiple users, so always use `id` for unique identification.\n */\n readonly primaryEmail: string | null,\n readonly primaryEmailVerified: boolean,\n readonly profileImageUrl: string | null,\n\n readonly signedUpAt: Date,\n\n readonly clientMetadata: any,\n readonly clientReadOnlyMetadata: any,\n\n /**\n * Whether the user has a password set.\n */\n readonly hasPassword: boolean,\n readonly otpAuthEnabled: boolean,\n readonly passkeyAuthEnabled: boolean,\n\n readonly isMultiFactorRequired: boolean,\n readonly isAnonymous: boolean,\n toClientJson(): CurrentUserCrud[\"Client\"][\"Read\"],\n\n /**\n * @deprecated, use contact channel's usedForAuth instead\n */\n readonly emailAuthEnabled: boolean,\n /**\n * @deprecated\n */\n readonly oauthProviders: readonly { id: string }[],\n}\n\nexport type UserExtra = {\n setDisplayName(displayName: string): Promise<void>,\n /** @deprecated Use contact channel's sendVerificationEmail instead */\n sendVerificationEmail(): Promise<KnownErrors[\"EmailAlreadyVerified\"] | void>,\n setClientMetadata(metadata: any): Promise<void>,\n updatePassword(options: { oldPassword: string, newPassword: string}): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n setPassword(options: { password: string }): Promise<KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n\n /**\n * A shorthand method to update multiple fields of the user at once.\n */\n update(update: UserUpdateOptions): Promise<void>,\n\n useContactChannels(): ContactChannel[], // THIS_LINE_PLATFORM react-like\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n useNotificationCategories(): NotificationCategory[], // THIS_LINE_PLATFORM react-like\n listNotificationCategories(): Promise<NotificationCategory[]>,\n\n delete(): Promise<void>,\n\n getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>,\n getConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): Promise<OAuthConnection | null>,\n\n useConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): OAuthConnection,\n useConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): OAuthConnection | null,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n usePermissions(scope: Team, options?: { recursive?: boolean }): TeamPermission[],\n usePermissions(options?: { recursive?: boolean }): TeamPermission[],\n\n usePermission(scope: Team, permissionId: string): TeamPermission | null,\n usePermission(permissionId: string): TeamPermission | null,\n\n readonly selectedTeam: Team | null,\n setSelectedTeam(team: Team | null): Promise<void>,\n createTeam(data: TeamCreateOptions): Promise<Team>,\n leaveTeam(team: Team): Promise<void>,\n\n getActiveSessions(): Promise<ActiveSession[]>,\n revokeSession(sessionId: string): Promise<void>,\n getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>,\n useTeamProfile(team: Team): EditableTeamMemberProfile, // THIS_LINE_PLATFORM react-like\n\n createApiKey(options: ApiKeyCreationOptions<\"user\">): Promise<UserApiKeyFirstView>,\n\n useOAuthProviders(): OAuthProvider[], // THIS_LINE_PLATFORM react-like\n listOAuthProviders(): Promise<OAuthProvider[]>,\n\n useOAuthProvider(id: string): OAuthProvider | null, // THIS_LINE_PLATFORM react-like\n getOAuthProvider(id: string): Promise<OAuthProvider | null>,\n}\n& AsyncStoreProperty<\"apiKeys\", [], UserApiKey[], true>\n& AsyncStoreProperty<\"team\", [id: string], Team | null, false>\n& AsyncStoreProperty<\"teams\", [], Team[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { recursive?: boolean }], TeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { recursive?: boolean }], TeamPermission[], true>;\n\nexport type InternalUserExtra =\n & {\n createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>,\n transferProject(projectIdToTransfer: string, newTeamId: string): Promise<void>,\n }\n & AsyncStoreProperty<\"ownedProjects\", [], AdminOwnedProject[], true>\n\nexport type User = BaseUser;\n\nexport type CurrentUser = BaseUser & Auth & UserExtra & Customer;\n\nexport type CurrentInternalUser = CurrentUser & InternalUserExtra;\n\nexport type ProjectCurrentUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalUser : CurrentUser;\n\nexport type TokenPartialUser = Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"isAnonymous\"\n>\n\nexport type SyncedPartialUser = TokenPartialUser & Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"profileImageUrl\"\n | \"signedUpAt\"\n | \"clientMetadata\"\n | \"clientReadOnlyMetadata\"\n | \"isAnonymous\"\n | \"hasPassword\"\n>;\n\n\nexport type ActiveSession = {\n id: string,\n userId: string,\n createdAt: Date,\n isImpersonation: boolean,\n lastUsedAt: Date | undefined,\n isCurrentSession: boolean,\n geoInfo?: GeoInfo,\n};\n\nexport type UserUpdateOptions = {\n displayName?: string,\n clientMetadata?: ReadonlyJson,\n selectedTeamId?: string | null,\n totpMultiFactorSecret?: Uint8Array | null,\n profileImageUrl?: string | null,\n otpAuthEnabled?: boolean,\n passkeyAuthEnabled?:boolean,\n}\nexport function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n client_metadata: options.clientMetadata,\n selected_team_id: options.selectedTeamId,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n profile_image_url: options.profileImageUrl,\n otp_auth_enabled: options.otpAuthEnabled,\n passkey_auth_enabled: options.passkeyAuthEnabled,\n };\n}\n\n\nexport type ServerBaseUser = {\n setPrimaryEmail(email: string | null, options?: { verified?: boolean | undefined }): Promise<void>,\n\n readonly lastActiveAt: Date,\n\n readonly serverMetadata: any,\n setServerMetadata(metadata: any): Promise<void>,\n setClientReadOnlyMetadata(metadata: any): Promise<void>,\n\n createTeam(data: Omit<ServerTeamCreateOptions, \"creatorUserId\">): Promise<ServerTeam>,\n\n useContactChannels(): ServerContactChannel[], // THIS_LINE_PLATFORM react-like\n listContactChannels(): Promise<ServerContactChannel[]>,\n createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>,\n\n update(user: ServerUserUpdateOptions): Promise<void>,\n\n grantPermission(scope: Team, permissionId: string): Promise<void>,\n grantPermission(permissionId: string): Promise<void>,\n\n revokePermission(scope: Team, permissionId: string): Promise<void>,\n revokePermission(permissionId: string): Promise<void>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n usePermissions(scope: Team, options?: { recursive?: boolean }): TeamPermission[],\n usePermissions(options?: { recursive?: boolean }): TeamPermission[],\n\n usePermission(scope: Team, permissionId: string): TeamPermission | null,\n usePermission(permissionId: string): TeamPermission | null,\n\n useOAuthProviders(): ServerOAuthProvider[], // THIS_LINE_PLATFORM react-like\n listOAuthProviders(): Promise<ServerOAuthProvider[]>,\n\n useOAuthProvider(id: string): ServerOAuthProvider | null, // THIS_LINE_PLATFORM react-like\n getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>,\n\n /**\n * Creates a new session object with a refresh token for this user. Can be used to impersonate them.\n */\n createSession(options?: { expiresInMillis?: number, isImpersonation?: boolean }): Promise<Session>,\n}\n& AsyncStoreProperty<\"team\", [id: string], ServerTeam | null, false>\n& AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { direct?: boolean }], AdminTeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { direct?: boolean }], AdminTeamPermission[], true>;\n\n/**\n * A user including sensitive fields that should only be used on the server, never sent to the client\n * (such as sensitive information and serverMetadata).\n */\nexport type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;\n\nexport type CurrentServerUser = Auth & ServerUser;\n\nexport type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;\n\nexport type ProjectCurrentServerUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalServerUser : CurrentServerUser;\n\nexport type SyncedPartialServerUser = SyncedPartialUser & Pick<\n ServerUser,\n | \"serverMetadata\"\n>;\n\nexport type ServerUserUpdateOptions = {\n primaryEmail?: string | null,\n primaryEmailVerified?: boolean,\n primaryEmailAuthEnabled?: boolean,\n clientReadOnlyMetadata?: ReadonlyJson,\n serverMetadata?: ReadonlyJson,\n password?: string,\n} & UserUpdateOptions;\nexport function serverUserUpdateOptionsToCrud(options: ServerUserUpdateOptions): CurrentUserCrud[\"Server\"][\"Update\"] {\n return {\n display_name: options.displayName,\n primary_email: options.primaryEmail,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n selected_team_id: options.selectedTeamId,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n primary_email_verified: options.primaryEmailVerified,\n password: options.password,\n profile_image_url: options.profileImageUrl,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n };\n}\n\n\nexport type ServerUserCreateOptions = {\n primaryEmail?: string | null,\n primaryEmailAuthEnabled?: boolean,\n password?: string,\n otpAuthEnabled?: boolean,\n displayName?: string,\n primaryEmailVerified?: boolean,\n clientMetadata?: any,\n clientReadOnlyMetadata?: any,\n serverMetadata?: any,\n}\nexport function serverUserCreateOptionsToCrud(options: ServerUserCreateOptions): UsersCrud[\"Server\"][\"Create\"] {\n return {\n primary_email: options.primaryEmail,\n password: options.password,\n otp_auth_enabled: options.otpAuthEnabled,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n display_name: options.displayName,\n primary_email_verified: options.primaryEmailVerified,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n };\n}\n"],"mappings":";AAQA,SAAS,oBAAoB;AAe7B,IAAM,yBAAyB;AAExB,SAAS,2BAA2B,QAAsB;AAC/D,QAAM,aAAa,OAAO,yBAAyB,QAAQ,MAAM;AACjE,MAAI,YAAY,QAAQ,aAAa;AACnC;AAAA,EACF;AAEA,SAAO,eAAe,QAAQ,QAAQ;AAAA,IACpC,KAAK;AAAA,IACL,cAAc;AAAA,IACd,YAAY;AAAA,EACd,CAAC;AACH;AAEA,SAAS,cAAqB;AAC5B,QAAM,IAAI,MAAM,sBAAsB;AACxC;AA6SO,SAAS,wBAAwB,SAAiE;AACvG,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,IAClH,mBAAmB,QAAQ;AAAA,IAC3B,kBAAkB,QAAQ;AAAA,IAC1B,sBAAsB,QAAQ;AAAA,EAChC;AACF;AAkFO,SAAS,8BAA8B,SAAuE;AACnH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,eAAe,QAAQ;AAAA,IACvB,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,wBAAwB,QAAQ;AAAA,IAChC,UAAU,QAAQ;AAAA,IAClB,mBAAmB,QAAQ;AAAA,IAC3B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,EACpH;AACF;AAcO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,eAAe,QAAQ;AAAA,IACvB,UAAU,QAAQ;AAAA,IAClB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,wBAAwB,QAAQ;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,EAC3B;AACF;","names":[]}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
// src/providers/stack-provider.tsx
|
|
2
2
|
import { Suspense } from "react";
|
|
3
|
-
import { StackProviderClient
|
|
3
|
+
import { StackProviderClient } from "./stack-provider-client.js";
|
|
4
4
|
import { TranslationProvider } from "./translation-provider.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
function UserFetcher(props) {
|
|
7
|
-
const userPromise = props.app.getUser({ or: "anonymous-if-exists[deprecated]" }).then((user) => user?.toClientJson() ?? null);
|
|
8
|
-
return /* @__PURE__ */ jsx(UserSetter, { userJsonPromise: userPromise });
|
|
9
|
-
}
|
|
10
6
|
function ReactStackProvider({
|
|
11
7
|
children,
|
|
12
8
|
app,
|
|
@@ -14,7 +10,7 @@ function ReactStackProvider({
|
|
|
14
10
|
translationOverrides
|
|
15
11
|
}) {
|
|
16
12
|
return /* @__PURE__ */ jsxs(StackProviderClient, { app, serialized: false, children: [
|
|
17
|
-
/* @__PURE__ */ jsx(Suspense, { fallback: null
|
|
13
|
+
/* @__PURE__ */ jsx(Suspense, { fallback: null }),
|
|
18
14
|
/* @__PURE__ */ jsx(TranslationProvider, { lang, translationOverrides, children })
|
|
19
15
|
] });
|
|
20
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/providers/stack-provider.tsx"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport React, { Suspense } from 'react';\nimport { StackAdminApp, StackClientApp, StackServerApp, stackAppInternalsSymbol } from '../lib/stack-app';\nimport { StackProviderClient
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/stack-provider.tsx"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport React, { Suspense } from 'react';\nimport { StackAdminApp, StackClientApp, StackServerApp, stackAppInternalsSymbol } from '../lib/stack-app';\nimport { StackProviderClient } from './stack-provider-client';\nimport { TranslationProvider } from './translation-provider';\n\nfunction ReactStackProvider({\n children,\n app,\n lang,\n translationOverrides,\n}: {\n lang?: React.ComponentProps<typeof TranslationProvider>['lang'],\n /**\n * A mapping of English translations to translated equivalents.\n *\n * These will take priority over the translations from the language specified in the `lang` property. Note that the\n * keys are case-sensitive.\n */\n translationOverrides?: Record<string, string>,\n children: React.ReactNode,\n // list all three types of apps even though server and admin are subclasses of client so it's clear that you can pass any\n app: StackClientApp<true>,\n}) {\n return (\n <StackProviderClient app={app as any} serialized={false}>\n <Suspense fallback={null} />\n <TranslationProvider lang={lang} translationOverrides={translationOverrides}>\n {children}\n </TranslationProvider>\n </StackProviderClient>\n );\n}\n\nexport default ReactStackProvider;\n"],"mappings":";AAIA,SAAgB,gBAAgB;AAEhC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAqBhC,SACE,KADF;AAnBJ,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAYG;AACD,SACE,qBAAC,uBAAoB,KAAiB,YAAY,OAChD;AAAA,wBAAC,YAAS,UAAU,MAAM;AAAA,IAC1B,oBAAC,uBAAoB,MAAY,sBAC9B,UACH;AAAA,KACF;AAEJ;AAEA,IAAO,yBAAQ;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -931,11 +931,10 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
931
931
|
], CustomerProductsList, true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
932
932
|
declare const StackServerApp: StackServerAppConstructor;
|
|
933
933
|
|
|
934
|
-
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (
|
|
934
|
+
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
935
935
|
superSecretAdminKey?: string;
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
}));
|
|
936
|
+
projectOwnerSession?: InternalSession;
|
|
937
|
+
});
|
|
939
938
|
type StackAdminAppConstructor = {
|
|
940
939
|
new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
|
941
940
|
new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
|
|
@@ -1194,16 +1193,28 @@ type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId e
|
|
|
1194
1193
|
publishableClientKey?: string;
|
|
1195
1194
|
urls?: Partial<HandlerUrls>;
|
|
1196
1195
|
oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>;
|
|
1197
|
-
tokenStore
|
|
1196
|
+
tokenStore?: TokenStoreInit<HasTokenStore>;
|
|
1198
1197
|
redirectMethod?: RedirectMethod;
|
|
1198
|
+
inheritsFrom?: StackClientApp<any, any>;
|
|
1199
1199
|
/**
|
|
1200
1200
|
* By default, the Stack app will automatically prefetch some data from Stack's server when this app is first
|
|
1201
1201
|
* constructed. This improves the performance of your app, but will create network requests that are unnecessary if
|
|
1202
1202
|
* the app is never used or disposed of immediately. To disable this behavior, set this option to true.
|
|
1203
1203
|
*/
|
|
1204
1204
|
noAutomaticPrefetch?: boolean;
|
|
1205
|
-
}
|
|
1205
|
+
} & ({
|
|
1206
|
+
tokenStore: TokenStoreInit<HasTokenStore>;
|
|
1207
|
+
} | {
|
|
1208
|
+
tokenStore?: undefined;
|
|
1209
|
+
inheritsFrom: StackClientApp<HasTokenStore, any>;
|
|
1210
|
+
}) & (string extends ProjectId ? unknown : ({
|
|
1211
|
+
projectId: ProjectId;
|
|
1212
|
+
} | {
|
|
1213
|
+
inheritsFrom: StackClientApp<any, ProjectId>;
|
|
1214
|
+
}));
|
|
1206
1215
|
type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
1216
|
+
inheritsFrom?: undefined;
|
|
1217
|
+
} & {
|
|
1207
1218
|
uniqueIdentifier: string;
|
|
1208
1219
|
};
|
|
1209
1220
|
type StackClientAppConstructor = {
|
|
@@ -1310,6 +1321,9 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1310
1321
|
[stackAppInternalsSymbol]: {
|
|
1311
1322
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
1312
1323
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
1324
|
+
getConstructorOptions(): StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
1325
|
+
inheritsFrom?: undefined;
|
|
1326
|
+
};
|
|
1313
1327
|
};
|
|
1314
1328
|
} & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty<"item", [
|
|
1315
1329
|
{
|
package/dist/index.d.ts
CHANGED
|
@@ -931,11 +931,10 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
931
931
|
], CustomerProductsList, true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
932
932
|
declare const StackServerApp: StackServerAppConstructor;
|
|
933
933
|
|
|
934
|
-
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (
|
|
934
|
+
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
935
935
|
superSecretAdminKey?: string;
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
}));
|
|
936
|
+
projectOwnerSession?: InternalSession;
|
|
937
|
+
});
|
|
939
938
|
type StackAdminAppConstructor = {
|
|
940
939
|
new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
|
941
940
|
new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
|
|
@@ -1194,16 +1193,28 @@ type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId e
|
|
|
1194
1193
|
publishableClientKey?: string;
|
|
1195
1194
|
urls?: Partial<HandlerUrls>;
|
|
1196
1195
|
oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>;
|
|
1197
|
-
tokenStore
|
|
1196
|
+
tokenStore?: TokenStoreInit<HasTokenStore>;
|
|
1198
1197
|
redirectMethod?: RedirectMethod;
|
|
1198
|
+
inheritsFrom?: StackClientApp<any, any>;
|
|
1199
1199
|
/**
|
|
1200
1200
|
* By default, the Stack app will automatically prefetch some data from Stack's server when this app is first
|
|
1201
1201
|
* constructed. This improves the performance of your app, but will create network requests that are unnecessary if
|
|
1202
1202
|
* the app is never used or disposed of immediately. To disable this behavior, set this option to true.
|
|
1203
1203
|
*/
|
|
1204
1204
|
noAutomaticPrefetch?: boolean;
|
|
1205
|
-
}
|
|
1205
|
+
} & ({
|
|
1206
|
+
tokenStore: TokenStoreInit<HasTokenStore>;
|
|
1207
|
+
} | {
|
|
1208
|
+
tokenStore?: undefined;
|
|
1209
|
+
inheritsFrom: StackClientApp<HasTokenStore, any>;
|
|
1210
|
+
}) & (string extends ProjectId ? unknown : ({
|
|
1211
|
+
projectId: ProjectId;
|
|
1212
|
+
} | {
|
|
1213
|
+
inheritsFrom: StackClientApp<any, ProjectId>;
|
|
1214
|
+
}));
|
|
1206
1215
|
type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
1216
|
+
inheritsFrom?: undefined;
|
|
1217
|
+
} & {
|
|
1207
1218
|
uniqueIdentifier: string;
|
|
1208
1219
|
};
|
|
1209
1220
|
type StackClientAppConstructor = {
|
|
@@ -1310,6 +1321,9 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1310
1321
|
[stackAppInternalsSymbol]: {
|
|
1311
1322
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
1312
1323
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
1324
|
+
getConstructorOptions(): StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
1325
|
+
inheritsFrom?: undefined;
|
|
1326
|
+
};
|
|
1313
1327
|
};
|
|
1314
1328
|
} & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty<"item", [
|
|
1315
1329
|
{
|
package/dist/lib/hooks.js
CHANGED
|
@@ -38,6 +38,9 @@ function useUser(options = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
function useStackApp(options = {}) {
|
|
41
|
+
if (typeof import_react.useContext !== "function") {
|
|
42
|
+
throw new Error("useStackApp() can only be used in a React Client Component. Make sure you're not calling it from a Server Component, or any other environment.");
|
|
43
|
+
}
|
|
41
44
|
const context = (0, import_react.useContext)(import_stack_provider_client.StackContext);
|
|
42
45
|
if (context === null) {
|
|
43
46
|
throw new Error("useStackApp must be used within a StackProvider");
|
package/dist/lib/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/hooks.tsx"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { useContext } from \"react\";\nimport { StackContext } from \"../providers/stack-provider-client\";\nimport { GetUserOptions as AppGetUserOptions, CurrentInternalUser, CurrentUser, StackClientApp } from \"./stack-app\";\n\ntype GetUserOptions = AppGetUserOptions<true> & {\n projectIdMustMatch?: string,\n};\n\n/**\n * Returns the current user object. Equivalent to `useStackApp().useUser()`.\n *\n * @returns the current user\n */\nexport function useUser(options: GetUserOptions & { or: 'redirect' | 'throw', projectIdMustMatch: \"internal\" }): CurrentInternalUser;\nexport function useUser(options: GetUserOptions & { or: 'redirect' | 'throw' }): CurrentUser;\nexport function useUser(options: GetUserOptions & { projectIdMustMatch: \"internal\" }): CurrentInternalUser | null;\nexport function useUser(options?: GetUserOptions): CurrentUser | CurrentInternalUser | null;\nexport function useUser(options: GetUserOptions = {}): CurrentUser | CurrentInternalUser | null {\n const stackApp = useStackApp(options);\n if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {\n throw new Error(\"Unexpected project ID in useStackApp: \" + stackApp.projectId);\n }\n if (options.projectIdMustMatch === \"internal\") {\n return stackApp.useUser(options) as CurrentInternalUser;\n } else {\n return stackApp.useUser(options) as CurrentUser;\n }\n}\n\n/**\n * Returns the current Stack app associated with the StackProvider.\n *\n * @returns the current Stack app\n */\nexport function useStackApp<ProjectId extends string>(options: { projectIdMustMatch?: ProjectId } = {}): StackClientApp<true, ProjectId> {\n const context = useContext(StackContext);\n if (context === null) {\n throw new Error(\"useStackApp must be used within a StackProvider\");\n }\n const stackApp = context.app;\n if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {\n throw new Error(\"Unexpected project ID in useStackApp: \" + stackApp.projectId);\n }\n return stackApp as StackClientApp<true, ProjectId>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAA2B;AAC3B,mCAA6B;AAgBtB,SAAS,QAAQ,UAA0B,CAAC,GAA6C;AAC9F,QAAM,WAAW,YAAY,OAAO;AACpC,MAAI,QAAQ,sBAAsB,SAAS,cAAc,QAAQ,oBAAoB;AACnF,UAAM,IAAI,MAAM,2CAA2C,SAAS,SAAS;AAAA,EAC/E;AACA,MAAI,QAAQ,uBAAuB,YAAY;AAC7C,WAAO,SAAS,QAAQ,OAAO;AAAA,EACjC,OAAO;AACL,WAAO,SAAS,QAAQ,OAAO;AAAA,EACjC;AACF;AAOO,SAAS,YAAsC,UAA8C,CAAC,GAAoC;AACvI,QAAM,cAAU,yBAAW,yCAAY;AACvC,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,iDAAiD;AAAA,EACnE;AACA,QAAM,WAAW,QAAQ;AACzB,MAAI,QAAQ,sBAAsB,SAAS,cAAc,QAAQ,oBAAoB;AACnF,UAAM,IAAI,MAAM,2CAA2C,SAAS,SAAS;AAAA,EAC/E;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/hooks.tsx"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { useContext } from \"react\";\nimport { StackContext } from \"../providers/stack-provider-client\";\nimport { GetUserOptions as AppGetUserOptions, CurrentInternalUser, CurrentUser, StackClientApp } from \"./stack-app\";\n\ntype GetUserOptions = AppGetUserOptions<true> & {\n projectIdMustMatch?: string,\n};\n\n/**\n * Returns the current user object. Equivalent to `useStackApp().useUser()`.\n *\n * @returns the current user\n */\nexport function useUser(options: GetUserOptions & { or: 'redirect' | 'throw', projectIdMustMatch: \"internal\" }): CurrentInternalUser;\nexport function useUser(options: GetUserOptions & { or: 'redirect' | 'throw' }): CurrentUser;\nexport function useUser(options: GetUserOptions & { projectIdMustMatch: \"internal\" }): CurrentInternalUser | null;\nexport function useUser(options?: GetUserOptions): CurrentUser | CurrentInternalUser | null;\nexport function useUser(options: GetUserOptions = {}): CurrentUser | CurrentInternalUser | null {\n const stackApp = useStackApp(options);\n if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {\n throw new Error(\"Unexpected project ID in useStackApp: \" + stackApp.projectId);\n }\n if (options.projectIdMustMatch === \"internal\") {\n return stackApp.useUser(options) as CurrentInternalUser;\n } else {\n return stackApp.useUser(options) as CurrentUser;\n }\n}\n\n/**\n * Returns the current Stack app associated with the StackProvider.\n *\n * @returns the current Stack app\n */\nexport function useStackApp<ProjectId extends string>(options: { projectIdMustMatch?: ProjectId } = {}): StackClientApp<true, ProjectId> {\n if (typeof useContext !== \"function\") {\n throw new Error(\"useStackApp() can only be used in a React Client Component. Make sure you're not calling it from a Server Component, or any other environment.\");\n }\n const context = useContext(StackContext);\n if (context === null) {\n throw new Error(\"useStackApp must be used within a StackProvider\");\n }\n const stackApp = context.app;\n if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {\n throw new Error(\"Unexpected project ID in useStackApp: \" + stackApp.projectId);\n }\n return stackApp as StackClientApp<true, ProjectId>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAA2B;AAC3B,mCAA6B;AAgBtB,SAAS,QAAQ,UAA0B,CAAC,GAA6C;AAC9F,QAAM,WAAW,YAAY,OAAO;AACpC,MAAI,QAAQ,sBAAsB,SAAS,cAAc,QAAQ,oBAAoB;AACnF,UAAM,IAAI,MAAM,2CAA2C,SAAS,SAAS;AAAA,EAC/E;AACA,MAAI,QAAQ,uBAAuB,YAAY;AAC7C,WAAO,SAAS,QAAQ,OAAO;AAAA,EACjC,OAAO;AACL,WAAO,SAAS,QAAQ,OAAO;AAAA,EACjC;AACF;AAOO,SAAS,YAAsC,UAA8C,CAAC,GAAoC;AACvI,MAAI,OAAO,4BAAe,YAAY;AACpC,UAAM,IAAI,MAAM,gJAAgJ;AAAA,EAClK;AACA,QAAM,cAAU,yBAAW,yCAAY;AACvC,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,iDAAiD;AAAA,EACnE;AACA,QAAM,WAAW,QAAQ;AACzB,MAAI,QAAQ,sBAAsB,SAAS,cAAc,QAAQ,oBAAoB;AACnF,UAAM,IAAI,MAAM,2CAA2C,SAAS,SAAS;AAAA,EAC/E;AACA,SAAO;AACT;","names":[]}
|
|
@@ -37,28 +37,23 @@ var import_common2 = require("./common.js");
|
|
|
37
37
|
var import_server_app_impl = require("./server-app-impl.js");
|
|
38
38
|
var import_common3 = require("./common.js");
|
|
39
39
|
var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackServerAppImplIncomplete {
|
|
40
|
-
constructor(options) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
constructor(options, extraOptions) {
|
|
41
|
+
const resolvedOptions = (0, import_common2.resolveConstructorOptions)(options);
|
|
42
|
+
super(resolvedOptions, {
|
|
43
|
+
...extraOptions,
|
|
44
|
+
interface: extraOptions?.interface ?? new import_stack_shared.StackAdminInterface({
|
|
45
|
+
getBaseUrl: () => (0, import_common2.getBaseUrl)(resolvedOptions.baseUrl),
|
|
46
|
+
projectId: resolvedOptions.projectId ?? (0, import_common2.getDefaultProjectId)(),
|
|
47
|
+
extraRequestHeaders: resolvedOptions.extraRequestHeaders ?? (0, import_common2.getDefaultExtraRequestHeaders)(),
|
|
46
48
|
clientVersion: import_common2.clientVersion,
|
|
47
|
-
...
|
|
48
|
-
projectOwnerSession:
|
|
49
|
+
...resolvedOptions.projectOwnerSession ? {
|
|
50
|
+
projectOwnerSession: resolvedOptions.projectOwnerSession
|
|
49
51
|
} : {
|
|
50
|
-
publishableClientKey:
|
|
51
|
-
secretServerKey:
|
|
52
|
-
superSecretAdminKey:
|
|
52
|
+
publishableClientKey: resolvedOptions.publishableClientKey ?? (0, import_common2.getDefaultPublishableClientKey)(),
|
|
53
|
+
secretServerKey: resolvedOptions.secretServerKey ?? (0, import_common2.getDefaultSecretServerKey)(),
|
|
54
|
+
superSecretAdminKey: resolvedOptions.superSecretAdminKey ?? (0, import_common2.getDefaultSuperSecretAdminKey)()
|
|
53
55
|
}
|
|
54
|
-
})
|
|
55
|
-
baseUrl: options.baseUrl,
|
|
56
|
-
extraRequestHeaders: options.extraRequestHeaders,
|
|
57
|
-
projectId: options.projectId,
|
|
58
|
-
tokenStore: options.tokenStore,
|
|
59
|
-
urls: options.urls,
|
|
60
|
-
oauthScopesOnSignIn: options.oauthScopesOnSignIn,
|
|
61
|
-
redirectMethod: options.redirectMethod
|
|
56
|
+
})
|
|
62
57
|
});
|
|
63
58
|
this._adminProjectCache = (0, import_common2.createCache)(async () => {
|
|
64
59
|
return await this._interface.getProject();
|
|
@@ -184,7 +179,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
184
179
|
return app._adminConfigFromCrud(await app._interface.getConfig());
|
|
185
180
|
},
|
|
186
181
|
useConfig() {
|
|
187
|
-
const config = (0, import_common3.useAsyncCache)(app._configOverridesCache, [], "useConfig()");
|
|
182
|
+
const config = (0, import_common3.useAsyncCache)(app._configOverridesCache, [], "project.useConfig()");
|
|
188
183
|
return (0, import_react.useMemo)(() => app._adminConfigFromCrud(config), [config]);
|
|
189
184
|
},
|
|
190
185
|
async updateConfig(configOverride) {
|
|
@@ -222,7 +217,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
222
217
|
);
|
|
223
218
|
}
|
|
224
219
|
useProject() {
|
|
225
|
-
const crud = (0, import_common3.useAsyncCache)(this._adminProjectCache, [], "
|
|
220
|
+
const crud = (0, import_common3.useAsyncCache)(this._adminProjectCache, [], "adminApp.useProject()");
|
|
226
221
|
return (0, import_react.useMemo)(() => this._adminProjectFromCrud(
|
|
227
222
|
crud,
|
|
228
223
|
() => this._refreshProject()
|
|
@@ -272,7 +267,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
272
267
|
return crud.map((j) => this._createInternalApiKeyFromCrud(j));
|
|
273
268
|
}
|
|
274
269
|
useInternalApiKeys() {
|
|
275
|
-
const crud = (0, import_common3.useAsyncCache)(this._internalApiKeysCache, [], "useInternalApiKeys()");
|
|
270
|
+
const crud = (0, import_common3.useAsyncCache)(this._internalApiKeysCache, [], "adminApp.useInternalApiKeys()");
|
|
276
271
|
return (0, import_react.useMemo)(() => {
|
|
277
272
|
return crud.map((j) => this._createInternalApiKeyFromCrud(j));
|
|
278
273
|
}, [crud]);
|
|
@@ -283,7 +278,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
283
278
|
return this._createInternalApiKeyFirstViewFromCrud(crud);
|
|
284
279
|
}
|
|
285
280
|
useEmailThemes() {
|
|
286
|
-
const crud = (0, import_common3.useAsyncCache)(this._adminEmailThemesCache, [], "useEmailThemes()");
|
|
281
|
+
const crud = (0, import_common3.useAsyncCache)(this._adminEmailThemesCache, [], "adminApp.useEmailThemes()");
|
|
287
282
|
return (0, import_react.useMemo)(() => {
|
|
288
283
|
return crud.map((theme) => ({
|
|
289
284
|
id: theme.id,
|
|
@@ -292,7 +287,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
292
287
|
}, [crud]);
|
|
293
288
|
}
|
|
294
289
|
useEmailTemplates() {
|
|
295
|
-
const crud = (0, import_common3.useAsyncCache)(this._adminEmailTemplatesCache, [], "useEmailTemplates()");
|
|
290
|
+
const crud = (0, import_common3.useAsyncCache)(this._adminEmailTemplatesCache, [], "adminApp.useEmailTemplates()");
|
|
296
291
|
return (0, import_react.useMemo)(() => {
|
|
297
292
|
return crud.map((template) => ({
|
|
298
293
|
id: template.id,
|
|
@@ -303,7 +298,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
303
298
|
}, [crud]);
|
|
304
299
|
}
|
|
305
300
|
useEmailDrafts() {
|
|
306
|
-
const crud = (0, import_common3.useAsyncCache)(this._adminEmailDraftsCache, [], "useEmailDrafts()");
|
|
301
|
+
const crud = (0, import_common3.useAsyncCache)(this._adminEmailDraftsCache, [], "adminApp.useEmailDrafts()");
|
|
307
302
|
return (0, import_react.useMemo)(() => {
|
|
308
303
|
return crud.map((draft) => ({
|
|
309
304
|
id: draft.id,
|
|
@@ -358,7 +353,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
358
353
|
return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));
|
|
359
354
|
}
|
|
360
355
|
useTeamPermissionDefinitions() {
|
|
361
|
-
const crud = (0, import_common3.useAsyncCache)(this._adminTeamPermissionDefinitionsCache, [], "
|
|
356
|
+
const crud = (0, import_common3.useAsyncCache)(this._adminTeamPermissionDefinitionsCache, [], "adminApp.useTeamPermissionDefinitions()");
|
|
362
357
|
return (0, import_react.useMemo)(() => {
|
|
363
358
|
return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));
|
|
364
359
|
}, [crud]);
|
|
@@ -381,13 +376,13 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
381
376
|
return crud.map((p) => this._serverProjectPermissionDefinitionFromCrud(p));
|
|
382
377
|
}
|
|
383
378
|
useProjectPermissionDefinitions() {
|
|
384
|
-
const crud = (0, import_common3.useAsyncCache)(this._adminProjectPermissionDefinitionsCache, [], "
|
|
379
|
+
const crud = (0, import_common3.useAsyncCache)(this._adminProjectPermissionDefinitionsCache, [], "adminApp.useProjectPermissionDefinitions()");
|
|
385
380
|
return (0, import_react.useMemo)(() => {
|
|
386
381
|
return crud.map((p) => this._serverProjectPermissionDefinitionFromCrud(p));
|
|
387
382
|
}, [crud]);
|
|
388
383
|
}
|
|
389
384
|
useSvixToken() {
|
|
390
|
-
const crud = (0, import_common3.useAsyncCache)(this._svixTokenCache, [], "useSvixToken()");
|
|
385
|
+
const crud = (0, import_common3.useAsyncCache)(this._svixTokenCache, [], "adminApp.useSvixToken()");
|
|
391
386
|
return crud.token;
|
|
392
387
|
}
|
|
393
388
|
async _refreshProject() {
|
|
@@ -403,7 +398,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
403
398
|
return {
|
|
404
399
|
...super[import_common.stackAppInternalsSymbol],
|
|
405
400
|
useMetrics: (includeAnonymous = false) => {
|
|
406
|
-
return (0, import_common3.useAsyncCache)(this._metricsCache, [includeAnonymous], "useMetrics()");
|
|
401
|
+
return (0, import_common3.useAsyncCache)(this._metricsCache, [includeAnonymous], "adminApp.useMetrics()");
|
|
407
402
|
}
|
|
408
403
|
};
|
|
409
404
|
}
|
|
@@ -476,11 +471,11 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
476
471
|
return (await this._interface.renderEmailPreview(options)).html;
|
|
477
472
|
}
|
|
478
473
|
useEmailPreview(options) {
|
|
479
|
-
const crud = (0, import_common3.useAsyncCache)(this._emailPreviewCache, [options.themeId, options.themeTsxSource, options.templateId, options.templateTsxSource], "useEmailPreview()");
|
|
474
|
+
const crud = (0, import_common3.useAsyncCache)(this._emailPreviewCache, [options.themeId, options.themeTsxSource, options.templateId, options.templateTsxSource], "adminApp.useEmailPreview()");
|
|
480
475
|
return crud.html;
|
|
481
476
|
}
|
|
482
477
|
useEmailTheme(id) {
|
|
483
|
-
const crud = (0, import_common3.useAsyncCache)(this._adminEmailThemeCache, [id], "useEmailTheme()");
|
|
478
|
+
const crud = (0, import_common3.useAsyncCache)(this._adminEmailThemeCache, [id], "adminApp.useEmailTheme()");
|
|
484
479
|
return {
|
|
485
480
|
displayName: crud.display_name,
|
|
486
481
|
tsxSource: crud.tsx_source
|
|
@@ -516,14 +511,14 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
516
511
|
return crud;
|
|
517
512
|
}
|
|
518
513
|
useTransactions(params) {
|
|
519
|
-
const data = (0, import_common3.useAsyncCache)(this._transactionsCache, [params.cursor, params.limit, params.type, params.customerType], "useTransactions()");
|
|
514
|
+
const data = (0, import_common3.useAsyncCache)(this._transactionsCache, [params.cursor, params.limit, params.type, params.customerType], "adminApp.useTransactions()");
|
|
520
515
|
return data;
|
|
521
516
|
}
|
|
522
517
|
async getStripeAccountInfo() {
|
|
523
518
|
return await this._interface.getStripeAccountInfo();
|
|
524
519
|
}
|
|
525
520
|
useStripeAccountInfo() {
|
|
526
|
-
const data = (0, import_common3.useAsyncCache)(this._stripeAccountInfoCache, [], "useStripeAccountInfo()");
|
|
521
|
+
const data = (0, import_common3.useAsyncCache)(this._stripeAccountInfoCache, [], "adminApp.useStripeAccountInfo()");
|
|
527
522
|
return data;
|
|
528
523
|
}
|
|
529
524
|
};
|