create-croissant 0.1.0 → 0.1.2
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/index.js +3 -3
- package/package.json +16 -8
- package/template/.prettierignore +10 -0
- package/template/.prettierrc +11 -0
- package/template/README.md +88 -0
- package/template/apps/web/.env.example +4 -0
- package/template/apps/web/components.json +23 -0
- package/template/apps/web/drizzle.config.ts +11 -0
- package/template/apps/web/eslint.config.js +10 -0
- package/template/apps/web/node_modules/@better-auth/core/LICENSE.md +20 -0
- package/template/apps/web/node_modules/@better-auth/core/README.md +17 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/api/index.d.mts +278 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/api/index.mjs +56 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/index.d.mts +6 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/index.mjs +20 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/pure.index.d.mts +6 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/pure.index.mjs +33 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/endpoint-context.d.mts +18 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/endpoint-context.mjs +29 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/global.d.mts +6 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/global.mjs +36 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/index.d.mts +5 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/index.mjs +5 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/request-state.d.mts +27 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/request-state.mjs +47 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/transaction.d.mts +24 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/context/transaction.mjs +93 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/factory.d.mts +17 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/factory.mjs +754 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-field-name.d.mts +18 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-field-name.mjs +36 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-model-name.d.mts +12 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-model-name.mjs +30 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-attributes.d.mts +26 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-attributes.mjs +37 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-name.d.mts +18 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-name.mjs +31 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-id-field.d.mts +36 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-id-field.mjs +64 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-model-name.d.mts +12 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-model-name.mjs +21 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/index.d.mts +525 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/index.mjs +24 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/types.d.mts +105 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/utils.d.mts +7 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/utils.mjs +37 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/get-tables.d.mts +6 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/get-tables.mjs +265 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/index.d.mts +10 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/index.mjs +8 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/plugin.d.mts +12 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/account.d.mts +28 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/account.mjs +17 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/rate-limit.d.mts +18 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/rate-limit.mjs +9 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/session.d.mts +23 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/session.mjs +12 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/shared.d.mts +10 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/shared.mjs +9 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/user.d.mts +22 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/user.mjs +11 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/verification.d.mts +21 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/verification.mjs +10 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/db/type.d.mts +167 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/env/color-depth.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/env/color-depth.mjs +86 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/env/env-impl.d.mts +32 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/env/env-impl.mjs +81 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/env/index.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/env/index.mjs +4 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/env/logger.d.mts +48 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/env/logger.mjs +79 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/error/codes.d.mts +68 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/error/codes.mjs +54 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/error/index.d.mts +19 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/error/index.mjs +27 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/index.d.mts +9 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/index.mjs +1 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/api.mjs +12 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/attributes.d.mts +11 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/attributes.mjs +10 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/index.d.mts +3 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/index.mjs +3 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/noop.mjs +42 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/pure.index.d.mts +7 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/pure.index.mjs +7 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/tracer.d.mts +13 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/tracer.mjs +53 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/client-credentials-token.d.mts +56 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/client-credentials-token.mjs +64 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/create-authorization-url.d.mts +44 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/create-authorization-url.mjs +41 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/index.d.mts +8 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/index.mjs +7 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/oauth-provider.d.mts +192 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/refresh-access-token.d.mts +54 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/refresh-access-token.mjs +73 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/utils.d.mts +16 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/utils.mjs +37 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/validate-authorization-code.d.mts +85 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/validate-authorization-code.mjs +79 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/verify.d.mts +42 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/verify.mjs +92 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/apple.d.mts +126 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/apple.mjs +107 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/atlassian.d.mts +70 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/atlassian.mjs +80 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/cognito.d.mts +85 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/cognito.mjs +162 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/discord.d.mts +124 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/discord.mjs +62 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/dropbox.d.mts +69 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/dropbox.mjs +72 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/facebook.d.mts +79 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/facebook.mjs +124 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/figma.d.mts +61 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/figma.mjs +83 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/github.d.mts +102 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/github.mjs +92 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/gitlab.d.mts +123 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/gitlab.mjs +79 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/google.d.mts +97 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/google.mjs +109 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/huggingface.d.mts +83 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/huggingface.mjs +73 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/index.d.mts +1834 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/index.mjs +78 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kakao.d.mts +161 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kakao.mjs +70 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kick.d.mts +73 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kick.mjs +68 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/line.d.mts +105 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/line.mjs +110 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linear.d.mts +68 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linear.mjs +85 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linkedin.d.mts +67 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linkedin.mjs +73 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/microsoft-entra-id.d.mts +174 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/microsoft-entra-id.mjs +140 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/naver.d.mts +92 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/naver.mjs +65 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/notion.d.mts +64 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/notion.mjs +72 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paybin.d.mts +71 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paybin.mjs +81 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paypal.d.mts +129 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paypal.mjs +140 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/polar.d.mts +74 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/polar.mjs +71 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/railway.d.mts +65 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/railway.mjs +74 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/reddit.d.mts +62 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/reddit.mjs +80 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/roblox.d.mts +70 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/roblox.mjs +57 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/salesforce.d.mts +79 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/salesforce.mjs +87 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/slack.d.mts +83 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/slack.mjs +66 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/spotify.d.mts +63 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/spotify.mjs +69 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/tiktok.d.mts +168 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/tiktok.mjs +60 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitch.d.mts +79 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitch.mjs +75 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitter.d.mts +126 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitter.mjs +85 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vercel.d.mts +62 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vercel.mjs +58 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vk.d.mts +70 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vk.mjs +81 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/wechat.d.mts +113 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/wechat.mjs +81 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/zoom.d.mts +163 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/zoom.mjs +69 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/types/context.d.mts +277 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/types/cookie.d.mts +15 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/types/helper.d.mts +10 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/types/index.d.mts +9 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/types/init-options.d.mts +1358 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/types/plugin-client.d.mts +113 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/types/plugin.d.mts +124 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/types/secret.d.mts +11 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/async.d.mts +22 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/async.mjs +32 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/db.d.mts +9 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/db.mjs +15 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/deprecate.d.mts +9 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/deprecate.mjs +16 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/error-codes.d.mts +13 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/error-codes.mjs +10 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/fetch-metadata.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/fetch-metadata.mjs +6 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/host.d.mts +147 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/host.mjs +291 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/id.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/id.mjs +7 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/ip.d.mts +54 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/ip.mjs +116 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/is-api-error.d.mts +6 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/is-api-error.mjs +8 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/json.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/json.mjs +41 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/string.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/string.mjs +6 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/url.d.mts +20 -0
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/url.mjs +31 -0
- package/template/apps/web/node_modules/@better-auth/core/package.json +193 -0
- package/template/apps/web/node_modules/@better-auth/core/src/api/index.ts +140 -0
- package/template/apps/web/node_modules/@better-auth/core/src/async_hooks/index.ts +40 -0
- package/template/apps/web/node_modules/@better-auth/core/src/async_hooks/pure.index.ts +46 -0
- package/template/apps/web/node_modules/@better-auth/core/src/context/endpoint-context.ts +50 -0
- package/template/apps/web/node_modules/@better-auth/core/src/context/global.ts +57 -0
- package/template/apps/web/node_modules/@better-auth/core/src/context/index.ts +23 -0
- package/template/apps/web/node_modules/@better-auth/core/src/context/request-state.ts +91 -0
- package/template/apps/web/node_modules/@better-auth/core/src/context/transaction.ts +136 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/factory.ts +1440 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-default-field-name.ts +59 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-default-model-name.ts +51 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-field-attributes.ts +62 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-field-name.ts +43 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-id-field.ts +150 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-model-name.ts +36 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/index.ts +567 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/types.ts +132 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/utils.ts +61 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/get-tables.ts +296 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/index.ts +43 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/plugin.ts +11 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/account.ts +47 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/rate-limit.ts +36 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/session.ts +29 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/shared.ts +7 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/user.ts +28 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/verification.ts +28 -0
- package/template/apps/web/node_modules/@better-auth/core/src/db/type.ts +333 -0
- package/template/apps/web/node_modules/@better-auth/core/src/env/color-depth.ts +172 -0
- package/template/apps/web/node_modules/@better-auth/core/src/env/env-impl.ts +124 -0
- package/template/apps/web/node_modules/@better-auth/core/src/env/index.ts +23 -0
- package/template/apps/web/node_modules/@better-auth/core/src/env/logger.ts +145 -0
- package/template/apps/web/node_modules/@better-auth/core/src/error/codes.ts +71 -0
- package/template/apps/web/node_modules/@better-auth/core/src/error/index.ts +35 -0
- package/template/apps/web/node_modules/@better-auth/core/src/index.ts +1 -0
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/api.ts +17 -0
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/attributes.ts +22 -0
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/index.ts +2 -0
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/noop.ts +74 -0
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/pure.index.ts +31 -0
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/tracer.ts +95 -0
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/client-credentials-token.ts +126 -0
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/create-authorization-url.ts +89 -0
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/index.ts +33 -0
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/oauth-provider.ts +222 -0
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/refresh-access-token.ts +157 -0
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/utils.ts +51 -0
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/validate-authorization-code.ts +180 -0
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/verify.ts +221 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/apple.ts +231 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/atlassian.ts +133 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/cognito.ts +281 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/discord.ts +170 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/dropbox.ts +112 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/facebook.ts +215 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/figma.ts +118 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/github.ts +184 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/gitlab.ts +155 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/google.ts +204 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/huggingface.ts +119 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/index.ts +132 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/kakao.ts +179 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/kick.ts +109 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/line.ts +169 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/linear.ts +121 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/linkedin.ts +110 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/microsoft-entra-id.ts +352 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/naver.ts +113 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/notion.ts +108 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/paybin.ts +118 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/paypal.ts +263 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/polar.ts +111 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/railway.ts +100 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/reddit.ts +122 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/roblox.ts +112 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/salesforce.ts +159 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/slack.ts +112 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/spotify.ts +94 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/tiktok.ts +211 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/twitch.ts +112 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/twitter.ts +199 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/vercel.ts +87 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/vk.ts +125 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/wechat.ts +213 -0
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/zoom.ts +230 -0
- package/template/apps/web/node_modules/@better-auth/core/src/types/context.ts +415 -0
- package/template/apps/web/node_modules/@better-auth/core/src/types/cookie.ts +10 -0
- package/template/apps/web/node_modules/@better-auth/core/src/types/helper.ts +27 -0
- package/template/apps/web/node_modules/@better-auth/core/src/types/index.ts +40 -0
- package/template/apps/web/node_modules/@better-auth/core/src/types/init-options.ts +1610 -0
- package/template/apps/web/node_modules/@better-auth/core/src/types/plugin-client.ts +129 -0
- package/template/apps/web/node_modules/@better-auth/core/src/types/plugin.ts +163 -0
- package/template/apps/web/node_modules/@better-auth/core/src/types/secret.ts +8 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/async.ts +53 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/db.ts +20 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/deprecate.ts +21 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/error-codes.ts +68 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/fetch-metadata.ts +3 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/host.ts +401 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/id.ts +5 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/ip.ts +211 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/is-api-error.ts +10 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/json.ts +56 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/string.ts +3 -0
- package/template/apps/web/node_modules/@better-auth/core/src/utils/url.ts +43 -0
- package/template/apps/web/node_modules/@better-auth/drizzle-adapter/LICENSE.md +20 -0
- package/template/apps/web/node_modules/@better-auth/drizzle-adapter/README.md +17 -0
- package/template/apps/web/node_modules/@better-auth/drizzle-adapter/dist/index.d.mts +47 -0
- package/template/apps/web/node_modules/@better-auth/drizzle-adapter/dist/index.mjs +458 -0
- package/template/apps/web/node_modules/@better-auth/drizzle-adapter/package.json +62 -0
- package/template/apps/web/node_modules/@better-auth/utils/README.md +384 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.cjs +104 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.cts +44 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.mts +44 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.ts +44 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.mjs +101 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.cjs +80 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.cts +16 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.mts +16 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.ts +16 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.mjs +77 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.cjs +16 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.cts +8 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.mts +8 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.ts +8 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.mjs +14 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.cjs +90 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.cts +19 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.mts +19 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.ts +19 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.mjs +88 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.cjs +31 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.cts +7 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.mts +7 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.ts +7 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.mjs +29 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.cjs +40 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.cts +8 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.mts +8 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.ts +8 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.mjs +38 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.cjs +58 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.cts +9 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.mts +9 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.ts +9 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.mjs +56 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.cjs +10 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.cts +3 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.mts +3 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.ts +3 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.mjs +8 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.cjs +90 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.cts +13 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.mts +13 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.ts +13 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.mjs +88 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.cjs +36 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.cts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.ts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.mjs +33 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.cjs +47 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.cts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.ts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.mjs +44 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.cjs +55 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.cts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.mts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.ts +4 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.mjs +53 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.cjs +76 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.cts +16 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.mts +16 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.ts +16 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.mjs +74 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.cts +22 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.mts +22 -0
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.ts +22 -0
- package/template/apps/web/node_modules/@better-auth/utils/package.json +95 -0
- package/template/apps/web/node_modules/better-call/LICENSE +21 -0
- package/template/apps/web/node_modules/better-call/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.cjs +181 -0
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.d.cts +16 -0
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.d.mts +16 -0
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.mjs +178 -0
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/client.cjs +23 -0
- package/template/apps/web/node_modules/better-call/dist/client.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/client.d.cts +53 -0
- package/template/apps/web/node_modules/better-call/dist/client.d.mts +53 -0
- package/template/apps/web/node_modules/better-call/dist/client.mjs +14 -0
- package/template/apps/web/node_modules/better-call/dist/client.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/context.cjs +103 -0
- package/template/apps/web/node_modules/better-call/dist/context.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/context.d.cts +341 -0
- package/template/apps/web/node_modules/better-call/dist/context.d.mts +341 -0
- package/template/apps/web/node_modules/better-call/dist/context.mjs +103 -0
- package/template/apps/web/node_modules/better-call/dist/context.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/cookies.cjs +87 -0
- package/template/apps/web/node_modules/better-call/dist/cookies.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/cookies.d.cts +103 -0
- package/template/apps/web/node_modules/better-call/dist/cookies.d.mts +103 -0
- package/template/apps/web/node_modules/better-call/dist/cookies.mjs +84 -0
- package/template/apps/web/node_modules/better-call/dist/cookies.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/crypto.cjs +39 -0
- package/template/apps/web/node_modules/better-call/dist/crypto.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/crypto.mjs +36 -0
- package/template/apps/web/node_modules/better-call/dist/crypto.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/endpoint.cjs +70 -0
- package/template/apps/web/node_modules/better-call/dist/endpoint.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/endpoint.d.cts +475 -0
- package/template/apps/web/node_modules/better-call/dist/endpoint.d.mts +475 -0
- package/template/apps/web/node_modules/better-call/dist/endpoint.mjs +70 -0
- package/template/apps/web/node_modules/better-call/dist/endpoint.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/error.cjs +141 -0
- package/template/apps/web/node_modules/better-call/dist/error.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/error.d.cts +103 -0
- package/template/apps/web/node_modules/better-call/dist/error.d.mts +103 -0
- package/template/apps/web/node_modules/better-call/dist/error.mjs +133 -0
- package/template/apps/web/node_modules/better-call/dist/error.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/helper.d.cts +12 -0
- package/template/apps/web/node_modules/better-call/dist/helper.d.mts +12 -0
- package/template/apps/web/node_modules/better-call/dist/index.cjs +28 -0
- package/template/apps/web/node_modules/better-call/dist/index.d.cts +11 -0
- package/template/apps/web/node_modules/better-call/dist/index.d.mts +11 -0
- package/template/apps/web/node_modules/better-call/dist/index.mjs +10 -0
- package/template/apps/web/node_modules/better-call/dist/middleware.cjs +52 -0
- package/template/apps/web/node_modules/better-call/dist/middleware.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/middleware.d.cts +123 -0
- package/template/apps/web/node_modules/better-call/dist/middleware.d.mts +123 -0
- package/template/apps/web/node_modules/better-call/dist/middleware.mjs +52 -0
- package/template/apps/web/node_modules/better-call/dist/middleware.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/node.cjs +18 -0
- package/template/apps/web/node_modules/better-call/dist/node.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/node.d.cts +9 -0
- package/template/apps/web/node_modules/better-call/dist/node.d.mts +9 -0
- package/template/apps/web/node_modules/better-call/dist/node.mjs +15 -0
- package/template/apps/web/node_modules/better-call/dist/node.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/openapi.cjs +191 -0
- package/template/apps/web/node_modules/better-call/dist/openapi.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/openapi.d.cts +113 -0
- package/template/apps/web/node_modules/better-call/dist/openapi.d.mts +113 -0
- package/template/apps/web/node_modules/better-call/dist/openapi.mjs +189 -0
- package/template/apps/web/node_modules/better-call/dist/openapi.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/router.cjs +118 -0
- package/template/apps/web/node_modules/better-call/dist/router.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/router.d.cts +103 -0
- package/template/apps/web/node_modules/better-call/dist/router.d.mts +103 -0
- package/template/apps/web/node_modules/better-call/dist/router.mjs +117 -0
- package/template/apps/web/node_modules/better-call/dist/router.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/standard-schema.d.cts +59 -0
- package/template/apps/web/node_modules/better-call/dist/standard-schema.d.mts +59 -0
- package/template/apps/web/node_modules/better-call/dist/to-response.cjs +153 -0
- package/template/apps/web/node_modules/better-call/dist/to-response.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/to-response.d.cts +12 -0
- package/template/apps/web/node_modules/better-call/dist/to-response.d.mts +12 -0
- package/template/apps/web/node_modules/better-call/dist/to-response.mjs +153 -0
- package/template/apps/web/node_modules/better-call/dist/to-response.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/utils.cjs +86 -0
- package/template/apps/web/node_modules/better-call/dist/utils.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/utils.mjs +82 -0
- package/template/apps/web/node_modules/better-call/dist/utils.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/validator.cjs +58 -0
- package/template/apps/web/node_modules/better-call/dist/validator.cjs.map +1 -0
- package/template/apps/web/node_modules/better-call/dist/validator.mjs +57 -0
- package/template/apps/web/node_modules/better-call/dist/validator.mjs.map +1 -0
- package/template/apps/web/node_modules/better-call/package.json +96 -0
- package/template/apps/web/node_modules/set-cookie-parser/LICENSE +21 -0
- package/template/apps/web/node_modules/set-cookie-parser/README.md +169 -0
- package/template/apps/web/node_modules/set-cookie-parser/dist/.eslintrc.cjs +16 -0
- package/template/apps/web/node_modules/set-cookie-parser/dist/set-cookie.cjs +260 -0
- package/template/apps/web/node_modules/set-cookie-parser/lib/set-cookie.d.ts +119 -0
- package/template/apps/web/node_modules/set-cookie-parser/lib/set-cookie.js +265 -0
- package/template/apps/web/node_modules/set-cookie-parser/package.json +61 -0
- package/template/apps/web/package.json +44 -0
- package/template/apps/web/public/favicon.ico +0 -0
- package/template/apps/web/public/manifest.json +25 -0
- package/template/apps/web/public/robots.txt +3 -0
- package/template/apps/web/src/components/app-sidebar.tsx +139 -0
- package/template/apps/web/src/components/login-form.tsx +111 -0
- package/template/apps/web/src/components/search-form.tsx +27 -0
- package/template/apps/web/src/components/signup-form.tsx +137 -0
- package/template/apps/web/src/components/version-switcher.tsx +64 -0
- package/template/apps/web/src/hooks/use-mobile.ts +19 -0
- package/template/apps/web/src/lib/auth-client.ts +3 -0
- package/template/apps/web/src/lib/auth-utils.ts +15 -0
- package/template/apps/web/src/lib/orpc.ts +32 -0
- package/template/apps/web/src/routeTree.gen.ts +282 -0
- package/template/apps/web/src/router.tsx +20 -0
- package/template/apps/web/src/routes/__root.tsx +53 -0
- package/template/apps/web/src/routes/api/auth/$.ts +15 -0
- package/template/apps/web/src/routes/api/rpc.$.ts +34 -0
- package/template/apps/web/src/routes/client-orpc-auth.tsx +62 -0
- package/template/apps/web/src/routes/client-orpc.tsx +43 -0
- package/template/apps/web/src/routes/dashboard.tsx +59 -0
- package/template/apps/web/src/routes/index.tsx +57 -0
- package/template/apps/web/src/routes/isr.tsx +33 -0
- package/template/apps/web/src/routes/login.tsx +16 -0
- package/template/apps/web/src/routes/signup.tsx +16 -0
- package/template/apps/web/src/routes/ssr-orpc-auth.tsx +53 -0
- package/template/apps/web/src/routes/ssr-orpc.tsx +36 -0
- package/template/apps/web/tsconfig.json +29 -0
- package/template/apps/web/vite.config.ts +19 -0
- package/template/docker-compose.yml +16 -0
- package/template/package.json +35 -0
- package/template/packages/auth/eslint.config.ts +3 -0
- package/template/packages/auth/package.json +24 -0
- package/template/packages/auth/src/lib/auth.ts +13 -0
- package/template/packages/auth/tsconfig.json +17 -0
- package/template/packages/auth/tsconfig.lint.json +14 -0
- package/template/packages/db/eslint.config.ts +3 -0
- package/template/packages/db/package.json +27 -0
- package/template/packages/db/src/auth-schema.ts +93 -0
- package/template/packages/db/src/index.ts +7 -0
- package/template/packages/db/src/planets-schema.ts +13 -0
- package/template/packages/db/src/schema.ts +2 -0
- package/template/packages/db/tsconfig.json +17 -0
- package/template/packages/db/tsconfig.lint.json +14 -0
- package/template/packages/orpc/eslint.config.ts +3 -0
- package/template/packages/orpc/package.json +21 -0
- package/template/packages/orpc/src/lib/router.ts +52 -0
- package/template/packages/orpc/tsconfig.json +17 -0
- package/template/packages/orpc/tsconfig.lint.json +14 -0
- package/template/packages/ui/components.json +23 -0
- package/template/packages/ui/eslint.config.ts +3 -0
- package/template/packages/ui/package.json +48 -0
- package/template/packages/ui/src/components/.gitkeep +0 -0
- package/template/packages/ui/src/components/accordion.tsx +72 -0
- package/template/packages/ui/src/components/alert-dialog.tsx +187 -0
- package/template/packages/ui/src/components/alert.tsx +77 -0
- package/template/packages/ui/src/components/aspect-ratio.tsx +22 -0
- package/template/packages/ui/src/components/avatar.tsx +107 -0
- package/template/packages/ui/src/components/badge.tsx +53 -0
- package/template/packages/ui/src/components/breadcrumb.tsx +125 -0
- package/template/packages/ui/src/components/button-group.tsx +88 -0
- package/template/packages/ui/src/components/button.tsx +59 -0
- package/template/packages/ui/src/components/calendar.tsx +229 -0
- package/template/packages/ui/src/components/card.tsx +103 -0
- package/template/packages/ui/src/components/carousel.tsx +240 -0
- package/template/packages/ui/src/components/chart.tsx +371 -0
- package/template/packages/ui/src/components/checkbox.tsx +29 -0
- package/template/packages/ui/src/components/collapsible.tsx +19 -0
- package/template/packages/ui/src/components/combobox.tsx +295 -0
- package/template/packages/ui/src/components/command.tsx +196 -0
- package/template/packages/ui/src/components/context-menu.tsx +271 -0
- package/template/packages/ui/src/components/dialog.tsx +158 -0
- package/template/packages/ui/src/components/direction.tsx +4 -0
- package/template/packages/ui/src/components/drawer.tsx +134 -0
- package/template/packages/ui/src/components/dropdown-menu.tsx +266 -0
- package/template/packages/ui/src/components/empty.tsx +105 -0
- package/template/packages/ui/src/components/field.tsx +237 -0
- package/template/packages/ui/src/components/hover-card.tsx +51 -0
- package/template/packages/ui/src/components/input-group.tsx +159 -0
- package/template/packages/ui/src/components/input-otp.tsx +85 -0
- package/template/packages/ui/src/components/input.tsx +20 -0
- package/template/packages/ui/src/components/item.tsx +202 -0
- package/template/packages/ui/src/components/kbd.tsx +26 -0
- package/template/packages/ui/src/components/label.tsx +20 -0
- package/template/packages/ui/src/components/menubar.tsx +280 -0
- package/template/packages/ui/src/components/native-select.tsx +61 -0
- package/template/packages/ui/src/components/navigation-menu.tsx +168 -0
- package/template/packages/ui/src/components/pagination.tsx +130 -0
- package/template/packages/ui/src/components/popover.tsx +88 -0
- package/template/packages/ui/src/components/progress.tsx +83 -0
- package/template/packages/ui/src/components/radio-group.tsx +36 -0
- package/template/packages/ui/src/components/resizable.tsx +50 -0
- package/template/packages/ui/src/components/scroll-area.tsx +53 -0
- package/template/packages/ui/src/components/select.tsx +201 -0
- package/template/packages/ui/src/components/separator.tsx +23 -0
- package/template/packages/ui/src/components/sheet.tsx +138 -0
- package/template/packages/ui/src/components/sidebar.tsx +726 -0
- package/template/packages/ui/src/components/skeleton.tsx +13 -0
- package/template/packages/ui/src/components/slider.tsx +52 -0
- package/template/packages/ui/src/components/sonner.tsx +50 -0
- package/template/packages/ui/src/components/spinner.tsx +10 -0
- package/template/packages/ui/src/components/switch.tsx +30 -0
- package/template/packages/ui/src/components/table.tsx +116 -0
- package/template/packages/ui/src/components/tabs.tsx +81 -0
- package/template/packages/ui/src/components/textarea.tsx +18 -0
- package/template/packages/ui/src/components/toggle-group.tsx +87 -0
- package/template/packages/ui/src/components/toggle.tsx +46 -0
- package/template/packages/ui/src/components/tooltip.tsx +64 -0
- package/template/packages/ui/src/hooks/.gitkeep +0 -0
- package/template/packages/ui/src/hooks/use-mobile.ts +19 -0
- package/template/packages/ui/src/lib/.gitkeep +0 -0
- package/template/packages/ui/src/lib/utils.ts +7 -0
- package/template/packages/ui/src/styles/globals.css +130 -0
- package/template/packages/ui/tsconfig.json +17 -0
- package/template/packages/ui/tsconfig.lint.json +14 -0
- package/template/tsconfig.json +9 -0
- package/template/turbo.json +24 -0
|
@@ -0,0 +1,1440 @@
|
|
|
1
|
+
import { createLogger, getColorDepth, TTY_COLORS } from "../../env";
|
|
2
|
+
import { BetterAuthError } from "../../error";
|
|
3
|
+
import {
|
|
4
|
+
ATTR_DB_COLLECTION_NAME,
|
|
5
|
+
ATTR_DB_OPERATION_NAME,
|
|
6
|
+
withSpan,
|
|
7
|
+
} from "../../instrumentation";
|
|
8
|
+
import type { BetterAuthOptions } from "../../types";
|
|
9
|
+
import { safeJSONParse } from "../../utils/json";
|
|
10
|
+
import { getAuthTables } from "../get-tables";
|
|
11
|
+
import { initGetDefaultFieldName } from "./get-default-field-name";
|
|
12
|
+
import { initGetDefaultModelName } from "./get-default-model-name";
|
|
13
|
+
import { initGetFieldAttributes } from "./get-field-attributes";
|
|
14
|
+
import { initGetFieldName } from "./get-field-name";
|
|
15
|
+
import { initGetIdField } from "./get-id-field";
|
|
16
|
+
import { initGetModelName } from "./get-model-name";
|
|
17
|
+
import type {
|
|
18
|
+
CleanedWhere,
|
|
19
|
+
DBAdapter,
|
|
20
|
+
DBTransactionAdapter,
|
|
21
|
+
JoinConfig,
|
|
22
|
+
JoinOption,
|
|
23
|
+
Where,
|
|
24
|
+
} from "./index";
|
|
25
|
+
import type {
|
|
26
|
+
AdapterFactoryConfig,
|
|
27
|
+
AdapterFactoryOptions,
|
|
28
|
+
AdapterTestDebugLogs,
|
|
29
|
+
} from "./types";
|
|
30
|
+
import { withApplyDefault } from "./utils";
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
initGetDefaultModelName,
|
|
34
|
+
initGetDefaultFieldName,
|
|
35
|
+
initGetModelName,
|
|
36
|
+
initGetFieldName,
|
|
37
|
+
initGetFieldAttributes,
|
|
38
|
+
initGetIdField,
|
|
39
|
+
};
|
|
40
|
+
export * from "./types";
|
|
41
|
+
|
|
42
|
+
let debugLogs: { instance: string; args: any[] }[] = [];
|
|
43
|
+
let transactionId = -1;
|
|
44
|
+
|
|
45
|
+
const createAsIsTransaction =
|
|
46
|
+
<Options extends BetterAuthOptions>(adapter: DBAdapter<Options>) =>
|
|
47
|
+
<R>(fn: (trx: DBTransactionAdapter<Options>) => Promise<R>) =>
|
|
48
|
+
fn(adapter);
|
|
49
|
+
|
|
50
|
+
export type AdapterFactory<Options extends BetterAuthOptions> = (
|
|
51
|
+
options: Options,
|
|
52
|
+
) => DBAdapter<Options>;
|
|
53
|
+
|
|
54
|
+
export const createAdapterFactory =
|
|
55
|
+
<Options extends BetterAuthOptions>({
|
|
56
|
+
adapter: customAdapter,
|
|
57
|
+
config: cfg,
|
|
58
|
+
}: AdapterFactoryOptions): AdapterFactory<Options> =>
|
|
59
|
+
(options: Options): DBAdapter<Options> => {
|
|
60
|
+
const uniqueAdapterFactoryInstanceId = Math.random()
|
|
61
|
+
.toString(36)
|
|
62
|
+
.substring(2, 15);
|
|
63
|
+
|
|
64
|
+
const config = {
|
|
65
|
+
...cfg,
|
|
66
|
+
supportsBooleans: cfg.supportsBooleans ?? true,
|
|
67
|
+
supportsDates: cfg.supportsDates ?? true,
|
|
68
|
+
supportsJSON: cfg.supportsJSON ?? false,
|
|
69
|
+
adapterName: cfg.adapterName ?? cfg.adapterId,
|
|
70
|
+
supportsNumericIds: cfg.supportsNumericIds ?? true,
|
|
71
|
+
supportsUUIDs: cfg.supportsUUIDs ?? false,
|
|
72
|
+
supportsArrays: cfg.supportsArrays ?? false,
|
|
73
|
+
transaction: cfg.transaction ?? false,
|
|
74
|
+
disableTransformInput: cfg.disableTransformInput ?? false,
|
|
75
|
+
disableTransformOutput: cfg.disableTransformOutput ?? false,
|
|
76
|
+
disableTransformJoin: cfg.disableTransformJoin ?? false,
|
|
77
|
+
} satisfies AdapterFactoryConfig;
|
|
78
|
+
|
|
79
|
+
const useNumberId = options.advanced?.database?.generateId === "serial";
|
|
80
|
+
if (useNumberId && config.supportsNumericIds === false) {
|
|
81
|
+
throw new BetterAuthError(
|
|
82
|
+
`[${config.adapterName}] Your database or database adapter does not support numeric ids. Please disable "useNumberId" in your config.`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// End-user's Better-Auth instance's schema
|
|
87
|
+
const schema = getAuthTables(options);
|
|
88
|
+
|
|
89
|
+
const debugLog = (...args: any[]) => {
|
|
90
|
+
if (config.debugLogs === true || typeof config.debugLogs === "object") {
|
|
91
|
+
const logger = createLogger({ level: "info" });
|
|
92
|
+
// If we're running adapter tests, we'll keep debug logs in memory, then print them out if a test fails.
|
|
93
|
+
if (
|
|
94
|
+
typeof config.debugLogs === "object" &&
|
|
95
|
+
"isRunningAdapterTests" in config.debugLogs
|
|
96
|
+
) {
|
|
97
|
+
if (config.debugLogs.isRunningAdapterTests) {
|
|
98
|
+
args.shift(); // Removes the {method: "..."} object from the args array.
|
|
99
|
+
debugLogs.push({ instance: uniqueAdapterFactoryInstanceId, args });
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
typeof config.debugLogs === "object" &&
|
|
106
|
+
config.debugLogs.logCondition &&
|
|
107
|
+
!config.debugLogs.logCondition?.()
|
|
108
|
+
) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (typeof args[0] === "object" && "method" in args[0]) {
|
|
113
|
+
const method = args.shift().method;
|
|
114
|
+
// Make sure the method is enabled in the config.
|
|
115
|
+
if (typeof config.debugLogs === "object") {
|
|
116
|
+
if (method === "create" && !config.debugLogs.create) {
|
|
117
|
+
return;
|
|
118
|
+
} else if (method === "update" && !config.debugLogs.update) {
|
|
119
|
+
return;
|
|
120
|
+
} else if (
|
|
121
|
+
method === "updateMany" &&
|
|
122
|
+
!config.debugLogs.updateMany
|
|
123
|
+
) {
|
|
124
|
+
return;
|
|
125
|
+
} else if (method === "findOne" && !config.debugLogs.findOne) {
|
|
126
|
+
return;
|
|
127
|
+
} else if (method === "findMany" && !config.debugLogs.findMany) {
|
|
128
|
+
return;
|
|
129
|
+
} else if (method === "delete" && !config.debugLogs.delete) {
|
|
130
|
+
return;
|
|
131
|
+
} else if (
|
|
132
|
+
method === "deleteMany" &&
|
|
133
|
+
!config.debugLogs.deleteMany
|
|
134
|
+
) {
|
|
135
|
+
return;
|
|
136
|
+
} else if (method === "count" && !config.debugLogs.count) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
logger.info(`[${config.adapterName}]`, ...args);
|
|
141
|
+
} else {
|
|
142
|
+
logger.info(`[${config.adapterName}]`, ...args);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const logger = createLogger(options.logger);
|
|
148
|
+
|
|
149
|
+
const getDefaultModelName = initGetDefaultModelName({
|
|
150
|
+
usePlural: config.usePlural,
|
|
151
|
+
schema,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const getDefaultFieldName = initGetDefaultFieldName({
|
|
155
|
+
usePlural: config.usePlural,
|
|
156
|
+
schema,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const getModelName = initGetModelName({
|
|
160
|
+
usePlural: config.usePlural,
|
|
161
|
+
schema,
|
|
162
|
+
});
|
|
163
|
+
const getFieldName = initGetFieldName({
|
|
164
|
+
schema,
|
|
165
|
+
usePlural: config.usePlural,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const idField = initGetIdField({
|
|
169
|
+
schema,
|
|
170
|
+
options,
|
|
171
|
+
usePlural: config.usePlural,
|
|
172
|
+
disableIdGeneration: config.disableIdGeneration,
|
|
173
|
+
customIdGenerator: config.customIdGenerator,
|
|
174
|
+
supportsUUIDs: config.supportsUUIDs,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const getFieldAttributes = initGetFieldAttributes({
|
|
178
|
+
schema,
|
|
179
|
+
options,
|
|
180
|
+
usePlural: config.usePlural,
|
|
181
|
+
disableIdGeneration: config.disableIdGeneration,
|
|
182
|
+
customIdGenerator: config.customIdGenerator,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const transformInput = async (
|
|
186
|
+
data: Record<string, any>,
|
|
187
|
+
defaultModelName: string,
|
|
188
|
+
action: "create" | "update" | "findOne" | "findMany",
|
|
189
|
+
forceAllowId?: boolean,
|
|
190
|
+
) => {
|
|
191
|
+
const transformedData: Record<string, any> = {};
|
|
192
|
+
const fields = schema[defaultModelName]!.fields;
|
|
193
|
+
|
|
194
|
+
const newMappedKeys = config.mapKeysTransformInput ?? {};
|
|
195
|
+
const useNumberId = options.advanced?.database?.generateId === "serial";
|
|
196
|
+
fields.id = idField({
|
|
197
|
+
customModelName: defaultModelName,
|
|
198
|
+
forceAllowId: forceAllowId && "id" in data,
|
|
199
|
+
});
|
|
200
|
+
for (const field in fields) {
|
|
201
|
+
let value = data[field];
|
|
202
|
+
const fieldAttributes = fields[field];
|
|
203
|
+
|
|
204
|
+
const newFieldName: string =
|
|
205
|
+
newMappedKeys[field] || fields[field]!.fieldName || field;
|
|
206
|
+
if (
|
|
207
|
+
value === undefined &&
|
|
208
|
+
((fieldAttributes!.defaultValue === undefined &&
|
|
209
|
+
!fieldAttributes!.transform?.input &&
|
|
210
|
+
!(action === "update" && fieldAttributes!.onUpdate)) ||
|
|
211
|
+
(action === "update" && !fieldAttributes!.onUpdate))
|
|
212
|
+
) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// In some endpoints (like signUpEmail) where there isn't proper Zod validation,
|
|
217
|
+
// we might receive a date as a string (this is because of the client converting the Date to a string
|
|
218
|
+
// when sending to the server). Because of this, we'll convert the string to a Date.
|
|
219
|
+
if (
|
|
220
|
+
fieldAttributes &&
|
|
221
|
+
fieldAttributes.type === "date" &&
|
|
222
|
+
!(value instanceof Date) &&
|
|
223
|
+
typeof value === "string"
|
|
224
|
+
) {
|
|
225
|
+
try {
|
|
226
|
+
value = new Date(value);
|
|
227
|
+
} catch {
|
|
228
|
+
logger.error("[Adapter Factory] Failed to convert string to date", {
|
|
229
|
+
value,
|
|
230
|
+
field,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// If the value is undefined, but the fieldAttr provides a `defaultValue`, then we'll use that.
|
|
236
|
+
let newValue = withApplyDefault(value, fieldAttributes!, action);
|
|
237
|
+
|
|
238
|
+
// If the field attr provides a custom transform input, then we'll let it handle the value transformation.
|
|
239
|
+
// Afterwards, we'll continue to apply the default transformations just to make sure it saves in the correct format.
|
|
240
|
+
if (fieldAttributes!.transform?.input) {
|
|
241
|
+
newValue = await fieldAttributes!.transform.input(newValue);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (fieldAttributes!.references?.field === "id" && useNumberId) {
|
|
245
|
+
if (Array.isArray(newValue)) {
|
|
246
|
+
newValue = newValue.map((x) => (x !== null ? Number(x) : null));
|
|
247
|
+
} else {
|
|
248
|
+
newValue = newValue !== null ? Number(newValue) : null;
|
|
249
|
+
}
|
|
250
|
+
} else if (
|
|
251
|
+
config.supportsJSON === false &&
|
|
252
|
+
typeof newValue === "object" &&
|
|
253
|
+
fieldAttributes!.type === "json"
|
|
254
|
+
) {
|
|
255
|
+
newValue = JSON.stringify(newValue);
|
|
256
|
+
} else if (
|
|
257
|
+
config.supportsArrays === false &&
|
|
258
|
+
Array.isArray(newValue) &&
|
|
259
|
+
(fieldAttributes!.type === "string[]" ||
|
|
260
|
+
fieldAttributes!.type === "number[]")
|
|
261
|
+
) {
|
|
262
|
+
newValue = JSON.stringify(newValue);
|
|
263
|
+
} else if (
|
|
264
|
+
config.supportsDates === false &&
|
|
265
|
+
newValue instanceof Date &&
|
|
266
|
+
fieldAttributes!.type === "date"
|
|
267
|
+
) {
|
|
268
|
+
newValue = newValue.toISOString();
|
|
269
|
+
} else if (
|
|
270
|
+
config.supportsBooleans === false &&
|
|
271
|
+
typeof newValue === "boolean"
|
|
272
|
+
) {
|
|
273
|
+
newValue = newValue ? 1 : 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (config.customTransformInput) {
|
|
277
|
+
newValue = config.customTransformInput({
|
|
278
|
+
data: newValue,
|
|
279
|
+
action,
|
|
280
|
+
field: newFieldName,
|
|
281
|
+
fieldAttributes: fieldAttributes!,
|
|
282
|
+
model: getModelName(defaultModelName),
|
|
283
|
+
schema,
|
|
284
|
+
options,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (newValue !== undefined) {
|
|
289
|
+
transformedData[newFieldName] = newValue;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return transformedData;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const transformOutput = async (
|
|
296
|
+
data: Record<string, any> | null,
|
|
297
|
+
unsafe_model: string,
|
|
298
|
+
select: string[] = [],
|
|
299
|
+
join: JoinConfig | undefined,
|
|
300
|
+
) => {
|
|
301
|
+
const transformSingleOutput = async (
|
|
302
|
+
data: Record<string, any> | null,
|
|
303
|
+
unsafe_model: string,
|
|
304
|
+
select: string[] = [],
|
|
305
|
+
) => {
|
|
306
|
+
if (!data) return null;
|
|
307
|
+
const newMappedKeys = config.mapKeysTransformOutput ?? {};
|
|
308
|
+
const transformedData: Record<string, any> = {};
|
|
309
|
+
const tableSchema = schema[getDefaultModelName(unsafe_model)]!.fields;
|
|
310
|
+
const idKey = Object.entries(newMappedKeys).find(
|
|
311
|
+
([_, v]) => v === "id",
|
|
312
|
+
)?.[0];
|
|
313
|
+
const useNumberId = options.advanced?.database?.generateId === "serial";
|
|
314
|
+
tableSchema[idKey ?? "id"] = {
|
|
315
|
+
type: useNumberId ? "number" : "string",
|
|
316
|
+
};
|
|
317
|
+
for (const key in tableSchema) {
|
|
318
|
+
if (select.length && !select.includes(key)) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const field = tableSchema[key];
|
|
322
|
+
if (field) {
|
|
323
|
+
const originalKey = field.fieldName || key;
|
|
324
|
+
|
|
325
|
+
// If the field is mapped, we'll use the mapped key. Otherwise, we'll use the original key.
|
|
326
|
+
let newValue =
|
|
327
|
+
data[
|
|
328
|
+
Object.entries(newMappedKeys).find(
|
|
329
|
+
([_, v]) => v === originalKey,
|
|
330
|
+
)?.[0] || originalKey
|
|
331
|
+
];
|
|
332
|
+
|
|
333
|
+
if (field.transform?.output) {
|
|
334
|
+
newValue = await field.transform.output(newValue);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const newFieldName: string = newMappedKeys[key] || key;
|
|
338
|
+
|
|
339
|
+
if (originalKey === "id" || field.references?.field === "id") {
|
|
340
|
+
// Even if `useNumberId` is true, we must always return a string `id` output.
|
|
341
|
+
if (typeof newValue !== "undefined" && newValue !== null)
|
|
342
|
+
newValue = String(newValue);
|
|
343
|
+
} else if (
|
|
344
|
+
config.supportsJSON === false &&
|
|
345
|
+
typeof newValue === "string" &&
|
|
346
|
+
field.type === "json"
|
|
347
|
+
) {
|
|
348
|
+
newValue = safeJSONParse(newValue);
|
|
349
|
+
} else if (
|
|
350
|
+
config.supportsArrays === false &&
|
|
351
|
+
typeof newValue === "string" &&
|
|
352
|
+
(field.type === "string[]" || field.type === "number[]")
|
|
353
|
+
) {
|
|
354
|
+
newValue = safeJSONParse(newValue);
|
|
355
|
+
} else if (
|
|
356
|
+
config.supportsDates === false &&
|
|
357
|
+
typeof newValue === "string" &&
|
|
358
|
+
field.type === "date"
|
|
359
|
+
) {
|
|
360
|
+
newValue = new Date(newValue);
|
|
361
|
+
} else if (
|
|
362
|
+
config.supportsBooleans === false &&
|
|
363
|
+
typeof newValue === "number" &&
|
|
364
|
+
field.type === "boolean"
|
|
365
|
+
) {
|
|
366
|
+
newValue = newValue === 1;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (config.customTransformOutput) {
|
|
370
|
+
newValue = config.customTransformOutput({
|
|
371
|
+
data: newValue,
|
|
372
|
+
field: newFieldName,
|
|
373
|
+
fieldAttributes: field,
|
|
374
|
+
select,
|
|
375
|
+
model: getModelName(unsafe_model),
|
|
376
|
+
schema,
|
|
377
|
+
options,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
transformedData[newFieldName] = newValue;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return transformedData as any;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
if (!join || Object.keys(join).length === 0) {
|
|
388
|
+
return await transformSingleOutput(data, unsafe_model, select);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
unsafe_model = getDefaultModelName(unsafe_model);
|
|
392
|
+
// for now we just transform the base model
|
|
393
|
+
// later we append the joined models to this object.
|
|
394
|
+
const transformedData: Record<string, any> = await transformSingleOutput(
|
|
395
|
+
data,
|
|
396
|
+
unsafe_model,
|
|
397
|
+
select,
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
// Get all the models that are required to be joined.
|
|
401
|
+
const requiredModels = Object.entries(join).map(
|
|
402
|
+
([model, joinConfig]) => ({
|
|
403
|
+
modelName: getModelName(model),
|
|
404
|
+
defaultModelName: getDefaultModelName(model),
|
|
405
|
+
joinConfig,
|
|
406
|
+
}),
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
if (!data) return null;
|
|
410
|
+
// Data is now the base model object directly (not wrapped under a key)
|
|
411
|
+
|
|
412
|
+
for (const {
|
|
413
|
+
modelName,
|
|
414
|
+
defaultModelName,
|
|
415
|
+
joinConfig,
|
|
416
|
+
} of requiredModels) {
|
|
417
|
+
let joinedData = await (async () => {
|
|
418
|
+
if (options.experimental?.joins) {
|
|
419
|
+
const result = data[modelName];
|
|
420
|
+
return result;
|
|
421
|
+
} else {
|
|
422
|
+
// doesn't support joins, so fallback to handleFallbackJoin
|
|
423
|
+
const result = await handleFallbackJoin({
|
|
424
|
+
baseModel: unsafe_model,
|
|
425
|
+
baseData: transformedData,
|
|
426
|
+
joinModel: modelName,
|
|
427
|
+
specificJoinConfig: joinConfig,
|
|
428
|
+
});
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
})();
|
|
432
|
+
|
|
433
|
+
// If joinedData is undefined, initialize it based on relationship type
|
|
434
|
+
if (joinedData === undefined || joinedData === null) {
|
|
435
|
+
joinedData = joinConfig.relation === "one-to-one" ? null : [];
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (
|
|
439
|
+
joinConfig.relation === "one-to-many" &&
|
|
440
|
+
!Array.isArray(joinedData)
|
|
441
|
+
) {
|
|
442
|
+
joinedData = [joinedData];
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const transformed = [];
|
|
446
|
+
|
|
447
|
+
if (Array.isArray(joinedData)) {
|
|
448
|
+
for (const item of joinedData) {
|
|
449
|
+
const transformedItem = await transformSingleOutput(
|
|
450
|
+
item,
|
|
451
|
+
modelName,
|
|
452
|
+
[],
|
|
453
|
+
);
|
|
454
|
+
transformed.push(transformedItem);
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
const transformedItem = await transformSingleOutput(
|
|
458
|
+
joinedData,
|
|
459
|
+
modelName,
|
|
460
|
+
[],
|
|
461
|
+
);
|
|
462
|
+
transformed.push(transformedItem);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const result =
|
|
466
|
+
joinConfig.relation === "one-to-one" ? transformed[0] : transformed;
|
|
467
|
+
transformedData[defaultModelName] = result ?? null;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return transformedData as any;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
const transformWhereClause = <W extends Where[] | undefined>({
|
|
474
|
+
model,
|
|
475
|
+
where,
|
|
476
|
+
action,
|
|
477
|
+
}: {
|
|
478
|
+
where: W;
|
|
479
|
+
model: string;
|
|
480
|
+
action:
|
|
481
|
+
| "create"
|
|
482
|
+
| "update"
|
|
483
|
+
| "findOne"
|
|
484
|
+
| "findMany"
|
|
485
|
+
| "updateMany"
|
|
486
|
+
| "delete"
|
|
487
|
+
| "deleteMany"
|
|
488
|
+
| "count";
|
|
489
|
+
}): W extends undefined ? undefined : CleanedWhere[] => {
|
|
490
|
+
if (!where) return undefined as any;
|
|
491
|
+
const newMappedKeys = config.mapKeysTransformInput ?? {};
|
|
492
|
+
|
|
493
|
+
return where.map((w) => {
|
|
494
|
+
const {
|
|
495
|
+
field: unsafe_field,
|
|
496
|
+
value,
|
|
497
|
+
operator = "eq",
|
|
498
|
+
connector = "AND",
|
|
499
|
+
mode = "sensitive",
|
|
500
|
+
} = w;
|
|
501
|
+
if (operator === "in") {
|
|
502
|
+
if (!Array.isArray(value)) {
|
|
503
|
+
throw new BetterAuthError("Value must be an array");
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
let newValue = value;
|
|
508
|
+
|
|
509
|
+
const defaultModelName = getDefaultModelName(model);
|
|
510
|
+
const defaultFieldName = getDefaultFieldName({
|
|
511
|
+
field: unsafe_field,
|
|
512
|
+
model,
|
|
513
|
+
});
|
|
514
|
+
const fieldName: string =
|
|
515
|
+
newMappedKeys[defaultFieldName] ||
|
|
516
|
+
getFieldName({
|
|
517
|
+
field: defaultFieldName,
|
|
518
|
+
model: defaultModelName,
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
const fieldAttr = getFieldAttributes({
|
|
522
|
+
field: defaultFieldName,
|
|
523
|
+
model: defaultModelName,
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const useNumberId = options.advanced?.database?.generateId === "serial";
|
|
527
|
+
|
|
528
|
+
if (
|
|
529
|
+
defaultFieldName === "id" ||
|
|
530
|
+
fieldAttr!.references?.field === "id"
|
|
531
|
+
) {
|
|
532
|
+
if (useNumberId) {
|
|
533
|
+
if (Array.isArray(value)) {
|
|
534
|
+
newValue = value.map(Number);
|
|
535
|
+
} else {
|
|
536
|
+
newValue = Number(value);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (
|
|
542
|
+
fieldAttr.type === "date" &&
|
|
543
|
+
value instanceof Date &&
|
|
544
|
+
!config.supportsDates
|
|
545
|
+
) {
|
|
546
|
+
newValue = value.toISOString();
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (fieldAttr.type === "boolean" && typeof newValue === "string") {
|
|
550
|
+
newValue = newValue === "true";
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (fieldAttr.type === "number") {
|
|
554
|
+
if (typeof newValue === "string" && newValue.trim() !== "") {
|
|
555
|
+
const parsed = Number(newValue);
|
|
556
|
+
if (!Number.isNaN(parsed)) {
|
|
557
|
+
newValue = parsed;
|
|
558
|
+
}
|
|
559
|
+
} else if (Array.isArray(newValue)) {
|
|
560
|
+
const parsed = newValue.map((v) =>
|
|
561
|
+
typeof v === "string" && v.trim() !== "" ? Number(v) : NaN,
|
|
562
|
+
);
|
|
563
|
+
if (parsed.every((n) => !Number.isNaN(n))) {
|
|
564
|
+
newValue = parsed;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (
|
|
570
|
+
fieldAttr.type === "boolean" &&
|
|
571
|
+
typeof newValue === "boolean" &&
|
|
572
|
+
!config.supportsBooleans
|
|
573
|
+
) {
|
|
574
|
+
newValue = newValue ? 1 : 0;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (
|
|
578
|
+
fieldAttr.type === "json" &&
|
|
579
|
+
typeof value === "object" &&
|
|
580
|
+
!config.supportsJSON
|
|
581
|
+
) {
|
|
582
|
+
try {
|
|
583
|
+
const stringifiedJSON = JSON.stringify(value);
|
|
584
|
+
newValue = stringifiedJSON;
|
|
585
|
+
} catch (error) {
|
|
586
|
+
throw new Error(
|
|
587
|
+
`Failed to stringify JSON value for field ${fieldName}`,
|
|
588
|
+
{ cause: error },
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (config.customTransformInput) {
|
|
594
|
+
newValue = config.customTransformInput({
|
|
595
|
+
data: newValue,
|
|
596
|
+
fieldAttributes: fieldAttr,
|
|
597
|
+
field: fieldName,
|
|
598
|
+
model: getModelName(model),
|
|
599
|
+
schema,
|
|
600
|
+
options,
|
|
601
|
+
action,
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return {
|
|
606
|
+
operator,
|
|
607
|
+
connector,
|
|
608
|
+
field: fieldName,
|
|
609
|
+
value: newValue,
|
|
610
|
+
mode,
|
|
611
|
+
} satisfies CleanedWhere;
|
|
612
|
+
}) as any;
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
const transformJoinClause = (
|
|
616
|
+
baseModel: string,
|
|
617
|
+
unsanitizedJoin: JoinOption | undefined,
|
|
618
|
+
select: string[] | undefined,
|
|
619
|
+
): { join: JoinConfig; select: string[] | undefined } | undefined => {
|
|
620
|
+
if (!unsanitizedJoin) return undefined;
|
|
621
|
+
if (Object.keys(unsanitizedJoin).length === 0) return undefined;
|
|
622
|
+
const transformedJoin: JoinConfig = {};
|
|
623
|
+
for (const [model, join] of Object.entries(unsanitizedJoin)) {
|
|
624
|
+
if (!join) continue;
|
|
625
|
+
const defaultModelName = getDefaultModelName(model);
|
|
626
|
+
const defaultBaseModelName = getDefaultModelName(baseModel);
|
|
627
|
+
|
|
628
|
+
// First, check if the joined model has FKs to the base model (forward join)
|
|
629
|
+
let foreignKeys = Object.entries(
|
|
630
|
+
schema[defaultModelName]!.fields,
|
|
631
|
+
).filter(
|
|
632
|
+
([field, fieldAttributes]) =>
|
|
633
|
+
fieldAttributes.references &&
|
|
634
|
+
getDefaultModelName(fieldAttributes.references.model) ===
|
|
635
|
+
defaultBaseModelName,
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
let isForwardJoin = true;
|
|
639
|
+
|
|
640
|
+
// If no forward join found, check backwards: does the base model have FKs to the joined model?
|
|
641
|
+
if (!foreignKeys.length) {
|
|
642
|
+
foreignKeys = Object.entries(
|
|
643
|
+
schema[defaultBaseModelName]!.fields,
|
|
644
|
+
).filter(
|
|
645
|
+
([field, fieldAttributes]) =>
|
|
646
|
+
fieldAttributes.references &&
|
|
647
|
+
getDefaultModelName(fieldAttributes.references.model) ===
|
|
648
|
+
defaultModelName,
|
|
649
|
+
);
|
|
650
|
+
isForwardJoin = false;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (!foreignKeys.length) {
|
|
654
|
+
throw new BetterAuthError(
|
|
655
|
+
`No foreign key found for model ${model} and base model ${baseModel} while performing join operation.`,
|
|
656
|
+
);
|
|
657
|
+
} else if (foreignKeys.length > 1) {
|
|
658
|
+
throw new BetterAuthError(
|
|
659
|
+
`Multiple foreign keys found for model ${model} and base model ${baseModel} while performing join operation. Only one foreign key is supported.`,
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
const [foreignKey, foreignKeyAttributes] = foreignKeys[0]!;
|
|
664
|
+
if (!foreignKeyAttributes.references) {
|
|
665
|
+
// this should never happen, as we filter for references in the foreign keys.
|
|
666
|
+
// it's here for typescript to be happy.
|
|
667
|
+
throw new BetterAuthError(
|
|
668
|
+
`No references found for foreign key ${foreignKey} on model ${model} while performing join operation.`,
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
let from: string;
|
|
673
|
+
let to: string;
|
|
674
|
+
let requiredSelectField: string;
|
|
675
|
+
|
|
676
|
+
if (isForwardJoin) {
|
|
677
|
+
// joined model has FK to base model
|
|
678
|
+
// The field we need in select is the referenced field in the base model
|
|
679
|
+
requiredSelectField = foreignKeyAttributes.references.field;
|
|
680
|
+
from = getFieldName({
|
|
681
|
+
model: baseModel,
|
|
682
|
+
field: requiredSelectField,
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
to = getFieldName({
|
|
686
|
+
model,
|
|
687
|
+
field: foreignKey,
|
|
688
|
+
});
|
|
689
|
+
} else {
|
|
690
|
+
// base model has FK to joined model
|
|
691
|
+
// The field we need in select is the foreign key field in the base model
|
|
692
|
+
requiredSelectField = foreignKey;
|
|
693
|
+
from = getFieldName({
|
|
694
|
+
model: baseModel,
|
|
695
|
+
field: requiredSelectField,
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
to = getFieldName({
|
|
699
|
+
model,
|
|
700
|
+
field: foreignKeyAttributes.references.field,
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// Ensure the required field is in select if select is provided
|
|
705
|
+
if (select && !select.includes(requiredSelectField)) {
|
|
706
|
+
select.push(requiredSelectField);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
const isUnique =
|
|
710
|
+
to === "id" ? true : (foreignKeyAttributes.unique ?? false);
|
|
711
|
+
|
|
712
|
+
let limit: number =
|
|
713
|
+
options.advanced?.database?.defaultFindManyLimit ?? 100;
|
|
714
|
+
if (isUnique) {
|
|
715
|
+
limit = 1;
|
|
716
|
+
} else if (typeof join === "object" && typeof join.limit === "number") {
|
|
717
|
+
limit = join.limit;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
transformedJoin[getModelName(model)] = {
|
|
721
|
+
on: {
|
|
722
|
+
from,
|
|
723
|
+
to,
|
|
724
|
+
},
|
|
725
|
+
limit,
|
|
726
|
+
relation: isUnique ? "one-to-one" : "one-to-many",
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
return { join: transformedJoin, select };
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Handle joins by making separate queries and combining results (fallback for adapters that don't support native joins).
|
|
734
|
+
*/
|
|
735
|
+
const handleFallbackJoin = async <T extends Record<string, any> | null>({
|
|
736
|
+
baseModel,
|
|
737
|
+
baseData,
|
|
738
|
+
joinModel,
|
|
739
|
+
specificJoinConfig: joinConfig,
|
|
740
|
+
}: {
|
|
741
|
+
baseModel: string;
|
|
742
|
+
baseData: T;
|
|
743
|
+
joinModel: string;
|
|
744
|
+
specificJoinConfig: JoinConfig[number];
|
|
745
|
+
}) => {
|
|
746
|
+
if (!baseData) return baseData;
|
|
747
|
+
const modelName = getModelName(joinModel);
|
|
748
|
+
const field = joinConfig.on.to;
|
|
749
|
+
const value =
|
|
750
|
+
baseData[
|
|
751
|
+
getDefaultFieldName({ field: joinConfig.on.from, model: baseModel })
|
|
752
|
+
];
|
|
753
|
+
|
|
754
|
+
if (value === null || value === undefined) {
|
|
755
|
+
// If there is no value, it could mean that the query used a `select` clause that didn't include the field.
|
|
756
|
+
// or the query result is purely empty.
|
|
757
|
+
// In any case, we return null/empty array.
|
|
758
|
+
return joinConfig.relation === "one-to-one" ? null : [];
|
|
759
|
+
}
|
|
760
|
+
let result: Record<string, any> | Record<string, any>[] | null;
|
|
761
|
+
const where = transformWhereClause({
|
|
762
|
+
model: modelName,
|
|
763
|
+
where: [
|
|
764
|
+
{
|
|
765
|
+
field,
|
|
766
|
+
value,
|
|
767
|
+
operator: "eq",
|
|
768
|
+
connector: "AND",
|
|
769
|
+
},
|
|
770
|
+
],
|
|
771
|
+
action: "findOne",
|
|
772
|
+
});
|
|
773
|
+
try {
|
|
774
|
+
if (joinConfig.relation === "one-to-one") {
|
|
775
|
+
result = await withSpan(
|
|
776
|
+
`db findOne ${modelName}`,
|
|
777
|
+
{
|
|
778
|
+
[ATTR_DB_OPERATION_NAME]: "findOne",
|
|
779
|
+
[ATTR_DB_COLLECTION_NAME]: modelName,
|
|
780
|
+
},
|
|
781
|
+
() =>
|
|
782
|
+
adapterInstance.findOne<Record<string, any>>({
|
|
783
|
+
model: modelName,
|
|
784
|
+
where: where,
|
|
785
|
+
}),
|
|
786
|
+
);
|
|
787
|
+
} else {
|
|
788
|
+
const limit =
|
|
789
|
+
joinConfig.limit ??
|
|
790
|
+
options.advanced?.database?.defaultFindManyLimit ??
|
|
791
|
+
100;
|
|
792
|
+
result = await withSpan(
|
|
793
|
+
`db findMany ${modelName}`,
|
|
794
|
+
{
|
|
795
|
+
[ATTR_DB_OPERATION_NAME]: "findMany",
|
|
796
|
+
[ATTR_DB_COLLECTION_NAME]: modelName,
|
|
797
|
+
},
|
|
798
|
+
() =>
|
|
799
|
+
adapterInstance.findMany<Record<string, any>>({
|
|
800
|
+
model: modelName,
|
|
801
|
+
where: where,
|
|
802
|
+
limit,
|
|
803
|
+
}),
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
} catch (error) {
|
|
807
|
+
logger.error(`Failed to query fallback join for model ${modelName}:`, {
|
|
808
|
+
where,
|
|
809
|
+
limit: joinConfig.limit,
|
|
810
|
+
});
|
|
811
|
+
console.error(error);
|
|
812
|
+
throw error;
|
|
813
|
+
}
|
|
814
|
+
return result;
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
const adapterInstance = customAdapter({
|
|
818
|
+
options,
|
|
819
|
+
schema,
|
|
820
|
+
debugLog,
|
|
821
|
+
getFieldName,
|
|
822
|
+
getModelName,
|
|
823
|
+
getDefaultModelName,
|
|
824
|
+
getDefaultFieldName,
|
|
825
|
+
getFieldAttributes,
|
|
826
|
+
transformInput,
|
|
827
|
+
transformOutput,
|
|
828
|
+
transformWhereClause,
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
let lazyLoadTransaction: DBAdapter<Options>["transaction"] | null = null;
|
|
832
|
+
const adapter: DBAdapter<Options> = {
|
|
833
|
+
transaction: async (cb) => {
|
|
834
|
+
if (!lazyLoadTransaction) {
|
|
835
|
+
if (!config.transaction) {
|
|
836
|
+
lazyLoadTransaction = createAsIsTransaction(adapter);
|
|
837
|
+
} else {
|
|
838
|
+
logger.debug(
|
|
839
|
+
`[${config.adapterName}] - Using provided transaction implementation.`,
|
|
840
|
+
);
|
|
841
|
+
lazyLoadTransaction = config.transaction;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
return lazyLoadTransaction(cb);
|
|
845
|
+
},
|
|
846
|
+
create: async <T extends Record<string, any>, R = T>({
|
|
847
|
+
data: unsafeData,
|
|
848
|
+
model: unsafeModel,
|
|
849
|
+
select,
|
|
850
|
+
forceAllowId = false,
|
|
851
|
+
}: {
|
|
852
|
+
model: string;
|
|
853
|
+
data: T;
|
|
854
|
+
select?: string[];
|
|
855
|
+
forceAllowId?: boolean;
|
|
856
|
+
}): Promise<R> => {
|
|
857
|
+
transactionId++;
|
|
858
|
+
const thisTransactionId = transactionId;
|
|
859
|
+
const model = getModelName(unsafeModel);
|
|
860
|
+
unsafeModel = getDefaultModelName(unsafeModel);
|
|
861
|
+
if (
|
|
862
|
+
"id" in unsafeData &&
|
|
863
|
+
typeof unsafeData.id !== "undefined" &&
|
|
864
|
+
!forceAllowId
|
|
865
|
+
) {
|
|
866
|
+
// The reason why `forceAllowId` was introduced was because we used to handle
|
|
867
|
+
// id generation ourselves (eg adapter.create({ data: { id: "123" } }))
|
|
868
|
+
// This was bad as certain things (such as number ids) would not work as expected.
|
|
869
|
+
// Since then, we have introduced the `forceAllowId` parameter to allow users to
|
|
870
|
+
// bypass this check. Otherwise, we would throw a warning stating that the id will be ignored
|
|
871
|
+
logger.warn(
|
|
872
|
+
`[${config.adapterName}] - You are trying to create a record with an id. This is not allowed as we handle id generation for you, unless you pass in the \`forceAllowId\` parameter. The id will be ignored.`,
|
|
873
|
+
);
|
|
874
|
+
const err = new Error();
|
|
875
|
+
const stack = err.stack
|
|
876
|
+
?.split("\n")
|
|
877
|
+
.filter((_, i) => i !== 1)
|
|
878
|
+
.join("\n")
|
|
879
|
+
.replace("Error:", "Create method with `id` being called at:");
|
|
880
|
+
console.log(stack);
|
|
881
|
+
//@ts-expect-error
|
|
882
|
+
unsafeData.id = undefined;
|
|
883
|
+
}
|
|
884
|
+
debugLog(
|
|
885
|
+
{ method: "create" },
|
|
886
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(1, 4)}`,
|
|
887
|
+
`${formatMethod("create")} ${formatAction("Unsafe Input")}:`,
|
|
888
|
+
{ model, data: unsafeData },
|
|
889
|
+
);
|
|
890
|
+
let data = unsafeData;
|
|
891
|
+
if (!config.disableTransformInput) {
|
|
892
|
+
data = (await transformInput(
|
|
893
|
+
unsafeData,
|
|
894
|
+
unsafeModel,
|
|
895
|
+
"create",
|
|
896
|
+
forceAllowId,
|
|
897
|
+
)) as T;
|
|
898
|
+
}
|
|
899
|
+
debugLog(
|
|
900
|
+
{ method: "create" },
|
|
901
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(2, 4)}`,
|
|
902
|
+
`${formatMethod("create")} ${formatAction("Parsed Input")}:`,
|
|
903
|
+
{ model, data },
|
|
904
|
+
);
|
|
905
|
+
const res = await withSpan(
|
|
906
|
+
`db create ${model}`,
|
|
907
|
+
{
|
|
908
|
+
[ATTR_DB_OPERATION_NAME]: "create",
|
|
909
|
+
[ATTR_DB_COLLECTION_NAME]: model,
|
|
910
|
+
},
|
|
911
|
+
() => adapterInstance.create<T>({ data, model }),
|
|
912
|
+
);
|
|
913
|
+
debugLog(
|
|
914
|
+
{ method: "create" },
|
|
915
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(3, 4)}`,
|
|
916
|
+
`${formatMethod("create")} ${formatAction("DB Result")}:`,
|
|
917
|
+
{ model, res },
|
|
918
|
+
);
|
|
919
|
+
let transformed = res as any;
|
|
920
|
+
if (!config.disableTransformOutput) {
|
|
921
|
+
transformed = await transformOutput(
|
|
922
|
+
res as any,
|
|
923
|
+
unsafeModel,
|
|
924
|
+
select,
|
|
925
|
+
undefined,
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
debugLog(
|
|
929
|
+
{ method: "create" },
|
|
930
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(4, 4)}`,
|
|
931
|
+
`${formatMethod("create")} ${formatAction("Parsed Result")}:`,
|
|
932
|
+
{ model, data: transformed },
|
|
933
|
+
);
|
|
934
|
+
return transformed;
|
|
935
|
+
},
|
|
936
|
+
update: async <T>({
|
|
937
|
+
model: unsafeModel,
|
|
938
|
+
where: unsafeWhere,
|
|
939
|
+
update: unsafeData,
|
|
940
|
+
}: {
|
|
941
|
+
model: string;
|
|
942
|
+
where: Where[];
|
|
943
|
+
update: Record<string, any>;
|
|
944
|
+
}): Promise<T | null> => {
|
|
945
|
+
transactionId++;
|
|
946
|
+
const thisTransactionId = transactionId;
|
|
947
|
+
unsafeModel = getDefaultModelName(unsafeModel);
|
|
948
|
+
const model = getModelName(unsafeModel);
|
|
949
|
+
const where = transformWhereClause({
|
|
950
|
+
model: unsafeModel,
|
|
951
|
+
where: unsafeWhere,
|
|
952
|
+
action: "update",
|
|
953
|
+
});
|
|
954
|
+
debugLog(
|
|
955
|
+
{ method: "update" },
|
|
956
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(1, 4)}`,
|
|
957
|
+
`${formatMethod("update")} ${formatAction("Unsafe Input")}:`,
|
|
958
|
+
{ model, data: unsafeData },
|
|
959
|
+
);
|
|
960
|
+
let data = unsafeData as T;
|
|
961
|
+
if (!config.disableTransformInput) {
|
|
962
|
+
data = (await transformInput(unsafeData, unsafeModel, "update")) as T;
|
|
963
|
+
}
|
|
964
|
+
debugLog(
|
|
965
|
+
{ method: "update" },
|
|
966
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(2, 4)}`,
|
|
967
|
+
`${formatMethod("update")} ${formatAction("Parsed Input")}:`,
|
|
968
|
+
{ model, data },
|
|
969
|
+
);
|
|
970
|
+
const res = await withSpan(
|
|
971
|
+
`db update ${model}`,
|
|
972
|
+
{
|
|
973
|
+
[ATTR_DB_OPERATION_NAME]: "update",
|
|
974
|
+
[ATTR_DB_COLLECTION_NAME]: model,
|
|
975
|
+
},
|
|
976
|
+
() =>
|
|
977
|
+
adapterInstance.update<T>({
|
|
978
|
+
model,
|
|
979
|
+
where,
|
|
980
|
+
update: data,
|
|
981
|
+
}),
|
|
982
|
+
);
|
|
983
|
+
debugLog(
|
|
984
|
+
{ method: "update" },
|
|
985
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(3, 4)}`,
|
|
986
|
+
`${formatMethod("update")} ${formatAction("DB Result")}:`,
|
|
987
|
+
{ model, data: res },
|
|
988
|
+
);
|
|
989
|
+
let transformed = res as any;
|
|
990
|
+
if (!config.disableTransformOutput) {
|
|
991
|
+
transformed = await transformOutput(
|
|
992
|
+
res as any,
|
|
993
|
+
unsafeModel,
|
|
994
|
+
undefined,
|
|
995
|
+
undefined,
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
debugLog(
|
|
999
|
+
{ method: "update" },
|
|
1000
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(4, 4)}`,
|
|
1001
|
+
`${formatMethod("update")} ${formatAction("Parsed Result")}:`,
|
|
1002
|
+
{ model, data: transformed },
|
|
1003
|
+
);
|
|
1004
|
+
return transformed;
|
|
1005
|
+
},
|
|
1006
|
+
updateMany: async ({
|
|
1007
|
+
model: unsafeModel,
|
|
1008
|
+
where: unsafeWhere,
|
|
1009
|
+
update: unsafeData,
|
|
1010
|
+
}: {
|
|
1011
|
+
model: string;
|
|
1012
|
+
where: Where[];
|
|
1013
|
+
update: Record<string, any>;
|
|
1014
|
+
}) => {
|
|
1015
|
+
transactionId++;
|
|
1016
|
+
const thisTransactionId = transactionId;
|
|
1017
|
+
const model = getModelName(unsafeModel);
|
|
1018
|
+
const where = transformWhereClause({
|
|
1019
|
+
model: unsafeModel,
|
|
1020
|
+
where: unsafeWhere,
|
|
1021
|
+
action: "updateMany",
|
|
1022
|
+
});
|
|
1023
|
+
unsafeModel = getDefaultModelName(unsafeModel);
|
|
1024
|
+
debugLog(
|
|
1025
|
+
{ method: "updateMany" },
|
|
1026
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(1, 4)}`,
|
|
1027
|
+
`${formatMethod("updateMany")} ${formatAction("Unsafe Input")}:`,
|
|
1028
|
+
{ model, data: unsafeData },
|
|
1029
|
+
);
|
|
1030
|
+
let data = unsafeData;
|
|
1031
|
+
if (!config.disableTransformInput) {
|
|
1032
|
+
data = await transformInput(unsafeData, unsafeModel, "update");
|
|
1033
|
+
}
|
|
1034
|
+
debugLog(
|
|
1035
|
+
{ method: "updateMany" },
|
|
1036
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(2, 4)}`,
|
|
1037
|
+
`${formatMethod("updateMany")} ${formatAction("Parsed Input")}:`,
|
|
1038
|
+
{ model, data },
|
|
1039
|
+
);
|
|
1040
|
+
|
|
1041
|
+
const updatedCount = await withSpan(
|
|
1042
|
+
`db updateMany ${model}`,
|
|
1043
|
+
{
|
|
1044
|
+
[ATTR_DB_OPERATION_NAME]: "updateMany",
|
|
1045
|
+
[ATTR_DB_COLLECTION_NAME]: model,
|
|
1046
|
+
},
|
|
1047
|
+
() =>
|
|
1048
|
+
adapterInstance.updateMany({
|
|
1049
|
+
model,
|
|
1050
|
+
where,
|
|
1051
|
+
update: data,
|
|
1052
|
+
}),
|
|
1053
|
+
);
|
|
1054
|
+
debugLog(
|
|
1055
|
+
{ method: "updateMany" },
|
|
1056
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(3, 4)}`,
|
|
1057
|
+
`${formatMethod("updateMany")} ${formatAction("DB Result")}:`,
|
|
1058
|
+
{ model, data: updatedCount },
|
|
1059
|
+
);
|
|
1060
|
+
debugLog(
|
|
1061
|
+
{ method: "updateMany" },
|
|
1062
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(4, 4)}`,
|
|
1063
|
+
`${formatMethod("updateMany")} ${formatAction("Parsed Result")}:`,
|
|
1064
|
+
{ model, data: updatedCount },
|
|
1065
|
+
);
|
|
1066
|
+
return updatedCount;
|
|
1067
|
+
},
|
|
1068
|
+
findOne: async <T extends Record<string, any>>({
|
|
1069
|
+
model: unsafeModel,
|
|
1070
|
+
where: unsafeWhere,
|
|
1071
|
+
select,
|
|
1072
|
+
join: unsafeJoin,
|
|
1073
|
+
}: {
|
|
1074
|
+
model: string;
|
|
1075
|
+
where: Where[];
|
|
1076
|
+
select?: string[];
|
|
1077
|
+
join?: JoinOption;
|
|
1078
|
+
}) => {
|
|
1079
|
+
transactionId++;
|
|
1080
|
+
const thisTransactionId = transactionId;
|
|
1081
|
+
const model = getModelName(unsafeModel);
|
|
1082
|
+
const where = transformWhereClause({
|
|
1083
|
+
model: unsafeModel,
|
|
1084
|
+
where: unsafeWhere,
|
|
1085
|
+
action: "findOne",
|
|
1086
|
+
});
|
|
1087
|
+
unsafeModel = getDefaultModelName(unsafeModel);
|
|
1088
|
+
let join: JoinConfig | undefined;
|
|
1089
|
+
let passJoinToAdapter = true;
|
|
1090
|
+
if (!config.disableTransformJoin) {
|
|
1091
|
+
const result = transformJoinClause(unsafeModel, unsafeJoin, select);
|
|
1092
|
+
if (result) {
|
|
1093
|
+
join = result.join;
|
|
1094
|
+
select = result.select;
|
|
1095
|
+
}
|
|
1096
|
+
// If adapter doesn't support joins and we have joins, don't pass them to the adapter
|
|
1097
|
+
const experimentalJoins = options.experimental?.joins;
|
|
1098
|
+
if (!experimentalJoins && join && Object.keys(join).length > 0) {
|
|
1099
|
+
passJoinToAdapter = false;
|
|
1100
|
+
}
|
|
1101
|
+
} else {
|
|
1102
|
+
// assume it's already transformed if transformation is disabled
|
|
1103
|
+
join = unsafeJoin as never as JoinConfig;
|
|
1104
|
+
}
|
|
1105
|
+
debugLog(
|
|
1106
|
+
{ method: "findOne" },
|
|
1107
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(1, 3)}`,
|
|
1108
|
+
`${formatMethod("findOne")}:`,
|
|
1109
|
+
{ model, where, select, join },
|
|
1110
|
+
);
|
|
1111
|
+
|
|
1112
|
+
const res = await withSpan(
|
|
1113
|
+
`db findOne ${model}`,
|
|
1114
|
+
{
|
|
1115
|
+
[ATTR_DB_OPERATION_NAME]: "findOne",
|
|
1116
|
+
[ATTR_DB_COLLECTION_NAME]: model,
|
|
1117
|
+
},
|
|
1118
|
+
() =>
|
|
1119
|
+
adapterInstance.findOne<T>({
|
|
1120
|
+
model,
|
|
1121
|
+
where,
|
|
1122
|
+
select,
|
|
1123
|
+
join: passJoinToAdapter ? join : undefined,
|
|
1124
|
+
}),
|
|
1125
|
+
);
|
|
1126
|
+
debugLog(
|
|
1127
|
+
{ method: "findOne" },
|
|
1128
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(2, 3)}`,
|
|
1129
|
+
`${formatMethod("findOne")} ${formatAction("DB Result")}:`,
|
|
1130
|
+
{ model, data: res },
|
|
1131
|
+
);
|
|
1132
|
+
|
|
1133
|
+
// Handle fallback join if adapter doesn't support joins
|
|
1134
|
+
let transformed = res as any;
|
|
1135
|
+
if (!config.disableTransformOutput) {
|
|
1136
|
+
transformed = await transformOutput(res, unsafeModel, select, join);
|
|
1137
|
+
}
|
|
1138
|
+
debugLog(
|
|
1139
|
+
{ method: "findOne" },
|
|
1140
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(3, 3)}`,
|
|
1141
|
+
`${formatMethod("findOne")} ${formatAction("Parsed Result")}:`,
|
|
1142
|
+
{ model, data: transformed },
|
|
1143
|
+
);
|
|
1144
|
+
return transformed;
|
|
1145
|
+
},
|
|
1146
|
+
findMany: async <T extends Record<string, any>>({
|
|
1147
|
+
model: unsafeModel,
|
|
1148
|
+
where: unsafeWhere,
|
|
1149
|
+
limit: unsafeLimit,
|
|
1150
|
+
select,
|
|
1151
|
+
sortBy,
|
|
1152
|
+
offset,
|
|
1153
|
+
join: unsafeJoin,
|
|
1154
|
+
}: {
|
|
1155
|
+
model: string;
|
|
1156
|
+
where?: Where[];
|
|
1157
|
+
limit?: number;
|
|
1158
|
+
select?: string[] | undefined;
|
|
1159
|
+
sortBy?: { field: string; direction: "asc" | "desc" };
|
|
1160
|
+
offset?: number;
|
|
1161
|
+
join?: JoinOption;
|
|
1162
|
+
}) => {
|
|
1163
|
+
transactionId++;
|
|
1164
|
+
const thisTransactionId = transactionId;
|
|
1165
|
+
const limit =
|
|
1166
|
+
unsafeLimit ??
|
|
1167
|
+
options.advanced?.database?.defaultFindManyLimit ??
|
|
1168
|
+
100;
|
|
1169
|
+
const model = getModelName(unsafeModel);
|
|
1170
|
+
const where = transformWhereClause({
|
|
1171
|
+
model: unsafeModel,
|
|
1172
|
+
where: unsafeWhere,
|
|
1173
|
+
action: "findMany",
|
|
1174
|
+
});
|
|
1175
|
+
unsafeModel = getDefaultModelName(unsafeModel);
|
|
1176
|
+
let join: JoinConfig | undefined;
|
|
1177
|
+
let passJoinToAdapter = true;
|
|
1178
|
+
if (!config.disableTransformJoin) {
|
|
1179
|
+
const result = transformJoinClause(unsafeModel, unsafeJoin, select);
|
|
1180
|
+
if (result) {
|
|
1181
|
+
join = result.join;
|
|
1182
|
+
select = result.select;
|
|
1183
|
+
}
|
|
1184
|
+
// If adapter doesn't support joins and we have joins, don't pass them to the adapter
|
|
1185
|
+
const experimentalJoins = options.experimental?.joins;
|
|
1186
|
+
if (!experimentalJoins && join && Object.keys(join).length > 0) {
|
|
1187
|
+
passJoinToAdapter = false;
|
|
1188
|
+
}
|
|
1189
|
+
} else {
|
|
1190
|
+
// assume it's already transformed if transformation is disabled
|
|
1191
|
+
join = unsafeJoin as never as JoinConfig;
|
|
1192
|
+
}
|
|
1193
|
+
debugLog(
|
|
1194
|
+
{ method: "findMany" },
|
|
1195
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(1, 3)}`,
|
|
1196
|
+
`${formatMethod("findMany")}:`,
|
|
1197
|
+
{ model, where, limit, sortBy, offset, join },
|
|
1198
|
+
);
|
|
1199
|
+
const res = await withSpan(
|
|
1200
|
+
`db findMany ${model}`,
|
|
1201
|
+
{
|
|
1202
|
+
[ATTR_DB_OPERATION_NAME]: "findMany",
|
|
1203
|
+
[ATTR_DB_COLLECTION_NAME]: model,
|
|
1204
|
+
},
|
|
1205
|
+
() =>
|
|
1206
|
+
adapterInstance.findMany<T>({
|
|
1207
|
+
model,
|
|
1208
|
+
where,
|
|
1209
|
+
limit: limit,
|
|
1210
|
+
select,
|
|
1211
|
+
sortBy,
|
|
1212
|
+
offset,
|
|
1213
|
+
join: passJoinToAdapter ? join : undefined,
|
|
1214
|
+
}),
|
|
1215
|
+
);
|
|
1216
|
+
debugLog(
|
|
1217
|
+
{ method: "findMany" },
|
|
1218
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(2, 3)}`,
|
|
1219
|
+
`${formatMethod("findMany")} ${formatAction("DB Result")}:`,
|
|
1220
|
+
{ model, data: res },
|
|
1221
|
+
);
|
|
1222
|
+
|
|
1223
|
+
let transformed = res as any;
|
|
1224
|
+
if (!config.disableTransformOutput) {
|
|
1225
|
+
transformed = await Promise.all(
|
|
1226
|
+
res.map(async (r: Record<string, any>) => {
|
|
1227
|
+
return await transformOutput(r, unsafeModel, undefined, join);
|
|
1228
|
+
}),
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
debugLog(
|
|
1233
|
+
{ method: "findMany" },
|
|
1234
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(3, 3)}`,
|
|
1235
|
+
`${formatMethod("findMany")} ${formatAction("Parsed Result")}:`,
|
|
1236
|
+
{ model, data: transformed },
|
|
1237
|
+
);
|
|
1238
|
+
return transformed;
|
|
1239
|
+
},
|
|
1240
|
+
delete: async ({
|
|
1241
|
+
model: unsafeModel,
|
|
1242
|
+
where: unsafeWhere,
|
|
1243
|
+
}: {
|
|
1244
|
+
model: string;
|
|
1245
|
+
where: Where[];
|
|
1246
|
+
}) => {
|
|
1247
|
+
transactionId++;
|
|
1248
|
+
const thisTransactionId = transactionId;
|
|
1249
|
+
const model = getModelName(unsafeModel);
|
|
1250
|
+
const where = transformWhereClause({
|
|
1251
|
+
model: unsafeModel,
|
|
1252
|
+
where: unsafeWhere,
|
|
1253
|
+
action: "delete",
|
|
1254
|
+
});
|
|
1255
|
+
unsafeModel = getDefaultModelName(unsafeModel);
|
|
1256
|
+
debugLog(
|
|
1257
|
+
{ method: "delete" },
|
|
1258
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(1, 2)}`,
|
|
1259
|
+
`${formatMethod("delete")}:`,
|
|
1260
|
+
{ model, where },
|
|
1261
|
+
);
|
|
1262
|
+
await withSpan(
|
|
1263
|
+
`db delete ${model}`,
|
|
1264
|
+
{
|
|
1265
|
+
[ATTR_DB_OPERATION_NAME]: "delete",
|
|
1266
|
+
[ATTR_DB_COLLECTION_NAME]: model,
|
|
1267
|
+
},
|
|
1268
|
+
() => adapterInstance.delete({ model, where }),
|
|
1269
|
+
);
|
|
1270
|
+
debugLog(
|
|
1271
|
+
{ method: "delete" },
|
|
1272
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(2, 2)}`,
|
|
1273
|
+
`${formatMethod("delete")} ${formatAction("DB Result")}:`,
|
|
1274
|
+
{ model },
|
|
1275
|
+
);
|
|
1276
|
+
},
|
|
1277
|
+
deleteMany: async ({
|
|
1278
|
+
model: unsafeModel,
|
|
1279
|
+
where: unsafeWhere,
|
|
1280
|
+
}: {
|
|
1281
|
+
model: string;
|
|
1282
|
+
where: Where[];
|
|
1283
|
+
}) => {
|
|
1284
|
+
transactionId++;
|
|
1285
|
+
const thisTransactionId = transactionId;
|
|
1286
|
+
const model = getModelName(unsafeModel);
|
|
1287
|
+
const where = transformWhereClause({
|
|
1288
|
+
model: unsafeModel,
|
|
1289
|
+
where: unsafeWhere,
|
|
1290
|
+
action: "deleteMany",
|
|
1291
|
+
});
|
|
1292
|
+
unsafeModel = getDefaultModelName(unsafeModel);
|
|
1293
|
+
debugLog(
|
|
1294
|
+
{ method: "deleteMany" },
|
|
1295
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(1, 2)}`,
|
|
1296
|
+
`${formatMethod("deleteMany")} ${formatAction("DeleteMany")}:`,
|
|
1297
|
+
{ model, where },
|
|
1298
|
+
);
|
|
1299
|
+
const res = await withSpan(
|
|
1300
|
+
`db deleteMany ${model}`,
|
|
1301
|
+
{
|
|
1302
|
+
[ATTR_DB_OPERATION_NAME]: "deleteMany",
|
|
1303
|
+
[ATTR_DB_COLLECTION_NAME]: model,
|
|
1304
|
+
},
|
|
1305
|
+
() => adapterInstance.deleteMany({ model, where }),
|
|
1306
|
+
);
|
|
1307
|
+
debugLog(
|
|
1308
|
+
{ method: "deleteMany" },
|
|
1309
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(2, 2)}`,
|
|
1310
|
+
`${formatMethod("deleteMany")} ${formatAction("DB Result")}:`,
|
|
1311
|
+
{ model, data: res },
|
|
1312
|
+
);
|
|
1313
|
+
return res;
|
|
1314
|
+
},
|
|
1315
|
+
count: async ({
|
|
1316
|
+
model: unsafeModel,
|
|
1317
|
+
where: unsafeWhere,
|
|
1318
|
+
}: {
|
|
1319
|
+
model: string;
|
|
1320
|
+
where?: Where[];
|
|
1321
|
+
}) => {
|
|
1322
|
+
transactionId++;
|
|
1323
|
+
const thisTransactionId = transactionId;
|
|
1324
|
+
const model = getModelName(unsafeModel);
|
|
1325
|
+
const where = transformWhereClause({
|
|
1326
|
+
model: unsafeModel,
|
|
1327
|
+
where: unsafeWhere,
|
|
1328
|
+
action: "count",
|
|
1329
|
+
});
|
|
1330
|
+
unsafeModel = getDefaultModelName(unsafeModel);
|
|
1331
|
+
debugLog(
|
|
1332
|
+
{ method: "count" },
|
|
1333
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(1, 2)}`,
|
|
1334
|
+
`${formatMethod("count")}:`,
|
|
1335
|
+
{
|
|
1336
|
+
model,
|
|
1337
|
+
where,
|
|
1338
|
+
},
|
|
1339
|
+
);
|
|
1340
|
+
const res = await withSpan(
|
|
1341
|
+
`db count ${model}`,
|
|
1342
|
+
{
|
|
1343
|
+
[ATTR_DB_OPERATION_NAME]: "count",
|
|
1344
|
+
[ATTR_DB_COLLECTION_NAME]: model,
|
|
1345
|
+
},
|
|
1346
|
+
() => adapterInstance.count({ model, where }),
|
|
1347
|
+
);
|
|
1348
|
+
debugLog(
|
|
1349
|
+
{ method: "count" },
|
|
1350
|
+
`${formatTransactionId(thisTransactionId)} ${formatStep(2, 2)}`,
|
|
1351
|
+
`${formatMethod("count")}:`,
|
|
1352
|
+
{
|
|
1353
|
+
model,
|
|
1354
|
+
data: res,
|
|
1355
|
+
},
|
|
1356
|
+
);
|
|
1357
|
+
return res;
|
|
1358
|
+
},
|
|
1359
|
+
createSchema: adapterInstance.createSchema
|
|
1360
|
+
? async (_, file) => {
|
|
1361
|
+
const tables = getAuthTables(options);
|
|
1362
|
+
|
|
1363
|
+
if (
|
|
1364
|
+
options.secondaryStorage &&
|
|
1365
|
+
!options.session?.storeSessionInDatabase
|
|
1366
|
+
) {
|
|
1367
|
+
// biome-ignore lint/performance/noDelete: If the user has enabled secondaryStorage, as well as not specifying to store session table in DB, then createSchema shouldn't generate schema table.
|
|
1368
|
+
delete tables.session;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
return adapterInstance.createSchema!({ file, tables });
|
|
1372
|
+
}
|
|
1373
|
+
: undefined,
|
|
1374
|
+
options: {
|
|
1375
|
+
adapterConfig: config,
|
|
1376
|
+
...(adapterInstance.options ?? {}),
|
|
1377
|
+
},
|
|
1378
|
+
id: config.adapterId,
|
|
1379
|
+
|
|
1380
|
+
// Secretly export values ONLY if this adapter has enabled adapter-test-debug-logs.
|
|
1381
|
+
// This would then be used during our adapter-tests to help print debug logs if a test fails.
|
|
1382
|
+
//@ts-expect-error - ^^
|
|
1383
|
+
...(config.debugLogs?.isRunningAdapterTests
|
|
1384
|
+
? {
|
|
1385
|
+
adapterTestDebugLogs: {
|
|
1386
|
+
resetDebugLogs() {
|
|
1387
|
+
debugLogs = debugLogs.filter(
|
|
1388
|
+
(log) => log.instance !== uniqueAdapterFactoryInstanceId,
|
|
1389
|
+
);
|
|
1390
|
+
},
|
|
1391
|
+
printDebugLogs() {
|
|
1392
|
+
const separator = `─`.repeat(80);
|
|
1393
|
+
const logs = debugLogs.filter(
|
|
1394
|
+
(log) => log.instance === uniqueAdapterFactoryInstanceId,
|
|
1395
|
+
);
|
|
1396
|
+
if (logs.length === 0) {
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
//`${colors.fg.blue}|${colors.reset} `,
|
|
1401
|
+
const log: any[] = logs
|
|
1402
|
+
.reverse()
|
|
1403
|
+
.map((log) => {
|
|
1404
|
+
log.args[0] = `\n${log.args[0]}`;
|
|
1405
|
+
return [...log.args, "\n"];
|
|
1406
|
+
})
|
|
1407
|
+
.reduce(
|
|
1408
|
+
(prev, curr) => {
|
|
1409
|
+
return [...curr, ...prev];
|
|
1410
|
+
},
|
|
1411
|
+
[`\n${separator}`],
|
|
1412
|
+
);
|
|
1413
|
+
|
|
1414
|
+
console.log(...log);
|
|
1415
|
+
},
|
|
1416
|
+
} satisfies AdapterTestDebugLogs,
|
|
1417
|
+
}
|
|
1418
|
+
: {}),
|
|
1419
|
+
};
|
|
1420
|
+
return adapter;
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1423
|
+
function formatTransactionId(transactionId: number) {
|
|
1424
|
+
if (getColorDepth() < 8) {
|
|
1425
|
+
return `#${transactionId}`;
|
|
1426
|
+
}
|
|
1427
|
+
return `${TTY_COLORS.fg.magenta}#${transactionId}${TTY_COLORS.reset}`;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
function formatStep(step: number, total: number) {
|
|
1431
|
+
return `${TTY_COLORS.bg.black}${TTY_COLORS.fg.yellow}[${step}/${total}]${TTY_COLORS.reset}`;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
function formatMethod(method: string) {
|
|
1435
|
+
return `${TTY_COLORS.bright}${method}${TTY_COLORS.reset}`;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function formatAction(action: string) {
|
|
1439
|
+
return `${TTY_COLORS.dim}(${action})${TTY_COLORS.reset}`;
|
|
1440
|
+
}
|