@better-auth/core 1.4.0-beta.20 → 1.4.0-beta.22

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.
Files changed (48) hide show
  1. package/.turbo/turbo-build.log +17 -17
  2. package/dist/api/index.d.mts +2 -2
  3. package/dist/api/index.mjs +2 -2
  4. package/dist/async_hooks/index.d.mts +1 -1
  5. package/dist/async_hooks/index.mjs +1 -1
  6. package/dist/context/index.d.mts +3 -3
  7. package/dist/context/index.mjs +2 -2
  8. package/dist/{context-Buud88Dd.mjs → context-DgQ9XGBl.mjs} +1 -1
  9. package/dist/db/adapter/index.d.mts +3 -3
  10. package/dist/db/index.d.mts +2 -2
  11. package/dist/db/index.mjs +1 -1
  12. package/dist/env/index.d.mts +1 -1
  13. package/dist/env/index.mjs +1 -1
  14. package/dist/error/index.mjs +2 -2
  15. package/dist/{error-D6EqgOXr.mjs → error-BhAKg8LX.mjs} +1 -1
  16. package/dist/{index-DSd3YwTg.d.mts → index-Duq4j0SF.d.mts} +87 -14
  17. package/dist/index.d.mts +2 -2
  18. package/dist/oauth2/index.d.mts +2 -2
  19. package/dist/oauth2/index.mjs +1 -1
  20. package/dist/social-providers/index.d.mts +2 -2
  21. package/dist/social-providers/index.mjs +15 -6
  22. package/dist/utils/index.mjs +1 -1
  23. package/package.json +1 -1
  24. package/src/api/index.ts +2 -6
  25. package/src/context/endpoint-context.ts +2 -1
  26. package/src/context/request-state.test.ts +1 -1
  27. package/src/context/request-state.ts +2 -1
  28. package/src/context/transaction.ts +2 -1
  29. package/src/db/adapter/index.ts +63 -1
  30. package/src/db/schema/account.ts +1 -1
  31. package/src/db/schema/rate-limit.ts +1 -1
  32. package/src/db/schema/session.ts +1 -1
  33. package/src/db/schema/shared.ts +1 -1
  34. package/src/db/schema/user.ts +1 -1
  35. package/src/db/schema/verification.ts +1 -1
  36. package/src/env/logger.test.ts +2 -1
  37. package/src/social-providers/index.ts +1 -1
  38. package/src/social-providers/vk.ts +1 -2
  39. package/src/social-providers/zoom.ts +17 -1
  40. package/src/types/context.ts +1 -1
  41. package/src/types/init-options.ts +15 -8
  42. package/vitest.config.ts +3 -0
  43. /package/dist/{async_hooks-BQqSywfV.mjs → async_hooks-BfRfbd1J.mjs} +0 -0
  44. /package/dist/{env-YhoEXwYv.mjs → env-DwlNAN_D.mjs} +0 -0
  45. /package/dist/{index-JSfspfWW.d.mts → index-CdubV7uy.d.mts} +0 -0
  46. /package/dist/{index-CRg-E-VF.d.mts → index-DgwIISs7.d.mts} +0 -0
  47. /package/dist/{oauth2-D4PPavcA.mjs → oauth2-D3aE32ZH.mjs} +0 -0
  48. /package/dist/{utils-BFQCAfNW.mjs → utils-C5EN75oV.mjs} +0 -0
@@ -1,14 +1,14 @@
1
1
 
2
- > @better-auth/core@1.4.0-beta.20 build /home/runner/work/better-auth/better-auth/packages/core
2
+ > @better-auth/core@1.4.0-beta.22 build /home/runner/work/better-auth/better-auth/packages/core
3
3
  > tsdown
4
4
 
5
- ℹ tsdown v0.16.0 powered by rolldown v1.0.0-beta.46
5
+ ℹ tsdown v0.16.5 powered by rolldown v1.0.0-beta.50
6
6
  ℹ Using tsdown config: /home/runner/work/better-auth/better-auth/packages/core/tsdown.config.ts
7
- ℹ entry: src/index.ts, src/async_hooks/index.ts, src/api/index.ts, src/context/index.ts, src/db/index.ts, src/env/index.ts, src/error/index.ts, src/oauth2/index.ts, src/social-providers/index.ts, src/utils/index.ts, src/db/adapter/index.ts
7
+ ℹ entry: src/index.ts, src/db/index.ts, src/db/adapter/index.ts, src/async_hooks/index.ts, src/context/index.ts, src/env/index.ts, src/oauth2/index.ts, src/api/index.ts, src/social-providers/index.ts, src/utils/index.ts, src/error/index.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ dist/social-providers/index.mjs  77.61 kB │ gzip: 10.11 kB
11
- ℹ dist/db/index.mjs  1.57 kB │ gzip: 0.49 kB
10
+ ℹ dist/social-providers/index.mjs  77.94 kB │ gzip: 10.14 kB
11
+ ℹ dist/db/index.mjs  1.58 kB │ gzip: 0.49 kB
12
12
  ℹ dist/api/index.mjs  0.83 kB │ gzip: 0.40 kB
13
13
  ℹ dist/context/index.mjs  0.74 kB │ gzip: 0.27 kB
14
14
  ℹ dist/oauth2/index.mjs  0.61 kB │ gzip: 0.24 kB
@@ -18,12 +18,12 @@
18
18
  ℹ dist/utils/index.mjs  0.09 kB │ gzip: 0.09 kB
19
19
  ℹ dist/db/adapter/index.mjs  0.01 kB │ gzip: 0.03 kB
20
20
  ℹ dist/index.mjs  0.01 kB │ gzip: 0.03 kB
21
- ℹ dist/oauth2-D4PPavcA.mjs  9.16 kB │ gzip: 2.12 kB
22
- ℹ dist/env-YhoEXwYv.mjs  7.67 kB │ gzip: 2.54 kB
23
- ℹ dist/context-Buud88Dd.mjs  3.89 kB │ gzip: 1.00 kB
24
- ℹ dist/error-D6EqgOXr.mjs  1.77 kB │ gzip: 0.79 kB
25
- ℹ dist/async_hooks-BQqSywfV.mjs  0.87 kB │ gzip: 0.46 kB
26
- ℹ dist/utils-BFQCAfNW.mjs  0.13 kB │ gzip: 0.12 kB
21
+ ℹ dist/oauth2-D3aE32ZH.mjs  9.16 kB │ gzip: 2.12 kB
22
+ ℹ dist/env-DwlNAN_D.mjs  7.67 kB │ gzip: 2.54 kB
23
+ ℹ dist/context-DgQ9XGBl.mjs  3.89 kB │ gzip: 1.00 kB
24
+ ℹ dist/error-BhAKg8LX.mjs  1.77 kB │ gzip: 0.79 kB
25
+ ℹ dist/async_hooks-BfRfbd1J.mjs  0.87 kB │ gzip: 0.46 kB
26
+ ℹ dist/utils-C5EN75oV.mjs  0.13 kB │ gzip: 0.12 kB
27
27
  ℹ dist/social-providers/index.d.mts  3.78 kB │ gzip: 1.17 kB
28
28
  ℹ dist/context/index.d.mts  3.05 kB │ gzip: 0.96 kB
29
29
  ℹ dist/error/index.d.mts  1.84 kB │ gzip: 0.72 kB
@@ -32,11 +32,11 @@
32
32
  ℹ dist/index.d.mts  0.83 kB │ gzip: 0.32 kB
33
33
  ℹ dist/oauth2/index.d.mts  0.79 kB │ gzip: 0.30 kB
34
34
  ℹ dist/env/index.d.mts  0.59 kB │ gzip: 0.30 kB
35
- ℹ dist/db/adapter/index.d.mts  0.47 kB │ gzip: 0.22 kB
35
+ ℹ dist/db/adapter/index.d.mts  0.53 kB │ gzip: 0.25 kB
36
36
  ℹ dist/api/index.d.mts  0.29 kB │ gzip: 0.16 kB
37
37
  ℹ dist/async_hooks/index.d.mts  0.14 kB │ gzip: 0.10 kB
38
- ℹ dist/index-DSd3YwTg.d.mts 201.62 kB │ gzip: 31.58 kB
39
- ℹ dist/index-JSfspfWW.d.mts  3.31 kB │ gzip: 1.11 kB
40
- ℹ dist/index-CRg-E-VF.d.mts  0.24 kB │ gzip: 0.16 kB
41
- ℹ 31 files, total: 324.50 kB
42
- ✔ Build complete in 4441ms
38
+ ℹ dist/index-Duq4j0SF.d.mts 203.73 kB │ gzip: 32.09 kB
39
+ ℹ dist/index-CdubV7uy.d.mts  3.31 kB │ gzip: 1.11 kB
40
+ ℹ dist/index-DgwIISs7.d.mts  0.24 kB │ gzip: 0.16 kB
41
+ ℹ 31 files, total: 326.99 kB
42
+ ✔ Build complete in 4755ms
@@ -1,3 +1,3 @@
1
- import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-DSd3YwTg.mjs";
2
- import "../index-JSfspfWW.mjs";
1
+ import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-Duq4j0SF.mjs";
2
+ import "../index-CdubV7uy.mjs";
3
3
  export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
@@ -1,5 +1,5 @@
1
- import "../async_hooks-BQqSywfV.mjs";
2
- import { f as runWithEndpointContext } from "../context-Buud88Dd.mjs";
1
+ import "../async_hooks-BfRfbd1J.mjs";
2
+ import { f as runWithEndpointContext } from "../context-DgQ9XGBl.mjs";
3
3
  import { createEndpoint, createMiddleware } from "better-call";
4
4
 
5
5
  //#region src/api/index.ts
@@ -1,2 +1,2 @@
1
- import { n as getAsyncLocalStorage, t as AsyncLocalStorage } from "../index-CRg-E-VF.mjs";
1
+ import { n as getAsyncLocalStorage, t as AsyncLocalStorage } from "../index-DgwIISs7.mjs";
2
2
  export { AsyncLocalStorage, getAsyncLocalStorage };
@@ -1,3 +1,3 @@
1
- import { t as getAsyncLocalStorage } from "../async_hooks-BQqSywfV.mjs";
1
+ import { t as getAsyncLocalStorage } from "../async_hooks-BfRfbd1J.mjs";
2
2
 
3
3
  export { getAsyncLocalStorage };
@@ -1,6 +1,6 @@
1
- import { Jn as DBTransactionAdapter, Un as DBAdapter, d as AuthContext } from "../index-DSd3YwTg.mjs";
2
- import "../index-JSfspfWW.mjs";
3
- import { t as AsyncLocalStorage } from "../index-CRg-E-VF.mjs";
1
+ import { Jn as DBTransactionAdapter, Un as DBAdapter, d as AuthContext } from "../index-Duq4j0SF.mjs";
2
+ import "../index-CdubV7uy.mjs";
3
+ import { t as AsyncLocalStorage } from "../index-DgwIISs7.mjs";
4
4
  import { EndpointContext, InputContext } from "better-call";
5
5
 
6
6
  //#region src/context/endpoint-context.d.ts
@@ -1,4 +1,4 @@
1
- import "../async_hooks-BQqSywfV.mjs";
2
- import { a as defineRequestState, c as hasRequestState, d as getCurrentAuthContextAsyncLocalStorage, f as runWithEndpointContext, i as runWithTransaction, l as runWithRequestState, n as getCurrentDBAdapterAsyncLocalStorage, o as getCurrentRequestState, r as runWithAdapter, s as getRequestStateAsyncLocalStorage, t as getCurrentAdapter, u as getCurrentAuthContext } from "../context-Buud88Dd.mjs";
1
+ import "../async_hooks-BfRfbd1J.mjs";
2
+ import { a as defineRequestState, c as hasRequestState, d as getCurrentAuthContextAsyncLocalStorage, f as runWithEndpointContext, i as runWithTransaction, l as runWithRequestState, n as getCurrentDBAdapterAsyncLocalStorage, o as getCurrentRequestState, r as runWithAdapter, s as getRequestStateAsyncLocalStorage, t as getCurrentAdapter, u as getCurrentAuthContext } from "../context-DgQ9XGBl.mjs";
3
3
 
4
4
  export { defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
@@ -1,4 +1,4 @@
1
- import { t as getAsyncLocalStorage } from "./async_hooks-BQqSywfV.mjs";
1
+ import { t as getAsyncLocalStorage } from "./async_hooks-BfRfbd1J.mjs";
2
2
 
3
3
  //#region src/context/endpoint-context.ts
4
4
  let currentContextAsyncStorage = null;
@@ -1,3 +1,3 @@
1
- import { Gn as DBAdapterFactoryConfig, Hn as CustomAdapter, Jn as DBTransactionAdapter, Kn as DBAdapterInstance, Un as DBAdapter, Vn as CleanedWhere, Wn as DBAdapterDebugLogOption, Yn as Where, qn as DBAdapterSchemaCreation } from "../../index-DSd3YwTg.mjs";
2
- import "../../index-JSfspfWW.mjs";
3
- export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
1
+ import { Gn as DBAdapterFactoryConfig, Hn as CustomAdapter, Jn as DBTransactionAdapter, Kn as DBAdapterInstance, Un as DBAdapter, Vn as CleanedWhere, Wn as DBAdapterDebugLogOption, Xn as JoinOption, Yn as JoinConfig, Zn as Where, qn as DBAdapterSchemaCreation } from "../../index-Duq4j0SF.mjs";
2
+ import "../../index-CdubV7uy.mjs";
3
+ export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, Where };
@@ -1,3 +1,3 @@
1
- import { $n as FieldAttributeConfig, Qn as FieldAttribute, Xn as AuthPluginSchema, Zn as BetterAuthDbSchema, _r as DBFieldType, ar as userSchema, br as SecondaryStorage, cr as sessionSchema, dr as Account, er as FieldType, fr as accountSchema, gr as DBFieldAttributeConfig, hr as DBFieldAttribute, ir as User, lr as RateLimit, mr as BetterAuthDBSchema, nr as Verification, or as coreSchema, pr as BetterAuthPluginDBSchema, rr as verificationSchema, sr as Session, tr as Primitive, ur as rateLimitSchema, vr as DBPreservedModels, yr as DBPrimitive } from "../index-DSd3YwTg.mjs";
2
- import "../index-JSfspfWW.mjs";
1
+ import { $n as BetterAuthDbSchema, Qn as AuthPluginSchema, Sr as SecondaryStorage, _r as DBFieldAttribute, ar as verificationSchema, br as DBPreservedModels, cr as coreSchema, dr as RateLimit, er as FieldAttribute, fr as rateLimitSchema, gr as BetterAuthDBSchema, hr as BetterAuthPluginDBSchema, ir as Verification, lr as Session, mr as accountSchema, nr as FieldType, or as User, pr as Account, rr as Primitive, sr as userSchema, tr as FieldAttributeConfig, ur as sessionSchema, vr as DBFieldAttributeConfig, xr as DBPrimitive, yr as DBFieldType } from "../index-Duq4j0SF.mjs";
2
+ import "../index-CdubV7uy.mjs";
3
3
  export { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
package/dist/db/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
 
3
3
  //#region src/db/schema/shared.ts
4
4
  const coreSchema = z.object({
@@ -1,2 +1,2 @@
1
- import { _ as isTest, a as TTY_COLORS, c as logger, d as EnvObject, f as env, g as isProduction, h as isDevelopment, i as Logger, l as shouldPublishLog, m as getEnvVar, n as LogHandlerParams, o as createLogger, p as getBooleanEnvVar, r as LogLevel, s as levels, t as InternalLogger, u as ENV, v as nodeENV, y as getColorDepth } from "../index-JSfspfWW.mjs";
1
+ import { _ as isTest, a as TTY_COLORS, c as logger, d as EnvObject, f as env, g as isProduction, h as isDevelopment, i as Logger, l as shouldPublishLog, m as getEnvVar, n as LogHandlerParams, o as createLogger, p as getBooleanEnvVar, r as LogLevel, s as levels, t as InternalLogger, u as ENV, v as nodeENV, y as getColorDepth } from "../index-CdubV7uy.mjs";
2
2
  export { ENV, EnvObject, InternalLogger, LogHandlerParams, LogLevel, Logger, TTY_COLORS, createLogger, env, getBooleanEnvVar, getColorDepth, getEnvVar, isDevelopment, isProduction, isTest, levels, logger, nodeENV, shouldPublishLog };
@@ -1,3 +1,3 @@
1
- import { a as shouldPublishLog, c as env, d as isDevelopment, f as isProduction, i as logger, l as getBooleanEnvVar, m as nodeENV, n as createLogger, o as getColorDepth, p as isTest, r as levels, s as ENV, t as TTY_COLORS, u as getEnvVar } from "../env-YhoEXwYv.mjs";
1
+ import { a as shouldPublishLog, c as env, d as isDevelopment, f as isProduction, i as logger, l as getBooleanEnvVar, m as nodeENV, n as createLogger, o as getColorDepth, p as isTest, r as levels, s as ENV, t as TTY_COLORS, u as getEnvVar } from "../env-DwlNAN_D.mjs";
2
2
 
3
3
  export { ENV, TTY_COLORS, createLogger, env, getBooleanEnvVar, getColorDepth, getEnvVar, isDevelopment, isProduction, isTest, levels, logger, nodeENV, shouldPublishLog };
@@ -1,4 +1,4 @@
1
- import "../utils-BFQCAfNW.mjs";
2
- import { n as BASE_ERROR_CODES, t as BetterAuthError } from "../error-D6EqgOXr.mjs";
1
+ import "../utils-C5EN75oV.mjs";
2
+ import { n as BASE_ERROR_CODES, t as BetterAuthError } from "../error-BhAKg8LX.mjs";
3
3
 
4
4
  export { BASE_ERROR_CODES, BetterAuthError };
@@ -1,4 +1,4 @@
1
- import { t as defineErrorCodes } from "./utils-BFQCAfNW.mjs";
1
+ import { t as defineErrorCodes } from "./utils-C5EN75oV.mjs";
2
2
 
3
3
  //#region src/error/codes.ts
4
4
  const BASE_ERROR_CODES = defineErrorCodes({
@@ -1,9 +1,9 @@
1
- import { i as Logger, o as createLogger } from "./index-JSfspfWW.mjs";
2
- import * as better_call0 from "better-call";
3
- import { CookieOptions, Endpoint, EndpointContext, EndpointOptions, InputContext, Middleware } from "better-call";
4
- import { z } from "zod";
1
+ import { i as Logger, o as createLogger } from "./index-CdubV7uy.mjs";
2
+ import * as z from "zod";
5
3
  import { BetterFetch, BetterFetchOption, BetterFetchPlugin } from "@better-fetch/fetch";
6
4
  import * as jose0 from "jose";
5
+ import * as better_call0 from "better-call";
6
+ import { CookieOptions, Endpoint, EndpointContext, EndpointOptions, InputContext, Middleware } from "better-call";
7
7
  import { StandardSchemaV1, StandardSchemaV1 as StandardSchemaV1$1 } from "@standard-schema/spec";
8
8
  import { Database } from "bun:sqlite";
9
9
  import { DatabaseSync } from "node:sqlite";
@@ -454,7 +454,7 @@ interface DBAdapterFactoryConfig<Options extends BetterAuthOptions = BetterAuthO
454
454
  /**
455
455
  * The action which was called from the adapter.
456
456
  */
457
- action: "create" | "update";
457
+ action: "create" | "update" | "findOne" | "findMany";
458
458
  /**
459
459
  * The model name.
460
460
  */
@@ -535,6 +535,12 @@ interface DBAdapterFactoryConfig<Options extends BetterAuthOptions = BetterAuthO
535
535
  * @default false
536
536
  */
537
537
  disableTransformInput?: boolean | undefined;
538
+ /**
539
+ * Whether to disable the transform join.
540
+ * Do not use this option unless you know what you are doing.
541
+ * @default false
542
+ */
543
+ disableTransformJoin?: boolean | undefined;
538
544
  }
539
545
  type Where = {
540
546
  /**
@@ -548,6 +554,56 @@ type Where = {
548
554
  */
549
555
  connector?: ("AND" | "OR") | undefined;
550
556
  };
557
+ /**
558
+ * JoinOption configuration for relational queries.
559
+ *
560
+ * Allows you to join related tables/models in a single query operation.
561
+ * Each key represents the name of the joined table/model, and the value
562
+ * configures how the join should be performed.
563
+ */
564
+ type JoinOption = {
565
+ [model: string]: boolean | {
566
+ limit?: number;
567
+ };
568
+ };
569
+ /**
570
+ * Once `JoinOption` has gone through the adapter factory, it will be transformed into a `JoinConfig`.
571
+ */
572
+ type JoinConfig = {
573
+ [model: string]: {
574
+ /**
575
+ * The joining column names.
576
+ */
577
+ on: {
578
+ /**
579
+ * Column name from the main table
580
+ */
581
+ from: string;
582
+ /**
583
+ * Column name from the joined table
584
+ */
585
+ to: string;
586
+ };
587
+ /**
588
+ * Limit the number of rows to return.
589
+ *
590
+ * If the relation has `unique` constraint, then this option will be ignored and limit will be set to 1.
591
+ *
592
+ * @default 100
593
+ */
594
+ limit?: number;
595
+ /**
596
+ * The relation type. Determines the ouput joined model data.
597
+ *
598
+ * `one-to-one` would have a single object in the output.
599
+ * `one-to-many` would have an array of objects in the output.
600
+ * `many-to-many` would have an array of objects in the output.
601
+ *
602
+ * @default "one-to-many"
603
+ */
604
+ relation?: "one-to-one" | "one-to-many" | "many-to-many";
605
+ };
606
+ };
551
607
  type DBTransactionAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = Omit<DBAdapter<Options>, "transaction">;
552
608
  type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
553
609
  id: string;
@@ -566,6 +622,7 @@ type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
566
622
  model: string;
567
623
  where: Where[];
568
624
  select?: string[] | undefined;
625
+ join?: JoinOption | undefined;
569
626
  }) => Promise<T | null>;
570
627
  findMany: <T>(data: {
571
628
  model: string;
@@ -576,6 +633,7 @@ type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
576
633
  direction: "asc" | "desc";
577
634
  } | undefined;
578
635
  offset?: number | undefined;
636
+ join?: JoinOption | undefined;
579
637
  }) => Promise<T[]>;
580
638
  count: (data: {
581
639
  model: string;
@@ -642,18 +700,21 @@ interface CustomAdapter {
642
700
  findOne: <T>({
643
701
  model,
644
702
  where,
645
- select
703
+ select,
704
+ join
646
705
  }: {
647
706
  model: string;
648
707
  where: CleanedWhere[];
649
708
  select?: string[] | undefined;
709
+ join?: JoinConfig | undefined;
650
710
  }) => Promise<T | null>;
651
711
  findMany: <T>({
652
712
  model,
653
713
  where,
654
714
  limit,
655
715
  sortBy,
656
- offset
716
+ offset,
717
+ join
657
718
  }: {
658
719
  model: string;
659
720
  where?: CleanedWhere[] | undefined;
@@ -663,6 +724,7 @@ interface CustomAdapter {
663
724
  direction: "asc" | "desc";
664
725
  } | undefined;
665
726
  offset?: number | undefined;
727
+ join?: JoinConfig | undefined;
666
728
  }) => Promise<T[]>;
667
729
  delete: ({
668
730
  model,
@@ -3360,6 +3422,7 @@ declare const zoom: (userOptions: ZoomOptions) => {
3360
3422
  codeVerifier?: string | undefined;
3361
3423
  deviceId?: string | undefined;
3362
3424
  }) => Promise<OAuth2Tokens>;
3425
+ refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
3363
3426
  getUserInfo(token: OAuth2Tokens & {
3364
3427
  user?: {
3365
3428
  name?: {
@@ -5252,6 +5315,7 @@ declare const socialProviders: {
5252
5315
  codeVerifier?: string | undefined;
5253
5316
  deviceId?: string | undefined;
5254
5317
  }) => Promise<OAuth2Tokens>;
5318
+ refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
5255
5319
  getUserInfo(token: OAuth2Tokens & {
5256
5320
  user?: {
5257
5321
  name?: {
@@ -6651,12 +6715,7 @@ type BetterAuthOptions = {
6651
6715
  /**
6652
6716
  * Advanced options
6653
6717
  */
6654
- advanced?: (BetterAuthAdvancedOptions & {
6655
- /**
6656
- * @deprecated Please use `database.generateId` instead.
6657
- */
6658
- generateId?: never;
6659
- }) | undefined;
6718
+ advanced?: BetterAuthAdvancedOptions | undefined;
6660
6719
  logger?: Logger | undefined;
6661
6720
  /**
6662
6721
  * allows you to define custom hooks that can be
@@ -6946,6 +7005,20 @@ type BetterAuthOptions = {
6946
7005
  */
6947
7006
  debug?: boolean;
6948
7007
  } | undefined;
7008
+ /**
7009
+ * Experimental features
7010
+ */
7011
+ experimental?: {
7012
+ /**
7013
+ * Enable experimental joins for your database adapter.
7014
+ *
7015
+ * Please read the adapter documentation for more information regarding joins before enabling this.
7016
+ * Not all adapters support joins.
7017
+ *
7018
+ * @default false
7019
+ */
7020
+ joins?: boolean;
7021
+ };
6949
7022
  };
6950
7023
  //#endregion
6951
7024
  //#region src/types/context.d.ts
@@ -7221,4 +7294,4 @@ declare const createAuthEndpoint: <Path extends string, Opts extends EndpointOpt
7221
7294
  type AuthEndpoint = ReturnType<typeof createAuthEndpoint>;
7222
7295
  type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;
7223
7296
  //#endregion
7224
- export { ZoomOptions as $, FieldAttributeConfig as $n, microsoft as $t, PayPalProfile as A, generateCodeChallenge as An, DropboxOptions as At, NaverOptions as B, ProviderOptions as Bn, SpotifyProfile as Bt, SocialProviders as C, getApplePublicKey as Cn, LinearOptions as Ct, PolarProfile as D, createAuthorizationCodeRequest as Dn, KickOptions as Dt, PolarOptions as E, BetterAuthCookies as En, linear as Et, paybin as F, clientCredentialsToken as Fn, twitter as Ft, kakao as G, DBAdapterFactoryConfig as Gn, HuggingFaceOptions as Gt, naver as H, CustomAdapter as Hn, SlackOptions as Ht, LineIdTokenPayload as I, createClientCredentialsTokenRequest as In, TwitchOptions as It, notion as J, DBTransactionAdapter as Jn, GoogleOptions as Jt, NotionOptions as K, DBAdapterInstance as Kn, HuggingFaceProfile as Kt, LineOptions as L, OAuth2Tokens as Ln, TwitchProfile as Lt, paypal as M, createRefreshAccessTokenRequest as Mn, dropbox as Mt, PaybinOptions as N, refreshAccessToken as Nn, TwitterOption as Nt, polar as O, validateAuthorizationCode as On, KickProfile as Ot, PaybinProfile as P, createAuthorizationURL as Pn, TwitterProfile as Pt, PronounOption as Q, FieldAttribute as Qn, MicrosoftOptions as Qt, LineUserInfo as R, OAuth2UserInfo as Rn, twitch as Rt, SocialProviderListEnum as S, apple as Sn, linkedin as St, socialProviders as T, LiteralUnion as Tn, LinearUser as Tt, KakaoOptions as U, DBAdapter as Un, SlackProfile as Ut, NaverProfile as V, CleanedWhere as Vn, spotify as Vt, KakaoProfile as W, DBAdapterDebugLogOption as Wn, slack as Wt, LoginType as X, AuthPluginSchema as Xn, google as Xt, AccountStatus as Y, Where as Yn, GoogleProfile as Yt, PhoneNumber as Z, BetterAuthDbSchema as Zn, MicrosoftEntraIDProfile as Zt, GenerateIdFn as _, AtlassianProfile as _n, DBFieldType as _r, GitlabOptions as _t, optionsMiddleware as a, figma as an, userSchema as ar, SalesforceOptions as at, SocialProvider as b, AppleOptions as bn, SecondaryStorage as br, LinkedInOptions as bt, BetterAuthClientPlugin as c, facebook as cn, sessionSchema as cr, RobloxOptions as ct, AuthContext as d, discord as dn, Account as dr, RedditOptions as dt, GithubOptions as en, FieldType as er, ZoomProfile as et, GenericEndpointContext as f, CognitoOptions as fn, accountSchema as fr, RedditProfile as ft, BetterAuthRateLimitOptions as g, AtlassianOptions as gn, DBFieldAttributeConfig as gr, tiktok as gt, BetterAuthOptions as h, getCognitoPublicKey as hn, DBFieldAttribute as hr, TiktokProfile as ht, createAuthMiddleware as i, FigmaProfile as in, User as ir, vk as it, PayPalTokenResponse as j, getOAuth2Tokens as jn, DropboxProfile as jt, PayPalOptions as k, validateToken as kn, kick as kt, ClientAtomListener as l, DiscordOptions as ln, RateLimit as lr, RobloxProfile as lt, BetterAuthAdvancedOptions as m, cognito as mn, BetterAuthDBSchema as mr, TiktokOptions as mt, AuthMiddleware as n, github as nn, Verification as nr, VkOption as nt, StandardSchemaV1$1 as o, FacebookOptions as on, coreSchema as or, SalesforceProfile as ot, InternalAdapter as p, CognitoProfile as pn, BetterAuthPluginDBSchema as pr, reddit as pt, NotionProfile as q, DBAdapterSchemaCreation as qn, huggingface as qt, createAuthEndpoint as r, FigmaOptions as rn, verificationSchema as rr, VkProfile as rt, BetterAuthClientOptions as s, FacebookProfile as sn, Session as sr, salesforce as st, AuthEndpoint as t, GithubProfile as tn, Primitive$1 as tr, zoom as tt, ClientStore as u, DiscordProfile as un, rateLimitSchema as ur, roblox as ut, BetterAuthPlugin as v, atlassian as vn, DBPreservedModels as vr, GitlabProfile as vt, socialProviderList as w, LiteralString as wn, LinearProfile as wt, SocialProviderList as x, AppleProfile as xn, LinkedInProfile as xt, HookEndpointContext as y, AppleNonConformUser as yn, DBPrimitive as yr, gitlab as yt, line as z, OAuthProvider as zn, SpotifyOptions as zt };
7297
+ export { ZoomOptions as $, BetterAuthDbSchema as $n, microsoft as $t, PayPalProfile as A, generateCodeChallenge as An, DropboxOptions as At, NaverOptions as B, ProviderOptions as Bn, SpotifyProfile as Bt, SocialProviders as C, getApplePublicKey as Cn, LinearOptions as Ct, PolarProfile as D, createAuthorizationCodeRequest as Dn, KickOptions as Dt, PolarOptions as E, BetterAuthCookies as En, linear as Et, paybin as F, clientCredentialsToken as Fn, twitter as Ft, kakao as G, DBAdapterFactoryConfig as Gn, HuggingFaceOptions as Gt, naver as H, CustomAdapter as Hn, SlackOptions as Ht, LineIdTokenPayload as I, createClientCredentialsTokenRequest as In, TwitchOptions as It, notion as J, DBTransactionAdapter as Jn, GoogleOptions as Jt, NotionOptions as K, DBAdapterInstance as Kn, HuggingFaceProfile as Kt, LineOptions as L, OAuth2Tokens as Ln, TwitchProfile as Lt, paypal as M, createRefreshAccessTokenRequest as Mn, dropbox as Mt, PaybinOptions as N, refreshAccessToken as Nn, TwitterOption as Nt, polar as O, validateAuthorizationCode as On, KickProfile as Ot, PaybinProfile as P, createAuthorizationURL as Pn, TwitterProfile as Pt, PronounOption as Q, AuthPluginSchema as Qn, MicrosoftOptions as Qt, LineUserInfo as R, OAuth2UserInfo as Rn, twitch as Rt, SocialProviderListEnum as S, apple as Sn, SecondaryStorage as Sr, linkedin as St, socialProviders as T, LiteralUnion as Tn, LinearUser as Tt, KakaoOptions as U, DBAdapter as Un, SlackProfile as Ut, NaverProfile as V, CleanedWhere as Vn, spotify as Vt, KakaoProfile as W, DBAdapterDebugLogOption as Wn, slack as Wt, LoginType as X, JoinOption as Xn, google as Xt, AccountStatus as Y, JoinConfig as Yn, GoogleProfile as Yt, PhoneNumber as Z, Where as Zn, MicrosoftEntraIDProfile as Zt, GenerateIdFn as _, AtlassianProfile as _n, DBFieldAttribute as _r, GitlabOptions as _t, optionsMiddleware as a, figma as an, verificationSchema as ar, SalesforceOptions as at, SocialProvider as b, AppleOptions as bn, DBPreservedModels as br, LinkedInOptions as bt, BetterAuthClientPlugin as c, facebook as cn, coreSchema as cr, RobloxOptions as ct, AuthContext as d, discord as dn, RateLimit as dr, RedditOptions as dt, GithubOptions as en, FieldAttribute as er, ZoomProfile as et, GenericEndpointContext as f, CognitoOptions as fn, rateLimitSchema as fr, RedditProfile as ft, BetterAuthRateLimitOptions as g, AtlassianOptions as gn, BetterAuthDBSchema as gr, tiktok as gt, BetterAuthOptions as h, getCognitoPublicKey as hn, BetterAuthPluginDBSchema as hr, TiktokProfile as ht, createAuthMiddleware as i, FigmaProfile as in, Verification as ir, vk as it, PayPalTokenResponse as j, getOAuth2Tokens as jn, DropboxProfile as jt, PayPalOptions as k, validateToken as kn, kick as kt, ClientAtomListener as l, DiscordOptions as ln, Session as lr, RobloxProfile as lt, BetterAuthAdvancedOptions as m, cognito as mn, accountSchema as mr, TiktokOptions as mt, AuthMiddleware as n, github as nn, FieldType as nr, VkOption as nt, StandardSchemaV1$1 as o, FacebookOptions as on, User as or, SalesforceProfile as ot, InternalAdapter as p, CognitoProfile as pn, Account as pr, reddit as pt, NotionProfile as q, DBAdapterSchemaCreation as qn, huggingface as qt, createAuthEndpoint as r, FigmaOptions as rn, Primitive$1 as rr, VkProfile as rt, BetterAuthClientOptions as s, FacebookProfile as sn, userSchema as sr, salesforce as st, AuthEndpoint as t, GithubProfile as tn, FieldAttributeConfig as tr, zoom as tt, ClientStore as u, DiscordProfile as un, sessionSchema as ur, roblox as ut, BetterAuthPlugin as v, atlassian as vn, DBFieldAttributeConfig as vr, GitlabProfile as vt, socialProviderList as w, LiteralString as wn, LinearProfile as wt, SocialProviderList as x, AppleProfile as xn, DBPrimitive as xr, LinkedInProfile as xt, HookEndpointContext as y, AppleNonConformUser as yn, DBFieldType as yr, gitlab as yt, line as z, OAuthProvider as zn, SpotifyOptions as zt };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { En as BetterAuthCookies, Tn as LiteralUnion, _ as GenerateIdFn, c as BetterAuthClientPlugin, d as AuthContext, f as GenericEndpointContext, g as BetterAuthRateLimitOptions, h as BetterAuthOptions, l as ClientAtomListener, m as BetterAuthAdvancedOptions, o as StandardSchemaV1, p as InternalAdapter, s as BetterAuthClientOptions, u as ClientStore, v as BetterAuthPlugin, wn as LiteralString, y as HookEndpointContext } from "./index-DSd3YwTg.mjs";
2
- import "./index-JSfspfWW.mjs";
1
+ import { En as BetterAuthCookies, Tn as LiteralUnion, _ as GenerateIdFn, c as BetterAuthClientPlugin, d as AuthContext, f as GenericEndpointContext, g as BetterAuthRateLimitOptions, h as BetterAuthOptions, l as ClientAtomListener, m as BetterAuthAdvancedOptions, o as StandardSchemaV1, p as InternalAdapter, s as BetterAuthClientOptions, u as ClientStore, v as BetterAuthPlugin, wn as LiteralString, y as HookEndpointContext } from "./index-Duq4j0SF.mjs";
2
+ import "./index-CdubV7uy.mjs";
3
3
  export { AuthContext, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InternalAdapter, LiteralString, LiteralUnion, StandardSchemaV1 };
@@ -1,3 +1,3 @@
1
- import { An as generateCodeChallenge, Bn as ProviderOptions, Dn as createAuthorizationCodeRequest, Fn as clientCredentialsToken, In as createClientCredentialsTokenRequest, Ln as OAuth2Tokens, Mn as createRefreshAccessTokenRequest, Nn as refreshAccessToken, On as validateAuthorizationCode, Pn as createAuthorizationURL, Rn as OAuth2UserInfo, jn as getOAuth2Tokens, kn as validateToken, zn as OAuthProvider } from "../index-DSd3YwTg.mjs";
2
- import "../index-JSfspfWW.mjs";
1
+ import { An as generateCodeChallenge, Bn as ProviderOptions, Dn as createAuthorizationCodeRequest, Fn as clientCredentialsToken, In as createClientCredentialsTokenRequest, Ln as OAuth2Tokens, Mn as createRefreshAccessTokenRequest, Nn as refreshAccessToken, On as validateAuthorizationCode, Pn as createAuthorizationURL, Rn as OAuth2UserInfo, jn as getOAuth2Tokens, kn as validateToken, zn as OAuthProvider } from "../index-Duq4j0SF.mjs";
2
+ import "../index-CdubV7uy.mjs";
3
3
  export { OAuth2Tokens, OAuth2UserInfo, OAuthProvider, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
@@ -1,3 +1,3 @@
1
- import { a as refreshAccessToken, c as getOAuth2Tokens, i as createRefreshAccessTokenRequest, l as clientCredentialsToken, n as validateAuthorizationCode, o as createAuthorizationURL, r as validateToken, s as generateCodeChallenge, t as createAuthorizationCodeRequest, u as createClientCredentialsTokenRequest } from "../oauth2-D4PPavcA.mjs";
1
+ import { a as refreshAccessToken, c as getOAuth2Tokens, i as createRefreshAccessTokenRequest, l as clientCredentialsToken, n as validateAuthorizationCode, o as createAuthorizationURL, r as validateToken, s as generateCodeChallenge, t as createAuthorizationCodeRequest, u as createClientCredentialsTokenRequest } from "../oauth2-D3aE32ZH.mjs";
2
2
 
3
3
  export { clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
@@ -1,3 +1,3 @@
1
- import { $ as ZoomOptions, $t as microsoft, A as PayPalProfile, At as DropboxOptions, B as NaverOptions, Bt as SpotifyProfile, C as SocialProviders, Cn as getApplePublicKey, Ct as LinearOptions, D as PolarProfile, Dt as KickOptions, E as PolarOptions, Et as linear, F as paybin, Ft as twitter, G as kakao, Gt as HuggingFaceOptions, H as naver, Ht as SlackOptions, I as LineIdTokenPayload, It as TwitchOptions, J as notion, Jt as GoogleOptions, K as NotionOptions, Kt as HuggingFaceProfile, L as LineOptions, Lt as TwitchProfile, M as paypal, Mt as dropbox, N as PaybinOptions, Nt as TwitterOption, O as polar, Ot as KickProfile, P as PaybinProfile, Pt as TwitterProfile, Q as PronounOption, Qt as MicrosoftOptions, R as LineUserInfo, Rt as twitch, S as SocialProviderListEnum, Sn as apple, St as linkedin, T as socialProviders, Tt as LinearUser, U as KakaoOptions, Ut as SlackProfile, V as NaverProfile, Vt as spotify, W as KakaoProfile, Wt as slack, X as LoginType, Xt as google, Y as AccountStatus, Yt as GoogleProfile, Z as PhoneNumber, Zt as MicrosoftEntraIDProfile, _n as AtlassianProfile, _t as GitlabOptions, an as figma, at as SalesforceOptions, b as SocialProvider, bn as AppleOptions, bt as LinkedInOptions, cn as facebook, ct as RobloxOptions, dn as discord, dt as RedditOptions, en as GithubOptions, et as ZoomProfile, fn as CognitoOptions, ft as RedditProfile, gn as AtlassianOptions, gt as tiktok, hn as getCognitoPublicKey, ht as TiktokProfile, in as FigmaProfile, it as vk, j as PayPalTokenResponse, jt as DropboxProfile, k as PayPalOptions, kt as kick, ln as DiscordOptions, lt as RobloxProfile, mn as cognito, mt as TiktokOptions, nn as github, nt as VkOption, on as FacebookOptions, ot as SalesforceProfile, pn as CognitoProfile, pt as reddit, q as NotionProfile, qt as huggingface, rn as FigmaOptions, rt as VkProfile, sn as FacebookProfile, st as salesforce, tn as GithubProfile, tt as zoom, un as DiscordProfile, ut as roblox, vn as atlassian, vt as GitlabProfile, w as socialProviderList, wt as LinearProfile, x as SocialProviderList, xn as AppleProfile, xt as LinkedInProfile, yn as AppleNonConformUser, yt as gitlab, z as line, zt as SpotifyOptions } from "../index-DSd3YwTg.mjs";
2
- import "../index-JSfspfWW.mjs";
1
+ import { $ as ZoomOptions, $t as microsoft, A as PayPalProfile, At as DropboxOptions, B as NaverOptions, Bt as SpotifyProfile, C as SocialProviders, Cn as getApplePublicKey, Ct as LinearOptions, D as PolarProfile, Dt as KickOptions, E as PolarOptions, Et as linear, F as paybin, Ft as twitter, G as kakao, Gt as HuggingFaceOptions, H as naver, Ht as SlackOptions, I as LineIdTokenPayload, It as TwitchOptions, J as notion, Jt as GoogleOptions, K as NotionOptions, Kt as HuggingFaceProfile, L as LineOptions, Lt as TwitchProfile, M as paypal, Mt as dropbox, N as PaybinOptions, Nt as TwitterOption, O as polar, Ot as KickProfile, P as PaybinProfile, Pt as TwitterProfile, Q as PronounOption, Qt as MicrosoftOptions, R as LineUserInfo, Rt as twitch, S as SocialProviderListEnum, Sn as apple, St as linkedin, T as socialProviders, Tt as LinearUser, U as KakaoOptions, Ut as SlackProfile, V as NaverProfile, Vt as spotify, W as KakaoProfile, Wt as slack, X as LoginType, Xt as google, Y as AccountStatus, Yt as GoogleProfile, Z as PhoneNumber, Zt as MicrosoftEntraIDProfile, _n as AtlassianProfile, _t as GitlabOptions, an as figma, at as SalesforceOptions, b as SocialProvider, bn as AppleOptions, bt as LinkedInOptions, cn as facebook, ct as RobloxOptions, dn as discord, dt as RedditOptions, en as GithubOptions, et as ZoomProfile, fn as CognitoOptions, ft as RedditProfile, gn as AtlassianOptions, gt as tiktok, hn as getCognitoPublicKey, ht as TiktokProfile, in as FigmaProfile, it as vk, j as PayPalTokenResponse, jt as DropboxProfile, k as PayPalOptions, kt as kick, ln as DiscordOptions, lt as RobloxProfile, mn as cognito, mt as TiktokOptions, nn as github, nt as VkOption, on as FacebookOptions, ot as SalesforceProfile, pn as CognitoProfile, pt as reddit, q as NotionProfile, qt as huggingface, rn as FigmaOptions, rt as VkProfile, sn as FacebookProfile, st as salesforce, tn as GithubProfile, tt as zoom, un as DiscordProfile, ut as roblox, vn as atlassian, vt as GitlabProfile, w as socialProviderList, wt as LinearProfile, x as SocialProviderList, xn as AppleProfile, xt as LinkedInProfile, yn as AppleNonConformUser, yt as gitlab, z as line, zt as SpotifyOptions } from "../index-Duq4j0SF.mjs";
2
+ import "../index-CdubV7uy.mjs";
3
3
  export { AccountStatus, AppleNonConformUser, AppleOptions, AppleProfile, AtlassianOptions, AtlassianProfile, CognitoOptions, CognitoProfile, DiscordOptions, DiscordProfile, DropboxOptions, DropboxProfile, FacebookOptions, FacebookProfile, FigmaOptions, FigmaProfile, GithubOptions, GithubProfile, GitlabOptions, GitlabProfile, GoogleOptions, GoogleProfile, HuggingFaceOptions, HuggingFaceProfile, KakaoOptions, KakaoProfile, KickOptions, KickProfile, LineIdTokenPayload, LineOptions, LineUserInfo, LinearOptions, LinearProfile, LinearUser, LinkedInOptions, LinkedInProfile, LoginType, MicrosoftEntraIDProfile, MicrosoftOptions, NaverOptions, NaverProfile, NotionOptions, NotionProfile, PayPalOptions, PayPalProfile, PayPalTokenResponse, PaybinOptions, PaybinProfile, PhoneNumber, PolarOptions, PolarProfile, PronounOption, RedditOptions, RedditProfile, RobloxOptions, RobloxProfile, SalesforceOptions, SalesforceProfile, SlackOptions, SlackProfile, SocialProvider, SocialProviderList, SocialProviderListEnum, SocialProviders, SpotifyOptions, SpotifyProfile, TiktokOptions, TiktokProfile, TwitchOptions, TwitchProfile, TwitterOption, TwitterProfile, VkOption, VkProfile, ZoomOptions, ZoomProfile, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vk, zoom };
@@ -1,12 +1,12 @@
1
- import { i as logger } from "../env-YhoEXwYv.mjs";
2
- import "../utils-BFQCAfNW.mjs";
3
- import { t as BetterAuthError } from "../error-D6EqgOXr.mjs";
4
- import { a as refreshAccessToken, c as getOAuth2Tokens, n as validateAuthorizationCode, o as createAuthorizationURL, s as generateCodeChallenge } from "../oauth2-D4PPavcA.mjs";
5
- import { APIError } from "better-call";
6
- import { z } from "zod";
1
+ import { i as logger } from "../env-DwlNAN_D.mjs";
2
+ import { a as refreshAccessToken, c as getOAuth2Tokens, n as validateAuthorizationCode, o as createAuthorizationURL, s as generateCodeChallenge } from "../oauth2-D3aE32ZH.mjs";
3
+ import "../utils-C5EN75oV.mjs";
4
+ import { t as BetterAuthError } from "../error-BhAKg8LX.mjs";
5
+ import * as z from "zod";
7
6
  import { base64 } from "@better-auth/utils/base64";
8
7
  import { betterFetch } from "@better-fetch/fetch";
9
8
  import { createRemoteJWKSet, decodeJwt, decodeProtectedHeader, importJWK, jwtVerify } from "jose";
9
+ import { APIError } from "better-call";
10
10
 
11
11
  //#region src/social-providers/apple.ts
12
12
  const apple = (options) => {
@@ -2450,6 +2450,15 @@ const zoom = (userOptions) => {
2450
2450
  authentication: "post"
2451
2451
  });
2452
2452
  },
2453
+ refreshAccessToken: options.refreshAccessToken ? options.refreshAccessToken : async (refreshToken) => refreshAccessToken({
2454
+ refreshToken,
2455
+ options: {
2456
+ clientId: options.clientId,
2457
+ clientKey: options.clientKey,
2458
+ clientSecret: options.clientSecret
2459
+ },
2460
+ tokenEndpoint: "https://zoom.us/oauth/token"
2461
+ }),
2453
2462
  async getUserInfo(token) {
2454
2463
  if (options.getUserInfo) return options.getUserInfo(token);
2455
2464
  const { data: profile, error } = await betterFetch("https://api.zoom.us/v2/users/me", { headers: { authorization: `Bearer ${token.accessToken}` } });
@@ -1,3 +1,3 @@
1
- import { t as defineErrorCodes } from "../utils-BFQCAfNW.mjs";
1
+ import { t as defineErrorCodes } from "../utils-C5EN75oV.mjs";
2
2
 
3
3
  export { defineErrorCodes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/core",
3
- "version": "1.4.0-beta.20",
3
+ "version": "1.4.0-beta.22",
4
4
  "description": "The most comprehensive authentication framework for TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
package/src/api/index.ts CHANGED
@@ -1,9 +1,5 @@
1
- import {
2
- createEndpoint,
3
- createMiddleware,
4
- type EndpointContext,
5
- type EndpointOptions,
6
- } from "better-call";
1
+ import type { EndpointContext, EndpointOptions } from "better-call";
2
+ import { createEndpoint, createMiddleware } from "better-call";
7
3
  import { runWithEndpointContext } from "../context";
8
4
  import type { AuthContext } from "../types";
9
5
 
@@ -1,5 +1,6 @@
1
1
  import type { EndpointContext, InputContext } from "better-call";
2
- import { type AsyncLocalStorage, getAsyncLocalStorage } from "../async_hooks";
2
+ import type { AsyncLocalStorage } from "../async_hooks";
3
+ import { getAsyncLocalStorage } from "../async_hooks";
3
4
  import type { AuthContext } from "../types";
4
5
 
5
6
  export type AuthEndpointContext = Partial<
@@ -1,9 +1,9 @@
1
1
  import { describe, expect, it } from "vitest";
2
+ import type { RequestStateWeakMap } from "./request-state";
2
3
  import {
3
4
  defineRequestState,
4
5
  getCurrentRequestState,
5
6
  hasRequestState,
6
- type RequestStateWeakMap,
7
7
  runWithRequestState,
8
8
  } from "./request-state";
9
9
 
@@ -1,4 +1,5 @@
1
- import { type AsyncLocalStorage, getAsyncLocalStorage } from "../async_hooks";
1
+ import type { AsyncLocalStorage } from "../async_hooks";
2
+ import { getAsyncLocalStorage } from "../async_hooks";
2
3
 
3
4
  export type RequestStateWeakMap = WeakMap<object, any>;
4
5
 
@@ -1,4 +1,5 @@
1
- import { type AsyncLocalStorage, getAsyncLocalStorage } from "../async_hooks";
1
+ import type { AsyncLocalStorage } from "../async_hooks";
2
+ import { getAsyncLocalStorage } from "../async_hooks";
2
3
  import type { DBAdapter, DBTransactionAdapter } from "../db/adapter";
3
4
 
4
5
  let currentAdapterAsyncStorage: AsyncLocalStorage<DBTransactionAdapter> | null =
@@ -195,7 +195,7 @@ export interface DBAdapterFactoryConfig<
195
195
  /**
196
196
  * The action which was called from the adapter.
197
197
  */
198
- action: "create" | "update";
198
+ action: "create" | "update" | "findOne" | "findMany";
199
199
  /**
200
200
  * The model name.
201
201
  */
@@ -277,6 +277,12 @@ export interface DBAdapterFactoryConfig<
277
277
  * @default false
278
278
  */
279
279
  disableTransformInput?: boolean | undefined;
280
+ /**
281
+ * Whether to disable the transform join.
282
+ * Do not use this option unless you know what you are doing.
283
+ * @default false
284
+ */
285
+ disableTransformJoin?: boolean | undefined;
280
286
  }
281
287
 
282
288
  export type Where = {
@@ -306,6 +312,56 @@ export type Where = {
306
312
  connector?: ("AND" | "OR") | undefined;
307
313
  };
308
314
 
315
+ /**
316
+ * JoinOption configuration for relational queries.
317
+ *
318
+ * Allows you to join related tables/models in a single query operation.
319
+ * Each key represents the name of the joined table/model, and the value
320
+ * configures how the join should be performed.
321
+ */
322
+ export type JoinOption = {
323
+ [model: string]: boolean | { limit?: number };
324
+ };
325
+
326
+ /**
327
+ * Once `JoinOption` has gone through the adapter factory, it will be transformed into a `JoinConfig`.
328
+ */
329
+ export type JoinConfig = {
330
+ [model: string]: {
331
+ /**
332
+ * The joining column names.
333
+ */
334
+ on: {
335
+ /**
336
+ * Column name from the main table
337
+ */
338
+ from: string;
339
+ /**
340
+ * Column name from the joined table
341
+ */
342
+ to: string;
343
+ };
344
+ /**
345
+ * Limit the number of rows to return.
346
+ *
347
+ * If the relation has `unique` constraint, then this option will be ignored and limit will be set to 1.
348
+ *
349
+ * @default 100
350
+ */
351
+ limit?: number;
352
+ /**
353
+ * The relation type. Determines the ouput joined model data.
354
+ *
355
+ * `one-to-one` would have a single object in the output.
356
+ * `one-to-many` would have an array of objects in the output.
357
+ * `many-to-many` would have an array of objects in the output.
358
+ *
359
+ * @default "one-to-many"
360
+ */
361
+ relation?: "one-to-one" | "one-to-many" | "many-to-many";
362
+ };
363
+ };
364
+
309
365
  export type DBTransactionAdapter<
310
366
  Options extends BetterAuthOptions = BetterAuthOptions,
311
367
  > = Omit<DBAdapter<Options>, "transaction">;
@@ -327,6 +383,7 @@ export type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
327
383
  model: string;
328
384
  where: Where[];
329
385
  select?: string[] | undefined;
386
+ join?: JoinOption | undefined;
330
387
  }) => Promise<T | null>;
331
388
  findMany: <T>(data: {
332
389
  model: string;
@@ -339,6 +396,7 @@ export type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
339
396
  }
340
397
  | undefined;
341
398
  offset?: number | undefined;
399
+ join?: JoinOption | undefined;
342
400
  }) => Promise<T[]>;
343
401
  count: (data: {
344
402
  model: string;
@@ -408,10 +466,12 @@ export interface CustomAdapter {
408
466
  model,
409
467
  where,
410
468
  select,
469
+ join,
411
470
  }: {
412
471
  model: string;
413
472
  where: CleanedWhere[];
414
473
  select?: string[] | undefined;
474
+ join?: JoinConfig | undefined;
415
475
  }) => Promise<T | null>;
416
476
  findMany: <T>({
417
477
  model,
@@ -419,12 +479,14 @@ export interface CustomAdapter {
419
479
  limit,
420
480
  sortBy,
421
481
  offset,
482
+ join,
422
483
  }: {
423
484
  model: string;
424
485
  where?: CleanedWhere[] | undefined;
425
486
  limit: number;
426
487
  sortBy?: { field: string; direction: "asc" | "desc" } | undefined;
427
488
  offset?: number | undefined;
489
+ join?: JoinConfig | undefined;
428
490
  }) => Promise<T[]>;
429
491
  delete: ({
430
492
  model,
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import { coreSchema } from "./shared";
3
3
 
4
4
  export const accountSchema = coreSchema.extend({
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
 
3
3
  export const rateLimitSchema = z.object({
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import { coreSchema } from "./shared";
3
3
 
4
4
  export const sessionSchema = coreSchema.extend({
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
 
3
3
  export const coreSchema = z.object({
4
4
  id: z.string(),
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import { coreSchema } from "./shared";
3
3
 
4
4
  export const userSchema = coreSchema.extend({
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import { coreSchema } from "./shared";
3
3
 
4
4
  export const verificationSchema = coreSchema.extend({
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { type LogLevel, shouldPublishLog } from "./logger";
2
+ import type { LogLevel } from "./logger";
3
+ import { shouldPublishLog } from "./logger";
3
4
 
4
5
  describe("shouldPublishLog", () => {
5
6
  const testCases: {
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import { apple } from "./apple";
3
3
  import { atlassian } from "./atlassian";
4
4
  import { cognito } from "./cognito";
@@ -1,8 +1,7 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
2
3
  import {
3
4
  createAuthorizationURL,
4
- type OAuthProvider,
5
- type ProviderOptions,
6
5
  refreshAccessToken,
7
6
  validateAuthorizationCode,
8
7
  } from "../oauth2";
@@ -1,6 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
2
  import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
- import { generateCodeChallenge, validateAuthorizationCode } from "../oauth2";
3
+ import {
4
+ generateCodeChallenge,
5
+ refreshAccessToken,
6
+ validateAuthorizationCode,
7
+ } from "../oauth2";
4
8
 
5
9
  export type LoginType =
6
10
  | 0 /** Facebook OAuth */
@@ -180,6 +184,18 @@ export const zoom = (userOptions: ZoomOptions) => {
180
184
  authentication: "post",
181
185
  });
182
186
  },
187
+ refreshAccessToken: options.refreshAccessToken
188
+ ? options.refreshAccessToken
189
+ : async (refreshToken) =>
190
+ refreshAccessToken({
191
+ refreshToken,
192
+ options: {
193
+ clientId: options.clientId,
194
+ clientKey: options.clientKey,
195
+ clientSecret: options.clientSecret,
196
+ },
197
+ tokenEndpoint: "https://zoom.us/oauth/token",
198
+ }),
183
199
  async getUserInfo(token) {
184
200
  if (options.getUserInfo) {
185
201
  return options.getUserInfo(token);
@@ -9,7 +9,7 @@ import type {
9
9
  Verification,
10
10
  } from "../db";
11
11
  import type { DBAdapter, Where } from "../db/adapter";
12
- import { createLogger } from "../env";
12
+ import type { createLogger } from "../env";
13
13
  import type { OAuthProvider } from "../oauth2";
14
14
  import type { BetterAuthCookies } from "./cookie";
15
15
  import type { LiteralUnion } from "./helper";
@@ -936,14 +936,7 @@ export type BetterAuthOptions = {
936
936
  /**
937
937
  * Advanced options
938
938
  */
939
- advanced?:
940
- | (BetterAuthAdvancedOptions & {
941
- /**
942
- * @deprecated Please use `database.generateId` instead.
943
- */
944
- generateId?: never;
945
- })
946
- | undefined;
939
+ advanced?: BetterAuthAdvancedOptions | undefined;
947
940
  logger?: Logger | undefined;
948
941
  /**
949
942
  * allows you to define custom hooks that can be
@@ -1345,4 +1338,18 @@ export type BetterAuthOptions = {
1345
1338
  debug?: boolean;
1346
1339
  }
1347
1340
  | undefined;
1341
+ /**
1342
+ * Experimental features
1343
+ */
1344
+ experimental?: {
1345
+ /**
1346
+ * Enable experimental joins for your database adapter.
1347
+ *
1348
+ * Please read the adapter documentation for more information regarding joins before enabling this.
1349
+ * Not all adapters support joins.
1350
+ *
1351
+ * @default false
1352
+ */
1353
+ joins?: boolean;
1354
+ };
1348
1355
  };
@@ -0,0 +1,3 @@
1
+ import { defineProject } from "vitest/config";
2
+
3
+ export default defineProject({});
File without changes
File without changes