better-auth 1.2.0-beta.1 → 1.2.0-beta.10

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 (201) hide show
  1. package/dist/adapters/drizzle.cjs +11 -4
  2. package/dist/adapters/drizzle.d.cts +6 -2
  3. package/dist/adapters/drizzle.d.ts +6 -2
  4. package/dist/adapters/drizzle.js +10 -3
  5. package/dist/adapters/kysely.cjs +4 -4
  6. package/dist/adapters/kysely.d.cts +6 -2
  7. package/dist/adapters/kysely.d.ts +6 -2
  8. package/dist/adapters/kysely.js +2 -2
  9. package/dist/adapters/memory.cjs +3 -3
  10. package/dist/adapters/memory.d.cts +6 -2
  11. package/dist/adapters/memory.d.ts +6 -2
  12. package/dist/adapters/memory.js +2 -2
  13. package/dist/adapters/mongodb.cjs +25 -7
  14. package/dist/adapters/mongodb.d.cts +6 -2
  15. package/dist/adapters/mongodb.d.ts +6 -2
  16. package/dist/adapters/mongodb.js +23 -5
  17. package/dist/adapters/prisma.cjs +17 -4
  18. package/dist/adapters/prisma.d.cts +6 -2
  19. package/dist/adapters/prisma.d.ts +6 -2
  20. package/dist/adapters/prisma.js +15 -2
  21. package/dist/adapters/test.cjs +1 -1
  22. package/dist/adapters/test.d.cts +2 -2
  23. package/dist/adapters/test.d.ts +2 -2
  24. package/dist/adapters/test.js +1 -1
  25. package/dist/api.cjs +47 -43
  26. package/dist/api.d.cts +3 -3
  27. package/dist/api.d.ts +3 -3
  28. package/dist/api.js +4 -4
  29. package/dist/{auth-D4rdpxtI.d.cts → auth-BLwS7t0V.d.cts} +7659 -3308
  30. package/dist/{auth-DcMc3BIq.d.ts → auth-C42JqOR9.d.ts} +7659 -3308
  31. package/dist/{chunk-5KMF6HGF.js → chunk-2F3IX7O2.js} +70 -49
  32. package/dist/{chunk-5E75URIA.cjs → chunk-2Z6CVQHH.cjs} +0 -4
  33. package/dist/{chunk-WLXFBYQ6.cjs → chunk-45RBYQKI.cjs} +77 -7
  34. package/dist/{chunk-WGCTQNSQ.js → chunk-4KMR5H5T.js} +1 -1
  35. package/dist/{chunk-CVDYU5OC.js → chunk-4POUTBIX.js} +5 -8
  36. package/dist/{chunk-BKFMDM3P.js → chunk-52TDJNDX.js} +110 -12
  37. package/dist/{chunk-PJ4KWXLQ.cjs → chunk-5ECP2UE2.cjs} +5 -5
  38. package/dist/{chunk-FXNG3YQA.js → chunk-5G6XUCMS.js} +146 -79
  39. package/dist/{chunk-UHGAA4GH.cjs → chunk-5KTUVZ3H.cjs} +5 -5
  40. package/dist/{chunk-YRUDZRY3.cjs → chunk-5RR5WN52.cjs} +73 -52
  41. package/dist/{chunk-JNZYTS3B.js → chunk-BZOIXJ2Q.js} +1 -1
  42. package/dist/{chunk-FA6UYV37.js → chunk-CG2CK6HR.js} +1 -1
  43. package/dist/{chunk-EM73ZZSP.cjs → chunk-DURU7ZRA.cjs} +20 -20
  44. package/dist/{chunk-MGJLVQOV.js → chunk-EQYRCOOF.js} +39 -2
  45. package/dist/{chunk-3BWJXTLC.cjs → chunk-GSEEAIRZ.cjs} +47 -53
  46. package/dist/{chunk-QFYRLTM5.cjs → chunk-HUDPJXOF.cjs} +24 -33
  47. package/dist/{chunk-764RYNTE.cjs → chunk-IG7Z7S3A.cjs} +61 -28
  48. package/dist/{chunk-5RY45WFV.js → chunk-IQUHEVLH.js} +2 -8
  49. package/dist/{chunk-JLATHUM5.cjs → chunk-IUGQVFPG.cjs} +6 -6
  50. package/dist/{chunk-5OBRFII2.js → chunk-J6VNT2T4.js} +49 -5
  51. package/dist/{chunk-NU4SXYJ5.cjs → chunk-JDAHD767.cjs} +198 -42
  52. package/dist/{chunk-LZ5DEQVH.cjs → chunk-K6WRBJAV.cjs} +3 -3
  53. package/dist/{chunk-WDOY7YUW.cjs → chunk-KAR56MJZ.cjs} +39 -2
  54. package/dist/{chunk-GTM45OYP.cjs → chunk-MKNDCNWD.cjs} +3 -3
  55. package/dist/{chunk-PIWBUHRB.cjs → chunk-N7UWN6ND.cjs} +42 -17
  56. package/dist/{chunk-E6LJZ5ME.js → chunk-QKCLO6S5.js} +1 -1
  57. package/dist/{chunk-ADGXBH3Y.js → chunk-QLKU77BF.js} +1 -10
  58. package/dist/{chunk-6O2GLU2U.cjs → chunk-QNLSMTXF.cjs} +17 -12
  59. package/dist/{chunk-S6MI7ZLE.js → chunk-QQGRNAM2.js} +11 -6
  60. package/dist/{chunk-GTQM7JU7.js → chunk-R42K7GPF.js} +3 -1
  61. package/dist/{chunk-3EY3LSQR.js → chunk-SCXZXQTZ.js} +37 -13
  62. package/dist/{chunk-WVLPJXQR.cjs → chunk-SMZIOWVN.cjs} +76 -32
  63. package/dist/{chunk-UP6VJQDB.js → chunk-ST2CQ4A2.js} +2 -2
  64. package/dist/{chunk-V6RGXSG4.cjs → chunk-SVC7H7K4.cjs} +3 -1
  65. package/dist/{chunk-VXDYNCOX.js → chunk-TODG5RSV.js} +172 -19
  66. package/dist/{chunk-5XAVWKUN.js → chunk-TZ34QTAV.js} +73 -3
  67. package/dist/{chunk-BAPXDO3E.cjs → chunk-U44XLDNH.cjs} +119 -21
  68. package/dist/{chunk-VPCROEJW.cjs → chunk-WD65CNWK.cjs} +170 -103
  69. package/dist/{chunk-RGG6OEA3.js → chunk-X7L62XYJ.js} +58 -25
  70. package/dist/{chunk-G7HOSQ5N.cjs → chunk-Z3CGJYU3.cjs} +15 -18
  71. package/dist/{chunk-YW3B2ST3.js → chunk-ZDYKAJ67.js} +116 -5
  72. package/dist/{chunk-NPO64SVN.js → chunk-ZFUBVSZD.js} +0 -4
  73. package/dist/{chunk-2LQ7T2GE.js → chunk-ZKMUJOIP.js} +1 -1
  74. package/dist/{chunk-OSBTXYDD.cjs → chunk-ZUUQ3FFY.cjs} +125 -14
  75. package/dist/client/plugins.cjs +45 -12
  76. package/dist/client/plugins.d.cts +45 -7
  77. package/dist/client/plugins.d.ts +45 -7
  78. package/dist/client/plugins.js +45 -12
  79. package/dist/client.d.cts +6 -7
  80. package/dist/client.d.ts +6 -7
  81. package/dist/cookies.d.cts +2 -2
  82. package/dist/cookies.d.ts +2 -2
  83. package/dist/db.cjs +13 -13
  84. package/dist/db.d.cts +3 -3
  85. package/dist/db.d.ts +3 -3
  86. package/dist/db.js +2 -2
  87. package/dist/index-Bszx4yMW.d.cts +7755 -0
  88. package/dist/{index-Ba5bMY6A.d.cts → index-BuRgaJZR.d.cts} +194 -2
  89. package/dist/index-DbIhOM3X.d.ts +7755 -0
  90. package/dist/{index-XrJz4AYF.d.ts → index-moQjyfmm.d.ts} +194 -2
  91. package/dist/index.cjs +18 -18
  92. package/dist/index.d.cts +3 -3
  93. package/dist/index.d.ts +3 -3
  94. package/dist/index.js +8 -8
  95. package/dist/next-js.cjs +23 -23
  96. package/dist/next-js.d.cts +2 -2
  97. package/dist/next-js.d.ts +2 -2
  98. package/dist/next-js.js +22 -22
  99. package/dist/node.d.cts +2 -2
  100. package/dist/node.d.ts +2 -2
  101. package/dist/oauth2.cjs +9 -9
  102. package/dist/oauth2.d.cts +6 -5
  103. package/dist/oauth2.d.ts +6 -5
  104. package/dist/oauth2.js +2 -2
  105. package/dist/plugins/admin.cjs +6 -6
  106. package/dist/plugins/admin.d.cts +162 -31
  107. package/dist/plugins/admin.d.ts +162 -31
  108. package/dist/plugins/admin.js +5 -5
  109. package/dist/plugins/anonymous.cjs +6 -6
  110. package/dist/plugins/anonymous.d.cts +8 -4
  111. package/dist/plugins/anonymous.d.ts +8 -4
  112. package/dist/plugins/anonymous.js +5 -5
  113. package/dist/plugins/bearer.cjs +6 -6
  114. package/dist/plugins/bearer.d.cts +2 -2
  115. package/dist/plugins/bearer.d.ts +2 -2
  116. package/dist/plugins/bearer.js +5 -5
  117. package/dist/{plugin → plugins}/custom-session.cjs +6 -6
  118. package/dist/{plugin → plugins}/custom-session.d.cts +8 -4
  119. package/dist/{plugin → plugins}/custom-session.d.ts +8 -4
  120. package/dist/{plugin → plugins}/custom-session.js +5 -5
  121. package/dist/plugins/email-otp.cjs +6 -6
  122. package/dist/plugins/email-otp.d.cts +44 -16
  123. package/dist/plugins/email-otp.d.ts +44 -16
  124. package/dist/plugins/email-otp.js +5 -5
  125. package/dist/plugins/generic-oauth.cjs +6 -6
  126. package/dist/plugins/generic-oauth.d.cts +95 -6
  127. package/dist/plugins/generic-oauth.d.ts +95 -6
  128. package/dist/plugins/generic-oauth.js +5 -5
  129. package/dist/plugins/jwt.cjs +6 -6
  130. package/dist/plugins/jwt.d.cts +28 -6
  131. package/dist/plugins/jwt.d.ts +28 -6
  132. package/dist/plugins/jwt.js +5 -5
  133. package/dist/plugins/magic-link.cjs +6 -6
  134. package/dist/plugins/magic-link.d.cts +16 -4
  135. package/dist/plugins/magic-link.d.ts +16 -4
  136. package/dist/plugins/magic-link.js +5 -5
  137. package/dist/plugins/multi-session.cjs +6 -6
  138. package/dist/plugins/multi-session.d.cts +20 -8
  139. package/dist/plugins/multi-session.d.ts +20 -8
  140. package/dist/plugins/multi-session.js +5 -5
  141. package/dist/plugins/oidc-provider.cjs +6 -6
  142. package/dist/plugins/oidc-provider.d.cts +43 -15
  143. package/dist/plugins/oidc-provider.d.ts +43 -15
  144. package/dist/plugins/oidc-provider.js +5 -5
  145. package/dist/plugins/one-tap.cjs +6 -6
  146. package/dist/plugins/one-tap.d.cts +13 -2
  147. package/dist/plugins/one-tap.d.ts +13 -2
  148. package/dist/plugins/one-tap.js +5 -5
  149. package/dist/plugins/open-api.cjs +7 -7
  150. package/dist/plugins/open-api.d.cts +14 -6
  151. package/dist/plugins/open-api.d.ts +14 -6
  152. package/dist/plugins/open-api.js +6 -6
  153. package/dist/plugins/organization.cjs +6 -6
  154. package/dist/plugins/organization.d.cts +3 -3
  155. package/dist/plugins/organization.d.ts +3 -3
  156. package/dist/plugins/organization.js +5 -5
  157. package/dist/plugins/passkey.cjs +17 -17
  158. package/dist/plugins/passkey.d.cts +44 -16
  159. package/dist/plugins/passkey.d.ts +44 -16
  160. package/dist/plugins/passkey.js +4 -4
  161. package/dist/plugins/phone-number.cjs +6 -6
  162. package/dist/plugins/phone-number.d.cts +122 -9
  163. package/dist/plugins/phone-number.d.ts +122 -9
  164. package/dist/plugins/phone-number.js +5 -5
  165. package/dist/plugins/sso.cjs +26 -18
  166. package/dist/plugins/sso.d.cts +24 -8
  167. package/dist/plugins/sso.d.ts +24 -8
  168. package/dist/plugins/sso.js +13 -5
  169. package/dist/plugins/two-factor.cjs +6 -6
  170. package/dist/plugins/two-factor.d.cts +62 -22
  171. package/dist/plugins/two-factor.d.ts +62 -22
  172. package/dist/plugins/two-factor.js +5 -5
  173. package/dist/plugins/username.cjs +6 -6
  174. package/dist/plugins/username.d.cts +36 -4
  175. package/dist/plugins/username.d.ts +36 -4
  176. package/dist/plugins/username.js +5 -5
  177. package/dist/plugins.cjs +42 -42
  178. package/dist/plugins.d.cts +11 -7
  179. package/dist/plugins.d.ts +11 -7
  180. package/dist/plugins.js +22 -22
  181. package/dist/react.d.cts +7 -9
  182. package/dist/react.d.ts +7 -9
  183. package/dist/social.cjs +32 -20
  184. package/dist/social.d.cts +1 -1
  185. package/dist/social.d.ts +1 -1
  186. package/dist/social.js +3 -3
  187. package/dist/solid.d.cts +7 -7
  188. package/dist/solid.d.ts +7 -7
  189. package/dist/{state-Cm8el5M1.d.ts → state-BlQHfd32.d.ts} +1 -1
  190. package/dist/{state-DcraY2_H.d.cts → state-lA7cG1Em.d.cts} +1 -1
  191. package/dist/svelte-kit.d.cts +2 -2
  192. package/dist/svelte-kit.d.ts +2 -2
  193. package/dist/svelte.d.cts +7 -7
  194. package/dist/svelte.d.ts +7 -7
  195. package/dist/types.d.cts +4 -4
  196. package/dist/types.d.ts +4 -4
  197. package/dist/vue.d.cts +7 -7
  198. package/dist/vue.d.ts +7 -7
  199. package/package.json +4 -4
  200. package/dist/index-CvlKSqnF.d.cts +0 -4023
  201. package/dist/index-Ivs2EsUL.d.ts +0 -4023
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkWDOY7YUW_cjs = require('../chunk-WDOY7YUW.cjs');
3
+ var chunkKAR56MJZ_cjs = require('../chunk-KAR56MJZ.cjs');
4
4
  require('../chunk-B5UCLTPZ.cjs');
5
5
  var chunkH74YRRNV_cjs = require('../chunk-H74YRRNV.cjs');
6
- require('../chunk-5E75URIA.cjs');
6
+ require('../chunk-2Z6CVQHH.cjs');
7
7
  require('../chunk-NIMYOIVU.cjs');
8
8
  require('../chunk-CCKQSGIR.cjs');
9
9
  require('../chunk-G2LZ73E2.cjs');
@@ -14,7 +14,7 @@ var chunkPEZRSDZS_cjs = require('../chunk-PEZRSDZS.cjs');
14
14
  var drizzleOrm = require('drizzle-orm');
15
15
 
16
16
  var createTransform = (db, config, options) => {
17
- const schema = chunkWDOY7YUW_cjs.getAuthTables(options);
17
+ const schema = chunkKAR56MJZ_cjs.getAuthTables(options);
18
18
  function getField(model, field) {
19
19
  if (field === "id") {
20
20
  return field;
@@ -116,7 +116,7 @@ var createTransform = (db, config, options) => {
116
116
  if (value === void 0 && !fields[field].defaultValue) {
117
117
  continue;
118
118
  }
119
- transformedData[fields[field].fieldName || field] = chunkWDOY7YUW_cjs.withApplyDefault(
119
+ transformedData[fields[field].fieldName || field] = chunkKAR56MJZ_cjs.withApplyDefault(
120
120
  value,
121
121
  fields[field],
122
122
  action
@@ -222,6 +222,13 @@ var drizzleAdapter = (db, config) => (options) => {
222
222
  const res = await builder.where(...clause);
223
223
  return res.map((r) => transformOutput(r, model));
224
224
  },
225
+ async count(data) {
226
+ const { model, where } = data;
227
+ const schemaModel = getSchema(model);
228
+ const clause = where ? convertWhereClause(where, model) : [];
229
+ const res = await db.select({ count: drizzleOrm.count() }).from(schemaModel).where(...clause);
230
+ return res.count;
231
+ },
225
232
  async update(data) {
226
233
  const { model, where, update: values } = data;
227
234
  const schemaModel = getSchema(model);
@@ -1,9 +1,9 @@
1
- import { B as BetterAuthOptions, W as Where } from '../auth-D4rdpxtI.cjs';
1
+ import { B as BetterAuthOptions, W as Where } from '../auth-BLwS7t0V.cjs';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.cjs';
6
- import '../index-Ba5bMY6A.cjs';
6
+ import '../index-BuRgaJZR.cjs';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -48,6 +48,10 @@ declare const drizzleAdapter: (db: DB, config: DrizzleAdapterConfig) => (options
48
48
  };
49
49
  offset?: number;
50
50
  }): Promise<any[]>;
51
+ count(data: {
52
+ model: string;
53
+ where?: Where[];
54
+ }): Promise<any>;
51
55
  update<T>(data: {
52
56
  model: string;
53
57
  where: Where[];
@@ -1,9 +1,9 @@
1
- import { B as BetterAuthOptions, W as Where } from '../auth-DcMc3BIq.js';
1
+ import { B as BetterAuthOptions, W as Where } from '../auth-C42JqOR9.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.js';
6
- import '../index-XrJz4AYF.js';
6
+ import '../index-moQjyfmm.js';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -48,6 +48,10 @@ declare const drizzleAdapter: (db: DB, config: DrizzleAdapterConfig) => (options
48
48
  };
49
49
  offset?: number;
50
50
  }): Promise<any[]>;
51
+ count(data: {
52
+ model: string;
53
+ where?: Where[];
54
+ }): Promise<any>;
51
55
  update<T>(data: {
52
56
  model: string;
53
57
  where: Where[];
@@ -1,7 +1,7 @@
1
- import { getAuthTables, withApplyDefault } from '../chunk-MGJLVQOV.js';
1
+ import { getAuthTables, withApplyDefault } from '../chunk-EQYRCOOF.js';
2
2
  import '../chunk-HZBNUY7E.js';
3
3
  import { generateId } from '../chunk-KLDFBLYL.js';
4
- import '../chunk-NPO64SVN.js';
4
+ import '../chunk-ZFUBVSZD.js';
5
5
  import '../chunk-SK6Y2YH6.js';
6
6
  import '../chunk-3XTQSPPA.js';
7
7
  import '../chunk-DBPOZRMS.js';
@@ -9,7 +9,7 @@ import '../chunk-53IPO2PJ.js';
9
9
  import '../chunk-FURNA6HY.js';
10
10
  import '../chunk-TQQSPPNA.js';
11
11
  import { BetterAuthError } from '../chunk-UNWCXKMP.js';
12
- import { desc, asc, eq, inArray, like, and, or } from 'drizzle-orm';
12
+ import { desc, asc, count, eq, inArray, like, and, or } from 'drizzle-orm';
13
13
 
14
14
  var createTransform = (db, config, options) => {
15
15
  const schema = getAuthTables(options);
@@ -220,6 +220,13 @@ var drizzleAdapter = (db, config) => (options) => {
220
220
  const res = await builder.where(...clause);
221
221
  return res.map((r) => transformOutput(r, model));
222
222
  },
223
+ async count(data) {
224
+ const { model, where } = data;
225
+ const schemaModel = getSchema(model);
226
+ const clause = where ? convertWhereClause(where, model) : [];
227
+ const res = await db.select({ count: count() }).from(schemaModel).where(...clause);
228
+ return res.count;
229
+ },
223
230
  async update(data) {
224
231
  const { model, where, update: values } = data;
225
232
  const schemaModel = getSchema(model);
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkWDOY7YUW_cjs = require('../chunk-WDOY7YUW.cjs');
3
+ var chunkKAR56MJZ_cjs = require('../chunk-KAR56MJZ.cjs');
4
4
  require('../chunk-B5UCLTPZ.cjs');
5
5
  require('../chunk-H74YRRNV.cjs');
6
- require('../chunk-5E75URIA.cjs');
6
+ require('../chunk-2Z6CVQHH.cjs');
7
7
  require('../chunk-NIMYOIVU.cjs');
8
8
  require('../chunk-CCKQSGIR.cjs');
9
9
  require('../chunk-G2LZ73E2.cjs');
@@ -16,9 +16,9 @@ require('../chunk-PEZRSDZS.cjs');
16
16
 
17
17
  Object.defineProperty(exports, "createKyselyAdapter", {
18
18
  enumerable: true,
19
- get: function () { return chunkWDOY7YUW_cjs.createKyselyAdapter; }
19
+ get: function () { return chunkKAR56MJZ_cjs.createKyselyAdapter; }
20
20
  });
21
21
  Object.defineProperty(exports, "kyselyAdapter", {
22
22
  enumerable: true,
23
- get: function () { return chunkWDOY7YUW_cjs.kyselyAdapter; }
23
+ get: function () { return chunkKAR56MJZ_cjs.kyselyAdapter; }
24
24
  });
@@ -1,9 +1,9 @@
1
1
  import { Kysely } from 'kysely';
2
- import { B as BetterAuthOptions, K as KyselyDatabaseType, W as Where } from '../auth-D4rdpxtI.cjs';
2
+ import { B as BetterAuthOptions, K as KyselyDatabaseType, W as Where } from '../auth-BLwS7t0V.cjs';
3
3
  import 'zod';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.cjs';
6
- import '../index-Ba5bMY6A.cjs';
6
+ import '../index-BuRgaJZR.cjs';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -50,6 +50,10 @@ declare const kyselyAdapter: (db: Kysely<any>, config?: KyselyAdapterConfig) =>
50
50
  where: Where[];
51
51
  update: Record<string, any>;
52
52
  }): Promise<number>;
53
+ count(data: {
54
+ model: string;
55
+ where?: Where[];
56
+ }): Promise<number>;
53
57
  delete<T>(data: {
54
58
  model: string;
55
59
  where: Where[];
@@ -1,9 +1,9 @@
1
1
  import { Kysely } from 'kysely';
2
- import { B as BetterAuthOptions, K as KyselyDatabaseType, W as Where } from '../auth-DcMc3BIq.js';
2
+ import { B as BetterAuthOptions, K as KyselyDatabaseType, W as Where } from '../auth-C42JqOR9.js';
3
3
  import 'zod';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.js';
6
- import '../index-XrJz4AYF.js';
6
+ import '../index-moQjyfmm.js';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -50,6 +50,10 @@ declare const kyselyAdapter: (db: Kysely<any>, config?: KyselyAdapterConfig) =>
50
50
  where: Where[];
51
51
  update: Record<string, any>;
52
52
  }): Promise<number>;
53
+ count(data: {
54
+ model: string;
55
+ where?: Where[];
56
+ }): Promise<number>;
53
57
  delete<T>(data: {
54
58
  model: string;
55
59
  where: Where[];
@@ -1,7 +1,7 @@
1
- export { createKyselyAdapter, kyselyAdapter } from '../chunk-MGJLVQOV.js';
1
+ export { createKyselyAdapter, kyselyAdapter } from '../chunk-EQYRCOOF.js';
2
2
  import '../chunk-HZBNUY7E.js';
3
3
  import '../chunk-KLDFBLYL.js';
4
- import '../chunk-NPO64SVN.js';
4
+ import '../chunk-ZFUBVSZD.js';
5
5
  import '../chunk-SK6Y2YH6.js';
6
6
  import '../chunk-3XTQSPPA.js';
7
7
  import '../chunk-DBPOZRMS.js';
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkWDOY7YUW_cjs = require('../chunk-WDOY7YUW.cjs');
3
+ var chunkKAR56MJZ_cjs = require('../chunk-KAR56MJZ.cjs');
4
4
  require('../chunk-B5UCLTPZ.cjs');
5
5
  require('../chunk-H74YRRNV.cjs');
6
- require('../chunk-5E75URIA.cjs');
6
+ require('../chunk-2Z6CVQHH.cjs');
7
7
  require('../chunk-NIMYOIVU.cjs');
8
8
  require('../chunk-CCKQSGIR.cjs');
9
9
  require('../chunk-G2LZ73E2.cjs');
@@ -16,5 +16,5 @@ require('../chunk-PEZRSDZS.cjs');
16
16
 
17
17
  Object.defineProperty(exports, "memoryAdapter", {
18
18
  enumerable: true,
19
- get: function () { return chunkWDOY7YUW_cjs.memoryAdapter; }
19
+ get: function () { return chunkKAR56MJZ_cjs.memoryAdapter; }
20
20
  });
@@ -1,9 +1,9 @@
1
- import { B as BetterAuthOptions, W as Where } from '../auth-D4rdpxtI.cjs';
1
+ import { B as BetterAuthOptions, W as Where } from '../auth-BLwS7t0V.cjs';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.cjs';
6
- import '../index-Ba5bMY6A.cjs';
6
+ import '../index-BuRgaJZR.cjs';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -32,6 +32,10 @@ declare const memoryAdapter: (db: MemoryDB) => (options: BetterAuthOptions) => {
32
32
  };
33
33
  offset?: number;
34
34
  }) => Promise<any[]>;
35
+ count: ({ model }: {
36
+ model: string;
37
+ where?: Where[];
38
+ }) => Promise<number>;
35
39
  update: <T>({ model, where, update }: {
36
40
  model: string;
37
41
  where: Where[];
@@ -1,9 +1,9 @@
1
- import { B as BetterAuthOptions, W as Where } from '../auth-DcMc3BIq.js';
1
+ import { B as BetterAuthOptions, W as Where } from '../auth-C42JqOR9.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.js';
6
- import '../index-XrJz4AYF.js';
6
+ import '../index-moQjyfmm.js';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -32,6 +32,10 @@ declare const memoryAdapter: (db: MemoryDB) => (options: BetterAuthOptions) => {
32
32
  };
33
33
  offset?: number;
34
34
  }) => Promise<any[]>;
35
+ count: ({ model }: {
36
+ model: string;
37
+ where?: Where[];
38
+ }) => Promise<number>;
35
39
  update: <T>({ model, where, update }: {
36
40
  model: string;
37
41
  where: Where[];
@@ -1,7 +1,7 @@
1
- export { memoryAdapter } from '../chunk-MGJLVQOV.js';
1
+ export { memoryAdapter } from '../chunk-EQYRCOOF.js';
2
2
  import '../chunk-HZBNUY7E.js';
3
3
  import '../chunk-KLDFBLYL.js';
4
- import '../chunk-NPO64SVN.js';
4
+ import '../chunk-ZFUBVSZD.js';
5
5
  import '../chunk-SK6Y2YH6.js';
6
6
  import '../chunk-3XTQSPPA.js';
7
7
  import '../chunk-DBPOZRMS.js';
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkWDOY7YUW_cjs = require('../chunk-WDOY7YUW.cjs');
3
+ var chunkKAR56MJZ_cjs = require('../chunk-KAR56MJZ.cjs');
4
4
  require('../chunk-B5UCLTPZ.cjs');
5
5
  require('../chunk-H74YRRNV.cjs');
6
- require('../chunk-5E75URIA.cjs');
6
+ require('../chunk-2Z6CVQHH.cjs');
7
7
  require('../chunk-NIMYOIVU.cjs');
8
8
  require('../chunk-CCKQSGIR.cjs');
9
9
  require('../chunk-G2LZ73E2.cjs');
@@ -14,8 +14,12 @@ require('../chunk-PEZRSDZS.cjs');
14
14
  var mongodb = require('mongodb');
15
15
 
16
16
  var createTransform = (options) => {
17
- const schema = chunkWDOY7YUW_cjs.getAuthTables(options);
17
+ const schema = chunkKAR56MJZ_cjs.getAuthTables(options);
18
+ const customIdGen = options.advanced?.generateId;
18
19
  function serializeID(field, value, model) {
20
+ if (customIdGen) {
21
+ return value;
22
+ }
19
23
  if (field === "id" || field === "_id" || schema[model].fields[field].references?.field === "id") {
20
24
  if (typeof value !== "string") {
21
25
  if (value instanceof mongodb.ObjectId) {
@@ -47,6 +51,9 @@ var createTransform = (options) => {
47
51
  return value;
48
52
  }
49
53
  function deserializeID(field, value, model) {
54
+ if (customIdGen) {
55
+ return value;
56
+ }
50
57
  if (field === "id" || schema[model].fields[field].references?.field === "id") {
51
58
  if (value instanceof mongodb.ObjectId) {
52
59
  return value.toHexString();
@@ -65,6 +72,9 @@ var createTransform = (options) => {
65
72
  }
66
73
  function getField(field, model) {
67
74
  if (field === "id") {
75
+ if (customIdGen) {
76
+ return "id";
77
+ }
68
78
  return "_id";
69
79
  }
70
80
  const f = schema[model].fields[field];
@@ -72,7 +82,9 @@ var createTransform = (options) => {
72
82
  }
73
83
  return {
74
84
  transformInput(data, model, action) {
75
- const transformedData = action === "update" ? {} : {
85
+ const transformedData = action === "update" ? {} : customIdGen ? {
86
+ id: customIdGen({ model })
87
+ } : {
76
88
  _id: new mongodb.ObjectId()
77
89
  };
78
90
  const fields = schema[model].fields;
@@ -81,7 +93,7 @@ var createTransform = (options) => {
81
93
  if (value === void 0 && (!fields[field].defaultValue || action === "update")) {
82
94
  continue;
83
95
  }
84
- transformedData[fields[field].fieldName || field] = chunkWDOY7YUW_cjs.withApplyDefault(
96
+ transformedData[fields[field].fieldName || field] = chunkKAR56MJZ_cjs.withApplyDefault(
85
97
  serializeID(field, value, model),
86
98
  fields[field],
87
99
  action
@@ -179,17 +191,18 @@ var createTransform = (options) => {
179
191
  };
180
192
  var mongodbAdapter = (db) => (options) => {
181
193
  const transform = createTransform(options);
194
+ const hasCustomId = options.advanced?.generateId;
182
195
  return {
183
196
  id: "mongodb-adapter",
184
197
  async create(data) {
185
198
  const { model, data: values, select } = data;
186
199
  const transformedData = transform.transformInput(values, model, "create");
187
- if (transformedData.id) {
200
+ if (transformedData.id && !hasCustomId) {
188
201
  delete transformedData.id;
189
202
  }
190
203
  const res = await db.collection(transform.getModelName(model)).insertOne(transformedData);
191
204
  const id = res.insertedId;
192
- const insertedData = { ...transformedData, id: id.toString() };
205
+ const insertedData = { id: id.toString(), ...transformedData };
193
206
  const t = transform.transformOutput(insertedData, model, select);
194
207
  return t;
195
208
  },
@@ -215,6 +228,11 @@ var mongodbAdapter = (db) => (options) => {
215
228
  const res = await cursor.toArray();
216
229
  return res.map((r) => transform.transformOutput(r, model));
217
230
  },
231
+ async count(data) {
232
+ const { model } = data;
233
+ const res = await db.collection(transform.getModelName(model)).countDocuments();
234
+ return res;
235
+ },
218
236
  async update(data) {
219
237
  const { model, where, update: values } = data;
220
238
  const clause = transform.convertWhereClause(where, model);
@@ -1,10 +1,10 @@
1
1
  import { Db } from 'mongodb';
2
- import { B as BetterAuthOptions, W as Where } from '../auth-D4rdpxtI.cjs';
2
+ import { B as BetterAuthOptions, W as Where } from '../auth-BLwS7t0V.cjs';
3
3
  import 'zod';
4
4
  import 'kysely';
5
5
  import 'better-call';
6
6
  import '../helper-Bi8FQwDD.cjs';
7
- import '../index-Ba5bMY6A.cjs';
7
+ import '../index-BuRgaJZR.cjs';
8
8
  import 'jose';
9
9
  import 'better-sqlite3';
10
10
 
@@ -30,6 +30,10 @@ declare const mongodbAdapter: (db: Db) => (options: BetterAuthOptions) => {
30
30
  };
31
31
  offset?: number;
32
32
  }): Promise<any[]>;
33
+ count(data: {
34
+ model: string;
35
+ where?: Where[];
36
+ }): Promise<number>;
33
37
  update<T>(data: {
34
38
  model: string;
35
39
  where: Where[];
@@ -1,10 +1,10 @@
1
1
  import { Db } from 'mongodb';
2
- import { B as BetterAuthOptions, W as Where } from '../auth-DcMc3BIq.js';
2
+ import { B as BetterAuthOptions, W as Where } from '../auth-C42JqOR9.js';
3
3
  import 'zod';
4
4
  import 'kysely';
5
5
  import 'better-call';
6
6
  import '../helper-Bi8FQwDD.js';
7
- import '../index-XrJz4AYF.js';
7
+ import '../index-moQjyfmm.js';
8
8
  import 'jose';
9
9
  import 'better-sqlite3';
10
10
 
@@ -30,6 +30,10 @@ declare const mongodbAdapter: (db: Db) => (options: BetterAuthOptions) => {
30
30
  };
31
31
  offset?: number;
32
32
  }): Promise<any[]>;
33
+ count(data: {
34
+ model: string;
35
+ where?: Where[];
36
+ }): Promise<number>;
33
37
  update<T>(data: {
34
38
  model: string;
35
39
  where: Where[];
@@ -1,7 +1,7 @@
1
- import { getAuthTables, withApplyDefault } from '../chunk-MGJLVQOV.js';
1
+ import { getAuthTables, withApplyDefault } from '../chunk-EQYRCOOF.js';
2
2
  import '../chunk-HZBNUY7E.js';
3
3
  import '../chunk-KLDFBLYL.js';
4
- import '../chunk-NPO64SVN.js';
4
+ import '../chunk-ZFUBVSZD.js';
5
5
  import '../chunk-SK6Y2YH6.js';
6
6
  import '../chunk-3XTQSPPA.js';
7
7
  import '../chunk-DBPOZRMS.js';
@@ -13,7 +13,11 @@ import { ObjectId } from 'mongodb';
13
13
 
14
14
  var createTransform = (options) => {
15
15
  const schema = getAuthTables(options);
16
+ const customIdGen = options.advanced?.generateId;
16
17
  function serializeID(field, value, model) {
18
+ if (customIdGen) {
19
+ return value;
20
+ }
17
21
  if (field === "id" || field === "_id" || schema[model].fields[field].references?.field === "id") {
18
22
  if (typeof value !== "string") {
19
23
  if (value instanceof ObjectId) {
@@ -45,6 +49,9 @@ var createTransform = (options) => {
45
49
  return value;
46
50
  }
47
51
  function deserializeID(field, value, model) {
52
+ if (customIdGen) {
53
+ return value;
54
+ }
48
55
  if (field === "id" || schema[model].fields[field].references?.field === "id") {
49
56
  if (value instanceof ObjectId) {
50
57
  return value.toHexString();
@@ -63,6 +70,9 @@ var createTransform = (options) => {
63
70
  }
64
71
  function getField(field, model) {
65
72
  if (field === "id") {
73
+ if (customIdGen) {
74
+ return "id";
75
+ }
66
76
  return "_id";
67
77
  }
68
78
  const f = schema[model].fields[field];
@@ -70,7 +80,9 @@ var createTransform = (options) => {
70
80
  }
71
81
  return {
72
82
  transformInput(data, model, action) {
73
- const transformedData = action === "update" ? {} : {
83
+ const transformedData = action === "update" ? {} : customIdGen ? {
84
+ id: customIdGen({ model })
85
+ } : {
74
86
  _id: new ObjectId()
75
87
  };
76
88
  const fields = schema[model].fields;
@@ -177,17 +189,18 @@ var createTransform = (options) => {
177
189
  };
178
190
  var mongodbAdapter = (db) => (options) => {
179
191
  const transform = createTransform(options);
192
+ const hasCustomId = options.advanced?.generateId;
180
193
  return {
181
194
  id: "mongodb-adapter",
182
195
  async create(data) {
183
196
  const { model, data: values, select } = data;
184
197
  const transformedData = transform.transformInput(values, model, "create");
185
- if (transformedData.id) {
198
+ if (transformedData.id && !hasCustomId) {
186
199
  delete transformedData.id;
187
200
  }
188
201
  const res = await db.collection(transform.getModelName(model)).insertOne(transformedData);
189
202
  const id = res.insertedId;
190
- const insertedData = { ...transformedData, id: id.toString() };
203
+ const insertedData = { id: id.toString(), ...transformedData };
191
204
  const t = transform.transformOutput(insertedData, model, select);
192
205
  return t;
193
206
  },
@@ -213,6 +226,11 @@ var mongodbAdapter = (db) => (options) => {
213
226
  const res = await cursor.toArray();
214
227
  return res.map((r) => transform.transformOutput(r, model));
215
228
  },
229
+ async count(data) {
230
+ const { model } = data;
231
+ const res = await db.collection(transform.getModelName(model)).countDocuments();
232
+ return res;
233
+ },
216
234
  async update(data) {
217
235
  const { model, where, update: values } = data;
218
236
  const clause = transform.convertWhereClause(where, model);
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkWDOY7YUW_cjs = require('../chunk-WDOY7YUW.cjs');
3
+ var chunkKAR56MJZ_cjs = require('../chunk-KAR56MJZ.cjs');
4
4
  require('../chunk-B5UCLTPZ.cjs');
5
5
  var chunkH74YRRNV_cjs = require('../chunk-H74YRRNV.cjs');
6
- require('../chunk-5E75URIA.cjs');
6
+ require('../chunk-2Z6CVQHH.cjs');
7
7
  require('../chunk-NIMYOIVU.cjs');
8
8
  require('../chunk-CCKQSGIR.cjs');
9
9
  require('../chunk-G2LZ73E2.cjs');
@@ -14,7 +14,7 @@ var chunkPEZRSDZS_cjs = require('../chunk-PEZRSDZS.cjs');
14
14
 
15
15
  // src/adapters/prisma-adapter/prisma-adapter.ts
16
16
  var createTransform = (config, options) => {
17
- const schema = chunkWDOY7YUW_cjs.getAuthTables(options);
17
+ const schema = chunkKAR56MJZ_cjs.getAuthTables(options);
18
18
  function getField(model, field) {
19
19
  if (field === "id") {
20
20
  return field;
@@ -49,7 +49,7 @@ var createTransform = (config, options) => {
49
49
  if (value === void 0 && (!fields[field].defaultValue || action === "update")) {
50
50
  continue;
51
51
  }
52
- transformedData[fields[field].fieldName || field] = chunkWDOY7YUW_cjs.withApplyDefault(
52
+ transformedData[fields[field].fieldName || field] = chunkKAR56MJZ_cjs.withApplyDefault(
53
53
  value,
54
54
  fields[field],
55
55
  action
@@ -181,6 +181,19 @@ var prismaAdapter = (prisma, config) => (options) => {
181
181
  });
182
182
  return result.map((r) => transformOutput(r, model));
183
183
  },
184
+ async count(data) {
185
+ const { model, where } = data;
186
+ const whereClause = convertWhereClause(model, where);
187
+ if (!db[getModelName(model)]) {
188
+ throw new chunkPEZRSDZS_cjs.BetterAuthError(
189
+ `Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`
190
+ );
191
+ }
192
+ const result = await db[getModelName(model)].count({
193
+ where: whereClause
194
+ });
195
+ return result;
196
+ },
184
197
  async update(data) {
185
198
  const { model, where, update } = data;
186
199
  if (!db[getModelName(model)]) {
@@ -1,9 +1,9 @@
1
- import { B as BetterAuthOptions, W as Where } from '../auth-D4rdpxtI.cjs';
1
+ import { B as BetterAuthOptions, W as Where } from '../auth-BLwS7t0V.cjs';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.cjs';
6
- import '../index-Ba5bMY6A.cjs';
6
+ import '../index-BuRgaJZR.cjs';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -37,6 +37,10 @@ declare const prismaAdapter: (prisma: PrismaClient, config: PrismaConfig) => (op
37
37
  };
38
38
  offset?: number;
39
39
  }): Promise<any[]>;
40
+ count(data: {
41
+ model: string;
42
+ where?: Where[];
43
+ }): Promise<any>;
40
44
  update<T>(data: {
41
45
  model: string;
42
46
  where: Where[];
@@ -1,9 +1,9 @@
1
- import { B as BetterAuthOptions, W as Where } from '../auth-DcMc3BIq.js';
1
+ import { B as BetterAuthOptions, W as Where } from '../auth-C42JqOR9.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.js';
6
- import '../index-XrJz4AYF.js';
6
+ import '../index-moQjyfmm.js';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -37,6 +37,10 @@ declare const prismaAdapter: (prisma: PrismaClient, config: PrismaConfig) => (op
37
37
  };
38
38
  offset?: number;
39
39
  }): Promise<any[]>;
40
+ count(data: {
41
+ model: string;
42
+ where?: Where[];
43
+ }): Promise<any>;
40
44
  update<T>(data: {
41
45
  model: string;
42
46
  where: Where[];
@@ -1,7 +1,7 @@
1
- import { getAuthTables, withApplyDefault } from '../chunk-MGJLVQOV.js';
1
+ import { getAuthTables, withApplyDefault } from '../chunk-EQYRCOOF.js';
2
2
  import '../chunk-HZBNUY7E.js';
3
3
  import { generateId } from '../chunk-KLDFBLYL.js';
4
- import '../chunk-NPO64SVN.js';
4
+ import '../chunk-ZFUBVSZD.js';
5
5
  import '../chunk-SK6Y2YH6.js';
6
6
  import '../chunk-3XTQSPPA.js';
7
7
  import '../chunk-DBPOZRMS.js';
@@ -179,6 +179,19 @@ var prismaAdapter = (prisma, config) => (options) => {
179
179
  });
180
180
  return result.map((r) => transformOutput(r, model));
181
181
  },
182
+ async count(data) {
183
+ const { model, where } = data;
184
+ const whereClause = convertWhereClause(model, where);
185
+ if (!db[getModelName(model)]) {
186
+ throw new BetterAuthError(
187
+ `Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`
188
+ );
189
+ }
190
+ const result = await db[getModelName(model)].count({
191
+ where: whereClause
192
+ });
193
+ return result;
194
+ },
182
195
  async update(data) {
183
196
  const { model, where, update } = data;
184
197
  if (!db[getModelName(model)]) {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkH74YRRNV_cjs = require('../chunk-H74YRRNV.cjs');
4
- require('../chunk-5E75URIA.cjs');
4
+ require('../chunk-2Z6CVQHH.cjs');
5
5
  require('../chunk-CCKQSGIR.cjs');
6
6
  require('../chunk-G2LZ73E2.cjs');
7
7
  var vitest = require('vitest');
@@ -1,9 +1,9 @@
1
- import { B as BetterAuthOptions, A as Adapter } from '../auth-D4rdpxtI.cjs';
1
+ import { B as BetterAuthOptions, A as Adapter } from '../auth-BLwS7t0V.cjs';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import '../helper-Bi8FQwDD.cjs';
6
- import '../index-Ba5bMY6A.cjs';
6
+ import '../index-BuRgaJZR.cjs';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9