@better-auth/core 1.5.5 → 1.5.7-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.mts +41 -14
- package/dist/api/index.mjs +1 -2
- package/dist/api/index.mjs.map +1 -1
- package/dist/async_hooks/index.mjs +1 -1
- package/dist/async_hooks/pure.index.mjs +1 -1
- package/dist/async_hooks/pure.index.mjs.map +1 -1
- package/dist/context/endpoint-context.d.mts +1 -2
- package/dist/context/endpoint-context.mjs +1 -2
- package/dist/context/endpoint-context.mjs.map +1 -1
- package/dist/context/global.mjs +2 -2
- package/dist/context/global.mjs.map +1 -1
- package/dist/context/index.mjs +1 -2
- package/dist/context/request-state.mjs +1 -2
- package/dist/context/request-state.mjs.map +1 -1
- package/dist/context/transaction.mjs +1 -2
- package/dist/context/transaction.mjs.map +1 -1
- package/dist/db/adapter/factory.d.mts +0 -2
- package/dist/db/adapter/factory.mjs +54 -22
- package/dist/db/adapter/factory.mjs.map +1 -1
- package/dist/db/adapter/get-default-field-name.mjs +1 -2
- package/dist/db/adapter/get-default-field-name.mjs.map +1 -1
- package/dist/db/adapter/get-default-model-name.mjs +1 -2
- package/dist/db/adapter/get-default-model-name.mjs.map +1 -1
- package/dist/db/adapter/get-field-attributes.d.mts +0 -3
- package/dist/db/adapter/get-field-attributes.mjs +1 -2
- package/dist/db/adapter/get-field-attributes.mjs.map +1 -1
- package/dist/db/adapter/get-field-name.mjs +1 -2
- package/dist/db/adapter/get-field-name.mjs.map +1 -1
- package/dist/db/adapter/get-id-field.d.mts +0 -3
- package/dist/db/adapter/get-id-field.mjs +3 -4
- package/dist/db/adapter/get-id-field.mjs.map +1 -1
- package/dist/db/adapter/get-model-name.mjs +1 -2
- package/dist/db/adapter/get-model-name.mjs.map +1 -1
- package/dist/db/adapter/index.d.mts +0 -2
- package/dist/db/adapter/index.mjs +1 -2
- package/dist/db/adapter/index.mjs.map +1 -1
- package/dist/db/adapter/types.d.mts +0 -2
- package/dist/db/adapter/utils.mjs +1 -1
- package/dist/db/adapter/utils.mjs.map +1 -1
- package/dist/db/get-tables.d.mts +0 -2
- package/dist/db/get-tables.mjs +1 -1
- package/dist/db/index.mjs +1 -2
- package/dist/db/schema/account.d.mts +0 -1
- package/dist/db/schema/account.mjs +1 -2
- package/dist/db/schema/account.mjs.map +1 -1
- package/dist/db/schema/rate-limit.d.mts +0 -1
- package/dist/db/schema/rate-limit.mjs +1 -2
- package/dist/db/schema/rate-limit.mjs.map +1 -1
- package/dist/db/schema/session.d.mts +0 -1
- package/dist/db/schema/session.mjs +1 -2
- package/dist/db/schema/session.mjs.map +1 -1
- package/dist/db/schema/shared.mjs +1 -2
- package/dist/db/schema/shared.mjs.map +1 -1
- package/dist/db/schema/user.d.mts +0 -1
- package/dist/db/schema/user.mjs +1 -2
- package/dist/db/schema/user.mjs.map +1 -1
- package/dist/db/schema/verification.d.mts +0 -1
- package/dist/db/schema/verification.mjs +1 -2
- package/dist/db/schema/verification.mjs.map +1 -1
- package/dist/db/type.d.mts +0 -1
- package/dist/env/color-depth.mjs +1 -2
- package/dist/env/color-depth.mjs.map +1 -1
- package/dist/env/env-impl.mjs +1 -1
- package/dist/env/env-impl.mjs.map +1 -1
- package/dist/env/index.mjs +1 -2
- package/dist/env/logger.mjs +1 -2
- package/dist/env/logger.mjs.map +1 -1
- package/dist/error/codes.mjs +1 -2
- package/dist/error/codes.mjs.map +1 -1
- package/dist/error/index.mjs +1 -2
- package/dist/error/index.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/instrumentation/attributes.d.mts +12 -0
- package/dist/instrumentation/attributes.mjs +12 -0
- package/dist/instrumentation/attributes.mjs.map +1 -0
- package/dist/instrumentation/index.d.mts +3 -0
- package/dist/instrumentation/index.mjs +3 -0
- package/dist/instrumentation/tracer.d.mts +14 -0
- package/dist/instrumentation/tracer.mjs +36 -0
- package/dist/instrumentation/tracer.mjs.map +1 -0
- package/dist/oauth2/client-credentials-token.d.mts +0 -1
- package/dist/oauth2/client-credentials-token.mjs +1 -2
- package/dist/oauth2/client-credentials-token.mjs.map +1 -1
- package/dist/oauth2/create-authorization-url.d.mts +0 -3
- package/dist/oauth2/create-authorization-url.mjs +1 -2
- package/dist/oauth2/create-authorization-url.mjs.map +1 -1
- package/dist/oauth2/index.mjs +1 -2
- package/dist/oauth2/oauth-provider.d.mts +0 -2
- package/dist/oauth2/refresh-access-token.d.mts +0 -1
- package/dist/oauth2/refresh-access-token.mjs +1 -2
- package/dist/oauth2/refresh-access-token.mjs.map +1 -1
- package/dist/oauth2/utils.mjs +1 -2
- package/dist/oauth2/utils.mjs.map +1 -1
- package/dist/oauth2/validate-authorization-code.d.mts +0 -2
- package/dist/oauth2/validate-authorization-code.mjs +1 -2
- package/dist/oauth2/validate-authorization-code.mjs.map +1 -1
- package/dist/oauth2/verify.mjs +1 -2
- package/dist/oauth2/verify.mjs.map +1 -1
- package/dist/social-providers/apple.d.mts +0 -2
- package/dist/social-providers/apple.mjs +2 -3
- package/dist/social-providers/apple.mjs.map +1 -1
- package/dist/social-providers/atlassian.d.mts +0 -2
- package/dist/social-providers/atlassian.mjs +4 -4
- package/dist/social-providers/atlassian.mjs.map +1 -1
- package/dist/social-providers/cognito.d.mts +0 -2
- package/dist/social-providers/cognito.mjs +1 -2
- package/dist/social-providers/cognito.mjs.map +1 -1
- package/dist/social-providers/discord.d.mts +0 -2
- package/dist/social-providers/discord.mjs +4 -4
- package/dist/social-providers/discord.mjs.map +1 -1
- package/dist/social-providers/dropbox.d.mts +0 -2
- package/dist/social-providers/dropbox.mjs +1 -2
- package/dist/social-providers/dropbox.mjs.map +1 -1
- package/dist/social-providers/facebook.d.mts +0 -2
- package/dist/social-providers/facebook.mjs +1 -2
- package/dist/social-providers/facebook.mjs.map +1 -1
- package/dist/social-providers/figma.d.mts +0 -2
- package/dist/social-providers/figma.mjs +4 -4
- package/dist/social-providers/figma.mjs.map +1 -1
- package/dist/social-providers/github.d.mts +0 -2
- package/dist/social-providers/github.mjs +2 -3
- package/dist/social-providers/github.mjs.map +1 -1
- package/dist/social-providers/gitlab.d.mts +0 -2
- package/dist/social-providers/gitlab.mjs +1 -2
- package/dist/social-providers/gitlab.mjs.map +1 -1
- package/dist/social-providers/google.d.mts +0 -2
- package/dist/social-providers/google.mjs +1 -2
- package/dist/social-providers/google.mjs.map +1 -1
- package/dist/social-providers/huggingface.d.mts +0 -2
- package/dist/social-providers/huggingface.mjs +4 -4
- package/dist/social-providers/huggingface.mjs.map +1 -1
- package/dist/social-providers/index.d.mts +61 -3
- package/dist/social-providers/index.mjs +5 -4
- package/dist/social-providers/index.mjs.map +1 -1
- package/dist/social-providers/kakao.d.mts +0 -2
- package/dist/social-providers/kakao.mjs +4 -4
- package/dist/social-providers/kakao.mjs.map +1 -1
- package/dist/social-providers/kick.d.mts +0 -2
- package/dist/social-providers/kick.mjs +1 -2
- package/dist/social-providers/kick.mjs.map +1 -1
- package/dist/social-providers/line.d.mts +0 -2
- package/dist/social-providers/line.mjs +1 -2
- package/dist/social-providers/line.mjs.map +1 -1
- package/dist/social-providers/linear.d.mts +0 -2
- package/dist/social-providers/linear.mjs +1 -2
- package/dist/social-providers/linear.mjs.map +1 -1
- package/dist/social-providers/linkedin.d.mts +0 -2
- package/dist/social-providers/linkedin.mjs +1 -2
- package/dist/social-providers/linkedin.mjs.map +1 -1
- package/dist/social-providers/microsoft-entra-id.d.mts +0 -2
- package/dist/social-providers/microsoft-entra-id.mjs +1 -2
- package/dist/social-providers/microsoft-entra-id.mjs.map +1 -1
- package/dist/social-providers/naver.d.mts +0 -2
- package/dist/social-providers/naver.mjs +4 -4
- package/dist/social-providers/naver.mjs.map +1 -1
- package/dist/social-providers/notion.d.mts +0 -2
- package/dist/social-providers/notion.mjs +1 -2
- package/dist/social-providers/notion.mjs.map +1 -1
- package/dist/social-providers/paybin.d.mts +0 -2
- package/dist/social-providers/paybin.mjs +1 -2
- package/dist/social-providers/paybin.mjs.map +1 -1
- package/dist/social-providers/paypal.d.mts +0 -2
- package/dist/social-providers/paypal.mjs +1 -2
- package/dist/social-providers/paypal.mjs.map +1 -1
- package/dist/social-providers/polar.d.mts +0 -2
- package/dist/social-providers/polar.mjs +4 -4
- package/dist/social-providers/polar.mjs.map +1 -1
- package/dist/social-providers/railway.d.mts +0 -2
- package/dist/social-providers/railway.mjs +1 -2
- package/dist/social-providers/railway.mjs.map +1 -1
- package/dist/social-providers/reddit.d.mts +0 -2
- package/dist/social-providers/reddit.mjs +1 -2
- package/dist/social-providers/reddit.mjs.map +1 -1
- package/dist/social-providers/roblox.d.mts +0 -2
- package/dist/social-providers/roblox.mjs +4 -4
- package/dist/social-providers/roblox.mjs.map +1 -1
- package/dist/social-providers/salesforce.d.mts +0 -2
- package/dist/social-providers/salesforce.mjs +1 -2
- package/dist/social-providers/salesforce.mjs.map +1 -1
- package/dist/social-providers/slack.d.mts +0 -2
- package/dist/social-providers/slack.mjs +4 -4
- package/dist/social-providers/slack.mjs.map +1 -1
- package/dist/social-providers/spotify.d.mts +0 -2
- package/dist/social-providers/spotify.mjs +4 -4
- package/dist/social-providers/spotify.mjs.map +1 -1
- package/dist/social-providers/tiktok.d.mts +0 -2
- package/dist/social-providers/tiktok.mjs +4 -4
- package/dist/social-providers/tiktok.mjs.map +1 -1
- package/dist/social-providers/twitch.d.mts +0 -2
- package/dist/social-providers/twitch.mjs +4 -4
- package/dist/social-providers/twitch.mjs.map +1 -1
- package/dist/social-providers/twitter.d.mts +0 -2
- package/dist/social-providers/twitter.mjs +4 -4
- package/dist/social-providers/twitter.mjs.map +1 -1
- package/dist/social-providers/vercel.d.mts +0 -2
- package/dist/social-providers/vercel.mjs +1 -2
- package/dist/social-providers/vercel.mjs.map +1 -1
- package/dist/social-providers/vk.d.mts +0 -2
- package/dist/social-providers/vk.mjs +4 -4
- package/dist/social-providers/vk.mjs.map +1 -1
- package/dist/social-providers/wechat.d.mts +114 -0
- package/dist/social-providers/wechat.mjs +83 -0
- package/dist/social-providers/wechat.mjs.map +1 -0
- package/dist/social-providers/zoom.d.mts +0 -2
- package/dist/social-providers/zoom.mjs +1 -2
- package/dist/social-providers/zoom.mjs.map +1 -1
- package/dist/types/context.d.mts +1 -5
- package/dist/types/init-options.d.mts +0 -1
- package/dist/types/plugin.d.mts +4 -2
- package/dist/utils/db.d.mts +0 -2
- package/dist/utils/db.mjs +1 -1
- package/dist/utils/deprecate.mjs +1 -1
- package/dist/utils/error-codes.mjs +1 -1
- package/dist/utils/fetch-metadata.mjs +1 -1
- package/dist/utils/id.mjs +1 -2
- package/dist/utils/id.mjs.map +1 -1
- package/dist/utils/ip.mjs +1 -2
- package/dist/utils/ip.mjs.map +1 -1
- package/dist/utils/json.mjs +1 -2
- package/dist/utils/json.mjs.map +1 -1
- package/dist/utils/string.mjs +1 -1
- package/dist/utils/url.mjs +1 -1
- package/package.json +18 -5
- package/src/api/index.ts +151 -41
- package/src/context/endpoint-context.ts +2 -1
- package/src/db/adapter/factory.ts +119 -47
- package/src/db/adapter/get-id-field.test.ts +222 -0
- package/src/db/adapter/get-id-field.ts +15 -4
- package/src/instrumentation/attributes.ts +22 -0
- package/src/instrumentation/index.ts +2 -0
- package/src/instrumentation/instrumentation.test.ts +139 -0
- package/src/instrumentation/tracer.ts +62 -0
- package/src/social-providers/apple.ts +1 -1
- package/src/social-providers/atlassian.ts +3 -2
- package/src/social-providers/discord.ts +3 -2
- package/src/social-providers/figma.ts +3 -2
- package/src/social-providers/github.ts +1 -1
- package/src/social-providers/huggingface.ts +3 -2
- package/src/social-providers/index.ts +3 -0
- package/src/social-providers/kakao.ts +3 -2
- package/src/social-providers/naver.ts +3 -2
- package/src/social-providers/polar.ts +3 -2
- package/src/social-providers/roblox.ts +3 -2
- package/src/social-providers/slack.ts +3 -2
- package/src/social-providers/spotify.ts +3 -2
- package/src/social-providers/tiktok.ts +3 -2
- package/src/social-providers/twitch.ts +3 -2
- package/src/social-providers/twitter.ts +3 -2
- package/src/social-providers/vk.ts +3 -2
- package/src/social-providers/wechat.ts +213 -0
- package/src/types/context.ts +1 -3
- package/src/types/plugin.ts +14 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/db/adapter/index.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"../../types\";\nimport type { BetterAuthDBSchema, DBFieldAttribute } from \"../type\";\n\nexport type DBAdapterDebugLogOption =\n\t| boolean\n\t| {\n\t\t\t/**\n\t\t\t * Useful when you want to log only certain conditions.\n\t\t\t */\n\t\t\tlogCondition?: (() => boolean) | undefined;\n\t\t\tcreate?: boolean | undefined;\n\t\t\tupdate?: boolean | undefined;\n\t\t\tupdateMany?: boolean | undefined;\n\t\t\tfindOne?: boolean | undefined;\n\t\t\tfindMany?: boolean | undefined;\n\t\t\tdelete?: boolean | undefined;\n\t\t\tdeleteMany?: boolean | undefined;\n\t\t\tcount?: boolean | undefined;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Only used for adapter tests to show debug logs if a test fails.\n\t\t\t *\n\t\t\t * @deprecated Not actually deprecated. Doing this for IDEs to show this option at the very bottom and stop end-users from using this.\n\t\t\t */\n\t\t\tisRunningAdapterTests: boolean;\n\t };\n\nexport type DBAdapterSchemaCreation = {\n\t/**\n\t * Code to be inserted into the file\n\t */\n\tcode: string;\n\t/**\n\t * Path to the file, including the file name and extension.\n\t * Relative paths are supported, with the current working directory of the developer's project as the base.\n\t */\n\tpath: string;\n\t/**\n\t * Append the file if it already exists.\n\t * Note: This will not apply if `overwrite` is set to true.\n\t */\n\tappend?: boolean | undefined;\n\t/**\n\t * Overwrite the file if it already exists\n\t */\n\toverwrite?: boolean | undefined;\n};\n\nexport interface DBAdapterFactoryConfig<\n\tOptions extends BetterAuthOptions = BetterAuthOptions,\n> {\n\t/**\n\t * Use plural table names.\n\t *\n\t * All tables will be named with an `s` at the end.\n\t *\n\t * @default false\n\t */\n\tusePlural?: boolean | undefined;\n\t/**\n\t * Enable debug logs.\n\t *\n\t * @default false\n\t */\n\tdebugLogs?: DBAdapterDebugLogOption | undefined;\n\t/**\n\t * Name of the adapter.\n\t *\n\t * This is used to identify the adapter in the debug logs.\n\t *\n\t * @default `adapterId`\n\t */\n\tadapterName?: string | undefined;\n\t/**\n\t * Adapter id\n\t */\n\tadapterId: string;\n\t/**\n\t * If the database supports numeric ids, set this to `true`.\n\t *\n\t * @default true\n\t */\n\tsupportsNumericIds?: boolean | undefined;\n\t/**\n\t * If the database supports natively generating UUIDs, set this to `true`.\n\t *\n\t * @default false\n\t */\n\tsupportsUUIDs?: boolean | undefined;\n\t/**\n\t * If the database doesn't support JSON columns, set this to `false`.\n\t *\n\t * We will handle the translation between using `JSON` columns, and saving `string`s to the database.\n\t *\n\t * @default false\n\t */\n\tsupportsJSON?: boolean | undefined;\n\t/**\n\t * If the database doesn't support dates, set this to `false`.\n\t *\n\t * We will handle the translation between using `Date` objects, and saving `string`s to the database.\n\t *\n\t * @default true\n\t */\n\tsupportsDates?: boolean | undefined;\n\t/**\n\t * If the database doesn't support booleans, set this to `false`.\n\t *\n\t * We will handle the translation between using `boolean`s, and saving `0`s and `1`s to the database.\n\t *\n\t * @default true\n\t */\n\tsupportsBooleans?: boolean | undefined;\n\t/**\n\t * If the database doesn't support arrays, set this to `false`.\n\t *\n\t * We will handle the translation between using `array`s, and saving `string`s to the database.\n\t *\n\t * @default false\n\t */\n\tsupportsArrays?: boolean | undefined;\n\t/**\n\t * Execute multiple operations in a transaction.\n\t *\n\t * If the database doesn't support transactions, set this to `false` and operations will be executed sequentially.\n\t *\n\t * @default false\n\t */\n\ttransaction?:\n\t\t| (\n\t\t\t\t| false\n\t\t\t\t| (<R>(\n\t\t\t\t\t\tcallback: (trx: DBTransactionAdapter<Options>) => Promise<R>,\n\t\t\t\t ) => Promise<R>)\n\t\t )\n\t\t| undefined;\n\t/**\n\t * Disable id generation for the `create` method.\n\t *\n\t * This is useful for databases that don't support custom id values and would auto-generate them for you.\n\t *\n\t * @default false\n\t */\n\tdisableIdGeneration?: boolean | undefined;\n\t/**\n\t * Map the keys of the input data.\n\t *\n\t * This is useful for databases that expect a different key name for a given situation.\n\t *\n\t * For example, MongoDB uses `_id` while in Better-Auth we use `id`.\n\t *\n\t *\n\t * @example\n\t * Each key represents the old key to replace.\n\t * The value represents the new key\n\t *\n\t * This can be a partial object that only transforms some keys.\n\t *\n\t * ```ts\n\t * mapKeysTransformInput: {\n\t * id: \"_id\" // We want to replace `id` to `_id` to save into MongoDB\n\t * }\n\t * ```\n\t */\n\tmapKeysTransformInput?: Record<string, string> | undefined;\n\t/**\n\t * Map the keys of the output data.\n\t *\n\t * This is useful for databases that expect a different key name for a given situation.\n\t *\n\t * For example, MongoDB uses `_id` while in Better-Auth we use `id`.\n\t *\n\t * @example\n\t * Each key represents the old key to replace.\n\t * The value represents the new key\n\t *\n\t * This can be a partial object that only transforms some keys.\n\t *\n\t * ```ts\n\t * mapKeysTransformOutput: {\n\t * _id: \"id\" // In MongoDB, we save `id` as `_id`. So we want to replace `_id` with `id` when we get the data back.\n\t * }\n\t * ```\n\t */\n\tmapKeysTransformOutput?: Record<string, string> | undefined;\n\t/**\n\t * Custom transform input function.\n\t *\n\t * This function is used to transform the input data before it is saved to the database.\n\t */\n\tcustomTransformInput?:\n\t\t| ((props: {\n\t\t\t\tdata: any;\n\t\t\t\t/**\n\t\t\t\t * The fields of the model.\n\t\t\t\t */\n\t\t\t\tfieldAttributes: DBFieldAttribute;\n\t\t\t\t/**\n\t\t\t\t * The field to transform.\n\t\t\t\t */\n\t\t\t\tfield: string;\n\t\t\t\t/**\n\t\t\t\t * The action which was called from the adapter.\n\t\t\t\t */\n\t\t\t\taction:\n\t\t\t\t\t| \"create\"\n\t\t\t\t\t| \"update\"\n\t\t\t\t\t| \"findOne\"\n\t\t\t\t\t| \"findMany\"\n\t\t\t\t\t| \"updateMany\"\n\t\t\t\t\t| \"delete\"\n\t\t\t\t\t| \"deleteMany\"\n\t\t\t\t\t| \"count\";\n\t\t\t\t/**\n\t\t\t\t * The model name.\n\t\t\t\t */\n\t\t\t\tmodel: string;\n\t\t\t\t/**\n\t\t\t\t * The schema of the user's Better-Auth instance.\n\t\t\t\t */\n\t\t\t\tschema: BetterAuthDBSchema;\n\t\t\t\t/**\n\t\t\t\t * The options of the user's Better-Auth instance.\n\t\t\t\t */\n\t\t\t\toptions: Options;\n\t\t }) => any)\n\t\t| undefined;\n\t/**\n\t * Custom transform output function.\n\t *\n\t * This function is used to transform the output data before it is returned to the user.\n\t */\n\tcustomTransformOutput?:\n\t\t| ((props: {\n\t\t\t\tdata: any;\n\t\t\t\t/**\n\t\t\t\t * The fields of the model.\n\t\t\t\t */\n\t\t\t\tfieldAttributes: DBFieldAttribute;\n\t\t\t\t/**\n\t\t\t\t * The field to transform.\n\t\t\t\t */\n\t\t\t\tfield: string;\n\t\t\t\t/**\n\t\t\t\t * The fields to select.\n\t\t\t\t */\n\t\t\t\tselect: string[];\n\t\t\t\t/**\n\t\t\t\t * The model name.\n\t\t\t\t */\n\t\t\t\tmodel: string;\n\t\t\t\t/**\n\t\t\t\t * The schema of the user's Better-Auth instance.\n\t\t\t\t */\n\t\t\t\tschema: BetterAuthDBSchema;\n\t\t\t\t/**\n\t\t\t\t * The options of the user's Better-Auth instance.\n\t\t\t\t */\n\t\t\t\toptions: Options;\n\t\t }) => any)\n\t\t| undefined;\n\t/**\n\t * Custom ID generator function.\n\t *\n\t * By default, we can handle ID generation for you, however if the database your adapter is for only supports a specific custom id generation,\n\t * then you can use this function to generate your own IDs.\n\t *\n\t *\n\t * Notes:\n\t * - If the user enabled `useNumberId` or `generateId` set to `serial`, then this option will be ignored. Unless this adapter config has `supportsNumericIds` set to `false`.\n\t * - If `generateId` is `false` in the user's Better-Auth config, then this option will be ignored.\n\t * - If `generateId` is a function, then it will override this option.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * customIdGenerator: ({ model }) => {\n\t * return \"my-super-unique-id\";\n\t * }\n\t * ```\n\t */\n\tcustomIdGenerator?: ((props: { model: string }) => string) | undefined;\n\t/**\n\t * Whether to disable the transform output.\n\t * Do not use this option unless you know what you are doing.\n\t * @default false\n\t */\n\tdisableTransformOutput?: boolean | undefined;\n\t/**\n\t * Whether to disable the transform input.\n\t * Do not use this option unless you know what you are doing.\n\t * @default false\n\t */\n\tdisableTransformInput?: boolean | undefined;\n\t/**\n\t * Whether to disable the transform join.\n\t * Do not use this option unless you know what you are doing.\n\t * @default false\n\t */\n\tdisableTransformJoin?: boolean | undefined;\n}\n\nexport const whereOperators = [\n\t\"eq\",\n\t\"ne\",\n\t\"lt\",\n\t\"lte\",\n\t\"gt\",\n\t\"gte\",\n\t\"in\",\n\t\"not_in\",\n\t\"contains\",\n\t\"starts_with\",\n\t\"ends_with\",\n] as const;\n\nexport type WhereOperator = (typeof whereOperators)[number];\n\nexport type Where = {\n\t/**\n\t * @default eq\n\t */\n\toperator?: WhereOperator | undefined;\n\tvalue: string | number | boolean | string[] | number[] | Date | null;\n\tfield: string;\n\t/**\n\t * @default AND\n\t */\n\tconnector?: (\"AND\" | \"OR\") | undefined;\n};\n\n/**\n * JoinOption configuration for relational queries.\n *\n * Allows you to join related tables/models in a single query operation.\n * Each key represents the name of the joined table/model, and the value\n * configures how the join should be performed.\n */\nexport type JoinOption = {\n\t[model: string]: boolean | { limit?: number };\n};\n\n/**\n * Once `JoinOption` has gone through the adapter factory, it will be transformed into a `JoinConfig`.\n */\nexport type JoinConfig = {\n\t[model: string]: {\n\t\t/**\n\t\t * The joining column names.\n\t\t */\n\t\ton: {\n\t\t\t/**\n\t\t\t * Column name from the main table\n\t\t\t */\n\t\t\tfrom: string;\n\t\t\t/**\n\t\t\t * Column name from the joined table\n\t\t\t */\n\t\t\tto: string;\n\t\t};\n\t\t/**\n\t\t * Limit the number of rows to return.\n\t\t *\n\t\t * If the relation has `unique` constraint, then this option will be ignored and limit will be set to 1.\n\t\t *\n\t\t * @default 100\n\t\t */\n\t\tlimit?: number;\n\t\t/**\n\t\t * The relation type. Determines the output joined model data.\n\t\t *\n\t\t * `one-to-one` would have a single object in the output.\n\t\t * `one-to-many` would have an array of objects in the output.\n\t\t * `many-to-many` would have an array of objects in the output.\n\t\t *\n\t\t * @default \"one-to-many\"\n\t\t */\n\t\trelation?: \"one-to-one\" | \"one-to-many\" | \"many-to-many\";\n\t};\n};\n\nexport type DBTransactionAdapter<\n\tOptions extends BetterAuthOptions = BetterAuthOptions,\n> = Omit<DBAdapter<Options>, \"transaction\">;\n\nexport type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {\n\tid: string;\n\tcreate: <T extends Record<string, any>, R = T>(data: {\n\t\tmodel: string;\n\t\tdata: Omit<T, \"id\">;\n\t\tselect?: string[] | undefined;\n\t\t/**\n\t\t * By default, any `id` provided in `data` will be ignored.\n\t\t *\n\t\t * If you want to force the `id` to be the same as the `data.id`, set this to `true`.\n\t\t */\n\t\tforceAllowId?: boolean | undefined;\n\t}) => Promise<R>;\n\tfindOne: <T>(data: {\n\t\tmodel: string;\n\t\twhere: Where[];\n\t\tselect?: string[] | undefined;\n\t\tjoin?: JoinOption | undefined;\n\t}) => Promise<T | null>;\n\tfindMany: <T>(data: {\n\t\tmodel: string;\n\t\twhere?: Where[] | undefined;\n\t\tlimit?: number | undefined;\n\t\tselect?: string[] | undefined;\n\t\tsortBy?:\n\t\t\t| {\n\t\t\t\t\tfield: string;\n\t\t\t\t\tdirection: \"asc\" | \"desc\";\n\t\t\t }\n\t\t\t| undefined;\n\t\toffset?: number | undefined;\n\t\tjoin?: JoinOption | undefined;\n\t}) => Promise<T[]>;\n\tcount: (data: {\n\t\tmodel: string;\n\t\twhere?: Where[] | undefined;\n\t}) => Promise<number>;\n\t/**\n\t * ⚠︎ Update may not return the updated data\n\t * if multiple where clauses are provided\n\t */\n\tupdate: <T>(data: {\n\t\tmodel: string;\n\t\twhere: Where[];\n\t\tupdate: Record<string, any>;\n\t}) => Promise<T | null>;\n\tupdateMany: (data: {\n\t\tmodel: string;\n\t\twhere: Where[];\n\t\tupdate: Record<string, any>;\n\t}) => Promise<number>;\n\tdelete: <_T>(data: { model: string; where: Where[] }) => Promise<void>;\n\tdeleteMany: (data: { model: string; where: Where[] }) => Promise<number>;\n\t/**\n\t * Execute multiple operations in a transaction.\n\t * If the adapter doesn't support transactions, operations will be executed sequentially.\n\t */\n\ttransaction: <R>(\n\t\tcallback: (trx: DBTransactionAdapter<Options>) => Promise<R>,\n\t) => Promise<R>;\n\t/**\n\t *\n\t * @param options\n\t * @param file - file path if provided by the user\n\t */\n\tcreateSchema?:\n\t\t| ((options: Options, file?: string) => Promise<DBAdapterSchemaCreation>)\n\t\t| undefined;\n\toptions?:\n\t\t| ({\n\t\t\t\tadapterConfig: DBAdapterFactoryConfig<Options>;\n\t\t } & CustomAdapter[\"options\"])\n\t\t| undefined;\n};\n\nexport type CleanedWhere = Required<Where>;\n\nexport interface CustomAdapter {\n\tcreate: <T extends Record<string, any>>({\n\t\tdata,\n\t\tmodel,\n\t\tselect,\n\t}: {\n\t\tmodel: string;\n\t\tdata: T;\n\t\tselect?: string[] | undefined;\n\t}) => Promise<T>;\n\tupdate: <T>(data: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t\tupdate: T;\n\t}) => Promise<T | null>;\n\tupdateMany: (data: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t\tupdate: Record<string, any>;\n\t}) => Promise<number>;\n\tfindOne: <T>({\n\t\tmodel,\n\t\twhere,\n\t\tselect,\n\t\tjoin,\n\t}: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t\tselect?: string[] | undefined;\n\t\tjoin?: JoinConfig | undefined;\n\t}) => Promise<T | null>;\n\tfindMany: <T>({\n\t\tmodel,\n\t\twhere,\n\t\tlimit,\n\t\tselect,\n\t\tsortBy,\n\t\toffset,\n\t\tjoin,\n\t}: {\n\t\tmodel: string;\n\t\twhere?: CleanedWhere[] | undefined;\n\t\tlimit: number;\n\t\tselect?: string[] | undefined;\n\t\tsortBy?: { field: string; direction: \"asc\" | \"desc\" } | undefined;\n\t\toffset?: number | undefined;\n\t\tjoin?: JoinConfig | undefined;\n\t}) => Promise<T[]>;\n\tdelete: ({\n\t\tmodel,\n\t\twhere,\n\t}: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t}) => Promise<void>;\n\tdeleteMany: ({\n\t\tmodel,\n\t\twhere,\n\t}: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t}) => Promise<number>;\n\tcount: ({\n\t\tmodel,\n\t\twhere,\n\t}: {\n\t\tmodel: string;\n\t\twhere?: CleanedWhere[] | undefined;\n\t}) => Promise<number>;\n\tcreateSchema?:\n\t\t| ((props: {\n\t\t\t\t/**\n\t\t\t\t * The file the user may have passed in to the `generate` command as the expected schema file output path.\n\t\t\t\t */\n\t\t\t\tfile?: string;\n\t\t\t\t/**\n\t\t\t\t * The tables from the user's Better-Auth instance schema.\n\t\t\t\t */\n\t\t\t\ttables: BetterAuthDBSchema;\n\t\t }) => Promise<DBAdapterSchemaCreation>)\n\t\t| undefined;\n\t/**\n\t * Your adapter's options.\n\t */\n\toptions?: Record<string, any> | undefined;\n}\n\nexport interface DBAdapterInstance<\n\tOptions extends BetterAuthOptions = BetterAuthOptions,\n> {\n\t(options: BetterAuthOptions): DBAdapter<Options>;\n}\n\nexport * from \"./factory\";\nexport * from \"./types\";\nexport * from \"./utils\";\n"],"mappings":";;;;;;;;;;AA+SA,MAAa,iBAAiB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/db/adapter/index.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"../../types\";\nimport type { BetterAuthDBSchema, DBFieldAttribute } from \"../type\";\n\nexport type DBAdapterDebugLogOption =\n\t| boolean\n\t| {\n\t\t\t/**\n\t\t\t * Useful when you want to log only certain conditions.\n\t\t\t */\n\t\t\tlogCondition?: (() => boolean) | undefined;\n\t\t\tcreate?: boolean | undefined;\n\t\t\tupdate?: boolean | undefined;\n\t\t\tupdateMany?: boolean | undefined;\n\t\t\tfindOne?: boolean | undefined;\n\t\t\tfindMany?: boolean | undefined;\n\t\t\tdelete?: boolean | undefined;\n\t\t\tdeleteMany?: boolean | undefined;\n\t\t\tcount?: boolean | undefined;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Only used for adapter tests to show debug logs if a test fails.\n\t\t\t *\n\t\t\t * @deprecated Not actually deprecated. Doing this for IDEs to show this option at the very bottom and stop end-users from using this.\n\t\t\t */\n\t\t\tisRunningAdapterTests: boolean;\n\t };\n\nexport type DBAdapterSchemaCreation = {\n\t/**\n\t * Code to be inserted into the file\n\t */\n\tcode: string;\n\t/**\n\t * Path to the file, including the file name and extension.\n\t * Relative paths are supported, with the current working directory of the developer's project as the base.\n\t */\n\tpath: string;\n\t/**\n\t * Append the file if it already exists.\n\t * Note: This will not apply if `overwrite` is set to true.\n\t */\n\tappend?: boolean | undefined;\n\t/**\n\t * Overwrite the file if it already exists\n\t */\n\toverwrite?: boolean | undefined;\n};\n\nexport interface DBAdapterFactoryConfig<\n\tOptions extends BetterAuthOptions = BetterAuthOptions,\n> {\n\t/**\n\t * Use plural table names.\n\t *\n\t * All tables will be named with an `s` at the end.\n\t *\n\t * @default false\n\t */\n\tusePlural?: boolean | undefined;\n\t/**\n\t * Enable debug logs.\n\t *\n\t * @default false\n\t */\n\tdebugLogs?: DBAdapterDebugLogOption | undefined;\n\t/**\n\t * Name of the adapter.\n\t *\n\t * This is used to identify the adapter in the debug logs.\n\t *\n\t * @default `adapterId`\n\t */\n\tadapterName?: string | undefined;\n\t/**\n\t * Adapter id\n\t */\n\tadapterId: string;\n\t/**\n\t * If the database supports numeric ids, set this to `true`.\n\t *\n\t * @default true\n\t */\n\tsupportsNumericIds?: boolean | undefined;\n\t/**\n\t * If the database supports natively generating UUIDs, set this to `true`.\n\t *\n\t * @default false\n\t */\n\tsupportsUUIDs?: boolean | undefined;\n\t/**\n\t * If the database doesn't support JSON columns, set this to `false`.\n\t *\n\t * We will handle the translation between using `JSON` columns, and saving `string`s to the database.\n\t *\n\t * @default false\n\t */\n\tsupportsJSON?: boolean | undefined;\n\t/**\n\t * If the database doesn't support dates, set this to `false`.\n\t *\n\t * We will handle the translation between using `Date` objects, and saving `string`s to the database.\n\t *\n\t * @default true\n\t */\n\tsupportsDates?: boolean | undefined;\n\t/**\n\t * If the database doesn't support booleans, set this to `false`.\n\t *\n\t * We will handle the translation between using `boolean`s, and saving `0`s and `1`s to the database.\n\t *\n\t * @default true\n\t */\n\tsupportsBooleans?: boolean | undefined;\n\t/**\n\t * If the database doesn't support arrays, set this to `false`.\n\t *\n\t * We will handle the translation between using `array`s, and saving `string`s to the database.\n\t *\n\t * @default false\n\t */\n\tsupportsArrays?: boolean | undefined;\n\t/**\n\t * Execute multiple operations in a transaction.\n\t *\n\t * If the database doesn't support transactions, set this to `false` and operations will be executed sequentially.\n\t *\n\t * @default false\n\t */\n\ttransaction?:\n\t\t| (\n\t\t\t\t| false\n\t\t\t\t| (<R>(\n\t\t\t\t\t\tcallback: (trx: DBTransactionAdapter<Options>) => Promise<R>,\n\t\t\t\t ) => Promise<R>)\n\t\t )\n\t\t| undefined;\n\t/**\n\t * Disable id generation for the `create` method.\n\t *\n\t * This is useful for databases that don't support custom id values and would auto-generate them for you.\n\t *\n\t * @default false\n\t */\n\tdisableIdGeneration?: boolean | undefined;\n\t/**\n\t * Map the keys of the input data.\n\t *\n\t * This is useful for databases that expect a different key name for a given situation.\n\t *\n\t * For example, MongoDB uses `_id` while in Better-Auth we use `id`.\n\t *\n\t *\n\t * @example\n\t * Each key represents the old key to replace.\n\t * The value represents the new key\n\t *\n\t * This can be a partial object that only transforms some keys.\n\t *\n\t * ```ts\n\t * mapKeysTransformInput: {\n\t * id: \"_id\" // We want to replace `id` to `_id` to save into MongoDB\n\t * }\n\t * ```\n\t */\n\tmapKeysTransformInput?: Record<string, string> | undefined;\n\t/**\n\t * Map the keys of the output data.\n\t *\n\t * This is useful for databases that expect a different key name for a given situation.\n\t *\n\t * For example, MongoDB uses `_id` while in Better-Auth we use `id`.\n\t *\n\t * @example\n\t * Each key represents the old key to replace.\n\t * The value represents the new key\n\t *\n\t * This can be a partial object that only transforms some keys.\n\t *\n\t * ```ts\n\t * mapKeysTransformOutput: {\n\t * _id: \"id\" // In MongoDB, we save `id` as `_id`. So we want to replace `_id` with `id` when we get the data back.\n\t * }\n\t * ```\n\t */\n\tmapKeysTransformOutput?: Record<string, string> | undefined;\n\t/**\n\t * Custom transform input function.\n\t *\n\t * This function is used to transform the input data before it is saved to the database.\n\t */\n\tcustomTransformInput?:\n\t\t| ((props: {\n\t\t\t\tdata: any;\n\t\t\t\t/**\n\t\t\t\t * The fields of the model.\n\t\t\t\t */\n\t\t\t\tfieldAttributes: DBFieldAttribute;\n\t\t\t\t/**\n\t\t\t\t * The field to transform.\n\t\t\t\t */\n\t\t\t\tfield: string;\n\t\t\t\t/**\n\t\t\t\t * The action which was called from the adapter.\n\t\t\t\t */\n\t\t\t\taction:\n\t\t\t\t\t| \"create\"\n\t\t\t\t\t| \"update\"\n\t\t\t\t\t| \"findOne\"\n\t\t\t\t\t| \"findMany\"\n\t\t\t\t\t| \"updateMany\"\n\t\t\t\t\t| \"delete\"\n\t\t\t\t\t| \"deleteMany\"\n\t\t\t\t\t| \"count\";\n\t\t\t\t/**\n\t\t\t\t * The model name.\n\t\t\t\t */\n\t\t\t\tmodel: string;\n\t\t\t\t/**\n\t\t\t\t * The schema of the user's Better-Auth instance.\n\t\t\t\t */\n\t\t\t\tschema: BetterAuthDBSchema;\n\t\t\t\t/**\n\t\t\t\t * The options of the user's Better-Auth instance.\n\t\t\t\t */\n\t\t\t\toptions: Options;\n\t\t }) => any)\n\t\t| undefined;\n\t/**\n\t * Custom transform output function.\n\t *\n\t * This function is used to transform the output data before it is returned to the user.\n\t */\n\tcustomTransformOutput?:\n\t\t| ((props: {\n\t\t\t\tdata: any;\n\t\t\t\t/**\n\t\t\t\t * The fields of the model.\n\t\t\t\t */\n\t\t\t\tfieldAttributes: DBFieldAttribute;\n\t\t\t\t/**\n\t\t\t\t * The field to transform.\n\t\t\t\t */\n\t\t\t\tfield: string;\n\t\t\t\t/**\n\t\t\t\t * The fields to select.\n\t\t\t\t */\n\t\t\t\tselect: string[];\n\t\t\t\t/**\n\t\t\t\t * The model name.\n\t\t\t\t */\n\t\t\t\tmodel: string;\n\t\t\t\t/**\n\t\t\t\t * The schema of the user's Better-Auth instance.\n\t\t\t\t */\n\t\t\t\tschema: BetterAuthDBSchema;\n\t\t\t\t/**\n\t\t\t\t * The options of the user's Better-Auth instance.\n\t\t\t\t */\n\t\t\t\toptions: Options;\n\t\t }) => any)\n\t\t| undefined;\n\t/**\n\t * Custom ID generator function.\n\t *\n\t * By default, we can handle ID generation for you, however if the database your adapter is for only supports a specific custom id generation,\n\t * then you can use this function to generate your own IDs.\n\t *\n\t *\n\t * Notes:\n\t * - If the user enabled `useNumberId` or `generateId` set to `serial`, then this option will be ignored. Unless this adapter config has `supportsNumericIds` set to `false`.\n\t * - If `generateId` is `false` in the user's Better-Auth config, then this option will be ignored.\n\t * - If `generateId` is a function, then it will override this option.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * customIdGenerator: ({ model }) => {\n\t * return \"my-super-unique-id\";\n\t * }\n\t * ```\n\t */\n\tcustomIdGenerator?: ((props: { model: string }) => string) | undefined;\n\t/**\n\t * Whether to disable the transform output.\n\t * Do not use this option unless you know what you are doing.\n\t * @default false\n\t */\n\tdisableTransformOutput?: boolean | undefined;\n\t/**\n\t * Whether to disable the transform input.\n\t * Do not use this option unless you know what you are doing.\n\t * @default false\n\t */\n\tdisableTransformInput?: boolean | undefined;\n\t/**\n\t * Whether to disable the transform join.\n\t * Do not use this option unless you know what you are doing.\n\t * @default false\n\t */\n\tdisableTransformJoin?: boolean | undefined;\n}\n\nexport const whereOperators = [\n\t\"eq\",\n\t\"ne\",\n\t\"lt\",\n\t\"lte\",\n\t\"gt\",\n\t\"gte\",\n\t\"in\",\n\t\"not_in\",\n\t\"contains\",\n\t\"starts_with\",\n\t\"ends_with\",\n] as const;\n\nexport type WhereOperator = (typeof whereOperators)[number];\n\nexport type Where = {\n\t/**\n\t * @default eq\n\t */\n\toperator?: WhereOperator | undefined;\n\tvalue: string | number | boolean | string[] | number[] | Date | null;\n\tfield: string;\n\t/**\n\t * @default AND\n\t */\n\tconnector?: (\"AND\" | \"OR\") | undefined;\n};\n\n/**\n * JoinOption configuration for relational queries.\n *\n * Allows you to join related tables/models in a single query operation.\n * Each key represents the name of the joined table/model, and the value\n * configures how the join should be performed.\n */\nexport type JoinOption = {\n\t[model: string]: boolean | { limit?: number };\n};\n\n/**\n * Once `JoinOption` has gone through the adapter factory, it will be transformed into a `JoinConfig`.\n */\nexport type JoinConfig = {\n\t[model: string]: {\n\t\t/**\n\t\t * The joining column names.\n\t\t */\n\t\ton: {\n\t\t\t/**\n\t\t\t * Column name from the main table\n\t\t\t */\n\t\t\tfrom: string;\n\t\t\t/**\n\t\t\t * Column name from the joined table\n\t\t\t */\n\t\t\tto: string;\n\t\t};\n\t\t/**\n\t\t * Limit the number of rows to return.\n\t\t *\n\t\t * If the relation has `unique` constraint, then this option will be ignored and limit will be set to 1.\n\t\t *\n\t\t * @default 100\n\t\t */\n\t\tlimit?: number;\n\t\t/**\n\t\t * The relation type. Determines the output joined model data.\n\t\t *\n\t\t * `one-to-one` would have a single object in the output.\n\t\t * `one-to-many` would have an array of objects in the output.\n\t\t * `many-to-many` would have an array of objects in the output.\n\t\t *\n\t\t * @default \"one-to-many\"\n\t\t */\n\t\trelation?: \"one-to-one\" | \"one-to-many\" | \"many-to-many\";\n\t};\n};\n\nexport type DBTransactionAdapter<\n\tOptions extends BetterAuthOptions = BetterAuthOptions,\n> = Omit<DBAdapter<Options>, \"transaction\">;\n\nexport type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {\n\tid: string;\n\tcreate: <T extends Record<string, any>, R = T>(data: {\n\t\tmodel: string;\n\t\tdata: Omit<T, \"id\">;\n\t\tselect?: string[] | undefined;\n\t\t/**\n\t\t * By default, any `id` provided in `data` will be ignored.\n\t\t *\n\t\t * If you want to force the `id` to be the same as the `data.id`, set this to `true`.\n\t\t */\n\t\tforceAllowId?: boolean | undefined;\n\t}) => Promise<R>;\n\tfindOne: <T>(data: {\n\t\tmodel: string;\n\t\twhere: Where[];\n\t\tselect?: string[] | undefined;\n\t\tjoin?: JoinOption | undefined;\n\t}) => Promise<T | null>;\n\tfindMany: <T>(data: {\n\t\tmodel: string;\n\t\twhere?: Where[] | undefined;\n\t\tlimit?: number | undefined;\n\t\tselect?: string[] | undefined;\n\t\tsortBy?:\n\t\t\t| {\n\t\t\t\t\tfield: string;\n\t\t\t\t\tdirection: \"asc\" | \"desc\";\n\t\t\t }\n\t\t\t| undefined;\n\t\toffset?: number | undefined;\n\t\tjoin?: JoinOption | undefined;\n\t}) => Promise<T[]>;\n\tcount: (data: {\n\t\tmodel: string;\n\t\twhere?: Where[] | undefined;\n\t}) => Promise<number>;\n\t/**\n\t * ⚠︎ Update may not return the updated data\n\t * if multiple where clauses are provided\n\t */\n\tupdate: <T>(data: {\n\t\tmodel: string;\n\t\twhere: Where[];\n\t\tupdate: Record<string, any>;\n\t}) => Promise<T | null>;\n\tupdateMany: (data: {\n\t\tmodel: string;\n\t\twhere: Where[];\n\t\tupdate: Record<string, any>;\n\t}) => Promise<number>;\n\tdelete: <_T>(data: { model: string; where: Where[] }) => Promise<void>;\n\tdeleteMany: (data: { model: string; where: Where[] }) => Promise<number>;\n\t/**\n\t * Execute multiple operations in a transaction.\n\t * If the adapter doesn't support transactions, operations will be executed sequentially.\n\t */\n\ttransaction: <R>(\n\t\tcallback: (trx: DBTransactionAdapter<Options>) => Promise<R>,\n\t) => Promise<R>;\n\t/**\n\t *\n\t * @param options\n\t * @param file - file path if provided by the user\n\t */\n\tcreateSchema?:\n\t\t| ((options: Options, file?: string) => Promise<DBAdapterSchemaCreation>)\n\t\t| undefined;\n\toptions?:\n\t\t| ({\n\t\t\t\tadapterConfig: DBAdapterFactoryConfig<Options>;\n\t\t } & CustomAdapter[\"options\"])\n\t\t| undefined;\n};\n\nexport type CleanedWhere = Required<Where>;\n\nexport interface CustomAdapter {\n\tcreate: <T extends Record<string, any>>({\n\t\tdata,\n\t\tmodel,\n\t\tselect,\n\t}: {\n\t\tmodel: string;\n\t\tdata: T;\n\t\tselect?: string[] | undefined;\n\t}) => Promise<T>;\n\tupdate: <T>(data: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t\tupdate: T;\n\t}) => Promise<T | null>;\n\tupdateMany: (data: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t\tupdate: Record<string, any>;\n\t}) => Promise<number>;\n\tfindOne: <T>({\n\t\tmodel,\n\t\twhere,\n\t\tselect,\n\t\tjoin,\n\t}: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t\tselect?: string[] | undefined;\n\t\tjoin?: JoinConfig | undefined;\n\t}) => Promise<T | null>;\n\tfindMany: <T>({\n\t\tmodel,\n\t\twhere,\n\t\tlimit,\n\t\tselect,\n\t\tsortBy,\n\t\toffset,\n\t\tjoin,\n\t}: {\n\t\tmodel: string;\n\t\twhere?: CleanedWhere[] | undefined;\n\t\tlimit: number;\n\t\tselect?: string[] | undefined;\n\t\tsortBy?: { field: string; direction: \"asc\" | \"desc\" } | undefined;\n\t\toffset?: number | undefined;\n\t\tjoin?: JoinConfig | undefined;\n\t}) => Promise<T[]>;\n\tdelete: ({\n\t\tmodel,\n\t\twhere,\n\t}: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t}) => Promise<void>;\n\tdeleteMany: ({\n\t\tmodel,\n\t\twhere,\n\t}: {\n\t\tmodel: string;\n\t\twhere: CleanedWhere[];\n\t}) => Promise<number>;\n\tcount: ({\n\t\tmodel,\n\t\twhere,\n\t}: {\n\t\tmodel: string;\n\t\twhere?: CleanedWhere[] | undefined;\n\t}) => Promise<number>;\n\tcreateSchema?:\n\t\t| ((props: {\n\t\t\t\t/**\n\t\t\t\t * The file the user may have passed in to the `generate` command as the expected schema file output path.\n\t\t\t\t */\n\t\t\t\tfile?: string;\n\t\t\t\t/**\n\t\t\t\t * The tables from the user's Better-Auth instance schema.\n\t\t\t\t */\n\t\t\t\ttables: BetterAuthDBSchema;\n\t\t }) => Promise<DBAdapterSchemaCreation>)\n\t\t| undefined;\n\t/**\n\t * Your adapter's options.\n\t */\n\toptions?: Record<string, any> | undefined;\n}\n\nexport interface DBAdapterInstance<\n\tOptions extends BetterAuthOptions = BetterAuthOptions,\n> {\n\t(options: BetterAuthOptions): DBAdapter<Options>;\n}\n\nexport * from \"./factory\";\nexport * from \"./types\";\nexport * from \"./utils\";\n"],"mappings":";;;;;;;;;AA+SA,MAAa,iBAAiB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { BetterAuthDBSchema, DBFieldAttribute } from "../type.mjs";
|
|
2
2
|
import { CleanedWhere, CustomAdapter, DBAdapterFactoryConfig, DBTransactionAdapter, JoinConfig, Where } from "./index.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
4
|
-
import "../../types/index.mjs";
|
|
5
|
-
|
|
6
4
|
//#region src/db/adapter/types.d.ts
|
|
7
5
|
type AdapterFactoryOptions = {
|
|
8
6
|
config: AdapterFactoryConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/db/adapter/utils.ts"],"sourcesContent":["import type { DBFieldAttribute } from \"../type\";\n\nexport function withApplyDefault(\n\tvalue: any,\n\tfield: DBFieldAttribute,\n\taction: \"create\" | \"update\" | \"findOne\" | \"findMany\",\n) {\n\tif (action === \"update\") {\n\t\t// Apply onUpdate if value is undefined\n\t\tif (value === undefined && field.onUpdate !== undefined) {\n\t\t\tif (typeof field.onUpdate === \"function\") {\n\t\t\t\treturn field.onUpdate();\n\t\t\t}\n\t\t\treturn field.onUpdate;\n\t\t}\n\t\treturn value;\n\t}\n\tif (action === \"create\") {\n\t\t// we do not want to apply default values if the value is null & not required\n\t\tif (value === undefined || (field.required === true && value === null)) {\n\t\t\tif (field.defaultValue !== undefined) {\n\t\t\t\tif (typeof field.defaultValue === \"function\") {\n\t\t\t\t\treturn field.defaultValue();\n\t\t\t\t}\n\t\t\t\treturn field.defaultValue;\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}\n\nfunction isObject(item: unknown): item is Record<string, unknown> {\n\treturn item !== null && typeof item === \"object\" && !Array.isArray(item);\n}\n\nexport function deepmerge<T>(target: T, source: Partial<T>): T {\n\tif (Array.isArray(target) && Array.isArray(source)) {\n\t\t// merge arrays by concatenation\n\t\treturn [...target, ...source] as T;\n\t} else if (isObject(target) && isObject(source)) {\n\t\tconst result: Record<string, unknown> = { ...target };\n\n\t\tfor (const [key, value] of Object.entries(source)) {\n\t\t\tif (value === undefined) continue; // skip undefined\n\n\t\t\tif (key in target) {\n\t\t\t\tresult[key] = deepmerge(\n\t\t\t\t\t(target as Record<string, unknown>)[key],\n\t\t\t\t\tvalue as unknown as Partial<T>,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tresult[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn result as T;\n\t}\n\n\t// primitives and fallback: source overrides target\n\treturn source as T;\n}\n"],"mappings":";AAEA,SAAgB,iBACf,OACA,OACA,QACC;AACD,KAAI,WAAW,UAAU;AAExB,MAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/db/adapter/utils.ts"],"sourcesContent":["import type { DBFieldAttribute } from \"../type\";\n\nexport function withApplyDefault(\n\tvalue: any,\n\tfield: DBFieldAttribute,\n\taction: \"create\" | \"update\" | \"findOne\" | \"findMany\",\n) {\n\tif (action === \"update\") {\n\t\t// Apply onUpdate if value is undefined\n\t\tif (value === undefined && field.onUpdate !== undefined) {\n\t\t\tif (typeof field.onUpdate === \"function\") {\n\t\t\t\treturn field.onUpdate();\n\t\t\t}\n\t\t\treturn field.onUpdate;\n\t\t}\n\t\treturn value;\n\t}\n\tif (action === \"create\") {\n\t\t// we do not want to apply default values if the value is null & not required\n\t\tif (value === undefined || (field.required === true && value === null)) {\n\t\t\tif (field.defaultValue !== undefined) {\n\t\t\t\tif (typeof field.defaultValue === \"function\") {\n\t\t\t\t\treturn field.defaultValue();\n\t\t\t\t}\n\t\t\t\treturn field.defaultValue;\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}\n\nfunction isObject(item: unknown): item is Record<string, unknown> {\n\treturn item !== null && typeof item === \"object\" && !Array.isArray(item);\n}\n\nexport function deepmerge<T>(target: T, source: Partial<T>): T {\n\tif (Array.isArray(target) && Array.isArray(source)) {\n\t\t// merge arrays by concatenation\n\t\treturn [...target, ...source] as T;\n\t} else if (isObject(target) && isObject(source)) {\n\t\tconst result: Record<string, unknown> = { ...target };\n\n\t\tfor (const [key, value] of Object.entries(source)) {\n\t\t\tif (value === undefined) continue; // skip undefined\n\n\t\t\tif (key in target) {\n\t\t\t\tresult[key] = deepmerge(\n\t\t\t\t\t(target as Record<string, unknown>)[key],\n\t\t\t\t\tvalue as unknown as Partial<T>,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tresult[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn result as T;\n\t}\n\n\t// primitives and fallback: source overrides target\n\treturn source as T;\n}\n"],"mappings":";AAEA,SAAgB,iBACf,OACA,OACA,QACC;AACD,KAAI,WAAW,UAAU;AAExB,MAAI,UAAU,KAAA,KAAa,MAAM,aAAa,KAAA,GAAW;AACxD,OAAI,OAAO,MAAM,aAAa,WAC7B,QAAO,MAAM,UAAU;AAExB,UAAO,MAAM;;AAEd,SAAO;;AAER,KAAI,WAAW;MAEV,UAAU,KAAA,KAAc,MAAM,aAAa,QAAQ,UAAU;OAC5D,MAAM,iBAAiB,KAAA,GAAW;AACrC,QAAI,OAAO,MAAM,iBAAiB,WACjC,QAAO,MAAM,cAAc;AAE5B,WAAO,MAAM;;;;AAIhB,QAAO;;AAGR,SAAS,SAAS,MAAgD;AACjE,QAAO,SAAS,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,KAAK;;AAGzE,SAAgB,UAAa,QAAW,QAAuB;AAC9D,KAAI,MAAM,QAAQ,OAAO,IAAI,MAAM,QAAQ,OAAO,CAEjD,QAAO,CAAC,GAAG,QAAQ,GAAG,OAAO;UACnB,SAAS,OAAO,IAAI,SAAS,OAAO,EAAE;EAChD,MAAM,SAAkC,EAAE,GAAG,QAAQ;AAErD,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,EAAE;AAClD,OAAI,UAAU,KAAA,EAAW;AAEzB,OAAI,OAAO,OACV,QAAO,OAAO,UACZ,OAAmC,MACpC,MACA;OAED,QAAO,OAAO;;AAIhB,SAAO;;AAIR,QAAO"}
|
package/dist/db/get-tables.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { BetterAuthDBSchema } from "./type.mjs";
|
|
2
2
|
import { BetterAuthOptions } from "../types/init-options.mjs";
|
|
3
|
-
import "../types/index.mjs";
|
|
4
|
-
|
|
5
3
|
//#region src/db/get-tables.d.ts
|
|
6
4
|
declare const getAuthTables: (options: BetterAuthOptions) => BetterAuthDBSchema;
|
|
7
5
|
//#endregion
|
package/dist/db/get-tables.mjs
CHANGED
package/dist/db/index.mjs
CHANGED
|
@@ -5,5 +5,4 @@ import { rateLimitSchema } from "./schema/rate-limit.mjs";
|
|
|
5
5
|
import { sessionSchema } from "./schema/session.mjs";
|
|
6
6
|
import { userSchema } from "./schema/user.mjs";
|
|
7
7
|
import { verificationSchema } from "./schema/verification.mjs";
|
|
8
|
-
|
|
9
|
-
export { accountSchema, coreSchema, getAuthTables, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
|
|
8
|
+
export { accountSchema, coreSchema, getAuthTables, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
2
2
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
4
|
-
import "../../types/index.mjs";
|
|
5
4
|
import * as z from "zod";
|
|
6
5
|
|
|
7
6
|
//#region src/db/schema/account.d.ts
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { coreSchema } from "./shared.mjs";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
|
|
4
3
|
//#region src/db/schema/account.ts
|
|
5
4
|
const accountSchema = coreSchema.extend({
|
|
6
5
|
providerId: z.string(),
|
|
@@ -14,7 +13,7 @@ const accountSchema = coreSchema.extend({
|
|
|
14
13
|
scope: z.string().nullish(),
|
|
15
14
|
password: z.string().nullish()
|
|
16
15
|
});
|
|
17
|
-
|
|
18
16
|
//#endregion
|
|
19
17
|
export { accountSchema };
|
|
18
|
+
|
|
20
19
|
//# sourceMappingURL=account.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.mjs","names":[],"sources":["../../../src/db/schema/account.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { Prettify } from \"../../types\";\nimport type { BetterAuthOptions } from \"../../types/init-options\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const accountSchema = coreSchema.extend({\n\tproviderId: z.string(),\n\taccountId: z.string(),\n\tuserId: z.coerce.string(),\n\taccessToken: z.string().nullish(),\n\trefreshToken: z.string().nullish(),\n\tidToken: z.string().nullish(),\n\t/**\n\t * Access token expires at\n\t */\n\taccessTokenExpiresAt: z.date().nullish(),\n\t/**\n\t * Refresh token expires at\n\t */\n\trefreshTokenExpiresAt: z.date().nullish(),\n\t/**\n\t * The scopes that the user has authorized\n\t */\n\tscope: z.string().nullish(),\n\t/**\n\t * Password is only stored in the credential provider\n\t */\n\tpassword: z.string().nullish(),\n});\n\nexport type BaseAccount = z.infer<typeof accountSchema>;\n\n/**\n * Account schema type used by better-auth, note that it's possible that account could have additional fields\n */\nexport type Account<\n\tDBOptions extends BetterAuthOptions[\"account\"] = BetterAuthOptions[\"account\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseAccount &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"account\", Plugins>\n>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"account.mjs","names":[],"sources":["../../../src/db/schema/account.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { Prettify } from \"../../types\";\nimport type { BetterAuthOptions } from \"../../types/init-options\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const accountSchema = coreSchema.extend({\n\tproviderId: z.string(),\n\taccountId: z.string(),\n\tuserId: z.coerce.string(),\n\taccessToken: z.string().nullish(),\n\trefreshToken: z.string().nullish(),\n\tidToken: z.string().nullish(),\n\t/**\n\t * Access token expires at\n\t */\n\taccessTokenExpiresAt: z.date().nullish(),\n\t/**\n\t * Refresh token expires at\n\t */\n\trefreshTokenExpiresAt: z.date().nullish(),\n\t/**\n\t * The scopes that the user has authorized\n\t */\n\tscope: z.string().nullish(),\n\t/**\n\t * Password is only stored in the credential provider\n\t */\n\tpassword: z.string().nullish(),\n});\n\nexport type BaseAccount = z.infer<typeof accountSchema>;\n\n/**\n * Account schema type used by better-auth, note that it's possible that account could have additional fields\n */\nexport type Account<\n\tDBOptions extends BetterAuthOptions[\"account\"] = BetterAuthOptions[\"account\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseAccount &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"account\", Plugins>\n>;\n"],"mappings":";;;AASA,MAAa,gBAAgB,WAAW,OAAO;CAC9C,YAAY,EAAE,QAAQ;CACtB,WAAW,EAAE,QAAQ;CACrB,QAAQ,EAAE,OAAO,QAAQ;CACzB,aAAa,EAAE,QAAQ,CAAC,SAAS;CACjC,cAAc,EAAE,QAAQ,CAAC,SAAS;CAClC,SAAS,EAAE,QAAQ,CAAC,SAAS;CAI7B,sBAAsB,EAAE,MAAM,CAAC,SAAS;CAIxC,uBAAuB,EAAE,MAAM,CAAC,SAAS;CAIzC,OAAO,EAAE,QAAQ,CAAC,SAAS;CAI3B,UAAU,EAAE,QAAQ,CAAC,SAAS;CAC9B,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
2
2
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
4
|
-
import "../../types/index.mjs";
|
|
5
4
|
import * as z from "zod";
|
|
6
5
|
|
|
7
6
|
//#region src/db/schema/rate-limit.d.ts
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
|
|
3
2
|
//#region src/db/schema/rate-limit.ts
|
|
4
3
|
const rateLimitSchema = z.object({
|
|
5
4
|
key: z.string(),
|
|
6
5
|
count: z.number(),
|
|
7
6
|
lastRequest: z.number()
|
|
8
7
|
});
|
|
9
|
-
|
|
10
8
|
//#endregion
|
|
11
9
|
export { rateLimitSchema };
|
|
10
|
+
|
|
12
11
|
//# sourceMappingURL=rate-limit.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.mjs","names":[],"sources":["../../../src/db/schema/rate-limit.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\n\nexport const rateLimitSchema = z.object({\n\t/**\n\t * The key to use for rate limiting\n\t */\n\tkey: z.string(),\n\t/**\n\t * The number of requests made\n\t */\n\tcount: z.number(),\n\t/**\n\t * The last request time in milliseconds\n\t */\n\tlastRequest: z.number(),\n});\n\nexport type BaseRateLimit = z.infer<typeof rateLimitSchema>;\n\n/**\n * Rate limit schema type used by better-auth for rate limiting\n */\nexport type RateLimit<\n\tDBOptions extends\n\t\tBetterAuthOptions[\"rateLimit\"] = BetterAuthOptions[\"rateLimit\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseRateLimit &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"rateLimit\", Plugins>\n>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rate-limit.mjs","names":[],"sources":["../../../src/db/schema/rate-limit.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\n\nexport const rateLimitSchema = z.object({\n\t/**\n\t * The key to use for rate limiting\n\t */\n\tkey: z.string(),\n\t/**\n\t * The number of requests made\n\t */\n\tcount: z.number(),\n\t/**\n\t * The last request time in milliseconds\n\t */\n\tlastRequest: z.number(),\n});\n\nexport type BaseRateLimit = z.infer<typeof rateLimitSchema>;\n\n/**\n * Rate limit schema type used by better-auth for rate limiting\n */\nexport type RateLimit<\n\tDBOptions extends\n\t\tBetterAuthOptions[\"rateLimit\"] = BetterAuthOptions[\"rateLimit\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseRateLimit &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"rateLimit\", Plugins>\n>;\n"],"mappings":";;AAOA,MAAa,kBAAkB,EAAE,OAAO;CAIvC,KAAK,EAAE,QAAQ;CAIf,OAAO,EAAE,QAAQ;CAIjB,aAAa,EAAE,QAAQ;CACvB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
2
2
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
4
|
-
import "../../types/index.mjs";
|
|
5
4
|
import * as z from "zod";
|
|
6
5
|
|
|
7
6
|
//#region src/db/schema/session.d.ts
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { coreSchema } from "./shared.mjs";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
|
|
4
3
|
//#region src/db/schema/session.ts
|
|
5
4
|
const sessionSchema = coreSchema.extend({
|
|
6
5
|
userId: z.coerce.string(),
|
|
@@ -9,7 +8,7 @@ const sessionSchema = coreSchema.extend({
|
|
|
9
8
|
ipAddress: z.string().nullish(),
|
|
10
9
|
userAgent: z.string().nullish()
|
|
11
10
|
});
|
|
12
|
-
|
|
13
11
|
//#endregion
|
|
14
12
|
export { sessionSchema };
|
|
13
|
+
|
|
15
14
|
//# sourceMappingURL=session.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.mjs","names":[],"sources":["../../../src/db/schema/session.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const sessionSchema = coreSchema.extend({\n\tuserId: z.coerce.string(),\n\texpiresAt: z.date(),\n\ttoken: z.string(),\n\tipAddress: z.string().nullish(),\n\tuserAgent: z.string().nullish(),\n});\n\nexport type BaseSession = z.infer<typeof sessionSchema>;\n\n/**\n * Session schema type used by better-auth, note that it's possible that session could have additional fields\n */\nexport type Session<\n\tDBOptions extends BetterAuthOptions[\"session\"] = BetterAuthOptions[\"session\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tz.infer<typeof sessionSchema> &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"session\", Plugins>\n>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.mjs","names":[],"sources":["../../../src/db/schema/session.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const sessionSchema = coreSchema.extend({\n\tuserId: z.coerce.string(),\n\texpiresAt: z.date(),\n\ttoken: z.string(),\n\tipAddress: z.string().nullish(),\n\tuserAgent: z.string().nullish(),\n});\n\nexport type BaseSession = z.infer<typeof sessionSchema>;\n\n/**\n * Session schema type used by better-auth, note that it's possible that session could have additional fields\n */\nexport type Session<\n\tDBOptions extends BetterAuthOptions[\"session\"] = BetterAuthOptions[\"session\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tz.infer<typeof sessionSchema> &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"session\", Plugins>\n>;\n"],"mappings":";;;AAQA,MAAa,gBAAgB,WAAW,OAAO;CAC9C,QAAQ,EAAE,OAAO,QAAQ;CACzB,WAAW,EAAE,MAAM;CACnB,OAAO,EAAE,QAAQ;CACjB,WAAW,EAAE,QAAQ,CAAC,SAAS;CAC/B,WAAW,EAAE,QAAQ,CAAC,SAAS;CAC/B,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
|
|
3
2
|
//#region src/db/schema/shared.ts
|
|
4
3
|
const coreSchema = z.object({
|
|
5
4
|
id: z.string(),
|
|
6
5
|
createdAt: z.date().default(() => /* @__PURE__ */ new Date()),
|
|
7
6
|
updatedAt: z.date().default(() => /* @__PURE__ */ new Date())
|
|
8
7
|
});
|
|
9
|
-
|
|
10
8
|
//#endregion
|
|
11
9
|
export { coreSchema };
|
|
10
|
+
|
|
12
11
|
//# sourceMappingURL=shared.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.mjs","names":[],"sources":["../../../src/db/schema/shared.ts"],"sourcesContent":["import * as z from \"zod\";\n\nexport const coreSchema = z.object({\n\tid: z.string(),\n\tcreatedAt: z.date().default(() => new Date()),\n\tupdatedAt: z.date().default(() => new Date()),\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.mjs","names":[],"sources":["../../../src/db/schema/shared.ts"],"sourcesContent":["import * as z from \"zod\";\n\nexport const coreSchema = z.object({\n\tid: z.string(),\n\tcreatedAt: z.date().default(() => new Date()),\n\tupdatedAt: z.date().default(() => new Date()),\n});\n"],"mappings":";;AAEA,MAAa,aAAa,EAAE,OAAO;CAClC,IAAI,EAAE,QAAQ;CACd,WAAW,EAAE,MAAM,CAAC,8BAAc,IAAI,MAAM,CAAC;CAC7C,WAAW,EAAE,MAAM,CAAC,8BAAc,IAAI,MAAM,CAAC;CAC7C,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
2
2
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
4
|
-
import "../../types/index.mjs";
|
|
5
4
|
import * as z from "zod";
|
|
6
5
|
|
|
7
6
|
//#region src/db/schema/user.d.ts
|
package/dist/db/schema/user.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { coreSchema } from "./shared.mjs";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
|
|
4
3
|
//#region src/db/schema/user.ts
|
|
5
4
|
const userSchema = coreSchema.extend({
|
|
6
5
|
email: z.string().transform((val) => val.toLowerCase()),
|
|
@@ -8,7 +7,7 @@ const userSchema = coreSchema.extend({
|
|
|
8
7
|
name: z.string(),
|
|
9
8
|
image: z.string().nullish()
|
|
10
9
|
});
|
|
11
|
-
|
|
12
10
|
//#endregion
|
|
13
11
|
export { userSchema };
|
|
12
|
+
|
|
14
13
|
//# sourceMappingURL=user.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.mjs","names":[],"sources":["../../../src/db/schema/user.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const userSchema = coreSchema.extend({\n\temail: z.string().transform((val) => val.toLowerCase()),\n\temailVerified: z.boolean().default(false),\n\tname: z.string(),\n\timage: z.string().nullish(),\n});\n\nexport type BaseUser = z.infer<typeof userSchema>;\n\n/**\n * User schema type used by better-auth, note that it's possible that user could have additional fields\n */\nexport type User<\n\tDBOptions extends BetterAuthOptions[\"user\"] = BetterAuthOptions[\"user\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseUser &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"user\", Plugins>\n>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.mjs","names":[],"sources":["../../../src/db/schema/user.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const userSchema = coreSchema.extend({\n\temail: z.string().transform((val) => val.toLowerCase()),\n\temailVerified: z.boolean().default(false),\n\tname: z.string(),\n\timage: z.string().nullish(),\n});\n\nexport type BaseUser = z.infer<typeof userSchema>;\n\n/**\n * User schema type used by better-auth, note that it's possible that user could have additional fields\n */\nexport type User<\n\tDBOptions extends BetterAuthOptions[\"user\"] = BetterAuthOptions[\"user\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseUser &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"user\", Plugins>\n>;\n"],"mappings":";;;AAQA,MAAa,aAAa,WAAW,OAAO;CAC3C,OAAO,EAAE,QAAQ,CAAC,WAAW,QAAQ,IAAI,aAAa,CAAC;CACvD,eAAe,EAAE,SAAS,CAAC,QAAQ,MAAM;CACzC,MAAM,EAAE,QAAQ;CAChB,OAAO,EAAE,QAAQ,CAAC,SAAS;CAC3B,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
2
2
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
4
|
-
import "../../types/index.mjs";
|
|
5
4
|
import * as z from "zod";
|
|
6
5
|
|
|
7
6
|
//#region src/db/schema/verification.d.ts
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { coreSchema } from "./shared.mjs";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
|
|
4
3
|
//#region src/db/schema/verification.ts
|
|
5
4
|
const verificationSchema = coreSchema.extend({
|
|
6
5
|
value: z.string(),
|
|
7
6
|
expiresAt: z.date(),
|
|
8
7
|
identifier: z.string()
|
|
9
8
|
});
|
|
10
|
-
|
|
11
9
|
//#endregion
|
|
12
10
|
export { verificationSchema };
|
|
11
|
+
|
|
13
12
|
//# sourceMappingURL=verification.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.mjs","names":[],"sources":["../../../src/db/schema/verification.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const verificationSchema = coreSchema.extend({\n\tvalue: z.string(),\n\texpiresAt: z.date(),\n\tidentifier: z.string(),\n});\n\nexport type BaseVerification = z.infer<typeof verificationSchema>;\n\n/**\n * Verification schema type used by better-auth, note that it's possible that verification could have additional fields\n */\nexport type Verification<\n\tDBOptions extends\n\t\tBetterAuthOptions[\"verification\"] = BetterAuthOptions[\"verification\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseVerification &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"verification\", Plugins>\n>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"verification.mjs","names":[],"sources":["../../../src/db/schema/verification.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const verificationSchema = coreSchema.extend({\n\tvalue: z.string(),\n\texpiresAt: z.date(),\n\tidentifier: z.string(),\n});\n\nexport type BaseVerification = z.infer<typeof verificationSchema>;\n\n/**\n * Verification schema type used by better-auth, note that it's possible that verification could have additional fields\n */\nexport type Verification<\n\tDBOptions extends\n\t\tBetterAuthOptions[\"verification\"] = BetterAuthOptions[\"verification\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseVerification &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"verification\", Plugins>\n>;\n"],"mappings":";;;AAQA,MAAa,qBAAqB,WAAW,OAAO;CACnD,OAAO,EAAE,QAAQ;CACjB,WAAW,EAAE,MAAM;CACnB,YAAY,EAAE,QAAQ;CACtB,CAAC"}
|
package/dist/db/type.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Awaitable, LiteralString, UnionToIntersection } from "../types/helper.mjs";
|
|
2
2
|
import { BetterAuthOptions } from "../types/init-options.mjs";
|
|
3
|
-
import "../types/index.mjs";
|
|
4
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
4
|
|
|
6
5
|
//#region src/db/type.d.ts
|
package/dist/env/color-depth.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { env, getEnvVar } from "./env-impl.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/env/color-depth.ts
|
|
4
3
|
const COLORS_2 = 1;
|
|
5
4
|
const COLORS_16 = 4;
|
|
@@ -83,7 +82,7 @@ function getColorDepth() {
|
|
|
83
82
|
if (getEnvVar("COLORTERM")) return COLORS_16;
|
|
84
83
|
return COLORS_2;
|
|
85
84
|
}
|
|
86
|
-
|
|
87
85
|
//#endregion
|
|
88
86
|
export { getColorDepth };
|
|
87
|
+
|
|
89
88
|
//# sourceMappingURL=color-depth.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-depth.mjs","names":[],"sources":["../../src/env/color-depth.ts"],"sourcesContent":["// Source code copied & modified from node internals: https://github.com/nodejs/node/blob/5b32bb1573dace2dd058c05ac4fab1e4e446c775/lib/internal/tty.js#L123\nimport { env, getEnvVar } from \"./env-impl\";\n\nconst COLORS_2 = 1;\nconst COLORS_16 = 4;\nconst COLORS_256 = 8;\nconst COLORS_16m = 24;\n\nconst TERM_ENVS: Record<string, number> = {\n\teterm: COLORS_16,\n\tcons25: COLORS_16,\n\tconsole: COLORS_16,\n\tcygwin: COLORS_16,\n\tdtterm: COLORS_16,\n\tgnome: COLORS_16,\n\thurd: COLORS_16,\n\tjfbterm: COLORS_16,\n\tkonsole: COLORS_16,\n\tkterm: COLORS_16,\n\tmlterm: COLORS_16,\n\tmosh: COLORS_16m,\n\tputty: COLORS_16,\n\tst: COLORS_16,\n\t// http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html\n\t\"rxvt-unicode-24bit\": COLORS_16m,\n\t// https://bugs.launchpad.net/terminator/+bug/1030562\n\tterminator: COLORS_16m,\n\t\"xterm-kitty\": COLORS_16m,\n};\n\nconst CI_ENVS_MAP = new Map(\n\tObject.entries({\n\t\tAPPVEYOR: COLORS_256,\n\t\tBUILDKITE: COLORS_256,\n\t\tCIRCLECI: COLORS_16m,\n\t\tDRONE: COLORS_256,\n\t\tGITEA_ACTIONS: COLORS_16m,\n\t\tGITHUB_ACTIONS: COLORS_16m,\n\t\tGITLAB_CI: COLORS_256,\n\t\tTRAVIS: COLORS_256,\n\t}),\n);\n\nconst TERM_ENVS_REG_EXP = [\n\t/ansi/,\n\t/color/,\n\t/linux/,\n\t/direct/,\n\t/^con[0-9]*x[0-9]/,\n\t/^rxvt/,\n\t/^screen/,\n\t/^xterm/,\n\t/^vt100/,\n\t/^vt220/,\n];\n\n// The `getColorDepth` API got inspired by multiple sources such as\n// https://github.com/chalk/supports-color,\n// https://github.com/isaacs/color-support.\nexport function getColorDepth(): number {\n\t// Use level 0-3 to support the same levels as `chalk` does. This is done for\n\t// consistency throughout the ecosystem.\n\tif (getEnvVar(\"FORCE_COLOR\") !== undefined) {\n\t\tswitch (getEnvVar(\"FORCE_COLOR\")) {\n\t\t\tcase \"\":\n\t\t\tcase \"1\":\n\t\t\tcase \"true\":\n\t\t\t\treturn COLORS_16;\n\t\t\tcase \"2\":\n\t\t\t\treturn COLORS_256;\n\t\t\tcase \"3\":\n\t\t\t\treturn COLORS_16m;\n\t\t\tdefault:\n\t\t\t\treturn COLORS_2;\n\t\t}\n\t}\n\n\tif (\n\t\t(getEnvVar(\"NODE_DISABLE_COLORS\") !== undefined &&\n\t\t\tgetEnvVar(\"NODE_DISABLE_COLORS\") !== \"\") ||\n\t\t// See https://no-color.org/\n\t\t(getEnvVar(\"NO_COLOR\") !== undefined && getEnvVar(\"NO_COLOR\") !== \"\") ||\n\t\t// The \"dumb\" special terminal, as defined by terminfo, doesn't support\n\t\t// ANSI color control codes.\n\t\t// See https://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials\n\t\tgetEnvVar(\"TERM\") === \"dumb\"\n\t) {\n\t\treturn COLORS_2;\n\t}\n\n\t// Edge runtime doesn't support `process?.platform` syntax\n\t// if (typeof process !== \"undefined\" && process?.platform === \"win32\") {\n\t// \t// Windows 10 build 14931 (from 2016) has true color support\n\t// \treturn COLORS_16m;\n\t// }\n\n\tif (getEnvVar(\"TMUX\")) {\n\t\treturn COLORS_16m;\n\t}\n\n\t// Azure DevOps\n\tif (\"TF_BUILD\" in env && \"AGENT_NAME\" in env) {\n\t\treturn COLORS_16;\n\t}\n\n\tif (\"CI\" in env) {\n\t\tfor (const { 0: envName, 1: colors } of CI_ENVS_MAP) {\n\t\t\tif (envName in env) {\n\t\t\t\treturn colors;\n\t\t\t}\n\t\t}\n\t\tif (getEnvVar(\"CI_NAME\") === \"codeship\") {\n\t\t\treturn COLORS_256;\n\t\t}\n\t\treturn COLORS_2;\n\t}\n\n\tif (\"TEAMCITY_VERSION\" in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.exec(\n\t\t\tgetEnvVar(\"TEAMCITY_VERSION\"),\n\t\t) !== null\n\t\t\t? COLORS_16\n\t\t\t: COLORS_2;\n\t}\n\n\tswitch (getEnvVar(\"TERM_PROGRAM\")) {\n\t\tcase \"iTerm.app\":\n\t\t\tif (\n\t\t\t\t!getEnvVar(\"TERM_PROGRAM_VERSION\") ||\n\t\t\t\t/^[0-2]\\./.exec(getEnvVar(\"TERM_PROGRAM_VERSION\")) !== null\n\t\t\t) {\n\t\t\t\treturn COLORS_256;\n\t\t\t}\n\t\t\treturn COLORS_16m;\n\t\tcase \"HyperTerm\":\n\t\tcase \"MacTerm\":\n\t\t\treturn COLORS_16m;\n\t\tcase \"Apple_Terminal\":\n\t\t\treturn COLORS_256;\n\t}\n\n\tif (\n\t\tgetEnvVar(\"COLORTERM\") === \"truecolor\" ||\n\t\tgetEnvVar(\"COLORTERM\") === \"24bit\"\n\t) {\n\t\treturn COLORS_16m;\n\t}\n\n\tif (getEnvVar(\"TERM\")) {\n\t\tif (/truecolor/.exec(getEnvVar(\"TERM\")) !== null) {\n\t\t\treturn COLORS_16m;\n\t\t}\n\n\t\tif (/^xterm-256/.exec(getEnvVar(\"TERM\")) !== null) {\n\t\t\treturn COLORS_256;\n\t\t}\n\n\t\tconst termEnv = getEnvVar(\"TERM\").toLowerCase();\n\n\t\tif (TERM_ENVS[termEnv]) {\n\t\t\treturn TERM_ENVS[termEnv];\n\t\t}\n\t\tif (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) {\n\t\t\treturn COLORS_16;\n\t\t}\n\t}\n\t// Move 16 color COLORTERM below 16m and 256\n\tif (getEnvVar(\"COLORTERM\")) {\n\t\treturn COLORS_16;\n\t}\n\treturn COLORS_2;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"color-depth.mjs","names":[],"sources":["../../src/env/color-depth.ts"],"sourcesContent":["// Source code copied & modified from node internals: https://github.com/nodejs/node/blob/5b32bb1573dace2dd058c05ac4fab1e4e446c775/lib/internal/tty.js#L123\nimport { env, getEnvVar } from \"./env-impl\";\n\nconst COLORS_2 = 1;\nconst COLORS_16 = 4;\nconst COLORS_256 = 8;\nconst COLORS_16m = 24;\n\nconst TERM_ENVS: Record<string, number> = {\n\teterm: COLORS_16,\n\tcons25: COLORS_16,\n\tconsole: COLORS_16,\n\tcygwin: COLORS_16,\n\tdtterm: COLORS_16,\n\tgnome: COLORS_16,\n\thurd: COLORS_16,\n\tjfbterm: COLORS_16,\n\tkonsole: COLORS_16,\n\tkterm: COLORS_16,\n\tmlterm: COLORS_16,\n\tmosh: COLORS_16m,\n\tputty: COLORS_16,\n\tst: COLORS_16,\n\t// http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html\n\t\"rxvt-unicode-24bit\": COLORS_16m,\n\t// https://bugs.launchpad.net/terminator/+bug/1030562\n\tterminator: COLORS_16m,\n\t\"xterm-kitty\": COLORS_16m,\n};\n\nconst CI_ENVS_MAP = new Map(\n\tObject.entries({\n\t\tAPPVEYOR: COLORS_256,\n\t\tBUILDKITE: COLORS_256,\n\t\tCIRCLECI: COLORS_16m,\n\t\tDRONE: COLORS_256,\n\t\tGITEA_ACTIONS: COLORS_16m,\n\t\tGITHUB_ACTIONS: COLORS_16m,\n\t\tGITLAB_CI: COLORS_256,\n\t\tTRAVIS: COLORS_256,\n\t}),\n);\n\nconst TERM_ENVS_REG_EXP = [\n\t/ansi/,\n\t/color/,\n\t/linux/,\n\t/direct/,\n\t/^con[0-9]*x[0-9]/,\n\t/^rxvt/,\n\t/^screen/,\n\t/^xterm/,\n\t/^vt100/,\n\t/^vt220/,\n];\n\n// The `getColorDepth` API got inspired by multiple sources such as\n// https://github.com/chalk/supports-color,\n// https://github.com/isaacs/color-support.\nexport function getColorDepth(): number {\n\t// Use level 0-3 to support the same levels as `chalk` does. This is done for\n\t// consistency throughout the ecosystem.\n\tif (getEnvVar(\"FORCE_COLOR\") !== undefined) {\n\t\tswitch (getEnvVar(\"FORCE_COLOR\")) {\n\t\t\tcase \"\":\n\t\t\tcase \"1\":\n\t\t\tcase \"true\":\n\t\t\t\treturn COLORS_16;\n\t\t\tcase \"2\":\n\t\t\t\treturn COLORS_256;\n\t\t\tcase \"3\":\n\t\t\t\treturn COLORS_16m;\n\t\t\tdefault:\n\t\t\t\treturn COLORS_2;\n\t\t}\n\t}\n\n\tif (\n\t\t(getEnvVar(\"NODE_DISABLE_COLORS\") !== undefined &&\n\t\t\tgetEnvVar(\"NODE_DISABLE_COLORS\") !== \"\") ||\n\t\t// See https://no-color.org/\n\t\t(getEnvVar(\"NO_COLOR\") !== undefined && getEnvVar(\"NO_COLOR\") !== \"\") ||\n\t\t// The \"dumb\" special terminal, as defined by terminfo, doesn't support\n\t\t// ANSI color control codes.\n\t\t// See https://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials\n\t\tgetEnvVar(\"TERM\") === \"dumb\"\n\t) {\n\t\treturn COLORS_2;\n\t}\n\n\t// Edge runtime doesn't support `process?.platform` syntax\n\t// if (typeof process !== \"undefined\" && process?.platform === \"win32\") {\n\t// \t// Windows 10 build 14931 (from 2016) has true color support\n\t// \treturn COLORS_16m;\n\t// }\n\n\tif (getEnvVar(\"TMUX\")) {\n\t\treturn COLORS_16m;\n\t}\n\n\t// Azure DevOps\n\tif (\"TF_BUILD\" in env && \"AGENT_NAME\" in env) {\n\t\treturn COLORS_16;\n\t}\n\n\tif (\"CI\" in env) {\n\t\tfor (const { 0: envName, 1: colors } of CI_ENVS_MAP) {\n\t\t\tif (envName in env) {\n\t\t\t\treturn colors;\n\t\t\t}\n\t\t}\n\t\tif (getEnvVar(\"CI_NAME\") === \"codeship\") {\n\t\t\treturn COLORS_256;\n\t\t}\n\t\treturn COLORS_2;\n\t}\n\n\tif (\"TEAMCITY_VERSION\" in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.exec(\n\t\t\tgetEnvVar(\"TEAMCITY_VERSION\"),\n\t\t) !== null\n\t\t\t? COLORS_16\n\t\t\t: COLORS_2;\n\t}\n\n\tswitch (getEnvVar(\"TERM_PROGRAM\")) {\n\t\tcase \"iTerm.app\":\n\t\t\tif (\n\t\t\t\t!getEnvVar(\"TERM_PROGRAM_VERSION\") ||\n\t\t\t\t/^[0-2]\\./.exec(getEnvVar(\"TERM_PROGRAM_VERSION\")) !== null\n\t\t\t) {\n\t\t\t\treturn COLORS_256;\n\t\t\t}\n\t\t\treturn COLORS_16m;\n\t\tcase \"HyperTerm\":\n\t\tcase \"MacTerm\":\n\t\t\treturn COLORS_16m;\n\t\tcase \"Apple_Terminal\":\n\t\t\treturn COLORS_256;\n\t}\n\n\tif (\n\t\tgetEnvVar(\"COLORTERM\") === \"truecolor\" ||\n\t\tgetEnvVar(\"COLORTERM\") === \"24bit\"\n\t) {\n\t\treturn COLORS_16m;\n\t}\n\n\tif (getEnvVar(\"TERM\")) {\n\t\tif (/truecolor/.exec(getEnvVar(\"TERM\")) !== null) {\n\t\t\treturn COLORS_16m;\n\t\t}\n\n\t\tif (/^xterm-256/.exec(getEnvVar(\"TERM\")) !== null) {\n\t\t\treturn COLORS_256;\n\t\t}\n\n\t\tconst termEnv = getEnvVar(\"TERM\").toLowerCase();\n\n\t\tif (TERM_ENVS[termEnv]) {\n\t\t\treturn TERM_ENVS[termEnv];\n\t\t}\n\t\tif (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) {\n\t\t\treturn COLORS_16;\n\t\t}\n\t}\n\t// Move 16 color COLORTERM below 16m and 256\n\tif (getEnvVar(\"COLORTERM\")) {\n\t\treturn COLORS_16;\n\t}\n\treturn COLORS_2;\n}\n"],"mappings":";;AAGA,MAAM,WAAW;AACjB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,YAAoC;CACzC,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;CACP,QAAQ;CACR,MAAM;CACN,OAAO;CACP,IAAI;CAEJ,sBAAsB;CAEtB,YAAY;CACZ,eAAe;CACf;AAED,MAAM,cAAc,IAAI,IACvB,OAAO,QAAQ;CACd,UAAU;CACV,WAAW;CACX,UAAU;CACV,OAAO;CACP,eAAe;CACf,gBAAgB;CAChB,WAAW;CACX,QAAQ;CACR,CAAC,CACF;AAED,MAAM,oBAAoB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAKD,SAAgB,gBAAwB;AAGvC,KAAI,UAAU,cAAc,KAAK,KAAA,EAChC,SAAQ,UAAU,cAAc,EAAhC;EACC,KAAK;EACL,KAAK;EACL,KAAK,OACJ,QAAO;EACR,KAAK,IACJ,QAAO;EACR,KAAK,IACJ,QAAO;EACR,QACC,QAAO;;AAIV,KACE,UAAU,sBAAsB,KAAK,KAAA,KACrC,UAAU,sBAAsB,KAAK,MAErC,UAAU,WAAW,KAAK,KAAA,KAAa,UAAU,WAAW,KAAK,MAIlE,UAAU,OAAO,KAAK,OAEtB,QAAO;AASR,KAAI,UAAU,OAAO,CACpB,QAAO;AAIR,KAAI,cAAc,OAAO,gBAAgB,IACxC,QAAO;AAGR,KAAI,QAAQ,KAAK;AAChB,OAAK,MAAM,EAAE,GAAG,SAAS,GAAG,YAAY,YACvC,KAAI,WAAW,IACd,QAAO;AAGT,MAAI,UAAU,UAAU,KAAK,WAC5B,QAAO;AAER,SAAO;;AAGR,KAAI,sBAAsB,IACzB,QAAO,gCAAgC,KACtC,UAAU,mBAAmB,CAC7B,KAAK,OACH,YACA;AAGJ,SAAQ,UAAU,eAAe,EAAjC;EACC,KAAK;AACJ,OACC,CAAC,UAAU,uBAAuB,IAClC,WAAW,KAAK,UAAU,uBAAuB,CAAC,KAAK,KAEvD,QAAO;AAER,UAAO;EACR,KAAK;EACL,KAAK,UACJ,QAAO;EACR,KAAK,iBACJ,QAAO;;AAGT,KACC,UAAU,YAAY,KAAK,eAC3B,UAAU,YAAY,KAAK,QAE3B,QAAO;AAGR,KAAI,UAAU,OAAO,EAAE;AACtB,MAAI,YAAY,KAAK,UAAU,OAAO,CAAC,KAAK,KAC3C,QAAO;AAGR,MAAI,aAAa,KAAK,UAAU,OAAO,CAAC,KAAK,KAC5C,QAAO;EAGR,MAAM,UAAU,UAAU,OAAO,CAAC,aAAa;AAE/C,MAAI,UAAU,SACb,QAAO,UAAU;AAElB,MAAI,kBAAkB,MAAM,SAAS,KAAK,KAAK,QAAQ,KAAK,KAAK,CAChE,QAAO;;AAIT,KAAI,UAAU,YAAY,CACzB,QAAO;AAER,QAAO"}
|
package/dist/env/env-impl.mjs
CHANGED
|
@@ -77,7 +77,7 @@ const ENV = Object.freeze({
|
|
|
77
77
|
return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "");
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
-
|
|
81
80
|
//#endregion
|
|
82
81
|
export { ENV, env, getBooleanEnvVar, getEnvVar, isDevelopment, isProduction, isTest, nodeENV };
|
|
82
|
+
|
|
83
83
|
//# sourceMappingURL=env-impl.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-impl.mjs","names":[],"sources":["../../src/env/env-impl.ts"],"sourcesContent":["/// <reference types=\"node\" />\n/// <reference types=\"bun\" />\n//https://github.com/unjs/std-env/blob/main/src/env.ts\n\nconst _envShim = Object.create(null);\n\nexport type EnvObject = Record<string, string | undefined>;\n\nconst _getEnv = (useShim?: boolean) =>\n\tglobalThis.process?.env ||\n\t//@ts-expect-error\n\tglobalThis.Deno?.env.toObject() ||\n\t//@ts-expect-error\n\tglobalThis.__env__ ||\n\t(useShim ? _envShim : globalThis);\n\nexport const env = new Proxy<EnvObject>(_envShim, {\n\tget(_, prop) {\n\t\tconst env = _getEnv();\n\t\treturn env[prop as any] ?? _envShim[prop];\n\t},\n\thas(_, prop) {\n\t\tconst env = _getEnv();\n\t\treturn prop in env || prop in _envShim;\n\t},\n\tset(_, prop, value) {\n\t\tconst env = _getEnv(true);\n\t\tenv[prop as any] = value;\n\t\treturn true;\n\t},\n\tdeleteProperty(_, prop) {\n\t\tif (!prop) {\n\t\t\treturn false;\n\t\t}\n\t\tconst env = _getEnv(true);\n\t\tdelete env[prop as any];\n\t\treturn true;\n\t},\n\townKeys() {\n\t\tconst env = _getEnv(true);\n\t\treturn Object.keys(env);\n\t},\n});\n\nfunction toBoolean(val: boolean | string | undefined) {\n\treturn val ? val !== \"false\" : false;\n}\n\nexport const nodeENV =\n\t(typeof process !== \"undefined\" && process.env && process.env.NODE_ENV) || \"\";\n\n/** Detect if `NODE_ENV` environment variable is `production` */\nexport const isProduction = nodeENV === \"production\";\n\n/** Detect if `NODE_ENV` environment variable is `dev` or `development` */\nexport const isDevelopment = () =>\n\tnodeENV === \"dev\" || nodeENV === \"development\";\n\n/** Detect if `NODE_ENV` environment variable is `test` */\nexport const isTest = () => nodeENV === \"test\" || toBoolean(env.TEST);\n\n/**\n * Get environment variable with fallback\n */\nexport function getEnvVar<Fallback extends string>(\n\tkey: string,\n\tfallback?: Fallback,\n): Fallback extends string ? string : string | undefined {\n\tif (typeof process !== \"undefined\" && process.env) {\n\t\treturn process.env[key] ?? (fallback as any);\n\t}\n\n\t// @ts-expect-error deno\n\tif (typeof Deno !== \"undefined\") {\n\t\t// @ts-expect-error deno\n\t\treturn Deno.env.get(key) ?? (fallback as string);\n\t}\n\n\t// Handle Bun\n\tif (typeof Bun !== \"undefined\") {\n\t\treturn Bun.env[key] ?? (fallback as string);\n\t}\n\n\treturn fallback as any;\n}\n\n/**\n * Get boolean environment variable\n */\nexport function getBooleanEnvVar(key: string, fallback = true): boolean {\n\tconst value = getEnvVar(key);\n\tif (!value) return fallback;\n\treturn value !== \"0\" && value.toLowerCase() !== \"false\" && value !== \"\";\n}\n\n/**\n * Common environment variables used in Better Auth\n */\nexport const ENV = Object.freeze({\n\tget BETTER_AUTH_SECRET() {\n\t\treturn getEnvVar(\"BETTER_AUTH_SECRET\");\n\t},\n\tget AUTH_SECRET() {\n\t\treturn getEnvVar(\"AUTH_SECRET\");\n\t},\n\tget BETTER_AUTH_TELEMETRY() {\n\t\treturn getEnvVar(\"BETTER_AUTH_TELEMETRY\");\n\t},\n\tget BETTER_AUTH_TELEMETRY_ID() {\n\t\treturn getEnvVar(\"BETTER_AUTH_TELEMETRY_ID\");\n\t},\n\tget NODE_ENV() {\n\t\treturn getEnvVar(\"NODE_ENV\", \"development\");\n\t},\n\tget PACKAGE_VERSION() {\n\t\treturn getEnvVar(\"PACKAGE_VERSION\", \"0.0.0\");\n\t},\n\tget BETTER_AUTH_TELEMETRY_ENDPOINT(): string | undefined {\n\t\treturn getEnvVar(\n\t\t\t\"BETTER_AUTH_TELEMETRY_ENDPOINT\",\n\t\t\timport.meta.env.BETTER_AUTH_TELEMETRY_ENDPOINT,\n\t\t);\n\t},\n});\n"],"mappings":";AAIA,MAAM,WAAW,OAAO,OAAO,KAAK;AAIpC,MAAM,WAAW,YAChB,WAAW,SAAS,OAEpB,WAAW,MAAM,IAAI,UAAU,IAE/B,WAAW,YACV,UAAU,WAAW;AAEvB,MAAa,MAAM,IAAI,MAAiB,UAAU;CACjD,IAAI,GAAG,MAAM;AAEZ,SADY,SAAS,CACV,SAAgB,SAAS;;CAErC,IAAI,GAAG,MAAM;AAEZ,SAAO,QADK,SAAS,IACC,QAAQ;;CAE/B,IAAI,GAAG,MAAM,OAAO;EACnB,MAAM,MAAM,QAAQ,KAAK;AACzB,MAAI,QAAe;AACnB,SAAO;;CAER,eAAe,GAAG,MAAM;AACvB,MAAI,CAAC,KACJ,QAAO;EAER,MAAM,MAAM,QAAQ,KAAK;AACzB,SAAO,IAAI;AACX,SAAO;;CAER,UAAU;EACT,MAAM,MAAM,QAAQ,KAAK;AACzB,SAAO,OAAO,KAAK,IAAI;;CAExB,CAAC;AAEF,SAAS,UAAU,KAAmC;AACrD,QAAO,MAAM,QAAQ,UAAU;;AAGhC,MAAa,UACX,OAAO,YAAY,eAAe,QAAQ,OAAO,QAAQ,IAAI,YAAa;;AAG5E,MAAa,eAAe,YAAY;;AAGxC,MAAa,sBACZ,YAAY,SAAS,YAAY;;AAGlC,MAAa,eAAe,YAAY,UAAU,UAAU,IAAI,KAAK;;;;AAKrE,SAAgB,UACf,KACA,UACwD;AACxD,KAAI,OAAO,YAAY,eAAe,QAAQ,IAC7C,QAAO,QAAQ,IAAI,QAAS;AAI7B,KAAI,OAAO,SAAS,YAEnB,QAAO,KAAK,IAAI,IAAI,IAAI,IAAK;AAI9B,KAAI,OAAO,QAAQ,YAClB,QAAO,IAAI,IAAI,QAAS;AAGzB,QAAO;;;;;AAMR,SAAgB,iBAAiB,KAAa,WAAW,MAAe;CACvE,MAAM,QAAQ,UAAU,IAAI;AAC5B,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,UAAU,OAAO,MAAM,aAAa,KAAK,WAAW,UAAU;;;;;AAMtE,MAAa,MAAM,OAAO,OAAO;CAChC,IAAI,qBAAqB;AACxB,SAAO,UAAU,qBAAqB;;CAEvC,IAAI,cAAc;AACjB,SAAO,UAAU,cAAc;;CAEhC,IAAI,wBAAwB;AAC3B,SAAO,UAAU,wBAAwB;;CAE1C,IAAI,2BAA2B;AAC9B,SAAO,UAAU,2BAA2B;;CAE7C,IAAI,WAAW;AACd,SAAO,UAAU,YAAY,cAAc;;CAE5C,IAAI,kBAAkB;AACrB,SAAO,UAAU,mBAAmB,QAAQ;;CAE7C,IAAI,iCAAqD;AACxD,SAAO,UACN,
|
|
1
|
+
{"version":3,"file":"env-impl.mjs","names":[],"sources":["../../src/env/env-impl.ts"],"sourcesContent":["/// <reference types=\"node\" />\n/// <reference types=\"bun\" />\n//https://github.com/unjs/std-env/blob/main/src/env.ts\n\nconst _envShim = Object.create(null);\n\nexport type EnvObject = Record<string, string | undefined>;\n\nconst _getEnv = (useShim?: boolean) =>\n\tglobalThis.process?.env ||\n\t//@ts-expect-error\n\tglobalThis.Deno?.env.toObject() ||\n\t//@ts-expect-error\n\tglobalThis.__env__ ||\n\t(useShim ? _envShim : globalThis);\n\nexport const env = new Proxy<EnvObject>(_envShim, {\n\tget(_, prop) {\n\t\tconst env = _getEnv();\n\t\treturn env[prop as any] ?? _envShim[prop];\n\t},\n\thas(_, prop) {\n\t\tconst env = _getEnv();\n\t\treturn prop in env || prop in _envShim;\n\t},\n\tset(_, prop, value) {\n\t\tconst env = _getEnv(true);\n\t\tenv[prop as any] = value;\n\t\treturn true;\n\t},\n\tdeleteProperty(_, prop) {\n\t\tif (!prop) {\n\t\t\treturn false;\n\t\t}\n\t\tconst env = _getEnv(true);\n\t\tdelete env[prop as any];\n\t\treturn true;\n\t},\n\townKeys() {\n\t\tconst env = _getEnv(true);\n\t\treturn Object.keys(env);\n\t},\n});\n\nfunction toBoolean(val: boolean | string | undefined) {\n\treturn val ? val !== \"false\" : false;\n}\n\nexport const nodeENV =\n\t(typeof process !== \"undefined\" && process.env && process.env.NODE_ENV) || \"\";\n\n/** Detect if `NODE_ENV` environment variable is `production` */\nexport const isProduction = nodeENV === \"production\";\n\n/** Detect if `NODE_ENV` environment variable is `dev` or `development` */\nexport const isDevelopment = () =>\n\tnodeENV === \"dev\" || nodeENV === \"development\";\n\n/** Detect if `NODE_ENV` environment variable is `test` */\nexport const isTest = () => nodeENV === \"test\" || toBoolean(env.TEST);\n\n/**\n * Get environment variable with fallback\n */\nexport function getEnvVar<Fallback extends string>(\n\tkey: string,\n\tfallback?: Fallback,\n): Fallback extends string ? string : string | undefined {\n\tif (typeof process !== \"undefined\" && process.env) {\n\t\treturn process.env[key] ?? (fallback as any);\n\t}\n\n\t// @ts-expect-error deno\n\tif (typeof Deno !== \"undefined\") {\n\t\t// @ts-expect-error deno\n\t\treturn Deno.env.get(key) ?? (fallback as string);\n\t}\n\n\t// Handle Bun\n\tif (typeof Bun !== \"undefined\") {\n\t\treturn Bun.env[key] ?? (fallback as string);\n\t}\n\n\treturn fallback as any;\n}\n\n/**\n * Get boolean environment variable\n */\nexport function getBooleanEnvVar(key: string, fallback = true): boolean {\n\tconst value = getEnvVar(key);\n\tif (!value) return fallback;\n\treturn value !== \"0\" && value.toLowerCase() !== \"false\" && value !== \"\";\n}\n\n/**\n * Common environment variables used in Better Auth\n */\nexport const ENV = Object.freeze({\n\tget BETTER_AUTH_SECRET() {\n\t\treturn getEnvVar(\"BETTER_AUTH_SECRET\");\n\t},\n\tget AUTH_SECRET() {\n\t\treturn getEnvVar(\"AUTH_SECRET\");\n\t},\n\tget BETTER_AUTH_TELEMETRY() {\n\t\treturn getEnvVar(\"BETTER_AUTH_TELEMETRY\");\n\t},\n\tget BETTER_AUTH_TELEMETRY_ID() {\n\t\treturn getEnvVar(\"BETTER_AUTH_TELEMETRY_ID\");\n\t},\n\tget NODE_ENV() {\n\t\treturn getEnvVar(\"NODE_ENV\", \"development\");\n\t},\n\tget PACKAGE_VERSION() {\n\t\treturn getEnvVar(\"PACKAGE_VERSION\", \"0.0.0\");\n\t},\n\tget BETTER_AUTH_TELEMETRY_ENDPOINT(): string | undefined {\n\t\treturn getEnvVar(\n\t\t\t\"BETTER_AUTH_TELEMETRY_ENDPOINT\",\n\t\t\timport.meta.env.BETTER_AUTH_TELEMETRY_ENDPOINT,\n\t\t);\n\t},\n});\n"],"mappings":";AAIA,MAAM,WAAW,OAAO,OAAO,KAAK;AAIpC,MAAM,WAAW,YAChB,WAAW,SAAS,OAEpB,WAAW,MAAM,IAAI,UAAU,IAE/B,WAAW,YACV,UAAU,WAAW;AAEvB,MAAa,MAAM,IAAI,MAAiB,UAAU;CACjD,IAAI,GAAG,MAAM;AAEZ,SADY,SAAS,CACV,SAAgB,SAAS;;CAErC,IAAI,GAAG,MAAM;AAEZ,SAAO,QADK,SAAS,IACC,QAAQ;;CAE/B,IAAI,GAAG,MAAM,OAAO;EACnB,MAAM,MAAM,QAAQ,KAAK;AACzB,MAAI,QAAe;AACnB,SAAO;;CAER,eAAe,GAAG,MAAM;AACvB,MAAI,CAAC,KACJ,QAAO;EAER,MAAM,MAAM,QAAQ,KAAK;AACzB,SAAO,IAAI;AACX,SAAO;;CAER,UAAU;EACT,MAAM,MAAM,QAAQ,KAAK;AACzB,SAAO,OAAO,KAAK,IAAI;;CAExB,CAAC;AAEF,SAAS,UAAU,KAAmC;AACrD,QAAO,MAAM,QAAQ,UAAU;;AAGhC,MAAa,UACX,OAAO,YAAY,eAAe,QAAQ,OAAO,QAAQ,IAAI,YAAa;;AAG5E,MAAa,eAAe,YAAY;;AAGxC,MAAa,sBACZ,YAAY,SAAS,YAAY;;AAGlC,MAAa,eAAe,YAAY,UAAU,UAAU,IAAI,KAAK;;;;AAKrE,SAAgB,UACf,KACA,UACwD;AACxD,KAAI,OAAO,YAAY,eAAe,QAAQ,IAC7C,QAAO,QAAQ,IAAI,QAAS;AAI7B,KAAI,OAAO,SAAS,YAEnB,QAAO,KAAK,IAAI,IAAI,IAAI,IAAK;AAI9B,KAAI,OAAO,QAAQ,YAClB,QAAO,IAAI,IAAI,QAAS;AAGzB,QAAO;;;;;AAMR,SAAgB,iBAAiB,KAAa,WAAW,MAAe;CACvE,MAAM,QAAQ,UAAU,IAAI;AAC5B,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,UAAU,OAAO,MAAM,aAAa,KAAK,WAAW,UAAU;;;;;AAMtE,MAAa,MAAM,OAAO,OAAO;CAChC,IAAI,qBAAqB;AACxB,SAAO,UAAU,qBAAqB;;CAEvC,IAAI,cAAc;AACjB,SAAO,UAAU,cAAc;;CAEhC,IAAI,wBAAwB;AAC3B,SAAO,UAAU,wBAAwB;;CAE1C,IAAI,2BAA2B;AAC9B,SAAO,UAAU,2BAA2B;;CAE7C,IAAI,WAAW;AACd,SAAO,UAAU,YAAY,cAAc;;CAE5C,IAAI,kBAAkB;AACrB,SAAO,UAAU,mBAAmB,QAAQ;;CAE7C,IAAI,iCAAqD;AACxD,SAAO,UACN,kCAAA,GAEA;;CAEF,CAAC"}
|
package/dist/env/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ENV, env, getBooleanEnvVar, getEnvVar, isDevelopment, isProduction, isTest, nodeENV } from "./env-impl.mjs";
|
|
2
2
|
import { getColorDepth } from "./color-depth.mjs";
|
|
3
3
|
import { TTY_COLORS, createLogger, levels, logger, shouldPublishLog } from "./logger.mjs";
|
|
4
|
-
|
|
5
|
-
export { ENV, TTY_COLORS, createLogger, env, getBooleanEnvVar, getColorDepth, getEnvVar, isDevelopment, isProduction, isTest, levels, logger, nodeENV, shouldPublishLog };
|
|
4
|
+
export { ENV, TTY_COLORS, createLogger, env, getBooleanEnvVar, getColorDepth, getEnvVar, isDevelopment, isProduction, isTest, levels, logger, nodeENV, shouldPublishLog };
|
package/dist/env/logger.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getColorDepth } from "./color-depth.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/env/logger.ts
|
|
4
3
|
const TTY_COLORS = {
|
|
5
4
|
reset: "\x1B[0m",
|
|
@@ -76,7 +75,7 @@ const createLogger = (options) => {
|
|
|
76
75
|
};
|
|
77
76
|
};
|
|
78
77
|
const logger = createLogger();
|
|
79
|
-
|
|
80
78
|
//#endregion
|
|
81
79
|
export { TTY_COLORS, createLogger, levels, logger, shouldPublishLog };
|
|
80
|
+
|
|
82
81
|
//# sourceMappingURL=logger.mjs.map
|
package/dist/env/logger.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.mjs","names":[],"sources":["../../src/env/logger.ts"],"sourcesContent":["import { getColorDepth } from \"./color-depth\";\n\nexport const TTY_COLORS = {\n\treset: \"\\x1b[0m\",\n\tbright: \"\\x1b[1m\",\n\tdim: \"\\x1b[2m\",\n\tundim: \"\\x1b[22m\",\n\tunderscore: \"\\x1b[4m\",\n\tblink: \"\\x1b[5m\",\n\treverse: \"\\x1b[7m\",\n\thidden: \"\\x1b[8m\",\n\tfg: {\n\t\tblack: \"\\x1b[30m\",\n\t\tred: \"\\x1b[31m\",\n\t\tgreen: \"\\x1b[32m\",\n\t\tyellow: \"\\x1b[33m\",\n\t\tblue: \"\\x1b[34m\",\n\t\tmagenta: \"\\x1b[35m\",\n\t\tcyan: \"\\x1b[36m\",\n\t\twhite: \"\\x1b[37m\",\n\t},\n\tbg: {\n\t\tblack: \"\\x1b[40m\",\n\t\tred: \"\\x1b[41m\",\n\t\tgreen: \"\\x1b[42m\",\n\t\tyellow: \"\\x1b[43m\",\n\t\tblue: \"\\x1b[44m\",\n\t\tmagenta: \"\\x1b[45m\",\n\t\tcyan: \"\\x1b[46m\",\n\t\twhite: \"\\x1b[47m\",\n\t},\n} as const;\n\nexport type LogLevel = \"debug\" | \"info\" | \"success\" | \"warn\" | \"error\";\n\nexport const levels = [\"debug\", \"info\", \"success\", \"warn\", \"error\"] as const;\n\nexport function shouldPublishLog(\n\tcurrentLogLevel: LogLevel,\n\tlogLevel: LogLevel,\n): boolean {\n\treturn levels.indexOf(logLevel) >= levels.indexOf(currentLogLevel);\n}\n\nexport interface Logger {\n\tdisabled?: boolean | undefined;\n\tdisableColors?: boolean | undefined;\n\tlevel?: Exclude<LogLevel, \"success\"> | undefined;\n\tlog?:\n\t\t| ((\n\t\t\t\tlevel: Exclude<LogLevel, \"success\">,\n\t\t\t\tmessage: string,\n\t\t\t\t...args: any[]\n\t\t ) => void)\n\t\t| undefined;\n}\n\nexport type LogHandlerParams =\n\tParameters<NonNullable<Logger[\"log\"]>> extends [LogLevel, ...infer Rest]\n\t\t? Rest\n\t\t: never;\n\nconst levelColors: Record<LogLevel, string> = {\n\tinfo: TTY_COLORS.fg.blue,\n\tsuccess: TTY_COLORS.fg.green,\n\twarn: TTY_COLORS.fg.yellow,\n\terror: TTY_COLORS.fg.red,\n\tdebug: TTY_COLORS.fg.magenta,\n};\n\nconst formatMessage = (\n\tlevel: LogLevel,\n\tmessage: string,\n\tcolorsEnabled: boolean,\n): string => {\n\tconst timestamp = new Date().toISOString();\n\n\tif (colorsEnabled) {\n\t\treturn `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${\n\t\t\tlevelColors[level]\n\t\t}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${\n\t\t\tTTY_COLORS.reset\n\t\t} ${message}`;\n\t}\n\n\treturn `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;\n};\n\nexport type InternalLogger = {\n\t[K in LogLevel]: (...params: LogHandlerParams) => void;\n} & {\n\tget level(): LogLevel;\n};\n\nexport const createLogger = (options?: Logger | undefined): InternalLogger => {\n\tconst enabled = options?.disabled !== true;\n\tconst logLevel = options?.level ?? \"warn\";\n\n\tconst isDisableColorsSpecified = options?.disableColors !== undefined;\n\tconst colorsEnabled = isDisableColorsSpecified\n\t\t? !options.disableColors\n\t\t: getColorDepth() !== 1;\n\n\tconst LogFunc = (\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\targs: any[] = [],\n\t): void => {\n\t\tif (!enabled || !shouldPublishLog(logLevel, level)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst formattedMessage = formatMessage(level, message, colorsEnabled);\n\n\t\tif (!options || typeof options.log !== \"function\") {\n\t\t\tif (level === \"error\") {\n\t\t\t\tconsole.error(formattedMessage, ...args);\n\t\t\t} else if (level === \"warn\") {\n\t\t\t\tconsole.warn(formattedMessage, ...args);\n\t\t\t} else {\n\t\t\t\tconsole.log(formattedMessage, ...args);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\toptions.log(level === \"success\" ? \"info\" : level, message, ...args);\n\t};\n\n\tconst logger = Object.fromEntries(\n\t\tlevels.map((level) => [\n\t\t\tlevel,\n\t\t\t(...[message, ...args]: LogHandlerParams) =>\n\t\t\t\tLogFunc(level, message, args),\n\t\t]),\n\t) as Record<LogLevel, (...params: LogHandlerParams) => void>;\n\n\treturn {\n\t\t...logger,\n\t\tget level() {\n\t\t\treturn logLevel;\n\t\t},\n\t};\n};\n\nexport const logger = createLogger();\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":[],"sources":["../../src/env/logger.ts"],"sourcesContent":["import { getColorDepth } from \"./color-depth\";\n\nexport const TTY_COLORS = {\n\treset: \"\\x1b[0m\",\n\tbright: \"\\x1b[1m\",\n\tdim: \"\\x1b[2m\",\n\tundim: \"\\x1b[22m\",\n\tunderscore: \"\\x1b[4m\",\n\tblink: \"\\x1b[5m\",\n\treverse: \"\\x1b[7m\",\n\thidden: \"\\x1b[8m\",\n\tfg: {\n\t\tblack: \"\\x1b[30m\",\n\t\tred: \"\\x1b[31m\",\n\t\tgreen: \"\\x1b[32m\",\n\t\tyellow: \"\\x1b[33m\",\n\t\tblue: \"\\x1b[34m\",\n\t\tmagenta: \"\\x1b[35m\",\n\t\tcyan: \"\\x1b[36m\",\n\t\twhite: \"\\x1b[37m\",\n\t},\n\tbg: {\n\t\tblack: \"\\x1b[40m\",\n\t\tred: \"\\x1b[41m\",\n\t\tgreen: \"\\x1b[42m\",\n\t\tyellow: \"\\x1b[43m\",\n\t\tblue: \"\\x1b[44m\",\n\t\tmagenta: \"\\x1b[45m\",\n\t\tcyan: \"\\x1b[46m\",\n\t\twhite: \"\\x1b[47m\",\n\t},\n} as const;\n\nexport type LogLevel = \"debug\" | \"info\" | \"success\" | \"warn\" | \"error\";\n\nexport const levels = [\"debug\", \"info\", \"success\", \"warn\", \"error\"] as const;\n\nexport function shouldPublishLog(\n\tcurrentLogLevel: LogLevel,\n\tlogLevel: LogLevel,\n): boolean {\n\treturn levels.indexOf(logLevel) >= levels.indexOf(currentLogLevel);\n}\n\nexport interface Logger {\n\tdisabled?: boolean | undefined;\n\tdisableColors?: boolean | undefined;\n\tlevel?: Exclude<LogLevel, \"success\"> | undefined;\n\tlog?:\n\t\t| ((\n\t\t\t\tlevel: Exclude<LogLevel, \"success\">,\n\t\t\t\tmessage: string,\n\t\t\t\t...args: any[]\n\t\t ) => void)\n\t\t| undefined;\n}\n\nexport type LogHandlerParams =\n\tParameters<NonNullable<Logger[\"log\"]>> extends [LogLevel, ...infer Rest]\n\t\t? Rest\n\t\t: never;\n\nconst levelColors: Record<LogLevel, string> = {\n\tinfo: TTY_COLORS.fg.blue,\n\tsuccess: TTY_COLORS.fg.green,\n\twarn: TTY_COLORS.fg.yellow,\n\terror: TTY_COLORS.fg.red,\n\tdebug: TTY_COLORS.fg.magenta,\n};\n\nconst formatMessage = (\n\tlevel: LogLevel,\n\tmessage: string,\n\tcolorsEnabled: boolean,\n): string => {\n\tconst timestamp = new Date().toISOString();\n\n\tif (colorsEnabled) {\n\t\treturn `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${\n\t\t\tlevelColors[level]\n\t\t}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${\n\t\t\tTTY_COLORS.reset\n\t\t} ${message}`;\n\t}\n\n\treturn `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;\n};\n\nexport type InternalLogger = {\n\t[K in LogLevel]: (...params: LogHandlerParams) => void;\n} & {\n\tget level(): LogLevel;\n};\n\nexport const createLogger = (options?: Logger | undefined): InternalLogger => {\n\tconst enabled = options?.disabled !== true;\n\tconst logLevel = options?.level ?? \"warn\";\n\n\tconst isDisableColorsSpecified = options?.disableColors !== undefined;\n\tconst colorsEnabled = isDisableColorsSpecified\n\t\t? !options.disableColors\n\t\t: getColorDepth() !== 1;\n\n\tconst LogFunc = (\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\targs: any[] = [],\n\t): void => {\n\t\tif (!enabled || !shouldPublishLog(logLevel, level)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst formattedMessage = formatMessage(level, message, colorsEnabled);\n\n\t\tif (!options || typeof options.log !== \"function\") {\n\t\t\tif (level === \"error\") {\n\t\t\t\tconsole.error(formattedMessage, ...args);\n\t\t\t} else if (level === \"warn\") {\n\t\t\t\tconsole.warn(formattedMessage, ...args);\n\t\t\t} else {\n\t\t\t\tconsole.log(formattedMessage, ...args);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\toptions.log(level === \"success\" ? \"info\" : level, message, ...args);\n\t};\n\n\tconst logger = Object.fromEntries(\n\t\tlevels.map((level) => [\n\t\t\tlevel,\n\t\t\t(...[message, ...args]: LogHandlerParams) =>\n\t\t\t\tLogFunc(level, message, args),\n\t\t]),\n\t) as Record<LogLevel, (...params: LogHandlerParams) => void>;\n\n\treturn {\n\t\t...logger,\n\t\tget level() {\n\t\t\treturn logLevel;\n\t\t},\n\t};\n};\n\nexport const logger = createLogger();\n"],"mappings":";;AAEA,MAAa,aAAa;CACzB,OAAO;CACP,QAAQ;CACR,KAAK;CACL,OAAO;CACP,YAAY;CACZ,OAAO;CACP,SAAS;CACT,QAAQ;CACR,IAAI;EACH,OAAO;EACP,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACN,SAAS;EACT,MAAM;EACN,OAAO;EACP;CACD,IAAI;EACH,OAAO;EACP,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACN,SAAS;EACT,MAAM;EACN,OAAO;EACP;CACD;AAID,MAAa,SAAS;CAAC;CAAS;CAAQ;CAAW;CAAQ;CAAQ;AAEnE,SAAgB,iBACf,iBACA,UACU;AACV,QAAO,OAAO,QAAQ,SAAS,IAAI,OAAO,QAAQ,gBAAgB;;AAqBnE,MAAM,cAAwC;CAC7C,MAAM,WAAW,GAAG;CACpB,SAAS,WAAW,GAAG;CACvB,MAAM,WAAW,GAAG;CACpB,OAAO,WAAW,GAAG;CACrB,OAAO,WAAW,GAAG;CACrB;AAED,MAAM,iBACL,OACA,SACA,kBACY;CACZ,MAAM,6BAAY,IAAI,MAAM,EAAC,aAAa;AAE1C,KAAI,cACH,QAAO,GAAG,WAAW,MAAM,YAAY,WAAW,MAAM,GACvD,YAAY,SACV,MAAM,aAAa,GAAG,WAAW,MAAM,GAAG,WAAW,OAAO,gBAC9D,WAAW,MACX,GAAG;AAGL,QAAO,GAAG,UAAU,GAAG,MAAM,aAAa,CAAC,kBAAkB;;AAS9D,MAAa,gBAAgB,YAAiD;CAC7E,MAAM,UAAU,SAAS,aAAa;CACtC,MAAM,WAAW,SAAS,SAAS;CAGnC,MAAM,gBAD2B,SAAS,kBAAkB,KAAA,IAEzD,CAAC,QAAQ,gBACT,eAAe,KAAK;CAEvB,MAAM,WACL,OACA,SACA,OAAc,EAAE,KACN;AACV,MAAI,CAAC,WAAW,CAAC,iBAAiB,UAAU,MAAM,CACjD;EAGD,MAAM,mBAAmB,cAAc,OAAO,SAAS,cAAc;AAErE,MAAI,CAAC,WAAW,OAAO,QAAQ,QAAQ,YAAY;AAClD,OAAI,UAAU,QACb,SAAQ,MAAM,kBAAkB,GAAG,KAAK;YAC9B,UAAU,OACpB,SAAQ,KAAK,kBAAkB,GAAG,KAAK;OAEvC,SAAQ,IAAI,kBAAkB,GAAG,KAAK;AAEvC;;AAGD,UAAQ,IAAI,UAAU,YAAY,SAAS,OAAO,SAAS,GAAG,KAAK;;AAWpE,QAAO;EACN,GATc,OAAO,YACrB,OAAO,KAAK,UAAU,CACrB,QACC,GAAG,CAAC,SAAS,GAAG,UAChB,QAAQ,OAAO,SAAS,KAAK,CAC9B,CAAC,CACF;EAIA,IAAI,QAAQ;AACX,UAAO;;EAER;;AAGF,MAAa,SAAS,cAAc"}
|
package/dist/error/codes.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineErrorCodes } from "../utils/error-codes.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/error/codes.ts
|
|
4
3
|
const BASE_ERROR_CODES = defineErrorCodes({
|
|
5
4
|
USER_NOT_FOUND: "User not found",
|
|
@@ -51,7 +50,7 @@ const BASE_ERROR_CODES = defineErrorCodes({
|
|
|
51
50
|
BODY_MUST_BE_AN_OBJECT: "Body must be an object",
|
|
52
51
|
PASSWORD_ALREADY_SET: "User already has a password set"
|
|
53
52
|
});
|
|
54
|
-
|
|
55
53
|
//#endregion
|
|
56
54
|
export { BASE_ERROR_CODES };
|
|
55
|
+
|
|
57
56
|
//# sourceMappingURL=codes.mjs.map
|
package/dist/error/codes.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codes.mjs","names":[],"sources":["../../src/error/codes.ts"],"sourcesContent":["import { defineErrorCodes } from \"../utils/error-codes\";\n\ndeclare module \"@better-auth/core\" {\n\tinterface BetterAuthPluginRegistry<AuthOptions, Options> {\n\t\t/**\n\t\t * This plugin does not exist, do not use it in runtime.\n\t\t */\n\t\t\"$internal:base\": {\n\t\t\tcreator: () => {\n\t\t\t\t$ERROR_CODES: typeof BASE_ERROR_CODES;\n\t\t\t};\n\t\t};\n\t}\n}\n\nexport const BASE_ERROR_CODES = defineErrorCodes({\n\tUSER_NOT_FOUND: \"User not found\",\n\tFAILED_TO_CREATE_USER: \"Failed to create user\",\n\tFAILED_TO_CREATE_SESSION: \"Failed to create session\",\n\tFAILED_TO_UPDATE_USER: \"Failed to update user\",\n\tFAILED_TO_GET_SESSION: \"Failed to get session\",\n\tINVALID_PASSWORD: \"Invalid password\",\n\tINVALID_EMAIL: \"Invalid email\",\n\tINVALID_EMAIL_OR_PASSWORD: \"Invalid email or password\",\n\tINVALID_USER: \"Invalid user\",\n\tSOCIAL_ACCOUNT_ALREADY_LINKED: \"Social account already linked\",\n\tPROVIDER_NOT_FOUND: \"Provider not found\",\n\tINVALID_TOKEN: \"Invalid token\",\n\tTOKEN_EXPIRED: \"Token expired\",\n\tID_TOKEN_NOT_SUPPORTED: \"id_token not supported\",\n\tFAILED_TO_GET_USER_INFO: \"Failed to get user info\",\n\tUSER_EMAIL_NOT_FOUND: \"User email not found\",\n\tEMAIL_NOT_VERIFIED: \"Email not verified\",\n\tPASSWORD_TOO_SHORT: \"Password too short\",\n\tPASSWORD_TOO_LONG: \"Password too long\",\n\tUSER_ALREADY_EXISTS: \"User already exists.\",\n\tUSER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:\n\t\t\"User already exists. Use another email.\",\n\tEMAIL_CAN_NOT_BE_UPDATED: \"Email can not be updated\",\n\tCREDENTIAL_ACCOUNT_NOT_FOUND: \"Credential account not found\",\n\tSESSION_EXPIRED: \"Session expired. Re-authenticate to perform this action.\",\n\tFAILED_TO_UNLINK_LAST_ACCOUNT: \"You can't unlink your last account\",\n\tACCOUNT_NOT_FOUND: \"Account not found\",\n\tUSER_ALREADY_HAS_PASSWORD:\n\t\t\"User already has a password. Provide that to delete the account.\",\n\tCROSS_SITE_NAVIGATION_LOGIN_BLOCKED:\n\t\t\"Cross-site navigation login blocked. This request appears to be a CSRF attack.\",\n\tVERIFICATION_EMAIL_NOT_ENABLED: \"Verification email isn't enabled\",\n\tEMAIL_ALREADY_VERIFIED: \"Email is already verified\",\n\tEMAIL_MISMATCH: \"Email mismatch\",\n\tSESSION_NOT_FRESH: \"Session is not fresh\",\n\tLINKED_ACCOUNT_ALREADY_EXISTS: \"Linked account already exists\",\n\tINVALID_ORIGIN: \"Invalid origin\",\n\tINVALID_CALLBACK_URL: \"Invalid callbackURL\",\n\tINVALID_REDIRECT_URL: \"Invalid redirectURL\",\n\tINVALID_ERROR_CALLBACK_URL: \"Invalid errorCallbackURL\",\n\tINVALID_NEW_USER_CALLBACK_URL: \"Invalid newUserCallbackURL\",\n\tMISSING_OR_NULL_ORIGIN: \"Missing or null Origin\",\n\tCALLBACK_URL_REQUIRED: \"callbackURL is required\",\n\tFAILED_TO_CREATE_VERIFICATION: \"Unable to create verification\",\n\tFIELD_NOT_ALLOWED: \"Field not allowed to be set\",\n\tASYNC_VALIDATION_NOT_SUPPORTED: \"Async validation is not supported\",\n\tVALIDATION_ERROR: \"Validation Error\",\n\tMISSING_FIELD: \"Field is required\",\n\tMETHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED:\n\t\t\"POST method requires deferSessionRefresh to be enabled in session config\",\n\tBODY_MUST_BE_AN_OBJECT: \"Body must be an object\",\n\tPASSWORD_ALREADY_SET: \"User already has a password set\",\n});\n\nexport type APIErrorCode = keyof typeof BASE_ERROR_CODES;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codes.mjs","names":[],"sources":["../../src/error/codes.ts"],"sourcesContent":["import { defineErrorCodes } from \"../utils/error-codes\";\n\ndeclare module \"@better-auth/core\" {\n\tinterface BetterAuthPluginRegistry<AuthOptions, Options> {\n\t\t/**\n\t\t * This plugin does not exist, do not use it in runtime.\n\t\t */\n\t\t\"$internal:base\": {\n\t\t\tcreator: () => {\n\t\t\t\t$ERROR_CODES: typeof BASE_ERROR_CODES;\n\t\t\t};\n\t\t};\n\t}\n}\n\nexport const BASE_ERROR_CODES = defineErrorCodes({\n\tUSER_NOT_FOUND: \"User not found\",\n\tFAILED_TO_CREATE_USER: \"Failed to create user\",\n\tFAILED_TO_CREATE_SESSION: \"Failed to create session\",\n\tFAILED_TO_UPDATE_USER: \"Failed to update user\",\n\tFAILED_TO_GET_SESSION: \"Failed to get session\",\n\tINVALID_PASSWORD: \"Invalid password\",\n\tINVALID_EMAIL: \"Invalid email\",\n\tINVALID_EMAIL_OR_PASSWORD: \"Invalid email or password\",\n\tINVALID_USER: \"Invalid user\",\n\tSOCIAL_ACCOUNT_ALREADY_LINKED: \"Social account already linked\",\n\tPROVIDER_NOT_FOUND: \"Provider not found\",\n\tINVALID_TOKEN: \"Invalid token\",\n\tTOKEN_EXPIRED: \"Token expired\",\n\tID_TOKEN_NOT_SUPPORTED: \"id_token not supported\",\n\tFAILED_TO_GET_USER_INFO: \"Failed to get user info\",\n\tUSER_EMAIL_NOT_FOUND: \"User email not found\",\n\tEMAIL_NOT_VERIFIED: \"Email not verified\",\n\tPASSWORD_TOO_SHORT: \"Password too short\",\n\tPASSWORD_TOO_LONG: \"Password too long\",\n\tUSER_ALREADY_EXISTS: \"User already exists.\",\n\tUSER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:\n\t\t\"User already exists. Use another email.\",\n\tEMAIL_CAN_NOT_BE_UPDATED: \"Email can not be updated\",\n\tCREDENTIAL_ACCOUNT_NOT_FOUND: \"Credential account not found\",\n\tSESSION_EXPIRED: \"Session expired. Re-authenticate to perform this action.\",\n\tFAILED_TO_UNLINK_LAST_ACCOUNT: \"You can't unlink your last account\",\n\tACCOUNT_NOT_FOUND: \"Account not found\",\n\tUSER_ALREADY_HAS_PASSWORD:\n\t\t\"User already has a password. Provide that to delete the account.\",\n\tCROSS_SITE_NAVIGATION_LOGIN_BLOCKED:\n\t\t\"Cross-site navigation login blocked. This request appears to be a CSRF attack.\",\n\tVERIFICATION_EMAIL_NOT_ENABLED: \"Verification email isn't enabled\",\n\tEMAIL_ALREADY_VERIFIED: \"Email is already verified\",\n\tEMAIL_MISMATCH: \"Email mismatch\",\n\tSESSION_NOT_FRESH: \"Session is not fresh\",\n\tLINKED_ACCOUNT_ALREADY_EXISTS: \"Linked account already exists\",\n\tINVALID_ORIGIN: \"Invalid origin\",\n\tINVALID_CALLBACK_URL: \"Invalid callbackURL\",\n\tINVALID_REDIRECT_URL: \"Invalid redirectURL\",\n\tINVALID_ERROR_CALLBACK_URL: \"Invalid errorCallbackURL\",\n\tINVALID_NEW_USER_CALLBACK_URL: \"Invalid newUserCallbackURL\",\n\tMISSING_OR_NULL_ORIGIN: \"Missing or null Origin\",\n\tCALLBACK_URL_REQUIRED: \"callbackURL is required\",\n\tFAILED_TO_CREATE_VERIFICATION: \"Unable to create verification\",\n\tFIELD_NOT_ALLOWED: \"Field not allowed to be set\",\n\tASYNC_VALIDATION_NOT_SUPPORTED: \"Async validation is not supported\",\n\tVALIDATION_ERROR: \"Validation Error\",\n\tMISSING_FIELD: \"Field is required\",\n\tMETHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED:\n\t\t\"POST method requires deferSessionRefresh to be enabled in session config\",\n\tBODY_MUST_BE_AN_OBJECT: \"Body must be an object\",\n\tPASSWORD_ALREADY_SET: \"User already has a password set\",\n});\n\nexport type APIErrorCode = keyof typeof BASE_ERROR_CODES;\n"],"mappings":";;AAeA,MAAa,mBAAmB,iBAAiB;CAChD,gBAAgB;CAChB,uBAAuB;CACvB,0BAA0B;CAC1B,uBAAuB;CACvB,uBAAuB;CACvB,kBAAkB;CAClB,eAAe;CACf,2BAA2B;CAC3B,cAAc;CACd,+BAA+B;CAC/B,oBAAoB;CACpB,eAAe;CACf,eAAe;CACf,wBAAwB;CACxB,yBAAyB;CACzB,sBAAsB;CACtB,oBAAoB;CACpB,oBAAoB;CACpB,mBAAmB;CACnB,qBAAqB;CACrB,uCACC;CACD,0BAA0B;CAC1B,8BAA8B;CAC9B,iBAAiB;CACjB,+BAA+B;CAC/B,mBAAmB;CACnB,2BACC;CACD,qCACC;CACD,gCAAgC;CAChC,wBAAwB;CACxB,gBAAgB;CAChB,mBAAmB;CACnB,+BAA+B;CAC/B,gBAAgB;CAChB,sBAAsB;CACtB,sBAAsB;CACtB,4BAA4B;CAC5B,+BAA+B;CAC/B,wBAAwB;CACxB,uBAAuB;CACvB,+BAA+B;CAC/B,mBAAmB;CACnB,gCAAgC;CAChC,kBAAkB;CAClB,eAAe;CACf,2CACC;CACD,wBAAwB;CACxB,sBAAsB;CACtB,CAAC"}
|
package/dist/error/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BASE_ERROR_CODES } from "./codes.mjs";
|
|
2
2
|
import { APIError as APIError$1 } from "better-call/error";
|
|
3
|
-
|
|
4
3
|
//#region src/error/index.ts
|
|
5
4
|
var BetterAuthError = class extends Error {
|
|
6
5
|
constructor(message, options) {
|
|
@@ -24,7 +23,7 @@ var APIError = class APIError extends APIError$1 {
|
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
};
|
|
27
|
-
|
|
28
26
|
//#endregion
|
|
29
27
|
export { APIError, BASE_ERROR_CODES, BetterAuthError };
|
|
28
|
+
|
|
30
29
|
//# sourceMappingURL=index.mjs.map
|
package/dist/error/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["BaseAPIError"],"sources":["../../src/error/index.ts"],"sourcesContent":["import { APIError as BaseAPIError } from \"better-call/error\";\n\nexport class BetterAuthError extends Error {\n\tconstructor(message: string, options?: { cause?: unknown | undefined }) {\n\t\tsuper(message, options);\n\t\tthis.name = \"BetterAuthError\";\n\t\tthis.message = message;\n\t\tthis.stack = \"\";\n\t}\n}\n\nexport { type APIErrorCode, BASE_ERROR_CODES } from \"./codes\";\n\nexport class APIError extends BaseAPIError {\n\tconstructor(...args: ConstructorParameters<typeof BaseAPIError>) {\n\t\tsuper(...args);\n\t}\n\n\tstatic fromStatus(\n\t\tstatus: ConstructorParameters<typeof BaseAPIError>[0],\n\t\tbody?: ConstructorParameters<typeof BaseAPIError>[1],\n\t) {\n\t\treturn new APIError(status, body);\n\t}\n\n\tstatic from(\n\t\tstatus: ConstructorParameters<typeof BaseAPIError>[0],\n\t\terror: { code: string; message: string },\n\t) {\n\t\treturn new APIError(status, {\n\t\t\tmessage: error.message,\n\t\t\tcode: error.code,\n\t\t});\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["BaseAPIError"],"sources":["../../src/error/index.ts"],"sourcesContent":["import { APIError as BaseAPIError } from \"better-call/error\";\n\nexport class BetterAuthError extends Error {\n\tconstructor(message: string, options?: { cause?: unknown | undefined }) {\n\t\tsuper(message, options);\n\t\tthis.name = \"BetterAuthError\";\n\t\tthis.message = message;\n\t\tthis.stack = \"\";\n\t}\n}\n\nexport { type APIErrorCode, BASE_ERROR_CODES } from \"./codes\";\n\nexport class APIError extends BaseAPIError {\n\tconstructor(...args: ConstructorParameters<typeof BaseAPIError>) {\n\t\tsuper(...args);\n\t}\n\n\tstatic fromStatus(\n\t\tstatus: ConstructorParameters<typeof BaseAPIError>[0],\n\t\tbody?: ConstructorParameters<typeof BaseAPIError>[1],\n\t) {\n\t\treturn new APIError(status, body);\n\t}\n\n\tstatic from(\n\t\tstatus: ConstructorParameters<typeof BaseAPIError>[0],\n\t\terror: { code: string; message: string },\n\t) {\n\t\treturn new APIError(status, {\n\t\t\tmessage: error.message,\n\t\t\tcode: error.code,\n\t\t});\n\t}\n}\n"],"mappings":";;;AAEA,IAAa,kBAAb,cAAqC,MAAM;CAC1C,YAAY,SAAiB,SAA2C;AACvE,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;AACZ,OAAK,UAAU;AACf,OAAK,QAAQ;;;AAMf,IAAa,WAAb,MAAa,iBAAiBA,WAAa;CAC1C,YAAY,GAAG,MAAkD;AAChE,QAAM,GAAG,KAAK;;CAGf,OAAO,WACN,QACA,MACC;AACD,SAAO,IAAI,SAAS,QAAQ,KAAK;;CAGlC,OAAO,KACN,QACA,OACC;AACD,SAAO,IAAI,SAAS,QAAQ;GAC3B,SAAS,MAAM;GACf,MAAM,MAAM;GACZ,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE } from "@opentelemetry/semantic-conventions";
|
|
2
|
+
|
|
3
|
+
//#region src/instrumentation/attributes.d.ts
|
|
4
|
+
/** Operation identifier (e.g. getSession, signUpWithEmailAndPassword). Uses endpoint operationId when set, otherwise the endpoint key. */
|
|
5
|
+
declare const ATTR_OPERATION_ID: "better_auth.operation_id";
|
|
6
|
+
/** Hook type (e.g. before, after, create.before). */
|
|
7
|
+
declare const ATTR_HOOK_TYPE: "better_auth.hook.type";
|
|
8
|
+
/** Execution context (e.g. user, plugin:id). */
|
|
9
|
+
declare const ATTR_CONTEXT: "better_auth.context";
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ATTR_CONTEXT, ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME, ATTR_HOOK_TYPE, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE, ATTR_OPERATION_ID };
|
|
12
|
+
//# sourceMappingURL=attributes.d.mts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE } from "@opentelemetry/semantic-conventions";
|
|
2
|
+
//#region src/instrumentation/attributes.ts
|
|
3
|
+
/** Operation identifier (e.g. getSession, signUpWithEmailAndPassword). Uses endpoint operationId when set, otherwise the endpoint key. */
|
|
4
|
+
const ATTR_OPERATION_ID = "better_auth.operation_id";
|
|
5
|
+
/** Hook type (e.g. before, after, create.before). */
|
|
6
|
+
const ATTR_HOOK_TYPE = "better_auth.hook.type";
|
|
7
|
+
/** Execution context (e.g. user, plugin:id). */
|
|
8
|
+
const ATTR_CONTEXT = "better_auth.context";
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ATTR_CONTEXT, ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME, ATTR_HOOK_TYPE, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE, ATTR_OPERATION_ID };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=attributes.mjs.map
|