@stackframe/stack-shared 2.8.10 → 2.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/config/schema.d.cts +11 -6
- package/dist/config/schema.d.ts +11 -6
- package/dist/config/schema.js +4 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/esm/config/schema.js +5 -3
- package/dist/esm/config/schema.js.map +1 -1
- package/dist/esm/interface/crud/projects.js +2 -10
- package/dist/esm/interface/crud/projects.js.map +1 -1
- package/dist/esm/known-errors.js +15 -0
- package/dist/esm/known-errors.js.map +1 -1
- package/dist/esm/utils/objects.js +24 -0
- package/dist/esm/utils/objects.js.map +1 -1
- package/dist/esm/utils/strings.js +1 -0
- package/dist/esm/utils/strings.js.map +1 -1
- package/dist/interface/crud/project-api-keys.d.cts +2 -2
- package/dist/interface/crud/project-api-keys.d.ts +2 -2
- package/dist/interface/crud/projects.d.cts +7 -20
- package/dist/interface/crud/projects.d.ts +7 -20
- package/dist/interface/crud/projects.js +2 -10
- package/dist/interface/crud/projects.js.map +1 -1
- package/dist/known-errors.d.cts +3 -0
- package/dist/known-errors.d.ts +3 -0
- package/dist/known-errors.js +15 -0
- package/dist/known-errors.js.map +1 -1
- package/dist/utils/objects.d.cts +9 -5
- package/dist/utils/objects.d.ts +9 -5
- package/dist/utils/objects.js +28 -0
- package/dist/utils/objects.js.map +1 -1
- package/dist/utils/strings.js +1 -0
- package/dist/utils/strings.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/known-errors.tsx"],"sourcesContent":["import { StackAssertionError, StatusError, throwErr } from \"./utils/errors\";\nimport { identityArgs } from \"./utils/functions\";\nimport { Json } from \"./utils/json\";\nimport { deindent } from \"./utils/strings\";\n\nexport type KnownErrorJson = {\n code: string,\n message: string,\n details?: Json,\n};\n\nexport type AbstractKnownErrorConstructor<Args extends any[]> =\n & (abstract new (...args: Args) => KnownError)\n & {\n constructorArgsFromJson: (json: KnownErrorJson) => Args,\n };\n\nexport type KnownErrorConstructor<SuperInstance extends KnownError, Args extends any[]> = {\n new (...args: Args): SuperInstance & { constructorArgs: Args },\n errorCode: string,\n constructorArgsFromJson: (json: KnownErrorJson) => Args,\n};\n\nexport abstract class KnownError extends StatusError {\n public name = \"KnownError\";\n\n constructor(\n public readonly statusCode: number,\n public readonly humanReadableMessage: string,\n public readonly details?: Json,\n ) {\n super(\n statusCode,\n humanReadableMessage\n );\n }\n\n public override getBody(): Uint8Array {\n return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), undefined, 2));\n }\n\n public override getHeaders(): Record<string, string[]> {\n return {\n \"Content-Type\": [\"application/json; charset=utf-8\"],\n \"X-Stack-Known-Error\": [this.errorCode],\n };\n }\n\n public override toDescriptiveJson(): Json {\n return {\n code: this.errorCode,\n ...this.details ? { details: this.details } : {},\n error: this.humanReadableMessage,\n };\n }\n\n get errorCode(): string {\n return (this.constructor as any).errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);\n }\n\n public static constructorArgsFromJson(json: KnownErrorJson): ConstructorParameters<typeof KnownError> {\n return [\n 400,\n json.message,\n json,\n ];\n }\n\n public static fromJson(json: KnownErrorJson): KnownError {\n for (const [_, KnownErrorType] of Object.entries(KnownErrors)) {\n if (json.code === KnownErrorType.prototype.errorCode) {\n const constructorArgs = KnownErrorType.constructorArgsFromJson(json);\n return new KnownErrorType(\n // @ts-expect-error\n ...constructorArgs,\n );\n }\n }\n\n throw new Error(`Unknown KnownError code. You may need to update your version of Stack to see more detailed information. ${json.code}: ${json.message}`);\n }\n}\n\nconst knownErrorConstructorErrorCodeSentinel = Symbol(\"knownErrorConstructorErrorCodeSentinel\");\n/**\n * Exists solely so that known errors are nominative types (ie. two KnownErrors with the same interface are not the same type)\n */\ntype KnownErrorBrand<ErrorCode extends string> = {\n /**\n * Does not exist at runtime\n *\n * Must be an object because it may be true for multiple error codes (it's true for all parents)\n */\n [knownErrorConstructorErrorCodeSentinel]: {\n [K in ErrorCode]: true\n },\n};\n\nfunction createKnownErrorConstructor<ErrorCode extends string, Super extends AbstractKnownErrorConstructor<any>, Args extends any[]>(\n SuperClass: Super,\n errorCode: ErrorCode,\n create: ((...args: Args) => Readonly<ConstructorParameters<Super>>),\n constructorArgsFromJson: ((jsonDetails: any) => Args),\n): KnownErrorConstructor<InstanceType<Super> & KnownErrorBrand<ErrorCode>, Args> & { errorCode: ErrorCode };\nfunction createKnownErrorConstructor<ErrorCode extends string, Super extends AbstractKnownErrorConstructor<any>>(\n SuperClass: Super,\n errorCode: ErrorCode,\n create: \"inherit\",\n constructorArgsFromJson: \"inherit\",\n): KnownErrorConstructor<InstanceType<Super> & KnownErrorBrand<ErrorCode>, ConstructorParameters<Super>> & { errorCode: ErrorCode };\nfunction createKnownErrorConstructor<ErrorCode extends string, Super extends AbstractKnownErrorConstructor<any>, Args extends any[]>(\n SuperClass: Super,\n errorCode: ErrorCode,\n create: \"inherit\" | ((...args: Args) => Readonly<ConstructorParameters<Super>>),\n constructorArgsFromJson: \"inherit\" | ((jsonDetails: any) => Args),\n): KnownErrorConstructor<InstanceType<Super> & KnownErrorBrand<ErrorCode>, Args> & { errorCode: ErrorCode } {\n const createFn = create === \"inherit\" ? identityArgs<Args> as never : create;\n const constructorArgsFromJsonFn = constructorArgsFromJson === \"inherit\" ? SuperClass.constructorArgsFromJson as never : constructorArgsFromJson;\n\n // @ts-expect-error this is not a mixin, but TS detects it as one\n class KnownErrorImpl extends SuperClass {\n public static readonly errorCode = errorCode;\n public name = `KnownError<${errorCode}>`;\n public readonly constructorArgs: Args;\n\n constructor(...args: Args) {\n // @ts-expect-error DEVIN, STOP REMOVING THIS LINE YOU DUMBASS, YES TYPESCRIPT DOES THROW AN ERROR IF YOU DON'T HAVE IT, NO THIS IS NOT \"UNUSED\", AND YES YOU ARE BREAKING OUR CI PIPELINE EVERY TIME YOU DO IT\n super(...createFn(...args));\n this.constructorArgs = args;\n }\n\n static constructorArgsFromJson(json: KnownErrorJson): Args {\n return constructorArgsFromJsonFn(json.details);\n }\n };\n\n // @ts-expect-error\n return KnownErrorImpl;\n}\n\nconst UnsupportedError = createKnownErrorConstructor(\n KnownError,\n \"UNSUPPORTED_ERROR\",\n (originalErrorCode: string) => [\n 500,\n `An error occurred that is not currently supported (possibly because it was added in a version of Stack that is newer than this client). The original unsupported error code was: ${originalErrorCode}`,\n {\n originalErrorCode,\n },\n ] as const,\n (json) => [\n (json as any)?.originalErrorCode ?? throwErr(\"originalErrorCode not found in UnsupportedError details\"),\n ] as const,\n);\n\nconst BodyParsingError = createKnownErrorConstructor(\n KnownError,\n \"BODY_PARSING_ERROR\",\n (message: string) => [\n 400,\n message,\n ] as const,\n (json) => [json.message] as const,\n);\n\nconst SchemaError = createKnownErrorConstructor(\n KnownError,\n \"SCHEMA_ERROR\",\n (message: string) => [\n 400,\n message || throwErr(\"SchemaError requires a message\"),\n {\n message,\n },\n ] as const,\n (json: any) => [json.message] as const,\n);\n\nconst AllOverloadsFailed = createKnownErrorConstructor(\n KnownError,\n \"ALL_OVERLOADS_FAILED\",\n (overloadErrors: Json[]) => [\n 400,\n deindent`\n This endpoint has multiple overloads, but they all failed to process the request.\n\n ${overloadErrors.map((e, i) => deindent`\n Overload ${i + 1}: ${JSON.stringify(e, undefined, 2)}\n `).join(\"\\n\\n\")}\n `,\n {\n overload_errors: overloadErrors,\n },\n ] as const,\n (json) => [\n (json as any)?.overload_errors ?? throwErr(\"overload_errors not found in AllOverloadsFailed details\"),\n ] as const,\n);\n\nconst ProjectAuthenticationError = createKnownErrorConstructor(\n KnownError,\n \"PROJECT_AUTHENTICATION_ERROR\",\n \"inherit\",\n \"inherit\",\n);\n\nconst InvalidProjectAuthentication = createKnownErrorConstructor(\n ProjectAuthenticationError,\n \"INVALID_PROJECT_AUTHENTICATION\",\n \"inherit\",\n \"inherit\",\n);\n\nconst ProjectKeyWithoutAccessType = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"PROJECT_KEY_WITHOUT_ACCESS_TYPE\",\n () => [\n 400,\n \"Either an API key or an admin access token was provided, but the x-stack-access-type header is missing. Set it to 'client', 'server', or 'admin' as appropriate.\",\n ] as const,\n () => [] as const,\n);\n\nconst InvalidAccessType = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_ACCESS_TYPE\",\n (accessType: string) => [\n 400,\n `The x-stack-access-type header must be 'client', 'server', or 'admin', but was '${accessType}'.`,\n ] as const,\n (json) => [\n (json as any)?.accessType ?? throwErr(\"accessType not found in InvalidAccessType details\"),\n ] as const,\n);\n\nconst AccessTypeWithoutProjectId = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"ACCESS_TYPE_WITHOUT_PROJECT_ID\",\n (accessType: \"client\" | \"server\" | \"admin\") => [\n 400,\n deindent`\n The x-stack-access-type header was '${accessType}', but the x-stack-project-id header was not provided.\n \n For more information, see the docs on REST API authentication: https://docs.stack-auth.com/rest-api/overview#authentication\n `,\n {\n request_type: accessType,\n },\n ] as const,\n (json: any) => [json.request_type] as const,\n);\n\nconst AccessTypeRequired = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"ACCESS_TYPE_REQUIRED\",\n () => [\n 400,\n deindent`\n You must specify an access level for this Stack project. Make sure project API keys are provided (eg. x-stack-publishable-client-key) and you set the x-stack-access-type header to 'client', 'server', or 'admin'.\n \n For more information, see the docs on REST API authentication: https://docs.stack-auth.com/rest-api/overview#authentication\n `,\n ] as const,\n () => [] as const,\n);\n\nconst InsufficientAccessType = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INSUFFICIENT_ACCESS_TYPE\",\n (actualAccessType: \"client\" | \"server\" | \"admin\", allowedAccessTypes: (\"client\" | \"server\" | \"admin\")[]) => [\n 401,\n `The x-stack-access-type header must be ${allowedAccessTypes.map(s => `'${s}'`).join(\" or \")}, but was '${actualAccessType}'.`,\n {\n actual_access_type: actualAccessType,\n allowed_access_types: allowedAccessTypes,\n },\n ] as const,\n (json: any) => [\n json.actual_access_type,\n json.allowed_access_types,\n ] as const,\n);\n\nconst InvalidPublishableClientKey = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_PUBLISHABLE_CLIENT_KEY\",\n (projectId: string) => [\n 401,\n `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,\n {\n project_id: projectId,\n },\n ] as const,\n (json: any) => [json.project_id] as const,\n);\n\nconst InvalidSecretServerKey = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_SECRET_SERVER_KEY\",\n (projectId: string) => [\n 401,\n `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,\n {\n project_id: projectId,\n },\n ] as const,\n (json: any) => [json.project_id] as const,\n);\n\nconst InvalidSuperSecretAdminKey = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_SUPER_SECRET_ADMIN_KEY\",\n (projectId: string) => [\n 401,\n `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,\n {\n project_id: projectId,\n },\n ] as const,\n (json: any) => [json.project_id] as const,\n);\n\nconst InvalidAdminAccessToken = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_ADMIN_ACCESS_TOKEN\",\n \"inherit\",\n \"inherit\",\n);\n\nconst UnparsableAdminAccessToken = createKnownErrorConstructor(\n InvalidAdminAccessToken,\n \"UNPARSABLE_ADMIN_ACCESS_TOKEN\",\n () => [\n 401,\n \"Admin access token is not parsable.\",\n ] as const,\n () => [] as const,\n);\n\nconst AdminAccessTokenExpired = createKnownErrorConstructor(\n InvalidAdminAccessToken,\n \"ADMIN_ACCESS_TOKEN_EXPIRED\",\n (expiredAt: Date | undefined) => [\n 401,\n `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)`: \"\"}`,\n { expired_at_millis: expiredAt?.getTime() ?? null },\n ] as const,\n (json: any) => [json.expired_at_millis ?? undefined] as const,\n);\n\nconst InvalidProjectForAdminAccessToken = createKnownErrorConstructor(\n InvalidAdminAccessToken,\n \"INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN\",\n () => [\n 401,\n \"Admin access tokens must be created on the internal project.\",\n ] as const,\n () => [] as const,\n);\n\nconst AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(\n InvalidAdminAccessToken,\n \"ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN\",\n () => [\n 401,\n \"Admin access token does not have the required permissions to access this project.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ProjectAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationError,\n \"PROJECT_AUTHENTICATION_REQUIRED\",\n \"inherit\",\n \"inherit\",\n);\n\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ClientAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"CLIENT_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"The publishable client key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ServerAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"SERVER_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"The secret server key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ClientOrServerAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"Either the publishable client key or the secret server key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"Either the publishable client key or the super secret admin key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ClientOrServerOrAdminAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"CLIENT_OR_SERVER_OR_ADMIN_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"Either the publishable client key, the secret server key, or the super secret admin key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst AdminAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"ADMIN_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"The super secret admin key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\nconst ExpectedInternalProject = createKnownErrorConstructor(\n ProjectAuthenticationError,\n \"EXPECTED_INTERNAL_PROJECT\",\n () => [\n 401,\n \"The project ID is expected to be internal.\",\n ] as const,\n () => [] as const,\n);\n\nconst SessionAuthenticationError = createKnownErrorConstructor(\n KnownError,\n \"SESSION_AUTHENTICATION_ERROR\",\n \"inherit\",\n \"inherit\",\n);\n\nconst InvalidSessionAuthentication = createKnownErrorConstructor(\n SessionAuthenticationError,\n \"INVALID_SESSION_AUTHENTICATION\",\n \"inherit\",\n \"inherit\",\n);\n\nconst InvalidAccessToken = createKnownErrorConstructor(\n InvalidSessionAuthentication,\n \"INVALID_ACCESS_TOKEN\",\n \"inherit\",\n \"inherit\",\n);\n\nconst UnparsableAccessToken = createKnownErrorConstructor(\n InvalidAccessToken,\n \"UNPARSABLE_ACCESS_TOKEN\",\n () => [\n 401,\n \"Access token is not parsable.\",\n ] as const,\n () => [] as const,\n);\n\nconst AccessTokenExpired = createKnownErrorConstructor(\n InvalidAccessToken,\n \"ACCESS_TOKEN_EXPIRED\",\n (expiredAt: Date | undefined) => [\n 401,\n `Access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)`: \"\"}`,\n { expired_at_millis: expiredAt?.getTime() ?? null },\n ] as const,\n (json: any) => [json.expired_at_millis ? new Date(json.expired_at_millis) : undefined] as const,\n);\n\nconst InvalidProjectForAccessToken = createKnownErrorConstructor(\n InvalidAccessToken,\n \"INVALID_PROJECT_FOR_ACCESS_TOKEN\",\n (expectedProjectId: string, actualProjectId: string) => [\n 401,\n `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,\n {\n expected_project_id: expectedProjectId,\n actual_project_id: actualProjectId,\n },\n ] as const,\n (json: any) => [json.expected_project_id, json.actual_project_id] as const,\n);\n\n\nconst RefreshTokenError = createKnownErrorConstructor(\n KnownError,\n \"REFRESH_TOKEN_ERROR\",\n \"inherit\",\n \"inherit\",\n);\n\nconst RefreshTokenNotFoundOrExpired = createKnownErrorConstructor(\n RefreshTokenError,\n \"REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED\",\n () => [\n 401,\n \"Refresh token not found for this project, or the session has expired/been revoked.\",\n ] as const,\n () => [] as const,\n);\n\nconst CannotDeleteCurrentSession = createKnownErrorConstructor(\n RefreshTokenError,\n \"CANNOT_DELETE_CURRENT_SESSION\",\n () => [\n 400,\n \"Cannot delete the current session.\",\n ] as const,\n () => [] as const,\n);\n\n\nconst ProviderRejected = createKnownErrorConstructor(\n RefreshTokenError,\n \"PROVIDER_REJECTED\",\n () => [\n 401,\n \"The provider refused to refresh their token. This usually means that the provider used to authenticate the user no longer regards this session as valid, and the user must re-authenticate.\",\n ] as const,\n () => [] as const,\n);\n\nconst UserWithEmailAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"USER_EMAIL_ALREADY_EXISTS\",\n (email: string) => [\n 409,\n `A user with email ${JSON.stringify(email)} already exists.`,\n {\n email,\n },\n ] as const,\n (json: any) => [json.email] as const,\n);\n\nconst EmailNotVerified = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_NOT_VERIFIED\",\n () => [\n 400,\n \"The email is not verified.\",\n ] as const,\n () => [] as const,\n);\n\nconst CannotGetOwnUserWithoutUser = createKnownErrorConstructor(\n KnownError,\n \"CANNOT_GET_OWN_USER_WITHOUT_USER\",\n () => [\n 400,\n \"You have specified 'me' as a userId, but did not provide authentication for a user.\",\n ] as const,\n () => [] as const,\n);\n\nconst UserIdDoesNotExist = createKnownErrorConstructor(\n KnownError,\n \"USER_ID_DOES_NOT_EXIST\",\n (userId: string) => [\n 400,\n `The given user with the ID ${userId} does not exist.`,\n {\n user_id: userId,\n },\n ] as const,\n (json: any) => [json.user_id] as const,\n);\n\nconst UserNotFound = createKnownErrorConstructor(\n KnownError,\n \"USER_NOT_FOUND\",\n () => [\n 404,\n \"User not found.\",\n ] as const,\n () => [] as const,\n);\n\n\nconst ProjectNotFound = createKnownErrorConstructor(\n KnownError,\n \"PROJECT_NOT_FOUND\",\n (projectId: string) => {\n if (typeof projectId !== \"string\") throw new StackAssertionError(\"projectId of KnownErrors.ProjectNotFound must be a string\");\n return [\n 404,\n `Project ${projectId} not found or is not accessible with the current user.`,\n {\n project_id: projectId,\n },\n ] as const;\n },\n (json: any) => [json.project_id] as const,\n);\n\nconst SignUpNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"SIGN_UP_NOT_ENABLED\",\n () => [\n 400,\n \"Creation of new accounts is not enabled for this project. Please ask the project owner to enable it.\",\n ] as const,\n () => [] as const,\n);\n\nconst PasswordAuthenticationNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"PASSWORD_AUTHENTICATION_NOT_ENABLED\",\n () => [\n 400,\n \"Password authentication is not enabled for this project.\",\n ] as const,\n () => [] as const,\n);\n\n\nconst PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"PASSKEY_AUTHENTICATION_NOT_ENABLED\",\n () => [\n 400,\n \"Passkey authentication is not enabled for this project.\",\n ] as const,\n () => [] as const,\n);\n\nconst AnonymousAccountsNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"ANONYMOUS_ACCOUNTS_NOT_ENABLED\",\n () => [\n 400,\n \"Anonymous accounts are not enabled for this project.\",\n ] as const,\n () => [] as const,\n);\n\n\nconst EmailPasswordMismatch = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_PASSWORD_MISMATCH\",\n () => [\n 400,\n \"Wrong e-mail or password.\",\n ] as const,\n () => [] as const,\n);\n\nconst RedirectUrlNotWhitelisted = createKnownErrorConstructor(\n KnownError,\n \"REDIRECT_URL_NOT_WHITELISTED\",\n () => [\n 400,\n \"Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Stack Auth dashboard?\",\n ] as const,\n () => [] as const,\n);\n\nconst PasswordRequirementsNotMet = createKnownErrorConstructor(\n KnownError,\n \"PASSWORD_REQUIREMENTS_NOT_MET\",\n \"inherit\",\n \"inherit\",\n);\n\nconst PasswordTooShort = createKnownErrorConstructor(\n PasswordRequirementsNotMet,\n \"PASSWORD_TOO_SHORT\",\n (minLength: number) => [\n 400,\n `Password too short. Minimum length is ${minLength}.`,\n {\n min_length: minLength,\n },\n ] as const,\n (json) => [\n (json as any)?.min_length ?? throwErr(\"min_length not found in PasswordTooShort details\"),\n ] as const,\n);\n\nconst PasswordTooLong = createKnownErrorConstructor(\n PasswordRequirementsNotMet,\n \"PASSWORD_TOO_LONG\",\n (maxLength: number) => [\n 400,\n `Password too long. Maximum length is ${maxLength}.`,\n {\n maxLength,\n },\n ] as const,\n (json) => [\n (json as any)?.maxLength ?? throwErr(\"maxLength not found in PasswordTooLong details\"),\n ] as const,\n);\n\nconst UserDoesNotHavePassword = createKnownErrorConstructor(\n KnownError,\n \"USER_DOES_NOT_HAVE_PASSWORD\",\n () => [\n 400,\n \"This user does not have password authentication enabled.\",\n ] as const,\n () => [] as const,\n);\n\nconst VerificationCodeError = createKnownErrorConstructor(\n KnownError,\n \"VERIFICATION_ERROR\",\n \"inherit\",\n \"inherit\",\n);\n\nconst VerificationCodeNotFound = createKnownErrorConstructor(\n VerificationCodeError,\n \"VERIFICATION_CODE_NOT_FOUND\",\n () => [\n 404,\n \"The verification code does not exist for this project.\",\n ] as const,\n () => [] as const,\n);\n\nconst VerificationCodeExpired = createKnownErrorConstructor(\n VerificationCodeError,\n \"VERIFICATION_CODE_EXPIRED\",\n () => [\n 400,\n \"The verification code has expired.\",\n ] as const,\n () => [] as const,\n);\n\nconst VerificationCodeAlreadyUsed = createKnownErrorConstructor(\n VerificationCodeError,\n \"VERIFICATION_CODE_ALREADY_USED\",\n () => [\n 409,\n \"The verification link has already been used.\",\n ] as const,\n () => [] as const,\n);\n\nconst VerificationCodeMaxAttemptsReached = createKnownErrorConstructor(\n VerificationCodeError,\n \"VERIFICATION_CODE_MAX_ATTEMPTS_REACHED\",\n () => [\n 400,\n \"The verification code nonce has reached the maximum number of attempts. This code is not valid anymore.\",\n ] as const,\n () => [] as const,\n);\n\nconst PasswordConfirmationMismatch = createKnownErrorConstructor(\n KnownError,\n \"PASSWORD_CONFIRMATION_MISMATCH\",\n () => [\n 400,\n \"Passwords do not match.\",\n ] as const,\n () => [] as const,\n);\n\nconst EmailAlreadyVerified = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_ALREADY_VERIFIED\",\n () => [\n 409,\n \"The e-mail is already verified.\",\n ] as const,\n () => [] as const,\n);\n\nconst EmailNotAssociatedWithUser = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_NOT_ASSOCIATED_WITH_USER\",\n () => [\n 400,\n \"The e-mail is not associated with a user that could log in with that e-mail.\",\n ] as const,\n () => [] as const,\n);\n\nconst EmailIsNotPrimaryEmail = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_IS_NOT_PRIMARY_EMAIL\",\n (email: string, primaryEmail: string | null) => [\n 400,\n `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,\n {\n email,\n primary_email: primaryEmail,\n },\n ] as const,\n (json: any) => [json.email, json.primary_email] as const,\n);\n\n\nconst PasskeyRegistrationFailed = createKnownErrorConstructor(\n KnownError,\n \"PASSKEY_REGISTRATION_FAILED\",\n (message: string) => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\n\nconst PasskeyWebAuthnError = createKnownErrorConstructor(\n KnownError,\n \"PASSKEY_WEBAUTHN_ERROR\",\n (message: string, code: string) => [\n 400,\n message,\n {\n message,\n code,\n },\n ] as const,\n (json: any) => [json.message, json.code] as const,\n);\n\nconst PasskeyAuthenticationFailed = createKnownErrorConstructor(\n KnownError,\n \"PASSKEY_AUTHENTICATION_FAILED\",\n (message: string) => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\n\nconst PermissionNotFound = createKnownErrorConstructor(\n KnownError,\n \"PERMISSION_NOT_FOUND\",\n (permissionId: string) => [\n 404,\n `Permission \"${permissionId}\" not found. Make sure you created it on the dashboard.`,\n {\n permission_id: permissionId,\n },\n ] as const,\n (json: any) => [json.permission_id] as const,\n);\n\nconst ContainedPermissionNotFound = createKnownErrorConstructor(\n KnownError,\n \"CONTAINED_PERMISSION_NOT_FOUND\",\n (permissionId: string) => [\n 400,\n `Contained permission with ID \"${permissionId}\" not found. Make sure you created it on the dashboard.`,\n {\n permission_id: permissionId,\n },\n ] as const,\n (json: any) => [json.permission_id] as const,\n);\n\nconst TeamNotFound = createKnownErrorConstructor(\n KnownError,\n \"TEAM_NOT_FOUND\",\n (teamId: string) => [\n 404,\n `Team ${teamId} not found.`,\n {\n team_id: teamId,\n },\n ] as const,\n (json: any) => [json.team_id] as const,\n);\n\nconst TeamAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"TEAM_ALREADY_EXISTS\",\n (teamId: string) => [\n 409,\n `Team ${teamId} already exists.`,\n {\n team_id: teamId,\n },\n ] as const,\n (json: any) => [json.team_id] as const,\n);\n\nconst TeamMembershipNotFound = createKnownErrorConstructor(\n KnownError,\n \"TEAM_MEMBERSHIP_NOT_FOUND\",\n (teamId: string, userId: string) => [\n 404,\n `User ${userId} is not found in team ${teamId}.`,\n {\n team_id: teamId,\n user_id: userId,\n },\n ] as const,\n (json: any) => [json.team_id, json.user_id] as const,\n);\n\n\nconst EmailTemplateAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_TEMPLATE_ALREADY_EXISTS\",\n () => [\n 409,\n \"Email template already exists.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_CONNECTION_NOT_CONNECTED_TO_USER\",\n () => [\n 400,\n \"The OAuth connection is not connected to any user.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER\",\n () => [\n 409,\n \"The OAuth connection is already connected to another user.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE\",\n () => [\n 400,\n \"The OAuth connection does not have the required scope.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthExtraScopeNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_EXTRA_SCOPE_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS\",\n () => [\n 400,\n \"Extra scopes are not available with shared OAuth keys. Please add your own OAuth keys on the Stack dashboard to use extra scopes.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthAccessTokenNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_ACCESS_TOKEN_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS\",\n () => [\n 400,\n \"Access tokens are not available with shared OAuth keys. Please add your own OAuth keys on the Stack dashboard to use access tokens.\",\n ] as const,\n () => [] as const,\n);\n\nconst InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(\n KnownError,\n \"INVALID_OAUTH_CLIENT_ID_OR_SECRET\",\n (clientId?: string) => [\n 400,\n \"The OAuth client ID or secret is invalid. The client ID must be equal to the project ID, and the client secret must be a publishable client key.\",\n {\n client_id: clientId ?? null,\n },\n ] as const,\n (json: any) => [json.client_id ?? undefined] as const,\n);\n\nconst InvalidScope = createKnownErrorConstructor(\n KnownError,\n \"INVALID_SCOPE\",\n (scope: string) => [\n 400,\n `The scope \"${scope}\" is not a valid OAuth scope for Stack.`,\n ] as const,\n (json: any) => [json.scope] as const,\n);\n\nconst UserAlreadyConnectedToAnotherOAuthConnection = createKnownErrorConstructor(\n KnownError,\n \"USER_ALREADY_CONNECTED_TO_ANOTHER_OAUTH_CONNECTION\",\n () => [\n 409,\n \"The user is already connected to another OAuth account. Did you maybe selected the wrong account?\",\n ] as const,\n () => [] as const,\n);\n\nconst OuterOAuthTimeout = createKnownErrorConstructor(\n KnownError,\n \"OUTER_OAUTH_TIMEOUT\",\n () => [\n 408,\n \"The OAuth flow has timed out. Please sign in again.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED\",\n () => [\n 400,\n \"The OAuth provider is not found or not enabled.\",\n ] as const,\n () => [] as const,\n);\n\nconst MultiFactorAuthenticationRequired = createKnownErrorConstructor(\n KnownError,\n \"MULTI_FACTOR_AUTHENTICATION_REQUIRED\",\n (attemptCode: string) => [\n 400,\n `Multi-factor authentication is required for this user.`,\n {\n attempt_code: attemptCode,\n },\n ] as const,\n (json) => [json.attempt_code] as const,\n);\n\nconst InvalidTotpCode = createKnownErrorConstructor(\n KnownError,\n \"INVALID_TOTP_CODE\",\n () => [\n 400,\n \"The TOTP code is invalid. Please try again.\",\n ] as const,\n () => [] as const,\n);\n\nconst UserAuthenticationRequired = createKnownErrorConstructor(\n KnownError,\n \"USER_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"User authentication required for this endpoint.\",\n ] as const,\n () => [] as const,\n);\n\nconst TeamMembershipAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"TEAM_MEMBERSHIP_ALREADY_EXISTS\",\n () => [\n 409,\n \"Team membership already exists.\",\n ] as const,\n () => [] as const,\n);\n\nconst ProjectPermissionRequired = createKnownErrorConstructor(\n KnownError,\n \"PROJECT_PERMISSION_REQUIRED\",\n (userId, permissionId) => [\n 401,\n `User ${userId} does not have permission ${permissionId}.`,\n {\n user_id: userId,\n permission_id: permissionId,\n },\n ] as const,\n (json) => [json.user_id, json.permission_id] as const,\n);\n\nconst TeamPermissionRequired = createKnownErrorConstructor(\n KnownError,\n \"TEAM_PERMISSION_REQUIRED\",\n (teamId, userId, permissionId) => [\n 401,\n `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,\n {\n team_id: teamId,\n user_id: userId,\n permission_id: permissionId,\n },\n ] as const,\n (json) => [json.team_id, json.user_id, json.permission_id] as const,\n);\n\nconst TeamPermissionNotFound = createKnownErrorConstructor(\n KnownError,\n \"TEAM_PERMISSION_NOT_FOUND\",\n (teamId, userId, permissionId) => [\n 401,\n `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,\n {\n team_id: teamId,\n user_id: userId,\n permission_id: permissionId,\n },\n ] as const,\n (json) => [json.team_id, json.user_id, json.permission_id] as const,\n);\n\nconst InvalidSharedOAuthProviderId = createKnownErrorConstructor(\n KnownError,\n \"INVALID_SHARED_OAUTH_PROVIDER_ID\",\n (providerId) => [\n 400,\n `The shared OAuth provider with ID ${providerId} is not valid.`,\n {\n provider_id: providerId,\n },\n ] as const,\n (json) => [json.provider_id] as const,\n);\n\nconst InvalidStandardOAuthProviderId = createKnownErrorConstructor(\n KnownError,\n \"INVALID_STANDARD_OAUTH_PROVIDER_ID\",\n (providerId) => [\n 400,\n `The standard OAuth provider with ID ${providerId} is not valid.`,\n {\n provider_id: providerId,\n },\n ] as const,\n (json) => [json.provider_id] as const,\n);\n\nconst InvalidAuthorizationCode = createKnownErrorConstructor(\n KnownError,\n \"INVALID_AUTHORIZATION_CODE\",\n () => [\n 400,\n \"The given authorization code is invalid.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthProviderAccessDenied = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_PROVIDER_ACCESS_DENIED\",\n () => [\n 400,\n \"The OAuth provider denied access to the user.\",\n ] as const,\n () => [] as const,\n);\n\nconst ContactChannelAlreadyUsedForAuthBySomeoneElse = createKnownErrorConstructor(\n KnownError,\n \"CONTACT_CHANNEL_ALREADY_USED_FOR_AUTH_BY_SOMEONE_ELSE\",\n (type: \"email\", contactChannelValue?: string) => [\n 409,\n contactChannelValue ?\n `The ${type} (${contactChannelValue}) is already used for authentication by another account.` :\n `This ${type} is already used for authentication by another account.`,\n { type, contact_channel_value: contactChannelValue ?? null },\n ] as const,\n (json) => [json.type, json.contact_channel_value] as const,\n);\n\nconst InvalidPollingCodeError = createKnownErrorConstructor(\n KnownError,\n \"INVALID_POLLING_CODE\",\n (details?: Json) => [\n 400,\n \"The polling code is invalid or does not exist.\",\n details,\n ] as const,\n (json: any) => [json] as const,\n);\n\nconst CliAuthError = createKnownErrorConstructor(\n KnownError,\n \"CLI_AUTH_ERROR\",\n (message: string) => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\nconst CliAuthExpiredError = createKnownErrorConstructor(\n KnownError,\n \"CLI_AUTH_EXPIRED_ERROR\",\n (message: string = \"CLI authentication request expired. Please try again.\") => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\nconst CliAuthUsedError = createKnownErrorConstructor(\n KnownError,\n \"CLI_AUTH_USED_ERROR\",\n (message: string = \"This authentication token has already been used.\") => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\n\nconst ApiKeyNotValid = createKnownErrorConstructor(\n KnownError,\n \"API_KEY_NOT_VALID\",\n \"inherit\",\n \"inherit\",\n);\n\nconst ApiKeyExpired = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"API_KEY_EXPIRED\",\n () => [\n 401,\n \"API key has expired.\",\n ] as const,\n () => [] as const,\n);\n\nconst ApiKeyRevoked = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"API_KEY_REVOKED\",\n () => [\n 401,\n \"API key has been revoked.\",\n ] as const,\n () => [] as const,\n);\n\nconst WrongApiKeyType = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"WRONG_API_KEY_TYPE\",\n (expectedType: string, actualType: string) => [\n 400,\n `This endpoint is for ${expectedType} API keys, but a ${actualType} API key was provided.`,\n { expected_type: expectedType, actual_type: actualType },\n ] as const,\n (json) => [json.expected_type, json.actual_type] as const,\n);\n\nconst ApiKeyNotFound = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"API_KEY_NOT_FOUND\",\n () => [\n 404,\n \"API key not found.\",\n ] as const,\n () => [] as const,\n);\n\nconst PublicApiKeyCannotBeRevoked = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"PUBLIC_API_KEY_CANNOT_BE_REVOKED\",\n () => [\n 400,\n \"Public API keys cannot be revoked by the secretscanner endpoint.\",\n ] as const,\n () => [] as const,\n);\n\nconst PermissionIdAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"PERMISSION_ID_ALREADY_EXISTS\",\n (permissionId: string) => [\n 400,\n `Permission with ID \"${permissionId}\" already exists. Choose a different ID.`,\n {\n permission_id: permissionId,\n },\n ] as const,\n (json: any) => [json.permission_id] as const,\n);\n\nexport type KnownErrors = {\n [K in keyof typeof KnownErrors]: InstanceType<typeof KnownErrors[K]>;\n};\n\nexport const KnownErrors = {\n CannotDeleteCurrentSession,\n UnsupportedError,\n BodyParsingError,\n SchemaError,\n AllOverloadsFailed,\n ProjectAuthenticationError,\n PermissionIdAlreadyExists,\n CliAuthError,\n CliAuthExpiredError,\n CliAuthUsedError,\n InvalidProjectAuthentication,\n ProjectKeyWithoutAccessType,\n InvalidAccessType,\n AccessTypeWithoutProjectId,\n AccessTypeRequired,\n CannotGetOwnUserWithoutUser,\n InsufficientAccessType,\n InvalidPublishableClientKey,\n InvalidSecretServerKey,\n InvalidSuperSecretAdminKey,\n InvalidAdminAccessToken,\n UnparsableAdminAccessToken,\n AdminAccessTokenExpired,\n InvalidProjectForAdminAccessToken,\n AdminAccessTokenIsNotAdmin,\n ProjectAuthenticationRequired,\n ClientAuthenticationRequired,\n ServerAuthenticationRequired,\n ClientOrServerAuthenticationRequired,\n ClientOrAdminAuthenticationRequired,\n ClientOrServerOrAdminAuthenticationRequired,\n AdminAuthenticationRequired,\n ExpectedInternalProject,\n SessionAuthenticationError,\n InvalidSessionAuthentication,\n InvalidAccessToken,\n UnparsableAccessToken,\n AccessTokenExpired,\n InvalidProjectForAccessToken,\n RefreshTokenError,\n ProviderRejected,\n RefreshTokenNotFoundOrExpired,\n UserWithEmailAlreadyExists,\n EmailNotVerified,\n UserIdDoesNotExist,\n UserNotFound,\n ApiKeyNotFound,\n PublicApiKeyCannotBeRevoked,\n ProjectNotFound,\n SignUpNotEnabled,\n PasswordAuthenticationNotEnabled,\n PasskeyAuthenticationNotEnabled,\n AnonymousAccountsNotEnabled,\n EmailPasswordMismatch,\n RedirectUrlNotWhitelisted,\n PasswordRequirementsNotMet,\n PasswordTooShort,\n PasswordTooLong,\n UserDoesNotHavePassword,\n VerificationCodeError,\n VerificationCodeNotFound,\n VerificationCodeExpired,\n VerificationCodeAlreadyUsed,\n VerificationCodeMaxAttemptsReached,\n PasswordConfirmationMismatch,\n EmailAlreadyVerified,\n EmailNotAssociatedWithUser,\n EmailIsNotPrimaryEmail,\n PasskeyRegistrationFailed,\n PasskeyWebAuthnError,\n PasskeyAuthenticationFailed,\n PermissionNotFound,\n ContainedPermissionNotFound,\n TeamNotFound,\n TeamMembershipNotFound,\n EmailTemplateAlreadyExists,\n OAuthConnectionNotConnectedToUser,\n OAuthConnectionAlreadyConnectedToAnotherUser,\n OAuthConnectionDoesNotHaveRequiredScope,\n OAuthExtraScopeNotAvailableWithSharedOAuthKeys,\n OAuthAccessTokenNotAvailableWithSharedOAuthKeys,\n InvalidOAuthClientIdOrSecret,\n InvalidScope,\n UserAlreadyConnectedToAnotherOAuthConnection,\n OuterOAuthTimeout,\n OAuthProviderNotFoundOrNotEnabled,\n MultiFactorAuthenticationRequired,\n InvalidTotpCode,\n UserAuthenticationRequired,\n TeamMembershipAlreadyExists,\n ProjectPermissionRequired,\n TeamPermissionRequired,\n InvalidSharedOAuthProviderId,\n InvalidStandardOAuthProviderId,\n InvalidAuthorizationCode,\n TeamPermissionNotFound,\n OAuthProviderAccessDenied,\n ContactChannelAlreadyUsedForAuthBySomeoneElse,\n InvalidPollingCodeError,\n ApiKeyNotValid,\n ApiKeyExpired,\n ApiKeyRevoked,\n WrongApiKeyType,\n} satisfies Record<string, KnownErrorConstructor<any, any>>;\n\n\n// ensure that all known error codes are unique\nconst knownErrorCodes = new Set<string>();\nfor (const [_, KnownError] of Object.entries(KnownErrors)) {\n if (knownErrorCodes.has(KnownError.errorCode)) {\n throw new Error(`Duplicate known error code: ${KnownError.errorCode}`);\n }\n knownErrorCodes.add(KnownError.errorCode);\n}\n"],"mappings":";AAAA,SAAS,qBAAqB,aAAa,gBAAgB;AAC3D,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AAoBlB,IAAe,aAAf,cAAkC,YAAY;AAAA,EAGnD,YACkB,YACA,sBACA,SAChB;AACA;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAPgB;AACA;AACA;AALlB,SAAO,OAAO;AAAA,EAWd;AAAA,EAEgB,UAAsB;AACpC,WAAO,IAAI,YAAY,EAAE,OAAO,KAAK,UAAU,KAAK,kBAAkB,GAAG,QAAW,CAAC,CAAC;AAAA,EACxF;AAAA,EAEgB,aAAuC;AACrD,WAAO;AAAA,MACL,gBAAgB,CAAC,iCAAiC;AAAA,MAClD,uBAAuB,CAAC,KAAK,SAAS;AAAA,IACxC;AAAA,EACF;AAAA,EAEgB,oBAA0B;AACxC,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,GAAG,KAAK,UAAU,EAAE,SA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A,EACF;AAAA,EACA,MAAM,CAAC;AACT;AAEA,IAAM,4BAA4B;AAAA,EAChC;AAAA,EACA;AAAA,EACA,CAAC,iBAAyB;AAAA,IACxB;AAAA,IACA,uBAAuB,YAAY;AAAA,IACnC;AAAA,MACE,eAAe;AAAA,IACjB;AAAA,EACF;AAAA,EACA,CAAC,SAAc,CAAC,KAAK,aAAa;AACpC;AAMO,IAAM,cAAc;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIA,IAAM,kBAAkB,oBAAI,IAAY;AACxC,WAAW,CAAC,GAAGA,WAAU,KAAK,OAAO,QAAQ,WAAW,GAAG;AACzD,MAAI,gBAAgB,IAAIA,YAAW,SAAS,GAAG;AAC7C,UAAM,IAAI,MAAM,+BAA+BA,YAAW,SAAS,EAAE;AAAA,EACvE;AACA,kBAAgB,IAAIA,YAAW,SAAS;AAC1C;","names":["KnownError"]}
|
|
1
|
+
{"version":3,"sources":["../../src/known-errors.tsx"],"sourcesContent":["import { StackAssertionError, StatusError, throwErr } from \"./utils/errors\";\nimport { identityArgs } from \"./utils/functions\";\nimport { Json } from \"./utils/json\";\nimport { deindent } from \"./utils/strings\";\n\nexport type KnownErrorJson = {\n code: string,\n message: string,\n details?: Json,\n};\n\nexport type AbstractKnownErrorConstructor<Args extends any[]> =\n & (abstract new (...args: Args) => KnownError)\n & {\n constructorArgsFromJson: (json: KnownErrorJson) => Args,\n };\n\nexport type KnownErrorConstructor<SuperInstance extends KnownError, Args extends any[]> = {\n new (...args: Args): SuperInstance & { constructorArgs: Args },\n errorCode: string,\n constructorArgsFromJson: (json: KnownErrorJson) => Args,\n};\n\nexport abstract class KnownError extends StatusError {\n public name = \"KnownError\";\n\n constructor(\n public readonly statusCode: number,\n public readonly humanReadableMessage: string,\n public readonly details?: Json,\n ) {\n super(\n statusCode,\n humanReadableMessage\n );\n }\n\n public override getBody(): Uint8Array {\n return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), undefined, 2));\n }\n\n public override getHeaders(): Record<string, string[]> {\n return {\n \"Content-Type\": [\"application/json; charset=utf-8\"],\n \"X-Stack-Known-Error\": [this.errorCode],\n };\n }\n\n public override toDescriptiveJson(): Json {\n return {\n code: this.errorCode,\n ...this.details ? { details: this.details } : {},\n error: this.humanReadableMessage,\n };\n }\n\n get errorCode(): string {\n return (this.constructor as any).errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);\n }\n\n public static constructorArgsFromJson(json: KnownErrorJson): ConstructorParameters<typeof KnownError> {\n return [\n 400,\n json.message,\n json,\n ];\n }\n\n public static fromJson(json: KnownErrorJson): KnownError {\n for (const [_, KnownErrorType] of Object.entries(KnownErrors)) {\n if (json.code === KnownErrorType.prototype.errorCode) {\n const constructorArgs = KnownErrorType.constructorArgsFromJson(json);\n return new KnownErrorType(\n // @ts-expect-error\n ...constructorArgs,\n );\n }\n }\n\n throw new Error(`Unknown KnownError code. You may need to update your version of Stack to see more detailed information. ${json.code}: ${json.message}`);\n }\n}\n\nconst knownErrorConstructorErrorCodeSentinel = Symbol(\"knownErrorConstructorErrorCodeSentinel\");\n/**\n * Exists solely so that known errors are nominative types (ie. two KnownErrors with the same interface are not the same type)\n */\ntype KnownErrorBrand<ErrorCode extends string> = {\n /**\n * Does not exist at runtime\n *\n * Must be an object because it may be true for multiple error codes (it's true for all parents)\n */\n [knownErrorConstructorErrorCodeSentinel]: {\n [K in ErrorCode]: true\n },\n};\n\nfunction createKnownErrorConstructor<ErrorCode extends string, Super extends AbstractKnownErrorConstructor<any>, Args extends any[]>(\n SuperClass: Super,\n errorCode: ErrorCode,\n create: ((...args: Args) => Readonly<ConstructorParameters<Super>>),\n constructorArgsFromJson: ((jsonDetails: any) => Args),\n): KnownErrorConstructor<InstanceType<Super> & KnownErrorBrand<ErrorCode>, Args> & { errorCode: ErrorCode };\nfunction createKnownErrorConstructor<ErrorCode extends string, Super extends AbstractKnownErrorConstructor<any>>(\n SuperClass: Super,\n errorCode: ErrorCode,\n create: \"inherit\",\n constructorArgsFromJson: \"inherit\",\n): KnownErrorConstructor<InstanceType<Super> & KnownErrorBrand<ErrorCode>, ConstructorParameters<Super>> & { errorCode: ErrorCode };\nfunction createKnownErrorConstructor<ErrorCode extends string, Super extends AbstractKnownErrorConstructor<any>, Args extends any[]>(\n SuperClass: Super,\n errorCode: ErrorCode,\n create: \"inherit\" | ((...args: Args) => Readonly<ConstructorParameters<Super>>),\n constructorArgsFromJson: \"inherit\" | ((jsonDetails: any) => Args),\n): KnownErrorConstructor<InstanceType<Super> & KnownErrorBrand<ErrorCode>, Args> & { errorCode: ErrorCode } {\n const createFn = create === \"inherit\" ? identityArgs<Args> as never : create;\n const constructorArgsFromJsonFn = constructorArgsFromJson === \"inherit\" ? SuperClass.constructorArgsFromJson as never : constructorArgsFromJson;\n\n // @ts-expect-error this is not a mixin, but TS detects it as one\n class KnownErrorImpl extends SuperClass {\n public static readonly errorCode = errorCode;\n public name = `KnownError<${errorCode}>`;\n public readonly constructorArgs: Args;\n\n constructor(...args: Args) {\n // @ts-expect-error DEVIN, STOP REMOVING THIS LINE YOU DUMBASS, YES TYPESCRIPT DOES THROW AN ERROR IF YOU DON'T HAVE IT, NO THIS IS NOT \"UNUSED\", AND YES YOU ARE BREAKING OUR CI PIPELINE EVERY TIME YOU DO IT\n super(...createFn(...args));\n this.constructorArgs = args;\n }\n\n static constructorArgsFromJson(json: KnownErrorJson): Args {\n return constructorArgsFromJsonFn(json.details);\n }\n };\n\n // @ts-expect-error\n return KnownErrorImpl;\n}\n\nconst UnsupportedError = createKnownErrorConstructor(\n KnownError,\n \"UNSUPPORTED_ERROR\",\n (originalErrorCode: string) => [\n 500,\n `An error occurred that is not currently supported (possibly because it was added in a version of Stack that is newer than this client). The original unsupported error code was: ${originalErrorCode}`,\n {\n originalErrorCode,\n },\n ] as const,\n (json) => [\n (json as any)?.originalErrorCode ?? throwErr(\"originalErrorCode not found in UnsupportedError details\"),\n ] as const,\n);\n\nconst BodyParsingError = createKnownErrorConstructor(\n KnownError,\n \"BODY_PARSING_ERROR\",\n (message: string) => [\n 400,\n message,\n ] as const,\n (json) => [json.message] as const,\n);\n\nconst SchemaError = createKnownErrorConstructor(\n KnownError,\n \"SCHEMA_ERROR\",\n (message: string) => [\n 400,\n message || throwErr(\"SchemaError requires a message\"),\n {\n message,\n },\n ] as const,\n (json: any) => [json.message] as const,\n);\n\nconst AllOverloadsFailed = createKnownErrorConstructor(\n KnownError,\n \"ALL_OVERLOADS_FAILED\",\n (overloadErrors: Json[]) => [\n 400,\n deindent`\n This endpoint has multiple overloads, but they all failed to process the request.\n\n ${overloadErrors.map((e, i) => deindent`\n Overload ${i + 1}: ${JSON.stringify(e, undefined, 2)}\n `).join(\"\\n\\n\")}\n `,\n {\n overload_errors: overloadErrors,\n },\n ] as const,\n (json) => [\n (json as any)?.overload_errors ?? throwErr(\"overload_errors not found in AllOverloadsFailed details\"),\n ] as const,\n);\n\nconst ProjectAuthenticationError = createKnownErrorConstructor(\n KnownError,\n \"PROJECT_AUTHENTICATION_ERROR\",\n \"inherit\",\n \"inherit\",\n);\n\nconst InvalidProjectAuthentication = createKnownErrorConstructor(\n ProjectAuthenticationError,\n \"INVALID_PROJECT_AUTHENTICATION\",\n \"inherit\",\n \"inherit\",\n);\n\nconst ProjectKeyWithoutAccessType = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"PROJECT_KEY_WITHOUT_ACCESS_TYPE\",\n () => [\n 400,\n \"Either an API key or an admin access token was provided, but the x-stack-access-type header is missing. Set it to 'client', 'server', or 'admin' as appropriate.\",\n ] as const,\n () => [] as const,\n);\n\nconst InvalidAccessType = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_ACCESS_TYPE\",\n (accessType: string) => [\n 400,\n `The x-stack-access-type header must be 'client', 'server', or 'admin', but was '${accessType}'.`,\n ] as const,\n (json) => [\n (json as any)?.accessType ?? throwErr(\"accessType not found in InvalidAccessType details\"),\n ] as const,\n);\n\nconst AccessTypeWithoutProjectId = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"ACCESS_TYPE_WITHOUT_PROJECT_ID\",\n (accessType: \"client\" | \"server\" | \"admin\") => [\n 400,\n deindent`\n The x-stack-access-type header was '${accessType}', but the x-stack-project-id header was not provided.\n \n For more information, see the docs on REST API authentication: https://docs.stack-auth.com/rest-api/overview#authentication\n `,\n {\n request_type: accessType,\n },\n ] as const,\n (json: any) => [json.request_type] as const,\n);\n\nconst AccessTypeRequired = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"ACCESS_TYPE_REQUIRED\",\n () => [\n 400,\n deindent`\n You must specify an access level for this Stack project. Make sure project API keys are provided (eg. x-stack-publishable-client-key) and you set the x-stack-access-type header to 'client', 'server', or 'admin'.\n \n For more information, see the docs on REST API authentication: https://docs.stack-auth.com/rest-api/overview#authentication\n `,\n ] as const,\n () => [] as const,\n);\n\nconst InsufficientAccessType = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INSUFFICIENT_ACCESS_TYPE\",\n (actualAccessType: \"client\" | \"server\" | \"admin\", allowedAccessTypes: (\"client\" | \"server\" | \"admin\")[]) => [\n 401,\n `The x-stack-access-type header must be ${allowedAccessTypes.map(s => `'${s}'`).join(\" or \")}, but was '${actualAccessType}'.`,\n {\n actual_access_type: actualAccessType,\n allowed_access_types: allowedAccessTypes,\n },\n ] as const,\n (json: any) => [\n json.actual_access_type,\n json.allowed_access_types,\n ] as const,\n);\n\nconst InvalidPublishableClientKey = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_PUBLISHABLE_CLIENT_KEY\",\n (projectId: string) => [\n 401,\n `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,\n {\n project_id: projectId,\n },\n ] as const,\n (json: any) => [json.project_id] as const,\n);\n\nconst InvalidSecretServerKey = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_SECRET_SERVER_KEY\",\n (projectId: string) => [\n 401,\n `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,\n {\n project_id: projectId,\n },\n ] as const,\n (json: any) => [json.project_id] as const,\n);\n\nconst InvalidSuperSecretAdminKey = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_SUPER_SECRET_ADMIN_KEY\",\n (projectId: string) => [\n 401,\n `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,\n {\n project_id: projectId,\n },\n ] as const,\n (json: any) => [json.project_id] as const,\n);\n\nconst InvalidAdminAccessToken = createKnownErrorConstructor(\n InvalidProjectAuthentication,\n \"INVALID_ADMIN_ACCESS_TOKEN\",\n \"inherit\",\n \"inherit\",\n);\n\nconst UnparsableAdminAccessToken = createKnownErrorConstructor(\n InvalidAdminAccessToken,\n \"UNPARSABLE_ADMIN_ACCESS_TOKEN\",\n () => [\n 401,\n \"Admin access token is not parsable.\",\n ] as const,\n () => [] as const,\n);\n\nconst AdminAccessTokenExpired = createKnownErrorConstructor(\n InvalidAdminAccessToken,\n \"ADMIN_ACCESS_TOKEN_EXPIRED\",\n (expiredAt: Date | undefined) => [\n 401,\n `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)`: \"\"}`,\n { expired_at_millis: expiredAt?.getTime() ?? null },\n ] as const,\n (json: any) => [json.expired_at_millis ?? undefined] as const,\n);\n\nconst InvalidProjectForAdminAccessToken = createKnownErrorConstructor(\n InvalidAdminAccessToken,\n \"INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN\",\n () => [\n 401,\n \"Admin access tokens must be created on the internal project.\",\n ] as const,\n () => [] as const,\n);\n\nconst AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(\n InvalidAdminAccessToken,\n \"ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN\",\n () => [\n 401,\n \"Admin access token does not have the required permissions to access this project.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ProjectAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationError,\n \"PROJECT_AUTHENTICATION_REQUIRED\",\n \"inherit\",\n \"inherit\",\n);\n\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ClientAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"CLIENT_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"The publishable client key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ServerAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"SERVER_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"The secret server key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ClientOrServerAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"Either the publishable client key or the secret server key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"Either the publishable client key or the super secret admin key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst ClientOrServerOrAdminAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"CLIENT_OR_SERVER_OR_ADMIN_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"Either the publishable client key, the secret server key, or the super secret admin key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\n/**\n * @deprecated Use InsufficientAccessType instead\n */\nconst AdminAuthenticationRequired = createKnownErrorConstructor(\n ProjectAuthenticationRequired,\n \"ADMIN_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"The super secret admin key must be provided.\",\n ] as const,\n () => [] as const,\n);\n\nconst ExpectedInternalProject = createKnownErrorConstructor(\n ProjectAuthenticationError,\n \"EXPECTED_INTERNAL_PROJECT\",\n () => [\n 401,\n \"The project ID is expected to be internal.\",\n ] as const,\n () => [] as const,\n);\n\nconst SessionAuthenticationError = createKnownErrorConstructor(\n KnownError,\n \"SESSION_AUTHENTICATION_ERROR\",\n \"inherit\",\n \"inherit\",\n);\n\nconst InvalidSessionAuthentication = createKnownErrorConstructor(\n SessionAuthenticationError,\n \"INVALID_SESSION_AUTHENTICATION\",\n \"inherit\",\n \"inherit\",\n);\n\nconst InvalidAccessToken = createKnownErrorConstructor(\n InvalidSessionAuthentication,\n \"INVALID_ACCESS_TOKEN\",\n \"inherit\",\n \"inherit\",\n);\n\nconst UnparsableAccessToken = createKnownErrorConstructor(\n InvalidAccessToken,\n \"UNPARSABLE_ACCESS_TOKEN\",\n () => [\n 401,\n \"Access token is not parsable.\",\n ] as const,\n () => [] as const,\n);\n\nconst AccessTokenExpired = createKnownErrorConstructor(\n InvalidAccessToken,\n \"ACCESS_TOKEN_EXPIRED\",\n (expiredAt: Date | undefined) => [\n 401,\n `Access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)`: \"\"}`,\n { expired_at_millis: expiredAt?.getTime() ?? null },\n ] as const,\n (json: any) => [json.expired_at_millis ? new Date(json.expired_at_millis) : undefined] as const,\n);\n\nconst InvalidProjectForAccessToken = createKnownErrorConstructor(\n InvalidAccessToken,\n \"INVALID_PROJECT_FOR_ACCESS_TOKEN\",\n (expectedProjectId: string, actualProjectId: string) => [\n 401,\n `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,\n {\n expected_project_id: expectedProjectId,\n actual_project_id: actualProjectId,\n },\n ] as const,\n (json: any) => [json.expected_project_id, json.actual_project_id] as const,\n);\n\n\nconst RefreshTokenError = createKnownErrorConstructor(\n KnownError,\n \"REFRESH_TOKEN_ERROR\",\n \"inherit\",\n \"inherit\",\n);\n\nconst RefreshTokenNotFoundOrExpired = createKnownErrorConstructor(\n RefreshTokenError,\n \"REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED\",\n () => [\n 401,\n \"Refresh token not found for this project, or the session has expired/been revoked.\",\n ] as const,\n () => [] as const,\n);\n\nconst CannotDeleteCurrentSession = createKnownErrorConstructor(\n RefreshTokenError,\n \"CANNOT_DELETE_CURRENT_SESSION\",\n () => [\n 400,\n \"Cannot delete the current session.\",\n ] as const,\n () => [] as const,\n);\n\n\nconst ProviderRejected = createKnownErrorConstructor(\n RefreshTokenError,\n \"PROVIDER_REJECTED\",\n () => [\n 401,\n \"The provider refused to refresh their token. This usually means that the provider used to authenticate the user no longer regards this session as valid, and the user must re-authenticate.\",\n ] as const,\n () => [] as const,\n);\n\nconst UserWithEmailAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"USER_EMAIL_ALREADY_EXISTS\",\n (email: string) => [\n 409,\n `A user with email ${JSON.stringify(email)} already exists.`,\n {\n email,\n },\n ] as const,\n (json: any) => [json.email] as const,\n);\n\nconst EmailNotVerified = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_NOT_VERIFIED\",\n () => [\n 400,\n \"The email is not verified.\",\n ] as const,\n () => [] as const,\n);\n\nconst CannotGetOwnUserWithoutUser = createKnownErrorConstructor(\n KnownError,\n \"CANNOT_GET_OWN_USER_WITHOUT_USER\",\n () => [\n 400,\n \"You have specified 'me' as a userId, but did not provide authentication for a user.\",\n ] as const,\n () => [] as const,\n);\n\nconst UserIdDoesNotExist = createKnownErrorConstructor(\n KnownError,\n \"USER_ID_DOES_NOT_EXIST\",\n (userId: string) => [\n 400,\n `The given user with the ID ${userId} does not exist.`,\n {\n user_id: userId,\n },\n ] as const,\n (json: any) => [json.user_id] as const,\n);\n\nconst UserNotFound = createKnownErrorConstructor(\n KnownError,\n \"USER_NOT_FOUND\",\n () => [\n 404,\n \"User not found.\",\n ] as const,\n () => [] as const,\n);\n\n\nconst ProjectNotFound = createKnownErrorConstructor(\n KnownError,\n \"PROJECT_NOT_FOUND\",\n (projectId: string) => {\n if (typeof projectId !== \"string\") throw new StackAssertionError(\"projectId of KnownErrors.ProjectNotFound must be a string\");\n return [\n 404,\n `Project ${projectId} not found or is not accessible with the current user.`,\n {\n project_id: projectId,\n },\n ] as const;\n },\n (json: any) => [json.project_id] as const,\n);\n\nconst SignUpNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"SIGN_UP_NOT_ENABLED\",\n () => [\n 400,\n \"Creation of new accounts is not enabled for this project. Please ask the project owner to enable it.\",\n ] as const,\n () => [] as const,\n);\n\nconst PasswordAuthenticationNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"PASSWORD_AUTHENTICATION_NOT_ENABLED\",\n () => [\n 400,\n \"Password authentication is not enabled for this project.\",\n ] as const,\n () => [] as const,\n);\n\n\nconst PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"PASSKEY_AUTHENTICATION_NOT_ENABLED\",\n () => [\n 400,\n \"Passkey authentication is not enabled for this project.\",\n ] as const,\n () => [] as const,\n);\n\nconst AnonymousAccountsNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"ANONYMOUS_ACCOUNTS_NOT_ENABLED\",\n () => [\n 400,\n \"Anonymous accounts are not enabled for this project.\",\n ] as const,\n () => [] as const,\n);\n\n\nconst EmailPasswordMismatch = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_PASSWORD_MISMATCH\",\n () => [\n 400,\n \"Wrong e-mail or password.\",\n ] as const,\n () => [] as const,\n);\n\nconst RedirectUrlNotWhitelisted = createKnownErrorConstructor(\n KnownError,\n \"REDIRECT_URL_NOT_WHITELISTED\",\n () => [\n 400,\n \"Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Stack Auth dashboard?\",\n ] as const,\n () => [] as const,\n);\n\nconst PasswordRequirementsNotMet = createKnownErrorConstructor(\n KnownError,\n \"PASSWORD_REQUIREMENTS_NOT_MET\",\n \"inherit\",\n \"inherit\",\n);\n\nconst PasswordTooShort = createKnownErrorConstructor(\n PasswordRequirementsNotMet,\n \"PASSWORD_TOO_SHORT\",\n (minLength: number) => [\n 400,\n `Password too short. Minimum length is ${minLength}.`,\n {\n min_length: minLength,\n },\n ] as const,\n (json) => [\n (json as any)?.min_length ?? throwErr(\"min_length not found in PasswordTooShort details\"),\n ] as const,\n);\n\nconst PasswordTooLong = createKnownErrorConstructor(\n PasswordRequirementsNotMet,\n \"PASSWORD_TOO_LONG\",\n (maxLength: number) => [\n 400,\n `Password too long. Maximum length is ${maxLength}.`,\n {\n maxLength,\n },\n ] as const,\n (json) => [\n (json as any)?.maxLength ?? throwErr(\"maxLength not found in PasswordTooLong details\"),\n ] as const,\n);\n\nconst UserDoesNotHavePassword = createKnownErrorConstructor(\n KnownError,\n \"USER_DOES_NOT_HAVE_PASSWORD\",\n () => [\n 400,\n \"This user does not have password authentication enabled.\",\n ] as const,\n () => [] as const,\n);\n\nconst VerificationCodeError = createKnownErrorConstructor(\n KnownError,\n \"VERIFICATION_ERROR\",\n \"inherit\",\n \"inherit\",\n);\n\nconst VerificationCodeNotFound = createKnownErrorConstructor(\n VerificationCodeError,\n \"VERIFICATION_CODE_NOT_FOUND\",\n () => [\n 404,\n \"The verification code does not exist for this project.\",\n ] as const,\n () => [] as const,\n);\n\nconst VerificationCodeExpired = createKnownErrorConstructor(\n VerificationCodeError,\n \"VERIFICATION_CODE_EXPIRED\",\n () => [\n 400,\n \"The verification code has expired.\",\n ] as const,\n () => [] as const,\n);\n\nconst VerificationCodeAlreadyUsed = createKnownErrorConstructor(\n VerificationCodeError,\n \"VERIFICATION_CODE_ALREADY_USED\",\n () => [\n 409,\n \"The verification link has already been used.\",\n ] as const,\n () => [] as const,\n);\n\nconst VerificationCodeMaxAttemptsReached = createKnownErrorConstructor(\n VerificationCodeError,\n \"VERIFICATION_CODE_MAX_ATTEMPTS_REACHED\",\n () => [\n 400,\n \"The verification code nonce has reached the maximum number of attempts. This code is not valid anymore.\",\n ] as const,\n () => [] as const,\n);\n\nconst PasswordConfirmationMismatch = createKnownErrorConstructor(\n KnownError,\n \"PASSWORD_CONFIRMATION_MISMATCH\",\n () => [\n 400,\n \"Passwords do not match.\",\n ] as const,\n () => [] as const,\n);\n\nconst EmailAlreadyVerified = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_ALREADY_VERIFIED\",\n () => [\n 409,\n \"The e-mail is already verified.\",\n ] as const,\n () => [] as const,\n);\n\nconst EmailNotAssociatedWithUser = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_NOT_ASSOCIATED_WITH_USER\",\n () => [\n 400,\n \"The e-mail is not associated with a user that could log in with that e-mail.\",\n ] as const,\n () => [] as const,\n);\n\nconst EmailIsNotPrimaryEmail = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_IS_NOT_PRIMARY_EMAIL\",\n (email: string, primaryEmail: string | null) => [\n 400,\n `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,\n {\n email,\n primary_email: primaryEmail,\n },\n ] as const,\n (json: any) => [json.email, json.primary_email] as const,\n);\n\n\nconst PasskeyRegistrationFailed = createKnownErrorConstructor(\n KnownError,\n \"PASSKEY_REGISTRATION_FAILED\",\n (message: string) => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\n\nconst PasskeyWebAuthnError = createKnownErrorConstructor(\n KnownError,\n \"PASSKEY_WEBAUTHN_ERROR\",\n (message: string, code: string) => [\n 400,\n message,\n {\n message,\n code,\n },\n ] as const,\n (json: any) => [json.message, json.code] as const,\n);\n\nconst PasskeyAuthenticationFailed = createKnownErrorConstructor(\n KnownError,\n \"PASSKEY_AUTHENTICATION_FAILED\",\n (message: string) => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\n\nconst PermissionNotFound = createKnownErrorConstructor(\n KnownError,\n \"PERMISSION_NOT_FOUND\",\n (permissionId: string) => [\n 404,\n `Permission \"${permissionId}\" not found. Make sure you created it on the dashboard.`,\n {\n permission_id: permissionId,\n },\n ] as const,\n (json: any) => [json.permission_id] as const,\n);\n\nconst PermissionScopeMismatch = createKnownErrorConstructor(\n KnownError,\n \"WRONG_PERMISSION_SCOPE\",\n (permissionId: string, expectedScope: \"team\" | \"project\", actualScope: \"team\" | \"project\" | null) => [\n 404,\n `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,\n {\n permission_id: permissionId,\n expected_scope: expectedScope,\n actual_scope: actualScope,\n },\n ] as const,\n (json: any) => [json.permission_id, json.expected_scope, json.actual_scope] as const,\n);\n\nconst ContainedPermissionNotFound = createKnownErrorConstructor(\n KnownError,\n \"CONTAINED_PERMISSION_NOT_FOUND\",\n (permissionId: string) => [\n 400,\n `Contained permission with ID \"${permissionId}\" not found. Make sure you created it on the dashboard.`,\n {\n permission_id: permissionId,\n },\n ] as const,\n (json: any) => [json.permission_id] as const,\n);\n\nconst TeamNotFound = createKnownErrorConstructor(\n KnownError,\n \"TEAM_NOT_FOUND\",\n (teamId: string) => [\n 404,\n `Team ${teamId} not found.`,\n {\n team_id: teamId,\n },\n ] as const,\n (json: any) => [json.team_id] as const,\n);\n\nconst TeamAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"TEAM_ALREADY_EXISTS\",\n (teamId: string) => [\n 409,\n `Team ${teamId} already exists.`,\n {\n team_id: teamId,\n },\n ] as const,\n (json: any) => [json.team_id] as const,\n);\n\nconst TeamMembershipNotFound = createKnownErrorConstructor(\n KnownError,\n \"TEAM_MEMBERSHIP_NOT_FOUND\",\n (teamId: string, userId: string) => [\n 404,\n `User ${userId} is not found in team ${teamId}.`,\n {\n team_id: teamId,\n user_id: userId,\n },\n ] as const,\n (json: any) => [json.team_id, json.user_id] as const,\n);\n\n\nconst EmailTemplateAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"EMAIL_TEMPLATE_ALREADY_EXISTS\",\n () => [\n 409,\n \"Email template already exists.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_CONNECTION_NOT_CONNECTED_TO_USER\",\n () => [\n 400,\n \"The OAuth connection is not connected to any user.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER\",\n () => [\n 409,\n \"The OAuth connection is already connected to another user.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE\",\n () => [\n 400,\n \"The OAuth connection does not have the required scope.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthExtraScopeNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_EXTRA_SCOPE_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS\",\n () => [\n 400,\n \"Extra scopes are not available with shared OAuth keys. Please add your own OAuth keys on the Stack dashboard to use extra scopes.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthAccessTokenNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_ACCESS_TOKEN_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS\",\n () => [\n 400,\n \"Access tokens are not available with shared OAuth keys. Please add your own OAuth keys on the Stack dashboard to use access tokens.\",\n ] as const,\n () => [] as const,\n);\n\nconst InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(\n KnownError,\n \"INVALID_OAUTH_CLIENT_ID_OR_SECRET\",\n (clientId?: string) => [\n 400,\n \"The OAuth client ID or secret is invalid. The client ID must be equal to the project ID, and the client secret must be a publishable client key.\",\n {\n client_id: clientId ?? null,\n },\n ] as const,\n (json: any) => [json.client_id ?? undefined] as const,\n);\n\nconst InvalidScope = createKnownErrorConstructor(\n KnownError,\n \"INVALID_SCOPE\",\n (scope: string) => [\n 400,\n `The scope \"${scope}\" is not a valid OAuth scope for Stack.`,\n ] as const,\n (json: any) => [json.scope] as const,\n);\n\nconst UserAlreadyConnectedToAnotherOAuthConnection = createKnownErrorConstructor(\n KnownError,\n \"USER_ALREADY_CONNECTED_TO_ANOTHER_OAUTH_CONNECTION\",\n () => [\n 409,\n \"The user is already connected to another OAuth account. Did you maybe selected the wrong account?\",\n ] as const,\n () => [] as const,\n);\n\nconst OuterOAuthTimeout = createKnownErrorConstructor(\n KnownError,\n \"OUTER_OAUTH_TIMEOUT\",\n () => [\n 408,\n \"The OAuth flow has timed out. Please sign in again.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED\",\n () => [\n 400,\n \"The OAuth provider is not found or not enabled.\",\n ] as const,\n () => [] as const,\n);\n\nconst MultiFactorAuthenticationRequired = createKnownErrorConstructor(\n KnownError,\n \"MULTI_FACTOR_AUTHENTICATION_REQUIRED\",\n (attemptCode: string) => [\n 400,\n `Multi-factor authentication is required for this user.`,\n {\n attempt_code: attemptCode,\n },\n ] as const,\n (json) => [json.attempt_code] as const,\n);\n\nconst InvalidTotpCode = createKnownErrorConstructor(\n KnownError,\n \"INVALID_TOTP_CODE\",\n () => [\n 400,\n \"The TOTP code is invalid. Please try again.\",\n ] as const,\n () => [] as const,\n);\n\nconst UserAuthenticationRequired = createKnownErrorConstructor(\n KnownError,\n \"USER_AUTHENTICATION_REQUIRED\",\n () => [\n 401,\n \"User authentication required for this endpoint.\",\n ] as const,\n () => [] as const,\n);\n\nconst TeamMembershipAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"TEAM_MEMBERSHIP_ALREADY_EXISTS\",\n () => [\n 409,\n \"Team membership already exists.\",\n ] as const,\n () => [] as const,\n);\n\nconst ProjectPermissionRequired = createKnownErrorConstructor(\n KnownError,\n \"PROJECT_PERMISSION_REQUIRED\",\n (userId, permissionId) => [\n 401,\n `User ${userId} does not have permission ${permissionId}.`,\n {\n user_id: userId,\n permission_id: permissionId,\n },\n ] as const,\n (json) => [json.user_id, json.permission_id] as const,\n);\n\nconst TeamPermissionRequired = createKnownErrorConstructor(\n KnownError,\n \"TEAM_PERMISSION_REQUIRED\",\n (teamId, userId, permissionId) => [\n 401,\n `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,\n {\n team_id: teamId,\n user_id: userId,\n permission_id: permissionId,\n },\n ] as const,\n (json) => [json.team_id, json.user_id, json.permission_id] as const,\n);\n\nconst TeamPermissionNotFound = createKnownErrorConstructor(\n KnownError,\n \"TEAM_PERMISSION_NOT_FOUND\",\n (teamId, userId, permissionId) => [\n 401,\n `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,\n {\n team_id: teamId,\n user_id: userId,\n permission_id: permissionId,\n },\n ] as const,\n (json) => [json.team_id, json.user_id, json.permission_id] as const,\n);\n\nconst InvalidSharedOAuthProviderId = createKnownErrorConstructor(\n KnownError,\n \"INVALID_SHARED_OAUTH_PROVIDER_ID\",\n (providerId) => [\n 400,\n `The shared OAuth provider with ID ${providerId} is not valid.`,\n {\n provider_id: providerId,\n },\n ] as const,\n (json) => [json.provider_id] as const,\n);\n\nconst InvalidStandardOAuthProviderId = createKnownErrorConstructor(\n KnownError,\n \"INVALID_STANDARD_OAUTH_PROVIDER_ID\",\n (providerId) => [\n 400,\n `The standard OAuth provider with ID ${providerId} is not valid.`,\n {\n provider_id: providerId,\n },\n ] as const,\n (json) => [json.provider_id] as const,\n);\n\nconst InvalidAuthorizationCode = createKnownErrorConstructor(\n KnownError,\n \"INVALID_AUTHORIZATION_CODE\",\n () => [\n 400,\n \"The given authorization code is invalid.\",\n ] as const,\n () => [] as const,\n);\n\nconst OAuthProviderAccessDenied = createKnownErrorConstructor(\n KnownError,\n \"OAUTH_PROVIDER_ACCESS_DENIED\",\n () => [\n 400,\n \"The OAuth provider denied access to the user.\",\n ] as const,\n () => [] as const,\n);\n\nconst ContactChannelAlreadyUsedForAuthBySomeoneElse = createKnownErrorConstructor(\n KnownError,\n \"CONTACT_CHANNEL_ALREADY_USED_FOR_AUTH_BY_SOMEONE_ELSE\",\n (type: \"email\", contactChannelValue?: string) => [\n 409,\n contactChannelValue ?\n `The ${type} (${contactChannelValue}) is already used for authentication by another account.` :\n `This ${type} is already used for authentication by another account.`,\n { type, contact_channel_value: contactChannelValue ?? null },\n ] as const,\n (json) => [json.type, json.contact_channel_value] as const,\n);\n\nconst InvalidPollingCodeError = createKnownErrorConstructor(\n KnownError,\n \"INVALID_POLLING_CODE\",\n (details?: Json) => [\n 400,\n \"The polling code is invalid or does not exist.\",\n details,\n ] as const,\n (json: any) => [json] as const,\n);\n\nconst CliAuthError = createKnownErrorConstructor(\n KnownError,\n \"CLI_AUTH_ERROR\",\n (message: string) => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\nconst CliAuthExpiredError = createKnownErrorConstructor(\n KnownError,\n \"CLI_AUTH_EXPIRED_ERROR\",\n (message: string = \"CLI authentication request expired. Please try again.\") => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\nconst CliAuthUsedError = createKnownErrorConstructor(\n KnownError,\n \"CLI_AUTH_USED_ERROR\",\n (message: string = \"This authentication token has already been used.\") => [\n 400,\n message,\n ] as const,\n (json: any) => [json.message] as const,\n);\n\n\nconst ApiKeyNotValid = createKnownErrorConstructor(\n KnownError,\n \"API_KEY_NOT_VALID\",\n \"inherit\",\n \"inherit\",\n);\n\nconst ApiKeyExpired = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"API_KEY_EXPIRED\",\n () => [\n 401,\n \"API key has expired.\",\n ] as const,\n () => [] as const,\n);\n\nconst ApiKeyRevoked = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"API_KEY_REVOKED\",\n () => [\n 401,\n \"API key has been revoked.\",\n ] as const,\n () => [] as const,\n);\n\nconst WrongApiKeyType = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"WRONG_API_KEY_TYPE\",\n (expectedType: string, actualType: string) => [\n 400,\n `This endpoint is for ${expectedType} API keys, but a ${actualType} API key was provided.`,\n { expected_type: expectedType, actual_type: actualType },\n ] as const,\n (json) => [json.expected_type, json.actual_type] as const,\n);\n\nconst ApiKeyNotFound = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"API_KEY_NOT_FOUND\",\n () => [\n 404,\n \"API key not found.\",\n ] as const,\n () => [] as const,\n);\n\nconst PublicApiKeyCannotBeRevoked = createKnownErrorConstructor(\n ApiKeyNotValid,\n \"PUBLIC_API_KEY_CANNOT_BE_REVOKED\",\n () => [\n 400,\n \"Public API keys cannot be revoked by the secretscanner endpoint.\",\n ] as const,\n () => [] as const,\n);\n\nconst PermissionIdAlreadyExists = createKnownErrorConstructor(\n KnownError,\n \"PERMISSION_ID_ALREADY_EXISTS\",\n (permissionId: string) => [\n 400,\n `Permission with ID \"${permissionId}\" already exists. Choose a different ID.`,\n {\n permission_id: permissionId,\n },\n ] as const,\n (json: any) => [json.permission_id] as const,\n);\n\nexport type KnownErrors = {\n [K in keyof typeof KnownErrors]: InstanceType<typeof KnownErrors[K]>;\n};\n\nexport const KnownErrors = {\n CannotDeleteCurrentSession,\n UnsupportedError,\n BodyParsingError,\n SchemaError,\n AllOverloadsFailed,\n ProjectAuthenticationError,\n PermissionIdAlreadyExists,\n CliAuthError,\n CliAuthExpiredError,\n CliAuthUsedError,\n InvalidProjectAuthentication,\n ProjectKeyWithoutAccessType,\n InvalidAccessType,\n AccessTypeWithoutProjectId,\n AccessTypeRequired,\n CannotGetOwnUserWithoutUser,\n InsufficientAccessType,\n InvalidPublishableClientKey,\n InvalidSecretServerKey,\n InvalidSuperSecretAdminKey,\n InvalidAdminAccessToken,\n UnparsableAdminAccessToken,\n AdminAccessTokenExpired,\n InvalidProjectForAdminAccessToken,\n AdminAccessTokenIsNotAdmin,\n ProjectAuthenticationRequired,\n ClientAuthenticationRequired,\n ServerAuthenticationRequired,\n ClientOrServerAuthenticationRequired,\n ClientOrAdminAuthenticationRequired,\n ClientOrServerOrAdminAuthenticationRequired,\n AdminAuthenticationRequired,\n ExpectedInternalProject,\n SessionAuthenticationError,\n InvalidSessionAuthentication,\n InvalidAccessToken,\n UnparsableAccessToken,\n AccessTokenExpired,\n InvalidProjectForAccessToken,\n RefreshTokenError,\n ProviderRejected,\n RefreshTokenNotFoundOrExpired,\n UserWithEmailAlreadyExists,\n EmailNotVerified,\n UserIdDoesNotExist,\n UserNotFound,\n ApiKeyNotFound,\n PublicApiKeyCannotBeRevoked,\n ProjectNotFound,\n SignUpNotEnabled,\n PasswordAuthenticationNotEnabled,\n PasskeyAuthenticationNotEnabled,\n AnonymousAccountsNotEnabled,\n EmailPasswordMismatch,\n RedirectUrlNotWhitelisted,\n PasswordRequirementsNotMet,\n PasswordTooShort,\n PasswordTooLong,\n UserDoesNotHavePassword,\n VerificationCodeError,\n VerificationCodeNotFound,\n VerificationCodeExpired,\n VerificationCodeAlreadyUsed,\n VerificationCodeMaxAttemptsReached,\n PasswordConfirmationMismatch,\n EmailAlreadyVerified,\n EmailNotAssociatedWithUser,\n EmailIsNotPrimaryEmail,\n PasskeyRegistrationFailed,\n PasskeyWebAuthnError,\n PasskeyAuthenticationFailed,\n PermissionNotFound,\n PermissionScopeMismatch,\n ContainedPermissionNotFound,\n TeamNotFound,\n TeamMembershipNotFound,\n EmailTemplateAlreadyExists,\n OAuthConnectionNotConnectedToUser,\n OAuthConnectionAlreadyConnectedToAnotherUser,\n OAuthConnectionDoesNotHaveRequiredScope,\n OAuthExtraScopeNotAvailableWithSharedOAuthKeys,\n OAuthAccessTokenNotAvailableWithSharedOAuthKeys,\n InvalidOAuthClientIdOrSecret,\n InvalidScope,\n UserAlreadyConnectedToAnotherOAuthConnection,\n OuterOAuthTimeout,\n OAuthProviderNotFoundOrNotEnabled,\n MultiFactorAuthenticationRequired,\n InvalidTotpCode,\n UserAuthenticationRequired,\n TeamMembershipAlreadyExists,\n ProjectPermissionRequired,\n TeamPermissionRequired,\n InvalidSharedOAuthProviderId,\n InvalidStandardOAuthProviderId,\n InvalidAuthorizationCode,\n TeamPermissionNotFound,\n OAuthProviderAccessDenied,\n ContactChannelAlreadyUsedForAuthBySomeoneElse,\n InvalidPollingCodeError,\n ApiKeyNotValid,\n ApiKeyExpired,\n ApiKeyRevoked,\n WrongApiKeyType,\n} satisfies Record<string, KnownErrorConstructor<any, any>>;\n\n\n// ensure that all known error codes are unique\nconst knownErrorCodes = new Set<string>();\nfor (const [_, KnownError] of Object.entries(KnownErrors)) {\n if (knownErrorCodes.has(KnownError.errorCode)) {\n throw new Error(`Duplicate known error code: ${KnownError.errorCode}`);\n }\n knownErrorCodes.add(KnownError.errorCode);\n}\n"],"mappings":";AAAA,SAAS,qBAAqB,aAAa,gBAAgB;AAC3D,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AAoBlB,IAAe,aAAf,cAAkC,YAAY;AAAA,EAGnD,YACkB,YACA,sBACA,SAChB;AACA;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAPgB;AACA;AACA;AALlB,SAAO,OAAO;AAAA,EAWd;AAAA,EAEgB,UAAsB;AACpC,WAAO,IAAI,YAAY,EAAE,OAAO,KAAK,UAAU,KAAK,kBAAkB,GAAG,QAAW,CAAC,CAAC;AAAA,EACxF;AAAA,EAEgB,aAAuC;AACrD,WAAO;AAAA,MACL,gBAAgB,CAAC,iCAAiC;AAAA,MAClD,uBAAuB,CAAC,KAAK,SAAS;AAAA,IACxC;AAAA,EACF;AAAA,EAEgB,oBAA0B;AACxC,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,GAAG,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,MAC/C,OAAO,KAAK;AAAA,IACd;AAAA,EACF;AAAA,EAEA,IAAI,YAAoB;AACtB,WAAQ,KAAK,YAAoB,aAAa,SAAS,0FAA0F,IAAI,EAAE;AAAA,EACzJ;AAAA,EAEA,OAAc,wBAAwB,MAAgE;AACpG,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AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIA,IAAM,kBAAkB,oBAAI,IAAY;AACxC,WAAW,CAAC,GAAGA,WAAU,KAAK,OAAO,QAAQ,WAAW,GAAG;AACzD,MAAI,gBAAgB,IAAIA,YAAW,SAAS,GAAG;AAC7C,UAAM,IAAI,MAAM,+BAA+BA,YAAW,SAAS,EAAE;AAAA,EACvE;AACA,kBAAgB,IAAIA,YAAW,SAAS;AAC1C;","names":["KnownError"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/utils/objects.tsx
|
|
2
2
|
import { StackAssertionError } from "./errors";
|
|
3
3
|
import { identity } from "./functions";
|
|
4
|
+
import { stringCompare } from "./strings";
|
|
4
5
|
function isNotNull(value) {
|
|
5
6
|
return value !== null && value !== void 0;
|
|
6
7
|
}
|
|
@@ -96,11 +97,27 @@ function pick(obj, keys) {
|
|
|
96
97
|
return Object.fromEntries(Object.entries(obj).filter(([k]) => keys.includes(k)));
|
|
97
98
|
}
|
|
98
99
|
function omit(obj, keys) {
|
|
100
|
+
if (!Array.isArray(keys)) throw new StackAssertionError("omit: keys must be an array", { obj, keys });
|
|
99
101
|
return Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k)));
|
|
100
102
|
}
|
|
101
103
|
function split(obj, keys) {
|
|
102
104
|
return [pick(obj, keys), omit(obj, keys)];
|
|
103
105
|
}
|
|
106
|
+
function mapValues(obj, fn) {
|
|
107
|
+
if (Array.isArray(obj)) {
|
|
108
|
+
return obj.map((v) => fn(v));
|
|
109
|
+
}
|
|
110
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn(v)]));
|
|
111
|
+
}
|
|
112
|
+
function sortKeys(obj) {
|
|
113
|
+
if (Array.isArray(obj)) {
|
|
114
|
+
return [...obj];
|
|
115
|
+
}
|
|
116
|
+
return Object.fromEntries(Object.entries(obj).sort(([a], [b]) => stringCompare(a, b)));
|
|
117
|
+
}
|
|
118
|
+
function deepSortKeys(obj) {
|
|
119
|
+
return sortKeys(mapValues(obj, (v) => isObjectLike(v) ? deepSortKeys(v) : v));
|
|
120
|
+
}
|
|
104
121
|
function set(obj, key, value) {
|
|
105
122
|
Object.defineProperty(obj, key, { value, writable: true, configurable: true, enumerable: true });
|
|
106
123
|
}
|
|
@@ -109,6 +126,9 @@ function get(obj, key) {
|
|
|
109
126
|
if (!descriptor) throw new StackAssertionError(`get: key ${String(key)} does not exist`, { obj, key });
|
|
110
127
|
return descriptor.value;
|
|
111
128
|
}
|
|
129
|
+
function getOrUndefined(obj, key) {
|
|
130
|
+
return has(obj, key) ? get(obj, key) : void 0;
|
|
131
|
+
}
|
|
112
132
|
function has(obj, key) {
|
|
113
133
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
114
134
|
}
|
|
@@ -130,19 +150,23 @@ export {
|
|
|
130
150
|
deepMerge,
|
|
131
151
|
deepPlainClone,
|
|
132
152
|
deepPlainEquals,
|
|
153
|
+
deepSortKeys,
|
|
133
154
|
deleteKey,
|
|
134
155
|
filterUndefined,
|
|
135
156
|
filterUndefinedOrNull,
|
|
136
157
|
get,
|
|
158
|
+
getOrUndefined,
|
|
137
159
|
has,
|
|
138
160
|
hasAndNotUndefined,
|
|
139
161
|
isCloneable,
|
|
140
162
|
isNotNull,
|
|
141
163
|
isObjectLike,
|
|
164
|
+
mapValues,
|
|
142
165
|
omit,
|
|
143
166
|
pick,
|
|
144
167
|
set,
|
|
145
168
|
shallowClone,
|
|
169
|
+
sortKeys,
|
|
146
170
|
split,
|
|
147
171
|
typedAssign,
|
|
148
172
|
typedEntries,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/objects.tsx"],"sourcesContent":["import { StackAssertionError } from \"./errors\";\nimport { identity } from \"./functions\";\n\nexport function isNotNull<T>(value: T): value is NonNullable<T> {\n return value !== null && value !== undefined;\n}\nundefined?.test(\"isNotNull\", ({ expect }) => {\n expect(isNotNull(null)).toBe(false);\n expect(isNotNull(undefined)).toBe(false);\n expect(isNotNull(0)).toBe(true);\n expect(isNotNull(\"\")).toBe(true);\n expect(isNotNull(false)).toBe(true);\n expect(isNotNull({})).toBe(true);\n expect(isNotNull([])).toBe(true);\n});\n\nexport type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;\nexport type DeepRequired<T> = T extends object ? { [P in keyof T]-?: DeepRequired<T[P]> } : T;\n\n/**\n * Assumes both objects are primitives, arrays, or non-function plain objects, and compares them deeply.\n *\n * Note that since they are assumed to be plain objects, this function does not compare prototypes.\n */\nexport function deepPlainEquals<T>(obj1: T, obj2: unknown, options: { ignoreUndefinedValues?: boolean } = {}): obj2 is T {\n if (typeof obj1 !== typeof obj2) return false;\n if (obj1 === obj2) return true;\n\n switch (typeof obj1) {\n case 'object': {\n if (!obj1 || !obj2) return false;\n\n if (Array.isArray(obj1) || Array.isArray(obj2)) {\n if (!Array.isArray(obj1) || !Array.isArray(obj2)) return false;\n if (obj1.length !== obj2.length) return false;\n return obj1.every((v, i) => deepPlainEquals(v, obj2[i], options));\n }\n\n const entries1 = Object.entries(obj1).filter(([k, v]) => !options.ignoreUndefinedValues || v !== undefined);\n const entries2 = Object.entries(obj2).filter(([k, v]) => !options.ignoreUndefinedValues || v !== undefined);\n if (entries1.length !== entries2.length) return false;\n return entries1.every(([k, v1]) => {\n const e2 = entries2.find(([k2]) => k === k2);\n if (!e2) return false;\n return deepPlainEquals(v1, e2[1], options);\n });\n }\n case 'undefined':\n case 'string':\n case 'number':\n case 'boolean':\n case 'bigint':\n case 'symbol':\n case 'function':{\n return false;\n }\n default: {\n throw new Error(\"Unexpected typeof \" + typeof obj1);\n }\n }\n}\nundefined?.test(\"deepPlainEquals\", ({ expect }) => {\n // Simple values\n expect(deepPlainEquals(1, 1)).toBe(true);\n expect(deepPlainEquals(\"test\", \"test\")).toBe(true);\n expect(deepPlainEquals(1, 2)).toBe(false);\n expect(deepPlainEquals(\"test\", \"other\")).toBe(false);\n\n // Arrays\n expect(deepPlainEquals([1, 2, 3], [1, 2, 3])).toBe(true);\n expect(deepPlainEquals([1, 2, 3], [1, 2, 4])).toBe(false);\n expect(deepPlainEquals([1, 2, 3], [1, 2])).toBe(false);\n\n // Objects\n expect(deepPlainEquals({ a: 1, b: 2 }, { a: 1, b: 2 })).toBe(true);\n expect(deepPlainEquals({ a: 1, b: 2 }, { a: 1, b: 3 })).toBe(false);\n expect(deepPlainEquals({ a: 1, b: 2 }, { a: 1 })).toBe(false);\n\n // Nested structures\n expect(deepPlainEquals({ a: 1, b: [1, 2, { c: 3 }] }, { a: 1, b: [1, 2, { c: 3 }] })).toBe(true);\n expect(deepPlainEquals({ a: 1, b: [1, 2, { c: 3 }] }, { a: 1, b: [1, 2, { c: 4 }] })).toBe(false);\n\n // With options\n expect(deepPlainEquals({ a: 1, b: undefined }, { a: 1 }, { ignoreUndefinedValues: true })).toBe(true);\n expect(deepPlainEquals({ a: 1, b: undefined }, { a: 1 })).toBe(false);\n});\n\nexport function isCloneable<T>(obj: T): obj is Exclude<T, symbol | Function> {\n return typeof obj !== 'symbol' && typeof obj !== 'function';\n}\n\nexport function shallowClone<T extends object>(obj: T): T {\n if (!isCloneable(obj)) throw new StackAssertionError(\"shallowClone does not support symbols or functions\", { obj });\n\n if (Array.isArray(obj)) return obj.map(identity) as T;\n return { ...obj };\n}\nundefined?.test(\"shallowClone\", ({ expect }) => {\n expect(shallowClone({ a: 1, b: 2 })).toEqual({ a: 1, b: 2 });\n expect(shallowClone([1, 2, 3])).toEqual([1, 2, 3]);\n expect(() => shallowClone(() => {})).toThrow();\n});\n\nexport function deepPlainClone<T>(obj: T): T {\n if (typeof obj === 'function') throw new StackAssertionError(\"deepPlainClone does not support functions\");\n if (typeof obj === 'symbol') throw new StackAssertionError(\"deepPlainClone does not support symbols\");\n if (typeof obj !== 'object' || !obj) return obj;\n if (Array.isArray(obj)) return obj.map(deepPlainClone) as any;\n return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, deepPlainClone(v)])) as any;\n}\nundefined?.test(\"deepPlainClone\", ({ expect }) => {\n // Primitive values\n expect(deepPlainClone(1)).toBe(1);\n expect(deepPlainClone(\"test\")).toBe(\"test\");\n expect(deepPlainClone(null)).toBe(null);\n expect(deepPlainClone(undefined)).toBe(undefined);\n\n // Arrays\n const arr = [1, 2, 3];\n const clonedArr = deepPlainClone(arr);\n expect(clonedArr).toEqual(arr);\n expect(clonedArr).not.toBe(arr); // Different reference\n\n // Objects\n const obj = { a: 1, b: 2 };\n const clonedObj = deepPlainClone(obj);\n expect(clonedObj).toEqual(obj);\n expect(clonedObj).not.toBe(obj); // Different reference\n\n // Nested structures\n const nested = { a: 1, b: [1, 2, { c: 3 }] };\n const clonedNested = deepPlainClone(nested);\n expect(clonedNested).toEqual(nested);\n expect(clonedNested).not.toBe(nested); // Different reference\n expect(clonedNested.b).not.toBe(nested.b); // Different reference for nested array\n expect(clonedNested.b[2]).not.toBe(nested.b[2]); // Different reference for nested object\n\n // Error cases\n expect(() => deepPlainClone(() => {})).toThrow();\n expect(() => deepPlainClone(Symbol())).toThrow();\n});\n\nexport type DeepMerge<T, U> = Omit<T, keyof U> & Omit<U, keyof T> & DeepMergeInner<Pick<T, keyof U & keyof T>, Pick<U, keyof U & keyof T>>;\ntype DeepMergeInner<T, U> = {\n [K in keyof U]-?:\n undefined extends U[K]\n ? K extends keyof T\n ? T[K] extends object\n ? Exclude<U[K], undefined> extends object\n ? DeepMerge<T[K], Exclude<U[K], undefined>>\n : T[K] | Exclude<U[K], undefined>\n : T[K] | Exclude<U[K], undefined>\n : Exclude<U[K], undefined>\n : K extends keyof T\n ? T[K] extends object\n ? U[K] extends object\n ? DeepMerge<T[K], U[K]>\n : U[K]\n : U[K]\n : U[K];\n};\nexport function deepMerge<T extends {}, U extends {}>(baseObj: T, mergeObj: U): DeepMerge<T, U> {\n if ([baseObj, mergeObj, ...Object.values(baseObj), ...Object.values(mergeObj)].some(o => !isCloneable(o))) throw new StackAssertionError(\"deepMerge does not support functions or symbols\", { baseObj, mergeObj });\n\n const res: any = shallowClone(baseObj);\n for (const [key, mergeValue] of Object.entries(mergeObj)) {\n if (has(res, key as any)) {\n const baseValue = get(res, key as any);\n if (isObjectLike(baseValue) && isObjectLike(mergeValue)) {\n set(res, key, deepMerge(baseValue, mergeValue));\n continue;\n }\n }\n set(res, key, mergeValue);\n }\n return res as any;\n}\nundefined?.test(\"deepMerge\", ({ expect }) => {\n // Test merging flat objects\n expect(deepMerge({ a: 1 }, { b: 2 })).toEqual({ a: 1, b: 2 });\n expect(deepMerge({ a: 1 }, { a: 2 })).toEqual({ a: 2 });\n expect(deepMerge({ a: 1, b: 2 }, { b: 3, c: 4 })).toEqual({ a: 1, b: 3, c: 4 });\n\n // Test with nested objects\n expect(deepMerge(\n { a: { x: 1, y: 2 }, b: 3 },\n { a: { y: 3, z: 4 }, c: 5 }\n )).toEqual({ a: { x: 1, y: 3, z: 4 }, b: 3, c: 5 });\n\n // Test with arrays\n expect(deepMerge(\n { a: [1, 2], b: 3 },\n { a: [3, 4], c: 5 }\n )).toEqual({ a: [3, 4], b: 3, c: 5 });\n\n // Test with null values\n expect(deepMerge(\n { a: { x: 1 }, b: null },\n { a: { y: 2 }, b: { z: 3 } }\n )).toEqual({ a: { x: 1, y: 2 }, b: { z: 3 } });\n\n // Test with undefined values\n expect(deepMerge(\n { a: 1, b: undefined },\n { b: 2, c: 3 }\n )).toEqual({ a: 1, b: 2, c: 3 });\n\n // Test deeply nested structures\n expect(deepMerge(\n {\n a: {\n x: { deep: 1 },\n y: [1, 2]\n },\n b: 2\n },\n {\n a: {\n x: { deeper: 3 },\n y: [3, 4]\n },\n c: 3\n }\n )).toEqual({\n a: {\n x: { deep: 1, deeper: 3 },\n y: [3, 4]\n },\n b: 2,\n c: 3\n });\n\n // Test with empty objects\n expect(deepMerge({}, { a: 1 })).toEqual({ a: 1 });\n expect(deepMerge({ a: 1 }, {})).toEqual({ a: 1 });\n expect(deepMerge({}, {})).toEqual({});\n\n // Test that original objects are not modified\n const base = { a: { x: 1 }, b: 2 };\n const merge = { a: { y: 2 }, c: 3 };\n const baseClone = deepPlainClone(base);\n const mergeClone = deepPlainClone(merge);\n\n const result = deepMerge(base, merge);\n expect(base).toEqual(baseClone);\n expect(merge).toEqual(mergeClone);\n expect(result).toEqual({ a: { x: 1, y: 2 }, b: 2, c: 3 });\n\n // Test error cases\n expect(() => deepMerge({ a: () => {} }, { b: 2 })).toThrow();\n expect(() => deepMerge({ a: 1 }, { b: () => {} })).toThrow();\n expect(() => deepMerge({ a: Symbol() }, { b: 2 })).toThrow();\n expect(() => deepMerge({ a: 1 }, { b: Symbol() })).toThrow();\n});\n\nexport function typedEntries<T extends {}>(obj: T): [keyof T, T[keyof T]][] {\n return Object.entries(obj) as any;\n}\nundefined?.test(\"typedEntries\", ({ expect }) => {\n expect(typedEntries({})).toEqual([]);\n expect(typedEntries({ a: 1, b: 2 })).toEqual([[\"a\", 1], [\"b\", 2]]);\n expect(typedEntries({ a: \"hello\", b: true, c: null })).toEqual([[\"a\", \"hello\"], [\"b\", true], [\"c\", null]]);\n\n // Test with object containing methods\n const objWithMethod = { a: 1, b: () => \"test\" };\n const entries = typedEntries(objWithMethod);\n expect(entries.length).toBe(2);\n expect(entries[0][0]).toBe(\"a\");\n expect(entries[0][1]).toBe(1);\n expect(entries[1][0]).toBe(\"b\");\n expect(typeof entries[1][1]).toBe(\"function\");\n});\n\nexport function typedFromEntries<K extends PropertyKey, V>(entries: (readonly [K, V])[]): Record<K, V> {\n return Object.fromEntries(entries) as any;\n}\nundefined?.test(\"typedFromEntries\", ({ expect }) => {\n expect(typedFromEntries([])).toEqual({});\n expect(typedFromEntries([[\"a\", 1], [\"b\", 2]])).toEqual({ a: 1, b: 2 });\n\n // Test with mixed types (using type assertion)\n const mixedEntries = [[\"a\", \"hello\"], [\"b\", true], [\"c\", null]] as [string, string | boolean | null][];\n const mixedObj = typedFromEntries(mixedEntries);\n expect(mixedObj).toEqual({ a: \"hello\", b: true, c: null });\n\n // Test with function values\n const fn = () => \"test\";\n type MixedValue = number | (() => string);\n const fnEntries: [string, MixedValue][] = [[\"a\", 1], [\"b\", fn]];\n const obj = typedFromEntries(fnEntries);\n expect(obj.a).toBe(1);\n expect(typeof obj.b).toBe(\"function\");\n // Type assertion needed for the function call\n expect((obj.b as () => string)()).toBe(\"test\");\n});\n\nexport function typedKeys<T extends {}>(obj: T): (keyof T)[] {\n return Object.keys(obj) as any;\n}\nundefined?.test(\"typedKeys\", ({ expect }) => {\n expect(typedKeys({})).toEqual([]);\n expect(typedKeys({ a: 1, b: 2 })).toEqual([\"a\", \"b\"]);\n expect(typedKeys({ a: \"hello\", b: true, c: null })).toEqual([\"a\", \"b\", \"c\"]);\n\n // Test with object containing methods\n const objWithMethod = { a: 1, b: () => \"test\" };\n expect(typedKeys(objWithMethod)).toEqual([\"a\", \"b\"]);\n});\n\nexport function typedValues<T extends {}>(obj: T): T[keyof T][] {\n return Object.values(obj) as any;\n}\nundefined?.test(\"typedValues\", ({ expect }) => {\n expect(typedValues({})).toEqual([]);\n expect(typedValues({ a: 1, b: 2 })).toEqual([1, 2]);\n\n // Test with mixed types\n type MixedObj = { a: string, b: boolean, c: null };\n const mixedObj: MixedObj = { a: \"hello\", b: true, c: null };\n expect(typedValues(mixedObj)).toEqual([\"hello\", true, null]);\n\n // Test with object containing methods\n type ObjWithFn = { a: number, b: () => string };\n const fn = () => \"test\";\n const objWithMethod: ObjWithFn = { a: 1, b: fn };\n const values = typedValues(objWithMethod);\n expect(values.length).toBe(2);\n expect(values[0]).toBe(1);\n expect(typeof values[1]).toBe(\"function\");\n // Need to cast to the correct type\n const fnValue = values[1] as () => string;\n expect(fnValue()).toBe(\"test\");\n});\n\nexport function typedAssign<T extends {}, U extends {}>(target: T, source: U): T & U {\n return Object.assign(target, source);\n}\nundefined?.test(\"typedAssign\", ({ expect }) => {\n // Test with empty objects\n const emptyTarget = {};\n const emptyResult = typedAssign(emptyTarget, { a: 1 });\n expect(emptyResult).toEqual({ a: 1 });\n expect(emptyResult).toBe(emptyTarget); // Same reference\n\n // Test with non-empty target\n const target = { a: 1, b: 2 };\n const result = typedAssign(target, { c: 3, d: 4 });\n expect(result).toEqual({ a: 1, b: 2, c: 3, d: 4 });\n expect(result).toBe(target); // Same reference\n\n // Test with overlapping properties\n const targetWithOverlap = { a: 1, b: 2 };\n const resultWithOverlap = typedAssign(targetWithOverlap, { b: 3, c: 4 });\n expect(resultWithOverlap).toEqual({ a: 1, b: 3, c: 4 });\n expect(resultWithOverlap).toBe(targetWithOverlap); // Same reference\n});\n\nexport type FilterUndefined<T> =\n & { [k in keyof T as (undefined extends T[k] ? (T[k] extends undefined | void ? never : k) : never)]+?: T[k] & ({} | null) }\n & { [k in keyof T as (undefined extends T[k] ? never : k)]: T[k] & ({} | null) }\n\n/**\n * Returns a new object with all undefined values removed. Useful when spreading optional parameters on an object, as\n * TypeScript's `Partial<XYZ>` type allows `undefined` values.\n */\nexport function filterUndefined<T extends object>(obj: T): FilterUndefined<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as any;\n}\nundefined?.test(\"filterUndefined\", ({ expect }) => {\n expect(filterUndefined({})).toEqual({});\n expect(filterUndefined({ a: 1, b: 2 })).toEqual({ a: 1, b: 2 });\n expect(filterUndefined({ a: 1, b: undefined })).toEqual({ a: 1 });\n expect(filterUndefined({ a: undefined, b: undefined })).toEqual({});\n expect(filterUndefined({ a: null, b: undefined })).toEqual({ a: null });\n expect(filterUndefined({ a: 0, b: \"\", c: false, d: undefined })).toEqual({ a: 0, b: \"\", c: false });\n});\n\nexport type FilterUndefinedOrNull<T> = FilterUndefined<{ [k in keyof T]: null extends T[k] ? NonNullable<T[k]> | undefined : T[k] }>;\n\n/**\n * Returns a new object with all undefined and null values removed. Useful when spreading optional parameters on an object, as\n * TypeScript's `Partial<XYZ>` type allows `undefined` values.\n */\nexport function filterUndefinedOrNull<T extends object>(obj: T): FilterUndefinedOrNull<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined && v !== null)) as any;\n}\nundefined?.test(\"filterUndefinedOrNull\", ({ expect }) => {\n expect(filterUndefinedOrNull({})).toEqual({});\n expect(filterUndefinedOrNull({ a: 1, b: 2 })).toEqual({ a: 1, b: 2 });\n});\n\nexport type DeepFilterUndefined<T> = T extends object ? FilterUndefined<{ [K in keyof T]: DeepFilterUndefined<T[K]> }> : T;\n\nexport function deepFilterUndefined<T extends object>(obj: T): DeepFilterUndefined<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined).map(([k, v]) => [k, isObjectLike(v) ? deepFilterUndefined(v) : v])) as any;\n}\nundefined?.test(\"deepFilterUndefined\", ({ expect }) => {\n expect(deepFilterUndefined({ a: 1, b: undefined })).toEqual({ a: 1 });\n});\n\nexport function pick<T extends {}, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n return Object.fromEntries(Object.entries(obj).filter(([k]) => keys.includes(k as K))) as any;\n}\nundefined?.test(\"pick\", ({ expect }) => {\n const obj = { a: 1, b: 2, c: 3, d: 4 };\n expect(pick(obj, [\"a\", \"c\"])).toEqual({ a: 1, c: 3 });\n expect(pick(obj, [])).toEqual({});\n expect(pick(obj, [\"a\", \"e\" as keyof typeof obj])).toEqual({ a: 1 });\n // Use type assertion for empty object to avoid TypeScript error\n expect(pick({} as Record<string, unknown>, [\"a\"])).toEqual({});\n});\n\nexport function omit<T extends {}, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n return Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k as K))) as any;\n}\nundefined?.test(\"omit\", ({ expect }) => {\n const obj = { a: 1, b: 2, c: 3, d: 4 };\n expect(omit(obj, [\"a\", \"c\"])).toEqual({ b: 2, d: 4 });\n expect(omit(obj, [])).toEqual(obj);\n expect(omit(obj, [\"a\", \"e\" as keyof typeof obj])).toEqual({ b: 2, c: 3, d: 4 });\n // Use type assertion for empty object to avoid TypeScript error\n expect(omit({} as Record<string, unknown>, [\"a\"])).toEqual({});\n});\n\nexport function split<T extends {}, K extends keyof T>(obj: T, keys: K[]): [Pick<T, K>, Omit<T, K>] {\n return [pick(obj, keys), omit(obj, keys)];\n}\n\nundefined?.test(\"split\", ({ expect }) => {\n const obj = { a: 1, b: 2, c: 3, d: 4 };\n expect(split(obj, [\"a\", \"c\"])).toEqual([{ a: 1, c: 3 }, { b: 2, d: 4 }]);\n expect(split(obj, [])).toEqual([{}, obj]);\n expect(split(obj, [\"a\", \"e\" as keyof typeof obj])).toEqual([{ a: 1 }, { b: 2, c: 3, d: 4 }]);\n // Use type assertion for empty object to avoid TypeScript error\n expect(split({} as Record<string, unknown>, [\"a\"])).toEqual([{}, {}]);\n});\n\nexport function set<T extends object, K extends keyof T>(obj: T, key: K, value: T[K]) {\n Object.defineProperty(obj, key, { value, writable: true, configurable: true, enumerable: true });\n}\n\nexport function get<T extends object, K extends keyof T>(obj: T, key: K): T[K] {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n if (!descriptor) throw new StackAssertionError(`get: key ${String(key)} does not exist`, { obj, key });\n return descriptor.value;\n}\n\nexport function has<T extends object, K extends keyof T>(obj: T, key: K): obj is T & { [k in K]: unknown } {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nexport function hasAndNotUndefined<T extends object, K extends keyof T>(obj: T, key: K): obj is T & { [k in K]: Exclude<T[K], undefined> } {\n return has(obj, key) && get(obj, key) !== undefined;\n}\n\nexport function deleteKey<T extends object, K extends keyof T>(obj: T, key: K) {\n if (has(obj, key)) {\n Reflect.deleteProperty(obj, key);\n } else {\n throw new StackAssertionError(`deleteKey: key ${String(key)} does not exist`, { obj, key });\n }\n}\n\nexport function isObjectLike(value: unknown): value is object {\n return (typeof value === 'object' || typeof value === 'function') && value !== null;\n}\n"],"mappings":";AAAA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAElB,SAAS,UAAa,OAAmC;AAC9D,SAAO,UAAU,QAAQ,UAAU;AACrC;AAmBO,SAAS,gBAAmB,MAAS,MAAe,UAA+C,CAAC,GAAc;AACvH,MAAI,OAAO,SAAS,OAAO,KAAM,QAAO;AACxC,MAAI,SAAS,KAAM,QAAO;AAE1B,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,UAAU;AACb,UAAI,CAAC,QAAQ,CAAC,KAAM,QAAO;AAE3B,UAAI,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,IAAI,GAAG;AAC9C,YAAI,CAAC,MAAM,QAAQ,IAAI,KAAK,CAAC,MAAM,QAAQ,IAAI,EAAG,QAAO;AACzD,YAAI,KAAK,WAAW,KAAK,OAAQ,QAAO;AACxC,eAAO,KAAK,MAAM,CAAC,GAAG,MAAM,gBAAgB,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC;AAAA,MAClE;AAEA,YAAM,WAAW,OAAO,QAAQ,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,yBAAyB,MAAM,MAAS;AAC1G,YAAM,WAAW,OAAO,QAAQ,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,yBAAyB,MAAM,MAAS;AAC1G,UAAI,SAAS,WAAW,SAAS,OAAQ,QAAO;AAChD,aAAO,SAAS,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM;AACjC,cAAM,KAAK,SAAS,KAAK,CAAC,CAAC,EAAE,MAAM,MAAM,EAAE;AAC3C,YAAI,CAAC,GAAI,QAAO;AAChB,eAAO,gBAAgB,IAAI,GAAG,CAAC,GA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x"],"sourcesContent":["import { StackAssertionError } from \"./errors\";\nimport { identity } from \"./functions\";\nimport { stringCompare } from \"./strings\";\n\nexport function isNotNull<T>(value: T): value is NonNullable<T> {\n return value !== null && value !== undefined;\n}\nundefined?.test(\"isNotNull\", ({ expect }) => {\n expect(isNotNull(null)).toBe(false);\n expect(isNotNull(undefined)).toBe(false);\n expect(isNotNull(0)).toBe(true);\n expect(isNotNull(\"\")).toBe(true);\n expect(isNotNull(false)).toBe(true);\n expect(isNotNull({})).toBe(true);\n expect(isNotNull([])).toBe(true);\n});\n\nexport type DeepPartial<T> = T extends object ? (T extends (infer E)[] ? T : { [P in keyof T]?: DeepPartial<T[P]> }) : T;\nexport type DeepRequired<T> = T extends object ? (T extends (infer E)[] ? T : { [P in keyof T]-?: DeepRequired<T[P]> }) : T;\n\n/**\n * Assumes both objects are primitives, arrays, or non-function plain objects, and compares them deeply.\n *\n * Note that since they are assumed to be plain objects, this function does not compare prototypes.\n */\nexport function deepPlainEquals<T>(obj1: T, obj2: unknown, options: { ignoreUndefinedValues?: boolean } = {}): obj2 is T {\n if (typeof obj1 !== typeof obj2) return false;\n if (obj1 === obj2) return true;\n\n switch (typeof obj1) {\n case 'object': {\n if (!obj1 || !obj2) return false;\n\n if (Array.isArray(obj1) || Array.isArray(obj2)) {\n if (!Array.isArray(obj1) || !Array.isArray(obj2)) return false;\n if (obj1.length !== obj2.length) return false;\n return obj1.every((v, i) => deepPlainEquals(v, obj2[i], options));\n }\n\n const entries1 = Object.entries(obj1).filter(([k, v]) => !options.ignoreUndefinedValues || v !== undefined);\n const entries2 = Object.entries(obj2).filter(([k, v]) => !options.ignoreUndefinedValues || v !== undefined);\n if (entries1.length !== entries2.length) return false;\n return entries1.every(([k, v1]) => {\n const e2 = entries2.find(([k2]) => k === k2);\n if (!e2) return false;\n return deepPlainEquals(v1, e2[1], options);\n });\n }\n case 'undefined':\n case 'string':\n case 'number':\n case 'boolean':\n case 'bigint':\n case 'symbol':\n case 'function':{\n return false;\n }\n default: {\n throw new Error(\"Unexpected typeof \" + typeof obj1);\n }\n }\n}\nundefined?.test(\"deepPlainEquals\", ({ expect }) => {\n // Simple values\n expect(deepPlainEquals(1, 1)).toBe(true);\n expect(deepPlainEquals(\"test\", \"test\")).toBe(true);\n expect(deepPlainEquals(1, 2)).toBe(false);\n expect(deepPlainEquals(\"test\", \"other\")).toBe(false);\n\n // Arrays\n expect(deepPlainEquals([1, 2, 3], [1, 2, 3])).toBe(true);\n expect(deepPlainEquals([1, 2, 3], [1, 2, 4])).toBe(false);\n expect(deepPlainEquals([1, 2, 3], [1, 2])).toBe(false);\n\n // Objects\n expect(deepPlainEquals({ a: 1, b: 2 }, { a: 1, b: 2 })).toBe(true);\n expect(deepPlainEquals({ a: 1, b: 2 }, { a: 1, b: 3 })).toBe(false);\n expect(deepPlainEquals({ a: 1, b: 2 }, { a: 1 })).toBe(false);\n\n // Nested structures\n expect(deepPlainEquals({ a: 1, b: [1, 2, { c: 3 }] }, { a: 1, b: [1, 2, { c: 3 }] })).toBe(true);\n expect(deepPlainEquals({ a: 1, b: [1, 2, { c: 3 }] }, { a: 1, b: [1, 2, { c: 4 }] })).toBe(false);\n\n // With options\n expect(deepPlainEquals({ a: 1, b: undefined }, { a: 1 }, { ignoreUndefinedValues: true })).toBe(true);\n expect(deepPlainEquals({ a: 1, b: undefined }, { a: 1 })).toBe(false);\n});\n\nexport function isCloneable<T>(obj: T): obj is Exclude<T, symbol | Function> {\n return typeof obj !== 'symbol' && typeof obj !== 'function';\n}\n\nexport function shallowClone<T extends object>(obj: T): T {\n if (!isCloneable(obj)) throw new StackAssertionError(\"shallowClone does not support symbols or functions\", { obj });\n\n if (Array.isArray(obj)) return obj.map(identity) as T;\n return { ...obj };\n}\nundefined?.test(\"shallowClone\", ({ expect }) => {\n expect(shallowClone({ a: 1, b: 2 })).toEqual({ a: 1, b: 2 });\n expect(shallowClone([1, 2, 3])).toEqual([1, 2, 3]);\n expect(() => shallowClone(() => {})).toThrow();\n});\n\nexport function deepPlainClone<T>(obj: T): T {\n if (typeof obj === 'function') throw new StackAssertionError(\"deepPlainClone does not support functions\");\n if (typeof obj === 'symbol') throw new StackAssertionError(\"deepPlainClone does not support symbols\");\n if (typeof obj !== 'object' || !obj) return obj;\n if (Array.isArray(obj)) return obj.map(deepPlainClone) as any;\n return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, deepPlainClone(v)])) as any;\n}\nundefined?.test(\"deepPlainClone\", ({ expect }) => {\n // Primitive values\n expect(deepPlainClone(1)).toBe(1);\n expect(deepPlainClone(\"test\")).toBe(\"test\");\n expect(deepPlainClone(null)).toBe(null);\n expect(deepPlainClone(undefined)).toBe(undefined);\n\n // Arrays\n const arr = [1, 2, 3];\n const clonedArr = deepPlainClone(arr);\n expect(clonedArr).toEqual(arr);\n expect(clonedArr).not.toBe(arr); // Different reference\n\n // Objects\n const obj = { a: 1, b: 2 };\n const clonedObj = deepPlainClone(obj);\n expect(clonedObj).toEqual(obj);\n expect(clonedObj).not.toBe(obj); // Different reference\n\n // Nested structures\n const nested = { a: 1, b: [1, 2, { c: 3 }] };\n const clonedNested = deepPlainClone(nested);\n expect(clonedNested).toEqual(nested);\n expect(clonedNested).not.toBe(nested); // Different reference\n expect(clonedNested.b).not.toBe(nested.b); // Different reference for nested array\n expect(clonedNested.b[2]).not.toBe(nested.b[2]); // Different reference for nested object\n\n // Error cases\n expect(() => deepPlainClone(() => {})).toThrow();\n expect(() => deepPlainClone(Symbol())).toThrow();\n});\n\nexport type DeepMerge<T, U> = Omit<T, keyof U> & Omit<U, keyof T> & DeepMergeInner<Pick<T, keyof U & keyof T>, Pick<U, keyof U & keyof T>>;\ntype DeepMergeInner<T, U> = {\n [K in keyof U]-?:\n undefined extends U[K]\n ? K extends keyof T\n ? T[K] extends object\n ? Exclude<U[K], undefined> extends object\n ? DeepMerge<T[K], Exclude<U[K], undefined>>\n : T[K] | Exclude<U[K], undefined>\n : T[K] | Exclude<U[K], undefined>\n : Exclude<U[K], undefined>\n : K extends keyof T\n ? T[K] extends object\n ? U[K] extends object\n ? DeepMerge<T[K], U[K]>\n : U[K]\n : U[K]\n : U[K];\n};\nexport function deepMerge<T extends {}, U extends {}>(baseObj: T, mergeObj: U): DeepMerge<T, U> {\n if ([baseObj, mergeObj, ...Object.values(baseObj), ...Object.values(mergeObj)].some(o => !isCloneable(o))) throw new StackAssertionError(\"deepMerge does not support functions or symbols\", { baseObj, mergeObj });\n\n const res: any = shallowClone(baseObj);\n for (const [key, mergeValue] of Object.entries(mergeObj)) {\n if (has(res, key as any)) {\n const baseValue = get(res, key as any);\n if (isObjectLike(baseValue) && isObjectLike(mergeValue)) {\n set(res, key, deepMerge(baseValue, mergeValue));\n continue;\n }\n }\n set(res, key, mergeValue);\n }\n return res as any;\n}\nundefined?.test(\"deepMerge\", ({ expect }) => {\n // Test merging flat objects\n expect(deepMerge({ a: 1 }, { b: 2 })).toEqual({ a: 1, b: 2 });\n expect(deepMerge({ a: 1 }, { a: 2 })).toEqual({ a: 2 });\n expect(deepMerge({ a: 1, b: 2 }, { b: 3, c: 4 })).toEqual({ a: 1, b: 3, c: 4 });\n\n // Test with nested objects\n expect(deepMerge(\n { a: { x: 1, y: 2 }, b: 3 },\n { a: { y: 3, z: 4 }, c: 5 }\n )).toEqual({ a: { x: 1, y: 3, z: 4 }, b: 3, c: 5 });\n\n // Test with arrays\n expect(deepMerge(\n { a: [1, 2], b: 3 },\n { a: [3, 4], c: 5 }\n )).toEqual({ a: [3, 4], b: 3, c: 5 });\n\n // Test with null values\n expect(deepMerge(\n { a: { x: 1 }, b: null },\n { a: { y: 2 }, b: { z: 3 } }\n )).toEqual({ a: { x: 1, y: 2 }, b: { z: 3 } });\n\n // Test with undefined values\n expect(deepMerge(\n { a: 1, b: undefined },\n { b: 2, c: 3 }\n )).toEqual({ a: 1, b: 2, c: 3 });\n\n // Test deeply nested structures\n expect(deepMerge(\n {\n a: {\n x: { deep: 1 },\n y: [1, 2]\n },\n b: 2\n },\n {\n a: {\n x: { deeper: 3 },\n y: [3, 4]\n },\n c: 3\n }\n )).toEqual({\n a: {\n x: { deep: 1, deeper: 3 },\n y: [3, 4]\n },\n b: 2,\n c: 3\n });\n\n // Test with empty objects\n expect(deepMerge({}, { a: 1 })).toEqual({ a: 1 });\n expect(deepMerge({ a: 1 }, {})).toEqual({ a: 1 });\n expect(deepMerge({}, {})).toEqual({});\n\n // Test that original objects are not modified\n const base = { a: { x: 1 }, b: 2 };\n const merge = { a: { y: 2 }, c: 3 };\n const baseClone = deepPlainClone(base);\n const mergeClone = deepPlainClone(merge);\n\n const result = deepMerge(base, merge);\n expect(base).toEqual(baseClone);\n expect(merge).toEqual(mergeClone);\n expect(result).toEqual({ a: { x: 1, y: 2 }, b: 2, c: 3 });\n\n // Test error cases\n expect(() => deepMerge({ a: () => {} }, { b: 2 })).toThrow();\n expect(() => deepMerge({ a: 1 }, { b: () => {} })).toThrow();\n expect(() => deepMerge({ a: Symbol() }, { b: 2 })).toThrow();\n expect(() => deepMerge({ a: 1 }, { b: Symbol() })).toThrow();\n});\n\nexport function typedEntries<T extends {}>(obj: T): [keyof T, T[keyof T]][] {\n return Object.entries(obj) as any;\n}\nundefined?.test(\"typedEntries\", ({ expect }) => {\n expect(typedEntries({})).toEqual([]);\n expect(typedEntries({ a: 1, b: 2 })).toEqual([[\"a\", 1], [\"b\", 2]]);\n expect(typedEntries({ a: \"hello\", b: true, c: null })).toEqual([[\"a\", \"hello\"], [\"b\", true], [\"c\", null]]);\n\n // Test with object containing methods\n const objWithMethod = { a: 1, b: () => \"test\" };\n const entries = typedEntries(objWithMethod);\n expect(entries.length).toBe(2);\n expect(entries[0][0]).toBe(\"a\");\n expect(entries[0][1]).toBe(1);\n expect(entries[1][0]).toBe(\"b\");\n expect(typeof entries[1][1]).toBe(\"function\");\n});\n\nexport function typedFromEntries<K extends PropertyKey, V>(entries: (readonly [K, V])[]): Record<K, V> {\n return Object.fromEntries(entries) as any;\n}\nundefined?.test(\"typedFromEntries\", ({ expect }) => {\n expect(typedFromEntries([])).toEqual({});\n expect(typedFromEntries([[\"a\", 1], [\"b\", 2]])).toEqual({ a: 1, b: 2 });\n\n // Test with mixed types (using type assertion)\n const mixedEntries = [[\"a\", \"hello\"], [\"b\", true], [\"c\", null]] as [string, string | boolean | null][];\n const mixedObj = typedFromEntries(mixedEntries);\n expect(mixedObj).toEqual({ a: \"hello\", b: true, c: null });\n\n // Test with function values\n const fn = () => \"test\";\n type MixedValue = number | (() => string);\n const fnEntries: [string, MixedValue][] = [[\"a\", 1], [\"b\", fn]];\n const obj = typedFromEntries(fnEntries);\n expect(obj.a).toBe(1);\n expect(typeof obj.b).toBe(\"function\");\n // Type assertion needed for the function call\n expect((obj.b as () => string)()).toBe(\"test\");\n});\n\nexport function typedKeys<T extends {}>(obj: T): (keyof T)[] {\n return Object.keys(obj) as any;\n}\nundefined?.test(\"typedKeys\", ({ expect }) => {\n expect(typedKeys({})).toEqual([]);\n expect(typedKeys({ a: 1, b: 2 })).toEqual([\"a\", \"b\"]);\n expect(typedKeys({ a: \"hello\", b: true, c: null })).toEqual([\"a\", \"b\", \"c\"]);\n\n // Test with object containing methods\n const objWithMethod = { a: 1, b: () => \"test\" };\n expect(typedKeys(objWithMethod)).toEqual([\"a\", \"b\"]);\n});\n\nexport function typedValues<T extends {}>(obj: T): T[keyof T][] {\n return Object.values(obj) as any;\n}\nundefined?.test(\"typedValues\", ({ expect }) => {\n expect(typedValues({})).toEqual([]);\n expect(typedValues({ a: 1, b: 2 })).toEqual([1, 2]);\n\n // Test with mixed types\n type MixedObj = { a: string, b: boolean, c: null };\n const mixedObj: MixedObj = { a: \"hello\", b: true, c: null };\n expect(typedValues(mixedObj)).toEqual([\"hello\", true, null]);\n\n // Test with object containing methods\n type ObjWithFn = { a: number, b: () => string };\n const fn = () => \"test\";\n const objWithMethod: ObjWithFn = { a: 1, b: fn };\n const values = typedValues(objWithMethod);\n expect(values.length).toBe(2);\n expect(values[0]).toBe(1);\n expect(typeof values[1]).toBe(\"function\");\n // Need to cast to the correct type\n const fnValue = values[1] as () => string;\n expect(fnValue()).toBe(\"test\");\n});\n\nexport function typedAssign<T extends {}, U extends {}>(target: T, source: U): T & U {\n return Object.assign(target, source);\n}\nundefined?.test(\"typedAssign\", ({ expect }) => {\n // Test with empty objects\n const emptyTarget = {};\n const emptyResult = typedAssign(emptyTarget, { a: 1 });\n expect(emptyResult).toEqual({ a: 1 });\n expect(emptyResult).toBe(emptyTarget); // Same reference\n\n // Test with non-empty target\n const target = { a: 1, b: 2 };\n const result = typedAssign(target, { c: 3, d: 4 });\n expect(result).toEqual({ a: 1, b: 2, c: 3, d: 4 });\n expect(result).toBe(target); // Same reference\n\n // Test with overlapping properties\n const targetWithOverlap = { a: 1, b: 2 };\n const resultWithOverlap = typedAssign(targetWithOverlap, { b: 3, c: 4 });\n expect(resultWithOverlap).toEqual({ a: 1, b: 3, c: 4 });\n expect(resultWithOverlap).toBe(targetWithOverlap); // Same reference\n});\n\nexport type FilterUndefined<T> =\n & { [k in keyof T as (undefined extends T[k] ? (T[k] extends undefined | void ? never : k) : never)]+?: T[k] & ({} | null) }\n & { [k in keyof T as (undefined extends T[k] ? never : k)]: T[k] & ({} | null) }\n\n/**\n * Returns a new object with all undefined values removed. Useful when spreading optional parameters on an object, as\n * TypeScript's `Partial<XYZ>` type allows `undefined` values.\n */\nexport function filterUndefined<T extends object>(obj: T): FilterUndefined<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as any;\n}\nundefined?.test(\"filterUndefined\", ({ expect }) => {\n expect(filterUndefined({})).toEqual({});\n expect(filterUndefined({ a: 1, b: 2 })).toEqual({ a: 1, b: 2 });\n expect(filterUndefined({ a: 1, b: undefined })).toEqual({ a: 1 });\n expect(filterUndefined({ a: undefined, b: undefined })).toEqual({});\n expect(filterUndefined({ a: null, b: undefined })).toEqual({ a: null });\n expect(filterUndefined({ a: 0, b: \"\", c: false, d: undefined })).toEqual({ a: 0, b: \"\", c: false });\n});\n\nexport type FilterUndefinedOrNull<T> = FilterUndefined<{ [k in keyof T]: null extends T[k] ? NonNullable<T[k]> | undefined : T[k] }>;\n\n/**\n * Returns a new object with all undefined and null values removed. Useful when spreading optional parameters on an object, as\n * TypeScript's `Partial<XYZ>` type allows `undefined` values.\n */\nexport function filterUndefinedOrNull<T extends object>(obj: T): FilterUndefinedOrNull<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined && v !== null)) as any;\n}\nundefined?.test(\"filterUndefinedOrNull\", ({ expect }) => {\n expect(filterUndefinedOrNull({})).toEqual({});\n expect(filterUndefinedOrNull({ a: 1, b: 2 })).toEqual({ a: 1, b: 2 });\n});\n\nexport type DeepFilterUndefined<T> = T extends object ? FilterUndefined<{ [K in keyof T]: DeepFilterUndefined<T[K]> }> : T;\n\nexport function deepFilterUndefined<T extends object>(obj: T): DeepFilterUndefined<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined).map(([k, v]) => [k, isObjectLike(v) ? deepFilterUndefined(v) : v])) as any;\n}\nundefined?.test(\"deepFilterUndefined\", ({ expect }) => {\n expect(deepFilterUndefined({ a: 1, b: undefined })).toEqual({ a: 1 });\n});\n\nexport function pick<T extends {}, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n return Object.fromEntries(Object.entries(obj).filter(([k]) => keys.includes(k as K))) as any;\n}\nundefined?.test(\"pick\", ({ expect }) => {\n const obj = { a: 1, b: 2, c: 3, d: 4 };\n expect(pick(obj, [\"a\", \"c\"])).toEqual({ a: 1, c: 3 });\n expect(pick(obj, [])).toEqual({});\n expect(pick(obj, [\"a\", \"e\" as keyof typeof obj])).toEqual({ a: 1 });\n // Use type assertion for empty object to avoid TypeScript error\n expect(pick({} as Record<string, unknown>, [\"a\"])).toEqual({});\n});\n\nexport function omit<T extends {}, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n if (!Array.isArray(keys)) throw new StackAssertionError(\"omit: keys must be an array\", { obj, keys });\n return Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k as K))) as any;\n}\nundefined?.test(\"omit\", ({ expect }) => {\n const obj = { a: 1, b: 2, c: 3, d: 4 };\n expect(omit(obj, [\"a\", \"c\"])).toEqual({ b: 2, d: 4 });\n expect(omit(obj, [])).toEqual(obj);\n expect(omit(obj, [\"a\", \"e\" as keyof typeof obj])).toEqual({ b: 2, c: 3, d: 4 });\n // Use type assertion for empty object to avoid TypeScript error\n expect(omit({} as Record<string, unknown>, [\"a\"])).toEqual({});\n});\n\nexport function split<T extends {}, K extends keyof T>(obj: T, keys: K[]): [Pick<T, K>, Omit<T, K>] {\n return [pick(obj, keys), omit(obj, keys)];\n}\nundefined?.test(\"split\", ({ expect }) => {\n const obj = { a: 1, b: 2, c: 3, d: 4 };\n expect(split(obj, [\"a\", \"c\"])).toEqual([{ a: 1, c: 3 }, { b: 2, d: 4 }]);\n expect(split(obj, [])).toEqual([{}, obj]);\n expect(split(obj, [\"a\", \"e\" as keyof typeof obj])).toEqual([{ a: 1 }, { b: 2, c: 3, d: 4 }]);\n // Use type assertion for empty object to avoid TypeScript error\n expect(split({} as Record<string, unknown>, [\"a\"])).toEqual([{}, {}]);\n});\n\nexport function mapValues<T extends object, U>(obj: T, fn: (value: T extends (infer E)[] ? E : T[keyof T]) => U): Record<keyof T, U> {\n if (Array.isArray(obj)) {\n return obj.map(v => fn(v)) as any;\n }\n return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn(v)])) as any;\n}\nundefined?.test(\"mapValues\", ({ expect }) => {\n expect(mapValues({ a: 1, b: 2 }, v => v * 2)).toEqual({ a: 2, b: 4 });\n expect(mapValues([1, 2, 3], v => v * 2)).toEqual([2, 4, 6]);\n});\n\nexport function sortKeys<T extends object>(obj: T): T {\n if (Array.isArray(obj)) {\n return [...obj] as any;\n }\n return Object.fromEntries(Object.entries(obj).sort(([a], [b]) => stringCompare(a, b))) as any;\n}\nundefined?.test(\"sortKeys\", ({ expect }) => {\n const obj = {\n \"1\": 0,\n \"10\": 1,\n b: 2,\n \"2\": 3,\n a: 4,\n \"-3.33\": 5,\n \"-4\": 6,\n \"-3\": 7,\n abc: 8,\n \"a-b\": 9,\n ab: 10,\n ac: 11,\n aa: 12,\n aab: 13,\n };\n expect(Object.entries(sortKeys(obj))).toEqual([\n [\"1\", 0],\n [\"2\", 3],\n [\"10\", 1],\n [\"-3\", 7],\n [\"-3.33\", 5],\n [\"-4\", 6],\n [\"a\", 4],\n [\"a-b\", 9],\n [\"aa\", 12],\n [\"aab\", 13],\n [\"ab\", 10],\n [\"abc\", 8],\n [\"ac\", 11],\n [\"b\", 2],\n ]);\n});\n\nexport function deepSortKeys<T extends object>(obj: T): T {\n return sortKeys(mapValues(obj, v => isObjectLike(v) ? deepSortKeys(v) : v)) as any;\n}\nundefined?.test(\"deepSortKeys\", ({ expect }) => {\n const obj = {\n h: { i: { k: 9, j: 8 }, l: 10 },\n b: { d: 3, c: 2 },\n a: 1,\n e: [4, 5, { g: 7, f: 6 }],\n };\n const sorted = deepSortKeys(obj);\n expect(Object.entries(sorted)).toEqual([\n [\"a\", 1],\n [\"b\", { c: 2, d: 3 }],\n [\"e\", [4, 5, { f: 6, g: 7 }]],\n [\"h\", { i: { j: 8, k: 9 }, l: 10 }],\n ]);\n expect(Object.entries(sorted.b)).toEqual([\n [\"c\", 2],\n [\"d\", 3],\n ]);\n expect(Object.entries(sorted.e[2])).toEqual([\n [\"f\", 6],\n [\"g\", 7],\n ]);\n expect(Object.entries(sorted.h)).toEqual([\n [\"i\", { j: 8, k: 9 }],\n [\"l\", 10],\n ]);\n expect(Object.entries(sorted.h.i)).toEqual([\n [\"j\", 8],\n [\"k\", 9],\n ]);\n});\n\nexport function set<T extends object, K extends keyof T>(obj: T, key: K, value: T[K]) {\n Object.defineProperty(obj, key, { value, writable: true, configurable: true, enumerable: true });\n}\n\nexport function get<T extends object, K extends keyof T>(obj: T, key: K): T[K] {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n if (!descriptor) throw new StackAssertionError(`get: key ${String(key)} does not exist`, { obj, key });\n return descriptor.value;\n}\n\nexport function getOrUndefined<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined {\n return has(obj, key) ? get(obj, key) : undefined;\n}\n\nexport function has<T extends object, K extends keyof T>(obj: T, key: K): obj is T & { [k in K]: unknown } {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nundefined?.test(\"has\", ({ expect }) => {\n const obj = { a: 1, b: undefined, c: null };\n expect(has(obj, \"a\")).toBe(true);\n expect(has(obj, \"b\")).toBe(true);\n expect(has(obj, \"c\")).toBe(true);\n expect(has(obj, \"d\" as keyof typeof obj)).toBe(false);\n});\n\n\nexport function hasAndNotUndefined<T extends object, K extends keyof T>(obj: T, key: K): obj is T & { [k in K]: Exclude<T[K], undefined> } {\n return has(obj, key) && get(obj, key) !== undefined;\n}\n\nexport function deleteKey<T extends object, K extends keyof T>(obj: T, key: K) {\n if (has(obj, key)) {\n Reflect.deleteProperty(obj, key);\n } else {\n throw new StackAssertionError(`deleteKey: key ${String(key)} does not exist`, { obj, key });\n }\n}\n\nexport function isObjectLike(value: unknown): value is object {\n return (typeof value === 'object' || typeof value === 'function') && value !== null;\n}\n"],"mappings":";AAAA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAEvB,SAAS,UAAa,OAAmC;AAC9D,SAAO,UAAU,QAAQ,UAAU;AACrC;AAmBO,SAAS,gBAAmB,MAAS,MAAe,UAA+C,CAAC,GAAc;AACvH,MAAI,OAAO,SAAS,OAAO,KAAM,QAAO;AACxC,MAAI,SAAS,KAAM,QAAO;AAE1B,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,UAAU;AACb,UAAI,CAAC,QAAQ,CAAC,KAAM,QAAO;AAE3B,UAAI,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,IAAI,GAAG;AAC9C,YAAI,CAAC,MAAM,QAAQ,IAAI,KAAK,CAAC,MAAM,Q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B,kBAAkB,OAAO,GAAG,CAAC,mBAAmB,EAAE,KAAK,IAAI,CAAC;AAAA,EAC5F;AACF;AAEO,SAAS,aAAa,OAAiC;AAC5D,UAAQ,OAAO,UAAU,YAAY,OAAO,UAAU,eAAe,UAAU;AACjF;","names":[]}
|
|
@@ -14,6 +14,7 @@ function typedCapitalize(s) {
|
|
|
14
14
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
15
15
|
}
|
|
16
16
|
function stringCompare(a, b) {
|
|
17
|
+
if (typeof a !== "string" || typeof b !== "string") throw new StackAssertionError(`Expected two strings for stringCompare, found ${typeof a} and ${typeof b}`, { a, b });
|
|
17
18
|
const cmp = (a2, b2) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
|
|
18
19
|
return cmp(a.toUpperCase(), b.toUpperCase()) || cmp(b, a);
|
|
19
20
|
}
|