@better-auth/core 1.7.0-rc.1 → 1.7.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.mts +28 -28
- package/dist/async_hooks/index.d.mts +0 -1
- package/dist/async_hooks/pure.index.d.mts +0 -1
- package/dist/context/endpoint-context.d.mts +1 -1
- package/dist/context/global.d.mts +0 -1
- package/dist/context/global.mjs +1 -1
- package/dist/context/request-state.d.mts +0 -1
- package/dist/context/request-state.mjs +8 -5
- package/dist/context/transaction.d.mts +8 -3
- package/dist/context/transaction.mjs +27 -10
- package/dist/db/adapter/factory.d.mts +3 -5
- package/dist/db/adapter/factory.mjs +7 -5
- package/dist/db/adapter/get-default-field-name.d.mts +2 -9
- package/dist/db/adapter/get-default-model-name.d.mts +1 -5
- package/dist/db/adapter/get-default-model-name.mjs +6 -5
- package/dist/db/adapter/get-field-attributes.d.mts +4 -11
- package/dist/db/adapter/get-field-name.d.mts +2 -9
- package/dist/db/adapter/get-id-field.d.mts +4 -12
- package/dist/db/adapter/get-model-name.d.mts +1 -5
- package/dist/db/adapter/index.d.mts +7 -32
- package/dist/db/adapter/types.d.mts +5 -17
- package/dist/db/adapter/utils.d.mts +0 -1
- package/dist/db/database-index.d.mts +44 -0
- package/dist/db/database-index.mjs +168 -0
- package/dist/db/get-tables.d.mts +7 -1
- package/dist/db/get-tables.mjs +47 -6
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs +2 -2
- package/dist/db/internal.d.mts +3 -0
- package/dist/db/internal.mjs +3 -0
- package/dist/db/plugin.d.mts +4 -3
- package/dist/db/schema/account.d.mts +16 -3
- package/dist/db/schema/account.mjs +35 -2
- package/dist/db/schema/rate-limit.d.mts +1 -1
- package/dist/db/schema/rate-limit.mjs +9 -0
- package/dist/db/schema/session.d.mts +1 -1
- package/dist/db/schema/shared.d.mts +0 -1
- package/dist/db/schema/user.d.mts +1 -1
- package/dist/db/schema/verification.d.mts +1 -1
- package/dist/db/type.d.mts +17 -9
- package/dist/env/logger.d.mts +25 -25
- package/dist/error/codes.d.mts +0 -1
- package/dist/error/index.d.mts +0 -1
- package/dist/index.d.mts +1 -1
- package/dist/instrumentation/attributes.d.mts +0 -1
- package/dist/instrumentation/pure.index.d.mts +0 -1
- package/dist/instrumentation/tracer.mjs +1 -1
- package/dist/oauth2/authorization-params.d.mts +0 -1
- package/dist/oauth2/client-assertion.d.mts +3 -13
- package/dist/oauth2/client-credentials-token.d.mts +3 -17
- package/dist/oauth2/client-credentials-token.mjs +1 -4
- package/dist/oauth2/create-authorization-url.d.mts +3 -21
- package/dist/oauth2/dpop.d.mts +2 -23
- package/dist/oauth2/dpop.mjs +1 -1
- package/dist/oauth2/index.d.mts +3 -3
- package/dist/oauth2/index.mjs +2 -2
- package/dist/oauth2/oauth-provider.d.mts +94 -36
- package/dist/oauth2/refresh-access-token.d.mts +3 -19
- package/dist/oauth2/refresh-access-token.mjs +3 -9
- package/dist/oauth2/reject-redirects.mjs +1 -1
- package/dist/oauth2/token-endpoint-auth.d.mts +0 -1
- package/dist/oauth2/utils.d.mts +0 -1
- package/dist/oauth2/utils.mjs +2 -3
- package/dist/oauth2/validate-authorization-code.d.mts +5 -29
- package/dist/oauth2/verify-id-token.d.mts +3 -2
- package/dist/oauth2/verify-id-token.mjs +3 -3
- package/dist/oauth2/verify.d.mts +18 -9
- package/dist/oauth2/verify.mjs +68 -5
- package/dist/social-providers/apple.d.mts +9 -24
- package/dist/social-providers/apple.mjs +2 -1
- package/dist/social-providers/atlassian.d.mts +18 -19
- package/dist/social-providers/atlassian.mjs +1 -1
- package/dist/social-providers/cognito.d.mts +33 -22
- package/dist/social-providers/cognito.mjs +2 -2
- package/dist/social-providers/discord.d.mts +7 -20
- package/dist/social-providers/discord.mjs +1 -1
- package/dist/social-providers/dropbox.d.mts +7 -22
- package/dist/social-providers/dropbox.mjs +1 -1
- package/dist/social-providers/facebook.d.mts +19 -27
- package/dist/social-providers/facebook.mjs +6 -17
- package/dist/social-providers/figma.d.mts +7 -22
- package/dist/social-providers/figma.mjs +1 -1
- package/dist/social-providers/github.d.mts +7 -23
- package/dist/social-providers/github.mjs +1 -1
- package/dist/social-providers/gitlab.d.mts +6 -43
- package/dist/social-providers/gitlab.mjs +1 -1
- package/dist/social-providers/google.d.mts +10 -32
- package/dist/social-providers/google.mjs +2 -1
- package/dist/social-providers/huggingface.d.mts +7 -22
- package/dist/social-providers/huggingface.mjs +1 -1
- package/dist/social-providers/index.d.mts +229 -787
- package/dist/social-providers/kakao.d.mts +8 -33
- package/dist/social-providers/kakao.mjs +1 -1
- package/dist/social-providers/kick.d.mts +7 -22
- package/dist/social-providers/kick.mjs +1 -1
- package/dist/social-providers/line.d.mts +8 -44
- package/dist/social-providers/line.mjs +4 -6
- package/dist/social-providers/linear.d.mts +7 -21
- package/dist/social-providers/linear.mjs +1 -1
- package/dist/social-providers/linkedin.d.mts +7 -21
- package/dist/social-providers/linkedin.mjs +1 -1
- package/dist/social-providers/microsoft-entra-id.d.mts +8 -18
- package/dist/social-providers/microsoft-entra-id.mjs +24 -4
- package/dist/social-providers/naver.d.mts +27 -42
- package/dist/social-providers/naver.mjs +1 -1
- package/dist/social-providers/notion.d.mts +7 -21
- package/dist/social-providers/notion.mjs +1 -1
- package/dist/social-providers/paybin.d.mts +8 -23
- package/dist/social-providers/paybin.mjs +2 -1
- package/dist/social-providers/paypal.d.mts +8 -33
- package/dist/social-providers/paypal.mjs +1 -1
- package/dist/social-providers/polar.d.mts +7 -22
- package/dist/social-providers/polar.mjs +1 -1
- package/dist/social-providers/railway.d.mts +7 -22
- package/dist/social-providers/railway.mjs +1 -1
- package/dist/social-providers/reddit.d.mts +7 -20
- package/dist/social-providers/reddit.mjs +1 -1
- package/dist/social-providers/roblox.d.mts +7 -20
- package/dist/social-providers/roblox.mjs +1 -1
- package/dist/social-providers/salesforce.d.mts +7 -22
- package/dist/social-providers/salesforce.mjs +1 -1
- package/dist/social-providers/slack.d.mts +7 -20
- package/dist/social-providers/slack.mjs +1 -1
- package/dist/social-providers/spotify.d.mts +7 -22
- package/dist/social-providers/spotify.mjs +1 -1
- package/dist/social-providers/tiktok.d.mts +10 -22
- package/dist/social-providers/tiktok.mjs +1 -1
- package/dist/social-providers/twitch.d.mts +7 -20
- package/dist/social-providers/twitch.mjs +1 -1
- package/dist/social-providers/twitter.d.mts +29 -26
- package/dist/social-providers/twitter.mjs +1 -1
- package/dist/social-providers/vercel.d.mts +7 -22
- package/dist/social-providers/vercel.mjs +1 -1
- package/dist/social-providers/vk.d.mts +8 -24
- package/dist/social-providers/vk.mjs +5 -6
- package/dist/social-providers/wechat.d.mts +7 -19
- package/dist/social-providers/wechat.mjs +1 -1
- package/dist/social-providers/zoom.d.mts +9 -25
- package/dist/social-providers/zoom.mjs +1 -1
- package/dist/types/context.d.mts +16 -9
- package/dist/types/cookie.d.mts +0 -1
- package/dist/types/helper.d.mts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/init-options.d.mts +37 -26
- package/dist/types/plugin-client.d.mts +1 -3
- package/dist/types/plugin.d.mts +2 -2
- package/dist/utils/async.d.mts +0 -1
- package/dist/utils/db.d.mts +1 -0
- package/dist/utils/deprecate.d.mts +0 -1
- package/dist/utils/error-codes.d.mts +2 -2
- package/dist/utils/host.d.mts +27 -1
- package/dist/utils/host.mjs +1 -1
- package/dist/utils/ip.d.mts +1 -0
- package/dist/utils/ip.mjs +1 -1
- package/dist/utils/is-api-error.d.mts +0 -1
- package/dist/utils/redirect-uri.d.mts +6 -2
- package/dist/utils/redirect-uri.mjs +11 -1
- package/package.json +10 -2
- package/src/context/request-state.ts +26 -6
- package/src/context/transaction.ts +37 -18
- package/src/db/adapter/factory.ts +34 -28
- package/src/db/adapter/get-default-model-name.ts +23 -14
- package/src/db/database-index.ts +351 -0
- package/src/db/get-tables.ts +89 -9
- package/src/db/index.ts +4 -0
- package/src/db/internal.ts +12 -0
- package/src/db/plugin.ts +3 -1
- package/src/db/schema/account.ts +27 -1
- package/src/db/schema/user.ts +1 -1
- package/src/db/type.ts +12 -0
- package/src/error/codes.ts +1 -0
- package/src/oauth2/index.ts +5 -0
- package/src/oauth2/oauth-provider.ts +105 -36
- package/src/oauth2/verify-id-token.ts +4 -2
- package/src/oauth2/verify.ts +121 -12
- package/src/social-providers/apple.ts +2 -1
- package/src/social-providers/atlassian.ts +1 -1
- package/src/social-providers/cognito.ts +2 -2
- package/src/social-providers/discord.ts +1 -1
- package/src/social-providers/dropbox.ts +1 -1
- package/src/social-providers/facebook.ts +21 -28
- package/src/social-providers/figma.ts +1 -1
- package/src/social-providers/github.ts +1 -1
- package/src/social-providers/gitlab.ts +1 -1
- package/src/social-providers/google.ts +2 -1
- package/src/social-providers/huggingface.ts +1 -1
- package/src/social-providers/kakao.ts +1 -1
- package/src/social-providers/kick.ts +1 -1
- package/src/social-providers/line.ts +7 -12
- package/src/social-providers/linear.ts +1 -1
- package/src/social-providers/linkedin.ts +1 -1
- package/src/social-providers/microsoft-entra-id.ts +36 -27
- package/src/social-providers/naver.ts +1 -1
- package/src/social-providers/notion.ts +1 -1
- package/src/social-providers/paybin.ts +2 -1
- package/src/social-providers/paypal.ts +1 -1
- package/src/social-providers/polar.ts +1 -1
- package/src/social-providers/railway.ts +1 -1
- package/src/social-providers/reddit.ts +1 -1
- package/src/social-providers/roblox.ts +1 -1
- package/src/social-providers/salesforce.ts +1 -1
- package/src/social-providers/slack.ts +1 -1
- package/src/social-providers/spotify.ts +1 -1
- package/src/social-providers/tiktok.ts +2 -2
- package/src/social-providers/twitch.ts +1 -1
- package/src/social-providers/twitter.ts +1 -1
- package/src/social-providers/vercel.ts +1 -1
- package/src/social-providers/vk.ts +2 -2
- package/src/social-providers/wechat.ts +1 -1
- package/src/social-providers/zoom.ts +1 -1
- package/src/types/context.ts +21 -14
- package/src/types/init-options.ts +15 -14
- package/src/utils/redirect-uri.ts +20 -0
package/dist/api/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BetterAuthDBSchema, ModelNames, SecondaryStorage } from "../db/type.mjs";
|
|
2
2
|
import { DBAdapter } from "../db/adapter/index.mjs";
|
|
3
3
|
import { createLogger } from "../env/logger.mjs";
|
|
4
|
+
import "../db/index.mjs";
|
|
4
5
|
import { AuthContext } from "../types/context.mjs";
|
|
6
|
+
import "../types/index.mjs";
|
|
5
7
|
import { OAuthProvider } from "../oauth2/oauth-provider.mjs";
|
|
6
|
-
import
|
|
8
|
+
import "../oauth2/index.mjs";
|
|
7
9
|
import { EndpointContext, EndpointOptions, StrictEndpoint } from "better-call";
|
|
8
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
9
|
-
|
|
10
10
|
//#region src/api/index.d.ts
|
|
11
11
|
/**
|
|
12
12
|
* Response headers that forbid any intermediary (proxy, CDN, browser) from
|
|
@@ -26,13 +26,13 @@ declare const NO_STORE_HEADERS: {
|
|
|
26
26
|
readonly "Cache-Control": "no-store";
|
|
27
27
|
readonly Pragma: "no-cache";
|
|
28
28
|
};
|
|
29
|
-
declare const optionsMiddleware: <InputCtx extends
|
|
29
|
+
declare const optionsMiddleware: <InputCtx extends import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>>(inputContext: InputCtx) => Promise<AuthContext>;
|
|
30
30
|
declare const createAuthMiddleware: {
|
|
31
|
-
<Options extends
|
|
31
|
+
<Options extends import("better-call").MiddlewareOptions, R>(options: Options, handler: (ctx: import("better-call").MiddlewareContext<Options, {
|
|
32
32
|
returned?: unknown | undefined;
|
|
33
33
|
responseHeaders?: Headers | undefined;
|
|
34
|
-
} &
|
|
35
|
-
options:
|
|
34
|
+
} & import("@better-auth/core").PluginContext<import("@better-auth/core").BetterAuthOptions> & import("@better-auth/core").InfoContext & {
|
|
35
|
+
options: import("@better-auth/core").BetterAuthOptions;
|
|
36
36
|
trustedOrigins: string[];
|
|
37
37
|
trustedProviders: string[];
|
|
38
38
|
isTrustedOrigin: (url: string, settings?: {
|
|
@@ -106,19 +106,19 @@ declare const createAuthMiddleware: {
|
|
|
106
106
|
} & Record<string, any>;
|
|
107
107
|
} | null) => void;
|
|
108
108
|
socialProviders: OAuthProvider[];
|
|
109
|
-
authCookies:
|
|
109
|
+
authCookies: import("@better-auth/core").BetterAuthCookies;
|
|
110
110
|
logger: ReturnType<typeof createLogger>;
|
|
111
111
|
rateLimit: {
|
|
112
112
|
enabled: boolean;
|
|
113
113
|
window: number;
|
|
114
114
|
max: number;
|
|
115
115
|
storage: "memory" | "database" | "secondary-storage";
|
|
116
|
-
} & Omit<
|
|
117
|
-
adapter: DBAdapter<
|
|
118
|
-
internalAdapter:
|
|
119
|
-
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<
|
|
116
|
+
} & Omit<import("@better-auth/core").BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
|
|
117
|
+
adapter: DBAdapter<import("@better-auth/core").BetterAuthOptions>;
|
|
118
|
+
internalAdapter: import("@better-auth/core").InternalAdapter<import("@better-auth/core").BetterAuthOptions>;
|
|
119
|
+
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-call").CookieOptions> | undefined) => import("@better-auth/core").BetterAuthCookie;
|
|
120
120
|
secret: string;
|
|
121
|
-
secretConfig: string |
|
|
121
|
+
secretConfig: string | import("@better-auth/core").SecretConfig;
|
|
122
122
|
sessionConfig: {
|
|
123
123
|
updateAge: number;
|
|
124
124
|
expiresIn: number;
|
|
@@ -143,7 +143,7 @@ declare const createAuthMiddleware: {
|
|
|
143
143
|
minPasswordLength: number;
|
|
144
144
|
maxPasswordLength: number;
|
|
145
145
|
};
|
|
146
|
-
checkPassword: (userId: string, ctx:
|
|
146
|
+
checkPassword: (userId: string, ctx: import("@better-auth/core").GenericEndpointContext<import("@better-auth/core").BetterAuthOptions>) => Promise<boolean>;
|
|
147
147
|
};
|
|
148
148
|
tables: BetterAuthDBSchema;
|
|
149
149
|
runMigrations: () => Promise<void>;
|
|
@@ -155,13 +155,13 @@ declare const createAuthMiddleware: {
|
|
|
155
155
|
skipOriginCheck: boolean | string[];
|
|
156
156
|
skipCSRFCheck: boolean;
|
|
157
157
|
runInBackground: (promise: Promise<unknown>) => void;
|
|
158
|
-
runInBackgroundOrAwait: (promise: Promise<unknown> | void) =>
|
|
159
|
-
}>) => Promise<R>): (inputContext:
|
|
160
|
-
<Options extends
|
|
158
|
+
runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("@better-auth/core").Awaitable<unknown>;
|
|
159
|
+
}>) => Promise<R>): (inputContext: import("better-call").MiddlewareInputContext<Options>) => Promise<R>;
|
|
160
|
+
<Options extends import("better-call").MiddlewareOptions, R_1>(handler: (ctx: import("better-call").MiddlewareContext<Options, {
|
|
161
161
|
returned?: unknown | undefined;
|
|
162
162
|
responseHeaders?: Headers | undefined;
|
|
163
|
-
} &
|
|
164
|
-
options:
|
|
163
|
+
} & import("@better-auth/core").PluginContext<import("@better-auth/core").BetterAuthOptions> & import("@better-auth/core").InfoContext & {
|
|
164
|
+
options: import("@better-auth/core").BetterAuthOptions;
|
|
165
165
|
trustedOrigins: string[];
|
|
166
166
|
trustedProviders: string[];
|
|
167
167
|
isTrustedOrigin: (url: string, settings?: {
|
|
@@ -235,19 +235,19 @@ declare const createAuthMiddleware: {
|
|
|
235
235
|
} & Record<string, any>;
|
|
236
236
|
} | null) => void;
|
|
237
237
|
socialProviders: OAuthProvider[];
|
|
238
|
-
authCookies:
|
|
238
|
+
authCookies: import("@better-auth/core").BetterAuthCookies;
|
|
239
239
|
logger: ReturnType<typeof createLogger>;
|
|
240
240
|
rateLimit: {
|
|
241
241
|
enabled: boolean;
|
|
242
242
|
window: number;
|
|
243
243
|
max: number;
|
|
244
244
|
storage: "memory" | "database" | "secondary-storage";
|
|
245
|
-
} & Omit<
|
|
246
|
-
adapter: DBAdapter<
|
|
247
|
-
internalAdapter:
|
|
248
|
-
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<
|
|
245
|
+
} & Omit<import("@better-auth/core").BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
|
|
246
|
+
adapter: DBAdapter<import("@better-auth/core").BetterAuthOptions>;
|
|
247
|
+
internalAdapter: import("@better-auth/core").InternalAdapter<import("@better-auth/core").BetterAuthOptions>;
|
|
248
|
+
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-call").CookieOptions> | undefined) => import("@better-auth/core").BetterAuthCookie;
|
|
249
249
|
secret: string;
|
|
250
|
-
secretConfig: string |
|
|
250
|
+
secretConfig: string | import("@better-auth/core").SecretConfig;
|
|
251
251
|
sessionConfig: {
|
|
252
252
|
updateAge: number;
|
|
253
253
|
expiresIn: number;
|
|
@@ -272,7 +272,7 @@ declare const createAuthMiddleware: {
|
|
|
272
272
|
minPasswordLength: number;
|
|
273
273
|
maxPasswordLength: number;
|
|
274
274
|
};
|
|
275
|
-
checkPassword: (userId: string, ctx:
|
|
275
|
+
checkPassword: (userId: string, ctx: import("@better-auth/core").GenericEndpointContext<import("@better-auth/core").BetterAuthOptions>) => Promise<boolean>;
|
|
276
276
|
};
|
|
277
277
|
tables: BetterAuthDBSchema;
|
|
278
278
|
runMigrations: () => Promise<void>;
|
|
@@ -284,8 +284,8 @@ declare const createAuthMiddleware: {
|
|
|
284
284
|
skipOriginCheck: boolean | string[];
|
|
285
285
|
skipCSRFCheck: boolean;
|
|
286
286
|
runInBackground: (promise: Promise<unknown>) => void;
|
|
287
|
-
runInBackgroundOrAwait: (promise: Promise<unknown> | void) =>
|
|
288
|
-
}>) => Promise<R_1>): (inputContext:
|
|
287
|
+
runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("@better-auth/core").Awaitable<unknown>;
|
|
288
|
+
}>) => Promise<R_1>): (inputContext: import("better-call").MiddlewareInputContext<Options>) => Promise<R_1>;
|
|
289
289
|
};
|
|
290
290
|
type EndpointHandler<Path extends string, Options extends EndpointOptions, R> = (context: EndpointContext<Path, Options, AuthContext>) => Promise<R>;
|
|
291
291
|
declare function createAuthEndpoint<Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: EndpointHandler<Path, Options, R>): StrictEndpoint<Path, Options, R>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthContext } from "../types/context.mjs";
|
|
2
|
+
import "../types/index.mjs";
|
|
2
3
|
import { EndpointContext, InputContext } from "better-call";
|
|
3
4
|
import { AsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
4
|
-
|
|
5
5
|
//#region src/context/endpoint-context.d.ts
|
|
6
6
|
type AuthEndpointContext = Partial<InputContext<string, any> & EndpointContext<string, any>> & {
|
|
7
7
|
context: AuthContext;
|
package/dist/context/global.mjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { __getBetterAuthGlobal } from "./global.mjs";
|
|
2
2
|
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
3
3
|
//#region src/context/request-state.ts
|
|
4
|
+
let asyncStorageInit = null;
|
|
4
5
|
const ensureAsyncStorage = async () => {
|
|
5
6
|
const betterAuthGlobal = __getBetterAuthGlobal();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const existing = betterAuthGlobal.context.requestStateAsyncStorage;
|
|
8
|
+
if (existing) return existing;
|
|
9
|
+
if (!asyncStorageInit) asyncStorageInit = getAsyncLocalStorage().then((AsyncLocalStorage) => {
|
|
10
|
+
betterAuthGlobal.context.requestStateAsyncStorage ??= new AsyncLocalStorage();
|
|
11
|
+
return betterAuthGlobal.context.requestStateAsyncStorage;
|
|
12
|
+
});
|
|
13
|
+
return asyncStorageInit;
|
|
11
14
|
};
|
|
12
15
|
async function getRequestStateAsyncLocalStorage() {
|
|
13
16
|
return ensureAsyncStorage();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DBAdapter, DBTransactionAdapter } from "../db/adapter/index.mjs";
|
|
2
2
|
import { BetterAuthOptions } from "../types/init-options.mjs";
|
|
3
|
+
import "../types/index.mjs";
|
|
3
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
-
|
|
5
5
|
//#region src/context/transaction.d.ts
|
|
6
6
|
type StoredAdapter = DBTransactionAdapter<BetterAuthOptions>;
|
|
7
7
|
type HookContext = {
|
|
@@ -17,11 +17,16 @@ type HookContext = {
|
|
|
17
17
|
declare const getCurrentDBAdapterAsyncLocalStorage: () => Promise<AsyncLocalStorage<HookContext>>;
|
|
18
18
|
declare const getCurrentAdapter: <Options extends BetterAuthOptions = BetterAuthOptions>(fallback: DBTransactionAdapter<Options>) => Promise<DBTransactionAdapter<Options>>;
|
|
19
19
|
declare const runWithAdapter: <R, Options extends BetterAuthOptions = BetterAuthOptions>(adapter: DBAdapter<Options>, fn: () => R) => Promise<R>;
|
|
20
|
-
declare const runWithTransaction: <R, Options extends BetterAuthOptions = BetterAuthOptions>(adapter: DBAdapter<Options>, fn: () => R
|
|
20
|
+
declare const runWithTransaction: <R, Options extends BetterAuthOptions = BetterAuthOptions>(adapter: DBAdapter<Options>, fn: () => R, options?: {
|
|
21
|
+
onAfterCommitHookError?: (error: unknown) => void | Promise<void>;
|
|
22
|
+
}) => Promise<R>;
|
|
21
23
|
/**
|
|
22
24
|
* Queue a hook to be executed after the current transaction commits.
|
|
23
25
|
* If not in a transaction, the hook will execute immediately.
|
|
24
26
|
*/
|
|
25
|
-
declare const queueAfterTransactionHook: (hook: () => Promise<void
|
|
27
|
+
declare const queueAfterTransactionHook: (hook: () => Promise<void>, options?: {
|
|
28
|
+
/** Handles a queued hook failure after the surrounding work has committed. */
|
|
29
|
+
onError?: (error: unknown) => void | Promise<void>;
|
|
30
|
+
}) => Promise<void>;
|
|
26
31
|
//#endregion
|
|
27
32
|
export { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, queueAfterTransactionHook, runWithAdapter, runWithTransaction };
|
|
@@ -50,7 +50,7 @@ const runWithAdapter = async (adapter, fn) => {
|
|
|
50
50
|
throw err;
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
|
-
const runWithTransaction = async (adapter, fn) => {
|
|
53
|
+
const runWithTransaction = async (adapter, fn, options) => {
|
|
54
54
|
let called = false;
|
|
55
55
|
return ensureAsyncStorage().then(async (als) => {
|
|
56
56
|
called = true;
|
|
@@ -71,8 +71,15 @@ const runWithTransaction = async (adapter, fn) => {
|
|
|
71
71
|
hasError = true;
|
|
72
72
|
error = e;
|
|
73
73
|
}
|
|
74
|
-
for (const hook of pendingHooks) await hook();
|
|
75
74
|
if (hasError) throw error;
|
|
75
|
+
for (const hook of pendingHooks) try {
|
|
76
|
+
await hook();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (!options?.onAfterCommitHookError) throw error;
|
|
79
|
+
try {
|
|
80
|
+
await options.onAfterCommitHookError(error);
|
|
81
|
+
} catch {}
|
|
82
|
+
}
|
|
76
83
|
return result;
|
|
77
84
|
}).catch((err) => {
|
|
78
85
|
if (!called) return fn();
|
|
@@ -83,14 +90,24 @@ const runWithTransaction = async (adapter, fn) => {
|
|
|
83
90
|
* Queue a hook to be executed after the current transaction commits.
|
|
84
91
|
* If not in a transaction, the hook will execute immediately.
|
|
85
92
|
*/
|
|
86
|
-
const queueAfterTransactionHook = async (hook) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
const queueAfterTransactionHook = async (hook, options) => {
|
|
94
|
+
const executeHook = async () => {
|
|
95
|
+
try {
|
|
96
|
+
await hook();
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (!options?.onError) throw error;
|
|
99
|
+
await options.onError(error);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
let storage;
|
|
103
|
+
try {
|
|
104
|
+
storage = await ensureAsyncStorage();
|
|
105
|
+
} catch {
|
|
106
|
+
return executeHook();
|
|
107
|
+
}
|
|
108
|
+
const store = storage.getStore();
|
|
109
|
+
if (!store?.isTransactionActive) return executeHook();
|
|
110
|
+
store.pendingHooks.push(executeHook);
|
|
94
111
|
};
|
|
95
112
|
//#endregion
|
|
96
113
|
export { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, queueAfterTransactionHook, runWithAdapter, runWithTransaction };
|
|
@@ -7,11 +7,9 @@ import { initGetModelName } from "./get-model-name.mjs";
|
|
|
7
7
|
import { AdapterFactoryConfig, AdapterFactoryCustomizeAdapterCreator, AdapterFactoryOptions, AdapterTestDebugLogs } from "./types.mjs";
|
|
8
8
|
import { DBAdapter } from "./index.mjs";
|
|
9
9
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
10
|
+
import "../../types/index.mjs";
|
|
10
11
|
//#region src/db/adapter/factory.d.ts
|
|
11
12
|
type AdapterFactory<Options extends BetterAuthOptions> = (options: Options) => DBAdapter<Options>;
|
|
12
|
-
declare const createAdapterFactory: <Options extends BetterAuthOptions>({
|
|
13
|
-
adapter: customAdapter,
|
|
14
|
-
config: cfg
|
|
15
|
-
}: AdapterFactoryOptions) => AdapterFactory<Options>;
|
|
13
|
+
declare const createAdapterFactory: <Options extends BetterAuthOptions>({ adapter: customAdapter, config: cfg }: AdapterFactoryOptions) => AdapterFactory<Options>;
|
|
16
14
|
//#endregion
|
|
17
|
-
export { AdapterFactory, createAdapterFactory };
|
|
15
|
+
export { AdapterFactory, AdapterFactoryConfig, AdapterFactoryCustomizeAdapterCreator, AdapterFactoryOptions, AdapterTestDebugLogs, createAdapterFactory, initGetDefaultFieldName, initGetDefaultModelName, initGetFieldAttributes, initGetFieldName, initGetIdField, initGetModelName };
|
|
@@ -187,8 +187,10 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
187
187
|
if (!data) return null;
|
|
188
188
|
for (const { modelName, defaultModelName, joinConfig } of requiredModels) {
|
|
189
189
|
let joinedData = await (async () => {
|
|
190
|
-
if (options.
|
|
191
|
-
|
|
190
|
+
if (options.advanced?.database?.joins) {
|
|
191
|
+
if (modelName in data) return data[modelName];
|
|
192
|
+
}
|
|
193
|
+
return await handleFallbackJoin({
|
|
192
194
|
baseModel: unsafe_model,
|
|
193
195
|
baseData: transformedData,
|
|
194
196
|
joinModel: modelName,
|
|
@@ -546,7 +548,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
546
548
|
join = result.join;
|
|
547
549
|
select = result.select;
|
|
548
550
|
}
|
|
549
|
-
if (!options.
|
|
551
|
+
if (!options.advanced?.database?.joins && join && Object.keys(join).length > 0) passJoinToAdapter = false;
|
|
550
552
|
} else join = unsafeJoin;
|
|
551
553
|
debugLog({ method: "findOne" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 3)}`, `${formatMethod("findOne")}:`, {
|
|
552
554
|
model,
|
|
@@ -594,7 +596,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
594
596
|
join = result.join;
|
|
595
597
|
select = result.select;
|
|
596
598
|
}
|
|
597
|
-
if (!options.
|
|
599
|
+
if (!options.advanced?.database?.joins && join && Object.keys(join).length > 0) passJoinToAdapter = false;
|
|
598
600
|
} else join = unsafeJoin;
|
|
599
601
|
debugLog({ method: "findMany" }, `${formatTransactionId(thisTransactionId)} ${formatStep(1, 3)}`, `${formatMethod("findMany")}:`, {
|
|
600
602
|
model,
|
|
@@ -839,4 +841,4 @@ function formatAction(action) {
|
|
|
839
841
|
return `${TTY_COLORS.dim}(${action})${TTY_COLORS.reset}`;
|
|
840
842
|
}
|
|
841
843
|
//#endregion
|
|
842
|
-
export { createAdapterFactory };
|
|
844
|
+
export { createAdapterFactory, initGetDefaultFieldName, initGetDefaultModelName, initGetFieldAttributes, initGetFieldName, initGetIdField, initGetModelName };
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { BetterAuthDBSchema } from "../type.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/db/adapter/get-default-field-name.d.ts
|
|
4
|
-
declare const initGetDefaultFieldName: ({
|
|
5
|
-
schema,
|
|
6
|
-
usePlural
|
|
7
|
-
}: {
|
|
3
|
+
declare const initGetDefaultFieldName: ({ schema, usePlural }: {
|
|
8
4
|
schema: BetterAuthDBSchema;
|
|
9
5
|
usePlural: boolean | undefined;
|
|
10
|
-
}) => ({
|
|
11
|
-
field,
|
|
12
|
-
model: unsafeModel
|
|
13
|
-
}: {
|
|
6
|
+
}) => ({ field, model: unsafeModel }: {
|
|
14
7
|
model: string;
|
|
15
8
|
field: string;
|
|
16
9
|
}) => string;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { BetterAuthDBSchema } from "../type.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/db/adapter/get-default-model-name.d.ts
|
|
4
|
-
declare const initGetDefaultModelName: ({
|
|
5
|
-
usePlural,
|
|
6
|
-
schema
|
|
7
|
-
}: {
|
|
3
|
+
declare const initGetDefaultModelName: ({ usePlural, schema }: {
|
|
8
4
|
usePlural: boolean | undefined;
|
|
9
5
|
schema: BetterAuthDBSchema;
|
|
10
6
|
}) => (model: string) => string;
|
|
@@ -13,14 +13,15 @@ const initGetDefaultModelName = ({ usePlural, schema }) => {
|
|
|
13
13
|
* 3. Using this function helps us get the actual model name based on the user's defined custom modelName.
|
|
14
14
|
*/
|
|
15
15
|
const getDefaultModelName = (model) => {
|
|
16
|
+
const resolve = (candidate) => {
|
|
17
|
+
if (schema[candidate]) return candidate;
|
|
18
|
+
return Object.entries(schema).find(([_, f]) => f.modelName === candidate)?.[0];
|
|
19
|
+
};
|
|
16
20
|
if (usePlural && model.charAt(model.length - 1) === "s") {
|
|
17
|
-
const
|
|
18
|
-
let m = schema[pluralessModel] ? pluralessModel : void 0;
|
|
19
|
-
if (!m) m = Object.entries(schema).find(([_, f]) => f.modelName === pluralessModel)?.[0];
|
|
21
|
+
const m = resolve(model.slice(0, -1));
|
|
20
22
|
if (m) return m;
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
if (!m) m = Object.entries(schema).find(([_, f]) => f.modelName === model)?.[0];
|
|
24
|
+
const m = resolve(model);
|
|
24
25
|
if (!m) throw new BetterAuthError(`Model "${model}" not found in schema`);
|
|
25
26
|
return m;
|
|
26
27
|
};
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { BetterAuthDBSchema, DBFieldAttribute, DBFieldType } from "../type.mjs";
|
|
2
2
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
3
|
+
import "../index.mjs";
|
|
4
|
+
import "../../types/index.mjs";
|
|
3
5
|
//#region src/db/adapter/get-field-attributes.d.ts
|
|
4
|
-
declare const initGetFieldAttributes: ({
|
|
5
|
-
usePlural,
|
|
6
|
-
schema,
|
|
7
|
-
options,
|
|
8
|
-
customIdGenerator,
|
|
9
|
-
disableIdGeneration
|
|
10
|
-
}: {
|
|
6
|
+
declare const initGetFieldAttributes: ({ usePlural, schema, options, customIdGenerator, disableIdGeneration }: {
|
|
11
7
|
usePlural?: boolean;
|
|
12
8
|
schema: BetterAuthDBSchema;
|
|
13
9
|
options: BetterAuthOptions;
|
|
@@ -15,10 +11,7 @@ declare const initGetFieldAttributes: ({
|
|
|
15
11
|
customIdGenerator?: ((props: {
|
|
16
12
|
model: string;
|
|
17
13
|
}) => string) | undefined;
|
|
18
|
-
}) => ({
|
|
19
|
-
model,
|
|
20
|
-
field
|
|
21
|
-
}: {
|
|
14
|
+
}) => ({ model, field }: {
|
|
22
15
|
model: string;
|
|
23
16
|
field: string;
|
|
24
17
|
}) => DBFieldAttribute<DBFieldType>;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { BetterAuthDBSchema } from "../type.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/db/adapter/get-field-name.d.ts
|
|
4
|
-
declare const initGetFieldName: ({
|
|
5
|
-
schema,
|
|
6
|
-
usePlural
|
|
7
|
-
}: {
|
|
3
|
+
declare const initGetFieldName: ({ schema, usePlural }: {
|
|
8
4
|
schema: BetterAuthDBSchema;
|
|
9
5
|
usePlural: boolean | undefined;
|
|
10
|
-
}) => ({
|
|
11
|
-
model: modelName,
|
|
12
|
-
field: fieldName
|
|
13
|
-
}: {
|
|
6
|
+
}) => ({ model: modelName, field: fieldName }: {
|
|
14
7
|
model: string;
|
|
15
8
|
field: string;
|
|
16
9
|
}) => string;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { BetterAuthDBSchema, DBPrimitive } from "../type.mjs";
|
|
2
2
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
3
|
+
import "../index.mjs";
|
|
4
|
+
import "../../types/index.mjs";
|
|
3
5
|
//#region src/db/adapter/get-id-field.d.ts
|
|
4
|
-
declare const initGetIdField: ({
|
|
5
|
-
usePlural,
|
|
6
|
-
schema,
|
|
7
|
-
disableIdGeneration,
|
|
8
|
-
options,
|
|
9
|
-
customIdGenerator,
|
|
10
|
-
supportsUUIDs
|
|
11
|
-
}: {
|
|
6
|
+
declare const initGetIdField: ({ usePlural, schema, disableIdGeneration, options, customIdGenerator, supportsUUIDs }: {
|
|
12
7
|
usePlural?: boolean;
|
|
13
8
|
schema: BetterAuthDBSchema;
|
|
14
9
|
options: BetterAuthOptions;
|
|
@@ -17,10 +12,7 @@ declare const initGetIdField: ({
|
|
|
17
12
|
model: string;
|
|
18
13
|
}) => string) | undefined;
|
|
19
14
|
supportsUUIDs?: boolean;
|
|
20
|
-
}) => ({
|
|
21
|
-
customModelName,
|
|
22
|
-
forceAllowId
|
|
23
|
-
}: {
|
|
15
|
+
}) => ({ customModelName, forceAllowId }: {
|
|
24
16
|
customModelName?: string;
|
|
25
17
|
forceAllowId?: boolean;
|
|
26
18
|
}) => {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { BetterAuthDBSchema } from "../type.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/db/adapter/get-model-name.d.ts
|
|
4
|
-
declare const initGetModelName: ({
|
|
5
|
-
usePlural,
|
|
6
|
-
schema
|
|
7
|
-
}: {
|
|
3
|
+
declare const initGetModelName: ({ usePlural, schema }: {
|
|
8
4
|
usePlural: boolean | undefined;
|
|
9
5
|
schema: BetterAuthDBSchema;
|
|
10
6
|
}) => (model: string) => string;
|
|
@@ -9,6 +9,7 @@ import { AdapterFactoryConfig, AdapterFactoryCustomizeAdapterCreator, AdapterFac
|
|
|
9
9
|
import { AdapterFactory, createAdapterFactory } from "./factory.mjs";
|
|
10
10
|
import { deepmerge, withApplyDefault } from "./utils.mjs";
|
|
11
11
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
12
|
+
import "../../types/index.mjs";
|
|
12
13
|
//#region src/db/adapter/index.d.ts
|
|
13
14
|
type DBAdapterDebugLogOption = boolean | {
|
|
14
15
|
/**
|
|
@@ -488,11 +489,7 @@ type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
|
488
489
|
};
|
|
489
490
|
type CleanedWhere = Required<Where>;
|
|
490
491
|
interface CustomAdapter {
|
|
491
|
-
create: <T extends Record<string, any>>({
|
|
492
|
-
data,
|
|
493
|
-
model,
|
|
494
|
-
select
|
|
495
|
-
}: {
|
|
492
|
+
create: <T extends Record<string, any>>({ data, model, select }: {
|
|
496
493
|
model: string;
|
|
497
494
|
data: T;
|
|
498
495
|
select?: string[] | undefined;
|
|
@@ -507,26 +504,13 @@ interface CustomAdapter {
|
|
|
507
504
|
where: CleanedWhere[];
|
|
508
505
|
update: Record<string, any>;
|
|
509
506
|
}) => Promise<number>;
|
|
510
|
-
findOne: <T>({
|
|
511
|
-
model,
|
|
512
|
-
where,
|
|
513
|
-
select,
|
|
514
|
-
join
|
|
515
|
-
}: {
|
|
507
|
+
findOne: <T>({ model, where, select, join }: {
|
|
516
508
|
model: string;
|
|
517
509
|
where: CleanedWhere[];
|
|
518
510
|
select?: string[] | undefined;
|
|
519
511
|
join?: JoinConfig | undefined;
|
|
520
512
|
}) => Promise<T | null>;
|
|
521
|
-
findMany: <T>({
|
|
522
|
-
model,
|
|
523
|
-
where,
|
|
524
|
-
limit,
|
|
525
|
-
select,
|
|
526
|
-
sortBy,
|
|
527
|
-
offset,
|
|
528
|
-
join
|
|
529
|
-
}: {
|
|
513
|
+
findMany: <T>({ model, where, limit, select, sortBy, offset, join }: {
|
|
530
514
|
model: string;
|
|
531
515
|
where?: CleanedWhere[] | undefined;
|
|
532
516
|
limit: number;
|
|
@@ -538,17 +522,11 @@ interface CustomAdapter {
|
|
|
538
522
|
offset?: number | undefined;
|
|
539
523
|
join?: JoinConfig | undefined;
|
|
540
524
|
}) => Promise<T[]>;
|
|
541
|
-
delete: ({
|
|
542
|
-
model,
|
|
543
|
-
where
|
|
544
|
-
}: {
|
|
525
|
+
delete: ({ model, where }: {
|
|
545
526
|
model: string;
|
|
546
527
|
where: CleanedWhere[];
|
|
547
528
|
}) => Promise<void>;
|
|
548
|
-
deleteMany: ({
|
|
549
|
-
model,
|
|
550
|
-
where
|
|
551
|
-
}: {
|
|
529
|
+
deleteMany: ({ model, where }: {
|
|
552
530
|
model: string;
|
|
553
531
|
where: CleanedWhere[];
|
|
554
532
|
}) => Promise<number>;
|
|
@@ -580,10 +558,7 @@ interface CustomAdapter {
|
|
|
580
558
|
increment: Record<string, number>;
|
|
581
559
|
set?: Record<string, unknown> | undefined;
|
|
582
560
|
}) => Promise<T | null>;
|
|
583
|
-
count: ({
|
|
584
|
-
model,
|
|
585
|
-
where
|
|
586
|
-
}: {
|
|
561
|
+
count: ({ model, where }: {
|
|
587
562
|
model: string;
|
|
588
563
|
where?: CleanedWhere[] | undefined;
|
|
589
564
|
}) => Promise<number>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BetterAuthDBSchema, DBFieldAttribute } from "../type.mjs";
|
|
2
2
|
import { CleanedWhere, CustomAdapter, DBAdapterFactoryConfig, DBTransactionAdapter, JoinConfig, Where } from "./index.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
4
|
+
import "../../types/index.mjs";
|
|
4
5
|
//#region src/db/adapter/types.d.ts
|
|
5
6
|
type AdapterFactoryOptions = {
|
|
6
7
|
config: AdapterFactoryConfig;
|
|
@@ -35,10 +36,7 @@ type AdapterFactoryCustomizeAdapterCreator = (config: {
|
|
|
35
36
|
/**
|
|
36
37
|
* Get the field name which is expected to be saved in the database based on the user's schema.
|
|
37
38
|
*/
|
|
38
|
-
getFieldName: ({
|
|
39
|
-
model,
|
|
40
|
-
field
|
|
41
|
-
}: {
|
|
39
|
+
getFieldName: ({ model, field }: {
|
|
42
40
|
model: string;
|
|
43
41
|
field: string;
|
|
44
42
|
}) => string;
|
|
@@ -66,10 +64,7 @@ type AdapterFactoryCustomizeAdapterCreator = (config: {
|
|
|
66
64
|
* 2. When using a custom fieldName, doing something like `schema[model].fields[field]` will not work.
|
|
67
65
|
*
|
|
68
66
|
*/
|
|
69
|
-
getDefaultFieldName: ({
|
|
70
|
-
model,
|
|
71
|
-
field
|
|
72
|
-
}: {
|
|
67
|
+
getDefaultFieldName: ({ model, field }: {
|
|
73
68
|
model: string;
|
|
74
69
|
field: string;
|
|
75
70
|
}) => string;
|
|
@@ -78,20 +73,13 @@ type AdapterFactoryCustomizeAdapterCreator = (config: {
|
|
|
78
73
|
*
|
|
79
74
|
* Note: any model name or field name is allowed, whether default to schema or not.
|
|
80
75
|
*/
|
|
81
|
-
getFieldAttributes: ({
|
|
82
|
-
model,
|
|
83
|
-
field
|
|
84
|
-
}: {
|
|
76
|
+
getFieldAttributes: ({ model, field }: {
|
|
85
77
|
model: string;
|
|
86
78
|
field: string;
|
|
87
79
|
}) => DBFieldAttribute;
|
|
88
80
|
transformInput: (data: Record<string, unknown>, defaultModelName: string, action: "create" | "update", forceAllowId?: boolean | undefined) => Promise<Record<string, unknown>>;
|
|
89
81
|
transformOutput: (data: Record<string, unknown>, defaultModelName: string, select?: string[] | undefined, joinConfig?: JoinConfig | undefined) => Promise<Record<string, unknown>>;
|
|
90
|
-
transformWhereClause: <W extends Where[] | undefined>({
|
|
91
|
-
model,
|
|
92
|
-
where,
|
|
93
|
-
action
|
|
94
|
-
}: {
|
|
82
|
+
transformWhereClause: <W extends Where[] | undefined>({ model, where, action }: {
|
|
95
83
|
where: W;
|
|
96
84
|
model: string;
|
|
97
85
|
action: "create" | "update" | "findOne" | "findMany" | "updateMany" | "delete" | "deleteMany" | "consumeOne" | "incrementOne" | "count";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DBFieldAttribute } from "../type.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/db/adapter/utils.d.ts
|
|
4
3
|
declare function withApplyDefault(value: any, field: DBFieldAttribute, action: "create" | "update" | "findOne" | "findMany"): any;
|
|
5
4
|
declare function deepmerge<T>(target: T, source: Partial<T>): T;
|