@better-auth/prisma-adapter 1.5.7-beta.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -31,5 +31,4 @@ interface PrismaConfig {
31
31
  interface PrismaClient {}
32
32
  declare const prismaAdapter: (prisma: PrismaClient, config: PrismaConfig) => (options: BetterAuthOptions) => DBAdapter<BetterAuthOptions>;
33
33
  //#endregion
34
- export { PrismaConfig, prismaAdapter };
35
- //# sourceMappingURL=index.d.mts.map
34
+ export { PrismaConfig, prismaAdapter };
package/dist/index.mjs CHANGED
@@ -62,6 +62,11 @@ const prismaAdapter = (prisma, config) => {
62
62
  return where.some((condition) => {
63
63
  if (condition.connector === "OR") return false;
64
64
  if (condition.operator && condition.operator !== "eq") return false;
65
+ if (condition.mode === "insensitive") {
66
+ const providerSupportsMode = config.provider === "postgresql" || config.provider === "mongodb";
67
+ const isStringValue = typeof condition.value === "string" || Array.isArray(condition.value) && condition.value.every((v) => typeof v === "string");
68
+ if (providerSupportsMode && isStringValue) return false;
69
+ }
65
70
  if (condition.field === "id") return true;
66
71
  return getFieldAttributes({
67
72
  model,
@@ -76,6 +81,10 @@ const prismaAdapter = (prisma, config) => {
76
81
  model,
77
82
  field: w.field
78
83
  });
84
+ const isInsensitive = (w.mode ?? "sensitive") === "insensitive" && (typeof w.value === "string" || Array.isArray(w.value) && w.value.every((v) => typeof v === "string"));
85
+ const providerSupportsMode = config.provider === "postgresql" || config.provider === "mongodb";
86
+ const prismaMode = isInsensitive && providerSupportsMode ? "insensitive" : void 0;
87
+ const modeFilter = prismaMode ? { mode: prismaMode } : {};
79
88
  if (w.operator === "ne" && w.value === null) return getFieldAttributes({
80
89
  model,
81
90
  field: w.field
@@ -85,21 +94,39 @@ const prismaAdapter = (prisma, config) => {
85
94
  if (filtered.length === 0) if (w.operator === "in") return { AND: [{ [fieldName]: { equals: "__never__" } }, { [fieldName]: { not: "__never__" } }] };
86
95
  else return {};
87
96
  const prismaOp = operatorToPrismaOperator(w.operator);
88
- return { [fieldName]: { [prismaOp]: filtered } };
97
+ return { [fieldName]: {
98
+ [prismaOp]: filtered,
99
+ ...modeFilter
100
+ } };
89
101
  }
90
- if (w.operator === "eq" || !w.operator) return { [fieldName]: w.value };
91
- return { [fieldName]: { [operatorToPrismaOperator(w.operator)]: w.value } };
102
+ if (w.operator === "eq" || !w.operator) return { [fieldName]: {
103
+ equals: w.value,
104
+ ...modeFilter
105
+ } };
106
+ if (w.operator === "ne") return { [fieldName]: {
107
+ not: { equals: w.value },
108
+ ...modeFilter
109
+ } };
110
+ const prismaOp = operatorToPrismaOperator(w.operator);
111
+ return { [fieldName]: {
112
+ [prismaOp]: w.value,
113
+ ...modeFilter
114
+ } };
92
115
  };
93
116
  if (action === "update") {
94
117
  const and = where.filter((w) => w.connector === "AND" || !w.connector);
95
118
  const or = where.filter((w) => w.connector === "OR");
96
119
  const andSimple = and.filter((w) => w.operator === "eq" || !w.operator);
97
- const andComplex = and.filter((w) => w.operator !== "eq" && w.operator !== void 0);
98
- const andSimpleClause = andSimple.map((w) => buildSingleCondition(w));
99
- const andComplexClause = andComplex.map((w) => buildSingleCondition(w));
120
+ const andComplexClause = and.filter((w) => w.operator !== "eq" && w.operator !== void 0).map((w) => buildSingleCondition(w));
100
121
  const orClause = or.map((w) => buildSingleCondition(w));
101
122
  const result = {};
102
- for (const clause of andSimpleClause) Object.assign(result, clause);
123
+ for (const w of andSimple) {
124
+ const fieldName = getFieldName({
125
+ model,
126
+ field: w.field
127
+ });
128
+ result[fieldName] = w.value;
129
+ }
103
130
  if (andComplexClause.length > 0) result.AND = andComplexClause;
104
131
  if (orClause.length > 0) result.OR = orClause;
105
132
  return result;
@@ -111,16 +138,13 @@ const prismaAdapter = (prisma, config) => {
111
138
  model,
112
139
  field: "id"
113
140
  });
114
- const idClause = buildSingleCondition(idCondition);
115
141
  const remainingWhere = where.filter((w) => w.field !== "id");
116
- if (remainingWhere.length === 0) return idClause;
142
+ if (remainingWhere.length === 0) return { [idFieldName]: idCondition.value };
117
143
  const and = remainingWhere.filter((w) => w.connector === "AND" || !w.connector);
118
144
  const or = remainingWhere.filter((w) => w.connector === "OR");
119
145
  const andClause = and.map((w) => buildSingleCondition(w));
120
146
  const orClause = or.map((w) => buildSingleCondition(w));
121
- const result = {};
122
- if (idFieldName in idClause) result[idFieldName] = idClause[idFieldName];
123
- else Object.assign(result, idClause);
147
+ const result = { [idFieldName]: idCondition.value };
124
148
  if (andClause.length > 0) result.AND = andClause;
125
149
  if (orClause.length > 0) result.OR = orClause;
126
150
  return result;
@@ -314,5 +338,3 @@ const prismaAdapter = (prisma, config) => {
314
338
  };
315
339
  //#endregion
316
340
  export { prismaAdapter };
317
-
318
- //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/prisma-adapter",
3
- "version": "1.5.7-beta.1",
3
+ "version": "1.6.0",
4
4
  "description": "Prisma adapter for Better Auth",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,6 +20,7 @@
20
20
  "publishConfig": {
21
21
  "access": "public"
22
22
  },
23
+ "sideEffects": false,
23
24
  "files": [
24
25
  "dist"
25
26
  ],
@@ -34,10 +35,10 @@
34
35
  }
35
36
  },
36
37
  "peerDependencies": {
37
- "@better-auth/utils": "^0.3.0",
38
+ "@better-auth/utils": "0.4.0",
38
39
  "@prisma/client": "^5.0.0 || ^6.0.0 || ^7.0.0",
39
40
  "prisma": "^5.0.0 || ^6.0.0 || ^7.0.0",
40
- "@better-auth/core": "1.5.7-beta.1"
41
+ "@better-auth/core": "^1.6.0"
41
42
  },
42
43
  "peerDependenciesMeta": {
43
44
  "@prisma/client": {
@@ -48,16 +49,15 @@
48
49
  }
49
50
  },
50
51
  "devDependencies": {
51
- "@better-auth/utils": "^0.3.1",
52
- "prisma": "^7.4.1",
52
+ "@better-auth/utils": "0.4.0",
53
53
  "tsdown": "0.21.1",
54
54
  "typescript": "^5.9.3",
55
- "@better-auth/core": "1.5.7-beta.1"
55
+ "@better-auth/core": "1.6.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsdown",
59
59
  "dev": "tsdown --watch",
60
- "lint:package": "publint run --strict",
60
+ "lint:package": "publint run --strict --pack false",
61
61
  "lint:types": "attw --profile esm-only --pack .",
62
62
  "typecheck": "tsc --noEmit",
63
63
  "test": "vitest"
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/prisma-adapter.ts"],"sourcesContent":["import type { Awaitable, BetterAuthOptions } from \"@better-auth/core\";\nimport type {\n\tAdapterFactoryCustomizeAdapterCreator,\n\tAdapterFactoryOptions,\n\tDBAdapter,\n\tDBAdapterDebugLogOption,\n\tJoinConfig,\n\tWhere,\n} from \"@better-auth/core/db/adapter\";\nimport { createAdapterFactory } from \"@better-auth/core/db/adapter\";\nimport { BetterAuthError } from \"@better-auth/core/error\";\n\nexport interface PrismaConfig {\n\t/**\n\t * Database provider.\n\t */\n\tprovider:\n\t\t| \"sqlite\"\n\t\t| \"cockroachdb\"\n\t\t| \"mysql\"\n\t\t| \"postgresql\"\n\t\t| \"sqlserver\"\n\t\t| \"mongodb\";\n\n\t/**\n\t * Enable debug logs for the adapter\n\t *\n\t * @default false\n\t */\n\tdebugLogs?: DBAdapterDebugLogOption | undefined;\n\n\t/**\n\t * Use plural table names\n\t *\n\t * @default false\n\t */\n\tusePlural?: boolean | undefined;\n\n\t/**\n\t * Whether to execute multiple operations in a transaction.\n\t *\n\t * If the database doesn't support transactions,\n\t * set this to `false` and operations will be executed sequentially.\n\t * @default false\n\t */\n\ttransaction?: boolean | undefined;\n}\n\ninterface PrismaClient {}\n\ntype PrismaClientInternal = {\n\t$transaction: (\n\t\tcallback: (db: PrismaClient) => Awaitable<any>,\n\t) => Promise<any>;\n} & {\n\t[model: string]: {\n\t\tcreate: (data: any) => Promise<any>;\n\t\tfindFirst: (data: any) => Promise<any>;\n\t\tfindMany: (data: any) => Promise<any>;\n\t\tupdate: (data: any) => Promise<any>;\n\t\tupdateMany: (data: any) => Promise<any>;\n\t\tdelete: (data: any) => Promise<any>;\n\t\t[key: string]: any;\n\t};\n};\n\nexport const prismaAdapter = (prisma: PrismaClient, config: PrismaConfig) => {\n\tlet lazyOptions: BetterAuthOptions | null = null;\n\tconst createCustomAdapter =\n\t\t(prisma: PrismaClient): AdapterFactoryCustomizeAdapterCreator =>\n\t\t({\n\t\t\tgetFieldName,\n\t\t\tgetModelName,\n\t\t\tgetFieldAttributes,\n\t\t\tgetDefaultModelName,\n\t\t\tschema,\n\t\t}) => {\n\t\t\tconst db = prisma as PrismaClientInternal;\n\n\t\t\tconst convertSelect = (\n\t\t\t\tselect: string[] | undefined,\n\t\t\t\tmodel: string,\n\t\t\t\tjoin?: JoinConfig | undefined,\n\t\t\t) => {\n\t\t\t\tif (!select && !join) return undefined;\n\n\t\t\t\tconst result: Record<string, Record<string, any> | boolean> = {};\n\n\t\t\t\tif (select) {\n\t\t\t\t\tfor (const field of select) {\n\t\t\t\t\t\tresult[getFieldName({ model, field })] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (join) {\n\t\t\t\t\t// when joining that has a limit, we need to use Prisma's `select` syntax to append the limit to the field\n\t\t\t\t\t// because of such, it also means we need to select all base-model fields as well\n\t\t\t\t\t// should check if `select` is not provided, because then we should select all base-model fields\n\t\t\t\t\tif (!select) {\n\t\t\t\t\t\tconst fields = schema[getDefaultModelName(model)]?.fields || {};\n\t\t\t\t\t\tfields.id = { type: \"string\" }; // make sure there is at least an id field\n\t\t\t\t\t\tfor (const field of Object.keys(fields)) {\n\t\t\t\t\t\t\tresult[getFieldName({ model, field })] = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const [joinModel, joinAttr] of Object.entries(join)) {\n\t\t\t\t\t\tconst key = getJoinKeyName(model, getModelName(joinModel), schema);\n\t\t\t\t\t\tif (joinAttr.relation === \"one-to-one\") {\n\t\t\t\t\t\t\tresult[key] = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult[key] = { take: joinAttr.limit };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Build the join key name based on whether the foreign field is unique or not.\n\t\t\t * If unique, use singular. Otherwise, pluralize (add 's').\n\t\t\t */\n\t\t\tconst getJoinKeyName = (\n\t\t\t\tbaseModel: string,\n\t\t\t\tjoinedModel: string,\n\t\t\t\tschema: any,\n\t\t\t): string => {\n\t\t\t\ttry {\n\t\t\t\t\tconst defaultBaseModelName = getDefaultModelName(baseModel);\n\t\t\t\t\tconst defaultJoinedModelName = getDefaultModelName(joinedModel);\n\t\t\t\t\tconst key = getModelName(joinedModel).toLowerCase();\n\n\t\t\t\t\t// First, check if the joined model has FKs to the base model (forward join)\n\t\t\t\t\tlet foreignKeys = Object.entries(\n\t\t\t\t\t\tschema[defaultJoinedModelName]?.fields || {},\n\t\t\t\t\t).filter(\n\t\t\t\t\t\t([_field, fieldAttributes]: any) =>\n\t\t\t\t\t\t\tfieldAttributes.references &&\n\t\t\t\t\t\t\tgetDefaultModelName(fieldAttributes.references.model) ===\n\t\t\t\t\t\t\t\tdefaultBaseModelName,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (foreignKeys.length > 0) {\n\t\t\t\t\t\t// Forward join: joined model has FK to base model\n\t\t\t\t\t\t// This is typically a one-to-many relationship (plural)\n\t\t\t\t\t\t// Unless the FK is unique, then it's one-to-one (singular)\n\t\t\t\t\t\tconst [_foreignKey, foreignKeyAttributes] = foreignKeys[0] as any;\n\t\t\t\t\t\t// Only check if field is explicitly marked as unique\n\t\t\t\t\t\tconst isUnique = foreignKeyAttributes?.unique === true;\n\t\t\t\t\t\treturn isUnique || config.usePlural === true ? key : `${key}s`;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check backwards: does the base model have FKs to the joined model?\n\t\t\t\t\tforeignKeys = Object.entries(\n\t\t\t\t\t\tschema[defaultBaseModelName]?.fields || {},\n\t\t\t\t\t).filter(\n\t\t\t\t\t\t([_field, fieldAttributes]: any) =>\n\t\t\t\t\t\t\tfieldAttributes.references &&\n\t\t\t\t\t\t\tgetDefaultModelName(fieldAttributes.references.model) ===\n\t\t\t\t\t\t\t\tdefaultJoinedModelName,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (foreignKeys.length > 0) {\n\t\t\t\t\t\treturn key;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Fallback to pluralizing if we can't determine uniqueness\n\t\t\t\t}\n\t\t\t\treturn `${getModelName(joinedModel).toLowerCase()}s`;\n\t\t\t};\n\t\t\tfunction operatorToPrismaOperator(operator: string) {\n\t\t\t\tswitch (operator) {\n\t\t\t\t\tcase \"starts_with\":\n\t\t\t\t\t\treturn \"startsWith\";\n\t\t\t\t\tcase \"ends_with\":\n\t\t\t\t\t\treturn \"endsWith\";\n\t\t\t\t\tcase \"ne\":\n\t\t\t\t\t\treturn \"not\";\n\t\t\t\t\tcase \"not_in\":\n\t\t\t\t\t\treturn \"notIn\";\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn operator;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst hasRootUniqueWhereCondition = (\n\t\t\t\tmodel: string,\n\t\t\t\twhere?: Where[] | undefined,\n\t\t\t) => {\n\t\t\t\tif (!where?.length) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn where.some((condition) => {\n\t\t\t\t\tif (condition.connector === \"OR\") {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (condition.operator && condition.operator !== \"eq\") {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (condition.field === \"id\") {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\tgetFieldAttributes({\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tfield: condition.field,\n\t\t\t\t\t\t})?.unique === true\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t};\n\t\t\tconst convertWhereClause = ({\n\t\t\t\taction,\n\t\t\t\tmodel,\n\t\t\t\twhere,\n\t\t\t}: {\n\t\t\t\tmodel: string;\n\t\t\t\twhere?: Where[] | undefined;\n\t\t\t\taction:\n\t\t\t\t\t| \"create\"\n\t\t\t\t\t| \"update\"\n\t\t\t\t\t| \"delete\"\n\t\t\t\t\t| \"findOne\"\n\t\t\t\t\t| \"findMany\"\n\t\t\t\t\t| \"count\"\n\t\t\t\t\t| \"updateMany\"\n\t\t\t\t\t| \"deleteMany\";\n\t\t\t}) => {\n\t\t\t\tif (!where || !where.length) return {};\n\t\t\t\tconst buildSingleCondition = (w: Where) => {\n\t\t\t\t\tconst fieldName = getFieldName({ model, field: w.field });\n\t\t\t\t\t// Special handling for Prisma null semantics, for non-nullable fields this is a tautology. Skip condition.\n\t\t\t\t\tif (w.operator === \"ne\" && w.value === null) {\n\t\t\t\t\t\tconst fieldAttributes = getFieldAttributes({\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tfield: w.field,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst isNullable = fieldAttributes?.required !== true;\n\t\t\t\t\t\treturn isNullable ? { [fieldName]: { not: null } } : {};\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\t(w.operator === \"in\" || w.operator === \"not_in\") &&\n\t\t\t\t\t\tArray.isArray(w.value)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst filtered = w.value.filter((v) => v != null);\n\t\t\t\t\t\tif (filtered.length === 0) {\n\t\t\t\t\t\t\tif (w.operator === \"in\") {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tAND: [\n\t\t\t\t\t\t\t\t\t\t{ [fieldName]: { equals: \"__never__\" } },\n\t\t\t\t\t\t\t\t\t\t{ [fieldName]: { not: \"__never__\" } },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst prismaOp = operatorToPrismaOperator(w.operator);\n\t\t\t\t\t\treturn { [fieldName]: { [prismaOp]: filtered } };\n\t\t\t\t\t}\n\t\t\t\t\tif (w.operator === \"eq\" || !w.operator) {\n\t\t\t\t\t\treturn { [fieldName]: w.value };\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\t[fieldName]: {\n\t\t\t\t\t\t\t[operatorToPrismaOperator(w.operator)]: w.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t};\n\n\t\t\t\t// Special handling for update actions: extract AND conditions with eq operator to root level\n\t\t\t\t// Prisma requires unique fields to be at root level, not nested in AND arrays\n\t\t\t\t// Only simple equality conditions can be at root level; complex operators must stay in AND array\n\t\t\t\tif (action === \"update\") {\n\t\t\t\t\tconst and = where.filter(\n\t\t\t\t\t\t(w) => w.connector === \"AND\" || !w.connector,\n\t\t\t\t\t);\n\t\t\t\t\tconst or = where.filter((w) => w.connector === \"OR\");\n\n\t\t\t\t\t// Separate AND conditions into simple eq (can extract) and complex (must stay in AND)\n\t\t\t\t\tconst andSimple = and.filter(\n\t\t\t\t\t\t(w) => w.operator === \"eq\" || !w.operator,\n\t\t\t\t\t);\n\t\t\t\t\tconst andComplex = and.filter(\n\t\t\t\t\t\t(w) => w.operator !== \"eq\" && w.operator !== undefined,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst andSimpleClause = andSimple.map((w) => buildSingleCondition(w));\n\t\t\t\t\tconst andComplexClause = andComplex.map((w) =>\n\t\t\t\t\t\tbuildSingleCondition(w),\n\t\t\t\t\t);\n\t\t\t\t\tconst orClause = or.map((w) => buildSingleCondition(w));\n\n\t\t\t\t\t// Extract simple equality AND conditions to root level\n\t\t\t\t\tconst result: Record<string, any> = {};\n\t\t\t\t\tfor (const clause of andSimpleClause) {\n\t\t\t\t\t\tObject.assign(result, clause);\n\t\t\t\t\t}\n\t\t\t\t\t// Keep complex AND conditions in AND array\n\t\t\t\t\tif (andComplexClause.length > 0) {\n\t\t\t\t\t\tresult.AND = andComplexClause;\n\t\t\t\t\t}\n\t\t\t\t\tif (orClause.length > 0) {\n\t\t\t\t\t\tresult.OR = orClause;\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\t// Special handling for delete actions: extract id to root level\n\t\t\t\tif (action === \"delete\") {\n\t\t\t\t\tconst idCondition = where.find((w) => w.field === \"id\");\n\t\t\t\t\tif (idCondition) {\n\t\t\t\t\t\tconst idFieldName = getFieldName({ model, field: \"id\" });\n\t\t\t\t\t\tconst idClause = buildSingleCondition(idCondition);\n\t\t\t\t\t\tconst remainingWhere = where.filter((w) => w.field !== \"id\");\n\n\t\t\t\t\t\tif (remainingWhere.length === 0) {\n\t\t\t\t\t\t\treturn idClause;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst and = remainingWhere.filter(\n\t\t\t\t\t\t\t(w) => w.connector === \"AND\" || !w.connector,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst or = remainingWhere.filter((w) => w.connector === \"OR\");\n\t\t\t\t\t\tconst andClause = and.map((w) => buildSingleCondition(w));\n\t\t\t\t\t\tconst orClause = or.map((w) => buildSingleCondition(w));\n\n\t\t\t\t\t\t// Extract id to root level, put other conditions in AND array\n\t\t\t\t\t\tconst result: Record<string, any> = {};\n\t\t\t\t\t\tif (idFieldName in idClause) {\n\t\t\t\t\t\t\tresult[idFieldName] = (idClause as Record<string, any>)[\n\t\t\t\t\t\t\t\tidFieldName\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Handle edge case where idClause might have special structure\n\t\t\t\t\t\t\tObject.assign(result, idClause);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (andClause.length > 0) {\n\t\t\t\t\t\t\tresult.AND = andClause;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (orClause.length > 0) {\n\t\t\t\t\t\t\tresult.OR = orClause;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (where.length === 1) {\n\t\t\t\t\tconst w = where[0]!;\n\t\t\t\t\tif (!w) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\treturn buildSingleCondition(w);\n\t\t\t\t}\n\t\t\t\tconst and = where.filter((w) => w.connector === \"AND\" || !w.connector);\n\t\t\t\tconst or = where.filter((w) => w.connector === \"OR\");\n\t\t\t\tconst andClause = and.map((w) => buildSingleCondition(w));\n\t\t\t\tconst orClause = or.map((w) => buildSingleCondition(w));\n\n\t\t\t\treturn {\n\t\t\t\t\t...(andClause.length ? { AND: andClause } : {}),\n\t\t\t\t\t...(orClause.length ? { OR: orClause } : {}),\n\t\t\t\t};\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tasync create({ model, data: values, select }) {\n\t\t\t\t\tif (!db[model]) {\n\t\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\t`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await db[model]!.create({\n\t\t\t\t\t\tdata: values,\n\t\t\t\t\t\tselect: convertSelect(select, model),\n\t\t\t\t\t});\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t\tasync findOne({ model, where, select, join }) {\n\t\t\t\t\t// this is just \"JoinOption\" type because we disabled join transformation in adapter config\n\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\twhere,\n\t\t\t\t\t\taction: \"findOne\",\n\t\t\t\t\t});\n\t\t\t\t\tif (!db[model]) {\n\t\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\t`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// transform join keys to use Prisma expected field names\n\t\t\t\t\tconst map = new Map<string, string>();\n\t\t\t\t\tfor (const joinModel of Object.keys(join ?? {})) {\n\t\t\t\t\t\tconst key = getJoinKeyName(model, joinModel, schema);\n\t\t\t\t\t\tmap.set(key, getModelName(joinModel));\n\t\t\t\t\t}\n\n\t\t\t\t\tconst selects = convertSelect(select, model, join);\n\n\t\t\t\t\tconst result = await db[model]!.findFirst({\n\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t\tselect: selects,\n\t\t\t\t\t});\n\n\t\t\t\t\t// transform the resulting `include` items to use better-auth expected field names\n\t\t\t\t\tif (join && result) {\n\t\t\t\t\t\tfor (const [includeKey, originalKey] of map.entries()) {\n\t\t\t\t\t\t\tif (includeKey === originalKey) continue;\n\t\t\t\t\t\t\tif (includeKey in result) {\n\t\t\t\t\t\t\t\tresult[originalKey] = result[includeKey];\n\t\t\t\t\t\t\t\tdelete result[includeKey];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t\tasync findMany({ model, where, limit, select, offset, sortBy, join }) {\n\t\t\t\t\t// this is just \"JoinOption\" type because we disabled join transformation in adapter config\n\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\twhere,\n\t\t\t\t\t\taction: \"findMany\",\n\t\t\t\t\t});\n\t\t\t\t\tif (!db[model]) {\n\t\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\t`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\t// transform join keys to use Prisma expected field names\n\t\t\t\t\tconst map = new Map<string, string>();\n\t\t\t\t\tif (join) {\n\t\t\t\t\t\tfor (const [joinModel, _value] of Object.entries(join)) {\n\t\t\t\t\t\t\tconst key = getJoinKeyName(model, joinModel, schema);\n\t\t\t\t\t\t\tmap.set(key, getModelName(joinModel));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst selects = convertSelect(select, model, join);\n\n\t\t\t\t\tconst result = await db[model]!.findMany({\n\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t\ttake: limit || 100,\n\t\t\t\t\t\tskip: offset || 0,\n\t\t\t\t\t\t...(sortBy?.field\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\torderBy: {\n\t\t\t\t\t\t\t\t\t\t[getFieldName({ model, field: sortBy.field })]:\n\t\t\t\t\t\t\t\t\t\t\tsortBy.direction === \"desc\" ? \"desc\" : \"asc\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\tselect: selects,\n\t\t\t\t\t});\n\n\t\t\t\t\t// transform the resulting join items to use better-auth expected field names\n\t\t\t\t\tif (join && Array.isArray(result)) {\n\t\t\t\t\t\tfor (const item of result) {\n\t\t\t\t\t\t\tfor (const [includeKey, originalKey] of map.entries()) {\n\t\t\t\t\t\t\t\tif (includeKey === originalKey) continue;\n\t\t\t\t\t\t\t\tif (includeKey in item) {\n\t\t\t\t\t\t\t\t\titem[originalKey] = item[includeKey];\n\t\t\t\t\t\t\t\t\tdelete item[includeKey];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t\tasync count({ model, where }) {\n\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\twhere,\n\t\t\t\t\t\taction: \"count\",\n\t\t\t\t\t});\n\t\t\t\t\tif (!db[model]) {\n\t\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\t`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn await db[model]!.count({\n\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tasync update({ model, where, update }) {\n\t\t\t\t\tif (!db[model]) {\n\t\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\t`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst hasRootUniqueCondition = hasRootUniqueWhereCondition(\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\twhere,\n\t\t\t\t\t);\n\t\t\t\t\tif (!hasRootUniqueCondition) {\n\t\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\twhere,\n\t\t\t\t\t\t\taction: \"updateMany\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst result = await db[model]!.updateMany({\n\t\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t\t\tdata: update,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!result?.count) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn await db[model]!.findFirst({\n\t\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\twhere,\n\t\t\t\t\t\taction: \"update\",\n\t\t\t\t\t});\n\n\t\t\t\t\treturn await db[model]!.update({\n\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t\tdata: update,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tasync updateMany({ model, where, update }) {\n\t\t\t\t\tif (!db[model]) {\n\t\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\t`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\twhere,\n\t\t\t\t\t\taction: \"updateMany\",\n\t\t\t\t\t});\n\t\t\t\t\tconst result = await db[model]!.updateMany({\n\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t\tdata: update,\n\t\t\t\t\t});\n\t\t\t\t\treturn result ? (result.count as number) : 0;\n\t\t\t\t},\n\t\t\t\tasync delete({ model, where }) {\n\t\t\t\t\tif (!db[model]) {\n\t\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\t`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\t// Prisma's delete() requires a WhereUniqueInput (unique/primary key field).\n\t\t\t\t\t// When deleting by non-unique fields (e.g. identifier), fall back to deleteMany.\n\t\t\t\t\tconst hasIdField = where?.some((w) => w.field === \"id\");\n\t\t\t\t\tif (!hasIdField) {\n\t\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\twhere,\n\t\t\t\t\t\t\taction: \"deleteMany\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait db[model]!.deleteMany({\n\t\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\twhere,\n\t\t\t\t\t\taction: \"delete\",\n\t\t\t\t\t});\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait db[model]!.delete({\n\t\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (e: any) {\n\t\t\t\t\t\t// If the record doesn't exist, we don't want to throw an error\n\t\t\t\t\t\tif (e?.meta?.cause === \"Record to delete does not exist.\") return;\n\t\t\t\t\t\tif (e?.code === \"P2025\") return; // Prisma 7+\n\t\t\t\t\t\t// otherwise if it's an unknown error, we want to just log it for debugging.\n\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync deleteMany({ model, where }) {\n\t\t\t\t\tconst whereClause = convertWhereClause({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\twhere,\n\t\t\t\t\t\taction: \"deleteMany\",\n\t\t\t\t\t});\n\t\t\t\t\tconst result = await db[model]!.deleteMany({\n\t\t\t\t\t\twhere: whereClause,\n\t\t\t\t\t});\n\t\t\t\t\treturn result ? (result.count as number) : 0;\n\t\t\t\t},\n\t\t\t\toptions: config,\n\t\t\t};\n\t\t};\n\n\tlet adapterOptions: AdapterFactoryOptions | null = null;\n\tadapterOptions = {\n\t\tconfig: {\n\t\t\tadapterId: \"prisma\",\n\t\t\tadapterName: \"Prisma Adapter\",\n\t\t\tusePlural: config.usePlural ?? false,\n\t\t\tdebugLogs: config.debugLogs ?? false,\n\t\t\tsupportsUUIDs: config.provider === \"postgresql\" ? true : false,\n\t\t\tsupportsArrays:\n\t\t\t\tconfig.provider === \"postgresql\" || config.provider === \"mongodb\"\n\t\t\t\t\t? true\n\t\t\t\t\t: false,\n\t\t\ttransaction:\n\t\t\t\t(config.transaction ?? false)\n\t\t\t\t\t? (cb) =>\n\t\t\t\t\t\t\t(prisma as PrismaClientInternal).$transaction((tx) => {\n\t\t\t\t\t\t\t\tconst adapter = createAdapterFactory({\n\t\t\t\t\t\t\t\t\tconfig: adapterOptions!.config,\n\t\t\t\t\t\t\t\t\tadapter: createCustomAdapter(tx),\n\t\t\t\t\t\t\t\t})(lazyOptions!);\n\t\t\t\t\t\t\t\treturn cb(adapter);\n\t\t\t\t\t\t\t})\n\t\t\t\t\t: false,\n\t\t},\n\t\tadapter: createCustomAdapter(prisma),\n\t};\n\n\tconst adapter = createAdapterFactory(adapterOptions);\n\treturn (options: BetterAuthOptions): DBAdapter<BetterAuthOptions> => {\n\t\tlazyOptions = options;\n\t\treturn adapter(options);\n\t};\n};\n"],"mappings":";;;AAkEA,MAAa,iBAAiB,QAAsB,WAAyB;CAC5E,IAAI,cAAwC;CAC5C,MAAM,uBACJ,YACA,EACA,cACA,cACA,oBACA,qBACA,aACK;EACL,MAAM,KAAK;EAEX,MAAM,iBACL,QACA,OACA,SACI;AACJ,OAAI,CAAC,UAAU,CAAC,KAAM,QAAO,KAAA;GAE7B,MAAM,SAAwD,EAAE;AAEhE,OAAI,OACH,MAAK,MAAM,SAAS,OACnB,QAAO,aAAa;IAAE;IAAO;IAAO,CAAC,IAAI;AAI3C,OAAI,MAAM;AAIT,QAAI,CAAC,QAAQ;KACZ,MAAM,SAAS,OAAO,oBAAoB,MAAM,GAAG,UAAU,EAAE;AAC/D,YAAO,KAAK,EAAE,MAAM,UAAU;AAC9B,UAAK,MAAM,SAAS,OAAO,KAAK,OAAO,CACtC,QAAO,aAAa;MAAE;MAAO;MAAO,CAAC,IAAI;;AAI3C,SAAK,MAAM,CAAC,WAAW,aAAa,OAAO,QAAQ,KAAK,EAAE;KACzD,MAAM,MAAM,eAAe,OAAO,aAAa,UAAU,EAAE,OAAO;AAClE,SAAI,SAAS,aAAa,aACzB,QAAO,OAAO;SAEd,QAAO,OAAO,EAAE,MAAM,SAAS,OAAO;;;AAKzC,UAAO;;;;;;EAOR,MAAM,kBACL,WACA,aACA,WACY;AACZ,OAAI;IACH,MAAM,uBAAuB,oBAAoB,UAAU;IAC3D,MAAM,yBAAyB,oBAAoB,YAAY;IAC/D,MAAM,MAAM,aAAa,YAAY,CAAC,aAAa;IAGnD,IAAI,cAAc,OAAO,QACxB,OAAO,yBAAyB,UAAU,EAAE,CAC5C,CAAC,QAC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