prisma-flare 1.2.9 → 1.3.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.
package/README.md CHANGED
@@ -23,6 +23,7 @@ npm install prisma-flare
23
23
  |----------------|-------------------|---------|
24
24
  | 5.x - 7.x | `prisma-client-js` | ✅ |
25
25
  | 7.x+ | `prisma-client` | ✅ |
26
+ | 7.x+ | Multi-file schema | ✅ |
26
27
 
27
28
  ## Quick Start
28
29
 
@@ -130,7 +131,19 @@ const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
130
131
  export const db = new FlareClient({ adapter });
131
132
  ```
132
133
 
133
- See [Configuration](docs/configuration.md#new-provider-prisma-client---prisma-7) for full setup.
134
+ ### Multi-File Schema (Prisma 7+)
135
+
136
+ prisma-flare automatically supports multi-file schemas. Just run `npx prisma-flare generate`:
137
+
138
+ ```
139
+ prisma/schema/
140
+ ├── _base.prisma # generator & datasource (can be in any file)
141
+ ├── user.prisma
142
+ ├── post.prisma
143
+ └── ...
144
+ ```
145
+
146
+ See [Configuration](docs/configuration.md#schema-auto-detection) for details.
134
147
 
135
148
  ## Transactions
136
149
 
@@ -28,7 +28,7 @@ var import_child_process = require("child_process");
28
28
 
29
29
  // src/cli/generate-client.ts
30
30
  var fs3 = __toESM(require("fs"), 1);
31
- var path3 = __toESM(require("path"), 1);
31
+ var path4 = __toESM(require("path"), 1);
32
32
 
33
33
  // src/cli/config.ts
34
34
  var fs = __toESM(require("fs"), 1);
@@ -66,8 +66,122 @@ function loadConfig(rootDir) {
66
66
  }
67
67
 
68
68
  // src/cli/schema-parser.ts
69
+ var path3 = __toESM(require("path"), 1);
70
+
71
+ // src/cli/schema-resolver.ts
69
72
  var fs2 = __toESM(require("fs"), 1);
70
73
  var path2 = __toESM(require("path"), 1);
74
+ function readPrismaConfigSchema(rootDir) {
75
+ const configPaths = [
76
+ path2.join(rootDir, "prisma.config.ts"),
77
+ path2.join(rootDir, "prisma.config.js"),
78
+ path2.join(rootDir, "prisma.config.mjs"),
79
+ path2.join(rootDir, "prisma.config.cjs")
80
+ ];
81
+ for (const configPath of configPaths) {
82
+ if (!fs2.existsSync(configPath)) {
83
+ continue;
84
+ }
85
+ try {
86
+ const content = fs2.readFileSync(configPath, "utf-8");
87
+ const schemaMatch = content.match(/schema\s*:\s*["']([^"']+)["']/);
88
+ if (schemaMatch) {
89
+ return schemaMatch[1];
90
+ }
91
+ const schemaMatchUnquoted = content.match(/schema\s*:\s*([^\s,}]+)/);
92
+ if (schemaMatchUnquoted && !schemaMatchUnquoted[1].startsWith("//")) {
93
+ const value = schemaMatchUnquoted[1].trim();
94
+ return value.replace(/^["']|["']$/g, "");
95
+ }
96
+ } catch {
97
+ }
98
+ }
99
+ return null;
100
+ }
101
+ function mergeSchemaDirectory(dirPath) {
102
+ const files = getPrismaFiles(dirPath);
103
+ const contents = [];
104
+ for (const file of files) {
105
+ const filePath = path2.join(dirPath, file);
106
+ const content = fs2.readFileSync(filePath, "utf-8");
107
+ contents.push(content);
108
+ }
109
+ return contents.join("\n\n");
110
+ }
111
+ function getPrismaFiles(dirPath) {
112
+ if (!fs2.existsSync(dirPath) || !fs2.statSync(dirPath).isDirectory()) {
113
+ throw new Error(`Schema directory not found: ${dirPath}`);
114
+ }
115
+ const files = fs2.readdirSync(dirPath).filter((file) => file.endsWith(".prisma"));
116
+ if (files.length === 0) {
117
+ throw new Error(`No .prisma files found in directory: ${dirPath}`);
118
+ }
119
+ return files;
120
+ }
121
+ function findGeneratorFile(dirPath) {
122
+ const files = getPrismaFiles(dirPath);
123
+ for (const file of files) {
124
+ const filePath = path2.join(dirPath, file);
125
+ const content = fs2.readFileSync(filePath, "utf-8");
126
+ if (/generator\s+\w+\s*\{/.test(content)) {
127
+ return content;
128
+ }
129
+ }
130
+ return null;
131
+ }
132
+ function resolveSchemaPath(rootDir) {
133
+ let schemaPath = null;
134
+ const prismaConfigSchema = readPrismaConfigSchema(rootDir);
135
+ if (prismaConfigSchema) {
136
+ schemaPath = path2.isAbsolute(prismaConfigSchema) ? prismaConfigSchema : path2.join(rootDir, prismaConfigSchema);
137
+ }
138
+ if (!schemaPath) {
139
+ const schemaDir = path2.join(rootDir, "prisma", "schema");
140
+ if (fs2.existsSync(schemaDir) && fs2.statSync(schemaDir).isDirectory()) {
141
+ schemaPath = schemaDir;
142
+ }
143
+ }
144
+ if (!schemaPath) {
145
+ const singleFile = path2.join(rootDir, "prisma", "schema.prisma");
146
+ if (fs2.existsSync(singleFile)) {
147
+ schemaPath = singleFile;
148
+ }
149
+ }
150
+ if (!schemaPath) {
151
+ return null;
152
+ }
153
+ if (!fs2.existsSync(schemaPath)) {
154
+ return null;
155
+ }
156
+ const stat = fs2.statSync(schemaPath);
157
+ if (stat.isDirectory()) {
158
+ try {
159
+ const content = mergeSchemaDirectory(schemaPath);
160
+ const generatorContent = findGeneratorFile(schemaPath) || content;
161
+ return {
162
+ schemaPath,
163
+ isDirectory: true,
164
+ content,
165
+ generatorContent,
166
+ schemaDir: schemaPath
167
+ };
168
+ } catch {
169
+ return null;
170
+ }
171
+ } else if (stat.isFile()) {
172
+ const content = fs2.readFileSync(schemaPath, "utf-8");
173
+ return {
174
+ schemaPath,
175
+ isDirectory: false,
176
+ content,
177
+ generatorContent: content,
178
+ schemaDir: path2.dirname(schemaPath)
179
+ };
180
+ }
181
+ return null;
182
+ }
183
+
184
+ // src/cli/schema-parser.ts
71
185
  function parseGeneratorClient(schemaContent) {
72
186
  const generatorRegex = /generator\s+client\s*\{([^}]+)\}/s;
73
187
  const match = schemaContent.match(generatorRegex);
@@ -84,39 +198,36 @@ function parseGeneratorClient(schemaContent) {
84
198
  }
85
199
  return config;
86
200
  }
87
- function resolvePrismaClientPath(rootDir, output) {
201
+ function resolvePrismaClientPath(rootDir, output, schemaDir) {
88
202
  if (!output) {
89
203
  return "@prisma/client";
90
204
  }
91
- const schemaDir = path2.join(rootDir, "prisma");
92
- const absolutePath = path2.resolve(schemaDir, output);
205
+ const resolvedSchemaDir = schemaDir || path3.join(rootDir, "prisma");
206
+ const absolutePath = path3.resolve(resolvedSchemaDir, output);
93
207
  return absolutePath;
94
208
  }
95
209
  function getPrismaClientPath(rootDir) {
96
- const schemaPath = path2.join(rootDir, "prisma", "schema.prisma");
97
- if (!fs2.existsSync(schemaPath)) {
210
+ const resolution = resolveSchemaPath(rootDir);
211
+ if (!resolution) {
98
212
  return "@prisma/client";
99
213
  }
100
- const schemaContent = fs2.readFileSync(schemaPath, "utf-8");
101
- const config = parseGeneratorClient(schemaContent);
102
- return resolvePrismaClientPath(rootDir, config?.output);
214
+ const config = parseGeneratorClient(resolution.generatorContent);
215
+ return resolvePrismaClientPath(rootDir, config?.output, resolution.schemaDir);
103
216
  }
104
217
  function hasCustomPrismaOutput(rootDir) {
105
- const schemaPath = path2.join(rootDir, "prisma", "schema.prisma");
106
- if (!fs2.existsSync(schemaPath)) {
218
+ const resolution = resolveSchemaPath(rootDir);
219
+ if (!resolution) {
107
220
  return false;
108
221
  }
109
- const schemaContent = fs2.readFileSync(schemaPath, "utf-8");
110
- const config = parseGeneratorClient(schemaContent);
222
+ const config = parseGeneratorClient(resolution.generatorContent);
111
223
  return config?.output != null;
112
224
  }
113
225
  function getPrismaProvider(rootDir) {
114
- const schemaPath = path2.join(rootDir, "prisma", "schema.prisma");
115
- if (!fs2.existsSync(schemaPath)) {
226
+ const resolution = resolveSchemaPath(rootDir);
227
+ if (!resolution) {
116
228
  return "prisma-client-js";
117
229
  }
118
- const schemaContent = fs2.readFileSync(schemaPath, "utf-8");
119
- const config = parseGeneratorClient(schemaContent);
230
+ const config = parseGeneratorClient(resolution.generatorContent);
120
231
  return config?.provider || "prisma-client-js";
121
232
  }
122
233
  function parseModelRelations(schemaContent) {
@@ -185,12 +296,11 @@ ${entries.join(",\n")}
185
296
  };`;
186
297
  }
187
298
  function getRelationModelMap(rootDir) {
188
- const schemaPath = path2.join(rootDir, "prisma", "schema.prisma");
189
- if (!fs2.existsSync(schemaPath)) {
299
+ const resolution = resolveSchemaPath(rootDir);
300
+ if (!resolution) {
190
301
  return null;
191
302
  }
192
- const schemaContent = fs2.readFileSync(schemaPath, "utf-8");
193
- const models = parseModelRelations(schemaContent);
303
+ const models = parseModelRelations(resolution.content);
194
304
  return generateRelationModelMap(models);
195
305
  }
196
306
 
@@ -454,53 +564,53 @@ var FLARE_BUILDER_METHODS = {
454
564
  whereConditions: [
455
565
  {
456
566
  name: "where",
457
- signature: "(condition: WhereInput<T>): FlareBuilder<T, Args & { where: WhereInput<T> }>"
567
+ signature: "(condition: WhereInput<T>): this"
458
568
  },
459
569
  {
460
570
  name: "andWhere",
461
- signature: "(condition: WhereInput<T>): FlareBuilder<T, Args & { where: WhereInput<T> }>"
571
+ signature: "(condition: WhereInput<T>): this"
462
572
  },
463
573
  {
464
574
  name: "orWhere",
465
- signature: "(condition: WhereInput<T>): FlareBuilder<T, Args & { where: WhereInput<T> }>"
575
+ signature: "(condition: WhereInput<T>): this"
466
576
  },
467
577
  {
468
578
  name: "whereGroup",
469
- signature: "(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>, mode?: 'AND' | 'OR'): FlareBuilder<T, Args & { where: WhereInput<T> }>"
579
+ signature: "(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>, mode?: 'AND' | 'OR'): this"
470
580
  },
471
581
  {
472
582
  name: "orWhereGroup",
473
- signature: "(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>): FlareBuilder<T, Args & { where: WhereInput<T> }>"
583
+ signature: "(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>): this"
474
584
  },
475
585
  {
476
586
  name: "withId",
477
- signature: "(id: number | string): FlareBuilder<T, Args & { where: { id: number | string } }>"
587
+ signature: "(id: number | string): this"
478
588
  }
479
589
  ],
480
590
  orderingAndLimiting: [
481
591
  {
482
592
  name: "order",
483
- signature: "(orderBy: OrderByInput<T>): FlareBuilder<T, Args & { orderBy: OrderByInput<T> }>"
593
+ signature: "(orderBy: OrderByInput<T>): this"
484
594
  },
485
595
  {
486
596
  name: "first",
487
- signature: "(key?: keyof RecordType<T> | string): FlareBuilder<T, Args & { orderBy: any; take: number }>"
597
+ signature: "(key?: keyof RecordType<T> | string): this"
488
598
  },
489
599
  {
490
600
  name: "last",
491
- signature: "(key?: keyof RecordType<T> | string): FlareBuilder<T, Args & { orderBy: any; take: number }>"
601
+ signature: "(key?: keyof RecordType<T> | string): this"
492
602
  },
493
603
  {
494
604
  name: "limit",
495
- signature: "(count: number): FlareBuilder<T, Args & { take: number }>"
605
+ signature: "(count: number): this"
496
606
  },
497
607
  {
498
608
  name: "skip",
499
- signature: "(count: number): FlareBuilder<T, Args & { skip: number }>"
609
+ signature: "(count: number): this"
500
610
  },
501
611
  {
502
612
  name: "distinct",
503
- signature: "(fields: DistinctInput<T>): FlareBuilder<T, Args & { distinct: DistinctInput<T> }>"
613
+ signature: "(fields: DistinctInput<T>): this"
504
614
  }
505
615
  ],
506
616
  selection: [
@@ -624,7 +734,7 @@ var FLARE_BUILDER_METHODS = {
624
734
  utilities: [
625
735
  {
626
736
  name: "when",
627
- signature: "(condition: boolean | (() => boolean), callback: (qb: FlareBuilder<T, Args>) => void): FlareBuilder<T, Args>"
737
+ signature: "(condition: boolean | (() => boolean), callback: (qb: this) => void): this"
628
738
  },
629
739
  {
630
740
  name: "chunk",
@@ -912,14 +1022,14 @@ function generateForNewProvider(rootDir, prismaClientPath) {
912
1022
  if (!fs3.existsSync(prismaClientPath)) {
913
1023
  fs3.mkdirSync(prismaClientPath, { recursive: true });
914
1024
  }
915
- const flareFilePath = path3.join(prismaClientPath, "flare.ts");
1025
+ const flareFilePath = path4.join(prismaClientPath, "flare.ts");
916
1026
  const content = generateNewProviderContent(rootDir);
917
1027
  fs3.writeFileSync(flareFilePath, content);
918
1028
  console.log(`\u2705 Generated prisma-flare client for new prisma-client provider`);
919
1029
  console.log(` Location: ${flareFilePath}`);
920
1030
  console.log(
921
1031
  `
922
- Import: import { FlareClient } from '${path3.relative(rootDir, flareFilePath).replace(/\\/g, "/").replace(".ts", ".js")}';`
1032
+ Import: import { FlareClient } from '${path4.relative(rootDir, flareFilePath).replace(/\\/g, "/").replace(".ts", ".js")}';`
923
1033
  );
924
1034
  }
925
1035
  function generateCustomOutputTypes(rootDir, resolvedImport, useFlareResult = false) {
@@ -1061,8 +1171,8 @@ function generateClient() {
1061
1171
  if (isNewProvider && isCustomOutput) {
1062
1172
  generateForNewProvider(rootDir, prismaClientImport);
1063
1173
  }
1064
- const nodeModulesDir = path3.join(rootDir, "node_modules");
1065
- const prismaFlareDir = path3.join(nodeModulesDir, "prisma-flare-generated");
1174
+ const nodeModulesDir = path4.join(rootDir, "node_modules");
1175
+ const prismaFlareDir = path4.join(nodeModulesDir, "prisma-flare-generated");
1066
1176
  if (!fs3.existsSync(prismaFlareDir)) {
1067
1177
  fs3.mkdirSync(prismaFlareDir, { recursive: true });
1068
1178
  }
@@ -1072,7 +1182,7 @@ function generateClient() {
1072
1182
  resolvedImport = "@prisma/client";
1073
1183
  resolvedImportForJs = "@prisma/client";
1074
1184
  } else {
1075
- resolvedImport = path3.relative(prismaFlareDir, prismaClientImport);
1185
+ resolvedImport = path4.relative(prismaFlareDir, prismaClientImport);
1076
1186
  if (!resolvedImport.startsWith(".")) {
1077
1187
  resolvedImport = "./" + resolvedImport;
1078
1188
  }
@@ -1123,8 +1233,8 @@ export const afterUpsert = _afterUpsert;
1123
1233
  export { hookRegistry };
1124
1234
  `;
1125
1235
  const dtsContent = isCustomOutput ? generateCustomOutputTypes(rootDir, resolvedImportForJs, isNewProvider) : generateDefaultTypes(resolvedImport);
1126
- fs3.writeFileSync(path3.join(prismaFlareDir, "index.js"), esmContent);
1127
- fs3.writeFileSync(path3.join(prismaFlareDir, "index.d.ts"), dtsContent);
1236
+ fs3.writeFileSync(path4.join(prismaFlareDir, "index.js"), esmContent);
1237
+ fs3.writeFileSync(path4.join(prismaFlareDir, "index.d.ts"), dtsContent);
1128
1238
  const packageJson = {
1129
1239
  name: "prisma-flare-generated",
1130
1240
  version: "0.0.0",
@@ -1140,7 +1250,7 @@ export { hookRegistry };
1140
1250
  }
1141
1251
  }
1142
1252
  };
1143
- fs3.writeFileSync(path3.join(prismaFlareDir, "package.json"), JSON.stringify(packageJson, null, 2));
1253
+ fs3.writeFileSync(path4.join(prismaFlareDir, "package.json"), JSON.stringify(packageJson, null, 2));
1144
1254
  if (isCustomOutput) {
1145
1255
  console.log(`\u2705 Generated prisma-flare client with custom Prisma output: ${prismaClientImport}`);
1146
1256
  } else {
@@ -1279,7 +1389,7 @@ export declare const hookRegistry: typeof _hookRegistry;
1279
1389
 
1280
1390
  // src/cli/generate-queries.ts
1281
1391
  var fs4 = __toESM(require("fs"), 1);
1282
- var path4 = __toESM(require("path"), 1);
1392
+ var path5 = __toESM(require("path"), 1);
1283
1393
  var import_pluralize = __toESM(require("pluralize"), 1);
1284
1394
  function toCamelCase(str) {
1285
1395
  return str.charAt(0).toLowerCase() + str.slice(1);
@@ -1313,41 +1423,44 @@ function parseRelations(schemaContent, models) {
1313
1423
  function generateQueries() {
1314
1424
  const rootDir = findProjectRoot(process.cwd());
1315
1425
  const config = loadConfig(rootDir);
1316
- const schemaPath = path4.join(rootDir, "prisma", "schema.prisma");
1317
- if (!fs4.existsSync(schemaPath)) {
1318
- console.error(`\u274C Schema not found at ${schemaPath}`);
1426
+ const resolution = resolveSchemaPath(rootDir);
1427
+ if (!resolution) {
1428
+ console.error(`\u274C Schema not found. Looked for:`);
1429
+ console.error(` - prisma.config.ts (Prisma 7+)`);
1430
+ console.error(` - prisma/schema/ directory`);
1431
+ console.error(` - prisma/schema.prisma file`);
1319
1432
  return;
1320
1433
  }
1321
- const schemaContent = fs4.readFileSync(schemaPath, "utf-8");
1434
+ const schemaContent = resolution.content;
1322
1435
  const modelRegex = /model\s+(\w+)\s+{/g;
1323
1436
  const models = [];
1324
1437
  let match;
1325
1438
  while ((match = modelRegex.exec(schemaContent)) !== null) {
1326
1439
  models.push(match[1]);
1327
1440
  }
1328
- const queriesDir = path4.join(rootDir, config.modelsPath);
1441
+ const queriesDir = path5.join(rootDir, config.modelsPath);
1329
1442
  if (!fs4.existsSync(queriesDir)) {
1330
1443
  fs4.mkdirSync(queriesDir, { recursive: true });
1331
1444
  }
1332
- const absDbPath = path4.join(rootDir, config.dbPath);
1333
- let relativePathToDb = path4.relative(queriesDir, absDbPath);
1445
+ const absDbPath = path5.join(rootDir, config.dbPath);
1446
+ let relativePathToDb = path5.relative(queriesDir, absDbPath);
1334
1447
  if (!relativePathToDb.startsWith(".")) relativePathToDb = "./" + relativePathToDb;
1335
1448
  relativePathToDb = relativePathToDb.replace(/\\/g, "/");
1336
1449
  const _provider = getPrismaProvider(rootDir);
1337
1450
  void _provider;
1338
1451
  models.forEach((model) => {
1339
1452
  const queryFileName = `${model}.ts`;
1340
- const queryFilePath = path4.join(queriesDir, queryFileName);
1453
+ const queryFilePath = path5.join(queriesDir, queryFileName);
1341
1454
  const modelCamel = toCamelCase(model);
1342
1455
  if (fs4.existsSync(queryFilePath)) {
1343
1456
  return;
1344
1457
  }
1345
1458
  console.log(`Generating ${queryFileName}...`);
1346
1459
  let queryBuilderImport = "import { FlareBuilder } from 'prisma-flare/client';";
1347
- const localQueryBuilderPath = path4.join(rootDir, "src/core/flareBuilder.ts");
1460
+ const localQueryBuilderPath = path5.join(rootDir, "src/core/flareBuilder.ts");
1348
1461
  if (fs4.existsSync(localQueryBuilderPath)) {
1349
- const absSrcPath = path4.join(rootDir, "src");
1350
- let relativePathToSrc = path4.relative(queriesDir, absSrcPath);
1462
+ const absSrcPath = path5.join(rootDir, "src");
1463
+ let relativePathToSrc = path5.relative(queriesDir, absSrcPath);
1351
1464
  if (!relativePathToSrc.startsWith(".")) relativePathToSrc = "./" + relativePathToSrc;
1352
1465
  relativePathToSrc = relativePathToSrc.replace(/\\/g, "/");
1353
1466
  queryBuilderImport = `import { FlareBuilder } from '${relativePathToSrc}';`;
@@ -1364,12 +1477,12 @@ export default class ${model} extends FlareBuilder<'${modelCamel}'> {
1364
1477
  fs4.writeFileSync(queryFilePath, content);
1365
1478
  });
1366
1479
  let pfDistDir;
1367
- const pfPackageDir = path4.join(rootDir, "node_modules", "prisma-flare");
1480
+ const pfPackageDir = path5.join(rootDir, "node_modules", "prisma-flare");
1368
1481
  let realPfPackageDir = pfPackageDir;
1369
1482
  if (fs4.existsSync(pfPackageDir)) {
1370
1483
  realPfPackageDir = fs4.realpathSync(pfPackageDir);
1371
1484
  }
1372
- pfDistDir = path4.join(realPfPackageDir, "dist");
1485
+ pfDistDir = path5.join(realPfPackageDir, "dist");
1373
1486
  let dbPathWithExt = absDbPath;
1374
1487
  if (!absDbPath.endsWith(".ts") && !absDbPath.endsWith(".js")) {
1375
1488
  if (fs4.existsSync(absDbPath + ".ts")) {
@@ -1378,12 +1491,12 @@ export default class ${model} extends FlareBuilder<'${modelCamel}'> {
1378
1491
  dbPathWithExt = absDbPath + ".js";
1379
1492
  }
1380
1493
  }
1381
- let relativePathToDbForDist = path4.relative(pfDistDir, dbPathWithExt);
1494
+ let relativePathToDbForDist = path5.relative(pfDistDir, dbPathWithExt);
1382
1495
  if (!relativePathToDbForDist.startsWith(".")) relativePathToDbForDist = "./" + relativePathToDbForDist;
1383
1496
  relativePathToDbForDist = relativePathToDbForDist.replace(/\\/g, "/");
1384
1497
  const relativePathToDbForDts = relativePathToDbForDist;
1385
- const absModelsPath = path4.join(queriesDir);
1386
- let relativePathToModels = path4.relative(pfDistDir, absModelsPath);
1498
+ const absModelsPath = path5.join(queriesDir);
1499
+ let relativePathToModels = path5.relative(pfDistDir, absModelsPath);
1387
1500
  if (!relativePathToModels.startsWith(".")) relativePathToModels = "./" + relativePathToModels;
1388
1501
  relativePathToModels = relativePathToModels.replace(/\\/g, "/");
1389
1502
  const relations = parseRelations(schemaContent, models);
@@ -1409,7 +1522,7 @@ export default class ${model} extends FlareBuilder<'${modelCamel}'> {
1409
1522
  }
1410
1523
  }
1411
1524
  const modelRegistrations = registrationLines.join("\n");
1412
- const generatedJsPath = path4.join(pfDistDir, "generated.js");
1525
+ const generatedJsPath = path5.join(pfDistDir, "generated.js");
1413
1526
  const imports = models.map((model) => {
1414
1527
  return `import ${model} from '${relativePathToModels}/${model}.ts';`;
1415
1528
  }).join("\n");
@@ -1430,7 +1543,7 @@ ${getters}
1430
1543
  }
1431
1544
  `;
1432
1545
  fs4.writeFileSync(generatedJsPath, generatedContent);
1433
- const generatedCjsPath = path4.join(pfDistDir, "generated.cjs");
1546
+ const generatedCjsPath = path5.join(pfDistDir, "generated.cjs");
1434
1547
  const importsCjs = models.map((model) => {
1435
1548
  return `const ${model} = require('${relativePathToModels}/${model}').default;`;
1436
1549
  }).join("\n");
@@ -1452,7 +1565,7 @@ ${getters}
1452
1565
  exports.DB = DB;
1453
1566
  `;
1454
1567
  fs4.writeFileSync(generatedCjsPath, generatedCjsContent);
1455
- const generatedDtsPath = path4.join(pfDistDir, "generated.d.ts");
1568
+ const generatedDtsPath = path5.join(pfDistDir, "generated.d.ts");
1456
1569
  const importsDts = models.map((model) => {
1457
1570
  return `import ${model} from '${relativePathToModels}/${model}.ts';`;
1458
1571
  }).join("\n");
@@ -1503,11 +1616,11 @@ ${gettersTypes}
1503
1616
 
1504
1617
  // src/cli/generate-callbacks.ts
1505
1618
  var fs5 = __toESM(require("fs"), 1);
1506
- var path5 = __toESM(require("path"), 1);
1619
+ var path6 = __toESM(require("path"), 1);
1507
1620
  function generateCallbacksIndex() {
1508
1621
  const rootDir = findProjectRoot(process.cwd());
1509
1622
  const config = loadConfig(rootDir);
1510
- const callbacksDir = path5.join(rootDir, config.callbacksPath);
1623
+ const callbacksDir = path6.join(rootDir, config.callbacksPath);
1511
1624
  if (!fs5.existsSync(callbacksDir)) {
1512
1625
  console.log(`\u2139\uFE0F Callbacks directory not found: ${callbacksDir}`);
1513
1626
  return;
@@ -1533,7 +1646,7 @@ function generateCallbacksIndex() {
1533
1646
 
1534
1647
  ${imports}
1535
1648
  `;
1536
- const indexPath = path5.join(callbacksDir, "index.ts");
1649
+ const indexPath = path6.join(callbacksDir, "index.ts");
1537
1650
  fs5.writeFileSync(indexPath, content);
1538
1651
  console.log(`\u2705 Generated callbacks index: ${callbacksDir}/index.ts (${callbackFiles.length} callbacks)`);
1539
1652
  }