create-croissant 0.1.8 → 0.1.9
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/package.json +1 -1
- package/template/apps/web/package.json +2 -0
- package/template/apps/web/src/components/login-form.tsx +95 -48
- package/template/apps/web/src/components/signup-form.tsx +149 -79
- package/template/apps/web/src/routes/__root.tsx +17 -12
- package/template/apps/web/src/routes/client-orpc-auth.tsx +8 -20
- package/template/apps/web/src/routes/client-orpc.tsx +203 -108
- package/template/apps/web/src/routes/ssr-orpc.tsx +169 -96
- package/template/package.json +3 -1
- package/template/apps/web/node_modules/@better-auth/core/LICENSE.md +0 -20
- package/template/apps/web/node_modules/@better-auth/core/README.md +0 -17
- package/template/apps/web/node_modules/@better-auth/core/dist/api/index.d.mts +0 -278
- package/template/apps/web/node_modules/@better-auth/core/dist/api/index.mjs +0 -56
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/index.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/index.mjs +0 -20
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/pure.index.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/pure.index.mjs +0 -33
- package/template/apps/web/node_modules/@better-auth/core/dist/context/endpoint-context.d.mts +0 -18
- package/template/apps/web/node_modules/@better-auth/core/dist/context/endpoint-context.mjs +0 -29
- package/template/apps/web/node_modules/@better-auth/core/dist/context/global.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/context/global.mjs +0 -36
- package/template/apps/web/node_modules/@better-auth/core/dist/context/index.d.mts +0 -5
- package/template/apps/web/node_modules/@better-auth/core/dist/context/index.mjs +0 -5
- package/template/apps/web/node_modules/@better-auth/core/dist/context/request-state.d.mts +0 -27
- package/template/apps/web/node_modules/@better-auth/core/dist/context/request-state.mjs +0 -47
- package/template/apps/web/node_modules/@better-auth/core/dist/context/transaction.d.mts +0 -24
- package/template/apps/web/node_modules/@better-auth/core/dist/context/transaction.mjs +0 -93
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/factory.d.mts +0 -17
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/factory.mjs +0 -754
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-field-name.d.mts +0 -18
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-field-name.mjs +0 -36
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-model-name.d.mts +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-model-name.mjs +0 -30
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-attributes.d.mts +0 -26
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-attributes.mjs +0 -37
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-name.d.mts +0 -18
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-name.mjs +0 -31
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-id-field.d.mts +0 -36
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-id-field.mjs +0 -64
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-model-name.d.mts +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-model-name.mjs +0 -21
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/index.d.mts +0 -525
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/index.mjs +0 -24
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/types.d.mts +0 -105
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/utils.d.mts +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/utils.mjs +0 -37
- package/template/apps/web/node_modules/@better-auth/core/dist/db/get-tables.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/db/get-tables.mjs +0 -265
- package/template/apps/web/node_modules/@better-auth/core/dist/db/index.d.mts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/db/index.mjs +0 -8
- package/template/apps/web/node_modules/@better-auth/core/dist/db/plugin.d.mts +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/account.d.mts +0 -28
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/account.mjs +0 -17
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/rate-limit.d.mts +0 -18
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/rate-limit.mjs +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/session.d.mts +0 -23
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/session.mjs +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/shared.d.mts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/shared.mjs +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/user.d.mts +0 -22
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/user.mjs +0 -11
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/verification.d.mts +0 -21
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/verification.mjs +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/db/type.d.mts +0 -167
- package/template/apps/web/node_modules/@better-auth/core/dist/env/color-depth.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/env/color-depth.mjs +0 -86
- package/template/apps/web/node_modules/@better-auth/core/dist/env/env-impl.d.mts +0 -32
- package/template/apps/web/node_modules/@better-auth/core/dist/env/env-impl.mjs +0 -81
- package/template/apps/web/node_modules/@better-auth/core/dist/env/index.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/env/index.mjs +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/env/logger.d.mts +0 -48
- package/template/apps/web/node_modules/@better-auth/core/dist/env/logger.mjs +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/error/codes.d.mts +0 -68
- package/template/apps/web/node_modules/@better-auth/core/dist/error/codes.mjs +0 -54
- package/template/apps/web/node_modules/@better-auth/core/dist/error/index.d.mts +0 -19
- package/template/apps/web/node_modules/@better-auth/core/dist/error/index.mjs +0 -27
- package/template/apps/web/node_modules/@better-auth/core/dist/index.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/index.mjs +0 -1
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/api.mjs +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/attributes.d.mts +0 -11
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/attributes.mjs +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/index.d.mts +0 -3
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/index.mjs +0 -3
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/noop.mjs +0 -42
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/pure.index.d.mts +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/pure.index.mjs +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/tracer.d.mts +0 -13
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/tracer.mjs +0 -53
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/client-credentials-token.d.mts +0 -56
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/client-credentials-token.mjs +0 -64
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/create-authorization-url.d.mts +0 -44
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/create-authorization-url.mjs +0 -41
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/index.d.mts +0 -8
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/index.mjs +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/oauth-provider.d.mts +0 -192
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/refresh-access-token.d.mts +0 -54
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/refresh-access-token.mjs +0 -73
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/utils.d.mts +0 -16
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/utils.mjs +0 -37
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/validate-authorization-code.d.mts +0 -85
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/validate-authorization-code.mjs +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/verify.d.mts +0 -42
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/verify.mjs +0 -92
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/apple.d.mts +0 -126
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/apple.mjs +0 -107
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/atlassian.d.mts +0 -70
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/atlassian.mjs +0 -80
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/cognito.d.mts +0 -85
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/cognito.mjs +0 -162
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/discord.d.mts +0 -124
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/discord.mjs +0 -62
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/dropbox.d.mts +0 -69
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/dropbox.mjs +0 -72
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/facebook.d.mts +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/facebook.mjs +0 -124
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/figma.d.mts +0 -61
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/figma.mjs +0 -83
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/github.d.mts +0 -102
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/github.mjs +0 -92
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/gitlab.d.mts +0 -123
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/gitlab.mjs +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/google.d.mts +0 -97
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/google.mjs +0 -109
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/huggingface.d.mts +0 -83
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/huggingface.mjs +0 -73
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/index.d.mts +0 -1834
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/index.mjs +0 -78
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kakao.d.mts +0 -161
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kakao.mjs +0 -70
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kick.d.mts +0 -73
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kick.mjs +0 -68
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/line.d.mts +0 -105
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/line.mjs +0 -110
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linear.d.mts +0 -68
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linear.mjs +0 -85
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linkedin.d.mts +0 -67
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linkedin.mjs +0 -73
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/microsoft-entra-id.d.mts +0 -174
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/microsoft-entra-id.mjs +0 -140
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/naver.d.mts +0 -92
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/naver.mjs +0 -65
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/notion.d.mts +0 -64
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/notion.mjs +0 -72
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paybin.d.mts +0 -71
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paybin.mjs +0 -81
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paypal.d.mts +0 -129
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paypal.mjs +0 -140
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/polar.d.mts +0 -74
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/polar.mjs +0 -71
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/railway.d.mts +0 -65
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/railway.mjs +0 -74
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/reddit.d.mts +0 -62
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/reddit.mjs +0 -80
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/roblox.d.mts +0 -70
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/roblox.mjs +0 -57
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/salesforce.d.mts +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/salesforce.mjs +0 -87
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/slack.d.mts +0 -83
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/slack.mjs +0 -66
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/spotify.d.mts +0 -63
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/spotify.mjs +0 -69
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/tiktok.d.mts +0 -168
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/tiktok.mjs +0 -60
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitch.d.mts +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitch.mjs +0 -75
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitter.d.mts +0 -126
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitter.mjs +0 -85
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vercel.d.mts +0 -62
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vercel.mjs +0 -58
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vk.d.mts +0 -70
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vk.mjs +0 -81
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/wechat.d.mts +0 -113
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/wechat.mjs +0 -81
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/zoom.d.mts +0 -163
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/zoom.mjs +0 -69
- package/template/apps/web/node_modules/@better-auth/core/dist/types/context.d.mts +0 -277
- package/template/apps/web/node_modules/@better-auth/core/dist/types/cookie.d.mts +0 -15
- package/template/apps/web/node_modules/@better-auth/core/dist/types/helper.d.mts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/types/index.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/types/init-options.d.mts +0 -1358
- package/template/apps/web/node_modules/@better-auth/core/dist/types/plugin-client.d.mts +0 -113
- package/template/apps/web/node_modules/@better-auth/core/dist/types/plugin.d.mts +0 -124
- package/template/apps/web/node_modules/@better-auth/core/dist/types/secret.d.mts +0 -11
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/async.d.mts +0 -22
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/async.mjs +0 -32
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/db.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/db.mjs +0 -15
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/deprecate.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/deprecate.mjs +0 -16
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/error-codes.d.mts +0 -13
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/error-codes.mjs +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/fetch-metadata.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/fetch-metadata.mjs +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/host.d.mts +0 -147
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/host.mjs +0 -291
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/id.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/id.mjs +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/ip.d.mts +0 -54
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/ip.mjs +0 -116
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/is-api-error.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/is-api-error.mjs +0 -8
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/json.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/json.mjs +0 -41
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/string.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/string.mjs +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/url.d.mts +0 -20
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/url.mjs +0 -31
- package/template/apps/web/node_modules/@better-auth/core/package.json +0 -193
- package/template/apps/web/node_modules/@better-auth/core/src/api/index.ts +0 -140
- package/template/apps/web/node_modules/@better-auth/core/src/async_hooks/index.ts +0 -40
- package/template/apps/web/node_modules/@better-auth/core/src/async_hooks/pure.index.ts +0 -46
- package/template/apps/web/node_modules/@better-auth/core/src/context/endpoint-context.ts +0 -50
- package/template/apps/web/node_modules/@better-auth/core/src/context/global.ts +0 -57
- package/template/apps/web/node_modules/@better-auth/core/src/context/index.ts +0 -23
- package/template/apps/web/node_modules/@better-auth/core/src/context/request-state.ts +0 -91
- package/template/apps/web/node_modules/@better-auth/core/src/context/transaction.ts +0 -136
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/factory.ts +0 -1440
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-default-field-name.ts +0 -59
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-default-model-name.ts +0 -51
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-field-attributes.ts +0 -62
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-field-name.ts +0 -43
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-id-field.ts +0 -150
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-model-name.ts +0 -36
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/index.ts +0 -567
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/types.ts +0 -132
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/utils.ts +0 -61
- package/template/apps/web/node_modules/@better-auth/core/src/db/get-tables.ts +0 -296
- package/template/apps/web/node_modules/@better-auth/core/src/db/index.ts +0 -43
- package/template/apps/web/node_modules/@better-auth/core/src/db/plugin.ts +0 -11
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/account.ts +0 -47
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/rate-limit.ts +0 -36
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/session.ts +0 -29
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/shared.ts +0 -7
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/user.ts +0 -28
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/verification.ts +0 -28
- package/template/apps/web/node_modules/@better-auth/core/src/db/type.ts +0 -333
- package/template/apps/web/node_modules/@better-auth/core/src/env/color-depth.ts +0 -172
- package/template/apps/web/node_modules/@better-auth/core/src/env/env-impl.ts +0 -124
- package/template/apps/web/node_modules/@better-auth/core/src/env/index.ts +0 -23
- package/template/apps/web/node_modules/@better-auth/core/src/env/logger.ts +0 -145
- package/template/apps/web/node_modules/@better-auth/core/src/error/codes.ts +0 -71
- package/template/apps/web/node_modules/@better-auth/core/src/error/index.ts +0 -35
- package/template/apps/web/node_modules/@better-auth/core/src/index.ts +0 -1
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/api.ts +0 -17
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/attributes.ts +0 -22
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/index.ts +0 -2
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/noop.ts +0 -74
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/pure.index.ts +0 -31
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/tracer.ts +0 -95
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/client-credentials-token.ts +0 -126
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/create-authorization-url.ts +0 -89
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/index.ts +0 -33
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/oauth-provider.ts +0 -222
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/refresh-access-token.ts +0 -157
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/utils.ts +0 -51
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/validate-authorization-code.ts +0 -180
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/verify.ts +0 -221
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/apple.ts +0 -231
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/atlassian.ts +0 -133
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/cognito.ts +0 -281
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/discord.ts +0 -170
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/dropbox.ts +0 -112
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/facebook.ts +0 -215
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/figma.ts +0 -118
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/github.ts +0 -184
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/gitlab.ts +0 -155
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/google.ts +0 -204
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/huggingface.ts +0 -119
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/index.ts +0 -132
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/kakao.ts +0 -179
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/kick.ts +0 -109
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/line.ts +0 -169
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/linear.ts +0 -121
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/linkedin.ts +0 -110
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/microsoft-entra-id.ts +0 -352
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/naver.ts +0 -113
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/notion.ts +0 -108
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/paybin.ts +0 -118
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/paypal.ts +0 -263
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/polar.ts +0 -111
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/railway.ts +0 -100
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/reddit.ts +0 -122
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/roblox.ts +0 -112
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/salesforce.ts +0 -159
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/slack.ts +0 -112
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/spotify.ts +0 -94
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/tiktok.ts +0 -211
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/twitch.ts +0 -112
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/twitter.ts +0 -199
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/vercel.ts +0 -87
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/vk.ts +0 -125
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/wechat.ts +0 -213
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/zoom.ts +0 -230
- package/template/apps/web/node_modules/@better-auth/core/src/types/context.ts +0 -415
- package/template/apps/web/node_modules/@better-auth/core/src/types/cookie.ts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/src/types/helper.ts +0 -27
- package/template/apps/web/node_modules/@better-auth/core/src/types/index.ts +0 -40
- package/template/apps/web/node_modules/@better-auth/core/src/types/init-options.ts +0 -1610
- package/template/apps/web/node_modules/@better-auth/core/src/types/plugin-client.ts +0 -129
- package/template/apps/web/node_modules/@better-auth/core/src/types/plugin.ts +0 -163
- package/template/apps/web/node_modules/@better-auth/core/src/types/secret.ts +0 -8
- package/template/apps/web/node_modules/@better-auth/core/src/utils/async.ts +0 -53
- package/template/apps/web/node_modules/@better-auth/core/src/utils/db.ts +0 -20
- package/template/apps/web/node_modules/@better-auth/core/src/utils/deprecate.ts +0 -21
- package/template/apps/web/node_modules/@better-auth/core/src/utils/error-codes.ts +0 -68
- package/template/apps/web/node_modules/@better-auth/core/src/utils/fetch-metadata.ts +0 -3
- package/template/apps/web/node_modules/@better-auth/core/src/utils/host.ts +0 -401
- package/template/apps/web/node_modules/@better-auth/core/src/utils/id.ts +0 -5
- package/template/apps/web/node_modules/@better-auth/core/src/utils/ip.ts +0 -211
- package/template/apps/web/node_modules/@better-auth/core/src/utils/is-api-error.ts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/src/utils/json.ts +0 -56
- package/template/apps/web/node_modules/@better-auth/core/src/utils/string.ts +0 -3
- package/template/apps/web/node_modules/@better-auth/core/src/utils/url.ts +0 -43
- package/template/apps/web/node_modules/@better-auth/utils/README.md +0 -384
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.cjs +0 -104
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.cts +0 -44
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.mts +0 -44
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.ts +0 -44
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.mjs +0 -101
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.cjs +0 -80
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.cts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.mts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.ts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.mjs +0 -77
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.cjs +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.cts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.mts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.ts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.mjs +0 -14
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.cjs +0 -90
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.cts +0 -19
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.mts +0 -19
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.ts +0 -19
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.mjs +0 -88
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.cjs +0 -31
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.cts +0 -7
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.mts +0 -7
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.ts +0 -7
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.mjs +0 -29
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.cjs +0 -40
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.cts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.mts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.ts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.mjs +0 -38
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.cjs +0 -58
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.cts +0 -9
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.ts +0 -9
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.mjs +0 -56
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.cjs +0 -10
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.cts +0 -3
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.mts +0 -3
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.ts +0 -3
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.mjs +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.cjs +0 -90
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.cts +0 -13
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.mts +0 -13
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.ts +0 -13
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.mjs +0 -88
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.cjs +0 -36
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.cts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.ts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.mjs +0 -33
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.cjs +0 -47
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.cts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.ts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.mjs +0 -44
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.cjs +0 -55
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.cts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.ts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.mjs +0 -53
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.cjs +0 -76
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.cts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.mts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.ts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.mjs +0 -74
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.cts +0 -22
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.mts +0 -22
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.ts +0 -22
- package/template/apps/web/node_modules/@better-auth/utils/package.json +0 -95
- package/template/apps/web/node_modules/better-call/LICENSE +0 -21
- package/template/apps/web/node_modules/better-call/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.cjs +0 -181
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.d.cts +0 -16
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.d.mts +0 -16
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.mjs +0 -178
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/client.cjs +0 -23
- package/template/apps/web/node_modules/better-call/dist/client.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/client.d.cts +0 -53
- package/template/apps/web/node_modules/better-call/dist/client.d.mts +0 -53
- package/template/apps/web/node_modules/better-call/dist/client.mjs +0 -14
- package/template/apps/web/node_modules/better-call/dist/client.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/context.cjs +0 -103
- package/template/apps/web/node_modules/better-call/dist/context.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/context.d.cts +0 -341
- package/template/apps/web/node_modules/better-call/dist/context.d.mts +0 -341
- package/template/apps/web/node_modules/better-call/dist/context.mjs +0 -103
- package/template/apps/web/node_modules/better-call/dist/context.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/cookies.cjs +0 -87
- package/template/apps/web/node_modules/better-call/dist/cookies.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/cookies.d.cts +0 -103
- package/template/apps/web/node_modules/better-call/dist/cookies.d.mts +0 -103
- package/template/apps/web/node_modules/better-call/dist/cookies.mjs +0 -84
- package/template/apps/web/node_modules/better-call/dist/cookies.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/crypto.cjs +0 -39
- package/template/apps/web/node_modules/better-call/dist/crypto.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/crypto.mjs +0 -36
- package/template/apps/web/node_modules/better-call/dist/crypto.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/endpoint.cjs +0 -70
- package/template/apps/web/node_modules/better-call/dist/endpoint.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/endpoint.d.cts +0 -475
- package/template/apps/web/node_modules/better-call/dist/endpoint.d.mts +0 -475
- package/template/apps/web/node_modules/better-call/dist/endpoint.mjs +0 -70
- package/template/apps/web/node_modules/better-call/dist/endpoint.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/error.cjs +0 -141
- package/template/apps/web/node_modules/better-call/dist/error.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/error.d.cts +0 -103
- package/template/apps/web/node_modules/better-call/dist/error.d.mts +0 -103
- package/template/apps/web/node_modules/better-call/dist/error.mjs +0 -133
- package/template/apps/web/node_modules/better-call/dist/error.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/helper.d.cts +0 -12
- package/template/apps/web/node_modules/better-call/dist/helper.d.mts +0 -12
- package/template/apps/web/node_modules/better-call/dist/index.cjs +0 -28
- package/template/apps/web/node_modules/better-call/dist/index.d.cts +0 -11
- package/template/apps/web/node_modules/better-call/dist/index.d.mts +0 -11
- package/template/apps/web/node_modules/better-call/dist/index.mjs +0 -10
- package/template/apps/web/node_modules/better-call/dist/middleware.cjs +0 -52
- package/template/apps/web/node_modules/better-call/dist/middleware.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/middleware.d.cts +0 -123
- package/template/apps/web/node_modules/better-call/dist/middleware.d.mts +0 -123
- package/template/apps/web/node_modules/better-call/dist/middleware.mjs +0 -52
- package/template/apps/web/node_modules/better-call/dist/middleware.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/node.cjs +0 -18
- package/template/apps/web/node_modules/better-call/dist/node.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/node.d.cts +0 -9
- package/template/apps/web/node_modules/better-call/dist/node.d.mts +0 -9
- package/template/apps/web/node_modules/better-call/dist/node.mjs +0 -15
- package/template/apps/web/node_modules/better-call/dist/node.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/openapi.cjs +0 -191
- package/template/apps/web/node_modules/better-call/dist/openapi.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/openapi.d.cts +0 -113
- package/template/apps/web/node_modules/better-call/dist/openapi.d.mts +0 -113
- package/template/apps/web/node_modules/better-call/dist/openapi.mjs +0 -189
- package/template/apps/web/node_modules/better-call/dist/openapi.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/router.cjs +0 -118
- package/template/apps/web/node_modules/better-call/dist/router.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/router.d.cts +0 -103
- package/template/apps/web/node_modules/better-call/dist/router.d.mts +0 -103
- package/template/apps/web/node_modules/better-call/dist/router.mjs +0 -117
- package/template/apps/web/node_modules/better-call/dist/router.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/standard-schema.d.cts +0 -59
- package/template/apps/web/node_modules/better-call/dist/standard-schema.d.mts +0 -59
- package/template/apps/web/node_modules/better-call/dist/to-response.cjs +0 -153
- package/template/apps/web/node_modules/better-call/dist/to-response.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/to-response.d.cts +0 -12
- package/template/apps/web/node_modules/better-call/dist/to-response.d.mts +0 -12
- package/template/apps/web/node_modules/better-call/dist/to-response.mjs +0 -153
- package/template/apps/web/node_modules/better-call/dist/to-response.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/utils.cjs +0 -86
- package/template/apps/web/node_modules/better-call/dist/utils.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/utils.mjs +0 -82
- package/template/apps/web/node_modules/better-call/dist/utils.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/validator.cjs +0 -58
- package/template/apps/web/node_modules/better-call/dist/validator.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/validator.mjs +0 -57
- package/template/apps/web/node_modules/better-call/dist/validator.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/package.json +0 -96
- package/template/apps/web/node_modules/set-cookie-parser/LICENSE +0 -21
- package/template/apps/web/node_modules/set-cookie-parser/README.md +0 -169
- package/template/apps/web/node_modules/set-cookie-parser/dist/.eslintrc.cjs +0 -16
- package/template/apps/web/node_modules/set-cookie-parser/dist/set-cookie.cjs +0 -260
- package/template/apps/web/node_modules/set-cookie-parser/lib/set-cookie.d.ts +0 -119
- package/template/apps/web/node_modules/set-cookie-parser/lib/set-cookie.js +0 -265
- package/template/apps/web/node_modules/set-cookie-parser/package.json +0 -61
|
@@ -1,754 +0,0 @@
|
|
|
1
|
-
import { BetterAuthError } from "../../error/index.mjs";
|
|
2
|
-
import { getAuthTables } from "../get-tables.mjs";
|
|
3
|
-
import { getColorDepth } from "../../env/color-depth.mjs";
|
|
4
|
-
import { TTY_COLORS, createLogger } from "../../env/logger.mjs";
|
|
5
|
-
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME } from "../../instrumentation/attributes.mjs";
|
|
6
|
-
import { withSpan } from "../../instrumentation/tracer.mjs";
|
|
7
|
-
import { safeJSONParse } from "../../utils/json.mjs";
|
|
8
|
-
import { initGetDefaultModelName } from "./get-default-model-name.mjs";
|
|
9
|
-
import { initGetDefaultFieldName } from "./get-default-field-name.mjs";
|
|
10
|
-
import { initGetIdField } from "./get-id-field.mjs";
|
|
11
|
-
import { initGetFieldAttributes } from "./get-field-attributes.mjs";
|
|
12
|
-
import { initGetFieldName } from "./get-field-name.mjs";
|
|
13
|
-
import { initGetModelName } from "./get-model-name.mjs";
|
|
14
|
-
import { withApplyDefault } from "./utils.mjs";
|
|
15
|
-
//#region src/db/adapter/factory.ts
|
|
16
|
-
let debugLogs = [];
|
|
17
|
-
let transactionId = -1;
|
|
18
|
-
const createAsIsTransaction = (adapter) => (fn) => fn(adapter);
|
|
19
|
-
const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (options) => {
|
|
20
|
-
const uniqueAdapterFactoryInstanceId = Math.random().toString(36).substring(2, 15);
|
|
21
|
-
const config = {
|
|
22
|
-
...cfg,
|
|
23
|
-
supportsBooleans: cfg.supportsBooleans ?? true,
|
|
24
|
-
supportsDates: cfg.supportsDates ?? true,
|
|
25
|
-
supportsJSON: cfg.supportsJSON ?? false,
|
|
26
|
-
adapterName: cfg.adapterName ?? cfg.adapterId,
|
|
27
|
-
supportsNumericIds: cfg.supportsNumericIds ?? true,
|
|
28
|
-
supportsUUIDs: cfg.supportsUUIDs ?? false,
|
|
29
|
-
supportsArrays: cfg.supportsArrays ?? false,
|
|
30
|
-
transaction: cfg.transaction ?? false,
|
|
31
|
-
disableTransformInput: cfg.disableTransformInput ?? false,
|
|
32
|
-
disableTransformOutput: cfg.disableTransformOutput ?? false,
|
|
33
|
-
disableTransformJoin: cfg.disableTransformJoin ?? false
|
|
34
|
-
};
|
|
35
|
-
if (options.advanced?.database?.generateId === "serial" && config.supportsNumericIds === false) throw new BetterAuthError(`[${config.adapterName}] Your database or database adapter does not support numeric ids. Please disable "useNumberId" in your config.`);
|
|
36
|
-
const schema = getAuthTables(options);
|
|
37
|
-
const debugLog = (...args) => {
|
|
38
|
-
if (config.debugLogs === true || typeof config.debugLogs === "object") {
|
|
39
|
-
const logger = createLogger({ level: "info" });
|
|
40
|
-
if (typeof config.debugLogs === "object" && "isRunningAdapterTests" in config.debugLogs) {
|
|
41
|
-
if (config.debugLogs.isRunningAdapterTests) {
|
|
42
|
-
args.shift();
|
|
43
|
-
debugLogs.push({
|
|
44
|
-
instance: uniqueAdapterFactoryInstanceId,
|
|
45
|
-
args
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (typeof config.debugLogs === "object" && config.debugLogs.logCondition && !config.debugLogs.logCondition?.()) return;
|
|
51
|
-
if (typeof args[0] === "object" && "method" in args[0]) {
|
|
52
|
-
const method = args.shift().method;
|
|
53
|
-
if (typeof config.debugLogs === "object") {
|
|
54
|
-
if (method === "create" && !config.debugLogs.create) return;
|
|
55
|
-
else if (method === "update" && !config.debugLogs.update) return;
|
|
56
|
-
else if (method === "updateMany" && !config.debugLogs.updateMany) return;
|
|
57
|
-
else if (method === "findOne" && !config.debugLogs.findOne) return;
|
|
58
|
-
else if (method === "findMany" && !config.debugLogs.findMany) return;
|
|
59
|
-
else if (method === "delete" && !config.debugLogs.delete) return;
|
|
60
|
-
else if (method === "deleteMany" && !config.debugLogs.deleteMany) return;
|
|
61
|
-
else if (method === "count" && !config.debugLogs.count) return;
|
|
62
|
-
}
|
|
63
|
-
logger.info(`[${config.adapterName}]`, ...args);
|
|
64
|
-
} else logger.info(`[${config.adapterName}]`, ...args);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const logger = createLogger(options.logger);
|
|
68
|
-
const getDefaultModelName = initGetDefaultModelName({
|
|
69
|
-
usePlural: config.usePlural,
|
|
70
|
-
schema
|
|
71
|
-
});
|
|
72
|
-
const getDefaultFieldName = initGetDefaultFieldName({
|
|
73
|
-
usePlural: config.usePlural,
|
|
74
|
-
schema
|
|
75
|
-
});
|
|
76
|
-
const getModelName = initGetModelName({
|
|
77
|
-
usePlural: config.usePlural,
|
|
78
|
-
schema
|
|
79
|
-
});
|
|
80
|
-
const getFieldName = initGetFieldName({
|
|
81
|
-
schema,
|
|
82
|
-
usePlural: config.usePlural
|
|
83
|
-
});
|
|
84
|
-
const idField = initGetIdField({
|
|
85
|
-
schema,
|
|
86
|
-
options,
|
|
87
|
-
usePlural: config.usePlural,
|
|
88
|
-
disableIdGeneration: config.disableIdGeneration,
|
|
89
|
-
customIdGenerator: config.customIdGenerator,
|
|
90
|
-
supportsUUIDs: config.supportsUUIDs
|
|
91
|
-
});
|
|
92
|
-
const getFieldAttributes = initGetFieldAttributes({
|
|
93
|
-
schema,
|
|
94
|
-
options,
|
|
95
|
-
usePlural: config.usePlural,
|
|
96
|
-
disableIdGeneration: config.disableIdGeneration,
|
|
97
|
-
customIdGenerator: config.customIdGenerator
|
|
98
|
-
});
|
|
99
|
-
const transformInput = async (data, defaultModelName, action, forceAllowId) => {
|
|
100
|
-
const transformedData = {};
|
|
101
|
-
const fields = schema[defaultModelName].fields;
|
|
102
|
-
const newMappedKeys = config.mapKeysTransformInput ?? {};
|
|
103
|
-
const useNumberId = options.advanced?.database?.generateId === "serial";
|
|
104
|
-
fields.id = idField({
|
|
105
|
-
customModelName: defaultModelName,
|
|
106
|
-
forceAllowId: forceAllowId && "id" in data
|
|
107
|
-
});
|
|
108
|
-
for (const field in fields) {
|
|
109
|
-
let value = data[field];
|
|
110
|
-
const fieldAttributes = fields[field];
|
|
111
|
-
const newFieldName = newMappedKeys[field] || fields[field].fieldName || field;
|
|
112
|
-
if (value === void 0 && (fieldAttributes.defaultValue === void 0 && !fieldAttributes.transform?.input && !(action === "update" && fieldAttributes.onUpdate) || action === "update" && !fieldAttributes.onUpdate)) continue;
|
|
113
|
-
if (fieldAttributes && fieldAttributes.type === "date" && !(value instanceof Date) && typeof value === "string") try {
|
|
114
|
-
value = new Date(value);
|
|
115
|
-
} catch {
|
|
116
|
-
logger.error("[Adapter Factory] Failed to convert string to date", {
|
|
117
|
-
value,
|
|
118
|
-
field
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
let newValue = withApplyDefault(value, fieldAttributes, action);
|
|
122
|
-
if (fieldAttributes.transform?.input) newValue = await fieldAttributes.transform.input(newValue);
|
|
123
|
-
if (fieldAttributes.references?.field === "id" && useNumberId) if (Array.isArray(newValue)) newValue = newValue.map((x) => x !== null ? Number(x) : null);
|
|
124
|
-
else newValue = newValue !== null ? Number(newValue) : null;
|
|
125
|
-
else if (config.supportsJSON === false && typeof newValue === "object" && fieldAttributes.type === "json") newValue = JSON.stringify(newValue);
|
|
126
|
-
else if (config.supportsArrays === false && Array.isArray(newValue) && (fieldAttributes.type === "string[]" || fieldAttributes.type === "number[]")) newValue = JSON.stringify(newValue);
|
|
127
|
-
else if (config.supportsDates === false && newValue instanceof Date && fieldAttributes.type === "date") newValue = newValue.toISOString();
|
|
128
|
-
else if (config.supportsBooleans === false && typeof newValue === "boolean") newValue = newValue ? 1 : 0;
|
|
129
|
-
if (config.customTransformInput) newValue = config.customTransformInput({
|
|
130
|
-
data: newValue,
|
|
131
|
-
action,
|
|
132
|
-
field: newFieldName,
|
|
133
|
-
fieldAttributes,
|
|
134
|
-
model: getModelName(defaultModelName),
|
|
135
|
-
schema,
|
|
136
|
-
options
|
|
137
|
-
});
|
|
138
|
-
if (newValue !== void 0) transformedData[newFieldName] = newValue;
|
|
139
|
-
}
|
|
140
|
-
return transformedData;
|
|
141
|
-
};
|
|
142
|
-
const transformOutput = async (data, unsafe_model, select = [], join) => {
|
|
143
|
-
const transformSingleOutput = async (data, unsafe_model, select = []) => {
|
|
144
|
-
if (!data) return null;
|
|
145
|
-
const newMappedKeys = config.mapKeysTransformOutput ?? {};
|
|
146
|
-
const transformedData = {};
|
|
147
|
-
const tableSchema = schema[getDefaultModelName(unsafe_model)].fields;
|
|
148
|
-
const idKey = Object.entries(newMappedKeys).find(([_, v]) => v === "id")?.[0];
|
|
149
|
-
tableSchema[idKey ?? "id"] = { type: options.advanced?.database?.generateId === "serial" ? "number" : "string" };
|
|
150
|
-
for (const key in tableSchema) {
|
|
151
|
-
if (select.length && !select.includes(key)) continue;
|
|
152
|
-
const field = tableSchema[key];
|
|
153
|
-
if (field) {
|
|
154
|
-
const originalKey = field.fieldName || key;
|
|
155
|
-
let newValue = data[Object.entries(newMappedKeys).find(([_, v]) => v === originalKey)?.[0] || originalKey];
|
|
156
|
-
if (field.transform?.output) newValue = await field.transform.output(newValue);
|
|
157
|
-
const newFieldName = newMappedKeys[key] || key;
|
|
158
|
-
if (originalKey === "id" || field.references?.field === "id") {
|
|
159
|
-
if (typeof newValue !== "undefined" && newValue !== null) newValue = String(newValue);
|
|
160
|
-
} else if (config.supportsJSON === false && typeof newValue === "string" && field.type === "json") newValue = safeJSONParse(newValue);
|
|
161
|
-
else if (config.supportsArrays === false && typeof newValue === "string" && (field.type === "string[]" || field.type === "number[]")) newValue = safeJSONParse(newValue);
|
|
162
|
-
else if (config.supportsDates === false && typeof newValue === "string" && field.type === "date") newValue = new Date(newValue);
|
|
163
|
-
else if (config.supportsBooleans === false && typeof newValue === "number" && field.type === "boolean") newValue = newValue === 1;
|
|
164
|
-
if (config.customTransformOutput) newValue = config.customTransformOutput({
|
|
165
|
-
data: newValue,
|
|
166
|
-
field: newFieldName,
|
|
167
|
-
fieldAttributes: field,
|
|
168
|
-
select,
|
|
169
|
-
model: getModelName(unsafe_model),
|
|
170
|
-
schema,
|
|
171
|
-
options
|
|
172
|
-
});
|
|
173
|
-
transformedData[newFieldName] = newValue;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return transformedData;
|
|
177
|
-
};
|
|
178
|
-
if (!join || Object.keys(join).length === 0) return await transformSingleOutput(data, unsafe_model, select);
|
|
179
|
-
unsafe_model = getDefaultModelName(unsafe_model);
|
|
180
|
-
const transformedData = await transformSingleOutput(data, unsafe_model, select);
|
|
181
|
-
const requiredModels = Object.entries(join).map(([model, joinConfig]) => ({
|
|
182
|
-
modelName: getModelName(model),
|
|
183
|
-
defaultModelName: getDefaultModelName(model),
|
|
184
|
-
joinConfig
|
|
185
|
-
}));
|
|
186
|
-
if (!data) return null;
|
|
187
|
-
for (const { modelName, defaultModelName, joinConfig } of requiredModels) {
|
|
188
|
-
let joinedData = await (async () => {
|
|
189
|
-
if (options.experimental?.joins) return data[modelName];
|
|
190
|
-
else return await handleFallbackJoin({
|
|
191
|
-
baseModel: unsafe_model,
|
|
192
|
-
baseData: transformedData,
|
|
193
|
-
joinModel: modelName,
|
|
194
|
-
specificJoinConfig: joinConfig
|
|
195
|
-
});
|
|
196
|
-
})();
|
|
197
|
-
if (joinedData === void 0 || joinedData === null) joinedData = joinConfig.relation === "one-to-one" ? null : [];
|
|
198
|
-
if (joinConfig.relation === "one-to-many" && !Array.isArray(joinedData)) joinedData = [joinedData];
|
|
199
|
-
const transformed = [];
|
|
200
|
-
if (Array.isArray(joinedData)) for (const item of joinedData) {
|
|
201
|
-
const transformedItem = await transformSingleOutput(item, modelName, []);
|
|
202
|
-
transformed.push(transformedItem);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
const transformedItem = await transformSingleOutput(joinedData, modelName, []);
|
|
206
|
-
transformed.push(transformedItem);
|
|
207
|
-
}
|
|
208
|
-
transformedData[defaultModelName] = (joinConfig.relation === "one-to-one" ? transformed[0] : transformed) ?? null;
|
|
209
|
-
}
|
|
210
|
-
return transformedData;
|
|
211
|
-
};
|
|
212
|
-
const transformWhereClause = ({ model, where, action }) => {
|
|
213
|
-
if (!where) return void 0;
|
|
214
|
-
const newMappedKeys = config.mapKeysTransformInput ?? {};
|
|
215
|
-
return where.map((w) => {
|
|
216
|
-
const { field: unsafe_field, value, operator = "eq", connector = "AND", mode = "sensitive" } = w;
|
|
217
|
-
if (operator === "in") {
|
|
218
|
-
if (!Array.isArray(value)) throw new BetterAuthError("Value must be an array");
|
|
219
|
-
}
|
|
220
|
-
let newValue = value;
|
|
221
|
-
const defaultModelName = getDefaultModelName(model);
|
|
222
|
-
const defaultFieldName = getDefaultFieldName({
|
|
223
|
-
field: unsafe_field,
|
|
224
|
-
model
|
|
225
|
-
});
|
|
226
|
-
const fieldName = newMappedKeys[defaultFieldName] || getFieldName({
|
|
227
|
-
field: defaultFieldName,
|
|
228
|
-
model: defaultModelName
|
|
229
|
-
});
|
|
230
|
-
const fieldAttr = getFieldAttributes({
|
|
231
|
-
field: defaultFieldName,
|
|
232
|
-
model: defaultModelName
|
|
233
|
-
});
|
|
234
|
-
const useNumberId = options.advanced?.database?.generateId === "serial";
|
|
235
|
-
if (defaultFieldName === "id" || fieldAttr.references?.field === "id") {
|
|
236
|
-
if (useNumberId) if (Array.isArray(value)) newValue = value.map(Number);
|
|
237
|
-
else newValue = Number(value);
|
|
238
|
-
}
|
|
239
|
-
if (fieldAttr.type === "date" && value instanceof Date && !config.supportsDates) newValue = value.toISOString();
|
|
240
|
-
if (fieldAttr.type === "boolean" && typeof newValue === "string") newValue = newValue === "true";
|
|
241
|
-
if (fieldAttr.type === "number") {
|
|
242
|
-
if (typeof newValue === "string" && newValue.trim() !== "") {
|
|
243
|
-
const parsed = Number(newValue);
|
|
244
|
-
if (!Number.isNaN(parsed)) newValue = parsed;
|
|
245
|
-
} else if (Array.isArray(newValue)) {
|
|
246
|
-
const parsed = newValue.map((v) => typeof v === "string" && v.trim() !== "" ? Number(v) : NaN);
|
|
247
|
-
if (parsed.every((n) => !Number.isNaN(n))) newValue = parsed;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (fieldAttr.type === "boolean" && typeof newValue === "boolean" && !config.supportsBooleans) newValue = newValue ? 1 : 0;
|
|
251
|
-
if (fieldAttr.type === "json" && typeof value === "object" && !config.supportsJSON) try {
|
|
252
|
-
newValue = JSON.stringify(value);
|
|
253
|
-
} catch (error) {
|
|
254
|
-
throw new Error(`Failed to stringify JSON value for field ${fieldName}`, { cause: error });
|
|
255
|
-
}
|
|
256
|
-
if (config.customTransformInput) newValue = config.customTransformInput({
|
|
257
|
-
data: newValue,
|
|
258
|
-
fieldAttributes: fieldAttr,
|
|
259
|
-
field: fieldName,
|
|
260
|
-
model: getModelName(model),
|
|
261
|
-
schema,
|
|
262
|
-
options,
|
|
263
|
-
action
|
|
264
|
-
});
|
|
265
|
-
return {
|
|
266
|
-
operator,
|
|
267
|
-
connector,
|
|
268
|
-
field: fieldName,
|
|
269
|
-
value: newValue,
|
|
270
|
-
mode
|
|
271
|
-
};
|
|
272
|
-
});
|
|
273
|
-
};
|
|
274
|
-
const transformJoinClause = (baseModel, unsanitizedJoin, select) => {
|
|
275
|
-
if (!unsanitizedJoin) return void 0;
|
|
276
|
-
if (Object.keys(unsanitizedJoin).length === 0) return void 0;
|
|
277
|
-
const transformedJoin = {};
|
|
278
|
-
for (const [model, join] of Object.entries(unsanitizedJoin)) {
|
|
279
|
-
if (!join) continue;
|
|
280
|
-
const defaultModelName = getDefaultModelName(model);
|
|
281
|
-
const defaultBaseModelName = getDefaultModelName(baseModel);
|
|
282
|
-
let foreignKeys = Object.entries(schema[defaultModelName].fields).filter(([field, fieldAttributes]) => fieldAttributes.references && getDefaultModelName(fieldAttributes.references.model) === defaultBaseModelName);
|
|
283
|
-
let isForwardJoin = true;
|
|
284
|
-
if (!foreignKeys.length) {
|
|
285
|
-
foreignKeys = Object.entries(schema[defaultBaseModelName].fields).filter(([field, fieldAttributes]) => fieldAttributes.references && getDefaultModelName(fieldAttributes.references.model) === defaultModelName);
|
|
286
|
-
isForwardJoin = false;
|
|
287
|
-
}
|
|
288
|
-
if (!foreignKeys.length) throw new BetterAuthError(`No foreign key found for model ${model} and base model ${baseModel} while performing join operation.`);
|
|
289
|
-
else if (foreignKeys.length > 1) throw new BetterAuthError(`Multiple foreign keys found for model ${model} and base model ${baseModel} while performing join operation. Only one foreign key is supported.`);
|
|
290
|
-
const [foreignKey, foreignKeyAttributes] = foreignKeys[0];
|
|
291
|
-
if (!foreignKeyAttributes.references) throw new BetterAuthError(`No references found for foreign key ${foreignKey} on model ${model} while performing join operation.`);
|
|
292
|
-
let from;
|
|
293
|
-
let to;
|
|
294
|
-
let requiredSelectField;
|
|
295
|
-
if (isForwardJoin) {
|
|
296
|
-
requiredSelectField = foreignKeyAttributes.references.field;
|
|
297
|
-
from = getFieldName({
|
|
298
|
-
model: baseModel,
|
|
299
|
-
field: requiredSelectField
|
|
300
|
-
});
|
|
301
|
-
to = getFieldName({
|
|
302
|
-
model,
|
|
303
|
-
field: foreignKey
|
|
304
|
-
});
|
|
305
|
-
} else {
|
|
306
|
-
requiredSelectField = foreignKey;
|
|
307
|
-
from = getFieldName({
|
|
308
|
-
model: baseModel,
|
|
309
|
-
field: requiredSelectField
|
|
310
|
-
});
|
|
311
|
-
to = getFieldName({
|
|
312
|
-
model,
|
|
313
|
-
field: foreignKeyAttributes.references.field
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
if (select && !select.includes(requiredSelectField)) select.push(requiredSelectField);
|
|
317
|
-
const isUnique = to === "id" ? true : foreignKeyAttributes.unique ?? false;
|
|
318
|
-
let limit = options.advanced?.database?.defaultFindManyLimit ?? 100;
|
|
319
|
-
if (isUnique) limit = 1;
|
|
320
|
-
else if (typeof join === "object" && typeof join.limit === "number") limit = join.limit;
|
|
321
|
-
transformedJoin[getModelName(model)] = {
|
|
322
|
-
on: {
|
|
323
|
-
from,
|
|
324
|
-
to
|
|
325
|
-
},
|
|
326
|
-
limit,
|
|
327
|
-
relation: isUnique ? "one-to-one" : "one-to-many"
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
join: transformedJoin,
|
|
332
|
-
select
|
|
333
|
-
};
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Handle joins by making separate queries and combining results (fallback for adapters that don't support native joins).
|
|
337
|
-
*/
|
|
338
|
-
const handleFallbackJoin = async ({ baseModel, baseData, joinModel, specificJoinConfig: joinConfig }) => {
|
|
339
|
-
if (!baseData) return baseData;
|
|
340
|
-
const modelName = getModelName(joinModel);
|
|
341
|
-
const field = joinConfig.on.to;
|
|
342
|
-
const value = baseData[getDefaultFieldName({
|
|
343
|
-
field: joinConfig.on.from,
|
|
344
|
-
model: baseModel
|
|
345
|
-
})];
|
|
346
|
-
if (value === null || value === void 0) return joinConfig.relation === "one-to-one" ? null : [];
|
|
347
|
-
let result;
|
|
348
|
-
const where = transformWhereClause({
|
|
349
|
-
model: modelName,
|
|
350
|
-
where: [{
|
|
351
|
-
field,
|
|
352
|
-
value,
|
|
353
|
-
operator: "eq",
|
|
354
|
-
connector: "AND"
|
|
355
|
-
}],
|
|
356
|
-
action: "findOne"
|
|
357
|
-
});
|
|
358
|
-
try {
|
|
359
|
-
if (joinConfig.relation === "one-to-one") result = await withSpan(`db findOne ${modelName}`, {
|
|
360
|
-
[ATTR_DB_OPERATION_NAME]: "findOne",
|
|
361
|
-
[ATTR_DB_COLLECTION_NAME]: modelName
|
|
362
|
-
}, () => adapterInstance.findOne({
|
|
363
|
-
model: modelName,
|
|
364
|
-
where
|
|
365
|
-
}));
|
|
366
|
-
else {
|
|
367
|
-
const limit = joinConfig.limit ?? options.advanced?.database?.defaultFindManyLimit ?? 100;
|
|
368
|
-
result = await withSpan(`db findMany ${modelName}`, {
|
|
369
|
-
[ATTR_DB_OPERATION_NAME]: "findMany",
|
|
370
|
-
[ATTR_DB_COLLECTION_NAME]: modelName
|
|
371
|
-
}, () => adapterInstance.findMany({
|
|
372
|
-
model: modelName,
|
|
373
|
-
where,
|
|
374
|
-
limit
|
|
375
|
-
}));
|
|
376
|
-
}
|
|
377
|
-
} catch (error) {
|
|
378
|
-
logger.error(`Failed to query fallback join for model ${modelName}:`, {
|
|
379
|
-
where,
|
|
380
|
-
limit: joinConfig.limit
|
|
381
|
-
});
|
|
382
|
-
console.error(error);
|
|
383
|
-
throw error;
|
|
384
|
-
}
|
|
385
|
-
return result;
|
|
386
|
-
};
|
|
387
|
-
const adapterInstance = customAdapter({
|
|
388
|
-
options,
|
|
389
|
-
schema,
|
|
390
|
-
debugLog,
|
|
391
|
-
getFieldName,
|
|
392
|
-
getModelName,
|
|
393
|
-
getDefaultModelName,
|
|
394
|
-
getDefaultFieldName,
|
|
395
|
-
getFieldAttributes,
|
|
396
|
-
transformInput,
|
|
397
|
-
transformOutput,
|
|
398
|
-
transformWhereClause
|
|
399
|
-
});
|
|
400
|
-
let lazyLoadTransaction = null;
|
|
401
|
-
const adapter = {
|
|
402
|
-
transaction: async (cb) => {
|
|
403
|
-
if (!lazyLoadTransaction) if (!config.transaction) lazyLoadTransaction = createAsIsTransaction(adapter);
|
|
404
|
-
else {
|
|
405
|
-
logger.debug(`[${config.adapterName}] - Using provided transaction implementation.`);
|
|
406
|
-
lazyLoadTransaction = config.transaction;
|
|
407
|
-
}
|
|
408
|
-
return lazyLoadTransaction(cb);
|
|
409
|
-
},
|
|
410
|
-
create: async ({ data: unsafeData, model: unsafeModel, select, forceAllowId = false }) => {
|
|
411
|
-
transactionId++;
|
|
412
|
-
const thisTransactionId = transactionId;
|
|
413
|
-
const model = getModelName(unsafeModel);
|
|
414
|
-
unsafeModel = getDefaultModelName(unsafeModel);
|
|
415
|
-
if ("id" in unsafeData && typeof unsafeData.id !== "undefined" && !forceAllowId) {
|
|
416
|
-
logger.warn(`[${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.`);
|
|
417
|
-
const stack = (/* @__PURE__ */ new Error()).stack?.split("\n").filter((_, i) => i !== 1).join("\n").replace("Error:", "Create method with `id` being called at:");
|
|
418
|
-
console.log(stack);
|
|
419
|
-
unsafeData.id = void 0;
|
|
420
|
-
}
|
|
421
|
-
debugLog({ method: "create" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 4)}`, `${formatMethod("create")} ${formatAction("Unsafe Input")}:`, {
|
|
422
|
-
model,
|
|
423
|
-
data: unsafeData
|
|
424
|
-
});
|
|
425
|
-
let data = unsafeData;
|
|
426
|
-
if (!config.disableTransformInput) data = await transformInput(unsafeData, unsafeModel, "create", forceAllowId);
|
|
427
|
-
debugLog({ method: "create" }, `${formatTransactionId(thisTransactionId)} ${formatStep(2, 4)}`, `${formatMethod("create")} ${formatAction("Parsed Input")}:`, {
|
|
428
|
-
model,
|
|
429
|
-
data
|
|
430
|
-
});
|
|
431
|
-
const res = await withSpan(`db create ${model}`, {
|
|
432
|
-
[ATTR_DB_OPERATION_NAME]: "create",
|
|
433
|
-
[ATTR_DB_COLLECTION_NAME]: model
|
|
434
|
-
}, () => adapterInstance.create({
|
|
435
|
-
data,
|
|
436
|
-
model
|
|
437
|
-
}));
|
|
438
|
-
debugLog({ method: "create" }, `${formatTransactionId(thisTransactionId)} ${formatStep(3, 4)}`, `${formatMethod("create")} ${formatAction("DB Result")}:`, {
|
|
439
|
-
model,
|
|
440
|
-
res
|
|
441
|
-
});
|
|
442
|
-
let transformed = res;
|
|
443
|
-
if (!config.disableTransformOutput) transformed = await transformOutput(res, unsafeModel, select, void 0);
|
|
444
|
-
debugLog({ method: "create" }, `${formatTransactionId(thisTransactionId)} ${formatStep(4, 4)}`, `${formatMethod("create")} ${formatAction("Parsed Result")}:`, {
|
|
445
|
-
model,
|
|
446
|
-
data: transformed
|
|
447
|
-
});
|
|
448
|
-
return transformed;
|
|
449
|
-
},
|
|
450
|
-
update: async ({ model: unsafeModel, where: unsafeWhere, update: unsafeData }) => {
|
|
451
|
-
transactionId++;
|
|
452
|
-
const thisTransactionId = transactionId;
|
|
453
|
-
unsafeModel = getDefaultModelName(unsafeModel);
|
|
454
|
-
const model = getModelName(unsafeModel);
|
|
455
|
-
const where = transformWhereClause({
|
|
456
|
-
model: unsafeModel,
|
|
457
|
-
where: unsafeWhere,
|
|
458
|
-
action: "update"
|
|
459
|
-
});
|
|
460
|
-
debugLog({ method: "update" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 4)}`, `${formatMethod("update")} ${formatAction("Unsafe Input")}:`, {
|
|
461
|
-
model,
|
|
462
|
-
data: unsafeData
|
|
463
|
-
});
|
|
464
|
-
let data = unsafeData;
|
|
465
|
-
if (!config.disableTransformInput) data = await transformInput(unsafeData, unsafeModel, "update");
|
|
466
|
-
debugLog({ method: "update" }, `${formatTransactionId(thisTransactionId)} ${formatStep(2, 4)}`, `${formatMethod("update")} ${formatAction("Parsed Input")}:`, {
|
|
467
|
-
model,
|
|
468
|
-
data
|
|
469
|
-
});
|
|
470
|
-
const res = await withSpan(`db update ${model}`, {
|
|
471
|
-
[ATTR_DB_OPERATION_NAME]: "update",
|
|
472
|
-
[ATTR_DB_COLLECTION_NAME]: model
|
|
473
|
-
}, () => adapterInstance.update({
|
|
474
|
-
model,
|
|
475
|
-
where,
|
|
476
|
-
update: data
|
|
477
|
-
}));
|
|
478
|
-
debugLog({ method: "update" }, `${formatTransactionId(thisTransactionId)} ${formatStep(3, 4)}`, `${formatMethod("update")} ${formatAction("DB Result")}:`, {
|
|
479
|
-
model,
|
|
480
|
-
data: res
|
|
481
|
-
});
|
|
482
|
-
let transformed = res;
|
|
483
|
-
if (!config.disableTransformOutput) transformed = await transformOutput(res, unsafeModel, void 0, void 0);
|
|
484
|
-
debugLog({ method: "update" }, `${formatTransactionId(thisTransactionId)} ${formatStep(4, 4)}`, `${formatMethod("update")} ${formatAction("Parsed Result")}:`, {
|
|
485
|
-
model,
|
|
486
|
-
data: transformed
|
|
487
|
-
});
|
|
488
|
-
return transformed;
|
|
489
|
-
},
|
|
490
|
-
updateMany: async ({ model: unsafeModel, where: unsafeWhere, update: unsafeData }) => {
|
|
491
|
-
transactionId++;
|
|
492
|
-
const thisTransactionId = transactionId;
|
|
493
|
-
const model = getModelName(unsafeModel);
|
|
494
|
-
const where = transformWhereClause({
|
|
495
|
-
model: unsafeModel,
|
|
496
|
-
where: unsafeWhere,
|
|
497
|
-
action: "updateMany"
|
|
498
|
-
});
|
|
499
|
-
unsafeModel = getDefaultModelName(unsafeModel);
|
|
500
|
-
debugLog({ method: "updateMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 4)}`, `${formatMethod("updateMany")} ${formatAction("Unsafe Input")}:`, {
|
|
501
|
-
model,
|
|
502
|
-
data: unsafeData
|
|
503
|
-
});
|
|
504
|
-
let data = unsafeData;
|
|
505
|
-
if (!config.disableTransformInput) data = await transformInput(unsafeData, unsafeModel, "update");
|
|
506
|
-
debugLog({ method: "updateMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(2, 4)}`, `${formatMethod("updateMany")} ${formatAction("Parsed Input")}:`, {
|
|
507
|
-
model,
|
|
508
|
-
data
|
|
509
|
-
});
|
|
510
|
-
const updatedCount = await withSpan(`db updateMany ${model}`, {
|
|
511
|
-
[ATTR_DB_OPERATION_NAME]: "updateMany",
|
|
512
|
-
[ATTR_DB_COLLECTION_NAME]: model
|
|
513
|
-
}, () => adapterInstance.updateMany({
|
|
514
|
-
model,
|
|
515
|
-
where,
|
|
516
|
-
update: data
|
|
517
|
-
}));
|
|
518
|
-
debugLog({ method: "updateMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(3, 4)}`, `${formatMethod("updateMany")} ${formatAction("DB Result")}:`, {
|
|
519
|
-
model,
|
|
520
|
-
data: updatedCount
|
|
521
|
-
});
|
|
522
|
-
debugLog({ method: "updateMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(4, 4)}`, `${formatMethod("updateMany")} ${formatAction("Parsed Result")}:`, {
|
|
523
|
-
model,
|
|
524
|
-
data: updatedCount
|
|
525
|
-
});
|
|
526
|
-
return updatedCount;
|
|
527
|
-
},
|
|
528
|
-
findOne: async ({ model: unsafeModel, where: unsafeWhere, select, join: unsafeJoin }) => {
|
|
529
|
-
transactionId++;
|
|
530
|
-
const thisTransactionId = transactionId;
|
|
531
|
-
const model = getModelName(unsafeModel);
|
|
532
|
-
const where = transformWhereClause({
|
|
533
|
-
model: unsafeModel,
|
|
534
|
-
where: unsafeWhere,
|
|
535
|
-
action: "findOne"
|
|
536
|
-
});
|
|
537
|
-
unsafeModel = getDefaultModelName(unsafeModel);
|
|
538
|
-
let join;
|
|
539
|
-
let passJoinToAdapter = true;
|
|
540
|
-
if (!config.disableTransformJoin) {
|
|
541
|
-
const result = transformJoinClause(unsafeModel, unsafeJoin, select);
|
|
542
|
-
if (result) {
|
|
543
|
-
join = result.join;
|
|
544
|
-
select = result.select;
|
|
545
|
-
}
|
|
546
|
-
if (!options.experimental?.joins && join && Object.keys(join).length > 0) passJoinToAdapter = false;
|
|
547
|
-
} else join = unsafeJoin;
|
|
548
|
-
debugLog({ method: "findOne" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 3)}`, `${formatMethod("findOne")}:`, {
|
|
549
|
-
model,
|
|
550
|
-
where,
|
|
551
|
-
select,
|
|
552
|
-
join
|
|
553
|
-
});
|
|
554
|
-
const res = await withSpan(`db findOne ${model}`, {
|
|
555
|
-
[ATTR_DB_OPERATION_NAME]: "findOne",
|
|
556
|
-
[ATTR_DB_COLLECTION_NAME]: model
|
|
557
|
-
}, () => adapterInstance.findOne({
|
|
558
|
-
model,
|
|
559
|
-
where,
|
|
560
|
-
select,
|
|
561
|
-
join: passJoinToAdapter ? join : void 0
|
|
562
|
-
}));
|
|
563
|
-
debugLog({ method: "findOne" }, `${formatTransactionId(thisTransactionId)} ${formatStep(2, 3)}`, `${formatMethod("findOne")} ${formatAction("DB Result")}:`, {
|
|
564
|
-
model,
|
|
565
|
-
data: res
|
|
566
|
-
});
|
|
567
|
-
let transformed = res;
|
|
568
|
-
if (!config.disableTransformOutput) transformed = await transformOutput(res, unsafeModel, select, join);
|
|
569
|
-
debugLog({ method: "findOne" }, `${formatTransactionId(thisTransactionId)} ${formatStep(3, 3)}`, `${formatMethod("findOne")} ${formatAction("Parsed Result")}:`, {
|
|
570
|
-
model,
|
|
571
|
-
data: transformed
|
|
572
|
-
});
|
|
573
|
-
return transformed;
|
|
574
|
-
},
|
|
575
|
-
findMany: async ({ model: unsafeModel, where: unsafeWhere, limit: unsafeLimit, select, sortBy, offset, join: unsafeJoin }) => {
|
|
576
|
-
transactionId++;
|
|
577
|
-
const thisTransactionId = transactionId;
|
|
578
|
-
const limit = unsafeLimit ?? options.advanced?.database?.defaultFindManyLimit ?? 100;
|
|
579
|
-
const model = getModelName(unsafeModel);
|
|
580
|
-
const where = transformWhereClause({
|
|
581
|
-
model: unsafeModel,
|
|
582
|
-
where: unsafeWhere,
|
|
583
|
-
action: "findMany"
|
|
584
|
-
});
|
|
585
|
-
unsafeModel = getDefaultModelName(unsafeModel);
|
|
586
|
-
let join;
|
|
587
|
-
let passJoinToAdapter = true;
|
|
588
|
-
if (!config.disableTransformJoin) {
|
|
589
|
-
const result = transformJoinClause(unsafeModel, unsafeJoin, select);
|
|
590
|
-
if (result) {
|
|
591
|
-
join = result.join;
|
|
592
|
-
select = result.select;
|
|
593
|
-
}
|
|
594
|
-
if (!options.experimental?.joins && join && Object.keys(join).length > 0) passJoinToAdapter = false;
|
|
595
|
-
} else join = unsafeJoin;
|
|
596
|
-
debugLog({ method: "findMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 3)}`, `${formatMethod("findMany")}:`, {
|
|
597
|
-
model,
|
|
598
|
-
where,
|
|
599
|
-
limit,
|
|
600
|
-
sortBy,
|
|
601
|
-
offset,
|
|
602
|
-
join
|
|
603
|
-
});
|
|
604
|
-
const res = await withSpan(`db findMany ${model}`, {
|
|
605
|
-
[ATTR_DB_OPERATION_NAME]: "findMany",
|
|
606
|
-
[ATTR_DB_COLLECTION_NAME]: model
|
|
607
|
-
}, () => adapterInstance.findMany({
|
|
608
|
-
model,
|
|
609
|
-
where,
|
|
610
|
-
limit,
|
|
611
|
-
select,
|
|
612
|
-
sortBy,
|
|
613
|
-
offset,
|
|
614
|
-
join: passJoinToAdapter ? join : void 0
|
|
615
|
-
}));
|
|
616
|
-
debugLog({ method: "findMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(2, 3)}`, `${formatMethod("findMany")} ${formatAction("DB Result")}:`, {
|
|
617
|
-
model,
|
|
618
|
-
data: res
|
|
619
|
-
});
|
|
620
|
-
let transformed = res;
|
|
621
|
-
if (!config.disableTransformOutput) transformed = await Promise.all(res.map(async (r) => {
|
|
622
|
-
return await transformOutput(r, unsafeModel, void 0, join);
|
|
623
|
-
}));
|
|
624
|
-
debugLog({ method: "findMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(3, 3)}`, `${formatMethod("findMany")} ${formatAction("Parsed Result")}:`, {
|
|
625
|
-
model,
|
|
626
|
-
data: transformed
|
|
627
|
-
});
|
|
628
|
-
return transformed;
|
|
629
|
-
},
|
|
630
|
-
delete: async ({ model: unsafeModel, where: unsafeWhere }) => {
|
|
631
|
-
transactionId++;
|
|
632
|
-
const thisTransactionId = transactionId;
|
|
633
|
-
const model = getModelName(unsafeModel);
|
|
634
|
-
const where = transformWhereClause({
|
|
635
|
-
model: unsafeModel,
|
|
636
|
-
where: unsafeWhere,
|
|
637
|
-
action: "delete"
|
|
638
|
-
});
|
|
639
|
-
unsafeModel = getDefaultModelName(unsafeModel);
|
|
640
|
-
debugLog({ method: "delete" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 2)}`, `${formatMethod("delete")}:`, {
|
|
641
|
-
model,
|
|
642
|
-
where
|
|
643
|
-
});
|
|
644
|
-
await withSpan(`db delete ${model}`, {
|
|
645
|
-
[ATTR_DB_OPERATION_NAME]: "delete",
|
|
646
|
-
[ATTR_DB_COLLECTION_NAME]: model
|
|
647
|
-
}, () => adapterInstance.delete({
|
|
648
|
-
model,
|
|
649
|
-
where
|
|
650
|
-
}));
|
|
651
|
-
debugLog({ method: "delete" }, `${formatTransactionId(thisTransactionId)} ${formatStep(2, 2)}`, `${formatMethod("delete")} ${formatAction("DB Result")}:`, { model });
|
|
652
|
-
},
|
|
653
|
-
deleteMany: async ({ model: unsafeModel, where: unsafeWhere }) => {
|
|
654
|
-
transactionId++;
|
|
655
|
-
const thisTransactionId = transactionId;
|
|
656
|
-
const model = getModelName(unsafeModel);
|
|
657
|
-
const where = transformWhereClause({
|
|
658
|
-
model: unsafeModel,
|
|
659
|
-
where: unsafeWhere,
|
|
660
|
-
action: "deleteMany"
|
|
661
|
-
});
|
|
662
|
-
unsafeModel = getDefaultModelName(unsafeModel);
|
|
663
|
-
debugLog({ method: "deleteMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 2)}`, `${formatMethod("deleteMany")} ${formatAction("DeleteMany")}:`, {
|
|
664
|
-
model,
|
|
665
|
-
where
|
|
666
|
-
});
|
|
667
|
-
const res = await withSpan(`db deleteMany ${model}`, {
|
|
668
|
-
[ATTR_DB_OPERATION_NAME]: "deleteMany",
|
|
669
|
-
[ATTR_DB_COLLECTION_NAME]: model
|
|
670
|
-
}, () => adapterInstance.deleteMany({
|
|
671
|
-
model,
|
|
672
|
-
where
|
|
673
|
-
}));
|
|
674
|
-
debugLog({ method: "deleteMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(2, 2)}`, `${formatMethod("deleteMany")} ${formatAction("DB Result")}:`, {
|
|
675
|
-
model,
|
|
676
|
-
data: res
|
|
677
|
-
});
|
|
678
|
-
return res;
|
|
679
|
-
},
|
|
680
|
-
count: async ({ model: unsafeModel, where: unsafeWhere }) => {
|
|
681
|
-
transactionId++;
|
|
682
|
-
const thisTransactionId = transactionId;
|
|
683
|
-
const model = getModelName(unsafeModel);
|
|
684
|
-
const where = transformWhereClause({
|
|
685
|
-
model: unsafeModel,
|
|
686
|
-
where: unsafeWhere,
|
|
687
|
-
action: "count"
|
|
688
|
-
});
|
|
689
|
-
unsafeModel = getDefaultModelName(unsafeModel);
|
|
690
|
-
debugLog({ method: "count" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 2)}`, `${formatMethod("count")}:`, {
|
|
691
|
-
model,
|
|
692
|
-
where
|
|
693
|
-
});
|
|
694
|
-
const res = await withSpan(`db count ${model}`, {
|
|
695
|
-
[ATTR_DB_OPERATION_NAME]: "count",
|
|
696
|
-
[ATTR_DB_COLLECTION_NAME]: model
|
|
697
|
-
}, () => adapterInstance.count({
|
|
698
|
-
model,
|
|
699
|
-
where
|
|
700
|
-
}));
|
|
701
|
-
debugLog({ method: "count" }, `${formatTransactionId(thisTransactionId)} ${formatStep(2, 2)}`, `${formatMethod("count")}:`, {
|
|
702
|
-
model,
|
|
703
|
-
data: res
|
|
704
|
-
});
|
|
705
|
-
return res;
|
|
706
|
-
},
|
|
707
|
-
createSchema: adapterInstance.createSchema ? async (_, file) => {
|
|
708
|
-
const tables = getAuthTables(options);
|
|
709
|
-
if (options.secondaryStorage && !options.session?.storeSessionInDatabase) delete tables.session;
|
|
710
|
-
return adapterInstance.createSchema({
|
|
711
|
-
file,
|
|
712
|
-
tables
|
|
713
|
-
});
|
|
714
|
-
} : void 0,
|
|
715
|
-
options: {
|
|
716
|
-
adapterConfig: config,
|
|
717
|
-
...adapterInstance.options ?? {}
|
|
718
|
-
},
|
|
719
|
-
id: config.adapterId,
|
|
720
|
-
...config.debugLogs?.isRunningAdapterTests ? { adapterTestDebugLogs: {
|
|
721
|
-
resetDebugLogs() {
|
|
722
|
-
debugLogs = debugLogs.filter((log) => log.instance !== uniqueAdapterFactoryInstanceId);
|
|
723
|
-
},
|
|
724
|
-
printDebugLogs() {
|
|
725
|
-
const separator = `─`.repeat(80);
|
|
726
|
-
const logs = debugLogs.filter((log) => log.instance === uniqueAdapterFactoryInstanceId);
|
|
727
|
-
if (logs.length === 0) return;
|
|
728
|
-
const log = logs.reverse().map((log) => {
|
|
729
|
-
log.args[0] = `\n${log.args[0]}`;
|
|
730
|
-
return [...log.args, "\n"];
|
|
731
|
-
}).reduce((prev, curr) => {
|
|
732
|
-
return [...curr, ...prev];
|
|
733
|
-
}, [`\n${separator}`]);
|
|
734
|
-
console.log(...log);
|
|
735
|
-
}
|
|
736
|
-
} } : {}
|
|
737
|
-
};
|
|
738
|
-
return adapter;
|
|
739
|
-
};
|
|
740
|
-
function formatTransactionId(transactionId) {
|
|
741
|
-
if (getColorDepth() < 8) return `#${transactionId}`;
|
|
742
|
-
return `${TTY_COLORS.fg.magenta}#${transactionId}${TTY_COLORS.reset}`;
|
|
743
|
-
}
|
|
744
|
-
function formatStep(step, total) {
|
|
745
|
-
return `${TTY_COLORS.bg.black}${TTY_COLORS.fg.yellow}[${step}/${total}]${TTY_COLORS.reset}`;
|
|
746
|
-
}
|
|
747
|
-
function formatMethod(method) {
|
|
748
|
-
return `${TTY_COLORS.bright}${method}${TTY_COLORS.reset}`;
|
|
749
|
-
}
|
|
750
|
-
function formatAction(action) {
|
|
751
|
-
return `${TTY_COLORS.dim}(${action})${TTY_COLORS.reset}`;
|
|
752
|
-
}
|
|
753
|
-
//#endregion
|
|
754
|
-
export { createAdapterFactory };
|