@hexclave/js 1.0.103 → 1.0.105
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/dist/{admin-app-impl-ksLk70Sj.d.ts → admin-app-impl-BebuSYtn.d.ts} +14 -14
- package/dist/{admin-app-impl-ksLk70Sj.d.ts.map → admin-app-impl-BebuSYtn.d.ts.map} +1 -1
- package/dist/clickmap/clickmap-core.d.ts +1 -1
- package/dist/clickmap/index.d.ts +1 -1
- package/dist/{client-app-CdAaCL3p.d.ts → client-app-Cri37vaC.d.ts} +10 -10
- package/dist/client-app-Cri37vaC.d.ts.map +1 -0
- package/dist/dev-tool/dev-tool-core.d.ts +1 -1
- package/dist/dev-tool/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +2 -12
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.js +0 -87
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +22 -2
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/common.js +2 -2
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js +21 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +10 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js +87 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/admin-app.d.ts +1 -11
- package/dist/esm/lib/hexclave-app/apps/interfaces/admin-app.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/server-app.d.ts +11 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/server-app.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/hexclave-app/index.d.ts +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.js +0 -87
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +22 -2
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
- package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js +21 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js +87 -0
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/hexclave-app/apps/index.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/interfaces/admin-app.d.ts +2 -3
- package/dist/lib/hexclave-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/hexclave-app/apps/interfaces/client-app.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/interfaces/server-app.d.ts +3 -2
- package/dist/lib/hexclave-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/hexclave-app/index.d.ts +3 -2
- package/dist/lib/hexclave-app/projects/index.d.ts +1 -1
- package/dist/lib/hexclave-app/teams/index.d.ts +1 -1
- package/dist/lib/hexclave-app/users/index.d.ts +1 -1
- package/dist/pushed-config-error-overlay/index.d.ts +1 -1
- package/dist/{redirect-page-urls-Cu5BRQwm.d.ts → redirect-page-urls-BLceehT4.d.ts} +2 -2
- package/dist/{redirect-page-urls-Cu5BRQwm.d.ts.map → redirect-page-urls-BLceehT4.d.ts.map} +1 -1
- package/package.json +2 -2
- package/src/lib/hexclave-app/apps/implementations/admin-app-impl.ts +0 -100
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.ts +31 -2
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +3 -1
- package/src/lib/hexclave-app/apps/implementations/redirect-page-urls.test.ts +24 -1
- package/src/lib/hexclave-app/apps/implementations/redirect-page-urls.ts +2 -2
- package/src/lib/hexclave-app/apps/implementations/server-app-impl.ts +100 -0
- package/src/lib/hexclave-app/apps/interfaces/admin-app.ts +0 -9
- package/src/lib/hexclave-app/apps/interfaces/server-app.ts +11 -0
- package/src/lib/hexclave-app/index.ts +10 -0
- package/dist/client-app-CdAaCL3p.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-app-impl.js","names":["_HexclaveClientAppImplIncomplete","Result","KnownErrors","HexclaveServerInterface","HexclaveAssertionError","opts","WebAuthnError","InternalSession"],"sources":["../../../../../src/lib/hexclave-app/apps/implementations/server-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\nimport { HexclaveServerInterface, KnownErrors } from \"@hexclave/shared\";\nimport type { AnalyticsQueryOptions, AnalyticsQueryResponse } from \"@hexclave/shared/dist/interface/crud/analytics\";\nimport { ContactChannelsCrud } from \"@hexclave/shared/dist/interface/crud/contact-channels\";\nimport { ItemCrud } from \"@hexclave/shared/dist/interface/crud/items\";\nimport { NotificationPreferenceCrud } from \"@hexclave/shared/dist/interface/crud/notification-preferences\";\nimport { OAuthProviderCrud } from \"@hexclave/shared/dist/interface/crud/oauth-providers\";\nimport type { CustomerProductsListResponse } from \"@hexclave/shared/dist/interface/crud/products\";\nimport { TeamApiKeysCrud, UserApiKeysCrud, teamApiKeysCreateOutputSchema, userApiKeysCreateOutputSchema } from \"@hexclave/shared/dist/interface/crud/project-api-keys\";\nimport { ProjectPermissionDefinitionsCrud, ProjectPermissionsCrud } from \"@hexclave/shared/dist/interface/crud/project-permissions\";\nimport { TeamInvitationCrud } from \"@hexclave/shared/dist/interface/crud/team-invitation\";\nimport { TeamMemberProfilesCrud } from \"@hexclave/shared/dist/interface/crud/team-member-profiles\";\nimport { TeamPermissionDefinitionsCrud, TeamPermissionsCrud } from \"@hexclave/shared/dist/interface/crud/team-permissions\";\nimport { TeamsCrud } from \"@hexclave/shared/dist/interface/crud/teams\";\nimport { UsersCrud } from \"@hexclave/shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@hexclave/shared/dist/sessions\";\nimport type { AsyncCache } from \"@hexclave/shared/dist/utils/caches\";\nimport { HexclaveAssertionError, captureError, throwErr } from \"@hexclave/shared/dist/utils/errors\";\nimport { ProviderType } from \"@hexclave/shared/dist/utils/oauth\";\nimport { runAsynchronously } from \"@hexclave/shared/dist/utils/promises\";\nimport { suspend } from \"@hexclave/shared/dist/utils/react\";\nimport { Result } from \"@hexclave/shared/dist/utils/results\";\nimport { isUuid } from \"@hexclave/shared/dist/utils/uuids\";\nimport { WebAuthnError, startRegistration } from \"@simplewebauthn/browser\";\nimport * as yup from \"yup\";\nimport { constructRedirectUrl } from \"../../../../utils/url\";\nimport { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud, apiKeyUpdateOptionsToCrud } from \"../../api-keys\";\nimport { ConvexCtx, GetCurrentUserOptions } from \"../../common\";\nimport { DeprecatedOAuthConnection, OAuthConnection } from \"../../connected-accounts\";\nimport { ServerContactChannel, ServerContactChannelCreateOptions, ServerContactChannelUpdateOptions, serverContactChannelCreateOptionsToCrud, serverContactChannelUpdateOptionsToCrud } from \"../../contact-channels\";\nimport { Customer, CustomerProductsList, CustomerProductsRequestOptions, InlineProduct, ServerItem } from \"../../customers\";\nimport { DataVaultStore } from \"../../data-vault\";\nimport { EmailDeliveryInfo, SendEmailOptions } from \"../../email\";\nimport { NotificationCategory } from \"../../notification-categories\";\nimport { scopePasskeyRegistrationToHostname } from \"../../passkey-rp-id\";\nimport { AdminProjectPermissionDefinition, AdminTeamPermission, AdminTeamPermissionDefinition } from \"../../permissions\";\nimport { EditableTeamMemberProfile, ReceivedTeamInvitation, SentTeamInvitation, ServerListTeamsOptions, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamUpdateOptions, ServerTeamUser, Team, serverTeamCreateOptionsToCrud, serverTeamUpdateOptionsToCrud } from \"../../teams\";\nimport { ProjectCurrentServerUser, ServerOAuthProvider, ServerUser, ServerUserCreateOptions, ServerUserUpdateOptions, serverUserCreateOptionsToCrud, serverUserUpdateOptionsToCrud, withUserDestructureGuard } from \"../../users\";\nimport { StackServerAppConstructorOptions } from \"../interfaces/server-app\";\nimport { _HexclaveClientAppImplIncomplete } from \"./client-app-impl\";\nimport { clientVersion, createCache, createCacheBySession, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey, resolveApiUrls, resolveConstructorOptions } from \"./common\";\n\n\nexport class _HexclaveServerAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _HexclaveClientAppImplIncomplete<HasTokenStore, ProjectId> {\n declare protected _interface: HexclaveServerInterface;\n\n // TODO override the client user cache to use the server user cache, so we save some requests\n private readonly _currentServerUserCache = createCacheBySession(async (session) => {\n if (session.isKnownToBeInvalid()) {\n // see comment in _currentUserCache for more details on why we do this\n return null;\n }\n return await this._interface.getServerUserByToken(session);\n });\n private readonly _serverUsersCache = createCache<[\n cursor?: string,\n limit?: number,\n orderBy?: 'signedUpAt' | 'lastActiveAt',\n desc?: boolean,\n query?: string,\n includeRestricted?: boolean,\n includeAnonymous?: boolean,\n onlyAnonymous?: boolean,\n teamId?: string,\n excludedEmailDomains?: string,\n ], UsersCrud['Server']['List']>(async ([cursor, limit, orderBy, desc, query, includeRestricted, includeAnonymous, onlyAnonymous, teamId, excludedEmailDomains]) => {\n if (onlyAnonymous && !includeAnonymous) {\n throw new HexclaveAssertionError(\"onlyAnonymous=true requires includeAnonymous=true\");\n }\n const excludedEmailDomainList = excludedEmailDomains?.split(\",\");\n if (onlyAnonymous) {\n return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query, excludedEmailDomains: excludedEmailDomainList, includeRestricted, includeAnonymous: true, onlyAnonymous: true, teamId });\n }\n return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query, excludedEmailDomains: excludedEmailDomainList, includeRestricted, includeAnonymous, teamId });\n });\n private readonly _serverUserCache = createCache<string[], UsersCrud['Server']['Read'] | null>(async ([userId]) => {\n const user = await this._interface.getServerUserById(userId);\n return Result.or(user, null);\n });\n private readonly _serverTeamsCache = createCache<[\n userId?: string,\n orderBy?: 'createdAt',\n desc?: boolean,\n cursor?: string,\n limit?: number,\n query?: string,\n ], TeamsCrud['Server']['List']>(async ([userId, orderBy, desc, cursor, limit, query]) => {\n return await this._interface.listServerTeamsPaginated({ userId, orderBy, desc, cursor, limit, query });\n });\n private readonly _serverTeamCache = createCache<string[], TeamsCrud['Server']['Read'] | null>(async ([teamId]) => {\n // The previous list-and-find implementation treated unknown or malformed IDs as null; preserve that behavior without making an invalid request.\n if (!isUuid(teamId)) {\n return null;\n }\n try {\n return await this._interface.getServerTeam(teamId);\n } catch (error) {\n if (KnownErrors.TeamNotFound.isInstance(error)) {\n return null;\n }\n throw error;\n }\n });\n\n protected async _refreshTeamMembership(teamId: string, userId: string) {\n await Promise.all([\n this._serverTeamMemberProfilesCache.refresh([teamId]),\n this._serverTeamsCache.refreshWhere(([u]) => u === userId || u === undefined),\n this._serverUsersCache.refreshWhere((key) => key[8] === teamId),\n ]);\n }\n private readonly _serverUserTeamInvitationsCache = createCache<string[], TeamInvitationCrud['Client']['Read'][]>(async ([userId]) => {\n return await this._interface.listServerUserTeamInvitations(userId);\n });\n private readonly _serverTeamUserPermissionsCache = createCache<\n [string, string, boolean],\n TeamPermissionsCrud['Server']['Read'][]\n >(async ([teamId, userId, recursive]) => {\n return await this._interface.listServerTeamPermissions({ teamId, userId, recursive }, null);\n });\n // Bulk variant: one request returning permissions for every member of a\n // team. Used by the dashboard's team-member table to avoid N per-row\n // calls. Keyed without userId so it's a distinct cache entry from the\n // per-user lookup above.\n private readonly _serverAllTeamMemberPermissionsCache = createCache<\n [string, boolean],\n TeamPermissionsCrud['Server']['Read'][]\n >(async ([teamId, recursive]) => {\n return await this._interface.listServerTeamPermissions({ teamId, recursive }, null);\n });\n private readonly _serverUserProjectPermissionsCache = createCache<\n [string, boolean],\n ProjectPermissionsCrud['Server']['Read'][]\n >(async ([userId, recursive]) => {\n return await this._interface.listServerProjectPermissions({ userId, recursive }, null);\n });\n /** @deprecated Used by legacy getConnectedAccount(providerId) — uses old per-provider access token endpoint */\n private readonly _serverUserOAuthConnectionAccessTokensCache = createCache<[string, string, string], { accessToken: string } | null>(\n async ([userId, providerId, scope]) => {\n try {\n const result = await this._interface.createServerProviderAccessToken(userId, providerId, scope || \"\");\n return { accessToken: result.access_token };\n } catch (err) {\n if (!(KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) {\n throw err;\n }\n }\n return null;\n }\n );\n /** @deprecated Used by legacy getConnectedAccount(providerId) — combines token check + redirect */\n private readonly _serverUserOAuthConnectionCache = createCache<[string, ProviderType, string, boolean], DeprecatedOAuthConnection | null>(\n async ([userId, providerId, scope, redirect]) => {\n return await this._getUserOAuthConnectionCacheFn({\n getUser: async () => Result.orThrow(await this._serverUserCache.getOrWait([userId], \"write-only\")),\n getOrWaitOAuthToken: async () => Result.orThrow(await this._serverUserOAuthConnectionAccessTokensCache.getOrWait([userId, providerId, scope || \"\"] as const, \"write-only\")),\n providerId,\n scope,\n redirect,\n session: null,\n });\n }\n );\n private readonly _serverUserConnectedAccountsCache = createCache<[string], OAuthConnection[]>(\n async ([userId]) => {\n const result = await this._interface.listServerConnectedAccounts(userId);\n return result.items.map((item) => this._createServerOAuthConnectionFromCrudItem(userId, item));\n }\n );\n private readonly _serverUserOAuthConnectionAccessTokensByAccountCache = createCache<[string, string, string, string], { accessToken: string } | null>(\n async ([userId, providerId, providerAccountId, scope]) => {\n try {\n const result = await this._interface.createServerProviderAccessTokenByAccount(userId, providerId, providerAccountId, scope || \"\");\n return { accessToken: result.access_token };\n } catch (err) {\n if (!(KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) {\n throw err;\n }\n }\n return null;\n }\n );\n private readonly _serverTeamMemberProfilesCache = createCache<[string], TeamMemberProfilesCrud['Server']['Read'][]>(\n async ([teamId]) => {\n return await this._interface.listServerTeamMemberProfiles({ teamId });\n }\n );\n private readonly _serverTeamInvitationsCache = createCache<[string], TeamInvitationCrud['Server']['Read'][]>(\n async ([teamId]) => {\n return await this._interface.listServerTeamInvitations({ teamId });\n }\n );\n private readonly _serverUserTeamProfileCache = createCache<[string, string], TeamMemberProfilesCrud['Client']['Read']>(\n async ([teamId, userId]) => {\n return await this._interface.getServerTeamMemberProfile({ teamId, userId });\n }\n );\n private readonly _serverContactChannelsCache = createCache<[string], ContactChannelsCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerContactChannels(userId);\n }\n );\n private readonly _serverNotificationCategoriesCache = createCache<[string], NotificationPreferenceCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerNotificationCategories(userId);\n }\n );\n private readonly _serverDataVaultStoreValueCache = createCache<[string, string, string], string | null>(async ([storeId, key, secret]) => {\n return await this._interface.getDataVaultStoreValue(secret, storeId, key);\n });\n\n private readonly _emailDeliveryInfoCache = createCache(async () => {\n return await this._interface.getEmailDeliveryInfo();\n });\n\n private readonly _serverUserApiKeysCache = createCache<[string], UserApiKeysCrud['Server']['Read'][]>(\n async ([userId]) => {\n const result = await this._interface.listProjectApiKeys({\n user_id: userId,\n }, null, \"server\");\n return result as UserApiKeysCrud['Server']['Read'][];\n }\n );\n\n private readonly _serverTeamApiKeysCache = createCache<[string], TeamApiKeysCrud['Server']['Read'][]>(\n async ([teamId]) => {\n const result = await this._interface.listProjectApiKeys({\n team_id: teamId,\n }, null, \"server\");\n return result as TeamApiKeysCrud['Server']['Read'][];\n }\n );\n\n private readonly _convexIdentitySubjectCache = createCache<[ConvexCtx], string | null>(\n async ([ctx]) => {\n const identity = await ctx.auth.getUserIdentity();\n return identity ? identity.subject : null;\n }\n );\n\n private readonly _serverCheckApiKeyCache = createCache<[\"user\" | \"team\", string], UserApiKeysCrud['Server']['Read'] | TeamApiKeysCrud['Server']['Read'] | null>(async ([type, apiKey]) => {\n const result = await this._interface.checkProjectApiKey(\n type,\n apiKey,\n null,\n \"server\",\n );\n return result;\n });\n\n private readonly _serverOAuthProvidersCache = createCache<[string], OAuthProviderCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerOAuthProviders({ user_id: userId });\n }\n );\n\n private readonly _serverTeamItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([teamId, itemId]) => {\n return await this._interface.getItem({ teamId, itemId }, null, \"server\");\n }\n );\n\n private readonly _serverUserItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([userId, itemId]) => {\n return await this._interface.getItem({ userId, itemId }, null, \"server\");\n }\n );\n\n private readonly _serverCustomItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([customCustomerId, itemId]) => {\n return await this._interface.getItem({ customCustomerId, itemId }, null, \"server\");\n }\n );\n\n private readonly _serverUserProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([userId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"user\",\n customer_id: userId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null, \"server\");\n }\n );\n\n private readonly _serverTeamProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([teamId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"team\",\n customer_id: teamId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null, \"server\");\n }\n );\n\n private readonly _serverCustomProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([customCustomerId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"custom\",\n customer_id: customCustomerId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null, \"server\");\n }\n );\n\n protected _createServerCustomer(userIdOrTeamId: string, type: \"user\" | \"team\"): Omit<Customer<true>, \"id\"> {\n const app = this;\n const productsCache = type === \"user\" ? app._serverUserProductsCache : app._serverTeamProductsCache;\n const customerOptions = type === \"user\" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };\n return {\n ...this._createCustomer(userIdOrTeamId, type, null),\n async getItem(itemId: string) {\n return await app.getItem({ itemId, ...customerOptions });\n },\n async grantProduct(productOptions: { productId: string, quantity?: number } | { product: InlineProduct, quantity?: number }) {\n if (type === \"user\") {\n if (\"productId\" in productOptions) {\n await app.grantProduct({ userId: userIdOrTeamId, productId: productOptions.productId, quantity: productOptions.quantity });\n } else {\n await app.grantProduct({ userId: userIdOrTeamId, product: productOptions.product, quantity: productOptions.quantity });\n }\n } else {\n if (\"productId\" in productOptions) {\n await app.grantProduct({ teamId: userIdOrTeamId, productId: productOptions.productId, quantity: productOptions.quantity });\n } else {\n await app.grantProduct({ teamId: userIdOrTeamId, product: productOptions.product, quantity: productOptions.quantity });\n }\n }\n await productsCache.refresh([userIdOrTeamId, null, null]);\n },\n async createCheckoutUrl(options: { productId: string, returnUrl?: string } | { product: InlineProduct, returnUrl?: string }) {\n const productIdOrInline = \"productId\" in options ? options.productId : options.product;\n return await app._interface.createCheckoutUrl(type, userIdOrTeamId, productIdOrInline, null, options.returnUrl, \"server\");\n },\n };\n }\n\n private async _updateServerUser(userId: string, update: ServerUserUpdateOptions): Promise<UsersCrud['Server']['Read']> {\n const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));\n await this._refreshUsers();\n return result;\n }\n\n protected _serverEditableTeamProfileFromCrud(crud: TeamMemberProfilesCrud['Client']['Read']): EditableTeamMemberProfile {\n const app = this;\n return {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n async update(update: { displayName?: string, profileImageUrl?: string }) {\n await app._interface.updateServerTeamMemberProfile({\n teamId: crud.team_id,\n userId: crud.user_id,\n profile: {\n display_name: update.displayName,\n profile_image_url: update.profileImageUrl,\n },\n });\n await app._serverUserTeamProfileCache.refresh([crud.team_id, crud.user_id]);\n }\n };\n }\n\n protected _serverContactChannelFromCrud(userId: string, crud: ContactChannelsCrud['Server']['Read']): ServerContactChannel {\n const app = this;\n return {\n id: crud.id,\n value: crud.value,\n type: crud.type,\n isVerified: crud.is_verified,\n isPrimary: crud.is_primary,\n usedForAuth: crud.used_for_auth,\n async sendVerificationEmail(options?: { callbackUrl?: string }) {\n await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, options?.callbackUrl ?? constructRedirectUrl(app._getUrls().emailVerification, \"callbackUrl\"));\n },\n async update(data: ServerContactChannelUpdateOptions) {\n await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));\n await Promise.all([\n app._serverContactChannelsCache.refresh([userId]),\n app._serverUserCache.refresh([userId])\n ]);\n },\n async delete() {\n await app._interface.deleteServerContactChannel(userId, crud.id);\n await Promise.all([\n app._serverContactChannelsCache.refresh([userId]),\n app._serverUserCache.refresh([userId])\n ]);\n },\n };\n }\n\n protected _serverNotificationCategoryFromCrud(userId: string, crud: NotificationPreferenceCrud['Server']['Read']): NotificationCategory {\n const app = this;\n return {\n id: crud.notification_category_id,\n name: crud.notification_category_name,\n enabled: crud.enabled,\n canDisable: crud.can_disable,\n\n async setEnabled(enabled: boolean) {\n await app._interface.setServerNotificationsEnabled(userId, crud.notification_category_id, enabled);\n await app._serverNotificationCategoriesCache.refresh([userId]);\n },\n };\n }\n\n protected _serverOAuthProviderFromCrud(crud: OAuthProviderCrud['Server']['Read']) {\n const app = this;\n return {\n id: crud.id,\n type: crud.type,\n userId: crud.user_id,\n accountId: crud.account_id,\n email: crud.email,\n allowSignIn: crud.allow_sign_in,\n allowConnectedAccounts: crud.allow_connected_accounts,\n\n async update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >> {\n try {\n await app._interface.updateServerOAuthProvider(crud.user_id, crud.id, {\n account_id: data.accountId,\n email: data.email,\n allow_sign_in: data.allowSignIn,\n allow_connected_accounts: data.allowConnectedAccounts,\n });\n await Promise.all([\n app._serverOAuthProvidersCache.refresh([crud.user_id]),\n app._serverUserConnectedAccountsCache.refresh([crud.user_id]),\n ]);\n return Result.ok(undefined);\n } catch (error) {\n if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) {\n return Result.error(error);\n }\n throw error;\n }\n },\n\n async delete() {\n await app._interface.deleteServerOAuthProvider(crud.user_id, crud.id);\n await Promise.all([\n app._serverOAuthProvidersCache.refresh([crud.user_id]),\n app._serverUserConnectedAccountsCache.refresh([crud.user_id]),\n ]);\n },\n };\n }\n\n constructor(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>, extraOptions?: { uniqueIdentifier?: string, checkString?: string, interface?: HexclaveServerInterface }) {\n const resolvedOptions = resolveConstructorOptions(options);\n\n const publishableClientKey = resolvedOptions.publishableClientKey ?? getDefaultPublishableClientKey();\n\n super(resolvedOptions, {\n ...extraOptions,\n interface: extraOptions?.interface ?? (() => {\n const apiUrls = resolveApiUrls(resolvedOptions.baseUrl);\n return new HexclaveServerInterface({\n getBaseUrl: () => apiUrls()[0],\n getApiUrls: apiUrls,\n projectId: resolvedOptions.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: resolvedOptions.extraRequestHeaders ?? getDefaultExtraRequestHeaders(),\n clientVersion,\n ...(publishableClientKey != null ? { publishableClientKey } : {}),\n secretServerKey: resolvedOptions.secretServerKey ?? getDefaultSecretServerKey(),\n });\n })(),\n });\n }\n\n\n protected _serverApiKeyFromCrud(crud: TeamApiKeysCrud['Client']['Read']): ApiKey<\"team\">;\n protected _serverApiKeyFromCrud(crud: UserApiKeysCrud['Client']['Read']): ApiKey<\"user\">;\n protected _serverApiKeyFromCrud(crud: yup.InferType<typeof teamApiKeysCreateOutputSchema>): ApiKey<\"team\", true>;\n protected _serverApiKeyFromCrud(crud: yup.InferType<typeof userApiKeysCreateOutputSchema>): ApiKey<\"user\", true>;\n protected _serverApiKeyFromCrud(crud: TeamApiKeysCrud['Client']['Read'] | UserApiKeysCrud['Client']['Read'] | yup.InferType<typeof teamApiKeysCreateOutputSchema> | yup.InferType<typeof userApiKeysCreateOutputSchema>): ApiKey<\"user\" | \"team\", boolean> {\n return {\n ...this._baseApiKeyFromCrud(crud),\n async revoke() {\n await this.update({ revoked: true });\n },\n update: async (options: ApiKeyUpdateOptions) => {\n await this._interface.updateProjectApiKey(\n crud.type === \"team\" ? { team_id: crud.team_id } : { user_id: crud.user_id },\n crud.id,\n await apiKeyUpdateOptionsToCrud(crud.type, options),\n null,\n \"server\");\n if (crud.type === \"team\") {\n await this._serverTeamApiKeysCache.refresh([crud.team_id]);\n } else {\n await this._serverUserApiKeysCache.refresh([crud.user_id]);\n }\n },\n };\n }\n\n protected _createServerOAuthConnectionFromCrudItem(\n userId: string,\n item: { provider: string, provider_account_id: string },\n ): OAuthConnection {\n const app = this;\n const providerId = item.provider;\n const providerAccountId = item.provider_account_id;\n return {\n id: providerId, // deprecated, for backward compat\n provider: providerId,\n providerAccountId,\n async getAccessToken(options?: { scopes?: string[] }) {\n const scopeString = options?.scopes?.join(\" \") ?? \"\";\n const result = Result.orThrow(await app._serverUserOAuthConnectionAccessTokensByAccountCache.getOrWait([userId, providerId, providerAccountId, scopeString], \"write-only\"));\n if (!result) {\n const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : \"The OAuth refresh token has likely been revoked or expired.\";\n return Result.error(new KnownErrors.OAuthAccessTokenNotAvailable(providerId, `${scopeDetail} The user needs to re-authorize by calling \\`linkConnectedAccount\\` or using \\`getOrLinkConnectedAccount\\`.`));\n }\n return Result.ok(result);\n },\n };\n }\n\n protected _serverUserFromCrud(crud: UsersCrud['Server']['Read']): ServerUser {\n const app = this;\n\n /** @deprecated The string-based overloads are deprecated. Use `getConnectedAccount({ provider, providerAccountId })` for existence check. */\n async function getConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): Promise<DeprecatedOAuthConnection | null>;\n async function getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<DeprecatedOAuthConnection>;\n async function getConnectedAccount(account: { provider: string, providerAccountId: string }): Promise<OAuthConnection | null>;\n async function getConnectedAccount(\n idOrAccount: ProviderType | { provider: string, providerAccountId: string },\n options?: { or?: 'redirect', scopes?: string[] }\n ): Promise<DeprecatedOAuthConnection | OAuthConnection | null> {\n const scopeString = options?.scopes?.join(\" \") ?? \"\";\n\n // Check if it's the new object-based API\n if (typeof idOrAccount === 'object' && 'provider' in idOrAccount && 'providerAccountId' in idOrAccount) {\n const { provider, providerAccountId } = idOrAccount;\n // Check if the account exists in the connected accounts list\n const connectedAccounts = Result.orThrow(await app._serverUserConnectedAccountsCache.getOrWait([crud.id], \"write-only\"));\n const found = connectedAccounts.find(\n a => a.provider === provider && a.providerAccountId === providerAccountId\n );\n if (!found) {\n return null;\n }\n return found;\n }\n\n // Original behavior: by provider ID (returns first match)\n return Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, idOrAccount, scopeString, options?.or === 'redirect'], \"write-only\"));\n }\n\n\n const serverUser = withUserDestructureGuard({\n ...super._createBaseUser(crud),\n lastActiveAt: new Date(crud.last_active_at_millis),\n serverMetadata: crud.server_metadata,\n restrictedByAdminPrivateDetails: crud.restricted_by_admin_private_details,\n countryCode: crud.country_code,\n riskScores: {\n signUp: {\n bot: crud.risk_scores.sign_up.bot,\n freeTrialAbuse: crud.risk_scores.sign_up.free_trial_abuse,\n },\n },\n async setPrimaryEmail(email: string | null, options?: { verified?: boolean }) {\n await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });\n },\n async grantPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<void> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string' && permissionId) {\n const scope = scopeOrPermissionId;\n await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);\n\n for (const recursive of [true, false]) {\n await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);\n await app._serverAllTeamMemberPermissionsCache.refresh([scope.id, recursive]);\n }\n } else {\n const pId = scopeOrPermissionId as string;\n await app._interface.grantServerProjectPermission(crud.id, pId);\n\n for (const recursive of [true, false]) {\n await app._serverUserProjectPermissionsCache.refresh([crud.id, recursive]);\n }\n }\n },\n async revokePermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<void> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string' && permissionId) {\n const scope = scopeOrPermissionId;\n await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);\n\n for (const recursive of [true, false]) {\n await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);\n await app._serverAllTeamMemberPermissionsCache.refresh([scope.id, recursive]);\n }\n } else {\n const pId = scopeOrPermissionId as string;\n await app._interface.revokeServerProjectPermission(crud.id, pId);\n\n for (const recursive of [true, false]) {\n await app._serverUserProjectPermissionsCache.refresh([crud.id, recursive]);\n }\n }\n },\n async delete() {\n const res = await app._interface.deleteServerUser(crud.id);\n await app._refreshUsers();\n return res;\n },\n async createSession(options: { expiresInMillis?: number, isImpersonation?: boolean }) {\n // TODO this should also refresh the access token when it expires (like InternalSession)\n const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1000 * 60 * 60 * 24 * 365, options.isImpersonation ?? false);\n return {\n async getTokens() {\n return tokens;\n },\n };\n },\n\n async getActiveSessions() {\n const sessions = await app._interface.listServerSessions(crud.id);\n return sessions.items.map((session) => app._clientSessionFromCrud(session));\n },\n\n async revokeSession(sessionId: string) {\n await app._interface.deleteServerSession(sessionId);\n },\n async setDisplayName(displayName: string | null) {\n return await this.update({ displayName });\n },\n async setClientMetadata(metadata: Record<string, any>) {\n return await this.update({ clientMetadata: metadata });\n },\n async setClientReadOnlyMetadata(metadata: Record<string, any>) {\n return await this.update({ clientReadOnlyMetadata: metadata });\n },\n async setServerMetadata(metadata: Record<string, any>) {\n return await this.update({ serverMetadata: metadata });\n },\n async setSelectedTeam(team: Team | string | null) {\n return await this.update({ selectedTeamId: typeof team === 'string' ? team : team?.id ?? null });\n },\n getConnectedAccount,\n async listConnectedAccounts() {\n return Result.orThrow(await app._serverUserConnectedAccountsCache.getOrWait([crud.id], \"write-only\"));\n },\n async linkConnectedAccount(): Promise<void> {\n throw new HexclaveAssertionError(\"linkConnectedAccount is not available for server users. OAuth flows must be initiated on the client side.\");\n },\n async getOrLinkConnectedAccount(): Promise<OAuthConnection> {\n throw new HexclaveAssertionError(\"getOrLinkConnectedAccount is not available for server users. OAuth flows must be initiated on the client side.\");\n },\n selectedTeam: crud.selected_team ? app._serverTeamFromCrud(crud.selected_team) : null,\n // Unlike the app-level getTeam/useTeam (which fetch any team by id),\n // the user-scoped variants search the user's own team list on purpose:\n // they must return null for teams the user is not a member of, and some\n // callers rely on that as a membership check.\n async getTeam(teamId: string) {\n const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n },\n async listTeams(options?: ServerListTeamsOptions): Promise<ServerTeam[] & { nextCursor: string | null }> {\n const result = Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id, options?.orderBy, options?.desc, options?.cursor, options?.limit, options?.query] as const, \"write-only\"));\n const teams: any = result.items.map((t) => app._serverTeamFromCrud(t));\n teams.nextCursor = result.pagination?.next_cursor ?? null;\n return teams as any;\n },\n createTeam: async (data: Omit<ServerTeamCreateOptions, \"creatorUserId\">) => {\n const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({\n creatorUserId: crud.id,\n ...data,\n }));\n await app._serverTeamsCache.refreshWhere(() => true);\n await app._updateServerUser(crud.id, { selectedTeamId: team.id });\n return app._serverTeamFromCrud(team);\n },\n leaveTeam: async (team: Team) => {\n await app._interface.leaveServerTeam({ teamId: team.id, userId: crud.id });\n await app._refreshTeamMembership(team.id, crud.id);\n },\n async listTeamInvitations() {\n const invitations = Result.orThrow(await app._serverUserTeamInvitationsCache.getOrWait([crud.id], \"write-only\"));\n return invitations.map((inv) => app._serverReceivedTeamInvitationFromCrud(crud.id, inv));\n },\n async listPermissions(scopeOrOptions?: Team | { recursive?: boolean }, options?: { recursive?: boolean }): Promise<AdminTeamPermission[]> {\n if (scopeOrOptions && 'id' in scopeOrOptions) {\n const scope = scopeOrOptions;\n const recursive = options?.recursive ?? true;\n const permissions = Result.orThrow(await app._serverTeamUserPermissionsCache.getOrWait([scope.id, crud.id, recursive], \"write-only\"));\n return permissions.map((crud) => app._serverPermissionFromCrud(crud));\n } else {\n const opts = scopeOrOptions;\n const recursive = opts?.recursive ?? true;\n const permissions = Result.orThrow(await app._serverUserProjectPermissionsCache.getOrWait([crud.id, recursive], \"write-only\"));\n return permissions.map((crud) => app._serverPermissionFromCrud(crud));\n }\n },\n async getPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<AdminTeamPermission | null> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n const permissions = await this.listPermissions(scope);\n return permissions.find((p) => p.id === permissionId) ?? null;\n } else {\n const pid = scopeOrPermissionId;\n const permissions = await this.listPermissions();\n return permissions.find((p) => p.id === pid) ?? null;\n }\n },\n async hasPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<boolean> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n return (await this.getPermission(scope, permissionId as string)) !== null;\n } else {\n const pid = scopeOrPermissionId;\n return (await this.getPermission(pid)) !== null;\n }\n },\n async update(update: ServerUserUpdateOptions) {\n await app._updateServerUser(crud.id, update);\n },\n async sendVerificationEmail() {\n return await app._checkFeatureSupport(\"sendVerificationEmail() on ServerUser\", {});\n },\n async updatePassword(options: { oldPassword: string, newPassword: string }) {\n const result = await app._interface.updatePassword(options);\n await app._serverUserCache.refresh([crud.id]);\n return result;\n },\n async setPassword(options: { password: string }) {\n const result = await this.update(options);\n await app._serverUserCache.refresh([crud.id]);\n return result;\n },\n async getTeamProfile(team: Team) {\n const result = Result.orThrow(await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], \"write-only\"));\n return app._serverEditableTeamProfileFromCrud(result);\n },\n async listContactChannels() {\n const result = Result.orThrow(await app._serverContactChannelsCache.getOrWait([crud.id], \"write-only\"));\n return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));\n },\n createContactChannel: async (data: ServerContactChannelCreateOptions) => {\n const contactChannel = await app._interface.createServerContactChannel(serverContactChannelCreateOptionsToCrud(crud.id, data));\n await Promise.all([\n app._serverContactChannelsCache.refresh([crud.id]),\n app._serverUserCache.refresh([crud.id])\n ]);\n return app._serverContactChannelFromCrud(crud.id, contactChannel);\n },\n async listNotificationCategories() {\n const results = Result.orThrow(await app._serverNotificationCategoriesCache.getOrWait([crud.id], \"write-only\"));\n return results.map((category) => app._serverNotificationCategoryFromCrud(crud.id, category));\n },\n async listApiKeys() {\n const result = Result.orThrow(await app._serverUserApiKeysCache.getOrWait([crud.id], \"write-only\"));\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async createApiKey(options: ApiKeyCreationOptions<\"user\">) {\n const result = await app._interface.createProjectApiKey(\n await apiKeyCreationOptionsToCrud(\"user\", crud.id, options),\n null,\n \"server\",\n );\n await app._serverUserApiKeysCache.refresh([crud.id]);\n return app._serverApiKeyFromCrud(result);\n },\n\n async listOAuthProviders() {\n const results = Result.orThrow(await app._serverOAuthProvidersCache.getOrWait([crud.id], \"write-only\"));\n return results.map((oauthCrud) => app._serverOAuthProviderFromCrud(oauthCrud));\n },\n\n async getOAuthProvider(id: string) {\n const providers = await this.listOAuthProviders();\n return providers.find((p) => p.id === id) ?? null;\n },\n async registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>> {\n const hostname = options?.hostname || (await app._getCurrentUrl())?.hostname;\n if (!hostname) {\n throw new HexclaveAssertionError(\"hostname must be provided if the Stack App does not have a redirect method\");\n }\n\n // Use server interface to initiate passkey registration for this specific user\n const initiationResult = await app._interface.initiateServerPasskeyRegistration(crud.id);\n\n if (initiationResult.status !== \"ok\") {\n return Result.error(new KnownErrors.PasskeyRegistrationFailed(\"Failed to get initiation options for passkey registration\"));\n }\n\n const { options_json, code } = initiationResult.data;\n\n scopePasskeyRegistrationToHostname(options_json, hostname);\n\n let attResp;\n try {\n attResp = await startRegistration({ optionsJSON: options_json });\n } catch (error: any) {\n if (error instanceof WebAuthnError) {\n return Result.error(new KnownErrors.PasskeyWebAuthnError(error.message, error.name));\n } else {\n // This should never happen\n captureError(\"passkey-registration-failed\", error);\n return Result.error(new KnownErrors.PasskeyRegistrationFailed(\"Failed to start passkey registration due to unknown error\"));\n }\n }\n\n // Create a temporary session to complete the registration\n // TODO instead of creating a new session, this should just call the endpoint in a way in which it doesn't require a session\n // (currently this shows up on session history etc... not ideal)\n const { accessToken, refreshToken } = await app._interface.createServerUserSession(crud.id, 60000 * 2, false);\n const tempSession = new InternalSession({\n accessToken,\n refreshToken,\n refreshAccessTokenCallback: async () => null,\n });\n\n const registrationResult = await app._interface.registerPasskey({ credential: attResp, code }, tempSession);\n\n await app._serverUserCache.refresh([crud.id]);\n return registrationResult;\n },\n ...app._createServerCustomer(crud.id, \"user\"),\n } satisfies ServerUser);\n\n return serverUser;\n }\n\n protected _serverTeamUserFromCrud(crud: TeamMemberProfilesCrud[\"Server\"][\"Read\"]): ServerTeamUser {\n const teamUser = withUserDestructureGuard({\n ...this._serverUserFromCrud(crud.user),\n teamProfile: {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n },\n } satisfies ServerTeamUser);\n\n return teamUser;\n }\n\n protected _serverSentTeamInvitationFromCrud(crud: TeamInvitationCrud['Server']['Read']): SentTeamInvitation {\n return {\n id: crud.id,\n recipientEmail: crud.recipient_email,\n expiresAt: new Date(crud.expires_at_millis),\n revoke: async () => {\n await this._interface.revokeServerTeamInvitation(crud.id, crud.team_id);\n await this._serverTeamInvitationsCache.refresh([crud.team_id]);\n },\n };\n }\n\n protected _serverReceivedTeamInvitationFromCrud(userId: string, crud: TeamInvitationCrud['Client']['Read']): ReceivedTeamInvitation {\n const app = this;\n return {\n id: crud.id,\n teamId: crud.team_id,\n teamDisplayName: crud.team_display_name,\n recipientEmail: crud.recipient_email,\n expiresAt: new Date(crud.expires_at_millis),\n accept: async () => {\n await app._interface.acceptServerTeamInvitationById(crud.id, userId);\n await Promise.all([\n app._serverUserTeamInvitationsCache.refresh([userId]),\n app._serverTeamInvitationsCache.refresh([crud.team_id]),\n app._refreshTeamMembership(crud.team_id, userId),\n ]);\n },\n };\n }\n\n protected override _currentUserFromCrud(crud: UsersCrud['Server']['Read'], session: InternalSession): ProjectCurrentServerUser<ProjectId> {\n const currentUser = withUserDestructureGuard({\n ...this._serverUserFromCrud(crud),\n ...this._createAuth(session),\n ...this._isInternalProject() ? this._createInternalUserExtra(session) : {},\n } satisfies ServerUser);\n\n return currentUser as ProjectCurrentServerUser<ProjectId>;\n }\n\n protected _serverTeamFromCrud(crud: TeamsCrud['Server']['Read']): ServerTeam {\n const app = this;\n return {\n id: crud.id,\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n createdAt: new Date(crud.created_at_millis),\n clientMetadata: crud.client_metadata,\n clientReadOnlyMetadata: crud.client_read_only_metadata,\n serverMetadata: crud.server_metadata,\n async update(update: Partial<ServerTeamUpdateOptions>) {\n await app._interface.updateServerTeam(crud.id, serverTeamUpdateOptionsToCrud(update));\n await Promise.all([\n app._serverTeamCache.refresh([crud.id]),\n app._serverTeamsCache.refreshWhere(() => true),\n app._serverUsersCache.refreshWhere(() => true),\n ]);\n },\n async delete() {\n await app._interface.deleteServerTeam(crud.id);\n await Promise.all([\n app._serverTeamCache.refresh([crud.id]),\n app._serverTeamsCache.refreshWhere(() => true),\n app._serverUsersCache.refreshWhere(() => true),\n ]);\n },\n async listUsers() {\n const result = Result.orThrow(await app._serverTeamMemberProfilesCache.getOrWait([crud.id], \"write-only\"));\n return result.map(u => app._serverTeamUserFromCrud(u));\n },\n async addUser(userId) {\n await app._interface.addServerUserToTeam({\n teamId: crud.id,\n userId,\n });\n await app._refreshTeamMembership(crud.id, userId);\n },\n async removeUser(userId) {\n await app._interface.removeServerUserFromTeam({\n teamId: crud.id,\n userId,\n });\n await app._refreshTeamMembership(crud.id, userId);\n },\n async inviteUser(options: { email: string, callbackUrl?: string }) {\n await app._interface.sendServerTeamInvitation({\n teamId: crud.id,\n email: options.email,\n callbackUrl: options.callbackUrl ?? constructRedirectUrl(app._getUrls().teamInvitation, \"callbackUrl\"),\n });\n await app._serverTeamInvitationsCache.refresh([crud.id]);\n },\n async listInvitations() {\n const result = Result.orThrow(await app._serverTeamInvitationsCache.getOrWait([crud.id], \"write-only\"));\n return result.map((crud) => app._serverSentTeamInvitationFromCrud(crud));\n },\n async listApiKeys() {\n const result = Result.orThrow(await app._serverTeamApiKeysCache.getOrWait([crud.id], \"write-only\"));\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async createApiKey(options: ApiKeyCreationOptions<\"team\">) {\n const result = await app._interface.createProjectApiKey(\n await apiKeyCreationOptionsToCrud(\"team\", crud.id, options),\n null,\n \"server\",\n );\n await app._serverTeamApiKeysCache.refresh([crud.id]);\n return app._serverApiKeyFromCrud(result);\n },\n ...app._createServerCustomer(crud.id, \"team\"),\n };\n }\n\n protected _serverItemFromCrud(customer: { type: \"user\" | \"team\" | \"custom\", id: string }, crud: ItemCrud['Client']['Read']): ServerItem {\n const app = this;\n return {\n displayName: crud.display_name,\n quantity: crud.quantity,\n nonNegativeQuantity: Math.max(0, crud.quantity),\n increaseQuantity: async (delta: number) => {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n },\n decreaseQuantity: async (delta: number) => {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta: -delta, allow_negative: true });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n },\n tryDecreaseQuantity: async (delta: number) => {\n try {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta: -delta });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n return true;\n } catch (error) {\n if (error instanceof KnownErrors.ItemQuantityInsufficientAmount) {\n return false;\n }\n throw error;\n }\n },\n };\n }\n\n protected async _getUserApiKey(options: { apiKey: string }): Promise<ApiKey<\"user\"> | null> {\n const crud = Result.orThrow(await this._serverCheckApiKeyCache.getOrWait([\"user\", options.apiKey], \"write-only\")) as UserApiKeysCrud['Server']['Read'] | null;\n return crud ? this._serverApiKeyFromCrud(crud) : null;\n }\n\n protected async _getTeamApiKey(options: { apiKey: string }): Promise<ApiKey<\"team\"> | null> {\n const crud = Result.orThrow(await this._serverCheckApiKeyCache.getOrWait([\"team\", options.apiKey], \"write-only\")) as TeamApiKeysCrud['Server']['Read'] | null;\n return crud ? this._serverApiKeyFromCrud(crud) : null;\n }\n protected async _getUserByApiKey(apiKey: string): Promise<ServerUser | null> {\n const apiKeyObject = await this._getUserApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return await this.getServerUserById(apiKeyObject.userId);\n }\n\n protected async _getUserByConvex(ctx: ConvexCtx, includeAnonymous: boolean): Promise<ServerUser | null> {\n const identity = await ctx.auth.getUserIdentity();\n if (identity === null) {\n return null;\n }\n const user = await this.getServerUserById(identity.subject);\n if (user?.isAnonymous && !includeAnonymous) {\n return null;\n }\n return user;\n }\n\n protected async _getTeamByApiKey(apiKey: string): Promise<ServerTeam | null> {\n const apiKeyObject = await this._getTeamApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return await this.getTeam(apiKeyObject.teamId);\n }\n\n async createUser(options: ServerUserCreateOptions): Promise<ServerUser> {\n const crud = await this._interface.createServerUser(serverUserCreateOptionsToCrud(options));\n await this._refreshUsers();\n return this._serverUserFromCrud(crud);\n }\n\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;\n async getUser(id: string): Promise<ServerUser | null>;\n async getUser(options: { apiKey: string }): Promise<ServerUser | null>;\n async getUser(options: { from: \"convex\", ctx: ConvexCtx, or?: \"return-null\" | \"anonymous\" }): Promise<ServerUser | null>;\n async getUser(options?: string | GetCurrentUserOptions<HasTokenStore> | { apiKey: string } | { from: \"convex\", ctx: ConvexCtx }): Promise<ProjectCurrentServerUser<ProjectId> | ServerUser | null> {\n if (typeof options === \"string\") {\n return await this.getServerUserById(options);\n } else if (typeof options === \"object\" && \"apiKey\" in options) {\n return await this._getUserByApiKey(options.apiKey);\n } else if (typeof options === \"object\" && \"from\" in options && options.from as string === \"convex\") {\n return await this._getUserByConvex(options.ctx, \"or\" in options && options.or === \"anonymous\");\n } else {\n options = options as GetCurrentUserOptions<HasTokenStore> | undefined;\n\n // Validate that includeRestricted: false and or: 'anonymous' are mutually exclusive\n if (options?.or === 'anonymous' && options.includeRestricted === false) {\n throw new Error(\"Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.\");\n }\n\n // TODO this code is duplicated from the client app; fix that\n this._ensurePersistentTokenStore(options?.tokenStore);\n const session = await this._getSession(options?.tokenStore);\n let crud = Result.orThrow(await this._currentServerUserCache.getOrWait([session], \"write-only\"));\n const includeAnonymous = options?.or === \"anonymous\" || options?.or === \"anonymous-if-exists[deprecated]\";\n const includeRestricted = options?.includeRestricted === true || includeAnonymous;\n\n if (crud === null || (crud.is_anonymous && !includeAnonymous) || (crud.is_restricted && !includeRestricted)) {\n switch (options?.or) {\n case 'redirect': {\n if (!crud?.is_anonymous && crud?.is_restricted) {\n await this.redirectToOnboarding({ replace: true });\n } else {\n await this.redirectToSignIn({ replace: true });\n }\n // TODO: see client-app-impl. We probably want to `await neverResolve()` here instead of returning null\n break;\n }\n case 'throw': {\n throw new Error(\"User is not signed in but getUser was called with { or: 'throw' }\");\n }\n case 'anonymous': {\n const tokens = await this._signUpAnonymously();\n return await this.getUser({ tokenStore: tokens, or: \"anonymous-if-exists[deprecated]\", includeRestricted: true }) ?? throwErr(\"Something went wrong while signing up anonymously\");\n }\n case undefined:\n case \"anonymous-if-exists[deprecated]\":\n case \"return-null\": {\n return null;\n }\n }\n }\n\n return crud && this._currentUserFromCrud(crud, session);\n }\n }\n\n async getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null> {\n console.warn(\"hexclaveServerApp.getServerUser is deprecated; use hexclaveServerApp.getUser instead\");\n return await this.getUser();\n }\n\n async getServerUserById(userId: string): Promise<ServerUser | null> {\n const crud = Result.orThrow(await this._serverUserCache.getOrWait([userId], \"write-only\"));\n return crud && this._serverUserFromCrud(crud);\n }\n\n\n async listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & { nextCursor: string | null }> {\n const excludedEmailDomains = options?.excludedEmailDomains && options.excludedEmailDomains.length > 0 ? options.excludedEmailDomains.join(\",\") : undefined;\n const crud = Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query, options?.includeRestricted, options?.includeAnonymous, options?.onlyAnonymous, options?.teamId, excludedEmailDomains], \"write-only\"));\n const result: any = crud.items.map((j) => this._serverUserFromCrud(j));\n result.nextCursor = crud.pagination?.next_cursor ?? null;\n return result as any;\n }\n\n\n _serverPermissionFromCrud(crud: TeamPermissionsCrud['Server']['Read'] | ProjectPermissionsCrud['Server']['Read']): AdminTeamPermission {\n return {\n id: crud.id,\n };\n }\n\n _serverTeamPermissionDefinitionFromCrud(crud: TeamPermissionDefinitionsCrud['Admin']['Read']): AdminTeamPermissionDefinition {\n return {\n id: crud.id,\n description: crud.description,\n containedPermissionIds: crud.contained_permission_ids,\n };\n }\n\n _serverProjectPermissionDefinitionFromCrud(crud: ProjectPermissionDefinitionsCrud['Admin']['Read']): AdminProjectPermissionDefinition {\n return {\n id: crud.id,\n description: crud.description,\n containedPermissionIds: crud.contained_permission_ids,\n };\n }\n\n async getItem(options: { itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }): Promise<ServerItem> {\n if (\"userId\" in options) {\n const result = Result.orThrow(await this._serverUserItemsCache.getOrWait([options.userId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"user\", id: options.userId }, result);\n } else if (\"teamId\" in options) {\n const result = Result.orThrow(await this._serverTeamItemsCache.getOrWait([options.teamId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"team\", id: options.teamId }, result);\n } else {\n const result = Result.orThrow(await this._serverCustomItemsCache.getOrWait([options.customCustomerId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"custom\", id: options.customCustomerId }, result);\n }\n }\n\n protected async _refreshItemCache(customerType: \"user\" | \"team\" | \"custom\", customerId: string, itemId: string): Promise<void> {\n if (customerType === \"user\") {\n await this._serverUserItemsCache.refresh([customerId, itemId]);\n } else if (customerType === \"team\") {\n await this._serverTeamItemsCache.refresh([customerId, itemId]);\n } else {\n await this._serverCustomItemsCache.refresh([customerId, itemId]);\n }\n }\n\n async listProducts(options: CustomerProductsRequestOptions): Promise<CustomerProductsList> {\n if (\"userId\" in options) {\n const response = Result.orThrow(await this._serverUserProductsCache.getOrWait([options.userId, options.cursor ?? null, options.limit ?? null], \"write-only\"));\n return this._customerProductsFromResponse(response);\n } else if (\"teamId\" in options) {\n const response = Result.orThrow(await this._serverTeamProductsCache.getOrWait([options.teamId, options.cursor ?? null, options.limit ?? null], \"write-only\"));\n return this._customerProductsFromResponse(response);\n }\n const response = Result.orThrow(await this._serverCustomProductsCache.getOrWait([options.customCustomerId, options.cursor ?? null, options.limit ?? null], \"write-only\"));\n return this._customerProductsFromResponse(response);\n }\n\n private _resolveCustomer(\n options: { userId: string } | { teamId: string } | { customCustomerId: string }\n ): { customerType: \"user\" | \"team\" | \"custom\", customerId: string } {\n if (\"userId\" in options) {\n return { customerType: \"user\", customerId: options.userId };\n }\n if (\"teamId\" in options) {\n return { customerType: \"team\", customerId: options.teamId };\n }\n return { customerType: \"custom\", customerId: options.customCustomerId };\n }\n\n async grantProduct(options: (\n ({ userId: string } | { teamId: string } | { customCustomerId: string }) &\n ({ productId: string } | { product: InlineProduct }) &\n { quantity?: number }\n )): Promise<void> {\n const { customerType, customerId } = this._resolveCustomer(options);\n\n await this._interface.grantProduct({\n customerType,\n customerId,\n productId: \"productId\" in options ? options.productId : undefined,\n product: \"product\" in options ? options.product : undefined,\n quantity: options.quantity,\n });\n\n const cache = customerType === \"user\"\n ? this._serverUserProductsCache\n : customerType === \"team\"\n ? this._serverTeamProductsCache\n : this._serverCustomProductsCache;\n await cache.refresh([customerId, null, null]);\n }\n\n async createCheckoutUrl(options: (\n ({ userId: string } | { teamId: string } | { customCustomerId: string }) &\n ({ productId: string } | { product: InlineProduct }) &\n { returnUrl?: string }\n )): Promise<string> {\n const { customerType, customerId } = this._resolveCustomer(options);\n\n const productIdOrInline = \"productId\" in options ? options.productId : options.product;\n return await this._interface.createCheckoutUrl(customerType, customerId, productIdOrInline, null, options.returnUrl, \"server\");\n }\n\n async createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam> {\n const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));\n await this._serverTeamCache.refresh([team.id]);\n await this._serverTeamsCache.refreshWhere(() => true);\n return this._serverTeamFromCrud(team);\n }\n\n async listTeams(options?: ServerListTeamsOptions): Promise<ServerTeam[] & { nextCursor: string | null }> {\n const crud = Result.orThrow(await this._serverTeamsCache.getOrWait([undefined, options?.orderBy, options?.desc, options?.cursor, options?.limit, options?.query] as const, \"write-only\"));\n const teams: any = crud.items.map((t) => this._serverTeamFromCrud(t));\n teams.nextCursor = crud.pagination?.next_cursor ?? null;\n return teams as any;\n }\n\n\n async listTeamMemberPermissions(teamId: string, options?: { recursive?: boolean }): Promise<{ userId: string, permissionId: string }[]> {\n const recursive = options?.recursive ?? false;\n const rows = Result.orThrow(await this._serverAllTeamMemberPermissionsCache.getOrWait([teamId, recursive] as const, \"write-only\"));\n return rows.map((r) => ({ userId: r.user_id, permissionId: r.id }));\n }\n\n\n async getTeam(options: { apiKey: string }): Promise<ServerTeam | null>;\n async getTeam(teamId: string): Promise<ServerTeam | null>;\n async getTeam(options?: { apiKey: string } | string): Promise<ServerTeam | null> {\n if (typeof options === \"object\" && \"apiKey\" in options) {\n return await this._getTeamByApiKey(options.apiKey);\n } else {\n const teamId = options;\n if (teamId == null) {\n return null;\n }\n const team = Result.orThrow(await this._serverTeamCache.getOrWait([teamId], \"write-only\"));\n return team == null ? null : this._serverTeamFromCrud(team);\n }\n }\n\n\n protected _createServerDataVaultStore(id: string): DataVaultStore {\n const validateOptions = (options: { secret: string }) => {\n if (typeof options.secret !== \"string\") throw new Error(\"secret must be a string, got \" + typeof options.secret);\n };\n return {\n id,\n setValue: async (key, value, options) => {\n validateOptions(options);\n await this._interface.setDataVaultStoreValue(options.secret, id, key, value);\n },\n getValue: async (key, options) => {\n validateOptions(options);\n return Result.orThrow(await this._serverDataVaultStoreValueCache.getOrWait([id, key, options.secret], \"write-only\"));\n },\n };\n }\n\n async getDataVaultStore(id: string): Promise<DataVaultStore> {\n return this._createServerDataVaultStore(id);\n }\n\n\n async sendEmail(options: SendEmailOptions): Promise<void> {\n await this._interface.sendEmail(options);\n await this._emailDeliveryInfoCache.refresh([]);\n }\n\n async getEmailDeliveryStats(): Promise<EmailDeliveryInfo> {\n return Result.orThrow(await this._emailDeliveryInfoCache.getOrWait([], \"write-only\"));\n }\n\n\n async activateEmailCapacityBoost(): Promise<void> {\n await this._interface.activateEmailCapacityBoost();\n // Refresh the cache so UI updates immediately\n await this._emailDeliveryInfoCache.refresh([]);\n }\n\n async queryAnalytics(options: AnalyticsQueryOptions): Promise<AnalyticsQueryResponse> {\n return await this._interface.queryAnalytics(options);\n }\n\n protected override async _refreshSession(session: InternalSession) {\n await Promise.all([\n super._refreshUser(session),\n this._currentServerUserCache.refresh([session]),\n ]);\n }\n\n protected override async _refreshUsers() {\n await Promise.all([\n super._refreshUsers(),\n this._serverUserCache.refreshWhere(() => true),\n this._serverUsersCache.refreshWhere(() => true),\n this._serverContactChannelsCache.refreshWhere(() => true),\n this._serverOAuthProvidersCache.refreshWhere(() => true),\n this._serverUserConnectedAccountsCache.refreshWhere(() => true),\n ]);\n }\n\n async createOAuthProvider(options: {\n userId: string,\n providerConfigId: string,\n accountId: string,\n email: string,\n allowSignIn: boolean,\n allowConnectedAccounts: boolean,\n }): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>> {\n try {\n const crud = await this._interface.createServerOAuthProvider({\n user_id: options.userId,\n provider_config_id: options.providerConfigId,\n account_id: options.accountId,\n email: options.email,\n allow_sign_in: options.allowSignIn,\n allow_connected_accounts: options.allowConnectedAccounts,\n });\n\n await Promise.all([\n this._serverOAuthProvidersCache.refresh([options.userId]),\n this._serverUserConnectedAccountsCache.refresh([options.userId]),\n ]);\n return Result.ok(this._serverOAuthProviderFromCrud(crud));\n } catch (error) {\n if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) {\n return Result.error(error);\n }\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8CA,IAAa,mCAAb,cAA+GA,qBAAAA,iCAA2D;CA6DxK,MAAgB,uBAAuB,QAAgB,QAAgB;EACrE,MAAM,QAAQ,IAAI;GAChB,KAAK,+BAA+B,QAAQ,CAAC,MAAM,CAAC;GACpD,KAAK,kBAAkB,cAAc,CAAC,OAAO,MAAM,UAAU,MAAM,KAAA,CAAS;GAC5E,KAAK,kBAAkB,cAAc,QAAQ,IAAI,OAAO,MAAM;EAChE,CAAC;CACH;CAqMA,sBAAgC,gBAAwB,MAAmD;EACzG,MAAM,MAAM;EACZ,MAAM,gBAAgB,SAAS,SAAS,IAAI,2BAA2B,IAAI;EAC3E,MAAM,kBAAkB,SAAS,SAAS,EAAE,QAAQ,eAAe,IAAI,EAAE,QAAQ,eAAe;EAChG,OAAO;GACL,GAAG,KAAK,gBAAgB,gBAAgB,MAAM,IAAI;GAClD,MAAM,QAAQ,QAAgB;IAC5B,OAAO,MAAM,IAAI,QAAQ;KAAE;KAAQ,GAAG;IAAgB,CAAC;GACzD;GACA,MAAM,aAAa,gBAA0G;IAC3H,IAAI,SAAS,QACX,IAAI,eAAe,gBACjB,MAAM,IAAI,aAAa;KAAE,QAAQ;KAAgB,WAAW,eAAe;KAAW,UAAU,eAAe;IAAS,CA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GACd,IAAIC,iBAAAA,YAAY,2CAA2C,WAAW,KAAK,GACzE,OAAOD,oCAAAA,OAAO,MAAM,KAAK;GAE3B,MAAM;EACR;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"server-app-impl.js","names":["_HexclaveClientAppImplIncomplete","Result","KnownErrors","HexclaveServerInterface","HexclaveAssertionError","opts","WebAuthnError","InternalSession"],"sources":["../../../../../src/lib/hexclave-app/apps/implementations/server-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\nimport { HexclaveServerInterface, KnownErrors } from \"@hexclave/shared\";\nimport type { AnalyticsQueryOptions, AnalyticsQueryResponse } from \"@hexclave/shared/dist/interface/crud/analytics\";\nimport type { AdminGetSessionReplayChunkEventsResponse } from \"@hexclave/shared/dist/interface/crud/session-replays\";\nimport type { AdminSessionReplay, AdminSessionReplayChunk, ListSessionReplayChunksOptions, ListSessionReplayChunksResult, ListSessionReplaysOptions, ListSessionReplaysResult, SessionReplayAllEventsResult } from \"../../session-replays\";\nimport { ContactChannelsCrud } from \"@hexclave/shared/dist/interface/crud/contact-channels\";\nimport { ItemCrud } from \"@hexclave/shared/dist/interface/crud/items\";\nimport { NotificationPreferenceCrud } from \"@hexclave/shared/dist/interface/crud/notification-preferences\";\nimport { OAuthProviderCrud } from \"@hexclave/shared/dist/interface/crud/oauth-providers\";\nimport type { CustomerProductsListResponse } from \"@hexclave/shared/dist/interface/crud/products\";\nimport { TeamApiKeysCrud, UserApiKeysCrud, teamApiKeysCreateOutputSchema, userApiKeysCreateOutputSchema } from \"@hexclave/shared/dist/interface/crud/project-api-keys\";\nimport { ProjectPermissionDefinitionsCrud, ProjectPermissionsCrud } from \"@hexclave/shared/dist/interface/crud/project-permissions\";\nimport { TeamInvitationCrud } from \"@hexclave/shared/dist/interface/crud/team-invitation\";\nimport { TeamMemberProfilesCrud } from \"@hexclave/shared/dist/interface/crud/team-member-profiles\";\nimport { TeamPermissionDefinitionsCrud, TeamPermissionsCrud } from \"@hexclave/shared/dist/interface/crud/team-permissions\";\nimport { TeamsCrud } from \"@hexclave/shared/dist/interface/crud/teams\";\nimport { UsersCrud } from \"@hexclave/shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@hexclave/shared/dist/sessions\";\nimport type { AsyncCache } from \"@hexclave/shared/dist/utils/caches\";\nimport { HexclaveAssertionError, captureError, throwErr } from \"@hexclave/shared/dist/utils/errors\";\nimport { ProviderType } from \"@hexclave/shared/dist/utils/oauth\";\nimport { runAsynchronously } from \"@hexclave/shared/dist/utils/promises\";\nimport { suspend } from \"@hexclave/shared/dist/utils/react\";\nimport { Result } from \"@hexclave/shared/dist/utils/results\";\nimport { isUuid } from \"@hexclave/shared/dist/utils/uuids\";\nimport { WebAuthnError, startRegistration } from \"@simplewebauthn/browser\";\nimport * as yup from \"yup\";\nimport { constructRedirectUrl } from \"../../../../utils/url\";\nimport { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud, apiKeyUpdateOptionsToCrud } from \"../../api-keys\";\nimport { ConvexCtx, GetCurrentUserOptions } from \"../../common\";\nimport { DeprecatedOAuthConnection, OAuthConnection } from \"../../connected-accounts\";\nimport { ServerContactChannel, ServerContactChannelCreateOptions, ServerContactChannelUpdateOptions, serverContactChannelCreateOptionsToCrud, serverContactChannelUpdateOptionsToCrud } from \"../../contact-channels\";\nimport { Customer, CustomerProductsList, CustomerProductsRequestOptions, InlineProduct, ServerItem } from \"../../customers\";\nimport { DataVaultStore } from \"../../data-vault\";\nimport { EmailDeliveryInfo, SendEmailOptions } from \"../../email\";\nimport { NotificationCategory } from \"../../notification-categories\";\nimport { scopePasskeyRegistrationToHostname } from \"../../passkey-rp-id\";\nimport { AdminProjectPermissionDefinition, AdminTeamPermission, AdminTeamPermissionDefinition } from \"../../permissions\";\nimport { EditableTeamMemberProfile, ReceivedTeamInvitation, SentTeamInvitation, ServerListTeamsOptions, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamUpdateOptions, ServerTeamUser, Team, serverTeamCreateOptionsToCrud, serverTeamUpdateOptionsToCrud } from \"../../teams\";\nimport { ProjectCurrentServerUser, ServerOAuthProvider, ServerUser, ServerUserCreateOptions, ServerUserUpdateOptions, serverUserCreateOptionsToCrud, serverUserUpdateOptionsToCrud, withUserDestructureGuard } from \"../../users\";\nimport { StackServerAppConstructorOptions } from \"../interfaces/server-app\";\nimport { _HexclaveClientAppImplIncomplete } from \"./client-app-impl\";\nimport { clientVersion, createCache, createCacheBySession, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey, resolveApiUrls, resolveConstructorOptions } from \"./common\";\n\n\nexport class _HexclaveServerAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _HexclaveClientAppImplIncomplete<HasTokenStore, ProjectId> {\n declare protected _interface: HexclaveServerInterface;\n\n // TODO override the client user cache to use the server user cache, so we save some requests\n private readonly _currentServerUserCache = createCacheBySession(async (session) => {\n if (session.isKnownToBeInvalid()) {\n // see comment in _currentUserCache for more details on why we do this\n return null;\n }\n return await this._interface.getServerUserByToken(session);\n });\n private readonly _serverUsersCache = createCache<[\n cursor?: string,\n limit?: number,\n orderBy?: 'signedUpAt' | 'lastActiveAt',\n desc?: boolean,\n query?: string,\n includeRestricted?: boolean,\n includeAnonymous?: boolean,\n onlyAnonymous?: boolean,\n teamId?: string,\n excludedEmailDomains?: string,\n ], UsersCrud['Server']['List']>(async ([cursor, limit, orderBy, desc, query, includeRestricted, includeAnonymous, onlyAnonymous, teamId, excludedEmailDomains]) => {\n if (onlyAnonymous && !includeAnonymous) {\n throw new HexclaveAssertionError(\"onlyAnonymous=true requires includeAnonymous=true\");\n }\n const excludedEmailDomainList = excludedEmailDomains?.split(\",\");\n if (onlyAnonymous) {\n return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query, excludedEmailDomains: excludedEmailDomainList, includeRestricted, includeAnonymous: true, onlyAnonymous: true, teamId });\n }\n return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query, excludedEmailDomains: excludedEmailDomainList, includeRestricted, includeAnonymous, teamId });\n });\n private readonly _serverUserCache = createCache<string[], UsersCrud['Server']['Read'] | null>(async ([userId]) => {\n const user = await this._interface.getServerUserById(userId);\n return Result.or(user, null);\n });\n private readonly _serverTeamsCache = createCache<[\n userId?: string,\n orderBy?: 'createdAt',\n desc?: boolean,\n cursor?: string,\n limit?: number,\n query?: string,\n ], TeamsCrud['Server']['List']>(async ([userId, orderBy, desc, cursor, limit, query]) => {\n return await this._interface.listServerTeamsPaginated({ userId, orderBy, desc, cursor, limit, query });\n });\n private readonly _serverTeamCache = createCache<string[], TeamsCrud['Server']['Read'] | null>(async ([teamId]) => {\n // The previous list-and-find implementation treated unknown or malformed IDs as null; preserve that behavior without making an invalid request.\n if (!isUuid(teamId)) {\n return null;\n }\n try {\n return await this._interface.getServerTeam(teamId);\n } catch (error) {\n if (KnownErrors.TeamNotFound.isInstance(error)) {\n return null;\n }\n throw error;\n }\n });\n\n protected async _refreshTeamMembership(teamId: string, userId: string) {\n await Promise.all([\n this._serverTeamMemberProfilesCache.refresh([teamId]),\n this._serverTeamsCache.refreshWhere(([u]) => u === userId || u === undefined),\n this._serverUsersCache.refreshWhere((key) => key[8] === teamId),\n ]);\n }\n private readonly _serverUserTeamInvitationsCache = createCache<string[], TeamInvitationCrud['Client']['Read'][]>(async ([userId]) => {\n return await this._interface.listServerUserTeamInvitations(userId);\n });\n private readonly _serverTeamUserPermissionsCache = createCache<\n [string, string, boolean],\n TeamPermissionsCrud['Server']['Read'][]\n >(async ([teamId, userId, recursive]) => {\n return await this._interface.listServerTeamPermissions({ teamId, userId, recursive }, null);\n });\n // Bulk variant: one request returning permissions for every member of a\n // team. Used by the dashboard's team-member table to avoid N per-row\n // calls. Keyed without userId so it's a distinct cache entry from the\n // per-user lookup above.\n private readonly _serverAllTeamMemberPermissionsCache = createCache<\n [string, boolean],\n TeamPermissionsCrud['Server']['Read'][]\n >(async ([teamId, recursive]) => {\n return await this._interface.listServerTeamPermissions({ teamId, recursive }, null);\n });\n private readonly _serverUserProjectPermissionsCache = createCache<\n [string, boolean],\n ProjectPermissionsCrud['Server']['Read'][]\n >(async ([userId, recursive]) => {\n return await this._interface.listServerProjectPermissions({ userId, recursive }, null);\n });\n /** @deprecated Used by legacy getConnectedAccount(providerId) — uses old per-provider access token endpoint */\n private readonly _serverUserOAuthConnectionAccessTokensCache = createCache<[string, string, string], { accessToken: string } | null>(\n async ([userId, providerId, scope]) => {\n try {\n const result = await this._interface.createServerProviderAccessToken(userId, providerId, scope || \"\");\n return { accessToken: result.access_token };\n } catch (err) {\n if (!(KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) {\n throw err;\n }\n }\n return null;\n }\n );\n /** @deprecated Used by legacy getConnectedAccount(providerId) — combines token check + redirect */\n private readonly _serverUserOAuthConnectionCache = createCache<[string, ProviderType, string, boolean], DeprecatedOAuthConnection | null>(\n async ([userId, providerId, scope, redirect]) => {\n return await this._getUserOAuthConnectionCacheFn({\n getUser: async () => Result.orThrow(await this._serverUserCache.getOrWait([userId], \"write-only\")),\n getOrWaitOAuthToken: async () => Result.orThrow(await this._serverUserOAuthConnectionAccessTokensCache.getOrWait([userId, providerId, scope || \"\"] as const, \"write-only\")),\n providerId,\n scope,\n redirect,\n session: null,\n });\n }\n );\n private readonly _serverUserConnectedAccountsCache = createCache<[string], OAuthConnection[]>(\n async ([userId]) => {\n const result = await this._interface.listServerConnectedAccounts(userId);\n return result.items.map((item) => this._createServerOAuthConnectionFromCrudItem(userId, item));\n }\n );\n private readonly _serverUserOAuthConnectionAccessTokensByAccountCache = createCache<[string, string, string, string], { accessToken: string } | null>(\n async ([userId, providerId, providerAccountId, scope]) => {\n try {\n const result = await this._interface.createServerProviderAccessTokenByAccount(userId, providerId, providerAccountId, scope || \"\");\n return { accessToken: result.access_token };\n } catch (err) {\n if (!(KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) {\n throw err;\n }\n }\n return null;\n }\n );\n private readonly _serverTeamMemberProfilesCache = createCache<[string], TeamMemberProfilesCrud['Server']['Read'][]>(\n async ([teamId]) => {\n return await this._interface.listServerTeamMemberProfiles({ teamId });\n }\n );\n private readonly _serverTeamInvitationsCache = createCache<[string], TeamInvitationCrud['Server']['Read'][]>(\n async ([teamId]) => {\n return await this._interface.listServerTeamInvitations({ teamId });\n }\n );\n private readonly _serverUserTeamProfileCache = createCache<[string, string], TeamMemberProfilesCrud['Client']['Read']>(\n async ([teamId, userId]) => {\n return await this._interface.getServerTeamMemberProfile({ teamId, userId });\n }\n );\n private readonly _serverContactChannelsCache = createCache<[string], ContactChannelsCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerContactChannels(userId);\n }\n );\n private readonly _serverNotificationCategoriesCache = createCache<[string], NotificationPreferenceCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerNotificationCategories(userId);\n }\n );\n private readonly _serverDataVaultStoreValueCache = createCache<[string, string, string], string | null>(async ([storeId, key, secret]) => {\n return await this._interface.getDataVaultStoreValue(secret, storeId, key);\n });\n\n private readonly _emailDeliveryInfoCache = createCache(async () => {\n return await this._interface.getEmailDeliveryInfo();\n });\n\n private readonly _serverUserApiKeysCache = createCache<[string], UserApiKeysCrud['Server']['Read'][]>(\n async ([userId]) => {\n const result = await this._interface.listProjectApiKeys({\n user_id: userId,\n }, null, \"server\");\n return result as UserApiKeysCrud['Server']['Read'][];\n }\n );\n\n private readonly _serverTeamApiKeysCache = createCache<[string], TeamApiKeysCrud['Server']['Read'][]>(\n async ([teamId]) => {\n const result = await this._interface.listProjectApiKeys({\n team_id: teamId,\n }, null, \"server\");\n return result as TeamApiKeysCrud['Server']['Read'][];\n }\n );\n\n private readonly _convexIdentitySubjectCache = createCache<[ConvexCtx], string | null>(\n async ([ctx]) => {\n const identity = await ctx.auth.getUserIdentity();\n return identity ? identity.subject : null;\n }\n );\n\n private readonly _serverCheckApiKeyCache = createCache<[\"user\" | \"team\", string], UserApiKeysCrud['Server']['Read'] | TeamApiKeysCrud['Server']['Read'] | null>(async ([type, apiKey]) => {\n const result = await this._interface.checkProjectApiKey(\n type,\n apiKey,\n null,\n \"server\",\n );\n return result;\n });\n\n private readonly _serverOAuthProvidersCache = createCache<[string], OAuthProviderCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerOAuthProviders({ user_id: userId });\n }\n );\n\n private readonly _serverTeamItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([teamId, itemId]) => {\n return await this._interface.getItem({ teamId, itemId }, null, \"server\");\n }\n );\n\n private readonly _serverUserItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([userId, itemId]) => {\n return await this._interface.getItem({ userId, itemId }, null, \"server\");\n }\n );\n\n private readonly _serverCustomItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([customCustomerId, itemId]) => {\n return await this._interface.getItem({ customCustomerId, itemId }, null, \"server\");\n }\n );\n\n private readonly _serverUserProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([userId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"user\",\n customer_id: userId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null, \"server\");\n }\n );\n\n private readonly _serverTeamProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([teamId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"team\",\n customer_id: teamId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null, \"server\");\n }\n );\n\n private readonly _serverCustomProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([customCustomerId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"custom\",\n customer_id: customCustomerId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null, \"server\");\n }\n );\n\n protected _createServerCustomer(userIdOrTeamId: string, type: \"user\" | \"team\"): Omit<Customer<true>, \"id\"> {\n const app = this;\n const productsCache = type === \"user\" ? app._serverUserProductsCache : app._serverTeamProductsCache;\n const customerOptions = type === \"user\" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };\n return {\n ...this._createCustomer(userIdOrTeamId, type, null),\n async getItem(itemId: string) {\n return await app.getItem({ itemId, ...customerOptions });\n },\n async grantProduct(productOptions: { productId: string, quantity?: number } | { product: InlineProduct, quantity?: number }) {\n if (type === \"user\") {\n if (\"productId\" in productOptions) {\n await app.grantProduct({ userId: userIdOrTeamId, productId: productOptions.productId, quantity: productOptions.quantity });\n } else {\n await app.grantProduct({ userId: userIdOrTeamId, product: productOptions.product, quantity: productOptions.quantity });\n }\n } else {\n if (\"productId\" in productOptions) {\n await app.grantProduct({ teamId: userIdOrTeamId, productId: productOptions.productId, quantity: productOptions.quantity });\n } else {\n await app.grantProduct({ teamId: userIdOrTeamId, product: productOptions.product, quantity: productOptions.quantity });\n }\n }\n await productsCache.refresh([userIdOrTeamId, null, null]);\n },\n async createCheckoutUrl(options: { productId: string, returnUrl?: string } | { product: InlineProduct, returnUrl?: string }) {\n const productIdOrInline = \"productId\" in options ? options.productId : options.product;\n return await app._interface.createCheckoutUrl(type, userIdOrTeamId, productIdOrInline, null, options.returnUrl, \"server\");\n },\n };\n }\n\n private async _updateServerUser(userId: string, update: ServerUserUpdateOptions): Promise<UsersCrud['Server']['Read']> {\n const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));\n await this._refreshUsers();\n return result;\n }\n\n protected _serverEditableTeamProfileFromCrud(crud: TeamMemberProfilesCrud['Client']['Read']): EditableTeamMemberProfile {\n const app = this;\n return {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n async update(update: { displayName?: string, profileImageUrl?: string }) {\n await app._interface.updateServerTeamMemberProfile({\n teamId: crud.team_id,\n userId: crud.user_id,\n profile: {\n display_name: update.displayName,\n profile_image_url: update.profileImageUrl,\n },\n });\n await app._serverUserTeamProfileCache.refresh([crud.team_id, crud.user_id]);\n }\n };\n }\n\n protected _serverContactChannelFromCrud(userId: string, crud: ContactChannelsCrud['Server']['Read']): ServerContactChannel {\n const app = this;\n return {\n id: crud.id,\n value: crud.value,\n type: crud.type,\n isVerified: crud.is_verified,\n isPrimary: crud.is_primary,\n usedForAuth: crud.used_for_auth,\n async sendVerificationEmail(options?: { callbackUrl?: string }) {\n await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, options?.callbackUrl ?? constructRedirectUrl(app._getUrls().emailVerification, \"callbackUrl\"));\n },\n async update(data: ServerContactChannelUpdateOptions) {\n await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));\n await Promise.all([\n app._serverContactChannelsCache.refresh([userId]),\n app._serverUserCache.refresh([userId])\n ]);\n },\n async delete() {\n await app._interface.deleteServerContactChannel(userId, crud.id);\n await Promise.all([\n app._serverContactChannelsCache.refresh([userId]),\n app._serverUserCache.refresh([userId])\n ]);\n },\n };\n }\n\n protected _serverNotificationCategoryFromCrud(userId: string, crud: NotificationPreferenceCrud['Server']['Read']): NotificationCategory {\n const app = this;\n return {\n id: crud.notification_category_id,\n name: crud.notification_category_name,\n enabled: crud.enabled,\n canDisable: crud.can_disable,\n\n async setEnabled(enabled: boolean) {\n await app._interface.setServerNotificationsEnabled(userId, crud.notification_category_id, enabled);\n await app._serverNotificationCategoriesCache.refresh([userId]);\n },\n };\n }\n\n protected _serverOAuthProviderFromCrud(crud: OAuthProviderCrud['Server']['Read']) {\n const app = this;\n return {\n id: crud.id,\n type: crud.type,\n userId: crud.user_id,\n accountId: crud.account_id,\n email: crud.email,\n allowSignIn: crud.allow_sign_in,\n allowConnectedAccounts: crud.allow_connected_accounts,\n\n async update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >> {\n try {\n await app._interface.updateServerOAuthProvider(crud.user_id, crud.id, {\n account_id: data.accountId,\n email: data.email,\n allow_sign_in: data.allowSignIn,\n allow_connected_accounts: data.allowConnectedAccounts,\n });\n await Promise.all([\n app._serverOAuthProvidersCache.refresh([crud.user_id]),\n app._serverUserConnectedAccountsCache.refresh([crud.user_id]),\n ]);\n return Result.ok(undefined);\n } catch (error) {\n if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) {\n return Result.error(error);\n }\n throw error;\n }\n },\n\n async delete() {\n await app._interface.deleteServerOAuthProvider(crud.user_id, crud.id);\n await Promise.all([\n app._serverOAuthProvidersCache.refresh([crud.user_id]),\n app._serverUserConnectedAccountsCache.refresh([crud.user_id]),\n ]);\n },\n };\n }\n\n constructor(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>, extraOptions?: { uniqueIdentifier?: string, checkString?: string, interface?: HexclaveServerInterface }) {\n const resolvedOptions = resolveConstructorOptions(options);\n\n const publishableClientKey = resolvedOptions.publishableClientKey ?? getDefaultPublishableClientKey();\n\n super(resolvedOptions, {\n ...extraOptions,\n interface: extraOptions?.interface ?? (() => {\n const apiUrls = resolveApiUrls(resolvedOptions.baseUrl);\n return new HexclaveServerInterface({\n getBaseUrl: () => apiUrls()[0],\n getApiUrls: apiUrls,\n projectId: resolvedOptions.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: resolvedOptions.extraRequestHeaders ?? getDefaultExtraRequestHeaders(),\n clientVersion,\n ...(publishableClientKey != null ? { publishableClientKey } : {}),\n secretServerKey: resolvedOptions.secretServerKey ?? getDefaultSecretServerKey(),\n });\n })(),\n });\n }\n\n\n protected _serverApiKeyFromCrud(crud: TeamApiKeysCrud['Client']['Read']): ApiKey<\"team\">;\n protected _serverApiKeyFromCrud(crud: UserApiKeysCrud['Client']['Read']): ApiKey<\"user\">;\n protected _serverApiKeyFromCrud(crud: yup.InferType<typeof teamApiKeysCreateOutputSchema>): ApiKey<\"team\", true>;\n protected _serverApiKeyFromCrud(crud: yup.InferType<typeof userApiKeysCreateOutputSchema>): ApiKey<\"user\", true>;\n protected _serverApiKeyFromCrud(crud: TeamApiKeysCrud['Client']['Read'] | UserApiKeysCrud['Client']['Read'] | yup.InferType<typeof teamApiKeysCreateOutputSchema> | yup.InferType<typeof userApiKeysCreateOutputSchema>): ApiKey<\"user\" | \"team\", boolean> {\n return {\n ...this._baseApiKeyFromCrud(crud),\n async revoke() {\n await this.update({ revoked: true });\n },\n update: async (options: ApiKeyUpdateOptions) => {\n await this._interface.updateProjectApiKey(\n crud.type === \"team\" ? { team_id: crud.team_id } : { user_id: crud.user_id },\n crud.id,\n await apiKeyUpdateOptionsToCrud(crud.type, options),\n null,\n \"server\");\n if (crud.type === \"team\") {\n await this._serverTeamApiKeysCache.refresh([crud.team_id]);\n } else {\n await this._serverUserApiKeysCache.refresh([crud.user_id]);\n }\n },\n };\n }\n\n protected _createServerOAuthConnectionFromCrudItem(\n userId: string,\n item: { provider: string, provider_account_id: string },\n ): OAuthConnection {\n const app = this;\n const providerId = item.provider;\n const providerAccountId = item.provider_account_id;\n return {\n id: providerId, // deprecated, for backward compat\n provider: providerId,\n providerAccountId,\n async getAccessToken(options?: { scopes?: string[] }) {\n const scopeString = options?.scopes?.join(\" \") ?? \"\";\n const result = Result.orThrow(await app._serverUserOAuthConnectionAccessTokensByAccountCache.getOrWait([userId, providerId, providerAccountId, scopeString], \"write-only\"));\n if (!result) {\n const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : \"The OAuth refresh token has likely been revoked or expired.\";\n return Result.error(new KnownErrors.OAuthAccessTokenNotAvailable(providerId, `${scopeDetail} The user needs to re-authorize by calling \\`linkConnectedAccount\\` or using \\`getOrLinkConnectedAccount\\`.`));\n }\n return Result.ok(result);\n },\n };\n }\n\n protected _serverUserFromCrud(crud: UsersCrud['Server']['Read']): ServerUser {\n const app = this;\n\n /** @deprecated The string-based overloads are deprecated. Use `getConnectedAccount({ provider, providerAccountId })` for existence check. */\n async function getConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): Promise<DeprecatedOAuthConnection | null>;\n async function getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<DeprecatedOAuthConnection>;\n async function getConnectedAccount(account: { provider: string, providerAccountId: string }): Promise<OAuthConnection | null>;\n async function getConnectedAccount(\n idOrAccount: ProviderType | { provider: string, providerAccountId: string },\n options?: { or?: 'redirect', scopes?: string[] }\n ): Promise<DeprecatedOAuthConnection | OAuthConnection | null> {\n const scopeString = options?.scopes?.join(\" \") ?? \"\";\n\n // Check if it's the new object-based API\n if (typeof idOrAccount === 'object' && 'provider' in idOrAccount && 'providerAccountId' in idOrAccount) {\n const { provider, providerAccountId } = idOrAccount;\n // Check if the account exists in the connected accounts list\n const connectedAccounts = Result.orThrow(await app._serverUserConnectedAccountsCache.getOrWait([crud.id], \"write-only\"));\n const found = connectedAccounts.find(\n a => a.provider === provider && a.providerAccountId === providerAccountId\n );\n if (!found) {\n return null;\n }\n return found;\n }\n\n // Original behavior: by provider ID (returns first match)\n return Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, idOrAccount, scopeString, options?.or === 'redirect'], \"write-only\"));\n }\n\n\n const serverUser = withUserDestructureGuard({\n ...super._createBaseUser(crud),\n lastActiveAt: new Date(crud.last_active_at_millis),\n serverMetadata: crud.server_metadata,\n restrictedByAdminPrivateDetails: crud.restricted_by_admin_private_details,\n countryCode: crud.country_code,\n riskScores: {\n signUp: {\n bot: crud.risk_scores.sign_up.bot,\n freeTrialAbuse: crud.risk_scores.sign_up.free_trial_abuse,\n },\n },\n async setPrimaryEmail(email: string | null, options?: { verified?: boolean }) {\n await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });\n },\n async grantPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<void> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string' && permissionId) {\n const scope = scopeOrPermissionId;\n await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);\n\n for (const recursive of [true, false]) {\n await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);\n await app._serverAllTeamMemberPermissionsCache.refresh([scope.id, recursive]);\n }\n } else {\n const pId = scopeOrPermissionId as string;\n await app._interface.grantServerProjectPermission(crud.id, pId);\n\n for (const recursive of [true, false]) {\n await app._serverUserProjectPermissionsCache.refresh([crud.id, recursive]);\n }\n }\n },\n async revokePermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<void> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string' && permissionId) {\n const scope = scopeOrPermissionId;\n await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);\n\n for (const recursive of [true, false]) {\n await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);\n await app._serverAllTeamMemberPermissionsCache.refresh([scope.id, recursive]);\n }\n } else {\n const pId = scopeOrPermissionId as string;\n await app._interface.revokeServerProjectPermission(crud.id, pId);\n\n for (const recursive of [true, false]) {\n await app._serverUserProjectPermissionsCache.refresh([crud.id, recursive]);\n }\n }\n },\n async delete() {\n const res = await app._interface.deleteServerUser(crud.id);\n await app._refreshUsers();\n return res;\n },\n async createSession(options: { expiresInMillis?: number, isImpersonation?: boolean }) {\n // TODO this should also refresh the access token when it expires (like InternalSession)\n const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1000 * 60 * 60 * 24 * 365, options.isImpersonation ?? false);\n return {\n async getTokens() {\n return tokens;\n },\n };\n },\n\n async getActiveSessions() {\n const sessions = await app._interface.listServerSessions(crud.id);\n return sessions.items.map((session) => app._clientSessionFromCrud(session));\n },\n\n async revokeSession(sessionId: string) {\n await app._interface.deleteServerSession(sessionId);\n },\n async setDisplayName(displayName: string | null) {\n return await this.update({ displayName });\n },\n async setClientMetadata(metadata: Record<string, any>) {\n return await this.update({ clientMetadata: metadata });\n },\n async setClientReadOnlyMetadata(metadata: Record<string, any>) {\n return await this.update({ clientReadOnlyMetadata: metadata });\n },\n async setServerMetadata(metadata: Record<string, any>) {\n return await this.update({ serverMetadata: metadata });\n },\n async setSelectedTeam(team: Team | string | null) {\n return await this.update({ selectedTeamId: typeof team === 'string' ? team : team?.id ?? null });\n },\n getConnectedAccount,\n async listConnectedAccounts() {\n return Result.orThrow(await app._serverUserConnectedAccountsCache.getOrWait([crud.id], \"write-only\"));\n },\n async linkConnectedAccount(): Promise<void> {\n throw new HexclaveAssertionError(\"linkConnectedAccount is not available for server users. OAuth flows must be initiated on the client side.\");\n },\n async getOrLinkConnectedAccount(): Promise<OAuthConnection> {\n throw new HexclaveAssertionError(\"getOrLinkConnectedAccount is not available for server users. OAuth flows must be initiated on the client side.\");\n },\n selectedTeam: crud.selected_team ? app._serverTeamFromCrud(crud.selected_team) : null,\n // Unlike the app-level getTeam/useTeam (which fetch any team by id),\n // the user-scoped variants search the user's own team list on purpose:\n // they must return null for teams the user is not a member of, and some\n // callers rely on that as a membership check.\n async getTeam(teamId: string) {\n const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n },\n async listTeams(options?: ServerListTeamsOptions): Promise<ServerTeam[] & { nextCursor: string | null }> {\n const result = Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id, options?.orderBy, options?.desc, options?.cursor, options?.limit, options?.query] as const, \"write-only\"));\n const teams: any = result.items.map((t) => app._serverTeamFromCrud(t));\n teams.nextCursor = result.pagination?.next_cursor ?? null;\n return teams as any;\n },\n createTeam: async (data: Omit<ServerTeamCreateOptions, \"creatorUserId\">) => {\n const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({\n creatorUserId: crud.id,\n ...data,\n }));\n await app._serverTeamsCache.refreshWhere(() => true);\n await app._updateServerUser(crud.id, { selectedTeamId: team.id });\n return app._serverTeamFromCrud(team);\n },\n leaveTeam: async (team: Team) => {\n await app._interface.leaveServerTeam({ teamId: team.id, userId: crud.id });\n await app._refreshTeamMembership(team.id, crud.id);\n },\n async listTeamInvitations() {\n const invitations = Result.orThrow(await app._serverUserTeamInvitationsCache.getOrWait([crud.id], \"write-only\"));\n return invitations.map((inv) => app._serverReceivedTeamInvitationFromCrud(crud.id, inv));\n },\n async listPermissions(scopeOrOptions?: Team | { recursive?: boolean }, options?: { recursive?: boolean }): Promise<AdminTeamPermission[]> {\n if (scopeOrOptions && 'id' in scopeOrOptions) {\n const scope = scopeOrOptions;\n const recursive = options?.recursive ?? true;\n const permissions = Result.orThrow(await app._serverTeamUserPermissionsCache.getOrWait([scope.id, crud.id, recursive], \"write-only\"));\n return permissions.map((crud) => app._serverPermissionFromCrud(crud));\n } else {\n const opts = scopeOrOptions;\n const recursive = opts?.recursive ?? true;\n const permissions = Result.orThrow(await app._serverUserProjectPermissionsCache.getOrWait([crud.id, recursive], \"write-only\"));\n return permissions.map((crud) => app._serverPermissionFromCrud(crud));\n }\n },\n async getPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<AdminTeamPermission | null> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n const permissions = await this.listPermissions(scope);\n return permissions.find((p) => p.id === permissionId) ?? null;\n } else {\n const pid = scopeOrPermissionId;\n const permissions = await this.listPermissions();\n return permissions.find((p) => p.id === pid) ?? null;\n }\n },\n async hasPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<boolean> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n return (await this.getPermission(scope, permissionId as string)) !== null;\n } else {\n const pid = scopeOrPermissionId;\n return (await this.getPermission(pid)) !== null;\n }\n },\n async update(update: ServerUserUpdateOptions) {\n await app._updateServerUser(crud.id, update);\n },\n async sendVerificationEmail() {\n return await app._checkFeatureSupport(\"sendVerificationEmail() on ServerUser\", {});\n },\n async updatePassword(options: { oldPassword: string, newPassword: string }) {\n const result = await app._interface.updatePassword(options);\n await app._serverUserCache.refresh([crud.id]);\n return result;\n },\n async setPassword(options: { password: string }) {\n const result = await this.update(options);\n await app._serverUserCache.refresh([crud.id]);\n return result;\n },\n async getTeamProfile(team: Team) {\n const result = Result.orThrow(await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], \"write-only\"));\n return app._serverEditableTeamProfileFromCrud(result);\n },\n async listContactChannels() {\n const result = Result.orThrow(await app._serverContactChannelsCache.getOrWait([crud.id], \"write-only\"));\n return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));\n },\n createContactChannel: async (data: ServerContactChannelCreateOptions) => {\n const contactChannel = await app._interface.createServerContactChannel(serverContactChannelCreateOptionsToCrud(crud.id, data));\n await Promise.all([\n app._serverContactChannelsCache.refresh([crud.id]),\n app._serverUserCache.refresh([crud.id])\n ]);\n return app._serverContactChannelFromCrud(crud.id, contactChannel);\n },\n async listNotificationCategories() {\n const results = Result.orThrow(await app._serverNotificationCategoriesCache.getOrWait([crud.id], \"write-only\"));\n return results.map((category) => app._serverNotificationCategoryFromCrud(crud.id, category));\n },\n async listApiKeys() {\n const result = Result.orThrow(await app._serverUserApiKeysCache.getOrWait([crud.id], \"write-only\"));\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async createApiKey(options: ApiKeyCreationOptions<\"user\">) {\n const result = await app._interface.createProjectApiKey(\n await apiKeyCreationOptionsToCrud(\"user\", crud.id, options),\n null,\n \"server\",\n );\n await app._serverUserApiKeysCache.refresh([crud.id]);\n return app._serverApiKeyFromCrud(result);\n },\n\n async listOAuthProviders() {\n const results = Result.orThrow(await app._serverOAuthProvidersCache.getOrWait([crud.id], \"write-only\"));\n return results.map((oauthCrud) => app._serverOAuthProviderFromCrud(oauthCrud));\n },\n\n async getOAuthProvider(id: string) {\n const providers = await this.listOAuthProviders();\n return providers.find((p) => p.id === id) ?? null;\n },\n async registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>> {\n const hostname = options?.hostname || (await app._getCurrentUrl())?.hostname;\n if (!hostname) {\n throw new HexclaveAssertionError(\"hostname must be provided if the Stack App does not have a redirect method\");\n }\n\n // Use server interface to initiate passkey registration for this specific user\n const initiationResult = await app._interface.initiateServerPasskeyRegistration(crud.id);\n\n if (initiationResult.status !== \"ok\") {\n return Result.error(new KnownErrors.PasskeyRegistrationFailed(\"Failed to get initiation options for passkey registration\"));\n }\n\n const { options_json, code } = initiationResult.data;\n\n scopePasskeyRegistrationToHostname(options_json, hostname);\n\n let attResp;\n try {\n attResp = await startRegistration({ optionsJSON: options_json });\n } catch (error: any) {\n if (error instanceof WebAuthnError) {\n return Result.error(new KnownErrors.PasskeyWebAuthnError(error.message, error.name));\n } else {\n // This should never happen\n captureError(\"passkey-registration-failed\", error);\n return Result.error(new KnownErrors.PasskeyRegistrationFailed(\"Failed to start passkey registration due to unknown error\"));\n }\n }\n\n // Create a temporary session to complete the registration\n // TODO instead of creating a new session, this should just call the endpoint in a way in which it doesn't require a session\n // (currently this shows up on session history etc... not ideal)\n const { accessToken, refreshToken } = await app._interface.createServerUserSession(crud.id, 60000 * 2, false);\n const tempSession = new InternalSession({\n accessToken,\n refreshToken,\n refreshAccessTokenCallback: async () => null,\n });\n\n const registrationResult = await app._interface.registerPasskey({ credential: attResp, code }, tempSession);\n\n await app._serverUserCache.refresh([crud.id]);\n return registrationResult;\n },\n ...app._createServerCustomer(crud.id, \"user\"),\n } satisfies ServerUser);\n\n return serverUser;\n }\n\n protected _serverTeamUserFromCrud(crud: TeamMemberProfilesCrud[\"Server\"][\"Read\"]): ServerTeamUser {\n const teamUser = withUserDestructureGuard({\n ...this._serverUserFromCrud(crud.user),\n teamProfile: {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n },\n } satisfies ServerTeamUser);\n\n return teamUser;\n }\n\n protected _serverSentTeamInvitationFromCrud(crud: TeamInvitationCrud['Server']['Read']): SentTeamInvitation {\n return {\n id: crud.id,\n recipientEmail: crud.recipient_email,\n expiresAt: new Date(crud.expires_at_millis),\n revoke: async () => {\n await this._interface.revokeServerTeamInvitation(crud.id, crud.team_id);\n await this._serverTeamInvitationsCache.refresh([crud.team_id]);\n },\n };\n }\n\n protected _serverReceivedTeamInvitationFromCrud(userId: string, crud: TeamInvitationCrud['Client']['Read']): ReceivedTeamInvitation {\n const app = this;\n return {\n id: crud.id,\n teamId: crud.team_id,\n teamDisplayName: crud.team_display_name,\n recipientEmail: crud.recipient_email,\n expiresAt: new Date(crud.expires_at_millis),\n accept: async () => {\n await app._interface.acceptServerTeamInvitationById(crud.id, userId);\n await Promise.all([\n app._serverUserTeamInvitationsCache.refresh([userId]),\n app._serverTeamInvitationsCache.refresh([crud.team_id]),\n app._refreshTeamMembership(crud.team_id, userId),\n ]);\n },\n };\n }\n\n protected override _currentUserFromCrud(crud: UsersCrud['Server']['Read'], session: InternalSession): ProjectCurrentServerUser<ProjectId> {\n const currentUser = withUserDestructureGuard({\n ...this._serverUserFromCrud(crud),\n ...this._createAuth(session),\n ...this._isInternalProject() ? this._createInternalUserExtra(session) : {},\n } satisfies ServerUser);\n\n return currentUser as ProjectCurrentServerUser<ProjectId>;\n }\n\n protected _serverTeamFromCrud(crud: TeamsCrud['Server']['Read']): ServerTeam {\n const app = this;\n return {\n id: crud.id,\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n createdAt: new Date(crud.created_at_millis),\n clientMetadata: crud.client_metadata,\n clientReadOnlyMetadata: crud.client_read_only_metadata,\n serverMetadata: crud.server_metadata,\n async update(update: Partial<ServerTeamUpdateOptions>) {\n await app._interface.updateServerTeam(crud.id, serverTeamUpdateOptionsToCrud(update));\n await Promise.all([\n app._serverTeamCache.refresh([crud.id]),\n app._serverTeamsCache.refreshWhere(() => true),\n app._serverUsersCache.refreshWhere(() => true),\n ]);\n },\n async delete() {\n await app._interface.deleteServerTeam(crud.id);\n await Promise.all([\n app._serverTeamCache.refresh([crud.id]),\n app._serverTeamsCache.refreshWhere(() => true),\n app._serverUsersCache.refreshWhere(() => true),\n ]);\n },\n async listUsers() {\n const result = Result.orThrow(await app._serverTeamMemberProfilesCache.getOrWait([crud.id], \"write-only\"));\n return result.map(u => app._serverTeamUserFromCrud(u));\n },\n async addUser(userId) {\n await app._interface.addServerUserToTeam({\n teamId: crud.id,\n userId,\n });\n await app._refreshTeamMembership(crud.id, userId);\n },\n async removeUser(userId) {\n await app._interface.removeServerUserFromTeam({\n teamId: crud.id,\n userId,\n });\n await app._refreshTeamMembership(crud.id, userId);\n },\n async inviteUser(options: { email: string, callbackUrl?: string }) {\n await app._interface.sendServerTeamInvitation({\n teamId: crud.id,\n email: options.email,\n callbackUrl: options.callbackUrl ?? constructRedirectUrl(app._getUrls().teamInvitation, \"callbackUrl\"),\n });\n await app._serverTeamInvitationsCache.refresh([crud.id]);\n },\n async listInvitations() {\n const result = Result.orThrow(await app._serverTeamInvitationsCache.getOrWait([crud.id], \"write-only\"));\n return result.map((crud) => app._serverSentTeamInvitationFromCrud(crud));\n },\n async listApiKeys() {\n const result = Result.orThrow(await app._serverTeamApiKeysCache.getOrWait([crud.id], \"write-only\"));\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async createApiKey(options: ApiKeyCreationOptions<\"team\">) {\n const result = await app._interface.createProjectApiKey(\n await apiKeyCreationOptionsToCrud(\"team\", crud.id, options),\n null,\n \"server\",\n );\n await app._serverTeamApiKeysCache.refresh([crud.id]);\n return app._serverApiKeyFromCrud(result);\n },\n ...app._createServerCustomer(crud.id, \"team\"),\n };\n }\n\n protected _serverItemFromCrud(customer: { type: \"user\" | \"team\" | \"custom\", id: string }, crud: ItemCrud['Client']['Read']): ServerItem {\n const app = this;\n return {\n displayName: crud.display_name,\n quantity: crud.quantity,\n nonNegativeQuantity: Math.max(0, crud.quantity),\n increaseQuantity: async (delta: number) => {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n },\n decreaseQuantity: async (delta: number) => {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta: -delta, allow_negative: true });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n },\n tryDecreaseQuantity: async (delta: number) => {\n try {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta: -delta });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n return true;\n } catch (error) {\n if (error instanceof KnownErrors.ItemQuantityInsufficientAmount) {\n return false;\n }\n throw error;\n }\n },\n };\n }\n\n protected async _getUserApiKey(options: { apiKey: string }): Promise<ApiKey<\"user\"> | null> {\n const crud = Result.orThrow(await this._serverCheckApiKeyCache.getOrWait([\"user\", options.apiKey], \"write-only\")) as UserApiKeysCrud['Server']['Read'] | null;\n return crud ? this._serverApiKeyFromCrud(crud) : null;\n }\n\n protected async _getTeamApiKey(options: { apiKey: string }): Promise<ApiKey<\"team\"> | null> {\n const crud = Result.orThrow(await this._serverCheckApiKeyCache.getOrWait([\"team\", options.apiKey], \"write-only\")) as TeamApiKeysCrud['Server']['Read'] | null;\n return crud ? this._serverApiKeyFromCrud(crud) : null;\n }\n protected async _getUserByApiKey(apiKey: string): Promise<ServerUser | null> {\n const apiKeyObject = await this._getUserApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return await this.getServerUserById(apiKeyObject.userId);\n }\n\n protected async _getUserByConvex(ctx: ConvexCtx, includeAnonymous: boolean): Promise<ServerUser | null> {\n const identity = await ctx.auth.getUserIdentity();\n if (identity === null) {\n return null;\n }\n const user = await this.getServerUserById(identity.subject);\n if (user?.isAnonymous && !includeAnonymous) {\n return null;\n }\n return user;\n }\n\n protected async _getTeamByApiKey(apiKey: string): Promise<ServerTeam | null> {\n const apiKeyObject = await this._getTeamApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return await this.getTeam(apiKeyObject.teamId);\n }\n\n async createUser(options: ServerUserCreateOptions): Promise<ServerUser> {\n const crud = await this._interface.createServerUser(serverUserCreateOptionsToCrud(options));\n await this._refreshUsers();\n return this._serverUserFromCrud(crud);\n }\n\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;\n async getUser(id: string): Promise<ServerUser | null>;\n async getUser(options: { apiKey: string }): Promise<ServerUser | null>;\n async getUser(options: { from: \"convex\", ctx: ConvexCtx, or?: \"return-null\" | \"anonymous\" }): Promise<ServerUser | null>;\n async getUser(options?: string | GetCurrentUserOptions<HasTokenStore> | { apiKey: string } | { from: \"convex\", ctx: ConvexCtx }): Promise<ProjectCurrentServerUser<ProjectId> | ServerUser | null> {\n if (typeof options === \"string\") {\n return await this.getServerUserById(options);\n } else if (typeof options === \"object\" && \"apiKey\" in options) {\n return await this._getUserByApiKey(options.apiKey);\n } else if (typeof options === \"object\" && \"from\" in options && options.from as string === \"convex\") {\n return await this._getUserByConvex(options.ctx, \"or\" in options && options.or === \"anonymous\");\n } else {\n options = options as GetCurrentUserOptions<HasTokenStore> | undefined;\n\n // Validate that includeRestricted: false and or: 'anonymous' are mutually exclusive\n if (options?.or === 'anonymous' && options.includeRestricted === false) {\n throw new Error(\"Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.\");\n }\n\n // TODO this code is duplicated from the client app; fix that\n this._ensurePersistentTokenStore(options?.tokenStore);\n const session = await this._getSession(options?.tokenStore);\n let crud = Result.orThrow(await this._currentServerUserCache.getOrWait([session], \"write-only\"));\n const includeAnonymous = options?.or === \"anonymous\" || options?.or === \"anonymous-if-exists[deprecated]\";\n const includeRestricted = options?.includeRestricted === true || includeAnonymous;\n\n if (crud === null || (crud.is_anonymous && !includeAnonymous) || (crud.is_restricted && !includeRestricted)) {\n switch (options?.or) {\n case 'redirect': {\n if (!crud?.is_anonymous && crud?.is_restricted) {\n await this.redirectToOnboarding({ replace: true });\n } else {\n await this.redirectToSignIn({ replace: true });\n }\n // TODO: see client-app-impl. We probably want to `await neverResolve()` here instead of returning null\n break;\n }\n case 'throw': {\n throw new Error(\"User is not signed in but getUser was called with { or: 'throw' }\");\n }\n case 'anonymous': {\n const tokens = await this._signUpAnonymously();\n return await this.getUser({ tokenStore: tokens, or: \"anonymous-if-exists[deprecated]\", includeRestricted: true }) ?? throwErr(\"Something went wrong while signing up anonymously\");\n }\n case undefined:\n case \"anonymous-if-exists[deprecated]\":\n case \"return-null\": {\n return null;\n }\n }\n }\n\n return crud && this._currentUserFromCrud(crud, session);\n }\n }\n\n async getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null> {\n console.warn(\"hexclaveServerApp.getServerUser is deprecated; use hexclaveServerApp.getUser instead\");\n return await this.getUser();\n }\n\n async getServerUserById(userId: string): Promise<ServerUser | null> {\n const crud = Result.orThrow(await this._serverUserCache.getOrWait([userId], \"write-only\"));\n return crud && this._serverUserFromCrud(crud);\n }\n\n\n async listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & { nextCursor: string | null }> {\n const excludedEmailDomains = options?.excludedEmailDomains && options.excludedEmailDomains.length > 0 ? options.excludedEmailDomains.join(\",\") : undefined;\n const crud = Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query, options?.includeRestricted, options?.includeAnonymous, options?.onlyAnonymous, options?.teamId, excludedEmailDomains], \"write-only\"));\n const result: any = crud.items.map((j) => this._serverUserFromCrud(j));\n result.nextCursor = crud.pagination?.next_cursor ?? null;\n return result as any;\n }\n\n\n _serverPermissionFromCrud(crud: TeamPermissionsCrud['Server']['Read'] | ProjectPermissionsCrud['Server']['Read']): AdminTeamPermission {\n return {\n id: crud.id,\n };\n }\n\n _serverTeamPermissionDefinitionFromCrud(crud: TeamPermissionDefinitionsCrud['Admin']['Read']): AdminTeamPermissionDefinition {\n return {\n id: crud.id,\n description: crud.description,\n containedPermissionIds: crud.contained_permission_ids,\n };\n }\n\n _serverProjectPermissionDefinitionFromCrud(crud: ProjectPermissionDefinitionsCrud['Admin']['Read']): AdminProjectPermissionDefinition {\n return {\n id: crud.id,\n description: crud.description,\n containedPermissionIds: crud.contained_permission_ids,\n };\n }\n\n async getItem(options: { itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }): Promise<ServerItem> {\n if (\"userId\" in options) {\n const result = Result.orThrow(await this._serverUserItemsCache.getOrWait([options.userId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"user\", id: options.userId }, result);\n } else if (\"teamId\" in options) {\n const result = Result.orThrow(await this._serverTeamItemsCache.getOrWait([options.teamId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"team\", id: options.teamId }, result);\n } else {\n const result = Result.orThrow(await this._serverCustomItemsCache.getOrWait([options.customCustomerId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"custom\", id: options.customCustomerId }, result);\n }\n }\n\n protected async _refreshItemCache(customerType: \"user\" | \"team\" | \"custom\", customerId: string, itemId: string): Promise<void> {\n if (customerType === \"user\") {\n await this._serverUserItemsCache.refresh([customerId, itemId]);\n } else if (customerType === \"team\") {\n await this._serverTeamItemsCache.refresh([customerId, itemId]);\n } else {\n await this._serverCustomItemsCache.refresh([customerId, itemId]);\n }\n }\n\n async listProducts(options: CustomerProductsRequestOptions): Promise<CustomerProductsList> {\n if (\"userId\" in options) {\n const response = Result.orThrow(await this._serverUserProductsCache.getOrWait([options.userId, options.cursor ?? null, options.limit ?? null], \"write-only\"));\n return this._customerProductsFromResponse(response);\n } else if (\"teamId\" in options) {\n const response = Result.orThrow(await this._serverTeamProductsCache.getOrWait([options.teamId, options.cursor ?? null, options.limit ?? null], \"write-only\"));\n return this._customerProductsFromResponse(response);\n }\n const response = Result.orThrow(await this._serverCustomProductsCache.getOrWait([options.customCustomerId, options.cursor ?? null, options.limit ?? null], \"write-only\"));\n return this._customerProductsFromResponse(response);\n }\n\n private _resolveCustomer(\n options: { userId: string } | { teamId: string } | { customCustomerId: string }\n ): { customerType: \"user\" | \"team\" | \"custom\", customerId: string } {\n if (\"userId\" in options) {\n return { customerType: \"user\", customerId: options.userId };\n }\n if (\"teamId\" in options) {\n return { customerType: \"team\", customerId: options.teamId };\n }\n return { customerType: \"custom\", customerId: options.customCustomerId };\n }\n\n async grantProduct(options: (\n ({ userId: string } | { teamId: string } | { customCustomerId: string }) &\n ({ productId: string } | { product: InlineProduct }) &\n { quantity?: number }\n )): Promise<void> {\n const { customerType, customerId } = this._resolveCustomer(options);\n\n await this._interface.grantProduct({\n customerType,\n customerId,\n productId: \"productId\" in options ? options.productId : undefined,\n product: \"product\" in options ? options.product : undefined,\n quantity: options.quantity,\n });\n\n const cache = customerType === \"user\"\n ? this._serverUserProductsCache\n : customerType === \"team\"\n ? this._serverTeamProductsCache\n : this._serverCustomProductsCache;\n await cache.refresh([customerId, null, null]);\n }\n\n async createCheckoutUrl(options: (\n ({ userId: string } | { teamId: string } | { customCustomerId: string }) &\n ({ productId: string } | { product: InlineProduct }) &\n { returnUrl?: string }\n )): Promise<string> {\n const { customerType, customerId } = this._resolveCustomer(options);\n\n const productIdOrInline = \"productId\" in options ? options.productId : options.product;\n return await this._interface.createCheckoutUrl(customerType, customerId, productIdOrInline, null, options.returnUrl, \"server\");\n }\n\n async createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam> {\n const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));\n await this._serverTeamCache.refresh([team.id]);\n await this._serverTeamsCache.refreshWhere(() => true);\n return this._serverTeamFromCrud(team);\n }\n\n async listTeams(options?: ServerListTeamsOptions): Promise<ServerTeam[] & { nextCursor: string | null }> {\n const crud = Result.orThrow(await this._serverTeamsCache.getOrWait([undefined, options?.orderBy, options?.desc, options?.cursor, options?.limit, options?.query] as const, \"write-only\"));\n const teams: any = crud.items.map((t) => this._serverTeamFromCrud(t));\n teams.nextCursor = crud.pagination?.next_cursor ?? null;\n return teams as any;\n }\n\n\n async listTeamMemberPermissions(teamId: string, options?: { recursive?: boolean }): Promise<{ userId: string, permissionId: string }[]> {\n const recursive = options?.recursive ?? false;\n const rows = Result.orThrow(await this._serverAllTeamMemberPermissionsCache.getOrWait([teamId, recursive] as const, \"write-only\"));\n return rows.map((r) => ({ userId: r.user_id, permissionId: r.id }));\n }\n\n\n async getTeam(options: { apiKey: string }): Promise<ServerTeam | null>;\n async getTeam(teamId: string): Promise<ServerTeam | null>;\n async getTeam(options?: { apiKey: string } | string): Promise<ServerTeam | null> {\n if (typeof options === \"object\" && \"apiKey\" in options) {\n return await this._getTeamByApiKey(options.apiKey);\n } else {\n const teamId = options;\n if (teamId == null) {\n return null;\n }\n const team = Result.orThrow(await this._serverTeamCache.getOrWait([teamId], \"write-only\"));\n return team == null ? null : this._serverTeamFromCrud(team);\n }\n }\n\n\n protected _createServerDataVaultStore(id: string): DataVaultStore {\n const validateOptions = (options: { secret: string }) => {\n if (typeof options.secret !== \"string\") throw new Error(\"secret must be a string, got \" + typeof options.secret);\n };\n return {\n id,\n setValue: async (key, value, options) => {\n validateOptions(options);\n await this._interface.setDataVaultStoreValue(options.secret, id, key, value);\n },\n getValue: async (key, options) => {\n validateOptions(options);\n return Result.orThrow(await this._serverDataVaultStoreValueCache.getOrWait([id, key, options.secret], \"write-only\"));\n },\n };\n }\n\n async getDataVaultStore(id: string): Promise<DataVaultStore> {\n return this._createServerDataVaultStore(id);\n }\n\n\n async sendEmail(options: SendEmailOptions): Promise<void> {\n await this._interface.sendEmail(options);\n await this._emailDeliveryInfoCache.refresh([]);\n }\n\n async getEmailDeliveryStats(): Promise<EmailDeliveryInfo> {\n return Result.orThrow(await this._emailDeliveryInfoCache.getOrWait([], \"write-only\"));\n }\n\n\n async activateEmailCapacityBoost(): Promise<void> {\n await this._interface.activateEmailCapacityBoost();\n // Refresh the cache so UI updates immediately\n await this._emailDeliveryInfoCache.refresh([]);\n }\n\n async queryAnalytics(options: AnalyticsQueryOptions): Promise<AnalyticsQueryResponse> {\n return await this._interface.queryAnalytics(options);\n }\n\n async listSessionReplays(options?: ListSessionReplaysOptions): Promise<ListSessionReplaysResult> {\n const response = await this._interface.listSessionReplays({\n cursor: options?.cursor,\n limit: options?.limit,\n user_ids: options?.userIds,\n team_ids: options?.teamIds,\n duration_ms_min: options?.durationMsMin,\n duration_ms_max: options?.durationMsMax,\n last_event_at_from_millis: options?.lastEventAtFromMillis,\n last_event_at_to_millis: options?.lastEventAtToMillis,\n click_count_min: options?.clickCountMin,\n });\n\n const items: AdminSessionReplay[] = response.items.map((r) => ({\n id: r.id,\n refreshTokenId: r.refresh_token_id,\n projectUser: {\n id: r.project_user.id,\n displayName: r.project_user.display_name,\n primaryEmail: r.project_user.primary_email,\n },\n startedAt: new Date(r.started_at_millis),\n lastEventAt: new Date(r.last_event_at_millis),\n chunkCount: r.chunk_count,\n eventCount: r.event_count,\n }));\n\n return {\n items,\n nextCursor: response.pagination.next_cursor,\n };\n }\n\n async getSessionReplay(sessionReplayId: string): Promise<AdminSessionReplay> {\n const response = await this._interface.getSessionReplay(sessionReplayId);\n return {\n id: response.id,\n refreshTokenId: response.refresh_token_id,\n projectUser: {\n id: response.project_user.id,\n displayName: response.project_user.display_name,\n primaryEmail: response.project_user.primary_email,\n },\n startedAt: new Date(response.started_at_millis),\n lastEventAt: new Date(response.last_event_at_millis),\n chunkCount: response.chunk_count,\n eventCount: response.event_count,\n };\n }\n\n async listSessionReplayChunks(sessionReplayId: string, options?: ListSessionReplayChunksOptions): Promise<ListSessionReplayChunksResult> {\n const response = await this._interface.listSessionReplayChunks(sessionReplayId, {\n cursor: options?.cursor,\n limit: options?.limit,\n });\n\n const items: AdminSessionReplayChunk[] = response.items.map((c) => ({\n id: c.id,\n batchId: c.batch_id,\n sessionReplaySegmentId: c.session_replay_segment_id,\n browserSessionId: c.browser_session_id,\n eventCount: c.event_count,\n byteLength: c.byte_length,\n firstEventAt: new Date(c.first_event_at_millis),\n lastEventAt: new Date(c.last_event_at_millis),\n createdAt: new Date(c.created_at_millis),\n }));\n\n return {\n items,\n nextCursor: response.pagination.next_cursor,\n };\n }\n\n async getSessionReplayChunkEvents(sessionReplayId: string, chunkId: string): Promise<AdminGetSessionReplayChunkEventsResponse> {\n return await this._interface.getSessionReplayChunkEvents(sessionReplayId, chunkId);\n }\n\n async getSessionReplayEvents(sessionReplayId: string, options?: { offset?: number, limit?: number }): Promise<SessionReplayAllEventsResult> {\n const response = await this._interface.getSessionReplayEvents(sessionReplayId, options);\n return {\n chunks: response.chunks.map((c) => ({\n id: c.id,\n batchId: c.batch_id,\n sessionReplaySegmentId: c.session_replay_segment_id,\n eventCount: c.event_count,\n byteLength: c.byte_length,\n firstEventAt: new Date(c.first_event_at_millis),\n lastEventAt: new Date(c.last_event_at_millis),\n createdAt: new Date(c.created_at_millis),\n })),\n chunkEvents: response.chunk_events.map((ce) => ({\n chunkId: ce.chunk_id,\n events: ce.events,\n })),\n };\n }\n\n protected override async _refreshSession(session: InternalSession) {\n await Promise.all([\n super._refreshUser(session),\n this._currentServerUserCache.refresh([session]),\n ]);\n }\n\n protected override async _refreshUsers() {\n await Promise.all([\n super._refreshUsers(),\n this._serverUserCache.refreshWhere(() => true),\n this._serverUsersCache.refreshWhere(() => true),\n this._serverContactChannelsCache.refreshWhere(() => true),\n this._serverOAuthProvidersCache.refreshWhere(() => true),\n this._serverUserConnectedAccountsCache.refreshWhere(() => true),\n ]);\n }\n\n async createOAuthProvider(options: {\n userId: string,\n providerConfigId: string,\n accountId: string,\n email: string,\n allowSignIn: boolean,\n allowConnectedAccounts: boolean,\n }): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>> {\n try {\n const crud = await this._interface.createServerOAuthProvider({\n user_id: options.userId,\n provider_config_id: options.providerConfigId,\n account_id: options.accountId,\n email: options.email,\n allow_sign_in: options.allowSignIn,\n allow_connected_accounts: options.allowConnectedAccounts,\n });\n\n await Promise.all([\n this._serverOAuthProvidersCache.refresh([options.userId]),\n this._serverUserConnectedAccountsCache.refresh([options.userId]),\n ]);\n return Result.ok(this._serverOAuthProviderFromCrud(crud));\n } catch (error) {\n if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) {\n return Result.error(error);\n }\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgDA,IAAa,mCAAb,cAA+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,0BAA0B,QAAQ;GACpC,CAAC;GAED,MAAM,QAAQ,IAAI,CAChB,KAAK,2BAA2B,QAAQ,CAAC,QAAQ,MAAM,CAAC,GACxD,KAAK,kCAAkC,QAAQ,CAAC,QAAQ,MAAM,CAAC,CACjE,CAAC;GACD,OAAOA,oCAAAA,OAAO,GAAG,KAAK,6BAA6B,IAAI,CAAC;EAC1D,SAAS,OAAO;GACd,IAAIC,iBAAAA,YAAY,2CAA2C,WAAW,KAAK,GACzE,OAAOD,oCAAAA,OAAO,MAAM,KAAK;GAE3B,MAAM;EACR;CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { B as StackServerAppConstructor, D as HexclaveAdminApp, F as StackAdminAppConstructorOptions, I as HexclaveServerApp, L as HexclaveServerAppConstructor, N as StackAdminApp, O as HexclaveAdminAppConstructor, P as StackAdminAppConstructor, R as HexclaveServerAppConstructorOptions, V as StackServerAppConstructorOptions, a as StackClientApp, c as StackClientAppJson, i as HexclaveClientAppJson, k as HexclaveAdminAppConstructorOptions, n as HexclaveClientAppConstructor, o as StackClientAppConstructor, r as HexclaveClientAppConstructorOptions, s as StackClientAppConstructorOptions, t as HexclaveClientApp, z as StackServerApp } from "../../../client-app-
|
|
1
|
+
import { B as StackServerAppConstructor, D as HexclaveAdminApp, F as StackAdminAppConstructorOptions, I as HexclaveServerApp, L as HexclaveServerAppConstructor, N as StackAdminApp, O as HexclaveAdminAppConstructor, P as StackAdminAppConstructor, R as HexclaveServerAppConstructorOptions, V as StackServerAppConstructorOptions, a as StackClientApp, c as StackClientAppJson, i as HexclaveClientAppJson, k as HexclaveAdminAppConstructorOptions, n as HexclaveClientAppConstructor, o as StackClientAppConstructor, r as HexclaveClientAppConstructorOptions, s as StackClientAppConstructorOptions, t as HexclaveClientApp, z as StackServerApp } from "../../../client-app-Cri37vaC.js";
|
|
2
2
|
export { HexclaveAdminApp, type HexclaveAdminAppConstructor, type HexclaveAdminAppConstructorOptions, HexclaveClientApp, type HexclaveClientAppConstructor, type HexclaveClientAppConstructorOptions, type HexclaveClientAppJson, HexclaveServerApp, type HexclaveServerAppConstructor, type HexclaveServerAppConstructorOptions, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { a as AdminWorkflowRunState, c as AdminWorkflowStepAttempt, d as AdminWorkflowUpgradeResult, f as AdminWorkflowVersion, i as AdminWorkflowRunDetails, l as AdminWorkflowSyncResult, n as AdminWorkflowDivergenceDiagnostic, o as AdminWorkflowRunsFilter, r as AdminWorkflowRun, s as AdminWorkflowStep, t as AdminWorkflow, u as AdminWorkflowTrigger } from "../../../../workflows-2-MBWbGl.js";
|
|
2
|
-
import { A as ManagedEmailProviderListItem, D as HexclaveAdminApp, E as EmailOutboxUpdateOptions, F as StackAdminAppConstructorOptions, M as ManagedEmailProviderStatus, N as StackAdminApp, O as HexclaveAdminAppConstructor, P as StackAdminAppConstructor, T as EmailOutboxListResult, j as ManagedEmailProviderSetupResult, k as HexclaveAdminAppConstructorOptions, w as EmailOutboxListOptions } from "../../../../client-app-
|
|
3
|
-
|
|
4
|
-
export { type AdminSessionReplay, type AdminSessionReplayChunk, type AdminWorkflow, type AdminWorkflowDivergenceDiagnostic, type AdminWorkflowRun, type AdminWorkflowRunDetails, type AdminWorkflowRunState, type AdminWorkflowRunsFilter, type AdminWorkflowStep, type AdminWorkflowStepAttempt, type AdminWorkflowSyncResult, type AdminWorkflowTrigger, type AdminWorkflowUpgradeResult, type AdminWorkflowVersion, EmailOutboxListOptions, EmailOutboxListResult, EmailOutboxUpdateOptions, HexclaveAdminApp, HexclaveAdminAppConstructor, HexclaveAdminAppConstructorOptions, type ListSessionReplayChunksOptions, type ListSessionReplayChunksResult, type ListSessionReplaysOptions, type ListSessionReplaysResult, ManagedEmailProviderListItem, ManagedEmailProviderSetupResult, ManagedEmailProviderStatus, type SessionReplayAllEventsResult, StackAdminApp, StackAdminAppConstructor, StackAdminAppConstructorOptions };
|
|
2
|
+
import { A as ManagedEmailProviderListItem, D as HexclaveAdminApp, E as EmailOutboxUpdateOptions, F as StackAdminAppConstructorOptions, M as ManagedEmailProviderStatus, N as StackAdminApp, O as HexclaveAdminAppConstructor, P as StackAdminAppConstructor, T as EmailOutboxListResult, j as ManagedEmailProviderSetupResult, k as HexclaveAdminAppConstructorOptions, w as EmailOutboxListOptions } from "../../../../client-app-Cri37vaC.js";
|
|
3
|
+
export { type AdminWorkflow, type AdminWorkflowDivergenceDiagnostic, type AdminWorkflowRun, type AdminWorkflowRunDetails, type AdminWorkflowRunState, type AdminWorkflowRunsFilter, type AdminWorkflowStep, type AdminWorkflowStepAttempt, type AdminWorkflowSyncResult, type AdminWorkflowTrigger, type AdminWorkflowUpgradeResult, type AdminWorkflowVersion, EmailOutboxListOptions, EmailOutboxListResult, EmailOutboxUpdateOptions, HexclaveAdminApp, HexclaveAdminAppConstructor, HexclaveAdminAppConstructorOptions, ManagedEmailProviderListItem, ManagedEmailProviderSetupResult, ManagedEmailProviderStatus, StackAdminApp, StackAdminAppConstructor, StackAdminAppConstructorOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-app.js","names":["_HexclaveAdminAppImpl"],"sources":["../../../../../src/lib/hexclave-app/apps/interfaces/admin-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\nimport type { AnalyticsClickmapOptions, AnalyticsClickmapResponse, AnalyticsClickmapTokenResponse } from \"@hexclave/shared/dist/interface/admin-metrics\";\nimport type { AdminGetSessionReplayChunkEventsResponse, AdminGetSessionReplayAllEventsResponse } from \"@hexclave/shared/dist/interface/crud/session-replays\";\nimport type { Transaction, TransactionType } from \"@hexclave/shared/dist/interface/crud/transactions\";\nimport { InternalSession } from \"@hexclave/shared/dist/sessions\";\nimport type { MoneyAmount } from \"@hexclave/shared/dist/utils/currency-constants\";\nimport { Result } from \"@hexclave/shared/dist/utils/results\";\nimport { AsyncStoreProperty, EmailConfig } from \"../../common\";\nimport { AdminEmailOutbox, AdminSentEmail } from \"../../email\";\nimport { InternalApiKey, InternalApiKeyCreateOptions, InternalApiKeyFirstView } from \"../../internal-api-keys\";\nimport { AdminProjectPermission, AdminProjectPermissionDefinition, AdminProjectPermissionDefinitionCreateOptions, AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions } from \"../../permissions\";\nimport type { PlanUsage } from \"../../plan-usage\";\nimport { AdminProject } from \"../../projects\";\nimport type { AdminWorkflow, AdminWorkflowRun, AdminWorkflowRunDetails, AdminWorkflowRunsFilter, AdminWorkflowSyncResult, AdminWorkflowUpgradeResult, AdminWorkflowVersion } from \"../../workflows\";\nimport { _HexclaveAdminAppImpl } from \"../implementations\";\nimport { StackServerApp, StackServerAppConstructorOptions } from \"./server-app\";\n\nexport type EmailOutboxListOptions = {\n status?: string,\n simpleStatus?: string,\n userId?: string,\n limit?: number,\n cursor?: string,\n};\n\nexport type EmailOutboxListResult = {\n items: AdminEmailOutbox[],\n nextCursor: string | null,\n};\n\nexport type EmailOutboxUpdateOptions = {\n isPaused?: boolean,\n scheduledAtMillis?: number,\n cancel?: boolean,\n tsxSource?: string,\n themeId?: string | null,\n};\n\nexport type ManagedEmailProviderSetupResult = {\n domainId: string,\n subdomain: string,\n senderLocalPart: string,\n nameServerRecords: string[],\n status: ManagedEmailProviderStatus[\"status\"],\n};\n\nexport type ManagedEmailProviderStatus = {\n status: \"pending_dns\" | \"pending_verification\" | \"verified\" | \"applied\" | \"failed\",\n};\n\nexport type ManagedEmailProviderListItem = {\n domainId: string,\n subdomain: string,\n senderLocalPart: string,\n status: ManagedEmailProviderStatus[\"status\"],\n nameServerRecords: string[],\n};\n\nimport type { AdminSessionReplay, ListSessionReplayChunksOptions, ListSessionReplayChunksResult, ListSessionReplaysOptions, ListSessionReplaysResult, SessionReplayAllEventsResult } from \"../../session-replays\";\nexport type { AdminSessionReplay, AdminSessionReplayChunk, ListSessionReplaysOptions, ListSessionReplaysResult, ListSessionReplayChunksOptions, ListSessionReplayChunksResult, SessionReplayAllEventsResult } from \"../../session-replays\";\nexport type { AdminWorkflow, AdminWorkflowDivergenceDiagnostic, AdminWorkflowRun, AdminWorkflowRunDetails, AdminWorkflowRunsFilter, AdminWorkflowRunState, AdminWorkflowStep, AdminWorkflowStepAttempt, AdminWorkflowSyncResult, AdminWorkflowTrigger, AdminWorkflowUpgradeResult, AdminWorkflowVersion } from \"../../workflows\";\n\n\n/** @deprecated Use `HexclaveAdminAppConstructorOptions` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */\nexport type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (\n & StackServerAppConstructorOptions<HasTokenStore, ProjectId>\n & {\n superSecretAdminKey?: string,\n projectOwnerSession?: InternalSession | (() => Promise<string | null>),\n }\n);\n\n\n/** @deprecated Use `HexclaveAdminApp` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */\nexport type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & AsyncStoreProperty<\"project\", [], AdminProject, false>\n & AsyncStoreProperty<\"planUsage\", [], PlanUsage, false>\n & AsyncStoreProperty<\"internalApiKeys\", [], InternalApiKey[], true>\n & AsyncStoreProperty<\"teamPermissionDefinitions\", [], AdminTeamPermissionDefinition[], true>\n & AsyncStoreProperty<\"projectPermissionDefinitions\", [], AdminProjectPermissionDefinition[], true>\n & AsyncStoreProperty<\"emailThemes\", [], { id: string, displayName: string }[], true>\n & AsyncStoreProperty<\"emailPreview\", [{ themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }], string, false>\n & AsyncStoreProperty<\"emailTemplates\", [], { id: string, displayName: string, themeId?: string, tsxSource: string }[], true>\n & AsyncStoreProperty<\"emailDrafts\", [], { id: string, displayName: string, themeId: string | undefined | false, tsxSource: string, sentAt: Date | null }[], true>\n & AsyncStoreProperty<\"workflows\", [], AdminWorkflow[], true>\n & AsyncStoreProperty<\"stripeAccountInfo\", [], { account_id: string, charges_enabled: boolean, details_submitted: boolean, payouts_enabled: boolean } | null, false>\n & AsyncStoreProperty<\n \"transactions\",\n [{\n cursor?: string,\n limit?: number,\n type?: TransactionType,\n customerType?: 'user' | 'team' | 'custom',\n customerId?: string,\n }],\n { transactions: Transaction[], nextCursor: string | null },\n true\n >\n & {\n createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>,\n\n createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>,\n updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>,\n deleteTeamPermissionDefinition(permissionId: string): Promise<void>,\n /**\n * @param options.query Free-text search; matches against permission ID and description.\n */\n listTeamPermissionDefinitionsPaginated(options: { limit: number, cursor?: string, query?: string }): Promise<{ items: AdminTeamPermissionDefinition[], nextCursor: string | null }>,\n\n createProjectPermissionDefinition(data: AdminProjectPermissionDefinitionCreateOptions): Promise<AdminProjectPermission>,\n updateProjectPermissionDefinition(permissionId: string, data: AdminProjectPermissionDefinitionUpdateOptions): Promise<void>,\n deleteProjectPermissionDefinition(permissionId: string): Promise<void>,\n\n\n sendTestEmail(options: {\n recipientEmail: string,\n emailConfig: EmailConfig,\n }): Promise<Result<undefined, { errorMessage: string }>>,\n\n sendTestWebhook(options: { endpointId: string }): Promise<Result<undefined, { errorMessage: string }>>,\n\n sendSignInInvitationEmail(email: string, callbackUrl: string): Promise<void>,\n\n listSentEmails(): Promise<AdminSentEmail[]>,\n setupManagedEmailProvider(options: { subdomain: string, senderLocalPart: string }): Promise<ManagedEmailProviderSetupResult>,\n checkManagedEmailStatus(options: { domainId: string, subdomain: string, senderLocalPart: string }): Promise<ManagedEmailProviderStatus>,\n listManagedEmailDomains(): Promise<ManagedEmailProviderListItem[]>,\n applyManagedEmailProvider(options: { domainId: string }): Promise<{ status: \"applied\" }>,\n deleteManagedEmailDomain(options: { resendDomainId: string }): Promise<{ status: \"deleted\" }>,\n\n createEmailTheme(displayName: string): Promise<{ id: string }>,\n updateEmailTheme(id: string, tsxSource: string): Promise<void>,\n deleteEmailTheme(id: string): Promise<void>,\n saveChatMessage(threadId: string, message: any): Promise<void>,\n listChatMessages(threadId: string): Promise<{ messages: Array<any> }>,\n rewriteTemplateSourceWithAI(templateTsxSource: string): Promise<{ tsxSource: string }>,\n updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ renderedHtml: string }>,\n createEmailTemplate(displayName: string): Promise<{ id: string }>,\n deleteEmailTemplate(id: string): Promise<void>,\n\n // Workflows (internal-project gated; see the Workflows v1 spec). The\n // management verbs live on the admin app only in v1.\n createWorkflow(options: { id: string, displayName?: string, source: string }): Promise<AdminWorkflowSyncResult>,\n updateWorkflowSource(workflowId: string, source: string): Promise<AdminWorkflowSyncResult>,\n deleteWorkflow(workflowId: string): Promise<void>,\n /** Pauses/resumes run creation. In-flight runs are unaffected. */\n setWorkflowPaused(workflowId: string, isPaused: boolean): Promise<void>,\n listWorkflowVersions(workflowId: string): Promise<AdminWorkflowVersion[]>,\n listWorkflowRuns: {\n (workflowId: string, filter: AdminWorkflowRunsFilter & { includeState: true }): Promise<{ runs: AdminWorkflowRunDetails[], nextCursor: string | null }>,\n (workflowId: string, filter?: AdminWorkflowRunsFilter): Promise<{ runs: AdminWorkflowRun[], nextCursor: string | null }>,\n },\n getWorkflowRun(runId: string): Promise<AdminWorkflowRunDetails>,\n cancelWorkflowRuns(workflowId: string, filter?: { runKey?: string, runId?: string, state?: \"queued\" | \"running\" | \"sleeping\", version?: number }): Promise<{ canceledCount: number }>,\n upgradeWorkflowRuns(workflowId: string, options: { toVersion: number, runKey?: string, fromVersion?: number }): Promise<AdminWorkflowUpgradeResult>,\n retryWorkflowRun(runId: string): Promise<void>,\n sendWorkflowEvent(name: string, data?: unknown): Promise<{ eventId: string }>,\n\n setupPayments(): Promise<{ url: string }>,\n createStripeWidgetAccountSession(): Promise<{ client_secret: string }>,\n getPaymentMethodConfigs(): Promise<{ configId: string, methods: Array<{ id: string, name: string, enabled: boolean, available: boolean, overridable: boolean }> } | null>,\n updatePaymentMethodConfigs(configId: string, updates: Record<string, 'on' | 'off'>): Promise<void>,\n createEmailDraft(options: { displayName: string, themeId?: string | undefined | false, tsxSource?: string }): Promise<{ id: string }>,\n updateEmailDraft(id: string, data: { displayName?: string, themeId?: string | undefined | false, tsxSource?: string }): Promise<void>,\n deleteEmailDraft(id: string): Promise<void>,\n refreshEmailDrafts(): Promise<void>,\n createItemQuantityChange(options: (\n { userId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { teamId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { customCustomerId: string, itemId: string, quantity: number, expiresAt?: string, description?: string }\n )): Promise<void>,\n refundTransaction(options: {\n type: \"subscription\" | \"one-time-purchase\",\n id: string,\n invoiceId?: string,\n amountUsd: MoneyAmount,\n endAction?: \"now\" | \"at-period-end\",\n }): Promise<{ refundTransactionId: string }>,\n getAnalyticsClickmap(options: AnalyticsClickmapOptions): Promise<AnalyticsClickmapResponse>,\n createAnalyticsClickmapToken(options: { origin: string }): Promise<AnalyticsClickmapTokenResponse>,\n\n listSessionReplays(options?: ListSessionReplaysOptions): Promise<ListSessionReplaysResult>,\n getSessionReplay(sessionReplayId: string): Promise<AdminSessionReplay>,\n listSessionReplayChunks(sessionReplayId: string, options?: ListSessionReplayChunksOptions): Promise<ListSessionReplayChunksResult>,\n getSessionReplayChunkEvents(sessionReplayId: string, chunkId: string): Promise<AdminGetSessionReplayChunkEventsResponse>,\n getSessionReplayEvents(sessionReplayId: string, options?: { offset?: number, limit?: number }): Promise<SessionReplayAllEventsResult>,\n\n // Email Outbox methods\n listOutboxEmails(options?: EmailOutboxListOptions): Promise<EmailOutboxListResult>,\n getOutboxEmail(id: string): Promise<AdminEmailOutbox>,\n updateOutboxEmail(id: string, options: EmailOutboxUpdateOptions): Promise<AdminEmailOutbox>,\n pauseOutboxEmail(id: string): Promise<AdminEmailOutbox>,\n unpauseOutboxEmail(id: string): Promise<AdminEmailOutbox>,\n cancelOutboxEmail(id: string): Promise<AdminEmailOutbox>,\n }\n & StackServerApp<HasTokenStore, ProjectId>\n);\n/** @deprecated Use `HexclaveAdminAppConstructor` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */\nexport type StackAdminAppConstructor = {\n new <\n HasTokenStore extends boolean,\n ProjectId extends string\n >(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>,\n new(options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>,\n};\nexport type HexclaveAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackAdminAppConstructorOptions<HasTokenStore, ProjectId>;\nexport type HexclaveAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = StackAdminApp<HasTokenStore, ProjectId>;\nexport type HexclaveAdminAppConstructor = StackAdminAppConstructor;\nexport const HexclaveAdminApp: HexclaveAdminAppConstructor = _HexclaveAdminAppImpl;\n/** @deprecated Use `HexclaveAdminApp` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */\nexport const StackAdminApp: StackAdminAppConstructor = HexclaveAdminApp;\n"],"mappings":";;AAmNA,MAAa,wDAAgDA,CAAAA,CAAAA;;AAE7D,MAAa,gBAA0C"}
|
|
1
|
+
{"version":3,"file":"admin-app.js","names":["_HexclaveAdminAppImpl"],"sources":["../../../../../src/lib/hexclave-app/apps/interfaces/admin-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\nimport type { AnalyticsClickmapOptions, AnalyticsClickmapResponse, AnalyticsClickmapTokenResponse } from \"@hexclave/shared/dist/interface/admin-metrics\";\nimport type { Transaction, TransactionType } from \"@hexclave/shared/dist/interface/crud/transactions\";\nimport { InternalSession } from \"@hexclave/shared/dist/sessions\";\nimport type { MoneyAmount } from \"@hexclave/shared/dist/utils/currency-constants\";\nimport { Result } from \"@hexclave/shared/dist/utils/results\";\nimport { AsyncStoreProperty, EmailConfig } from \"../../common\";\nimport { AdminEmailOutbox, AdminSentEmail } from \"../../email\";\nimport { InternalApiKey, InternalApiKeyCreateOptions, InternalApiKeyFirstView } from \"../../internal-api-keys\";\nimport { AdminProjectPermission, AdminProjectPermissionDefinition, AdminProjectPermissionDefinitionCreateOptions, AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions } from \"../../permissions\";\nimport type { PlanUsage } from \"../../plan-usage\";\nimport { AdminProject } from \"../../projects\";\nimport type { AdminWorkflow, AdminWorkflowRun, AdminWorkflowRunDetails, AdminWorkflowRunsFilter, AdminWorkflowSyncResult, AdminWorkflowUpgradeResult, AdminWorkflowVersion } from \"../../workflows\";\nimport { _HexclaveAdminAppImpl } from \"../implementations\";\nimport { StackServerApp, StackServerAppConstructorOptions } from \"./server-app\";\n\nexport type EmailOutboxListOptions = {\n status?: string,\n simpleStatus?: string,\n userId?: string,\n limit?: number,\n cursor?: string,\n};\n\nexport type EmailOutboxListResult = {\n items: AdminEmailOutbox[],\n nextCursor: string | null,\n};\n\nexport type EmailOutboxUpdateOptions = {\n isPaused?: boolean,\n scheduledAtMillis?: number,\n cancel?: boolean,\n tsxSource?: string,\n themeId?: string | null,\n};\n\nexport type ManagedEmailProviderSetupResult = {\n domainId: string,\n subdomain: string,\n senderLocalPart: string,\n nameServerRecords: string[],\n status: ManagedEmailProviderStatus[\"status\"],\n};\n\nexport type ManagedEmailProviderStatus = {\n status: \"pending_dns\" | \"pending_verification\" | \"verified\" | \"applied\" | \"failed\",\n};\n\nexport type ManagedEmailProviderListItem = {\n domainId: string,\n subdomain: string,\n senderLocalPart: string,\n status: ManagedEmailProviderStatus[\"status\"],\n nameServerRecords: string[],\n};\n\nexport type { AdminWorkflow, AdminWorkflowDivergenceDiagnostic, AdminWorkflowRun, AdminWorkflowRunDetails, AdminWorkflowRunsFilter, AdminWorkflowRunState, AdminWorkflowStep, AdminWorkflowStepAttempt, AdminWorkflowSyncResult, AdminWorkflowTrigger, AdminWorkflowUpgradeResult, AdminWorkflowVersion } from \"../../workflows\";\n\n\n/** @deprecated Use `HexclaveAdminAppConstructorOptions` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */\nexport type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (\n & StackServerAppConstructorOptions<HasTokenStore, ProjectId>\n & {\n superSecretAdminKey?: string,\n projectOwnerSession?: InternalSession | (() => Promise<string | null>),\n }\n);\n\n\n/** @deprecated Use `HexclaveAdminApp` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */\nexport type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & AsyncStoreProperty<\"project\", [], AdminProject, false>\n & AsyncStoreProperty<\"planUsage\", [], PlanUsage, false>\n & AsyncStoreProperty<\"internalApiKeys\", [], InternalApiKey[], true>\n & AsyncStoreProperty<\"teamPermissionDefinitions\", [], AdminTeamPermissionDefinition[], true>\n & AsyncStoreProperty<\"projectPermissionDefinitions\", [], AdminProjectPermissionDefinition[], true>\n & AsyncStoreProperty<\"emailThemes\", [], { id: string, displayName: string }[], true>\n & AsyncStoreProperty<\"emailPreview\", [{ themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }], string, false>\n & AsyncStoreProperty<\"emailTemplates\", [], { id: string, displayName: string, themeId?: string, tsxSource: string }[], true>\n & AsyncStoreProperty<\"emailDrafts\", [], { id: string, displayName: string, themeId: string | undefined | false, tsxSource: string, sentAt: Date | null }[], true>\n & AsyncStoreProperty<\"workflows\", [], AdminWorkflow[], true>\n & AsyncStoreProperty<\"stripeAccountInfo\", [], { account_id: string, charges_enabled: boolean, details_submitted: boolean, payouts_enabled: boolean } | null, false>\n & AsyncStoreProperty<\n \"transactions\",\n [{\n cursor?: string,\n limit?: number,\n type?: TransactionType,\n customerType?: 'user' | 'team' | 'custom',\n customerId?: string,\n }],\n { transactions: Transaction[], nextCursor: string | null },\n true\n >\n & {\n createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>,\n\n createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>,\n updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>,\n deleteTeamPermissionDefinition(permissionId: string): Promise<void>,\n /**\n * @param options.query Free-text search; matches against permission ID and description.\n */\n listTeamPermissionDefinitionsPaginated(options: { limit: number, cursor?: string, query?: string }): Promise<{ items: AdminTeamPermissionDefinition[], nextCursor: string | null }>,\n\n createProjectPermissionDefinition(data: AdminProjectPermissionDefinitionCreateOptions): Promise<AdminProjectPermission>,\n updateProjectPermissionDefinition(permissionId: string, data: AdminProjectPermissionDefinitionUpdateOptions): Promise<void>,\n deleteProjectPermissionDefinition(permissionId: string): Promise<void>,\n\n\n sendTestEmail(options: {\n recipientEmail: string,\n emailConfig: EmailConfig,\n }): Promise<Result<undefined, { errorMessage: string }>>,\n\n sendTestWebhook(options: { endpointId: string }): Promise<Result<undefined, { errorMessage: string }>>,\n\n sendSignInInvitationEmail(email: string, callbackUrl: string): Promise<void>,\n\n listSentEmails(): Promise<AdminSentEmail[]>,\n setupManagedEmailProvider(options: { subdomain: string, senderLocalPart: string }): Promise<ManagedEmailProviderSetupResult>,\n checkManagedEmailStatus(options: { domainId: string, subdomain: string, senderLocalPart: string }): Promise<ManagedEmailProviderStatus>,\n listManagedEmailDomains(): Promise<ManagedEmailProviderListItem[]>,\n applyManagedEmailProvider(options: { domainId: string }): Promise<{ status: \"applied\" }>,\n deleteManagedEmailDomain(options: { resendDomainId: string }): Promise<{ status: \"deleted\" }>,\n\n createEmailTheme(displayName: string): Promise<{ id: string }>,\n updateEmailTheme(id: string, tsxSource: string): Promise<void>,\n deleteEmailTheme(id: string): Promise<void>,\n saveChatMessage(threadId: string, message: any): Promise<void>,\n listChatMessages(threadId: string): Promise<{ messages: Array<any> }>,\n rewriteTemplateSourceWithAI(templateTsxSource: string): Promise<{ tsxSource: string }>,\n updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ renderedHtml: string }>,\n createEmailTemplate(displayName: string): Promise<{ id: string }>,\n deleteEmailTemplate(id: string): Promise<void>,\n\n // Workflows (internal-project gated; see the Workflows v1 spec). The\n // management verbs live on the admin app only in v1.\n createWorkflow(options: { id: string, displayName?: string, source: string }): Promise<AdminWorkflowSyncResult>,\n updateWorkflowSource(workflowId: string, source: string): Promise<AdminWorkflowSyncResult>,\n deleteWorkflow(workflowId: string): Promise<void>,\n /** Pauses/resumes run creation. In-flight runs are unaffected. */\n setWorkflowPaused(workflowId: string, isPaused: boolean): Promise<void>,\n listWorkflowVersions(workflowId: string): Promise<AdminWorkflowVersion[]>,\n listWorkflowRuns: {\n (workflowId: string, filter: AdminWorkflowRunsFilter & { includeState: true }): Promise<{ runs: AdminWorkflowRunDetails[], nextCursor: string | null }>,\n (workflowId: string, filter?: AdminWorkflowRunsFilter): Promise<{ runs: AdminWorkflowRun[], nextCursor: string | null }>,\n },\n getWorkflowRun(runId: string): Promise<AdminWorkflowRunDetails>,\n cancelWorkflowRuns(workflowId: string, filter?: { runKey?: string, runId?: string, state?: \"queued\" | \"running\" | \"sleeping\", version?: number }): Promise<{ canceledCount: number }>,\n upgradeWorkflowRuns(workflowId: string, options: { toVersion: number, runKey?: string, fromVersion?: number }): Promise<AdminWorkflowUpgradeResult>,\n retryWorkflowRun(runId: string): Promise<void>,\n sendWorkflowEvent(name: string, data?: unknown): Promise<{ eventId: string }>,\n\n setupPayments(): Promise<{ url: string }>,\n createStripeWidgetAccountSession(): Promise<{ client_secret: string }>,\n getPaymentMethodConfigs(): Promise<{ configId: string, methods: Array<{ id: string, name: string, enabled: boolean, available: boolean, overridable: boolean }> } | null>,\n updatePaymentMethodConfigs(configId: string, updates: Record<string, 'on' | 'off'>): Promise<void>,\n createEmailDraft(options: { displayName: string, themeId?: string | undefined | false, tsxSource?: string }): Promise<{ id: string }>,\n updateEmailDraft(id: string, data: { displayName?: string, themeId?: string | undefined | false, tsxSource?: string }): Promise<void>,\n deleteEmailDraft(id: string): Promise<void>,\n refreshEmailDrafts(): Promise<void>,\n createItemQuantityChange(options: (\n { userId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { teamId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { customCustomerId: string, itemId: string, quantity: number, expiresAt?: string, description?: string }\n )): Promise<void>,\n refundTransaction(options: {\n type: \"subscription\" | \"one-time-purchase\",\n id: string,\n invoiceId?: string,\n amountUsd: MoneyAmount,\n endAction?: \"now\" | \"at-period-end\",\n }): Promise<{ refundTransactionId: string }>,\n getAnalyticsClickmap(options: AnalyticsClickmapOptions): Promise<AnalyticsClickmapResponse>,\n createAnalyticsClickmapToken(options: { origin: string }): Promise<AnalyticsClickmapTokenResponse>,\n\n // Email Outbox methods\n listOutboxEmails(options?: EmailOutboxListOptions): Promise<EmailOutboxListResult>,\n getOutboxEmail(id: string): Promise<AdminEmailOutbox>,\n updateOutboxEmail(id: string, options: EmailOutboxUpdateOptions): Promise<AdminEmailOutbox>,\n pauseOutboxEmail(id: string): Promise<AdminEmailOutbox>,\n unpauseOutboxEmail(id: string): Promise<AdminEmailOutbox>,\n cancelOutboxEmail(id: string): Promise<AdminEmailOutbox>,\n }\n & StackServerApp<HasTokenStore, ProjectId>\n);\n/** @deprecated Use `HexclaveAdminAppConstructor` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */\nexport type StackAdminAppConstructor = {\n new <\n HasTokenStore extends boolean,\n ProjectId extends string\n >(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>,\n new(options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>,\n};\nexport type HexclaveAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackAdminAppConstructorOptions<HasTokenStore, ProjectId>;\nexport type HexclaveAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = StackAdminApp<HasTokenStore, ProjectId>;\nexport type HexclaveAdminAppConstructor = StackAdminAppConstructor;\nexport const HexclaveAdminApp: HexclaveAdminAppConstructor = _HexclaveAdminAppImpl;\n/** @deprecated Use `HexclaveAdminApp` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */\nexport const StackAdminApp: StackAdminAppConstructor = HexclaveAdminApp;\n"],"mappings":";;AA0MA,MAAa,wDAAgDA,CAAAA,CAAAA;;AAE7D,MAAa,gBAA0C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as StackClientApp, c as StackClientAppJson, i as HexclaveClientAppJson, n as HexclaveClientAppConstructor, o as StackClientAppConstructor, r as HexclaveClientAppConstructorOptions, s as StackClientAppConstructorOptions, t as HexclaveClientApp } from "../../../../client-app-
|
|
1
|
+
import { a as StackClientApp, c as StackClientAppJson, i as HexclaveClientAppJson, n as HexclaveClientAppConstructor, o as StackClientAppConstructor, r as HexclaveClientAppConstructorOptions, s as StackClientAppConstructorOptions, t as HexclaveClientApp } from "../../../../client-app-Cri37vaC.js";
|
|
2
2
|
export { HexclaveClientApp, HexclaveClientAppConstructor, HexclaveClientAppConstructorOptions, HexclaveClientAppJson, StackClientApp, StackClientAppConstructor, StackClientAppConstructorOptions, StackClientAppJson };
|