@stackframe/stack 2.8.34 → 2.8.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +21 -8
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +25 -2
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +65 -15
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/index.d.mts +89 -45
- package/dist/index.d.ts +89 -45
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +21 -8
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +25 -2
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +65 -15
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/stack-app/customers/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -7,7 +7,7 @@ import { suspendIfSsr } from "@stackframe/stack-shared/dist/utils/react";
|
|
|
7
7
|
import { Result } from "@stackframe/stack-shared/dist/utils/results";
|
|
8
8
|
import { Store } from "@stackframe/stack-shared/dist/utils/stores";
|
|
9
9
|
import React, { useCallback } from "react";
|
|
10
|
-
var clientVersion = "js @stackframe/stack@2.8.
|
|
10
|
+
var clientVersion = "js @stackframe/stack@2.8.35";
|
|
11
11
|
if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
|
|
12
12
|
throw new StackAssertionError("Client version was not replaced. Something went wrong during build!");
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/lib/stack-app/apps/implementations/common.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { AsyncCache } from \"@stackframe/stack-shared/dist/utils/caches\";\nimport { isBrowserLike } from \"@stackframe/stack-shared/dist/utils/env\";\nimport { StackAssertionError, concatStacktraces, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { filterUndefined } from \"@stackframe/stack-shared/dist/utils/objects\";\nimport { ReactPromise } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { suspendIfSsr } from \"@stackframe/stack-shared/dist/utils/react\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { Store } from \"@stackframe/stack-shared/dist/utils/stores\";\nimport React, { useCallback } from \"react\"; // THIS_LINE_PLATFORM react-like\nimport { HandlerUrls } from \"../../common\";\n\n// hack to make sure process is defined in non-node environments\n\nexport const clientVersion = \"js @stackframe/stack@2.8.34\";\nif (clientVersion.startsWith(\"STACK_COMPILE_TIME\")) {\n throw new StackAssertionError(\"Client version was not replaced. Something went wrong during build!\");\n}\n\n\nexport const createCache = <D extends any[], T>(fetcher: (dependencies: D) => Promise<T>) => {\n return new AsyncCache<D, Result<T>>(\n async (dependencies) => await Result.fromThrowingAsync(async () => await fetcher(dependencies)),\n {},\n );\n};\n\nexport const createCacheBySession = <D extends any[], T>(fetcher: (session: InternalSession, extraDependencies: D) => Promise<T> ) => {\n return new AsyncCache<[InternalSession, ...D], Result<T>>(\n async ([session, ...extraDependencies]) => await Result.fromThrowingAsync(async () => await fetcher(session, extraDependencies)),\n {\n onSubscribe: ([session], refresh) => {\n const handler = session.onInvalidate(() => refresh());\n return () => handler.unsubscribe();\n },\n },\n );\n};\n\nexport function getUrls(partial: Partial<HandlerUrls>): HandlerUrls {\n const handler = partial.handler ?? \"/handler\";\n const home = partial.home ?? \"/\";\n const afterSignIn = partial.afterSignIn ?? home;\n return {\n handler,\n signIn: `${handler}/sign-in`,\n afterSignIn: home,\n signUp: `${handler}/sign-up`,\n afterSignUp: afterSignIn,\n signOut: `${handler}/sign-out`,\n afterSignOut: home,\n emailVerification: `${handler}/email-verification`,\n passwordReset: `${handler}/password-reset`,\n forgotPassword: `${handler}/forgot-password`,\n oauthCallback: `${handler}/oauth-callback`,\n magicLinkCallback: `${handler}/magic-link-callback`,\n home: home,\n accountSettings: `${handler}/account-settings`,\n error: `${handler}/error`,\n teamInvitation: `${handler}/team-invitation`,\n mfa: `${handler}/mfa`,\n ...filterUndefined(partial),\n };\n}\n\nexport function getDefaultProjectId() {\n return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || throwErr(new Error(\"Welcome to Stack Auth! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable.\"));\n}\n\nexport function getDefaultPublishableClientKey() {\n return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || throwErr(new Error(\"Welcome to Stack Auth! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable.\"));\n}\n\nexport function getDefaultSecretServerKey() {\n return process.env.STACK_SECRET_SERVER_KEY || throwErr(new Error(\"No secret server key provided. Please copy your key from the Stack dashboard and put it in the STACK_SECRET_SERVER_KEY environment variable.\"));\n}\n\nexport function getDefaultSuperSecretAdminKey() {\n return process.env.STACK_SUPER_SECRET_ADMIN_KEY || throwErr(new Error(\"No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable.\"));\n}\n\nexport function getDefaultExtraRequestHeaders() {\n return JSON.parse(process.env.NEXT_PUBLIC_STACK_EXTRA_REQUEST_HEADERS || '{}');\n}\n\n/**\n * Returns the base URL for the Stack API.\n *\n * The URL can be specified in several ways, in order of precedence:\n * 1. Directly through userSpecifiedBaseUrl parameter as string or browser/server object\n * 2. Through environment variables:\n * - Browser: NEXT_PUBLIC_BROWSER_STACK_API_URL\n * - Server: NEXT_PUBLIC_SERVER_STACK_API_URL\n * - Fallback: NEXT_PUBLIC_STACK_API_URL or NEXT_PUBLIC_STACK_URL\n * 3. Default base URL if none of the above are specified\n *\n * The function also ensures the URL doesn't end with a trailing slash\n * by removing it if present.\n *\n * @param userSpecifiedBaseUrl - Optional URL override as string or {browser, server} object\n * @returns The configured base URL without trailing slash\n\n */\nexport function getBaseUrl(userSpecifiedBaseUrl: string | { browser: string, server: string } | undefined) {\n let url;\n if (userSpecifiedBaseUrl) {\n if (typeof userSpecifiedBaseUrl === \"string\") {\n url = userSpecifiedBaseUrl;\n } else {\n if (isBrowserLike()) {\n url = userSpecifiedBaseUrl.browser;\n } else {\n url = userSpecifiedBaseUrl.server;\n }\n }\n } else {\n if (isBrowserLike()) {\n url = process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL;\n } else {\n url = process.env.NEXT_PUBLIC_SERVER_STACK_API_URL;\n }\n url = url || process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;\n }\n\n return url.endsWith('/') ? url.slice(0, -1) : url;\n}\nconst defaultBaseUrl = \"https://api.stack-auth.com\";\n\nexport type TokenObject = {\n accessToken: string | null,\n refreshToken: string | null,\n};\n\nexport function createEmptyTokenStore() {\n return new Store<TokenObject>({\n refreshToken: null,\n accessToken: null,\n });\n}\n\n\nconst cachePromiseByHookId = new Map<string, ReactPromise<Result<unknown>>>();\nexport function useAsyncCache<D extends any[], T>(cache: AsyncCache<D, Result<T>>, dependencies: D, caller: string): T {\n // we explicitly don't want to run this hook in SSR\n suspendIfSsr(caller);\n\n const id = React.useId();\n\n // whenever the dependencies change, we need to refresh the promise cache\n React.useEffect(() => {\n cachePromiseByHookId.delete(id);\n }, [...dependencies, id]);\n\n const subscribe = useCallback((cb: () => void) => {\n const { unsubscribe } = cache.onStateChange(dependencies, () => {\n cachePromiseByHookId.delete(id);\n cb();\n });\n return unsubscribe;\n }, [cache, ...dependencies]);\n const getSnapshot = useCallback(() => {\n // React checks whether a promise passed to `use` is still the same as the previous one by comparing the reference.\n // If we didn't cache here, this wouldn't work because the promise would be recreated every time the value changes.\n if (!cachePromiseByHookId.has(id)) {\n cachePromiseByHookId.set(id, cache.getOrWait(dependencies, \"read-write\"));\n }\n return cachePromiseByHookId.get(id) as ReactPromise<Result<T>>;\n }, [cache, ...dependencies]);\n\n // note: we must use React.useSyncExternalStore instead of importing the function directly, as it will otherwise\n // throw an error on Next.js (\"can't import useSyncExternalStore from the server\")\n const promise = React.useSyncExternalStore(\n subscribe,\n getSnapshot,\n () => throwErr(new Error(\"getServerSnapshot should never be called in useAsyncCache because we restrict to CSR earlier\"))\n );\n\n const result = React.use(promise);\n if (result.status === \"error\") {\n const error = result.error;\n if (error instanceof Error && !(error as any).__stackHasConcatenatedStacktraces) {\n concatStacktraces(error, new Error());\n (error as any).__stackHasConcatenatedStacktraces = true;\n }\n throw error;\n }\n return result.data;\n}\n"],"mappings":";AAKA,SA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aAAa;AAAA,EACf,CAAC;AACH;AAGA,IAAM,uBAAuB,oBAAI,IAA2C;AACrE,SAAS,cAAkC,OAAiC,cAAiB,QAAmB;AAErH,eAAa,MAAM;AAEnB,QAAM,KAAK,MAAM,MAAM;AAGvB,QAAM,UAAU,MAAM;AACpB,yBAAqB,OAAO,EAAE;AAAA,EAChC,GAAG,CAAC,GAAG,cAAc,EAAE,CAAC;AAExB,QAAM,YAAY,YAAY,CAAC,OAAmB;AAChD,UAAM,EAAE,YAAY,IAAI,MAAM,cAAc,cAAc,MAAM;AAC9D,2BAAqB,OAAO,EAAE;AAC9B,SAAG;AAAA,IACL,CAAC;AACD,WAAO;AAAA,EACT,GAAG,CAAC,OAAO,GAAG,YAAY,CAAC;AAC3B,QAAM,cAAc,YAAY,MAAM;AAGpC,QAAI,CAAC,qBAAqB,IAAI,EAAE,GAAG;AACjC,2BAAqB,IAAI,IAAI,MAAM,UAAU,cAAc,YAAY,CAAC;AAAA,IAC1E;AACA,WAAO,qBAAqB,IAAI,EAAE;AAAA,EACpC,GAAG,CAAC,OAAO,GAAG,YAAY,CAAC;AAI3B,QAAM,UAAU,MAAM;AAAA,IACpB;AAAA,IACA;AAAA,IACA,MAAM,SAAS,IAAI,MAAM,8FAA8F,CAAC;AAAA,EAC1H;AAEA,QAAM,SAAS,MAAM,IAAI,OAAO;AAChC,MAAI,OAAO,WAAW,SAAS;AAC7B,UAAM,QAAQ,OAAO;AACrB,QAAI,iBAAiB,SAAS,CAAE,MAAc,mCAAmC;AAC/E,wBAAkB,OAAO,IAAI,MAAM,CAAC;AACpC,MAAC,MAAc,oCAAoC;AAAA,IACrD;AACA,UAAM;AAAA,EACR;AACA,SAAO,OAAO;AAChB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/lib/stack-app/apps/implementations/common.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { AsyncCache } from \"@stackframe/stack-shared/dist/utils/caches\";\nimport { isBrowserLike } from \"@stackframe/stack-shared/dist/utils/env\";\nimport { StackAssertionError, concatStacktraces, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { filterUndefined } from \"@stackframe/stack-shared/dist/utils/objects\";\nimport { ReactPromise } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { suspendIfSsr } from \"@stackframe/stack-shared/dist/utils/react\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { Store } from \"@stackframe/stack-shared/dist/utils/stores\";\nimport React, { useCallback } from \"react\"; // THIS_LINE_PLATFORM react-like\nimport { HandlerUrls } from \"../../common\";\n\n// hack to make sure process is defined in non-node environments\n\nexport const clientVersion = \"js @stackframe/stack@2.8.35\";\nif (clientVersion.startsWith(\"STACK_COMPILE_TIME\")) {\n throw new StackAssertionError(\"Client version was not replaced. Something went wrong during build!\");\n}\n\n\nexport const createCache = <D extends any[], T>(fetcher: (dependencies: D) => Promise<T>) => {\n return new AsyncCache<D, Result<T>>(\n async (dependencies) => await Result.fromThrowingAsync(async () => await fetcher(dependencies)),\n {},\n );\n};\n\nexport const createCacheBySession = <D extends any[], T>(fetcher: (session: InternalSession, extraDependencies: D) => Promise<T> ) => {\n return new AsyncCache<[InternalSession, ...D], Result<T>>(\n async ([session, ...extraDependencies]) => await Result.fromThrowingAsync(async () => await fetcher(session, extraDependencies)),\n {\n onSubscribe: ([session], refresh) => {\n const handler = session.onInvalidate(() => refresh());\n return () => handler.unsubscribe();\n },\n },\n );\n};\n\nexport function getUrls(partial: Partial<HandlerUrls>): HandlerUrls {\n const handler = partial.handler ?? \"/handler\";\n const home = partial.home ?? \"/\";\n const afterSignIn = partial.afterSignIn ?? home;\n return {\n handler,\n signIn: `${handler}/sign-in`,\n afterSignIn: home,\n signUp: `${handler}/sign-up`,\n afterSignUp: afterSignIn,\n signOut: `${handler}/sign-out`,\n afterSignOut: home,\n emailVerification: `${handler}/email-verification`,\n passwordReset: `${handler}/password-reset`,\n forgotPassword: `${handler}/forgot-password`,\n oauthCallback: `${handler}/oauth-callback`,\n magicLinkCallback: `${handler}/magic-link-callback`,\n home: home,\n accountSettings: `${handler}/account-settings`,\n error: `${handler}/error`,\n teamInvitation: `${handler}/team-invitation`,\n mfa: `${handler}/mfa`,\n ...filterUndefined(partial),\n };\n}\n\nexport function getDefaultProjectId() {\n return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || throwErr(new Error(\"Welcome to Stack Auth! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable.\"));\n}\n\nexport function getDefaultPublishableClientKey() {\n return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || throwErr(new Error(\"Welcome to Stack Auth! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable.\"));\n}\n\nexport function getDefaultSecretServerKey() {\n return process.env.STACK_SECRET_SERVER_KEY || throwErr(new Error(\"No secret server key provided. Please copy your key from the Stack dashboard and put it in the STACK_SECRET_SERVER_KEY environment variable.\"));\n}\n\nexport function getDefaultSuperSecretAdminKey() {\n return process.env.STACK_SUPER_SECRET_ADMIN_KEY || throwErr(new Error(\"No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable.\"));\n}\n\nexport function getDefaultExtraRequestHeaders() {\n return JSON.parse(process.env.NEXT_PUBLIC_STACK_EXTRA_REQUEST_HEADERS || '{}');\n}\n\n/**\n * Returns the base URL for the Stack API.\n *\n * The URL can be specified in several ways, in order of precedence:\n * 1. Directly through userSpecifiedBaseUrl parameter as string or browser/server object\n * 2. Through environment variables:\n * - Browser: NEXT_PUBLIC_BROWSER_STACK_API_URL\n * - Server: NEXT_PUBLIC_SERVER_STACK_API_URL\n * - Fallback: NEXT_PUBLIC_STACK_API_URL or NEXT_PUBLIC_STACK_URL\n * 3. Default base URL if none of the above are specified\n *\n * The function also ensures the URL doesn't end with a trailing slash\n * by removing it if present.\n *\n * @param userSpecifiedBaseUrl - Optional URL override as string or {browser, server} object\n * @returns The configured base URL without trailing slash\n\n */\nexport function getBaseUrl(userSpecifiedBaseUrl: string | { browser: string, server: string } | undefined) {\n let url;\n if (userSpecifiedBaseUrl) {\n if (typeof userSpecifiedBaseUrl === \"string\") {\n url = userSpecifiedBaseUrl;\n } else {\n if (isBrowserLike()) {\n url = userSpecifiedBaseUrl.browser;\n } else {\n url = userSpecifiedBaseUrl.server;\n }\n }\n } else {\n if (isBrowserLike()) {\n url = process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL;\n } else {\n url = process.env.NEXT_PUBLIC_SERVER_STACK_API_URL;\n }\n url = url || process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;\n }\n\n return url.endsWith('/') ? url.slice(0, -1) : url;\n}\nconst defaultBaseUrl = \"https://api.stack-auth.com\";\n\nexport type TokenObject = {\n accessToken: string | null,\n refreshToken: string | null,\n};\n\nexport function createEmptyTokenStore() {\n return new Store<TokenObject>({\n refreshToken: null,\n accessToken: null,\n });\n}\n\n\nconst cachePromiseByHookId = new Map<string, ReactPromise<Result<unknown>>>();\nexport function useAsyncCache<D extends any[], T>(cache: AsyncCache<D, Result<T>>, dependencies: D, caller: string): T {\n // we explicitly don't want to run this hook in SSR\n suspendIfSsr(caller);\n\n const id = React.useId();\n\n // whenever the dependencies change, we need to refresh the promise cache\n React.useEffect(() => {\n cachePromiseByHookId.delete(id);\n }, [...dependencies, id]);\n\n const subscribe = useCallback((cb: () => void) => {\n const { unsubscribe } = cache.onStateChange(dependencies, () => {\n cachePromiseByHookId.delete(id);\n cb();\n });\n return unsubscribe;\n }, [cache, ...dependencies]);\n const getSnapshot = useCallback(() => {\n // React checks whether a promise passed to `use` is still the same as the previous one by comparing the reference.\n // If we didn't cache here, this wouldn't work because the promise would be recreated every time the value changes.\n if (!cachePromiseByHookId.has(id)) {\n cachePromiseByHookId.set(id, cache.getOrWait(dependencies, \"read-write\"));\n }\n return cachePromiseByHookId.get(id) as ReactPromise<Result<T>>;\n }, [cache, ...dependencies]);\n\n // note: we must use React.useSyncExternalStore instead of importing the function directly, as it will otherwise\n // throw an error on Next.js (\"can't import useSyncExternalStore from the server\")\n const promise = React.useSyncExternalStore(\n subscribe,\n getSnapshot,\n () => throwErr(new Error(\"getServerSnapshot should never be called in useAsyncCache because we restrict to CSR earlier\"))\n );\n\n const result = React.use(promise);\n if (result.status === \"error\") {\n const error = result.error;\n if (error instanceof Error && !(error as any).__stackHasConcatenatedStacktraces) {\n concatStacktraces(error, new Error());\n (error as any).__stackHasConcatenatedStacktraces = true;\n }\n throw error;\n }\n return result.data;\n}\n"],"mappings":";AAKA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB,mBAAmB,gBAAgB;AACjE,SAAS,uBAAuB;AAEhC,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,OAAO,SAAS,mBAAmB;AAK5B,IAAM,gBAAgB;AAC7B,IAAI,cAAc,WAAW,oBAAoB,GAAG;AAClD,QAAM,IAAI,oBAAoB,qEAAqE;AACrG;AAGO,IAAM,cAAc,CAAqB,YAA6C;AAC3F,SAAO,IAAI;AAAA,IACT,OAAO,iBAAiB,MAAM,OAAO,kBAAkB,YAAY,MAAM,QAAQ,YAAY,CAAC;AAAA,IAC9F,CAAC;AAAA,EACH;AACF;AAEO,IAAM,uBAAuB,CAAqB,YAA6E;AACpI,SAAO,IAAI;AAAA,IACT,OAAO,CAAC,SAAY,oBAAiB,MAAM,MAAM,OAAO,kBAAkB,YAAY,MAAM,QAAQ,SAAS,iBAAiB,CAAC;AAAA,IAC/H;AAAA,MACE,aAAa,CAAC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E;AAAA,EACpC,GAAG,CAAC,OAAO,GAAG,YAAY,CAAC;AAI3B,QAAM,UAAU,MAAM;AAAA,IACpB;AAAA,IACA;AAAA,IACA,MAAM,SAAS,IAAI,MAAM,8FAA8F,CAAC;AAAA,EAC1H;AAEA,QAAM,SAAS,MAAM,IAAI,OAAO;AAChC,MAAI,OAAO,WAAW,SAAS;AAC7B,UAAM,QAAQ,OAAO;AACrB,QAAI,iBAAiB,SAAS,CAAE,MAAc,mCAAmC;AAC/E,wBAAkB,OAAO,IAAI,MAAM,CAAC;AACpC,MAAC,MAAc,oCAAoC;AAAA,IACrD;AACA,UAAM;AAAA,EACR;AACA,SAAO,OAAO;AAChB;","names":[]}
|
|
@@ -147,6 +147,11 @@ var _StackServerAppImplIncomplete = class extends _StackClientAppImplIncomplete
|
|
|
147
147
|
return await this._interface.getItem({ userId, itemId }, null);
|
|
148
148
|
}
|
|
149
149
|
);
|
|
150
|
+
this._serverCustomItemsCache = createCache(
|
|
151
|
+
async ([customCustomerId, itemId]) => {
|
|
152
|
+
return await this._interface.getItem({ customCustomerId, itemId }, null);
|
|
153
|
+
}
|
|
154
|
+
);
|
|
150
155
|
}
|
|
151
156
|
async _updateServerUser(userId, update) {
|
|
152
157
|
const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));
|
|
@@ -472,16 +477,17 @@ var _StackServerAppImplIncomplete = class extends _StackClientAppImplIncomplete
|
|
|
472
477
|
await app._serverUserApiKeysCache.refresh([crud.id]);
|
|
473
478
|
return app._serverApiKeyFromCrud(result);
|
|
474
479
|
},
|
|
475
|
-
async createCheckoutUrl(
|
|
476
|
-
|
|
480
|
+
async createCheckoutUrl(options) {
|
|
481
|
+
const offerIdOrInline = "offerId" in options ? options.offerId : options.offer;
|
|
482
|
+
return await app._interface.createCheckoutUrl("user", crud.id, offerIdOrInline, null);
|
|
477
483
|
},
|
|
478
484
|
async getItem(itemId) {
|
|
479
485
|
const result = Result.orThrow(await app._serverUserItemsCache.getOrWait([crud.id, itemId], "write-only"));
|
|
480
|
-
return app._serverItemFromCrud(crud.id, result);
|
|
486
|
+
return app._serverItemFromCrud({ type: "user", id: crud.id }, result);
|
|
481
487
|
},
|
|
482
488
|
useItem(itemId) {
|
|
483
489
|
const result = useAsyncCache(app._serverUserItemsCache, [crud.id, itemId], "user.useItem()");
|
|
484
|
-
return useMemo(() => app._serverItemFromCrud(crud.id, result), [result]);
|
|
490
|
+
return useMemo(() => app._serverItemFromCrud({ type: "user", id: crud.id }, result), [result]);
|
|
485
491
|
}
|
|
486
492
|
};
|
|
487
493
|
}
|
|
@@ -589,35 +595,45 @@ var _StackServerAppImplIncomplete = class extends _StackClientAppImplIncomplete
|
|
|
589
595
|
},
|
|
590
596
|
async getItem(itemId) {
|
|
591
597
|
const result = Result.orThrow(await app._serverTeamItemsCache.getOrWait([crud.id, itemId], "write-only"));
|
|
592
|
-
return app._serverItemFromCrud(crud.id, result);
|
|
598
|
+
return app._serverItemFromCrud({ type: "team", id: crud.id }, result);
|
|
593
599
|
},
|
|
594
600
|
useItem(itemId) {
|
|
595
601
|
const result = useAsyncCache(app._serverTeamItemsCache, [crud.id, itemId], "team.useItem()");
|
|
596
|
-
return useMemo(() => app._serverItemFromCrud(crud.id, result), [result]);
|
|
602
|
+
return useMemo(() => app._serverItemFromCrud({ type: "team", id: crud.id }, result), [result]);
|
|
597
603
|
},
|
|
598
|
-
async createCheckoutUrl(
|
|
599
|
-
|
|
604
|
+
async createCheckoutUrl(options) {
|
|
605
|
+
const offerIdOrInline = "offerId" in options ? options.offerId : options.offer;
|
|
606
|
+
return await app._interface.createCheckoutUrl("team", crud.id, offerIdOrInline, null);
|
|
600
607
|
}
|
|
601
608
|
};
|
|
602
609
|
}
|
|
603
|
-
_serverItemFromCrud(
|
|
610
|
+
_serverItemFromCrud(customer, crud) {
|
|
604
611
|
const app = this;
|
|
605
612
|
return {
|
|
606
613
|
displayName: crud.display_name,
|
|
607
614
|
quantity: crud.quantity,
|
|
608
615
|
nonNegativeQuantity: Math.max(0, crud.quantity),
|
|
609
616
|
increaseQuantity: async (delta) => {
|
|
610
|
-
|
|
611
|
-
await app.
|
|
617
|
+
const updateOptions = customer.type === "user" ? { itemId: crud.id, userId: customer.id } : customer.type === "team" ? { itemId: crud.id, teamId: customer.id } : { itemId: crud.id, customCustomerId: customer.id };
|
|
618
|
+
await app._interface.updateItemQuantity(updateOptions, { delta });
|
|
619
|
+
if (customer.type === "user") await app._serverUserItemsCache.refresh([customer.id, crud.id]);
|
|
620
|
+
else if (customer.type === "team") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);
|
|
621
|
+
else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);
|
|
612
622
|
},
|
|
613
623
|
decreaseQuantity: async (delta) => {
|
|
614
|
-
|
|
615
|
-
await app.
|
|
624
|
+
const updateOptions = customer.type === "user" ? { itemId: crud.id, userId: customer.id } : customer.type === "team" ? { itemId: crud.id, teamId: customer.id } : { itemId: crud.id, customCustomerId: customer.id };
|
|
625
|
+
await app._interface.updateItemQuantity(updateOptions, { delta: -delta, allow_negative: true });
|
|
626
|
+
if (customer.type === "user") await app._serverUserItemsCache.refresh([customer.id, crud.id]);
|
|
627
|
+
else if (customer.type === "team") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);
|
|
628
|
+
else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);
|
|
616
629
|
},
|
|
617
630
|
tryDecreaseQuantity: async (delta) => {
|
|
618
631
|
try {
|
|
619
|
-
|
|
620
|
-
await app.
|
|
632
|
+
const updateOptions = customer.type === "user" ? { itemId: crud.id, userId: customer.id } : customer.type === "team" ? { itemId: crud.id, teamId: customer.id } : { itemId: crud.id, customCustomerId: customer.id };
|
|
633
|
+
await app._interface.updateItemQuantity(updateOptions, { delta: -delta });
|
|
634
|
+
if (customer.type === "user") await app._serverUserItemsCache.refresh([customer.id, crud.id]);
|
|
635
|
+
else if (customer.type === "team") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);
|
|
636
|
+
else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);
|
|
621
637
|
return true;
|
|
622
638
|
} catch (error) {
|
|
623
639
|
if (error instanceof KnownErrors.ItemQuantityInsufficientAmount) {
|
|
@@ -804,6 +820,40 @@ var _StackServerAppImplIncomplete = class extends _StackClientAppImplIncomplete
|
|
|
804
820
|
const teams = Result.orThrow(await this._serverTeamsCache.getOrWait([void 0], "write-only"));
|
|
805
821
|
return teams.map((t) => this._serverTeamFromCrud(t));
|
|
806
822
|
}
|
|
823
|
+
async getItem(options) {
|
|
824
|
+
if ("userId" in options) {
|
|
825
|
+
const result = Result.orThrow(await this._serverUserItemsCache.getOrWait([options.userId, options.itemId], "write-only"));
|
|
826
|
+
return this._serverItemFromCrud({ type: "user", id: options.userId }, result);
|
|
827
|
+
} else if ("teamId" in options) {
|
|
828
|
+
const result = Result.orThrow(await this._serverTeamItemsCache.getOrWait([options.teamId, options.itemId], "write-only"));
|
|
829
|
+
return this._serverItemFromCrud({ type: "team", id: options.teamId }, result);
|
|
830
|
+
} else {
|
|
831
|
+
const result = Result.orThrow(await this._serverCustomItemsCache.getOrWait([options.customCustomerId, options.itemId], "write-only"));
|
|
832
|
+
return this._serverItemFromCrud({ type: "custom", id: options.customCustomerId }, result);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
useItem(options) {
|
|
836
|
+
let type;
|
|
837
|
+
let id;
|
|
838
|
+
let cache;
|
|
839
|
+
if ("userId" in options) {
|
|
840
|
+
type = "user";
|
|
841
|
+
id = options.userId;
|
|
842
|
+
cache = this._serverUserItemsCache;
|
|
843
|
+
} else if ("teamId" in options) {
|
|
844
|
+
type = "team";
|
|
845
|
+
id = options.teamId;
|
|
846
|
+
cache = this._serverTeamItemsCache;
|
|
847
|
+
} else {
|
|
848
|
+
type = "custom";
|
|
849
|
+
id = options.customCustomerId;
|
|
850
|
+
cache = this._serverCustomItemsCache;
|
|
851
|
+
}
|
|
852
|
+
const cacheKey = [id, options.itemId];
|
|
853
|
+
const debugLabel = `app.useItem(${type})`;
|
|
854
|
+
const result = useAsyncCache(cache, cacheKey, debugLabel);
|
|
855
|
+
return useMemo(() => this._serverItemFromCrud({ type, id }, result), [result]);
|
|
856
|
+
}
|
|
807
857
|
async createTeam(data) {
|
|
808
858
|
const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));
|
|
809
859
|
await this._serverTeamsCache.refresh([void 0]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/lib/stack-app/apps/implementations/server-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors, StackServerInterface } from \"@stackframe/stack-shared\";\nimport { ContactChannelsCrud } from \"@stackframe/stack-shared/dist/interface/crud/contact-channels\";\nimport { ItemCrud } from \"@stackframe/stack-shared/dist/interface/crud/items\";\nimport { NotificationPreferenceCrud } from \"@stackframe/stack-shared/dist/interface/crud/notification-preferences\";\nimport { TeamApiKeysCrud, UserApiKeysCrud, teamApiKeysCreateOutputSchema, userApiKeysCreateOutputSchema } from \"@stackframe/stack-shared/dist/interface/crud/project-api-keys\";\nimport { ProjectPermissionDefinitionsCrud, ProjectPermissionsCrud } from \"@stackframe/stack-shared/dist/interface/crud/project-permissions\";\nimport { TeamInvitationCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-invitation\";\nimport { TeamMemberProfilesCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-member-profiles\";\nimport { TeamPermissionDefinitionsCrud, TeamPermissionsCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-permissions\";\nimport { TeamsCrud } from \"@stackframe/stack-shared/dist/interface/crud/teams\";\nimport { UsersCrud } from \"@stackframe/stack-shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { suspend } from \"@stackframe/stack-shared/dist/utils/react\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { useMemo } from \"react\"; // THIS_LINE_PLATFORM react-like\nimport * as yup from \"yup\";\nimport { constructRedirectUrl } from \"../../../../utils/url\";\nimport { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud, apiKeyUpdateOptionsToCrud } from \"../../api-keys\";\nimport { GetUserOptions, HandlerUrls, OAuthScopesOnSignIn, TokenStoreInit } from \"../../common\";\nimport { OAuthConnection } from \"../../connected-accounts\";\nimport { ServerContactChannel, ServerContactChannelCreateOptions, ServerContactChannelUpdateOptions, serverContactChannelCreateOptionsToCrud, serverContactChannelUpdateOptionsToCrud } from \"../../contact-channels\";\nimport { InlineOffer, ServerItem } from \"../../customers\";\nimport { SendEmailOptions } from \"../../email\";\nimport { NotificationCategory } from \"../../notification-categories\";\nimport { AdminProjectPermissionDefinition, AdminTeamPermission, AdminTeamPermissionDefinition } from \"../../permissions\";\nimport { EditableTeamMemberProfile, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamUpdateOptions, ServerTeamUser, Team, TeamInvitation, serverTeamCreateOptionsToCrud, serverTeamUpdateOptionsToCrud } from \"../../teams\";\nimport { ProjectCurrentServerUser, ServerUser, ServerUserCreateOptions, ServerUserUpdateOptions, serverUserCreateOptionsToCrud, serverUserUpdateOptionsToCrud } from \"../../users\";\nimport { StackServerAppConstructorOptions } from \"../interfaces/server-app\";\nimport { _StackClientAppImplIncomplete } from \"./client-app-impl\";\nimport { clientVersion, createCache, createCacheBySession, getBaseUrl, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey } from \"./common\";\n\nimport { useAsyncCache } from \"./common\";\n\nexport class _StackServerAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackClientAppImplIncomplete<HasTokenStore, ProjectId> {\n declare protected _interface: StackServerInterface;\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',\n desc?: boolean,\n query?: string,\n includeAnonymous?: boolean,\n ], UsersCrud['Server']['List']>(async ([cursor, limit, orderBy, desc, query, includeAnonymous]) => {\n return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query, includeAnonymous });\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<[string | undefined], TeamsCrud['Server']['Read'][]>(async ([userId]) => {\n return await this._interface.listServerTeams({ 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 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 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.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) {\n throw err;\n }\n }\n return null;\n }\n );\n private readonly _serverUserOAuthConnectionCache = createCache<[string, ProviderType, string, boolean], OAuthConnection | 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 useOAuthToken: () => useAsyncCache(this._serverUserOAuthConnectionAccessTokensCache, [userId, providerId, scope || \"\"] as const, \"user.useConnectedAccount()\"),\n providerId,\n scope,\n redirect,\n session: null,\n });\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\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 _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 _serverTeamItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([teamId, itemId]) => {\n return await this._interface.getItem({ teamId, itemId }, null);\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);\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.urls.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 constructor(options:\n | StackServerAppConstructorOptions<HasTokenStore, ProjectId>\n | {\n interface: StackServerInterface,\n tokenStore: TokenStoreInit<HasTokenStore>,\n urls: Partial<HandlerUrls> | undefined,\n oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn> | undefined,\n }\n ) {\n super(\"interface\" in options ? {\n interface: options.interface,\n tokenStore: options.tokenStore,\n urls: options.urls,\n oauthScopesOnSignIn: options.oauthScopesOnSignIn,\n } : {\n interface: new StackServerInterface({\n getBaseUrl: () => getBaseUrl(options.baseUrl),\n projectId: options.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: options.extraRequestHeaders ?? {},\n clientVersion,\n publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),\n secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey(),\n }),\n baseUrl: options.baseUrl,\n extraRequestHeaders: options.extraRequestHeaders,\n projectId: options.projectId,\n publishableClientKey: options.publishableClientKey,\n tokenStore: options.tokenStore,\n urls: options.urls,\n oauthScopesOnSignIn: options.oauthScopesOnSignIn,\n redirectMethod: options.redirectMethod,\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 _serverUserFromCrud(crud: UsersCrud['Server']['Read']): ServerUser {\n const app = this;\n\n async function getConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): Promise<OAuthConnection | null>;\n async function getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>;\n async function getConnectedAccount(id: ProviderType, options?: { or?: 'redirect', scopes?: string[] }): Promise<OAuthConnection | null> {\n const scopeString = options?.scopes?.join(\" \");\n return Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, id, scopeString || \"\", options?.or === 'redirect'], \"write-only\"));\n }\n\n function useConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): OAuthConnection | null;\n function useConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): OAuthConnection;\n function useConnectedAccount(id: ProviderType, options?: { or?: 'redirect', scopes?: string[] }): OAuthConnection | null {\n const scopeString = options?.scopes?.join(\" \");\n return useAsyncCache(app._serverUserOAuthConnectionCache, [crud.id, id, scopeString || \"\", options?.or === 'redirect'] as const, \"user.useConnectedAccount()\");\n }\n\n return {\n ...super._createBaseUser(crud),\n lastActiveAt: new Date(crud.last_active_at_millis),\n serverMetadata: crud.server_metadata,\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 }\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 }\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.map((session) => app._clientSessionFromCrud(session));\n },\n\n async revokeSession(sessionId: string) {\n await app._interface.deleteServerSession(sessionId);\n },\n async setDisplayName(displayName: string) {\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 | null) {\n return await this.update({ selectedTeamId: team?.id ?? null });\n },\n getConnectedAccount,\n useConnectedAccount, // THIS_LINE_PLATFORM react-like\n selectedTeam: crud.selected_team ? app._serverTeamFromCrud(crud.selected_team) : null,\n async getTeam(teamId: string) {\n const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n },\n useTeam(teamId: string) {\n const teams = this.useTeams();\n return useMemo(() => {\n return teams.find((t) => t.id === teamId) ?? null;\n }, [teams, teamId]);\n },\n async listTeams() {\n const teams = Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id], \"write-only\"));\n return teams.map((t) => app._serverTeamFromCrud(t));\n },\n useTeams() {\n const teams = useAsyncCache(app._serverTeamsCache, [crud.id], \"user.useTeams()\");\n return useMemo(() => teams.map((t) => app._serverTeamFromCrud(t)), [teams]);\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.refresh([undefined]);\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 // TODO: refresh cache\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 usePermissions(scopeOrOptions?: Team | { recursive?: boolean }, options?: { recursive?: boolean }): AdminTeamPermission[] {\n if (scopeOrOptions && 'id' in scopeOrOptions) {\n const scope = scopeOrOptions;\n const recursive = options?.recursive ?? true;\n const permissions = useAsyncCache(app._serverTeamUserPermissionsCache, [scope.id, crud.id, recursive] as const, \"user.usePermissions()\");\n return useMemo(() => permissions.map((crud) => app._serverPermissionFromCrud(crud)), [permissions]);\n } else {\n const opts = scopeOrOptions;\n const recursive = opts?.recursive ?? true;\n const permissions = useAsyncCache(app._serverUserProjectPermissionsCache, [crud.id, recursive] as const, \"user.usePermissions()\");\n return useMemo(() => permissions.map((crud) => app._serverPermissionFromCrud(crud)), [permissions]);\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 usePermission(scopeOrPermissionId: Team | string, permissionId?: string): AdminTeamPermission | null {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n const permissions = this.usePermissions(scope);\n return useMemo(() => permissions.find((p) => p.id === permissionId) ?? null, [permissions, permissionId]);\n } else {\n const pid = scopeOrPermissionId;\n const permissions = this.usePermissions();\n return useMemo(() => permissions.find((p) => p.id === pid) ?? null, [permissions, pid]);\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 useTeamProfile(team: Team) {\n const result = useAsyncCache(app._serverUserTeamProfileCache, [team.id, crud.id] as const, \"user.useTeamProfile()\");\n return useMemo(() => app._serverEditableTeamProfileFromCrud(result), [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 useContactChannels() {\n const result = useAsyncCache(app._serverContactChannelsCache, [crud.id] as const, \"user.useContactChannels()\");\n return useMemo(() => result.map((data) => app._serverContactChannelFromCrud(crud.id, data)), [result]);\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 useNotificationCategories() {\n const results = useAsyncCache(app._serverNotificationCategoriesCache, [crud.id] as const, \"user.useNotificationCategories()\");\n return results.map((category) => app._serverNotificationCategoryFromCrud(crud.id, category));\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 useApiKeys() {\n const result = useAsyncCache(app._serverUserApiKeysCache, [crud.id] as const, \"user.useApiKeys()\");\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\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 async createCheckoutUrl(offerIdOrInline: string | InlineOffer) {\n return await app._interface.createCheckoutUrl(crud.id, offerIdOrInline, null);\n },\n async getItem(itemId: string) {\n const result = Result.orThrow(await app._serverUserItemsCache.getOrWait([crud.id, itemId], \"write-only\"));\n return app._serverItemFromCrud(crud.id, result);\n },\n useItem(itemId: string) {\n const result = useAsyncCache(app._serverUserItemsCache, [crud.id, itemId] as const, \"user.useItem()\");\n return useMemo(() => app._serverItemFromCrud(crud.id, result), [result]);\n },\n };\n }\n\n protected _serverTeamUserFromCrud(crud: TeamMemberProfilesCrud[\"Server\"][\"Read\"]): ServerTeamUser {\n return {\n ...this._serverUserFromCrud(crud.user),\n teamProfile: {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n },\n };\n }\n\n protected _serverTeamInvitationFromCrud(crud: TeamInvitationCrud['Server']['Read']): TeamInvitation {\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 },\n };\n }\n\n protected override _currentUserFromCrud(crud: UsersCrud['Server']['Read'], session: InternalSession): ProjectCurrentServerUser<ProjectId> {\n const app = this;\n const currentUser = {\n ...this._serverUserFromCrud(crud),\n ...this._createAuth(session),\n ...this._isInternalProject() ? this._createInternalUserExtra(session) : {},\n } satisfies ServerUser;\n\n Object.freeze(currentUser);\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 app._serverTeamsCache.refresh([undefined]);\n },\n async delete() {\n await app._interface.deleteServerTeam(crud.id);\n await app._serverTeamsCache.refresh([undefined]);\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 useUsers() {\n const result = useAsyncCache(app._serverTeamMemberProfilesCache, [crud.id] as const, \"team.useUsers()\");\n return useMemo(() => result.map(u => app._serverTeamUserFromCrud(u)), [result]);\n },\n async addUser(userId) {\n await app._interface.addServerUserToTeam({\n teamId: crud.id,\n userId,\n });\n await app._serverTeamMemberProfilesCache.refresh([crud.id]);\n },\n async removeUser(userId) {\n await app._interface.removeServerUserFromTeam({\n teamId: crud.id,\n userId,\n });\n await app._serverTeamMemberProfilesCache.refresh([crud.id]);\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.urls.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._serverTeamInvitationFromCrud(crud));\n },\n useInvitations() {\n const result = useAsyncCache(app._serverTeamInvitationsCache, [crud.id] as const, \"team.useInvitations()\");\n return useMemo(() => result.map((crud) => app._serverTeamInvitationFromCrud(crud)), [result]);\n },\n useApiKeys() {\n const result = useAsyncCache(app._serverTeamApiKeysCache, [crud.id] as const, \"team.useApiKeys()\");\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\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 async getItem(itemId: string) {\n const result = Result.orThrow(await app._serverTeamItemsCache.getOrWait([crud.id, itemId], \"write-only\"));\n return app._serverItemFromCrud(crud.id, result);\n },\n useItem(itemId: string) {\n const result = useAsyncCache(app._serverTeamItemsCache, [crud.id, itemId] as const, \"team.useItem()\");\n return useMemo(() => app._serverItemFromCrud(crud.id, result), [result]);\n },\n async createCheckoutUrl(offerIdOrInline: string | InlineOffer) {\n return await app._interface.createCheckoutUrl(crud.id, offerIdOrInline, null);\n },\n };\n }\n\n protected _serverItemFromCrud(customerId: 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 await app._interface.updateItemQuantity(customerId, crud.id, { delta });\n await app._serverUserItemsCache.refresh([customerId, crud.id]);\n },\n decreaseQuantity: async (delta: number) => {\n await app._interface.updateItemQuantity(customerId, crud.id, { delta: -delta, allow_negative: true });\n await app._serverUserItemsCache.refresh([customerId, crud.id]);\n },\n tryDecreaseQuantity: async (delta: number) => {\n try {\n await app._interface.updateItemQuantity(customerId, crud.id, { delta: -delta });\n await app._serverUserItemsCache.refresh([customerId, 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 _useUserApiKey(options: { apiKey: string }): ApiKey<\"user\"> | null {\n const crud = useAsyncCache(this._serverCheckApiKeyCache, [\"user\", options.apiKey] as const, \"useUserApiKey()\") as UserApiKeysCrud['Server']['Read'] | null;\n return useMemo(() => crud ? this._serverApiKeyFromCrud(crud) : null, [crud]);\n }\n protected _useTeamApiKey(options: { apiKey: string }): ApiKey<\"team\"> | null {\n const crud = useAsyncCache(this._serverCheckApiKeyCache, [\"team\", options.apiKey] as const, \"useTeamApiKey()\") as TeamApiKeysCrud['Server']['Read'] | null;\n return useMemo(() => crud ? this._serverApiKeyFromCrud(crud) : null, [crud]);\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 protected _useUserByApiKey(apiKey: string): ServerUser | null {\n const apiKeyObject = this._useUserApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return this.useUserById(apiKeyObject.userId);\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 protected _useTeamByApiKey(apiKey: string): ServerTeam | null {\n const apiKeyObject = this._useTeamApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return this.useTeam(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: GetUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options?: GetUserOptions<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?: string | GetUserOptions<HasTokenStore> | { apiKey: string }): 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 {\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 if (crud?.is_anonymous && options?.or !== \"anonymous\" && options?.or !== \"anonymous-if-exists[deprecated]\") {\n crud = null;\n }\n\n if (crud === null) {\n switch (options?.or) {\n case 'redirect': {\n await this.redirectToSignIn({ replace: true });\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]\" }) ?? 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(\"stackServerApp.getServerUser is deprecated; use stackServerApp.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 useUser(options: GetUserOptions<HasTokenStore> & { or: 'redirect' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options: GetUserOptions<HasTokenStore> & { or: 'throw' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options: GetUserOptions<HasTokenStore> & { or: 'anonymous' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options?: GetUserOptions<HasTokenStore>): ProjectCurrentServerUser<ProjectId> | null;\n useUser(id: string): ServerUser | null;\n useUser(options: { apiKey: string }): ServerUser | null;\n useUser(options?: GetUserOptions<HasTokenStore> | string | { apiKey: string }): ProjectCurrentServerUser<ProjectId> | ServerUser | null {\n if (typeof options === \"string\") {\n return this.useUserById(options);\n } else if (typeof options === \"object\" && \"apiKey\" in options) {\n return this._useUserByApiKey(options.apiKey);\n } else {\n // TODO this code is duplicated from the client app; fix that\n this._ensurePersistentTokenStore(options?.tokenStore);\n\n const session = this._useSession(options?.tokenStore);\n let crud = useAsyncCache(this._currentServerUserCache, [session] as const, \"useUser()\");\n if (crud?.is_anonymous && options?.or !== \"anonymous\" && options?.or !== \"anonymous-if-exists[deprecated]\") {\n crud = null;\n }\n\n if (crud === null) {\n switch (options?.or) {\n case 'redirect': {\n runAsynchronously(this.redirectToSignIn({ replace: true }));\n suspend();\n throw new StackAssertionError(\"suspend should never return\");\n }\n case 'throw': {\n throw new Error(\"User is not signed in but useUser was called with { or: 'throw' }\");\n }\n case 'anonymous': {\n // TODO we should think about the behavior when calling useUser (or getUser) in anonymous with a custom token store. signUpAnonymously always sets the current token store on app level, instead of the one passed to this function\n // TODO we shouldn't reload & suspend here, instead we should use a promise that resolves to the new anonymous user\n runAsynchronously(async () => {\n await this._signUpAnonymously();\n if (typeof window !== \"undefined\") {\n window.location.reload();\n }\n });\n suspend();\n throw new StackAssertionError(\"suspend should never return\");\n }\n case undefined:\n case \"anonymous-if-exists[deprecated]\":\n case \"return-null\": {\n // do nothing\n }\n }\n }\n\n return useMemo(() => {\n return crud && this._currentUserFromCrud(crud, session);\n }, [crud, session, options?.or]);\n }\n }\n useUserById(userId: string): ServerUser | null {\n const crud = useAsyncCache(this._serverUserCache, [userId], \"useUserById()\");\n return useMemo(() => {\n return crud && this._serverUserFromCrud(crud);\n }, [crud]);\n }\n\n async listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & { nextCursor: string | null }> {\n const crud = Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query, options?.includeAnonymous], \"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 useUsers(options?: ServerListUsersOptions): ServerUser[] & { nextCursor: string | null } {\n const crud = useAsyncCache(this._serverUsersCache, [options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query] as const, \"useServerUsers()\");\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 _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 listTeams(): Promise<ServerTeam[]> {\n const teams = Result.orThrow(await this._serverTeamsCache.getOrWait([undefined], \"write-only\"));\n return teams.map((t) => this._serverTeamFromCrud(t));\n }\n\n async createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam> {\n const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));\n await this._serverTeamsCache.refresh([undefined]);\n return this._serverTeamFromCrud(team);\n }\n\n useTeams(): ServerTeam[] {\n const teams = useAsyncCache(this._serverTeamsCache, [undefined], \"useServerTeams()\");\n return useMemo(() => {\n return teams.map((t) => this._serverTeamFromCrud(t));\n }, [teams]);\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 const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n }\n }\n\n useTeam(options: { apiKey: string }): ServerTeam | null;\n useTeam(teamId: string): ServerTeam | null;\n useTeam(options?: { apiKey: string } | string): ServerTeam | null {\n if (typeof options === \"object\" && \"apiKey\" in options) {\n return this._useTeamByApiKey(options.apiKey);\n } else {\n const teamId = options;\n const teams = this.useTeams();\n return useMemo(() => {\n return teams.find((t) => t.id === teamId) ?? null;\n }, [teams, teamId]);\n }\n }\n\n async sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors[\"RequiresCustomEmailServer\"] | KnownErrors[\"SchemaError\"] | KnownErrors[\"UserIdDoesNotExist\"]>> {\n return await this._interface.sendEmail(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 ]);\n }\n}\n"],"mappings":";AAIA,SAAS,aAAa,4BAA4B;AAYlD,SAAS,qBAAqB,gBAAgB;AAE9C,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,eAAe;AAExB,SAAS,4BAA4B;AACrC,SAA6D,6BAA6B,iCAAiC;AAG3H,SAAqG,yCAAyC,+CAA+C;AAK7L,SAAgK,+BAA+B,qCAAqC;AACpO,SAAiG,+BAA+B,qCAAqC;AAErK,SAAS,qCAAqC;AAC9C,SAAS,eAAe,aAAa,sBAAsB,YAAY,qBAAqB,gCAAgC,iCAAiC;AAE7J,SAAS,qBAAqB;AAEvB,IAAM,gCAAN,cAAqG,8BAAwD;AAAA,EAyMlK,YAAY,SAQV;AACA,UAAM,eAAe,UAAU;AAAA,MAC7B,WAAW,QAAQ;AAAA,MACnB,YAAY,QAAQ;AAAA,MACpB,MAAM,QAAQ;AAAA,MACd,qBAAqB,QAAQ;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AO;AAAA,EAChD;AAAA,EAEA,MAAyB,gBAAgB,SAA0B;AACjE,UAAM,QAAQ,IAAI;AAAA,MAChB,MAAM,aAAa,OAAO;AAAA,MAC1B,KAAK,wBAAwB,QAAQ,CAAC,OAAO,CAAC;AAAA,IAChD,CAAC;AAAA,EACH;AAAA,EAEA,MAAyB,gBAAgB;AACvC,UAAM,QAAQ,IAAI;AAAA,MAChB,MAAM,cAAc;AAAA,MACpB,KAAK,iBAAiB,aAAa,MAAM,IAAI;AAAA,MAC7C,KAAK,kBAAkB,aAAa,MAAM,IAAI;AAAA,MAC9C,KAAK,4BAA4B,aAAa,MAAM,IAAI;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;","names":["crud"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/lib/stack-app/apps/implementations/server-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors, StackServerInterface } from \"@stackframe/stack-shared\";\nimport { ContactChannelsCrud } from \"@stackframe/stack-shared/dist/interface/crud/contact-channels\";\nimport { ItemCrud } from \"@stackframe/stack-shared/dist/interface/crud/items\";\nimport { NotificationPreferenceCrud } from \"@stackframe/stack-shared/dist/interface/crud/notification-preferences\";\nimport { TeamApiKeysCrud, UserApiKeysCrud, teamApiKeysCreateOutputSchema, userApiKeysCreateOutputSchema } from \"@stackframe/stack-shared/dist/interface/crud/project-api-keys\";\nimport { ProjectPermissionDefinitionsCrud, ProjectPermissionsCrud } from \"@stackframe/stack-shared/dist/interface/crud/project-permissions\";\nimport { TeamInvitationCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-invitation\";\nimport { TeamMemberProfilesCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-member-profiles\";\nimport { TeamPermissionDefinitionsCrud, TeamPermissionsCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-permissions\";\nimport { TeamsCrud } from \"@stackframe/stack-shared/dist/interface/crud/teams\";\nimport { UsersCrud } from \"@stackframe/stack-shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport type { AsyncCache } from \"@stackframe/stack-shared/dist/utils/caches\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { suspend } from \"@stackframe/stack-shared/dist/utils/react\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { useMemo } from \"react\"; // THIS_LINE_PLATFORM react-like\nimport * as yup from \"yup\";\nimport { constructRedirectUrl } from \"../../../../utils/url\";\nimport { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud, apiKeyUpdateOptionsToCrud } from \"../../api-keys\";\nimport { GetUserOptions, HandlerUrls, OAuthScopesOnSignIn, TokenStoreInit } from \"../../common\";\nimport { OAuthConnection } from \"../../connected-accounts\";\nimport { ServerContactChannel, ServerContactChannelCreateOptions, ServerContactChannelUpdateOptions, serverContactChannelCreateOptionsToCrud, serverContactChannelUpdateOptionsToCrud } from \"../../contact-channels\";\nimport { SendEmailOptions } from \"../../email\";\nimport { NotificationCategory } from \"../../notification-categories\";\nimport { AdminProjectPermissionDefinition, AdminTeamPermission, AdminTeamPermissionDefinition } from \"../../permissions\";\nimport { EditableTeamMemberProfile, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamUpdateOptions, ServerTeamUser, Team, TeamInvitation, serverTeamCreateOptionsToCrud, serverTeamUpdateOptionsToCrud } from \"../../teams\";\nimport { ProjectCurrentServerUser, ServerUser, ServerUserCreateOptions, ServerUserUpdateOptions, serverUserCreateOptionsToCrud, serverUserUpdateOptionsToCrud } from \"../../users\";\nimport { StackServerAppConstructorOptions } from \"../interfaces/server-app\";\nimport { _StackClientAppImplIncomplete } from \"./client-app-impl\";\nimport { clientVersion, createCache, createCacheBySession, getBaseUrl, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey } from \"./common\";\nimport { InlineOffer, ServerItem } from \"../../customers\";\n\nimport { useAsyncCache } from \"./common\";\n\nexport class _StackServerAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackClientAppImplIncomplete<HasTokenStore, ProjectId> {\n declare protected _interface: StackServerInterface;\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',\n desc?: boolean,\n query?: string,\n includeAnonymous?: boolean,\n ], UsersCrud['Server']['List']>(async ([cursor, limit, orderBy, desc, query, includeAnonymous]) => {\n return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query, includeAnonymous });\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<[string | undefined], TeamsCrud['Server']['Read'][]>(async ([userId]) => {\n return await this._interface.listServerTeams({ 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 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 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.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) {\n throw err;\n }\n }\n return null;\n }\n );\n private readonly _serverUserOAuthConnectionCache = createCache<[string, ProviderType, string, boolean], OAuthConnection | 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 useOAuthToken: () => useAsyncCache(this._serverUserOAuthConnectionAccessTokensCache, [userId, providerId, scope || \"\"] as const, \"user.useConnectedAccount()\"),\n providerId,\n scope,\n redirect,\n session: null,\n });\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\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 _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 _serverTeamItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([teamId, itemId]) => {\n return await this._interface.getItem({ teamId, itemId }, null);\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);\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);\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.urls.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 constructor(options:\n | StackServerAppConstructorOptions<HasTokenStore, ProjectId>\n | {\n interface: StackServerInterface,\n tokenStore: TokenStoreInit<HasTokenStore>,\n urls: Partial<HandlerUrls> | undefined,\n oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn> | undefined,\n }\n ) {\n super(\"interface\" in options ? {\n interface: options.interface,\n tokenStore: options.tokenStore,\n urls: options.urls,\n oauthScopesOnSignIn: options.oauthScopesOnSignIn,\n } : {\n interface: new StackServerInterface({\n getBaseUrl: () => getBaseUrl(options.baseUrl),\n projectId: options.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: options.extraRequestHeaders ?? {},\n clientVersion,\n publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),\n secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey(),\n }),\n baseUrl: options.baseUrl,\n extraRequestHeaders: options.extraRequestHeaders,\n projectId: options.projectId,\n publishableClientKey: options.publishableClientKey,\n tokenStore: options.tokenStore,\n urls: options.urls,\n oauthScopesOnSignIn: options.oauthScopesOnSignIn,\n redirectMethod: options.redirectMethod,\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 _serverUserFromCrud(crud: UsersCrud['Server']['Read']): ServerUser {\n const app = this;\n\n async function getConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): Promise<OAuthConnection | null>;\n async function getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>;\n async function getConnectedAccount(id: ProviderType, options?: { or?: 'redirect', scopes?: string[] }): Promise<OAuthConnection | null> {\n const scopeString = options?.scopes?.join(\" \");\n return Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, id, scopeString || \"\", options?.or === 'redirect'], \"write-only\"));\n }\n\n function useConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): OAuthConnection | null;\n function useConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): OAuthConnection;\n function useConnectedAccount(id: ProviderType, options?: { or?: 'redirect', scopes?: string[] }): OAuthConnection | null {\n const scopeString = options?.scopes?.join(\" \");\n return useAsyncCache(app._serverUserOAuthConnectionCache, [crud.id, id, scopeString || \"\", options?.or === 'redirect'] as const, \"user.useConnectedAccount()\");\n }\n\n return {\n ...super._createBaseUser(crud),\n lastActiveAt: new Date(crud.last_active_at_millis),\n serverMetadata: crud.server_metadata,\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 }\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 }\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.map((session) => app._clientSessionFromCrud(session));\n },\n\n async revokeSession(sessionId: string) {\n await app._interface.deleteServerSession(sessionId);\n },\n async setDisplayName(displayName: string) {\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 | null) {\n return await this.update({ selectedTeamId: team?.id ?? null });\n },\n getConnectedAccount,\n useConnectedAccount, // THIS_LINE_PLATFORM react-like\n selectedTeam: crud.selected_team ? app._serverTeamFromCrud(crud.selected_team) : null,\n async getTeam(teamId: string) {\n const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n },\n useTeam(teamId: string) {\n const teams = this.useTeams();\n return useMemo(() => {\n return teams.find((t) => t.id === teamId) ?? null;\n }, [teams, teamId]);\n },\n async listTeams() {\n const teams = Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id], \"write-only\"));\n return teams.map((t) => app._serverTeamFromCrud(t));\n },\n useTeams() {\n const teams = useAsyncCache(app._serverTeamsCache, [crud.id], \"user.useTeams()\");\n return useMemo(() => teams.map((t) => app._serverTeamFromCrud(t)), [teams]);\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.refresh([undefined]);\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 // TODO: refresh cache\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 usePermissions(scopeOrOptions?: Team | { recursive?: boolean }, options?: { recursive?: boolean }): AdminTeamPermission[] {\n if (scopeOrOptions && 'id' in scopeOrOptions) {\n const scope = scopeOrOptions;\n const recursive = options?.recursive ?? true;\n const permissions = useAsyncCache(app._serverTeamUserPermissionsCache, [scope.id, crud.id, recursive] as const, \"user.usePermissions()\");\n return useMemo(() => permissions.map((crud) => app._serverPermissionFromCrud(crud)), [permissions]);\n } else {\n const opts = scopeOrOptions;\n const recursive = opts?.recursive ?? true;\n const permissions = useAsyncCache(app._serverUserProjectPermissionsCache, [crud.id, recursive] as const, \"user.usePermissions()\");\n return useMemo(() => permissions.map((crud) => app._serverPermissionFromCrud(crud)), [permissions]);\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 usePermission(scopeOrPermissionId: Team | string, permissionId?: string): AdminTeamPermission | null {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n const permissions = this.usePermissions(scope);\n return useMemo(() => permissions.find((p) => p.id === permissionId) ?? null, [permissions, permissionId]);\n } else {\n const pid = scopeOrPermissionId;\n const permissions = this.usePermissions();\n return useMemo(() => permissions.find((p) => p.id === pid) ?? null, [permissions, pid]);\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 useTeamProfile(team: Team) {\n const result = useAsyncCache(app._serverUserTeamProfileCache, [team.id, crud.id] as const, \"user.useTeamProfile()\");\n return useMemo(() => app._serverEditableTeamProfileFromCrud(result), [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 useContactChannels() {\n const result = useAsyncCache(app._serverContactChannelsCache, [crud.id] as const, \"user.useContactChannels()\");\n return useMemo(() => result.map((data) => app._serverContactChannelFromCrud(crud.id, data)), [result]);\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 useNotificationCategories() {\n const results = useAsyncCache(app._serverNotificationCategoriesCache, [crud.id] as const, \"user.useNotificationCategories()\");\n return results.map((category) => app._serverNotificationCategoryFromCrud(crud.id, category));\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 useApiKeys() {\n const result = useAsyncCache(app._serverUserApiKeysCache, [crud.id] as const, \"user.useApiKeys()\");\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\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 async createCheckoutUrl(options: { offerId: string } | { offer: InlineOffer }) {\n const offerIdOrInline = \"offerId\" in options ? options.offerId : options.offer;\n return await app._interface.createCheckoutUrl(\"user\", crud.id, offerIdOrInline, null);\n },\n async getItem(itemId: string) {\n const result = Result.orThrow(await app._serverUserItemsCache.getOrWait([crud.id, itemId], \"write-only\"));\n return app._serverItemFromCrud({ type: \"user\", id: crud.id }, result);\n },\n useItem(itemId: string) {\n const result = useAsyncCache(app._serverUserItemsCache, [crud.id, itemId] as const, \"user.useItem()\");\n return useMemo(() => app._serverItemFromCrud({ type: \"user\", id: crud.id }, result), [result]);\n },\n };\n }\n\n protected _serverTeamUserFromCrud(crud: TeamMemberProfilesCrud[\"Server\"][\"Read\"]): ServerTeamUser {\n return {\n ...this._serverUserFromCrud(crud.user),\n teamProfile: {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n },\n };\n }\n\n protected _serverTeamInvitationFromCrud(crud: TeamInvitationCrud['Server']['Read']): TeamInvitation {\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 },\n };\n }\n\n protected override _currentUserFromCrud(crud: UsersCrud['Server']['Read'], session: InternalSession): ProjectCurrentServerUser<ProjectId> {\n const app = this;\n const currentUser = {\n ...this._serverUserFromCrud(crud),\n ...this._createAuth(session),\n ...this._isInternalProject() ? this._createInternalUserExtra(session) : {},\n } satisfies ServerUser;\n\n Object.freeze(currentUser);\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 app._serverTeamsCache.refresh([undefined]);\n },\n async delete() {\n await app._interface.deleteServerTeam(crud.id);\n await app._serverTeamsCache.refresh([undefined]);\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 useUsers() {\n const result = useAsyncCache(app._serverTeamMemberProfilesCache, [crud.id] as const, \"team.useUsers()\");\n return useMemo(() => result.map(u => app._serverTeamUserFromCrud(u)), [result]);\n },\n async addUser(userId) {\n await app._interface.addServerUserToTeam({\n teamId: crud.id,\n userId,\n });\n await app._serverTeamMemberProfilesCache.refresh([crud.id]);\n },\n async removeUser(userId) {\n await app._interface.removeServerUserFromTeam({\n teamId: crud.id,\n userId,\n });\n await app._serverTeamMemberProfilesCache.refresh([crud.id]);\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.urls.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._serverTeamInvitationFromCrud(crud));\n },\n useInvitations() {\n const result = useAsyncCache(app._serverTeamInvitationsCache, [crud.id] as const, \"team.useInvitations()\");\n return useMemo(() => result.map((crud) => app._serverTeamInvitationFromCrud(crud)), [result]);\n },\n useApiKeys() {\n const result = useAsyncCache(app._serverTeamApiKeysCache, [crud.id] as const, \"team.useApiKeys()\");\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\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 async getItem(itemId: string) {\n const result = Result.orThrow(await app._serverTeamItemsCache.getOrWait([crud.id, itemId], \"write-only\"));\n return app._serverItemFromCrud({ type: \"team\", id: crud.id }, result);\n },\n useItem(itemId: string) {\n const result = useAsyncCache(app._serverTeamItemsCache, [crud.id, itemId] as const, \"team.useItem()\");\n return useMemo(() => app._serverItemFromCrud({ type: \"team\", id: crud.id }, result), [result]);\n },\n async createCheckoutUrl(options: { offerId: string } | { offer: InlineOffer }) {\n const offerIdOrInline = \"offerId\" in options ? options.offerId : options.offer;\n return await app._interface.createCheckoutUrl(\"team\", crud.id, offerIdOrInline, null);\n },\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 _useUserApiKey(options: { apiKey: string }): ApiKey<\"user\"> | null {\n const crud = useAsyncCache(this._serverCheckApiKeyCache, [\"user\", options.apiKey] as const, \"useUserApiKey()\") as UserApiKeysCrud['Server']['Read'] | null;\n return useMemo(() => crud ? this._serverApiKeyFromCrud(crud) : null, [crud]);\n }\n protected _useTeamApiKey(options: { apiKey: string }): ApiKey<\"team\"> | null {\n const crud = useAsyncCache(this._serverCheckApiKeyCache, [\"team\", options.apiKey] as const, \"useTeamApiKey()\") as TeamApiKeysCrud['Server']['Read'] | null;\n return useMemo(() => crud ? this._serverApiKeyFromCrud(crud) : null, [crud]);\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 protected _useUserByApiKey(apiKey: string): ServerUser | null {\n const apiKeyObject = this._useUserApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return this.useUserById(apiKeyObject.userId);\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 protected _useTeamByApiKey(apiKey: string): ServerTeam | null {\n const apiKeyObject = this._useTeamApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return this.useTeam(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: GetUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options?: GetUserOptions<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?: string | GetUserOptions<HasTokenStore> | { apiKey: string }): 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 {\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 if (crud?.is_anonymous && options?.or !== \"anonymous\" && options?.or !== \"anonymous-if-exists[deprecated]\") {\n crud = null;\n }\n\n if (crud === null) {\n switch (options?.or) {\n case 'redirect': {\n await this.redirectToSignIn({ replace: true });\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]\" }) ?? 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(\"stackServerApp.getServerUser is deprecated; use stackServerApp.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 useUser(options: GetUserOptions<HasTokenStore> & { or: 'redirect' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options: GetUserOptions<HasTokenStore> & { or: 'throw' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options: GetUserOptions<HasTokenStore> & { or: 'anonymous' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options?: GetUserOptions<HasTokenStore>): ProjectCurrentServerUser<ProjectId> | null;\n useUser(id: string): ServerUser | null;\n useUser(options: { apiKey: string }): ServerUser | null;\n useUser(options?: GetUserOptions<HasTokenStore> | string | { apiKey: string }): ProjectCurrentServerUser<ProjectId> | ServerUser | null {\n if (typeof options === \"string\") {\n return this.useUserById(options);\n } else if (typeof options === \"object\" && \"apiKey\" in options) {\n return this._useUserByApiKey(options.apiKey);\n } else {\n // TODO this code is duplicated from the client app; fix that\n this._ensurePersistentTokenStore(options?.tokenStore);\n\n const session = this._useSession(options?.tokenStore);\n let crud = useAsyncCache(this._currentServerUserCache, [session] as const, \"useUser()\");\n if (crud?.is_anonymous && options?.or !== \"anonymous\" && options?.or !== \"anonymous-if-exists[deprecated]\") {\n crud = null;\n }\n\n if (crud === null) {\n switch (options?.or) {\n case 'redirect': {\n runAsynchronously(this.redirectToSignIn({ replace: true }));\n suspend();\n throw new StackAssertionError(\"suspend should never return\");\n }\n case 'throw': {\n throw new Error(\"User is not signed in but useUser was called with { or: 'throw' }\");\n }\n case 'anonymous': {\n // TODO we should think about the behavior when calling useUser (or getUser) in anonymous with a custom token store. signUpAnonymously always sets the current token store on app level, instead of the one passed to this function\n // TODO we shouldn't reload & suspend here, instead we should use a promise that resolves to the new anonymous user\n runAsynchronously(async () => {\n await this._signUpAnonymously();\n if (typeof window !== \"undefined\") {\n window.location.reload();\n }\n });\n suspend();\n throw new StackAssertionError(\"suspend should never return\");\n }\n case undefined:\n case \"anonymous-if-exists[deprecated]\":\n case \"return-null\": {\n // do nothing\n }\n }\n }\n\n return useMemo(() => {\n return crud && this._currentUserFromCrud(crud, session);\n }, [crud, session, options?.or]);\n }\n }\n useUserById(userId: string): ServerUser | null {\n const crud = useAsyncCache(this._serverUserCache, [userId], \"useUserById()\");\n return useMemo(() => {\n return crud && this._serverUserFromCrud(crud);\n }, [crud]);\n }\n\n async listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & { nextCursor: string | null }> {\n const crud = Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query, options?.includeAnonymous], \"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 useUsers(options?: ServerListUsersOptions): ServerUser[] & { nextCursor: string | null } {\n const crud = useAsyncCache(this._serverUsersCache, [options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query] as const, \"useServerUsers()\");\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 _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 listTeams(): Promise<ServerTeam[]> {\n const teams = Result.orThrow(await this._serverTeamsCache.getOrWait([undefined], \"write-only\"));\n return teams.map((t) => this._serverTeamFromCrud(t));\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 useItem(options: { itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }): ServerItem {\n let type: \"user\" | \"team\" | \"custom\";\n let id: string;\n let cache: AsyncCache<[string, string], Result<ItemCrud['Client']['Read']>>;\n if (\"userId\" in options) {\n type = \"user\";\n id = options.userId;\n cache = this._serverUserItemsCache;\n } else if (\"teamId\" in options) {\n type = \"team\";\n id = options.teamId;\n cache = this._serverTeamItemsCache;\n } else {\n type = \"custom\";\n id = options.customCustomerId;\n cache = this._serverCustomItemsCache;\n }\n\n const cacheKey = [id, options.itemId] as [string, string];\n const debugLabel = `app.useItem(${type})`;\n const result = useAsyncCache(cache, cacheKey, debugLabel);\n return useMemo(() => this._serverItemFromCrud({ type, id }, result), [result]);\n }\n\n async createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam> {\n const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));\n await this._serverTeamsCache.refresh([undefined]);\n return this._serverTeamFromCrud(team);\n }\n\n useTeams(): ServerTeam[] {\n const teams = useAsyncCache(this._serverTeamsCache, [undefined], \"useServerTeams()\");\n return useMemo(() => {\n return teams.map((t) => this._serverTeamFromCrud(t));\n }, [teams]);\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 const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n }\n }\n\n useTeam(options: { apiKey: string }): ServerTeam | null;\n useTeam(teamId: string): ServerTeam | null;\n useTeam(options?: { apiKey: string } | string): ServerTeam | null {\n if (typeof options === \"object\" && \"apiKey\" in options) {\n return this._useTeamByApiKey(options.apiKey);\n } else {\n const teamId = options;\n const teams = this.useTeams();\n return useMemo(() => {\n return teams.find((t) => t.id === teamId) ?? null;\n }, [teams, teamId]);\n }\n }\n\n async sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors[\"RequiresCustomEmailServer\"] | KnownErrors[\"SchemaError\"] | KnownErrors[\"UserIdDoesNotExist\"]>> {\n return await this._interface.sendEmail(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 ]);\n }\n}\n"],"mappings":";AAIA,SAAS,aAAa,4BAA4B;AAalD,SAAS,qBAAqB,gBAAgB;AAE9C,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,eAAe;AAExB,SAAS,4BAA4B;AACrC,SAA6D,6BAA6B,iCAAiC;AAG3H,SAAqG,yCAAyC,+CAA+C;AAI7L,SAAgK,+BAA+B,qCAAqC;AACpO,SAAiG,+BAA+B,qCAAqC;AAErK,SAAS,qCAAqC;AAC9C,SAAS,eAAe,aAAa,sBAAsB,YAAY,qBAAqB,gCAAgC,iCAAiC;AAG7J,SAAS,qBAAqB;AAEvB,IAAM,gCAAN,cAAqG,8BAAwD;AAAA,EA+MlK,YAAY,SAQV;AACA,UAAM,eAAe,UAAU;AAAA,MAC7B,WAAW,QAAQ;AAAA,MACnB,YAAY,QAAQ;AAAA,MACpB,MAAM,QAAQ;AAAA,MACd,qBAAqB,QAAQ;AAAA,IAC/B,IAAI;AAAA,MACF,WAAW,IAAI,qBAAqB;AAAA,QAClC,YAAY,MAAM,WAAW,QAAQ,OAAO;AAAA,QAC5C,WAAW,QAAQ,aAAa,oBAAoB;AAAA,QACpD,qBAAqB,QAAQ,uBAAuB,CAAC;AAAA,QACrD;AAAA,QACA,sBAAsB,QAAQ,wBAAwB,+BAA+B;AAAA,QACrF,iBAAiB,QAAQ,mBAAmB,0BAA0B;AAAA,MACxE,CAAC;AAAA,MACD,SAAS,QAAQ;AAAA,MACjB,qBAAqB,QAAQ;AAAA,M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