@stackframe/js 2.8.54 → 2.8.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/lib/cookie.js +50 -15
- package/dist/esm/lib/cookie.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +235 -0
- 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 +81 -25
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +2 -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 +31 -23
- 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/esm/lib/stack-app/common.js.map +1 -1
- package/dist/esm/lib/stack-app/index.js.map +1 -1
- package/dist/esm/lib/stack-app/projects/index.js +4 -0
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js +13 -12
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/index.d.mts +249 -16
- package/dist/index.d.ts +249 -16
- package/dist/lib/cookie.js +50 -15
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +235 -0
- 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 +79 -23
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +2 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +29 -21
- 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/common.js.map +1 -1
- package/dist/lib/stack-app/email/index.js.map +1 -1
- package/dist/lib/stack-app/index.js.map +1 -1
- package/dist/lib/stack-app/project-configs/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js +4 -0
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/teams/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js +15 -14
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/package.json +3 -2
- package/CHANGELOG.md +0 -2052
package/dist/esm/lib/cookie.js
CHANGED
|
@@ -42,7 +42,7 @@ function getCookieClient(name) {
|
|
|
42
42
|
}
|
|
43
43
|
function getAllCookiesClient() {
|
|
44
44
|
ensureClient();
|
|
45
|
-
Cookies.set("stack-is-https", "true", { secure: true });
|
|
45
|
+
Cookies.set("stack-is-https", "true", { secure: true, expires: new Date(Date.now() + 1e3 * 60 * 60 * 24 * 365) });
|
|
46
46
|
return Cookies.get();
|
|
47
47
|
}
|
|
48
48
|
async function getCookie(name) {
|
|
@@ -58,21 +58,56 @@ async function isSecure() {
|
|
|
58
58
|
function determineSecureFromClientContext() {
|
|
59
59
|
return typeof window !== "undefined" && window.location.protocol === "https:";
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
var _shouldSetPartitionedClientCache = void 0;
|
|
62
|
+
function shouldSetPartitionedClient() {
|
|
63
|
+
return _shouldSetPartitionedClientCache ??= _internalShouldSetPartitionedClient();
|
|
64
|
+
}
|
|
65
|
+
function _internalShouldSetPartitionedClient() {
|
|
66
|
+
ensureClient();
|
|
67
|
+
if (!determineSecureFromClientContext()) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const cookie1Name = "__Host-stack-temporary-chips-test-" + Math.random().toString(36).substring(2, 15);
|
|
71
|
+
document.cookie = `${cookie1Name}=value1; Secure; path=/`;
|
|
72
|
+
const cookies1 = document.cookie.split("; ");
|
|
73
|
+
document.cookie = `${cookie1Name}=delete1; Secure; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;`;
|
|
74
|
+
if (cookies1.some((c) => c.startsWith(cookie1Name + "="))) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const cookie2Name = "__Host-stack-temporary-chips-test-" + Math.random().toString(36).substring(2, 15);
|
|
78
|
+
document.cookie = `${cookie2Name}=delete1; Secure; SameSite=None; Partitioned; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;
|
|
79
|
+
document.cookie = `${cookie2Name}=delete2; Secure; SameSite=None; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;
|
|
80
|
+
document.cookie = `${cookie2Name}=set1; Secure; SameSite=None; Partitioned; path=/`;
|
|
81
|
+
document.cookie = `${cookie2Name}=set2; Secure; SameSite=None; path=/`;
|
|
82
|
+
const cookies2 = document.cookie.split("; ");
|
|
83
|
+
const numberOfCookiesWithThisName = cookies2.filter((c) => c.startsWith(cookie2Name + "=")).length;
|
|
84
|
+
document.cookie = `${cookie2Name}=delete3; Secure; SameSite=None; Partitioned; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;
|
|
85
|
+
document.cookie = `${cookie2Name}=delete4; Secure; SameSite=None; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;
|
|
86
|
+
return numberOfCookiesWithThisName === 2;
|
|
87
|
+
}
|
|
88
|
+
function setCookieClientInternal(name, value, options) {
|
|
62
89
|
const secure = options.secure ?? determineSecureFromClientContext();
|
|
90
|
+
const partitioned = shouldSetPartitionedClient();
|
|
63
91
|
Cookies.set(name, value, {
|
|
64
|
-
expires: options.maxAge ===
|
|
92
|
+
expires: options.maxAge === "session" ? void 0 : new Date(Date.now() + options.maxAge * 1e3),
|
|
65
93
|
domain: options.domain,
|
|
66
|
-
secure
|
|
94
|
+
secure,
|
|
95
|
+
sameSite: "Lax",
|
|
96
|
+
...partitioned ? {
|
|
97
|
+
partitioned,
|
|
98
|
+
sameSite: "None"
|
|
99
|
+
} : {}
|
|
67
100
|
});
|
|
68
101
|
}
|
|
69
|
-
function deleteCookieClientInternal(name, options
|
|
70
|
-
|
|
71
|
-
|
|
102
|
+
function deleteCookieClientInternal(name, options) {
|
|
103
|
+
for (const partitioned of [true, false]) {
|
|
104
|
+
if (options.domain !== void 0) {
|
|
105
|
+
Cookies.remove(name, { domain: options.domain, secure: determineSecureFromClientContext(), partitioned });
|
|
106
|
+
}
|
|
107
|
+
Cookies.remove(name, { secure: determineSecureFromClientContext(), partitioned });
|
|
72
108
|
}
|
|
73
|
-
Cookies.remove(name, { secure: determineSecureFromClientContext() });
|
|
74
109
|
}
|
|
75
|
-
function setOrDeleteCookieClient(name, value, options
|
|
110
|
+
function setOrDeleteCookieClient(name, value, options) {
|
|
76
111
|
ensureClient();
|
|
77
112
|
if (value === null) {
|
|
78
113
|
deleteCookieClientInternal(name, options);
|
|
@@ -80,23 +115,23 @@ function setOrDeleteCookieClient(name, value, options = {}) {
|
|
|
80
115
|
setCookieClientInternal(name, value, options);
|
|
81
116
|
}
|
|
82
117
|
}
|
|
83
|
-
async function setOrDeleteCookie(name, value, options
|
|
118
|
+
async function setOrDeleteCookie(name, value, options) {
|
|
84
119
|
const cookieHelper = await createCookieHelper();
|
|
85
120
|
cookieHelper.setOrDelete(name, value, options);
|
|
86
121
|
}
|
|
87
|
-
function deleteCookieClient(name, options
|
|
122
|
+
function deleteCookieClient(name, options) {
|
|
88
123
|
ensureClient();
|
|
89
124
|
deleteCookieClientInternal(name, options);
|
|
90
125
|
}
|
|
91
|
-
async function deleteCookie(name, options
|
|
126
|
+
async function deleteCookie(name, options) {
|
|
92
127
|
const cookieHelper = await createCookieHelper();
|
|
93
128
|
cookieHelper.delete(name, options);
|
|
94
129
|
}
|
|
95
|
-
function setCookieClient(name, value, options
|
|
130
|
+
function setCookieClient(name, value, options) {
|
|
96
131
|
ensureClient();
|
|
97
132
|
setCookieClientInternal(name, value, options);
|
|
98
133
|
}
|
|
99
|
-
async function setCookie(name, value, options
|
|
134
|
+
async function setCookie(name, value, options) {
|
|
100
135
|
const cookieHelper = await createCookieHelper();
|
|
101
136
|
cookieHelper.set(name, value, options);
|
|
102
137
|
}
|
|
@@ -117,7 +152,7 @@ function consumeVerifierAndStateCookie(state) {
|
|
|
117
152
|
if (!codeVerifier) {
|
|
118
153
|
return null;
|
|
119
154
|
}
|
|
120
|
-
deleteCookieClient(cookieName);
|
|
155
|
+
deleteCookieClient(cookieName, {});
|
|
121
156
|
return {
|
|
122
157
|
codeVerifier
|
|
123
158
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/cookie.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { isBrowserLike } from '@stackframe/stack-shared/dist/utils/env';\nimport { StackAssertionError } from '@stackframe/stack-shared/dist/utils/errors';\nimport Cookies from \"js-cookie\";\nimport { calculatePKCECodeChallenge, generateRandomCodeVerifier, generateRandomState } from \"oauth4webapi\";\n\ntype SetCookieOptions = { maxAge?: number, noOpIfServerComponent?: boolean, domain?: string, secure?: boolean };\ntype DeleteCookieOptions = { noOpIfServerComponent?: boolean, domain?: string };\n\nfunction ensureClient() {\n if (!isBrowserLike()) {\n throw new Error(\"cookieClient functions can only be called in a browser environment, yet window is undefined\");\n }\n}\n\nexport type CookieHelper = {\n get: (name: string) => string | null,\n getAll: () => Record<string, string>,\n set: (name: string, value: string, options: SetCookieOptions) => void,\n setOrDelete: (name: string, value: string | null, options: SetCookieOptions & DeleteCookieOptions) => void,\n delete: (name: string, options: DeleteCookieOptions) => void,\n};\n\nconst placeholderCookieHelperIdentity = { \"placeholder cookie helper identity\": true };\nexport async function createPlaceholderCookieHelper(): Promise<CookieHelper> {\n function throwError(): never {\n throw new StackAssertionError(\"Throwing cookie helper is just a placeholder. This should never be called\");\n }\n return {\n get: throwError,\n getAll: throwError,\n set: throwError,\n setOrDelete: throwError,\n delete: throwError,\n };\n}\n\nexport async function createCookieHelper(): Promise<CookieHelper> {\n if (isBrowserLike()) {\n return createBrowserCookieHelper();\n } else {\n return await createPlaceholderCookieHelper();\n }\n}\n\nexport function createBrowserCookieHelper(): CookieHelper {\n return {\n get: getCookieClient,\n getAll: getAllCookiesClient,\n set: setCookieClient,\n setOrDelete: setOrDeleteCookieClient,\n delete: deleteCookieClient,\n };\n}\n\nfunction handleCookieError(e: unknown, options: DeleteCookieOptions | SetCookieOptions) {\n if (e instanceof Error && e.message.includes(\"Cookies can only be modified in\")) {\n if (options.noOpIfServerComponent) {\n // ignore\n } else {\n throw new StackAssertionError(\"Attempted to set cookie in server component. Pass { noOpIfServerComponent: true } in the options of Stack's cookie functions if this is intentional and you want to ignore this error. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options\");\n }\n } else {\n throw e;\n }\n}\n\n\nexport function getCookieClient(name: string): string | null {\n const all = getAllCookiesClient();\n return all[name] ?? null;\n}\n\nexport function getAllCookiesClient(): Record<string, string> {\n ensureClient();\n // set a helper cookie, see comment in `NextCookieHelper.set` above\n Cookies.set(\"stack-is-https\", \"true\", { secure: true });\n return Cookies.get();\n}\n\nexport async function getCookie(name: string): Promise<string | null> {\n const cookieHelper = await createCookieHelper();\n return cookieHelper.get(name);\n}\n\nexport async function isSecure(): Promise<boolean> {\n if (isBrowserLike()) {\n return determineSecureFromClientContext();\n }\n return false;\n}\n\nfunction determineSecureFromClientContext(): boolean {\n return typeof window !== \"undefined\" && window.location.protocol === \"https:\";\n}\n\nfunction setCookieClientInternal(name: string, value: string, options: SetCookieOptions = {}) {\n const secure = options.secure ?? determineSecureFromClientContext();\n Cookies.set(name, value, {\n expires: options.maxAge === undefined ? undefined : new Date(Date.now() + (options.maxAge) * 1000),\n domain: options.domain,\n secure,\n });\n}\n\nfunction deleteCookieClientInternal(name: string, options: DeleteCookieOptions = {}) {\n if (options.domain !== undefined) {\n Cookies.remove(name, { domain: options.domain, secure: determineSecureFromClientContext() });\n }\n Cookies.remove(name, { secure: determineSecureFromClientContext() });\n}\n\nexport function setOrDeleteCookieClient(name: string, value: string | null, options: SetCookieOptions & DeleteCookieOptions = {}) {\n ensureClient();\n if (value === null) {\n deleteCookieClientInternal(name, options);\n } else {\n setCookieClientInternal(name, value, options);\n }\n}\n\nexport async function setOrDeleteCookie(name: string, value: string | null, options: SetCookieOptions & DeleteCookieOptions = {}) {\n const cookieHelper = await createCookieHelper();\n cookieHelper.setOrDelete(name, value, options);\n}\n\nexport function deleteCookieClient(name: string, options: DeleteCookieOptions = {}) {\n ensureClient();\n deleteCookieClientInternal(name, options);\n}\n\nexport async function deleteCookie(name: string, options: DeleteCookieOptions = {}) {\n const cookieHelper = await createCookieHelper();\n cookieHelper.delete(name, options);\n}\n\nexport function setCookieClient(name: string, value: string, options: SetCookieOptions = {}) {\n ensureClient();\n setCookieClientInternal(name, value, options);\n}\n\nexport async function setCookie(name: string, value: string, options: SetCookieOptions = {}) {\n const cookieHelper = await createCookieHelper();\n cookieHelper.set(name, value, options);\n}\n\nexport async function saveVerifierAndState() {\n const codeVerifier = generateRandomCodeVerifier();\n const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);\n const state = generateRandomState();\n\n await setCookie(\"stack-oauth-outer-\" + state, codeVerifier, { maxAge: 60 * 60 });\n\n return {\n codeChallenge,\n state,\n };\n}\n\nexport function consumeVerifierAndStateCookie(state: string) {\n ensureClient();\n const cookieName = \"stack-oauth-outer-\" + state;\n const codeVerifier = getCookieClient(cookieName);\n if (!codeVerifier) {\n return null;\n }\n deleteCookieClient(cookieName);\n return {\n codeVerifier,\n };\n}\n"],"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AChD,QAAM,gBAAgB,MAAM,2BAA2B,YAAY;AACnE,QAAM,QAAQ,oBAAoB;AAElC,QAAM,UAAU,uBAAuB,OAAO,cAAc,EAAE,QAAQ,KAAK,GAAG,CAAC;AAE/E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,8BAA8B,OAAe;AAC3D,eAAa;AACb,QAAM,aAAa,uBAAuB;AAC1C,QAAM,eAAe,gBAAgB,UAAU;AAC/C,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AACA,qBAAmB,UAAU;AAC7B,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/cookie.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { isBrowserLike } from '@stackframe/stack-shared/dist/utils/env';\nimport { StackAssertionError } from '@stackframe/stack-shared/dist/utils/errors';\nimport Cookies from \"js-cookie\";\nimport { calculatePKCECodeChallenge, generateRandomCodeVerifier, generateRandomState } from \"oauth4webapi\";\n\n\n// INFO: This file is used to manage cookies. It also sets some cookie flags automatically, see this description.\n//\n// It provides asynchronous setCookie, getCookie, deleteCookie, etc. functions that can be used in various environments\n// (browser + Next.js for now). Under the hood, they just get a CookieHelper object and then set the cookies there.\n//\n// The CookieHelper object is a simple object that lets you set, get and delete cookies synchronously. Acquiring one\n// is asynchronous (except for browser environments, where they can be acquired synchronously), but once you have it,\n// you can use it synchronously. This function is useful if you cannot await in the calling code, but otherwise you\n// should prefer to await the functions directly.\n//\n// Some cookie flags are set automatically by the CookieHelper (and hence also the <xyz>Cookie functions).\n// In particular:\n// - SameSite is set to `Lax` by default, which is already true in Chromium-based browsers, so this creates\n// compatibility with other browsers that use either Strict or None (particularly Safari and Firefox, and older\n// versions of Chrome). If Partitioned is automatically set (as described below), then this value is set to `None`\n// instead.\n// - Secure is set depending on whether we could successfully determine that the client is on HTTPS. For this, we use a\n// set of heuristics:\n// - In a browser environment, we check window.location.protocol which is always accurate\n// - In a Next.js server environment:\n// - First we check the `stack-is-https` cookie, which is set in various places on the\n// client with a Secure attribute. If that one is passed on to the server, we know that the client is on HTTPS\n// and we can set the Secure flag on the cookie. TODO: Should we also do this with a second cookie with a\n// __Host- prefix, so a malicious subdomain of the current domain cannot forcibly enable HTTPS mode and\n// therefore prevent new cookies from being set?\n// - Otherwise, we check the X-Forwarded-Proto header. If that one is `https`, we know that the client is\n// (pretending to be) on HTTPS and we can set the Secure flag on the cookie. Note that this header is\n// spoofable by malicious clients (so is the cookie actually), but since setting this value can only *increase*\n// security (and therefore prevent setting of a cookie), and requires a malicious client, this is still safe.\n// - If neither of the above is true, we don't set the Secure flag on the cookie.\n// - Partitioned is set depending on whether it is needed & supported. Unfortunately, the fact that Partitioned\n// cookies require SameSite=None, browsers that don't support it will still set them as normal third-party cookies,\n// which are fundamentally unsafe. Therefore, we need to take extra care that we only ever set Partitioned cookies\n// if we know for sure that the browser supports it.\n// - In a browser environment, we check:\n// - Whether `Secure` is set. If it's not, we don't set Partitioned.\n// - Whether we can set & retrieve cookies without Partitioned being set. If this is the case, we are likely in a\n// top-level context or a browser that partitions cookies by default (eg. Firefox). In this case, we don't need\n// Partitioned and can just proceed as normal.\n// - Whether CHIPS is supported. To prevent the case where CHIPS is not supported but third-party cookies are (in\n// which we would accidentally set SameSite=None without Partitioned as the latter requires the former), we\n// check this by running a simple test with document.cookie.\n// - Whether the browser supports Partitioned cookies. If yes, set Partitioned. Otherwise, don't set Partitioned.\n// Since there's no easy cross-compat way to do this (CookieStore and document.cookie do not return whether a\n// cookie is partitioned on some/all versions of Safari and Firefox), we use a heuristic; we run this test by\n// creating two cookies with the same name: One with Partitioned and one without. If there are two resulting\n// cookies, that means they were put into different jars, implying that the browser supports Partitioned cookies\n// (but doesn't partition cookies by default). If they result in just one cookie, that could mean that the\n// browser doesn't support Partitioned cookies, or that the browser doesn't put partitioned cookies into\n// different jars by default, in which case we still don't know. This heuristic works on Chrome, but may\n// incorrectly conclude that some other browsers don't support Partitioned. But from a security perspective,\n// that is better than accidentally setting SameSite=None without Partitioned. TODO: Find a better heuristic to\n// to determine whether the browser supports Partitioned cookies or not.\n// - In a Next.js server environment, right now we do nothing because of the complexity involved :( TODO: In the\n// future, we could improve this for example by setting hint cookies from the client, but we need to make sure that\n// no malicious actor (eg. on a malicious subdomain) can forcefully enable Partitioned cookies on a browser that\n// does not support it.\n\n\ntype SetCookieOptions = { maxAge: number | \"session\", noOpIfServerComponent?: boolean, domain?: string, secure?: boolean };\ntype DeleteCookieOptions = { noOpIfServerComponent?: boolean, domain?: string };\n\nfunction ensureClient() {\n if (!isBrowserLike()) {\n throw new Error(\"cookieClient functions can only be called in a browser environment, yet window is undefined\");\n }\n}\n\nexport type CookieHelper = {\n get: (name: string) => string | null,\n getAll: () => Record<string, string>,\n set: (name: string, value: string, options: SetCookieOptions) => void,\n setOrDelete: (name: string, value: string | null, options: SetCookieOptions & DeleteCookieOptions) => void,\n delete: (name: string, options: DeleteCookieOptions) => void,\n};\n\nconst placeholderCookieHelperIdentity = { \"placeholder cookie helper identity\": true };\nexport async function createPlaceholderCookieHelper(): Promise<CookieHelper> {\n function throwError(): never {\n throw new StackAssertionError(\"Throwing cookie helper is just a placeholder. This should never be called\");\n }\n return {\n get: throwError,\n getAll: throwError,\n set: throwError,\n setOrDelete: throwError,\n delete: throwError,\n };\n}\n\nexport async function createCookieHelper(): Promise<CookieHelper> {\n if (isBrowserLike()) {\n return createBrowserCookieHelper();\n } else {\n return await createPlaceholderCookieHelper();\n }\n}\n\nexport function createBrowserCookieHelper(): CookieHelper {\n return {\n get: getCookieClient,\n getAll: getAllCookiesClient,\n set: setCookieClient,\n setOrDelete: setOrDeleteCookieClient,\n delete: deleteCookieClient,\n };\n}\n\nfunction handleCookieError(e: unknown, options: DeleteCookieOptions | SetCookieOptions) {\n if (e instanceof Error && e.message.includes(\"Cookies can only be modified in\")) {\n if (options.noOpIfServerComponent) {\n // ignore\n } else {\n throw new StackAssertionError(\"Attempted to set cookie in server component. Pass { noOpIfServerComponent: true } in the options of Stack's cookie functions if this is intentional and you want to ignore this error. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options\");\n }\n } else {\n throw e;\n }\n}\n\n\nexport function getCookieClient(name: string): string | null {\n const all = getAllCookiesClient();\n return all[name] ?? null;\n}\n\nexport function getAllCookiesClient(): Record<string, string> {\n ensureClient();\n // set a helper cookie, see comment in `NextCookieHelper.set` above\n Cookies.set(\"stack-is-https\", \"true\", { secure: true, expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365) });\n return Cookies.get();\n}\n\nexport async function getCookie(name: string): Promise<string | null> {\n const cookieHelper = await createCookieHelper();\n return cookieHelper.get(name);\n}\n\nexport async function isSecure(): Promise<boolean> {\n if (isBrowserLike()) {\n return determineSecureFromClientContext();\n }\n return false;\n}\n\nfunction determineSecureFromClientContext(): boolean {\n return typeof window !== \"undefined\" && window.location.protocol === \"https:\";\n}\n\n\nlet _shouldSetPartitionedClientCache: boolean | undefined = undefined;\nfunction shouldSetPartitionedClient() {\n return _shouldSetPartitionedClientCache ??= _internalShouldSetPartitionedClient();\n}\nfunction _internalShouldSetPartitionedClient() {\n ensureClient();\n\n if (!(determineSecureFromClientContext())) {\n return false;\n }\n\n // check whether we can set & retrieve normal cookies (either because we're on a top-level/same-origin context or the browser partitions cookies by default)\n const cookie1Name = \"__Host-stack-temporary-chips-test-\" + Math.random().toString(36).substring(2, 15);\n document.cookie = `${cookie1Name}=value1; Secure; path=/`;\n const cookies1 = document.cookie.split(\"; \");\n document.cookie = `${cookie1Name}=delete1; Secure; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;`;\n if (cookies1.some((c) => c.startsWith(cookie1Name + \"=\"))) {\n return false;\n }\n\n\n // check whether Partitioned cookies are supported by the browser\n // TODO: See comment at the top. Feels like we should find a better way to do this\n const cookie2Name = \"__Host-stack-temporary-chips-test-\" + Math.random().toString(36).substring(2, 15);\n\n // just to be safe, delete the cookie first to avoid weird RNG-prediction attacks\n // I don't know what they look like (since this is a host cookie) but better safe than sorry\n // (this function should be 100% bulletproof so we don't accidentally fall back to non-partitioned third party cookies on unsupported browsers)\n document.cookie = `${cookie2Name}=delete1; Secure; SameSite=None; Partitioned; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;\n document.cookie = `${cookie2Name}=delete2; Secure; SameSite=None; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;\n\n // set the cookie, once partitioned and once not partitioned\n document.cookie = `${cookie2Name}=set1; Secure; SameSite=None; Partitioned; path=/`;\n document.cookie = `${cookie2Name}=set2; Secure; SameSite=None; path=/`;\n\n // check if there are two cookies\n const cookies2 = document.cookie.split(\"; \");\n const numberOfCookiesWithThisName = cookies2.filter((c) => c.startsWith(cookie2Name + \"=\")).length;\n\n // clean up\n document.cookie = `${cookie2Name}=delete3; Secure; SameSite=None; Partitioned; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;\n document.cookie = `${cookie2Name}=delete4; Secure; SameSite=None; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;\n\n return numberOfCookiesWithThisName === 2;\n}\n\nfunction setCookieClientInternal(name: string, value: string, options: SetCookieOptions) {\n const secure = options.secure ?? determineSecureFromClientContext();\n const partitioned = shouldSetPartitionedClient();\n Cookies.set(name, value, {\n expires: options.maxAge === \"session\" ? undefined : new Date(Date.now() + (options.maxAge) * 1000),\n domain: options.domain,\n secure,\n sameSite: \"Lax\",\n ...(partitioned ? {\n partitioned,\n sameSite: \"None\",\n } : {}),\n });\n}\n\nfunction deleteCookieClientInternal(name: string, options: DeleteCookieOptions) {\n for (const partitioned of [true, false]) {\n if (options.domain !== undefined) {\n Cookies.remove(name, { domain: options.domain, secure: determineSecureFromClientContext(), partitioned });\n }\n Cookies.remove(name, { secure: determineSecureFromClientContext(), partitioned });\n }\n}\n\nexport function setOrDeleteCookieClient(name: string, value: string | null, options: SetCookieOptions & DeleteCookieOptions) {\n ensureClient();\n if (value === null) {\n deleteCookieClientInternal(name, options);\n } else {\n setCookieClientInternal(name, value, options);\n }\n}\n\nexport async function setOrDeleteCookie(name: string, value: string | null, options: SetCookieOptions & DeleteCookieOptions) {\n const cookieHelper = await createCookieHelper();\n cookieHelper.setOrDelete(name, value, options);\n}\n\nexport function deleteCookieClient(name: string, options: DeleteCookieOptions) {\n ensureClient();\n deleteCookieClientInternal(name, options);\n}\n\nexport async function deleteCookie(name: string, options: DeleteCookieOptions) {\n const cookieHelper = await createCookieHelper();\n cookieHelper.delete(name, options);\n}\n\nexport function setCookieClient(name: string, value: string, options: SetCookieOptions) {\n ensureClient();\n setCookieClientInternal(name, value, options);\n}\n\nexport async function setCookie(name: string, value: string, options: SetCookieOptions) {\n const cookieHelper = await createCookieHelper();\n cookieHelper.set(name, value, options);\n}\n\nexport async function saveVerifierAndState() {\n const codeVerifier = generateRandomCodeVerifier();\n const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);\n const state = generateRandomState();\n\n await setCookie(\"stack-oauth-outer-\" + state, codeVerifier, { maxAge: 60 * 60 });\n\n return {\n codeChallenge,\n state,\n };\n}\n\nexport function consumeVerifierAndStateCookie(state: string) {\n ensureClient();\n const cookieName = \"stack-oauth-outer-\" + state;\n const codeVerifier = getCookieClient(cookieName);\n if (!codeVerifier) {\n return null;\n }\n deleteCookieClient(cookieName, {});\n return {\n codeVerifier,\n };\n}\n"],"mappings":";AAIA,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,OAAO,aAAa;AACpB,SAAS,4BAA4B,4BAA4B,2BAA2B;AAiE5F,SAAS,eAAe;AACtB,MAAI,CAAC,cAAc,GAAG;AACpB,UAAM,IAAI,MAAM,6FAA6F;AAAA,EAC/G;AACF;AAWA,eAAsB,gCAAuD;AAC3E,WAAS,aAAoB;AAC3B,UAAM,IAAI,oBAAoB,2EAA2E;AAAA,EAC3G;AACA,SAAO;AAAA,IACL,KAAK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OAAsB,SAAiD;AAC3H,eAAa;AACb,MAAI,UAAU,MAAM;AAClB,+BAA2B,MAAM,OAAO;AAAA,EAC1C,OAAO;AACL,4BAAwB,MAAM,OAAO,OAAO;AAAA,EAC9C;AACF;AAEA,eAAsB,kBAAkB,MAAc,OAAsB,SAAiD;AAC3H,QAAM,eAAe,MAAM,mBAAmB;AAC9C,eAAa,YAAY,MAAM,OAAO,OAAO;AAC/C;AAEO,SAAS,mBAAmB,MAAc,SAA8B;AAC7E,eAAa;AACb,6BAA2B,MAAM,OAAO;AAC1C;AAEA,eAAsB,aAAa,MAAc,SAA8B;AAC7E,QAAM,eAAe,MAAM,mBAAmB;AAC9C,eAAa,OAAO,MAAM,OAAO;AACnC;AAEO,SAAS,gBAAgB,MAAc,OAAe,SAA2B;AACtF,eAAa;AACb,0BAAwB,MAAM,OAAO,OAAO;AAC9C;AAEA,eAAsB,UAAU,MAAc,OAAe,SAA2B;AACtF,QAAM,eAAe,MAAM,mBAAmB;AAC9C,eAAa,IAAI,MAAM,OAAO,OAAO;AACvC;AAEA,eAAsB,uBAAuB;AAC3C,QAAM,eAAe,2BAA2B;AAChD,QAAM,gBAAgB,MAAM,2BAA2B,YAAY;AACnE,QAAM,QAAQ,oBAAoB;AAElC,QAAM,UAAU,uBAAuB,OAAO,cAAc,EAAE,QAAQ,KAAK,GAAG,CAAC;AAE/E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,8BAA8B,OAAe;AAC3D,eAAa;AACb,QAAM,aAAa,uBAAuB;AAC1C,QAAM,eAAe,gBAAgB,UAAU;AAC/C,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AACA,qBAAmB,YAAY,CAAC,CAAC;AACjC,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
|
|
@@ -425,9 +425,244 @@ var _StackAdminAppImplIncomplete = class extends _StackServerAppImplIncomplete {
|
|
|
425
425
|
const crud = Result.orThrow(await this._transactionsCache.getOrWait([params.cursor, params.limit, params.type, params.customerType], "write-only"));
|
|
426
426
|
return crud;
|
|
427
427
|
}
|
|
428
|
+
// Email Outbox methods
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Complex discriminated union conversion from API response
|
|
430
|
+
_emailOutboxCrudToAdmin(crud) {
|
|
431
|
+
const recipient = crud.to;
|
|
432
|
+
let to;
|
|
433
|
+
if (recipient.type === "user-primary-email") {
|
|
434
|
+
to = { type: "user-primary-email", userId: recipient.user_id };
|
|
435
|
+
} else if (recipient.type === "user-custom-emails") {
|
|
436
|
+
to = { type: "user-custom-emails", userId: recipient.user_id, emails: recipient.emails };
|
|
437
|
+
} else {
|
|
438
|
+
to = { type: "custom-emails", emails: recipient.emails };
|
|
439
|
+
}
|
|
440
|
+
const base = {
|
|
441
|
+
id: crud.id,
|
|
442
|
+
createdAt: new Date(crud.created_at_millis),
|
|
443
|
+
updatedAt: new Date(crud.updated_at_millis),
|
|
444
|
+
to,
|
|
445
|
+
scheduledAt: new Date(crud.scheduled_at_millis),
|
|
446
|
+
isPaused: false,
|
|
447
|
+
hasRendered: false,
|
|
448
|
+
hasDelivered: false
|
|
449
|
+
};
|
|
450
|
+
const rendered = crud.has_rendered ? {
|
|
451
|
+
...base,
|
|
452
|
+
startedRenderingAt: new Date(crud.started_rendering_at_millis),
|
|
453
|
+
renderedAt: new Date(crud.rendered_at_millis),
|
|
454
|
+
subject: crud.subject,
|
|
455
|
+
html: crud.html,
|
|
456
|
+
text: crud.text,
|
|
457
|
+
isTransactional: crud.is_transactional,
|
|
458
|
+
isHighPriority: crud.is_high_priority,
|
|
459
|
+
notificationCategoryId: crud.notification_category_id,
|
|
460
|
+
hasRendered: true
|
|
461
|
+
} : null;
|
|
462
|
+
const startedSending = rendered && crud.started_sending_at_millis ? {
|
|
463
|
+
...rendered,
|
|
464
|
+
startedSendingAt: new Date(crud.started_sending_at_millis)
|
|
465
|
+
} : null;
|
|
466
|
+
const finishedDelivering = startedSending && crud.has_delivered ? {
|
|
467
|
+
...startedSending,
|
|
468
|
+
deliveredAt: new Date(crud.delivered_at_millis),
|
|
469
|
+
hasDelivered: true
|
|
470
|
+
} : null;
|
|
471
|
+
const result = (() => {
|
|
472
|
+
switch (crud.status) {
|
|
473
|
+
case "paused": {
|
|
474
|
+
return {
|
|
475
|
+
...base,
|
|
476
|
+
status: "paused",
|
|
477
|
+
simpleStatus: "in-progress",
|
|
478
|
+
isPaused: true
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
case "preparing": {
|
|
482
|
+
return {
|
|
483
|
+
...base,
|
|
484
|
+
status: "preparing",
|
|
485
|
+
simpleStatus: "in-progress"
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
case "rendering": {
|
|
489
|
+
return {
|
|
490
|
+
...base,
|
|
491
|
+
status: "rendering",
|
|
492
|
+
simpleStatus: "in-progress",
|
|
493
|
+
startedRenderingAt: new Date(crud.started_rendering_at_millis)
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
case "render-error": {
|
|
497
|
+
return {
|
|
498
|
+
...base,
|
|
499
|
+
status: "render-error",
|
|
500
|
+
simpleStatus: "error",
|
|
501
|
+
startedRenderingAt: new Date(crud.started_rendering_at_millis),
|
|
502
|
+
renderedAt: new Date(crud.rendered_at_millis),
|
|
503
|
+
renderError: crud.render_error
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
case "scheduled": {
|
|
507
|
+
return {
|
|
508
|
+
...rendered,
|
|
509
|
+
status: "scheduled",
|
|
510
|
+
simpleStatus: "in-progress"
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
case "queued": {
|
|
514
|
+
return {
|
|
515
|
+
...rendered,
|
|
516
|
+
status: "queued",
|
|
517
|
+
simpleStatus: "in-progress"
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
case "sending": {
|
|
521
|
+
return {
|
|
522
|
+
...startedSending,
|
|
523
|
+
status: "sending",
|
|
524
|
+
simpleStatus: "in-progress"
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
case "server-error": {
|
|
528
|
+
return {
|
|
529
|
+
...startedSending,
|
|
530
|
+
status: "server-error",
|
|
531
|
+
simpleStatus: "error",
|
|
532
|
+
errorAt: new Date(crud.error_at_millis),
|
|
533
|
+
serverError: crud.server_error
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
case "skipped": {
|
|
537
|
+
return {
|
|
538
|
+
...base,
|
|
539
|
+
status: "skipped",
|
|
540
|
+
simpleStatus: "ok",
|
|
541
|
+
skippedAt: new Date(crud.skipped_at_millis),
|
|
542
|
+
skippedReason: crud.skipped_reason,
|
|
543
|
+
skippedDetails: crud.skipped_details ?? {},
|
|
544
|
+
hasRendered: crud.has_rendered,
|
|
545
|
+
// Optional fields
|
|
546
|
+
startedRenderingAt: crud.started_rendering_at_millis ? new Date(crud.started_rendering_at_millis) : void 0,
|
|
547
|
+
renderedAt: crud.rendered_at_millis ? new Date(crud.rendered_at_millis) : void 0,
|
|
548
|
+
subject: crud.subject,
|
|
549
|
+
html: crud.html,
|
|
550
|
+
text: crud.text,
|
|
551
|
+
isTransactional: crud.is_transactional,
|
|
552
|
+
isHighPriority: crud.is_high_priority,
|
|
553
|
+
notificationCategoryId: crud.notification_category_id,
|
|
554
|
+
startedSendingAt: crud.started_sending_at_millis ? new Date(crud.started_sending_at_millis) : void 0
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
case "bounced": {
|
|
558
|
+
return {
|
|
559
|
+
...startedSending,
|
|
560
|
+
status: "bounced",
|
|
561
|
+
simpleStatus: "error",
|
|
562
|
+
bouncedAt: new Date(crud.bounced_at_millis)
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
case "delivery-delayed": {
|
|
566
|
+
return {
|
|
567
|
+
...startedSending,
|
|
568
|
+
status: "delivery-delayed",
|
|
569
|
+
simpleStatus: "ok",
|
|
570
|
+
deliveryDelayedAt: new Date(crud.delivery_delayed_at_millis)
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
case "sent": {
|
|
574
|
+
return {
|
|
575
|
+
...finishedDelivering,
|
|
576
|
+
status: "sent",
|
|
577
|
+
simpleStatus: "ok",
|
|
578
|
+
canHaveDeliveryInfo: crud.can_have_delivery_info
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
case "opened": {
|
|
582
|
+
return {
|
|
583
|
+
...finishedDelivering,
|
|
584
|
+
status: "opened",
|
|
585
|
+
simpleStatus: "ok",
|
|
586
|
+
openedAt: new Date(crud.opened_at_millis),
|
|
587
|
+
canHaveDeliveryInfo: true
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
case "clicked": {
|
|
591
|
+
return {
|
|
592
|
+
...finishedDelivering,
|
|
593
|
+
status: "clicked",
|
|
594
|
+
simpleStatus: "ok",
|
|
595
|
+
clickedAt: new Date(crud.clicked_at_millis),
|
|
596
|
+
canHaveDeliveryInfo: true
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
case "marked-as-spam": {
|
|
600
|
+
return {
|
|
601
|
+
...finishedDelivering,
|
|
602
|
+
status: "marked-as-spam",
|
|
603
|
+
simpleStatus: "ok",
|
|
604
|
+
markedAsSpamAt: new Date(crud.marked_as_spam_at_millis),
|
|
605
|
+
canHaveDeliveryInfo: true
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
default: {
|
|
609
|
+
throw new StackAssertionError(`Unknown email outbox status: ${crud.status}`, { status: crud.status });
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
})();
|
|
613
|
+
return result;
|
|
614
|
+
}
|
|
615
|
+
async listOutboxEmails(options) {
|
|
616
|
+
const response = await this._interface.listOutboxEmails({
|
|
617
|
+
status: options?.status,
|
|
618
|
+
simple_status: options?.simpleStatus,
|
|
619
|
+
limit: options?.limit,
|
|
620
|
+
cursor: options?.cursor
|
|
621
|
+
});
|
|
622
|
+
return {
|
|
623
|
+
items: response.items.map((item) => this._emailOutboxCrudToAdmin(item)),
|
|
624
|
+
nextCursor: response.pagination?.next_cursor ?? null
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
async getOutboxEmail(id) {
|
|
628
|
+
const response = await this._interface.getOutboxEmail(id);
|
|
629
|
+
return this._emailOutboxCrudToAdmin(response);
|
|
630
|
+
}
|
|
631
|
+
async updateOutboxEmail(id, options) {
|
|
632
|
+
const response = await this._interface.updateOutboxEmail(id, {
|
|
633
|
+
is_paused: options.isPaused,
|
|
634
|
+
scheduled_at_millis: options.scheduledAtMillis,
|
|
635
|
+
cancel: options.cancel
|
|
636
|
+
});
|
|
637
|
+
return this._emailOutboxCrudToAdmin(response);
|
|
638
|
+
}
|
|
639
|
+
async pauseOutboxEmail(id) {
|
|
640
|
+
return await this.updateOutboxEmail(id, { isPaused: true });
|
|
641
|
+
}
|
|
642
|
+
async unpauseOutboxEmail(id) {
|
|
643
|
+
return await this.updateOutboxEmail(id, { isPaused: false });
|
|
644
|
+
}
|
|
645
|
+
async cancelOutboxEmail(id) {
|
|
646
|
+
return await this.updateOutboxEmail(id, { cancel: true });
|
|
647
|
+
}
|
|
428
648
|
async getStripeAccountInfo() {
|
|
429
649
|
return await this._interface.getStripeAccountInfo();
|
|
430
650
|
}
|
|
651
|
+
async previewAffectedUsersByOnboardingChange(onboarding, limit) {
|
|
652
|
+
const result = await this._interface.previewAffectedUsersByOnboardingChange(
|
|
653
|
+
{ require_email_verification: onboarding.requireEmailVerification },
|
|
654
|
+
limit
|
|
655
|
+
);
|
|
656
|
+
return {
|
|
657
|
+
affectedUsers: result.affected_users.map((u) => ({
|
|
658
|
+
id: u.id,
|
|
659
|
+
displayName: u.display_name,
|
|
660
|
+
primaryEmail: u.primary_email,
|
|
661
|
+
restrictedReason: u.restricted_reason
|
|
662
|
+
})),
|
|
663
|
+
totalAffectedCount: result.total_affected_count
|
|
664
|
+
};
|
|
665
|
+
}
|
|
431
666
|
};
|
|
432
667
|
export {
|
|
433
668
|
_StackAdminAppImplIncomplete
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/lib/stack-app/apps/implementations/admin-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { StackAdminInterface } from \"@stackframe/stack-shared\";\nimport { getProductionModeErrors } from \"@stackframe/stack-shared/dist/helpers/production-mode\";\nimport { InternalApiKeyCreateCrudResponse } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport { EmailTemplateCrud } from \"@stackframe/stack-shared/dist/interface/crud/email-templates\";\nimport { InternalApiKeysCrud } from \"@stackframe/stack-shared/dist/interface/crud/internal-api-keys\";\nimport { ProjectsCrud } from \"@stackframe/stack-shared/dist/interface/crud/projects\";\nimport type { Transaction, TransactionType } from \"@stackframe/stack-shared/dist/interface/crud/transactions\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { pick } from \"@stackframe/stack-shared/dist/utils/objects\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AdminSentEmail } from \"../..\";\nimport { EmailConfig, stackAppInternalsSymbol } from \"../../common\";\nimport { AdminEmailTemplate } from \"../../email-templates\";\nimport { InternalApiKey, InternalApiKeyBase, InternalApiKeyBaseCrudRead, InternalApiKeyCreateOptions, InternalApiKeyFirstView, internalApiKeyCreateOptionsToCrud } from \"../../internal-api-keys\";\nimport { AdminProjectPermission, AdminProjectPermissionDefinition, AdminProjectPermissionDefinitionCreateOptions, AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, adminProjectPermissionDefinitionCreateOptionsToCrud, adminProjectPermissionDefinitionUpdateOptionsToCrud, adminTeamPermissionDefinitionCreateOptionsToCrud, adminTeamPermissionDefinitionUpdateOptionsToCrud } from \"../../permissions\";\nimport { AdminOwnedProject, AdminProject, AdminProjectUpdateOptions, adminProjectUpdateOptionsToCrud } from \"../../projects\";\nimport { StackAdminApp, StackAdminAppConstructorOptions } from \"../interfaces/admin-app\";\nimport { clientVersion, createCache, getBaseUrl, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey, getDefaultSuperSecretAdminKey, resolveConstructorOptions } from \"./common\";\nimport { _StackServerAppImplIncomplete } from \"./server-app-impl\";\n\nimport { CompleteConfig, EnvironmentConfigOverrideOverride } from \"@stackframe/stack-shared/dist/config/schema\";\nimport { ChatContent } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport { ConfigCrud } from \"@stackframe/stack-shared/dist/interface/crud/config\";\n\nexport class _StackAdminAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackServerAppImplIncomplete<HasTokenStore, ProjectId> implements StackAdminApp<HasTokenStore, ProjectId> {\n declare protected _interface: StackAdminInterface;\n\n private readonly _adminProjectCache = createCache(async () => {\n return await this._interface.getProject();\n });\n private readonly _internalApiKeysCache = createCache(async () => {\n const res = await this._interface.listInternalApiKeys();\n return res;\n });\n private readonly _adminEmailThemeCache = createCache(async ([id]: [string]) => {\n return await this._interface.getEmailTheme(id);\n });\n private readonly _adminEmailThemesCache = createCache(async () => {\n return await this._interface.listEmailThemes();\n });\n private readonly _adminEmailTemplatesCache = createCache(async () => {\n return await this._interface.listInternalEmailTemplates();\n });\n private readonly _adminEmailDraftsCache = createCache(async () => {\n return await this._interface.listInternalEmailDrafts();\n });\n private readonly _adminTeamPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listTeamPermissionDefinitions();\n });\n private readonly _adminProjectPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listProjectPermissionDefinitions();\n });\n private readonly _svixTokenCache = createCache(async () => {\n return await this._interface.getSvixToken();\n });\n private readonly _metricsCache = createCache(async ([includeAnonymous]: [boolean]) => {\n return await this._interface.getMetrics(includeAnonymous);\n });\n private readonly _emailPreviewCache = createCache(async ([themeId, themeTsxSource, templateId, templateTsxSource]: [string | null | false | undefined, string | undefined, string | undefined, string | undefined]) => {\n return await this._interface.renderEmailPreview({ themeId, themeTsxSource, templateId, templateTsxSource });\n });\n private readonly _configOverridesCache = createCache(async () => {\n return await this._interface.getConfig();\n });\n private readonly _stripeAccountInfoCache = createCache(async () => {\n try {\n return await this._interface.getStripeAccountInfo();\n } catch (error: any) {\n if (error?.status === 404) {\n return null;\n }\n throw error;\n }\n });\n private readonly _transactionsCache = createCache(async ([cursor, limit, type, customerType]: [string | undefined, number | undefined, TransactionType | undefined, 'user' | 'team' | 'custom' | undefined]) => {\n return await this._interface.listTransactions({ cursor, limit, type, customerType });\n });\n\n constructor(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>, extraOptions?: { uniqueIdentifier?: string, checkString?: string, interface?: StackAdminInterface }) {\n const resolvedOptions = resolveConstructorOptions(options);\n\n super(resolvedOptions, {\n ...extraOptions,\n interface: extraOptions?.interface ?? new StackAdminInterface({\n getBaseUrl: () => getBaseUrl(resolvedOptions.baseUrl),\n projectId: resolvedOptions.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: resolvedOptions.extraRequestHeaders ?? getDefaultExtraRequestHeaders(),\n clientVersion,\n ...resolvedOptions.projectOwnerSession ? {\n projectOwnerSession: resolvedOptions.projectOwnerSession,\n } : {\n publishableClientKey: resolvedOptions.publishableClientKey ?? getDefaultPublishableClientKey(),\n secretServerKey: resolvedOptions.secretServerKey ?? getDefaultSecretServerKey(),\n superSecretAdminKey: resolvedOptions.superSecretAdminKey ?? getDefaultSuperSecretAdminKey(),\n },\n }),\n });\n }\n\n _adminConfigFromCrud(data: ConfigCrud['Admin']['Read']): CompleteConfig {\n return JSON.parse(data.config_string);\n }\n\n _adminOwnedProjectFromCrud(data: ProjectsCrud['Admin']['Read'], onRefresh: () => Promise<void>): AdminOwnedProject {\n if (this._tokenStoreInit !== null) {\n throw new StackAssertionError(\"Owned apps must always have tokenStore === null — did you not create this project with app._createOwnedApp()?\");\n }\n return {\n ...this._adminProjectFromCrud(data, onRefresh),\n app: this as StackAdminApp<false>,\n };\n }\n\n _adminProjectFromCrud(data: ProjectsCrud['Admin']['Read'], onRefresh: () => Promise<void>): AdminProject {\n if (data.id !== this.projectId) {\n throw new StackAssertionError(`The project ID of the provided project JSON (${data.id}) does not match the project ID of the app (${this.projectId})!`);\n }\n\n const app = this;\n return {\n id: data.id,\n displayName: data.display_name,\n description: data.description,\n createdAt: new Date(data.created_at_millis),\n isProductionMode: data.is_production_mode,\n ownerTeamId: data.owner_team_id,\n logoUrl: data.logo_url,\n logoFullUrl: data.logo_full_url,\n logoDarkModeUrl: data.logo_dark_mode_url,\n logoFullDarkModeUrl: data.logo_full_dark_mode_url,\n config: {\n signUpEnabled: data.config.sign_up_enabled,\n credentialEnabled: data.config.credential_enabled,\n magicLinkEnabled: data.config.magic_link_enabled,\n passkeyEnabled: data.config.passkey_enabled,\n clientTeamCreationEnabled: data.config.client_team_creation_enabled,\n clientUserDeletionEnabled: data.config.client_user_deletion_enabled,\n allowLocalhost: data.config.allow_localhost,\n oauthAccountMergeStrategy: data.config.oauth_account_merge_strategy,\n allowUserApiKeys: data.config.allow_user_api_keys,\n allowTeamApiKeys: data.config.allow_team_api_keys,\n oauthProviders: data.config.oauth_providers.map((p) => ((p.type === 'shared' ? {\n id: p.id,\n type: 'shared',\n } as const : {\n id: p.id,\n type: 'standard',\n clientId: p.client_id ?? throwErr(\"Client ID is missing\"),\n clientSecret: p.client_secret ?? throwErr(\"Client secret is missing\"),\n facebookConfigId: p.facebook_config_id,\n microsoftTenantId: p.microsoft_tenant_id,\n } as const))),\n emailConfig: data.config.email_config.type === 'shared' ? {\n type: 'shared'\n } : {\n type: 'standard',\n host: data.config.email_config.host ?? throwErr(\"Email host is missing\"),\n port: data.config.email_config.port ?? throwErr(\"Email port is missing\"),\n username: data.config.email_config.username ?? throwErr(\"Email username is missing\"),\n password: data.config.email_config.password ?? throwErr(\"Email password is missing\"),\n senderName: data.config.email_config.sender_name ?? throwErr(\"Email sender name is missing\"),\n senderEmail: data.config.email_config.sender_email ?? throwErr(\"Email sender email is missing\"),\n },\n emailTheme: data.config.email_theme,\n domains: data.config.domains.map((d) => ({\n domain: d.domain,\n handlerPath: d.handler_path,\n })),\n createTeamOnSignUp: data.config.create_team_on_sign_up,\n teamCreatorDefaultPermissions: data.config.team_creator_default_permissions,\n teamMemberDefaultPermissions: data.config.team_member_default_permissions,\n userDefaultPermissions: data.config.user_default_permissions,\n },\n async getConfig() {\n return app._adminConfigFromCrud(await app._interface.getConfig());\n },\n async updateConfig(configOverride: EnvironmentConfigOverrideOverride) {\n await app._interface.updateConfig({ configOverride });\n await app._configOverridesCache.refresh([]);\n },\n async update(update: AdminProjectUpdateOptions) {\n const updateOptions = adminProjectUpdateOptionsToCrud(update);\n await app._interface.updateProject(updateOptions);\n await onRefresh();\n },\n async delete() {\n await app._interface.deleteProject();\n },\n async getProductionModeErrors() {\n return getProductionModeErrors(data);\n },\n };\n }\n\n _adminEmailTemplateFromCrud(data: EmailTemplateCrud['Admin']['Read']): AdminEmailTemplate {\n return {\n type: data.type,\n subject: data.subject,\n content: data.content,\n isDefault: data.is_default,\n };\n }\n\n override async getProject(): Promise<AdminProject> {\n return this._adminProjectFromCrud(\n Result.orThrow(await this._adminProjectCache.getOrWait([], \"write-only\")),\n () => this._refreshProject()\n );\n }\n\n\n protected _createInternalApiKeyBaseFromCrud(data: InternalApiKeyBaseCrudRead): InternalApiKeyBase {\n const app = this;\n return {\n id: data.id,\n description: data.description,\n expiresAt: new Date(data.expires_at_millis),\n manuallyRevokedAt: data.manually_revoked_at_millis ? new Date(data.manually_revoked_at_millis) : null,\n createdAt: new Date(data.created_at_millis),\n isValid() {\n return this.whyInvalid() === null;\n },\n whyInvalid() {\n if (this.expiresAt.getTime() < Date.now()) return \"expired\";\n if (this.manuallyRevokedAt) return \"manually-revoked\";\n return null;\n },\n async revoke() {\n const res = await app._interface.revokeInternalApiKeyById(data.id);\n await app._refreshInternalApiKeys();\n return res;\n }\n };\n }\n\n protected _createInternalApiKeyFromCrud(data: InternalApiKeysCrud[\"Admin\"][\"Read\"]): InternalApiKey {\n return {\n ...this._createInternalApiKeyBaseFromCrud(data),\n publishableClientKey: data.publishable_client_key ? { lastFour: data.publishable_client_key.last_four } : null,\n secretServerKey: data.secret_server_key ? { lastFour: data.secret_server_key.last_four } : null,\n superSecretAdminKey: data.super_secret_admin_key ? { lastFour: data.super_secret_admin_key.last_four } : null,\n };\n }\n\n protected _createInternalApiKeyFirstViewFromCrud(data: InternalApiKeyCreateCrudResponse): InternalApiKeyFirstView {\n return {\n ...this._createInternalApiKeyBaseFromCrud(data),\n publishableClientKey: data.publishable_client_key,\n secretServerKey: data.secret_server_key,\n superSecretAdminKey: data.super_secret_admin_key,\n };\n }\n\n async listInternalApiKeys(): Promise<InternalApiKey[]> {\n const crud = Result.orThrow(await this._internalApiKeysCache.getOrWait([], \"write-only\"));\n return crud.map((j) => this._createInternalApiKeyFromCrud(j));\n }\n\n\n async createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView> {\n const crud = await this._interface.createInternalApiKey(internalApiKeyCreateOptionsToCrud(options));\n await this._refreshInternalApiKeys();\n return this._createInternalApiKeyFirstViewFromCrud(crud);\n }\n\n\n async listEmailThemes(): Promise<{ id: string, displayName: string }[]> {\n const crud = Result.orThrow(await this._adminEmailThemesCache.getOrWait([], \"write-only\"));\n return crud.map((theme) => ({\n id: theme.id,\n displayName: theme.display_name,\n }));\n }\n\n async listEmailTemplates(): Promise<{ id: string, displayName: string, themeId?: string, tsxSource: string }[]> {\n const crud = Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], \"write-only\"));\n return crud.map((template) => ({\n id: template.id,\n displayName: template.display_name,\n themeId: template.theme_id,\n tsxSource: template.tsx_source,\n }));\n }\n\n async listEmailDrafts(): Promise<{ id: string, displayName: string, themeId: string | undefined | false, tsxSource: string, sentAt: Date | null }[]> {\n const crud = Result.orThrow(await this._adminEmailDraftsCache.getOrWait([], \"write-only\"));\n return crud.map((draft) => ({\n id: draft.id,\n displayName: draft.display_name,\n themeId: draft.theme_id,\n tsxSource: draft.tsx_source,\n sentAt: draft.sent_at_millis ? new Date(draft.sent_at_millis) : null,\n }));\n }\n\n\n async createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission> {\n const crud = await this._interface.createTeamPermissionDefinition(adminTeamPermissionDefinitionCreateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n return this._serverTeamPermissionDefinitionFromCrud(crud);\n }\n\n async updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions) {\n await this._interface.updateTeamPermissionDefinition(permissionId, adminTeamPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deleteTeamPermissionDefinition(permissionId);\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async listTeamPermissionDefinitions(): Promise<AdminTeamPermissionDefinition[]> {\n const crud = Result.orThrow(await this._adminTeamPermissionDefinitionsCache.getOrWait([], \"write-only\"));\n return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));\n }\n\n\n async createProjectPermissionDefinition(data: AdminProjectPermissionDefinitionCreateOptions): Promise<AdminProjectPermission> {\n const crud = await this._interface.createProjectPermissionDefinition(adminProjectPermissionDefinitionCreateOptionsToCrud(data));\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n return this._serverProjectPermissionDefinitionFromCrud(crud);\n }\n\n async updateProjectPermissionDefinition(permissionId: string, data: AdminProjectPermissionDefinitionUpdateOptions) {\n await this._interface.updateProjectPermissionDefinition(permissionId, adminProjectPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteProjectPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deleteProjectPermissionDefinition(permissionId);\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n }\n\n async listProjectPermissionDefinitions(): Promise<AdminProjectPermissionDefinition[]> {\n const crud = Result.orThrow(await this._adminProjectPermissionDefinitionsCache.getOrWait([], \"write-only\"));\n return crud.map((p) => this._serverProjectPermissionDefinitionFromCrud(p));\n }\n\n\n protected override async _refreshProject() {\n await Promise.all([\n super._refreshProject(),\n this._adminProjectCache.refresh([]),\n ]);\n }\n\n protected async _refreshInternalApiKeys() {\n await this._internalApiKeysCache.refresh([]);\n }\n\n protected override async _refreshUsers() {\n await Promise.all([\n super._refreshUsers(),\n this._metricsCache.refresh([false]),\n this._metricsCache.refresh([true]),\n ]);\n }\n\n get [stackAppInternalsSymbol]() {\n return {\n ...super[stackAppInternalsSymbol],\n };\n }\n\n async sendTestEmail(options: {\n recipientEmail: string,\n emailConfig: EmailConfig,\n }): Promise<Result<undefined, { errorMessage: string }>> {\n const response = await this._interface.sendTestEmail({\n recipient_email: options.recipientEmail,\n email_config: {\n ...(pick(options.emailConfig, ['host', 'port', 'username', 'password'])),\n sender_email: options.emailConfig.senderEmail,\n sender_name: options.emailConfig.senderName,\n },\n });\n\n if (response.success) {\n return Result.ok(undefined);\n } else {\n return Result.error({ errorMessage: response.error_message ?? throwErr(\"Email test error not specified\") });\n }\n }\n\n async sendTestWebhook(options: { endpointId: string }): Promise<Result<undefined, { errorMessage: string }>> {\n const response = await this._interface.sendTestWebhook({\n endpoint_id: options.endpointId,\n });\n\n if (response.success) {\n return Result.ok(undefined);\n } else {\n return Result.error({ errorMessage: response.error_message ?? throwErr(\"Webhook test error not specified\") });\n }\n }\n\n async listSentEmails(): Promise<AdminSentEmail[]> {\n const response = await this._interface.listSentEmails();\n return response.items.map((email) => ({\n id: email.id,\n to: email.to ?? [],\n subject: email.subject,\n recipient: email.to?.[0] ?? \"\",\n sentAt: new Date(email.sent_at_millis),\n error: email.error,\n }));\n }\n\n async sendSignInInvitationEmail(email: string, callbackUrl: string): Promise<void> {\n await this._interface.sendSignInInvitationEmail(email, callbackUrl);\n }\n\n async createEmailTemplate(displayName: string): Promise<{ id: string }> {\n const result = await this._interface.createEmailTemplate(displayName);\n await this._adminEmailTemplatesCache.refresh([]);\n return result;\n }\n\n async createEmailDraft(options: { displayName: string, themeId?: string | false, tsxSource?: string }): Promise<{ id: string }> {\n const result = await this._interface.createEmailDraft({\n display_name: options.displayName,\n theme_id: options.themeId,\n tsx_source: options.tsxSource,\n });\n await this._adminEmailDraftsCache.refresh([]);\n return result;\n }\n\n async updateEmailDraft(id: string, data: { displayName?: string, themeId?: string | undefined | false, tsxSource?: string }): Promise<void> {\n await this._interface.updateEmailDraft(id, {\n display_name: data.displayName,\n theme_id: data.themeId,\n tsx_source: data.tsxSource,\n });\n await this._adminEmailDraftsCache.refresh([]);\n }\n\n async sendChatMessage(\n threadId: string,\n contextType: \"email-theme\" | \"email-template\" | \"email-draft\",\n messages: Array<{ role: string, content: any }>,\n abortSignal?: AbortSignal,\n ): Promise<{ content: ChatContent }> {\n return await this._interface.sendChatMessage(threadId, contextType, messages, abortSignal);\n }\n\n async saveChatMessage(threadId: string, message: any): Promise<void> {\n await this._interface.saveChatMessage(threadId, message);\n }\n\n async listChatMessages(threadId: string): Promise<{ messages: Array<any> }> {\n return await this._interface.listChatMessages(threadId);\n }\n\n async createEmailTheme(displayName: string): Promise<{ id: string }> {\n const result = await this._interface.createEmailTheme(displayName);\n await this._adminEmailThemesCache.refresh([]);\n return result;\n }\n\n async getEmailPreview(options: { themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }): Promise<string> {\n return (await this._interface.renderEmailPreview(options)).html;\n }\n async updateEmailTheme(id: string, tsxSource: string): Promise<void> {\n await this._interface.updateEmailTheme(id, tsxSource);\n }\n async updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ renderedHtml: string }> {\n const result = await this._interface.updateEmailTemplate(id, tsxSource, themeId);\n await this._adminEmailTemplatesCache.refresh([]);\n return { renderedHtml: result.rendered_html };\n }\n\n async setupPayments(): Promise<{ url: string }> {\n return await this._interface.setupPayments();\n }\n\n async createStripeWidgetAccountSession(): Promise<{ client_secret: string }> {\n return await this._interface.createStripeWidgetAccountSession();\n }\n\n async createItemQuantityChange(options: (\n { userId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { teamId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { customCustomerId: string, itemId: string, quantity: number, expiresAt?: string, description?: string }\n )): Promise<void> {\n await this._interface.updateItemQuantity(\n { itemId: options.itemId, ...(\"userId\" in options ? { userId: options.userId } : (\"teamId\" in options ? { teamId: options.teamId } : { customCustomerId: options.customCustomerId })) },\n {\n delta: options.quantity,\n expires_at: options.expiresAt,\n description: options.description,\n allow_negative: true,\n }\n );\n }\n\n async refundTransaction(options: { type: \"subscription\" | \"one-time-purchase\", id: string }): Promise<void> {\n await this._interface.refundTransaction({ type: options.type, id: options.id });\n await this._transactionsCache.invalidateWhere(() => true);\n }\n\n async listTransactions(params: { cursor?: string, limit?: number, type?: TransactionType, customerType?: 'user' | 'team' | 'custom' }): Promise<{ transactions: Transaction[], nextCursor: string | null }> {\n const crud = Result.orThrow(await this._transactionsCache.getOrWait([params.cursor, params.limit, params.type, params.customerType] as const, \"write-only\"));\n return crud;\n }\n\n\n async getStripeAccountInfo(): Promise<null | { account_id: string, charges_enabled: boolean, details_submitted: boolean, payouts_enabled: boolean }> {\n return await this._interface.getStripeAccountInfo();\n }\n\n}\n"],"mappings":";AAIA,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AAMxC,SAAS,qBAAqB,gBAAgB;AAC9C,SAAS,YAAY;AACrB,SAAS,cAAc;AAEvB,SAAsB,+BAA+B;AAErD,SAA+H,yCAAyC;AACxK,SAA6S,qDAAqD,qDAAqD,kDAAkD,wDAAwD;AACjgB,SAAqE,uCAAuC;AAE5G,SAAS,eAAe,aAAa,YAAY,+BAA+B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yB,SAIb;AAChB,UAAM,KAAK,WAAW;AAAA,MACpB,EAAE,QAAQ,QAAQ,QAAQ,GAAI,YAAY,UAAU,EAAE,QAAQ,QAAQ,OAAO,IAAK,YAAY,UAAU,EAAE,QAAQ,QAAQ,OAAO,IAAI,EAAE,kBAAkB,QAAQ,iBAAiB,EAAI;AAAA,MACtL;AAAA,QACE,OAAO,QAAQ;AAAA,QACf,YAAY,QAAQ;AAAA,QACpB,aAAa,QAAQ;AAAA,QACrB,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,kBAAkB,SAAoF;AAC1G,UAAM,KAAK,WAAW,kBAAkB,EAAE,MAAM,QAAQ,MAAM,IAAI,QAAQ,GAAG,CAAC;AAC9E,UAAM,KAAK,mBAAmB,gBAAgB,MAAM,IAAI;AAAA,EAC1D;AAAA,EAEA,MAAM,iBAAiB,QAAqL;AAC1M,UAAM,OAAO,OAAO,QAAQ,MAAM,KAAK,mBAAmB,UAAU,CAAC,OAAO,QAAQ,OAAO,OAAO,OAAO,MAAM,OAAO,YAAY,GAAY,YAAY,CAAC;AAC3J,WAAO;AAAA,EACT;AAAA,EAGA,MAAM,uBAA+I;AACnJ,WAAO,MAAM,KAAK,WAAW,qBAAqB;AAAA,EACpD;AAEF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/lib/stack-app/apps/implementations/admin-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { StackAdminInterface } from \"@stackframe/stack-shared\";\nimport { getProductionModeErrors } from \"@stackframe/stack-shared/dist/helpers/production-mode\";\nimport { InternalApiKeyCreateCrudResponse } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport { EmailTemplateCrud } from \"@stackframe/stack-shared/dist/interface/crud/email-templates\";\nimport { InternalApiKeysCrud } from \"@stackframe/stack-shared/dist/interface/crud/internal-api-keys\";\nimport { ProjectsCrud } from \"@stackframe/stack-shared/dist/interface/crud/projects\";\nimport type { Transaction, TransactionType } from \"@stackframe/stack-shared/dist/interface/crud/transactions\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { pick } from \"@stackframe/stack-shared/dist/utils/objects\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AdminEmailOutbox, AdminSentEmail } from \"../..\";\nimport { EmailConfig, stackAppInternalsSymbol } from \"../../common\";\nimport { AdminEmailTemplate } from \"../../email-templates\";\nimport { InternalApiKey, InternalApiKeyBase, InternalApiKeyBaseCrudRead, InternalApiKeyCreateOptions, InternalApiKeyFirstView, internalApiKeyCreateOptionsToCrud } from \"../../internal-api-keys\";\nimport { AdminProjectPermission, AdminProjectPermissionDefinition, AdminProjectPermissionDefinitionCreateOptions, AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, adminProjectPermissionDefinitionCreateOptionsToCrud, adminProjectPermissionDefinitionUpdateOptionsToCrud, adminTeamPermissionDefinitionCreateOptionsToCrud, adminTeamPermissionDefinitionUpdateOptionsToCrud } from \"../../permissions\";\nimport { AdminOwnedProject, AdminProject, AdminProjectUpdateOptions, adminProjectUpdateOptionsToCrud } from \"../../projects\";\nimport { StackAdminApp, StackAdminAppConstructorOptions } from \"../interfaces/admin-app\";\nimport { clientVersion, createCache, getBaseUrl, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey, getDefaultSuperSecretAdminKey, resolveConstructorOptions } from \"./common\";\nimport { _StackServerAppImplIncomplete } from \"./server-app-impl\";\n\nimport { CompleteConfig, EnvironmentConfigOverrideOverride } from \"@stackframe/stack-shared/dist/config/schema\";\nimport { ChatContent } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\n\nexport class _StackAdminAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackServerAppImplIncomplete<HasTokenStore, ProjectId> implements StackAdminApp<HasTokenStore, ProjectId> {\n declare protected _interface: StackAdminInterface;\n\n private readonly _adminProjectCache = createCache(async () => {\n return await this._interface.getProject();\n });\n private readonly _internalApiKeysCache = createCache(async () => {\n const res = await this._interface.listInternalApiKeys();\n return res;\n });\n private readonly _adminEmailThemeCache = createCache(async ([id]: [string]) => {\n return await this._interface.getEmailTheme(id);\n });\n private readonly _adminEmailThemesCache = createCache(async () => {\n return await this._interface.listEmailThemes();\n });\n private readonly _adminEmailTemplatesCache = createCache(async () => {\n return await this._interface.listInternalEmailTemplates();\n });\n private readonly _adminEmailDraftsCache = createCache(async () => {\n return await this._interface.listInternalEmailDrafts();\n });\n private readonly _adminTeamPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listTeamPermissionDefinitions();\n });\n private readonly _adminProjectPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listProjectPermissionDefinitions();\n });\n private readonly _svixTokenCache = createCache(async () => {\n return await this._interface.getSvixToken();\n });\n private readonly _metricsCache = createCache(async ([includeAnonymous]: [boolean]) => {\n return await this._interface.getMetrics(includeAnonymous);\n });\n private readonly _emailPreviewCache = createCache(async ([themeId, themeTsxSource, templateId, templateTsxSource]: [string | null | false | undefined, string | undefined, string | undefined, string | undefined]) => {\n return await this._interface.renderEmailPreview({ themeId, themeTsxSource, templateId, templateTsxSource });\n });\n private readonly _configOverridesCache = createCache(async () => {\n return await this._interface.getConfig();\n });\n private readonly _stripeAccountInfoCache = createCache(async () => {\n try {\n return await this._interface.getStripeAccountInfo();\n } catch (error: any) {\n if (error?.status === 404) {\n return null;\n }\n throw error;\n }\n });\n private readonly _transactionsCache = createCache(async ([cursor, limit, type, customerType]: [string | undefined, number | undefined, TransactionType | undefined, 'user' | 'team' | 'custom' | undefined]) => {\n return await this._interface.listTransactions({ cursor, limit, type, customerType });\n });\n\n constructor(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>, extraOptions?: { uniqueIdentifier?: string, checkString?: string, interface?: StackAdminInterface }) {\n const resolvedOptions = resolveConstructorOptions(options);\n\n super(resolvedOptions, {\n ...extraOptions,\n interface: extraOptions?.interface ?? new StackAdminInterface({\n getBaseUrl: () => getBaseUrl(resolvedOptions.baseUrl),\n projectId: resolvedOptions.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: resolvedOptions.extraRequestHeaders ?? getDefaultExtraRequestHeaders(),\n clientVersion,\n ...resolvedOptions.projectOwnerSession ? {\n projectOwnerSession: resolvedOptions.projectOwnerSession,\n } : {\n publishableClientKey: resolvedOptions.publishableClientKey ?? getDefaultPublishableClientKey(),\n secretServerKey: resolvedOptions.secretServerKey ?? getDefaultSecretServerKey(),\n superSecretAdminKey: resolvedOptions.superSecretAdminKey ?? getDefaultSuperSecretAdminKey(),\n },\n }),\n });\n }\n\n _adminConfigFromCrud(data: { config_string: string }): CompleteConfig {\n return JSON.parse(data.config_string);\n }\n\n _adminOwnedProjectFromCrud(data: ProjectsCrud['Admin']['Read'], onRefresh: () => Promise<void>): AdminOwnedProject {\n if (this._tokenStoreInit !== null) {\n throw new StackAssertionError(\"Owned apps must always have tokenStore === null — did you not create this project with app._createOwnedApp()?\");\n }\n return {\n ...this._adminProjectFromCrud(data, onRefresh),\n app: this as StackAdminApp<false>,\n };\n }\n\n _adminProjectFromCrud(data: ProjectsCrud['Admin']['Read'], onRefresh: () => Promise<void>): AdminProject {\n if (data.id !== this.projectId) {\n throw new StackAssertionError(`The project ID of the provided project JSON (${data.id}) does not match the project ID of the app (${this.projectId})!`);\n }\n\n const app = this;\n return {\n id: data.id,\n displayName: data.display_name,\n description: data.description,\n createdAt: new Date(data.created_at_millis),\n isProductionMode: data.is_production_mode,\n ownerTeamId: data.owner_team_id,\n logoUrl: data.logo_url,\n logoFullUrl: data.logo_full_url,\n logoDarkModeUrl: data.logo_dark_mode_url,\n logoFullDarkModeUrl: data.logo_full_dark_mode_url,\n config: {\n signUpEnabled: data.config.sign_up_enabled,\n credentialEnabled: data.config.credential_enabled,\n magicLinkEnabled: data.config.magic_link_enabled,\n passkeyEnabled: data.config.passkey_enabled,\n clientTeamCreationEnabled: data.config.client_team_creation_enabled,\n clientUserDeletionEnabled: data.config.client_user_deletion_enabled,\n allowLocalhost: data.config.allow_localhost,\n oauthAccountMergeStrategy: data.config.oauth_account_merge_strategy,\n allowUserApiKeys: data.config.allow_user_api_keys,\n allowTeamApiKeys: data.config.allow_team_api_keys,\n oauthProviders: data.config.oauth_providers.map((p) => ((p.type === 'shared' ? {\n id: p.id,\n type: 'shared',\n } as const : {\n id: p.id,\n type: 'standard',\n clientId: p.client_id ?? throwErr(\"Client ID is missing\"),\n clientSecret: p.client_secret ?? throwErr(\"Client secret is missing\"),\n facebookConfigId: p.facebook_config_id,\n microsoftTenantId: p.microsoft_tenant_id,\n } as const))),\n emailConfig: data.config.email_config.type === 'shared' ? {\n type: 'shared'\n } : {\n type: 'standard',\n host: data.config.email_config.host ?? throwErr(\"Email host is missing\"),\n port: data.config.email_config.port ?? throwErr(\"Email port is missing\"),\n username: data.config.email_config.username ?? throwErr(\"Email username is missing\"),\n password: data.config.email_config.password ?? throwErr(\"Email password is missing\"),\n senderName: data.config.email_config.sender_name ?? throwErr(\"Email sender name is missing\"),\n senderEmail: data.config.email_config.sender_email ?? throwErr(\"Email sender email is missing\"),\n },\n emailTheme: data.config.email_theme,\n domains: data.config.domains.map((d) => ({\n domain: d.domain,\n handlerPath: d.handler_path,\n })),\n createTeamOnSignUp: data.config.create_team_on_sign_up,\n teamCreatorDefaultPermissions: data.config.team_creator_default_permissions,\n teamMemberDefaultPermissions: data.config.team_member_default_permissions,\n userDefaultPermissions: data.config.user_default_permissions,\n },\n async getConfig() {\n return app._adminConfigFromCrud(await app._interface.getConfig());\n },\n async updateConfig(configOverride: EnvironmentConfigOverrideOverride) {\n await app._interface.updateConfig({ configOverride });\n await app._configOverridesCache.refresh([]);\n },\n async update(update: AdminProjectUpdateOptions) {\n const updateOptions = adminProjectUpdateOptionsToCrud(update);\n await app._interface.updateProject(updateOptions);\n await onRefresh();\n },\n async delete() {\n await app._interface.deleteProject();\n },\n async getProductionModeErrors() {\n return getProductionModeErrors(data);\n },\n };\n }\n\n _adminEmailTemplateFromCrud(data: EmailTemplateCrud['Admin']['Read']): AdminEmailTemplate {\n return {\n type: data.type,\n subject: data.subject,\n content: data.content,\n isDefault: data.is_default,\n };\n }\n\n override async getProject(): Promise<AdminProject> {\n return this._adminProjectFromCrud(\n Result.orThrow(await this._adminProjectCache.getOrWait([], \"write-only\")),\n () => this._refreshProject()\n );\n }\n\n\n protected _createInternalApiKeyBaseFromCrud(data: InternalApiKeyBaseCrudRead): InternalApiKeyBase {\n const app = this;\n return {\n id: data.id,\n description: data.description,\n expiresAt: new Date(data.expires_at_millis),\n manuallyRevokedAt: data.manually_revoked_at_millis ? new Date(data.manually_revoked_at_millis) : null,\n createdAt: new Date(data.created_at_millis),\n isValid() {\n return this.whyInvalid() === null;\n },\n whyInvalid() {\n if (this.expiresAt.getTime() < Date.now()) return \"expired\";\n if (this.manuallyRevokedAt) return \"manually-revoked\";\n return null;\n },\n async revoke() {\n const res = await app._interface.revokeInternalApiKeyById(data.id);\n await app._refreshInternalApiKeys();\n return res;\n }\n };\n }\n\n protected _createInternalApiKeyFromCrud(data: InternalApiKeysCrud[\"Admin\"][\"Read\"]): InternalApiKey {\n return {\n ...this._createInternalApiKeyBaseFromCrud(data),\n publishableClientKey: data.publishable_client_key ? { lastFour: data.publishable_client_key.last_four } : null,\n secretServerKey: data.secret_server_key ? { lastFour: data.secret_server_key.last_four } : null,\n superSecretAdminKey: data.super_secret_admin_key ? { lastFour: data.super_secret_admin_key.last_four } : null,\n };\n }\n\n protected _createInternalApiKeyFirstViewFromCrud(data: InternalApiKeyCreateCrudResponse): InternalApiKeyFirstView {\n return {\n ...this._createInternalApiKeyBaseFromCrud(data),\n publishableClientKey: data.publishable_client_key,\n secretServerKey: data.secret_server_key,\n superSecretAdminKey: data.super_secret_admin_key,\n };\n }\n\n async listInternalApiKeys(): Promise<InternalApiKey[]> {\n const crud = Result.orThrow(await this._internalApiKeysCache.getOrWait([], \"write-only\"));\n return crud.map((j) => this._createInternalApiKeyFromCrud(j));\n }\n\n\n async createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView> {\n const crud = await this._interface.createInternalApiKey(internalApiKeyCreateOptionsToCrud(options));\n await this._refreshInternalApiKeys();\n return this._createInternalApiKeyFirstViewFromCrud(crud);\n }\n\n\n async listEmailThemes(): Promise<{ id: string, displayName: string }[]> {\n const crud = Result.orThrow(await this._adminEmailThemesCache.getOrWait([], \"write-only\"));\n return crud.map((theme) => ({\n id: theme.id,\n displayName: theme.display_name,\n }));\n }\n\n async listEmailTemplates(): Promise<{ id: string, displayName: string, themeId?: string, tsxSource: string }[]> {\n const crud = Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], \"write-only\"));\n return crud.map((template) => ({\n id: template.id,\n displayName: template.display_name,\n themeId: template.theme_id,\n tsxSource: template.tsx_source,\n }));\n }\n\n async listEmailDrafts(): Promise<{ id: string, displayName: string, themeId: string | undefined | false, tsxSource: string, sentAt: Date | null }[]> {\n const crud = Result.orThrow(await this._adminEmailDraftsCache.getOrWait([], \"write-only\"));\n return crud.map((draft) => ({\n id: draft.id,\n displayName: draft.display_name,\n themeId: draft.theme_id,\n tsxSource: draft.tsx_source,\n sentAt: draft.sent_at_millis ? new Date(draft.sent_at_millis) : null,\n }));\n }\n\n\n async createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission> {\n const crud = await this._interface.createTeamPermissionDefinition(adminTeamPermissionDefinitionCreateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n return this._serverTeamPermissionDefinitionFromCrud(crud);\n }\n\n async updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions) {\n await this._interface.updateTeamPermissionDefinition(permissionId, adminTeamPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deleteTeamPermissionDefinition(permissionId);\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async listTeamPermissionDefinitions(): Promise<AdminTeamPermissionDefinition[]> {\n const crud = Result.orThrow(await this._adminTeamPermissionDefinitionsCache.getOrWait([], \"write-only\"));\n return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));\n }\n\n\n async createProjectPermissionDefinition(data: AdminProjectPermissionDefinitionCreateOptions): Promise<AdminProjectPermission> {\n const crud = await this._interface.createProjectPermissionDefinition(adminProjectPermissionDefinitionCreateOptionsToCrud(data));\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n return this._serverProjectPermissionDefinitionFromCrud(crud);\n }\n\n async updateProjectPermissionDefinition(permissionId: string, data: AdminProjectPermissionDefinitionUpdateOptions) {\n await this._interface.updateProjectPermissionDefinition(permissionId, adminProjectPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteProjectPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deleteProjectPermissionDefinition(permissionId);\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n }\n\n async listProjectPermissionDefinitions(): Promise<AdminProjectPermissionDefinition[]> {\n const crud = Result.orThrow(await this._adminProjectPermissionDefinitionsCache.getOrWait([], \"write-only\"));\n return crud.map((p) => this._serverProjectPermissionDefinitionFromCrud(p));\n }\n\n\n protected override async _refreshProject() {\n await Promise.all([\n super._refreshProject(),\n this._adminProjectCache.refresh([]),\n ]);\n }\n\n protected async _refreshInternalApiKeys() {\n await this._internalApiKeysCache.refresh([]);\n }\n\n protected override async _refreshUsers() {\n await Promise.all([\n super._refreshUsers(),\n this._metricsCache.refresh([false]),\n this._metricsCache.refresh([true]),\n ]);\n }\n\n get [stackAppInternalsSymbol]() {\n return {\n ...super[stackAppInternalsSymbol],\n };\n }\n\n async sendTestEmail(options: {\n recipientEmail: string,\n emailConfig: EmailConfig,\n }): Promise<Result<undefined, { errorMessage: string }>> {\n const response = await this._interface.sendTestEmail({\n recipient_email: options.recipientEmail,\n email_config: {\n ...(pick(options.emailConfig, ['host', 'port', 'username', 'password'])),\n sender_email: options.emailConfig.senderEmail,\n sender_name: options.emailConfig.senderName,\n },\n });\n\n if (response.success) {\n return Result.ok(undefined);\n } else {\n return Result.error({ errorMessage: response.error_message ?? throwErr(\"Email test error not specified\") });\n }\n }\n\n async sendTestWebhook(options: { endpointId: string }): Promise<Result<undefined, { errorMessage: string }>> {\n const response = await this._interface.sendTestWebhook({\n endpoint_id: options.endpointId,\n });\n\n if (response.success) {\n return Result.ok(undefined);\n } else {\n return Result.error({ errorMessage: response.error_message ?? throwErr(\"Webhook test error not specified\") });\n }\n }\n\n async listSentEmails(): Promise<AdminSentEmail[]> {\n const response = await this._interface.listSentEmails();\n return response.items.map((email) => ({\n id: email.id,\n to: email.to ?? [],\n subject: email.subject,\n recipient: email.to?.[0] ?? \"\",\n sentAt: new Date(email.sent_at_millis),\n error: email.error,\n }));\n }\n\n async sendSignInInvitationEmail(email: string, callbackUrl: string): Promise<void> {\n await this._interface.sendSignInInvitationEmail(email, callbackUrl);\n }\n\n async createEmailTemplate(displayName: string): Promise<{ id: string }> {\n const result = await this._interface.createEmailTemplate(displayName);\n await this._adminEmailTemplatesCache.refresh([]);\n return result;\n }\n\n async createEmailDraft(options: { displayName: string, themeId?: string | false, tsxSource?: string }): Promise<{ id: string }> {\n const result = await this._interface.createEmailDraft({\n display_name: options.displayName,\n theme_id: options.themeId,\n tsx_source: options.tsxSource,\n });\n await this._adminEmailDraftsCache.refresh([]);\n return result;\n }\n\n async updateEmailDraft(id: string, data: { displayName?: string, themeId?: string | undefined | false, tsxSource?: string }): Promise<void> {\n await this._interface.updateEmailDraft(id, {\n display_name: data.displayName,\n theme_id: data.themeId,\n tsx_source: data.tsxSource,\n });\n await this._adminEmailDraftsCache.refresh([]);\n }\n\n async sendChatMessage(\n threadId: string,\n contextType: \"email-theme\" | \"email-template\" | \"email-draft\",\n messages: Array<{ role: string, content: any }>,\n abortSignal?: AbortSignal,\n ): Promise<{ content: ChatContent }> {\n return await this._interface.sendChatMessage(threadId, contextType, messages, abortSignal);\n }\n\n async saveChatMessage(threadId: string, message: any): Promise<void> {\n await this._interface.saveChatMessage(threadId, message);\n }\n\n async listChatMessages(threadId: string): Promise<{ messages: Array<any> }> {\n return await this._interface.listChatMessages(threadId);\n }\n\n async createEmailTheme(displayName: string): Promise<{ id: string }> {\n const result = await this._interface.createEmailTheme(displayName);\n await this._adminEmailThemesCache.refresh([]);\n return result;\n }\n\n async getEmailPreview(options: { themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }): Promise<string> {\n return (await this._interface.renderEmailPreview(options)).html;\n }\n async updateEmailTheme(id: string, tsxSource: string): Promise<void> {\n await this._interface.updateEmailTheme(id, tsxSource);\n }\n async updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ renderedHtml: string }> {\n const result = await this._interface.updateEmailTemplate(id, tsxSource, themeId);\n await this._adminEmailTemplatesCache.refresh([]);\n return { renderedHtml: result.rendered_html };\n }\n\n async setupPayments(): Promise<{ url: string }> {\n return await this._interface.setupPayments();\n }\n\n async createStripeWidgetAccountSession(): Promise<{ client_secret: string }> {\n return await this._interface.createStripeWidgetAccountSession();\n }\n\n async createItemQuantityChange(options: (\n { userId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { teamId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { customCustomerId: string, itemId: string, quantity: number, expiresAt?: string, description?: string }\n )): Promise<void> {\n await this._interface.updateItemQuantity(\n { itemId: options.itemId, ...(\"userId\" in options ? { userId: options.userId } : (\"teamId\" in options ? { teamId: options.teamId } : { customCustomerId: options.customCustomerId })) },\n {\n delta: options.quantity,\n expires_at: options.expiresAt,\n description: options.description,\n allow_negative: true,\n }\n );\n }\n\n async refundTransaction(options: { type: \"subscription\" | \"one-time-purchase\", id: string }): Promise<void> {\n await this._interface.refundTransaction({ type: options.type, id: options.id });\n await this._transactionsCache.invalidateWhere(() => true);\n }\n\n async listTransactions(params: { cursor?: string, limit?: number, type?: TransactionType, customerType?: 'user' | 'team' | 'custom' }): Promise<{ transactions: Transaction[], nextCursor: string | null }> {\n const crud = Result.orThrow(await this._transactionsCache.getOrWait([params.cursor, params.limit, params.type, params.customerType] as const, \"write-only\"));\n return crud;\n }\n\n // Email Outbox methods\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Complex discriminated union conversion from API response\n private _emailOutboxCrudToAdmin(crud: any): AdminEmailOutbox {\n const recipient = crud.to;\n let to: AdminEmailOutbox[\"to\"];\n if (recipient.type === \"user-primary-email\") {\n to = { type: \"user-primary-email\", userId: recipient.user_id };\n } else if (recipient.type === \"user-custom-emails\") {\n to = { type: \"user-custom-emails\", userId: recipient.user_id, emails: recipient.emails };\n } else {\n to = { type: \"custom-emails\", emails: recipient.emails };\n }\n\n // Base fields present on all emails\n const base = {\n id: crud.id as string,\n createdAt: new Date(crud.created_at_millis),\n updatedAt: new Date(crud.updated_at_millis),\n to,\n scheduledAt: new Date(crud.scheduled_at_millis),\n isPaused: false as const,\n hasRendered: false as const,\n hasDelivered: false as const,\n };\n\n // Rendered fields (available after rendering completes successfully)\n const rendered = crud.has_rendered ? {\n ...base,\n startedRenderingAt: new Date(crud.started_rendering_at_millis),\n renderedAt: new Date(crud.rendered_at_millis),\n subject: crud.subject as string,\n html: crud.html as string | null,\n text: crud.text as string | null,\n isTransactional: crud.is_transactional as boolean,\n isHighPriority: crud.is_high_priority as boolean,\n notificationCategoryId: crud.notification_category_id as string | null,\n hasRendered: true as const,\n } : null;\n\n // Started sending fields\n const startedSending = rendered && crud.started_sending_at_millis ? {\n ...rendered,\n startedSendingAt: new Date(crud.started_sending_at_millis),\n } : null;\n\n // Finished delivering fields\n const finishedDelivering = startedSending && crud.has_delivered ? {\n ...startedSending,\n deliveredAt: new Date(crud.delivered_at_millis),\n hasDelivered: true as const,\n } : null;\n\n // Use type assertion at the end because TypeScript has trouble with\n // spread + override patterns on discriminated unions with const literal types\n const result = (() => {\n switch (crud.status) {\n case \"paused\": {\n return {\n ...base,\n status: \"paused\" as const,\n simpleStatus: \"in-progress\" as const,\n isPaused: true as const,\n };\n }\n case \"preparing\": {\n return {\n ...base,\n status: \"preparing\" as const,\n simpleStatus: \"in-progress\" as const,\n };\n }\n case \"rendering\": {\n return {\n ...base,\n status: \"rendering\" as const,\n simpleStatus: \"in-progress\" as const,\n startedRenderingAt: new Date(crud.started_rendering_at_millis),\n };\n }\n case \"render-error\": {\n return {\n ...base,\n status: \"render-error\" as const,\n simpleStatus: \"error\" as const,\n startedRenderingAt: new Date(crud.started_rendering_at_millis),\n renderedAt: new Date(crud.rendered_at_millis),\n renderError: crud.render_error,\n };\n }\n case \"scheduled\": {\n return {\n ...rendered!,\n status: \"scheduled\" as const,\n simpleStatus: \"in-progress\" as const,\n };\n }\n case \"queued\": {\n return {\n ...rendered!,\n status: \"queued\" as const,\n simpleStatus: \"in-progress\" as const,\n };\n }\n case \"sending\": {\n return {\n ...startedSending!,\n status: \"sending\" as const,\n simpleStatus: \"in-progress\" as const,\n };\n }\n case \"server-error\": {\n return {\n ...startedSending!,\n status: \"server-error\" as const,\n simpleStatus: \"error\" as const,\n errorAt: new Date(crud.error_at_millis),\n serverError: crud.server_error,\n };\n }\n case \"skipped\": {\n return {\n ...base,\n status: \"skipped\" as const,\n simpleStatus: \"ok\" as const,\n skippedAt: new Date(crud.skipped_at_millis),\n skippedReason: crud.skipped_reason,\n skippedDetails: crud.skipped_details ?? {},\n hasRendered: crud.has_rendered as boolean,\n // Optional fields\n startedRenderingAt: crud.started_rendering_at_millis ? new Date(crud.started_rendering_at_millis) : undefined,\n renderedAt: crud.rendered_at_millis ? new Date(crud.rendered_at_millis) : undefined,\n subject: crud.subject,\n html: crud.html,\n text: crud.text,\n isTransactional: crud.is_transactional,\n isHighPriority: crud.is_high_priority,\n notificationCategoryId: crud.notification_category_id,\n startedSendingAt: crud.started_sending_at_millis ? new Date(crud.started_sending_at_millis) : undefined,\n };\n }\n case \"bounced\": {\n return {\n ...startedSending!,\n status: \"bounced\" as const,\n simpleStatus: \"error\" as const,\n bouncedAt: new Date(crud.bounced_at_millis),\n };\n }\n case \"delivery-delayed\": {\n return {\n ...startedSending!,\n status: \"delivery-delayed\" as const,\n simpleStatus: \"ok\" as const,\n deliveryDelayedAt: new Date(crud.delivery_delayed_at_millis),\n };\n }\n case \"sent\": {\n return {\n ...finishedDelivering!,\n status: \"sent\" as const,\n simpleStatus: \"ok\" as const,\n canHaveDeliveryInfo: crud.can_have_delivery_info,\n };\n }\n case \"opened\": {\n return {\n ...finishedDelivering!,\n status: \"opened\" as const,\n simpleStatus: \"ok\" as const,\n openedAt: new Date(crud.opened_at_millis),\n canHaveDeliveryInfo: true as const,\n };\n }\n case \"clicked\": {\n return {\n ...finishedDelivering!,\n status: \"clicked\" as const,\n simpleStatus: \"ok\" as const,\n clickedAt: new Date(crud.clicked_at_millis),\n canHaveDeliveryInfo: true as const,\n };\n }\n case \"marked-as-spam\": {\n return {\n ...finishedDelivering!,\n status: \"marked-as-spam\" as const,\n simpleStatus: \"ok\" as const,\n markedAsSpamAt: new Date(crud.marked_as_spam_at_millis),\n canHaveDeliveryInfo: true as const,\n };\n }\n default: {\n throw new StackAssertionError(`Unknown email outbox status: ${crud.status}`, { status: crud.status });\n }\n }\n })();\n // The type system has difficulty with spread + override patterns on discriminated unions,\n // so we use a type assertion here. The switch statement above ensures we return the correct shape.\n return result as AdminEmailOutbox;\n }\n\n async listOutboxEmails(options?: { status?: string, simpleStatus?: string, limit?: number, cursor?: string }): Promise<{ items: AdminEmailOutbox[], nextCursor: string | null }> {\n const response = await this._interface.listOutboxEmails({\n status: options?.status,\n simple_status: options?.simpleStatus,\n limit: options?.limit,\n cursor: options?.cursor,\n });\n return {\n items: response.items.map((item) => this._emailOutboxCrudToAdmin(item)),\n nextCursor: response.pagination?.next_cursor ?? null,\n };\n }\n\n async getOutboxEmail(id: string): Promise<AdminEmailOutbox> {\n const response = await this._interface.getOutboxEmail(id);\n return this._emailOutboxCrudToAdmin(response);\n }\n\n async updateOutboxEmail(id: string, options: { isPaused?: boolean, scheduledAtMillis?: number, cancel?: boolean }): Promise<AdminEmailOutbox> {\n const response = await this._interface.updateOutboxEmail(id, {\n is_paused: options.isPaused,\n scheduled_at_millis: options.scheduledAtMillis,\n cancel: options.cancel,\n });\n return this._emailOutboxCrudToAdmin(response);\n }\n\n async pauseOutboxEmail(id: string): Promise<AdminEmailOutbox> {\n return await this.updateOutboxEmail(id, { isPaused: true });\n }\n\n async unpauseOutboxEmail(id: string): Promise<AdminEmailOutbox> {\n return await this.updateOutboxEmail(id, { isPaused: false });\n }\n\n async cancelOutboxEmail(id: string): Promise<AdminEmailOutbox> {\n return await this.updateOutboxEmail(id, { cancel: true });\n }\n\n\n async getStripeAccountInfo(): Promise<null | { account_id: string, charges_enabled: boolean, details_submitted: boolean, payouts_enabled: boolean }> {\n return await this._interface.getStripeAccountInfo();\n }\n\n\n async previewAffectedUsersByOnboardingChange(\n onboarding: { requireEmailVerification?: boolean },\n limit?: number,\n ): Promise<{\n affectedUsers: Array<{\n id: string,\n displayName: string | null,\n primaryEmail: string | null,\n restrictedReason: { type: \"anonymous\" | \"email_not_verified\" },\n }>,\n totalAffectedCount: number,\n }> {\n const result = await this._interface.previewAffectedUsersByOnboardingChange(\n { require_email_verification: onboarding.requireEmailVerification },\n limit,\n );\n return {\n affectedUsers: result.affected_users.map(u => ({\n id: u.id,\n displayName: u.display_name,\n primaryEmail: u.primary_email,\n restrictedReason: u.restricted_reason as { type: \"anonymous\" | \"email_not_verified\" },\n })),\n totalAffectedCount: result.total_affected_count,\n };\n }\n}\n"],"mappings":";AAIA,SAAS,2BAA2B;AACpC,SAAS,+BAA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