@zenstackhq/better-auth 3.6.1 → 3.6.3-beta.1

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.
@@ -0,0 +1,398 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let _zenstackhq_common_helpers = require("@zenstackhq/common-helpers");
25
+ let _zenstackhq_language = require("@zenstackhq/language");
26
+ let _zenstackhq_language_ast = require("@zenstackhq/language/ast");
27
+ let _zenstackhq_language_utils = require("@zenstackhq/language/utils");
28
+ require("better-auth");
29
+ let node_fs = require("node:fs");
30
+ node_fs = __toESM(node_fs, 1);
31
+ let ts_pattern = require("ts-pattern");
32
+ //#region src/schema-generator.ts
33
+ async function generateSchema(file, tables, config, options) {
34
+ let filePath = file;
35
+ if (!filePath) if (node_fs.default.existsSync("./schema.zmodel")) filePath = "./schema.zmodel";
36
+ else filePath = "./zenstack/schema.zmodel";
37
+ const schemaExists = node_fs.default.existsSync(filePath);
38
+ const schema = await updateSchema(filePath, tables, config, options);
39
+ return {
40
+ code: schema ?? "",
41
+ path: filePath,
42
+ overwrite: schemaExists && !!schema
43
+ };
44
+ }
45
+ async function updateSchema(schemaPath, tables, config, options) {
46
+ let zmodel;
47
+ if (node_fs.default.existsSync(schemaPath)) {
48
+ const loadResult = await (0, _zenstackhq_language.loadDocument)(schemaPath);
49
+ if (!loadResult.success) throw new Error(`Failed to load existing schema at ${schemaPath}: ${loadResult.errors.join(", ")}`);
50
+ zmodel = loadResult.model;
51
+ } else zmodel = initializeZmodel(config);
52
+ const toManyRelations = /* @__PURE__ */ new Map();
53
+ for (const [tableName, table] of Object.entries(tables)) {
54
+ const fields = tables[tableName]?.fields;
55
+ for (const field in fields) {
56
+ const attr = fields[field];
57
+ if (attr.references) {
58
+ const referencedOriginalModel = attr.references.model;
59
+ const referencedModelNameCap = (0, _zenstackhq_common_helpers.upperCaseFirst)(tables[referencedOriginalModel]?.modelName || referencedOriginalModel);
60
+ if (!toManyRelations.has(referencedModelNameCap)) toManyRelations.set(referencedModelNameCap, /* @__PURE__ */ new Set());
61
+ const currentModelNameCap = (0, _zenstackhq_common_helpers.upperCaseFirst)(table.modelName ?? tableName);
62
+ toManyRelations.get(referencedModelNameCap).add(currentModelNameCap);
63
+ }
64
+ }
65
+ }
66
+ let changed = false;
67
+ for (const [name, table] of Object.entries(tables)) {
68
+ const c = addOrUpdateModel(name, table, zmodel, tables, toManyRelations, !!options.advanced?.database?.useNumberId);
69
+ changed = changed || c;
70
+ }
71
+ if (!changed) return;
72
+ let content = new _zenstackhq_language.ZModelCodeGenerator().generate(zmodel);
73
+ try {
74
+ content = await (0, _zenstackhq_language.formatDocument)(content);
75
+ } catch {}
76
+ return content;
77
+ }
78
+ function addDefaultNow(df) {
79
+ const nowArg = { $type: "AttributeArg" };
80
+ nowArg.value = {
81
+ $type: "InvocationExpr",
82
+ function: { $refText: "now" },
83
+ args: [],
84
+ $container: nowArg
85
+ };
86
+ addFieldAttribute(df, "@default", [nowArg]);
87
+ }
88
+ function createDataModel(modelName, zmodel, numericId) {
89
+ const dataModel = {
90
+ $type: "DataModel",
91
+ name: modelName,
92
+ fields: [],
93
+ attributes: [],
94
+ mixins: [],
95
+ comments: [],
96
+ isView: false,
97
+ $container: zmodel
98
+ };
99
+ let idField;
100
+ if (numericId) idField = addModelField(dataModel, "id", "Int", false, false);
101
+ else idField = addModelField(dataModel, "id", "String", false, false);
102
+ addFieldAttribute(idField, "@id");
103
+ return dataModel;
104
+ }
105
+ function addModelField(dataModel, fieldName, fieldType, array, optional) {
106
+ const field = {
107
+ $type: "DataField",
108
+ name: fieldName,
109
+ attributes: [],
110
+ comments: [],
111
+ $container: dataModel
112
+ };
113
+ field.type = {
114
+ $type: "DataFieldType",
115
+ type: fieldType,
116
+ array,
117
+ optional,
118
+ $container: field
119
+ };
120
+ dataModel.fields.push(field);
121
+ return field;
122
+ }
123
+ function initializeZmodel(config) {
124
+ const zmodel = {
125
+ $type: "Model",
126
+ declarations: [],
127
+ imports: []
128
+ };
129
+ const ds = {
130
+ $type: "DataSource",
131
+ name: "db",
132
+ fields: [],
133
+ $container: zmodel
134
+ };
135
+ zmodel.declarations.push(ds);
136
+ const providerField = {
137
+ $type: "ConfigField",
138
+ name: "provider",
139
+ $container: ds
140
+ };
141
+ providerField.value = {
142
+ $type: "StringLiteral",
143
+ value: config.provider,
144
+ $container: providerField
145
+ };
146
+ const urlField = {
147
+ $type: "ConfigField",
148
+ name: "url",
149
+ $container: ds
150
+ };
151
+ const envCall = {
152
+ $type: "InvocationExpr",
153
+ function: { $refText: "env" },
154
+ args: [],
155
+ $container: urlField
156
+ };
157
+ const dbUrlArg = { $type: "Argument" };
158
+ dbUrlArg.value = {
159
+ $type: "StringLiteral",
160
+ value: "DATABASE_URL",
161
+ $container: dbUrlArg
162
+ };
163
+ envCall.args = [dbUrlArg];
164
+ urlField.value = config.provider === "sqlite" ? {
165
+ $type: "StringLiteral",
166
+ value: "file:./dev.db",
167
+ $container: urlField
168
+ } : envCall;
169
+ ds.fields.push(providerField);
170
+ ds.fields.push(urlField);
171
+ return zmodel;
172
+ }
173
+ function getMappedFieldType({ bigint, type }) {
174
+ return (0, ts_pattern.match)(type).with("string", () => ({ type: "String" })).with("number", () => bigint ? { type: "BigInt" } : { type: "Int" }).with("boolean", () => ({ type: "Boolean" })).with("date", () => ({ type: "DateTime" })).with("json", () => ({ type: "Json" })).with("string[]", () => ({
175
+ type: "String",
176
+ array: true
177
+ })).with("number[]", () => ({
178
+ type: "Int",
179
+ array: true
180
+ })).when((v) => Array.isArray(v) && v.every((e) => typeof e === "string"), () => {
181
+ return { type: "String" };
182
+ }).otherwise(() => {
183
+ throw new Error(`Unsupported field type: ${type}`);
184
+ });
185
+ }
186
+ function addOrUpdateModel(tableName, table, zmodel, tables, toManyRelations, numericId) {
187
+ let changed = false;
188
+ const modelName = (0, _zenstackhq_common_helpers.upperCaseFirst)(tables[tableName]?.modelName ?? tableName);
189
+ let dataModel = zmodel.declarations.find((d) => (0, _zenstackhq_language_ast.isDataModel)(d) && d.name === modelName);
190
+ if (!dataModel) {
191
+ changed = true;
192
+ dataModel = createDataModel(modelName, zmodel, numericId);
193
+ zmodel.declarations.push(dataModel);
194
+ }
195
+ if (modelName !== tableName && !(0, _zenstackhq_language_utils.hasAttribute)(dataModel, "@@map")) addModelAttribute(dataModel, "@@map", [createStringAttributeArg(tableName)]);
196
+ for (const [fName, field] of Object.entries(table.fields)) {
197
+ const fieldName = field.fieldName ?? fName;
198
+ if (dataModel.fields.some((f) => f.name === fieldName)) continue;
199
+ changed = true;
200
+ if (!field.references) {
201
+ const { array, type } = getMappedFieldType(field);
202
+ const df = {
203
+ $type: "DataField",
204
+ name: fieldName,
205
+ attributes: [],
206
+ comments: [],
207
+ $container: dataModel
208
+ };
209
+ df.type = {
210
+ $type: "DataFieldType",
211
+ type,
212
+ array: !!array,
213
+ optional: !field.required,
214
+ $container: df
215
+ };
216
+ dataModel.fields.push(df);
217
+ if (fieldName === "id") addFieldAttribute(df, "@id");
218
+ if (field.unique) addFieldAttribute(df, "@unique");
219
+ if (field.defaultValue !== void 0) {
220
+ if (fieldName === "createdAt") addDefaultNow(df);
221
+ else if (typeof field.defaultValue === "boolean") addFieldAttribute(df, "@default", [createBooleanAttributeArg(field.defaultValue)]);
222
+ else if (typeof field.defaultValue === "string") addFieldAttribute(df, "@default", [createStringAttributeArg(field.defaultValue)]);
223
+ else if (typeof field.defaultValue === "number") addFieldAttribute(df, "@default", [createNumberAttributeArg(field.defaultValue)]);
224
+ else if (typeof field.defaultValue === "function") if (field.defaultValue() instanceof Date) addDefaultNow(df);
225
+ else console.warn(`Warning: Unsupported default function for field ${fieldName} in model ${table.modelName}. Please adjust manually.`);
226
+ }
227
+ if (fieldName === "updatedAt" && field.onUpdate) addFieldAttribute(df, "@updatedAt");
228
+ else if (field.onUpdate) console.warn(`Warning: 'onUpdate' is only supported on 'updatedAt' fields. Please adjust manually for field ${fieldName} in model ${table.modelName}.`);
229
+ } else {
230
+ addModelField(dataModel, fieldName, numericId ? "Int" : "String", false, !field.required);
231
+ const referencedOriginalModelName = field.references.model;
232
+ const referencedCustomModelName = tables[referencedOriginalModelName]?.modelName || referencedOriginalModelName;
233
+ const relationField = {
234
+ $type: "DataField",
235
+ name: (0, _zenstackhq_common_helpers.lowerCaseFirst)(referencedCustomModelName),
236
+ attributes: [],
237
+ comments: [],
238
+ $container: dataModel
239
+ };
240
+ relationField.type = {
241
+ $type: "DataFieldType",
242
+ reference: { $refText: (0, _zenstackhq_common_helpers.upperCaseFirst)(referencedCustomModelName) },
243
+ array: field.type.endsWith("[]"),
244
+ optional: !field.required,
245
+ $container: relationField
246
+ };
247
+ let action = "Cascade";
248
+ if (field.references.onDelete === "no action") action = "NoAction";
249
+ else if (field.references.onDelete === "set null") action = "SetNull";
250
+ else if (field.references.onDelete === "set default") action = "SetDefault";
251
+ else if (field.references.onDelete === "restrict") action = "Restrict";
252
+ const relationAttr = {
253
+ $type: "DataFieldAttribute",
254
+ decl: { $refText: "@relation" },
255
+ args: [],
256
+ $container: relationField
257
+ };
258
+ const fieldsArg = {
259
+ $type: "AttributeArg",
260
+ name: "fields",
261
+ $container: relationAttr
262
+ };
263
+ const fieldsExpr = {
264
+ $type: "ArrayExpr",
265
+ items: [],
266
+ $container: fieldsArg
267
+ };
268
+ const fkRefExpr = {
269
+ $type: "ReferenceExpr",
270
+ args: [],
271
+ $container: fieldsExpr,
272
+ target: { $refText: fieldName }
273
+ };
274
+ fieldsExpr.items.push(fkRefExpr);
275
+ fieldsArg.value = fieldsExpr;
276
+ const referencesArg = {
277
+ $type: "AttributeArg",
278
+ name: "references",
279
+ $container: relationAttr
280
+ };
281
+ const referencesExpr = {
282
+ $type: "ArrayExpr",
283
+ items: [],
284
+ $container: referencesArg
285
+ };
286
+ const pkRefExpr = {
287
+ $type: "ReferenceExpr",
288
+ args: [],
289
+ $container: referencesExpr,
290
+ target: { $refText: field.references.field }
291
+ };
292
+ referencesExpr.items.push(pkRefExpr);
293
+ referencesArg.value = referencesExpr;
294
+ const onDeleteArg = {
295
+ $type: "AttributeArg",
296
+ name: "onDelete",
297
+ $container: relationAttr
298
+ };
299
+ onDeleteArg.value = {
300
+ $type: "ReferenceExpr",
301
+ target: { $refText: action },
302
+ args: [],
303
+ $container: onDeleteArg
304
+ };
305
+ relationAttr.args.push(...[
306
+ fieldsArg,
307
+ referencesArg,
308
+ onDeleteArg
309
+ ]);
310
+ relationField.attributes.push(relationAttr);
311
+ dataModel.fields.push(relationField);
312
+ }
313
+ }
314
+ if (toManyRelations.has(modelName)) {
315
+ const relations = toManyRelations.get(modelName);
316
+ for (const relatedModel of relations) {
317
+ const relationName = `${(0, _zenstackhq_common_helpers.lowerCaseFirst)(relatedModel)}s`;
318
+ if (!dataModel.fields.some((f) => f.name === relationName)) {
319
+ const relationField = {
320
+ $type: "DataField",
321
+ name: relationName,
322
+ attributes: [],
323
+ comments: [],
324
+ $container: dataModel
325
+ };
326
+ relationField.type = {
327
+ $type: "DataFieldType",
328
+ reference: { $refText: relatedModel },
329
+ array: true,
330
+ optional: false,
331
+ $container: relationField
332
+ };
333
+ dataModel.fields.push(relationField);
334
+ }
335
+ }
336
+ }
337
+ return changed;
338
+ }
339
+ function addModelAttribute(dataModel, name, args = []) {
340
+ const attr = {
341
+ $type: "DataModelAttribute",
342
+ decl: { $refText: name },
343
+ $container: dataModel,
344
+ args: []
345
+ };
346
+ const finalArgs = args.map((arg) => ({
347
+ ...arg,
348
+ $container: attr
349
+ }));
350
+ attr.args.push(...finalArgs);
351
+ dataModel.attributes.push(attr);
352
+ }
353
+ function addFieldAttribute(dataField, name, args = []) {
354
+ const attr = {
355
+ $type: "DataFieldAttribute",
356
+ decl: { $refText: name },
357
+ $container: dataField,
358
+ args: []
359
+ };
360
+ const finalArgs = args.map((arg) => ({
361
+ ...arg,
362
+ $container: attr
363
+ }));
364
+ attr.args.push(...finalArgs);
365
+ dataField.attributes.push(attr);
366
+ }
367
+ function createBooleanAttributeArg(value) {
368
+ const arg = { $type: "AttributeArg" };
369
+ arg.value = {
370
+ $type: "BooleanLiteral",
371
+ value,
372
+ $container: arg
373
+ };
374
+ return arg;
375
+ }
376
+ function createNumberAttributeArg(value) {
377
+ const arg = { $type: "AttributeArg" };
378
+ arg.value = {
379
+ $type: "NumberLiteral",
380
+ value: value.toString(),
381
+ $container: arg
382
+ };
383
+ return arg;
384
+ }
385
+ function createStringAttributeArg(value) {
386
+ const arg = { $type: "AttributeArg" };
387
+ arg.value = {
388
+ $type: "StringLiteral",
389
+ value,
390
+ $container: arg
391
+ };
392
+ return arg;
393
+ }
394
+ //#endregion
395
+ exports.__toESM = __toESM;
396
+ exports.generateSchema = generateSchema;
397
+
398
+ //# sourceMappingURL=schema-generator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-generator.cjs","names":["fs","ZModelCodeGenerator"],"sources":["../src/schema-generator.ts"],"sourcesContent":["import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/common-helpers';\nimport { formatDocument, loadDocument, ZModelCodeGenerator } from '@zenstackhq/language';\nimport {\n Argument,\n ArrayExpr,\n AttributeArg,\n BooleanLiteral,\n ConfigExpr,\n ConfigField,\n DataField,\n DataFieldAttribute,\n DataFieldType,\n DataModel,\n DataModelAttribute,\n DataSource,\n InvocationExpr,\n isDataModel,\n Model,\n NumberLiteral,\n ReferenceExpr,\n StringLiteral,\n} from '@zenstackhq/language/ast';\nimport { hasAttribute } from '@zenstackhq/language/utils';\nimport { type BetterAuthOptions } from 'better-auth';\nimport type { DBAdapterSchemaCreation } from 'better-auth/adapters';\nimport type { BetterAuthDBSchema, DBFieldAttribute, DBFieldType } from 'better-auth/db';\nimport fs from 'node:fs';\nimport { match } from 'ts-pattern';\nimport type { AdapterConfig } from './adapter';\n\nexport async function generateSchema(\n file: string | undefined,\n tables: BetterAuthDBSchema,\n config: AdapterConfig,\n options: BetterAuthOptions,\n): Promise<DBAdapterSchemaCreation> {\n let filePath = file;\n\n if (!filePath) {\n // TODO: respect \"zenstack\" entry in package.json for default schema file path\n if (fs.existsSync('./schema.zmodel')) {\n filePath = './schema.zmodel';\n } else {\n filePath = './zenstack/schema.zmodel';\n }\n }\n\n const schemaExists = fs.existsSync(filePath);\n\n const schema = await updateSchema(filePath, tables, config, options);\n\n return {\n code: schema ?? '',\n path: filePath,\n overwrite: schemaExists && !!schema,\n };\n}\n\nasync function updateSchema(\n schemaPath: string,\n tables: BetterAuthDBSchema,\n config: AdapterConfig,\n options: BetterAuthOptions,\n) {\n let zmodel: Model | undefined;\n if (fs.existsSync(schemaPath)) {\n const loadResult = await loadDocument(schemaPath);\n if (!loadResult.success) {\n throw new Error(`Failed to load existing schema at ${schemaPath}: ${loadResult.errors.join(', ')}`);\n }\n zmodel = loadResult.model;\n } else {\n zmodel = initializeZmodel(config);\n }\n\n // collect to-many relations\n const toManyRelations = new Map();\n for (const [tableName, table] of Object.entries(tables)) {\n const fields = tables[tableName]?.fields;\n for (const field in fields) {\n const attr = fields[field]!;\n if (attr.references) {\n const referencedOriginalModel = attr.references.model;\n const referencedCustomModel = tables[referencedOriginalModel]?.modelName || referencedOriginalModel;\n const referencedModelNameCap = upperCaseFirst(referencedCustomModel);\n if (!toManyRelations.has(referencedModelNameCap)) {\n toManyRelations.set(referencedModelNameCap, new Set());\n }\n const currentCustomModel = table.modelName ?? tableName;\n const currentModelNameCap = upperCaseFirst(currentCustomModel);\n toManyRelations.get(referencedModelNameCap).add(currentModelNameCap);\n }\n }\n }\n\n let changed = false;\n\n for (const [name, table] of Object.entries(tables)) {\n const c = addOrUpdateModel(\n name,\n table,\n zmodel,\n tables,\n toManyRelations,\n !!options.advanced?.database?.useNumberId,\n );\n changed = changed || c;\n }\n\n if (!changed) {\n return undefined;\n }\n\n const generator = new ZModelCodeGenerator();\n let content = generator.generate(zmodel);\n\n try {\n content = await formatDocument(content);\n } catch {\n // ignore formatting errors\n }\n\n return content;\n}\n\n// @default(now())\nfunction addDefaultNow(df: DataField) {\n const nowArg: AttributeArg = {\n $type: 'AttributeArg',\n } as any;\n const nowExpr: InvocationExpr = {\n $type: 'InvocationExpr',\n function: { $refText: 'now' },\n args: [],\n $container: nowArg,\n };\n nowArg.value = nowExpr;\n addFieldAttribute(df, '@default', [nowArg]);\n}\n\nfunction createDataModel(modelName: string, zmodel: Model, numericId: boolean) {\n const dataModel: DataModel = {\n $type: 'DataModel',\n name: modelName,\n fields: [],\n attributes: [],\n mixins: [],\n comments: [],\n isView: false,\n $container: zmodel,\n };\n\n let idField: DataField;\n if (numericId) {\n idField = addModelField(dataModel, 'id', 'Int', false, false);\n } else {\n idField = addModelField(dataModel, 'id', 'String', false, false);\n }\n addFieldAttribute(idField, '@id');\n\n return dataModel;\n}\n\nfunction addModelField(dataModel: DataModel, fieldName: string, fieldType: string, array: boolean, optional: boolean) {\n const field: DataField = {\n $type: 'DataField',\n name: fieldName,\n attributes: [],\n comments: [],\n $container: dataModel,\n } as any;\n field.type = {\n $type: 'DataFieldType',\n type: fieldType as any,\n array,\n optional,\n $container: field,\n };\n dataModel.fields.push(field);\n return field;\n}\n\nfunction initializeZmodel(config: AdapterConfig) {\n const zmodel: Model = {\n $type: 'Model',\n declarations: [],\n imports: [],\n };\n\n // datasource db { ... }\n const ds: DataSource = {\n $type: 'DataSource',\n name: 'db',\n fields: [],\n $container: zmodel,\n };\n zmodel.declarations.push(ds);\n\n // provider = 'sqlite' | 'postgresql'\n const providerField: ConfigField = {\n $type: 'ConfigField',\n name: 'provider',\n $container: ds,\n } as any;\n providerField.value = {\n $type: 'StringLiteral',\n value: config.provider,\n $container: providerField,\n } satisfies ConfigExpr;\n\n const urlField: ConfigField = {\n $type: 'ConfigField',\n name: 'url',\n $container: ds,\n } as any;\n\n // env('DATABASE_URL')\n const envCall: InvocationExpr = {\n $type: 'InvocationExpr',\n function: {\n $refText: 'env',\n },\n args: [],\n $container: urlField,\n };\n\n // 'DATABASE_URL' arg\n const dbUrlArg: Argument = {\n $type: 'Argument',\n } as any;\n dbUrlArg.value = {\n $type: 'StringLiteral',\n value: 'DATABASE_URL',\n $container: dbUrlArg,\n } satisfies ConfigExpr;\n\n envCall.args = [dbUrlArg];\n\n urlField.value =\n config.provider === 'sqlite'\n ? {\n $type: 'StringLiteral',\n value: 'file:./dev.db',\n $container: urlField,\n }\n : envCall;\n\n ds.fields.push(providerField);\n ds.fields.push(urlField);\n\n return zmodel;\n}\n\nfunction getMappedFieldType({ bigint, type }: DBFieldAttribute) {\n return match<DBFieldType, { type: string; array?: boolean }>(type)\n .with('string', () => ({ type: 'String' }))\n .with('number', () => (bigint ? { type: 'BigInt' } : { type: 'Int' }))\n .with('boolean', () => ({ type: 'Boolean' }))\n .with('date', () => ({ type: 'DateTime' }))\n .with('json', () => ({ type: 'Json' }))\n .with('string[]', () => ({ type: 'String', array: true }))\n .with('number[]', () => ({ type: 'Int', array: true }))\n .when(\n (v) => Array.isArray(v) && v.every((e) => typeof e === 'string'),\n () => {\n // Handle enum types (e.g., ['user', 'admin']), map them to String type for now\n return { type: 'String' };\n },\n )\n .otherwise(() => {\n throw new Error(`Unsupported field type: ${type}`);\n });\n}\n\nfunction addOrUpdateModel(\n tableName: string,\n table: BetterAuthDBSchema[string],\n zmodel: Model,\n tables: BetterAuthDBSchema,\n toManyRelations: Map<string, Set<string>>,\n numericId: boolean,\n): boolean {\n let changed = false;\n const customModelName = tables[tableName]?.modelName ?? tableName;\n const modelName = upperCaseFirst(customModelName);\n\n let dataModel = zmodel.declarations.find((d): d is DataModel => isDataModel(d) && d.name === modelName);\n if (!dataModel) {\n changed = true;\n dataModel = createDataModel(modelName, zmodel, numericId);\n zmodel.declarations.push(dataModel);\n }\n\n if (modelName !== tableName && !hasAttribute(dataModel, '@@map')) {\n addModelAttribute(dataModel, '@@map', [createStringAttributeArg(tableName)]);\n }\n\n for (const [fName, field] of Object.entries(table.fields)) {\n const fieldName = field.fieldName ?? fName;\n if (dataModel.fields.some((f) => f.name === fieldName)) {\n continue;\n }\n\n changed = true;\n\n if (!field.references) {\n // scalar field\n const { array, type } = getMappedFieldType(field);\n\n const df: DataField = {\n $type: 'DataField',\n name: fieldName,\n attributes: [],\n comments: [],\n $container: dataModel,\n } as any;\n df.type = {\n $type: 'DataFieldType',\n type: type as any,\n array: !!array,\n optional: !field.required,\n $container: df,\n };\n dataModel.fields.push(df);\n\n // @id\n if (fieldName === 'id') {\n addFieldAttribute(df, '@id');\n }\n\n // @unique\n if (field.unique) {\n addFieldAttribute(df, '@unique');\n }\n\n // @default\n if (field.defaultValue !== undefined) {\n if (fieldName === 'createdAt') {\n // @default(now())\n addDefaultNow(df);\n } else if (typeof field.defaultValue === 'boolean') {\n addFieldAttribute(df, '@default', [createBooleanAttributeArg(field.defaultValue)]);\n } else if (typeof field.defaultValue === 'string') {\n addFieldAttribute(df, '@default', [createStringAttributeArg(field.defaultValue)]);\n } else if (typeof field.defaultValue === 'number') {\n addFieldAttribute(df, '@default', [createNumberAttributeArg(field.defaultValue)]);\n } else if (typeof field.defaultValue === 'function') {\n // For other function-based defaults, we'll need to check what they return\n const defaultVal = field.defaultValue();\n if (defaultVal instanceof Date) {\n // @default(now())\n addDefaultNow(df);\n } else {\n console.warn(\n `Warning: Unsupported default function for field ${fieldName} in model ${table.modelName}. Please adjust manually.`,\n );\n }\n }\n }\n\n // This is a special handling for updatedAt fields\n if (fieldName === 'updatedAt' && field.onUpdate) {\n addFieldAttribute(df, '@updatedAt');\n } else if (field.onUpdate) {\n console.warn(\n `Warning: 'onUpdate' is only supported on 'updatedAt' fields. Please adjust manually for field ${fieldName} in model ${table.modelName}.`,\n );\n }\n } else {\n // relation\n\n // fk field\n addModelField(dataModel, fieldName, numericId ? 'Int' : 'String', false, !field.required);\n\n // relation field\n const referencedOriginalModelName = field.references.model;\n const referencedCustomModelName =\n tables[referencedOriginalModelName]?.modelName || referencedOriginalModelName;\n\n const relationField: DataField = {\n $type: 'DataField',\n name: lowerCaseFirst(referencedCustomModelName),\n attributes: [],\n comments: [],\n $container: dataModel,\n } as any;\n relationField.type = {\n $type: 'DataFieldType',\n reference: {\n $refText: upperCaseFirst(referencedCustomModelName),\n },\n array: (field.type as string).endsWith('[]'),\n optional: !field.required,\n $container: relationField,\n } satisfies DataFieldType;\n\n let action = 'Cascade';\n if (field.references.onDelete === 'no action') action = 'NoAction';\n else if (field.references.onDelete === 'set null') action = 'SetNull';\n else if (field.references.onDelete === 'set default') action = 'SetDefault';\n else if (field.references.onDelete === 'restrict') action = 'Restrict';\n\n // @relation(fields: [field], references: [referencedField], onDelete: action)\n const relationAttr: DataFieldAttribute = {\n $type: 'DataFieldAttribute',\n decl: {\n $refText: '@relation',\n },\n args: [],\n $container: relationField,\n };\n\n // fields: [field]\n const fieldsArg: AttributeArg = {\n $type: 'AttributeArg',\n name: 'fields',\n $container: relationAttr,\n } as any;\n const fieldsExpr: ArrayExpr = {\n $type: 'ArrayExpr',\n items: [],\n $container: fieldsArg,\n };\n const fkRefExpr: ReferenceExpr = {\n $type: 'ReferenceExpr',\n args: [],\n $container: fieldsExpr,\n target: {\n $refText: fieldName,\n },\n };\n fieldsExpr.items.push(fkRefExpr);\n fieldsArg.value = fieldsExpr;\n\n // references: [referencedField]\n const referencesArg: AttributeArg = {\n $type: 'AttributeArg',\n name: 'references',\n $container: relationAttr,\n } as any;\n const referencesExpr: ArrayExpr = {\n $type: 'ArrayExpr',\n items: [],\n $container: referencesArg,\n };\n const pkRefExpr: ReferenceExpr = {\n $type: 'ReferenceExpr',\n args: [],\n $container: referencesExpr,\n target: {\n $refText: field.references.field,\n },\n };\n referencesExpr.items.push(pkRefExpr);\n referencesArg.value = referencesExpr;\n\n // onDelete: action\n const onDeleteArg: AttributeArg = {\n $type: 'AttributeArg',\n name: 'onDelete',\n $container: relationAttr,\n } as any;\n const onDeleteValueExpr: ReferenceExpr = {\n $type: 'ReferenceExpr',\n target: { $refText: action },\n args: [],\n $container: onDeleteArg,\n };\n onDeleteArg.value = onDeleteValueExpr;\n\n relationAttr.args.push(...[fieldsArg, referencesArg, onDeleteArg]);\n relationField.attributes.push(relationAttr);\n\n dataModel.fields.push(relationField);\n }\n }\n\n // add to-many relations\n if (toManyRelations.has(modelName)) {\n const relations = toManyRelations.get(modelName)!;\n for (const relatedModel of relations) {\n const relationName = `${lowerCaseFirst(relatedModel)}s`;\n if (!dataModel.fields.some((f) => f.name === relationName)) {\n const relationField: DataField = {\n $type: 'DataField',\n name: relationName,\n attributes: [],\n comments: [],\n $container: dataModel,\n } as any;\n const relationType: DataFieldType = {\n $type: 'DataFieldType',\n reference: {\n $refText: relatedModel,\n },\n array: true,\n optional: false,\n $container: relationField,\n };\n relationField.type = relationType;\n dataModel.fields.push(relationField);\n }\n }\n }\n\n return changed;\n}\n\nfunction addModelAttribute(dataModel: DataModel, name: string, args: Omit<AttributeArg, '$container'>[] = []) {\n const attr: DataModelAttribute = {\n $type: 'DataModelAttribute',\n decl: { $refText: name },\n $container: dataModel,\n args: [],\n };\n const finalArgs = args.map((arg) => ({\n ...arg,\n $container: attr,\n }));\n attr.args.push(...finalArgs);\n dataModel.attributes.push(attr);\n}\n\nfunction addFieldAttribute(dataField: DataField, name: string, args: Omit<AttributeArg, '$container'>[] = []) {\n const attr: DataFieldAttribute = {\n $type: 'DataFieldAttribute',\n decl: { $refText: name },\n $container: dataField,\n args: [],\n };\n const finalArgs = args.map((arg) => ({\n ...arg,\n $container: attr,\n }));\n attr.args.push(...finalArgs);\n dataField.attributes.push(attr);\n}\n\nfunction createBooleanAttributeArg(value: boolean) {\n const arg: AttributeArg = {\n $type: 'AttributeArg',\n } as any;\n const expr: BooleanLiteral = {\n $type: 'BooleanLiteral',\n value,\n $container: arg,\n };\n arg.value = expr;\n return arg;\n}\n\nfunction createNumberAttributeArg(value: number) {\n const arg: AttributeArg = {\n $type: 'AttributeArg',\n } as any;\n const expr: NumberLiteral = {\n $type: 'NumberLiteral',\n value: value.toString(),\n $container: arg,\n };\n arg.value = expr;\n return arg;\n}\n\nfunction createStringAttributeArg(value: string) {\n const arg: AttributeArg = {\n $type: 'AttributeArg',\n } as any;\n const expr: StringLiteral = {\n $type: 'StringLiteral',\n value,\n $container: arg,\n };\n arg.value = expr;\n return arg;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,eAAsB,eAClB,MACA,QACA,QACA,SACgC;CAChC,IAAI,WAAW;AAEf,KAAI,CAAC,SAED,KAAIA,QAAAA,QAAG,WAAW,kBAAkB,CAChC,YAAW;KAEX,YAAW;CAInB,MAAM,eAAeA,QAAAA,QAAG,WAAW,SAAS;CAE5C,MAAM,SAAS,MAAM,aAAa,UAAU,QAAQ,QAAQ,QAAQ;AAEpE,QAAO;EACH,MAAM,UAAU;EAChB,MAAM;EACN,WAAW,gBAAgB,CAAC,CAAC;EAChC;;AAGL,eAAe,aACX,YACA,QACA,QACA,SACF;CACE,IAAI;AACJ,KAAIA,QAAAA,QAAG,WAAW,WAAW,EAAE;EAC3B,MAAM,a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,KAAK,KAAK;;AAGnC,SAAS,0BAA0B,OAAgB;CAC/C,MAAM,MAAoB,EACtB,OAAO,gBACV;AAMD,KAAI,QALyB;EACzB,OAAO;EACP;EACA,YAAY;EACf;AAED,QAAO;;AAGX,SAAS,yBAAyB,OAAe;CAC7C,MAAM,MAAoB,EACtB,OAAO,gBACV;AAMD,KAAI,QALwB;EACxB,OAAO;EACP,OAAO,MAAM,UAAU;EACvB,YAAY;EACf;AAED,QAAO;;AAGX,SAAS,yBAAyB,OAAe;CAC7C,MAAM,MAAoB,EACtB,OAAO,gBACV;AAMD,KAAI,QALwB;EACxB,OAAO;EACP;EACA,YAAY;EACf;AAED,QAAO"}
@@ -0,0 +1,10 @@
1
+ import { t as AdapterConfig } from "./adapter-Hkvk-P1x.cjs";
2
+ import { BetterAuthOptions } from "better-auth";
3
+ import { DBAdapterSchemaCreation } from "better-auth/adapters";
4
+ import { BetterAuthDBSchema } from "better-auth/db";
5
+
6
+ //#region src/schema-generator.d.ts
7
+ declare function generateSchema(file: string | undefined, tables: BetterAuthDBSchema, config: AdapterConfig, options: BetterAuthOptions): Promise<DBAdapterSchemaCreation>;
8
+ //#endregion
9
+ export { generateSchema };
10
+ //# sourceMappingURL=schema-generator.d.cts.map
@@ -0,0 +1,10 @@
1
+ import { t as AdapterConfig } from "./adapter-4J4FE5_e.mjs";
2
+ import { DBAdapterSchemaCreation } from "better-auth/adapters";
3
+ import { BetterAuthOptions } from "better-auth";
4
+ import { BetterAuthDBSchema } from "better-auth/db";
5
+
6
+ //#region src/schema-generator.d.ts
7
+ declare function generateSchema(file: string | undefined, tables: BetterAuthDBSchema, config: AdapterConfig, options: BetterAuthOptions): Promise<DBAdapterSchemaCreation>;
8
+ //#endregion
9
+ export { generateSchema };
10
+ //# sourceMappingURL=schema-generator.d.mts.map