prisma-flare 1.3.0 → 1.3.2
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/cli/db-migrate.cjs +119 -49
- package/dist/cli/db-migrate.js +125 -49
- package/dist/cli/db-reset.cjs +119 -49
- package/dist/cli/db-reset.js +125 -49
- package/dist/cli/index.cjs +119 -49
- package/dist/cli/index.js +125 -49
- package/dist/core/flareBuilder.d.cts +17 -45
- package/dist/core/flareBuilder.d.ts +17 -45
- package/dist/core/hooks.cjs +44 -22
- package/dist/core/hooks.d.cts +8 -8
- package/dist/core/hooks.d.ts +8 -8
- package/dist/core/hooks.js +44 -22
- package/dist/{hookRegistry-CjujesJK.d.cts → hookRegistry-B8oyCNJ9.d.cts} +14 -2
- package/dist/{hookRegistry--2l0ARPy.d.ts → hookRegistry-C2bTS4YN.d.ts} +14 -2
- package/dist/hooks.cjs +44 -22
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +44 -22
- package/dist/index.cjs +30 -8
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +30 -8
- package/dist/{prisma.types-CIEFXVL-.d.cts → prisma.types-WBv5kOSl.d.cts} +18 -1
- package/dist/{prisma.types-CIEFXVL-.d.ts → prisma.types-WBv5kOSl.d.ts} +18 -1
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
2
8
|
|
|
3
9
|
// src/cli/generate-queries.ts
|
|
4
10
|
import * as fs3 from "fs";
|
|
@@ -207,11 +213,32 @@ function getPrismaProvider(rootDir) {
|
|
|
207
213
|
}
|
|
208
214
|
function parseModelRelations(schemaContent) {
|
|
209
215
|
const models = [];
|
|
210
|
-
const
|
|
216
|
+
const modelStartRegex = /model\s+(\w+)\s*\{/g;
|
|
211
217
|
let modelMatch;
|
|
212
|
-
while ((modelMatch =
|
|
218
|
+
while ((modelMatch = modelStartRegex.exec(schemaContent)) !== null) {
|
|
213
219
|
const modelName = modelMatch[1];
|
|
214
|
-
const
|
|
220
|
+
const bodyStart = modelMatch.index + modelMatch[0].length;
|
|
221
|
+
let depth = 1;
|
|
222
|
+
let i = bodyStart;
|
|
223
|
+
let inString = false;
|
|
224
|
+
let stringChar = "";
|
|
225
|
+
while (i < schemaContent.length && depth > 0) {
|
|
226
|
+
const ch = schemaContent[i];
|
|
227
|
+
if (inString) {
|
|
228
|
+
if (ch === stringChar && schemaContent[i - 1] !== "\\") inString = false;
|
|
229
|
+
} else {
|
|
230
|
+
if (ch === '"' || ch === "'") {
|
|
231
|
+
inString = true;
|
|
232
|
+
stringChar = ch;
|
|
233
|
+
} else if (ch === "{") {
|
|
234
|
+
depth++;
|
|
235
|
+
} else if (ch === "}") {
|
|
236
|
+
depth--;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
i++;
|
|
240
|
+
}
|
|
241
|
+
const modelBody = schemaContent.slice(bodyStart, i - 1);
|
|
215
242
|
const relations = [];
|
|
216
243
|
const lines = modelBody.split("\n");
|
|
217
244
|
for (const line of lines) {
|
|
@@ -271,13 +298,33 @@ ${entries.join(",\n")}
|
|
|
271
298
|
};`;
|
|
272
299
|
}
|
|
273
300
|
function getRelationModelMap(rootDir) {
|
|
301
|
+
const dmmfResult = getRelationModelMapFromDMMF(rootDir);
|
|
302
|
+
if (dmmfResult) return dmmfResult;
|
|
274
303
|
const resolution = resolveSchemaPath(rootDir);
|
|
275
|
-
if (!resolution)
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
304
|
+
if (!resolution) return null;
|
|
278
305
|
const models = parseModelRelations(resolution.content);
|
|
279
306
|
return generateRelationModelMap(models);
|
|
280
307
|
}
|
|
308
|
+
function getRelationModelMapFromDMMF(rootDir) {
|
|
309
|
+
try {
|
|
310
|
+
const clientPath = getPrismaClientPath(rootDir);
|
|
311
|
+
const resolvedPath = clientPath.startsWith("/") ? clientPath : __require.resolve(clientPath, { paths: [rootDir] });
|
|
312
|
+
const prismaModule = __require(resolvedPath);
|
|
313
|
+
const dmmf = prismaModule?.Prisma?.dmmf ?? prismaModule?.dmmf;
|
|
314
|
+
if (!dmmf?.datamodel?.models) return null;
|
|
315
|
+
const models = dmmf.datamodel.models.map((model) => ({
|
|
316
|
+
name: model.name,
|
|
317
|
+
relations: model.fields.filter((f) => f.kind === "object").map((f) => ({
|
|
318
|
+
fieldName: f.name,
|
|
319
|
+
targetModel: f.type,
|
|
320
|
+
isArray: f.isList
|
|
321
|
+
}))
|
|
322
|
+
}));
|
|
323
|
+
return generateRelationModelMap(models);
|
|
324
|
+
} catch {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
281
328
|
|
|
282
329
|
// src/cli/generate-queries.ts
|
|
283
330
|
function toCamelCase(str) {
|
|
@@ -788,6 +835,11 @@ ${exportKeyword}type ColumnChangeCallback<T extends ModelName = ModelName> = (
|
|
|
788
835
|
/**
|
|
789
836
|
* Options for column change hooks (afterChange)
|
|
790
837
|
*/
|
|
838
|
+
${exportKeyword}interface HookOptions {
|
|
839
|
+
/** Tag to group hooks. Tagged hooks can be disabled/enabled via hookRegistry.disable(tag)/enable(tag). */
|
|
840
|
+
tag?: string;
|
|
841
|
+
}
|
|
842
|
+
|
|
791
843
|
${exportKeyword}interface ColumnChangeOptions<T extends ModelName = ModelName> {
|
|
792
844
|
/**
|
|
793
845
|
* Additional fields to include when fetching records for this hook.
|
|
@@ -795,6 +847,8 @@ ${exportKeyword}interface ColumnChangeOptions<T extends ModelName = ModelName> {
|
|
|
795
847
|
* Use this when your callback needs access to other fields.
|
|
796
848
|
*/
|
|
797
849
|
includeFields?: FieldName<T>[];
|
|
850
|
+
/** Tag to group hooks. Tagged hooks can be disabled/enabled via hookRegistry.disable(tag)/enable(tag). */
|
|
851
|
+
tag?: string;
|
|
798
852
|
}
|
|
799
853
|
`.trimStart();
|
|
800
854
|
}
|
|
@@ -804,53 +858,53 @@ var FLARE_BUILDER_METHODS = {
|
|
|
804
858
|
whereConditions: [
|
|
805
859
|
{
|
|
806
860
|
name: "where",
|
|
807
|
-
signature: "(condition: WhereInput<T>):
|
|
861
|
+
signature: "(condition: WhereInput<T>): this"
|
|
808
862
|
},
|
|
809
863
|
{
|
|
810
864
|
name: "andWhere",
|
|
811
|
-
signature: "(condition: WhereInput<T>):
|
|
865
|
+
signature: "(condition: WhereInput<T>): this"
|
|
812
866
|
},
|
|
813
867
|
{
|
|
814
868
|
name: "orWhere",
|
|
815
|
-
signature: "(condition: WhereInput<T>):
|
|
869
|
+
signature: "(condition: WhereInput<T>): this"
|
|
816
870
|
},
|
|
817
871
|
{
|
|
818
872
|
name: "whereGroup",
|
|
819
|
-
signature: "(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>, mode?: 'AND' | 'OR'):
|
|
873
|
+
signature: "(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>, mode?: 'AND' | 'OR'): this"
|
|
820
874
|
},
|
|
821
875
|
{
|
|
822
876
|
name: "orWhereGroup",
|
|
823
|
-
signature: "(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>):
|
|
877
|
+
signature: "(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>): this"
|
|
824
878
|
},
|
|
825
879
|
{
|
|
826
880
|
name: "withId",
|
|
827
|
-
signature: "(id: number | string):
|
|
881
|
+
signature: "(id: number | string): this"
|
|
828
882
|
}
|
|
829
883
|
],
|
|
830
884
|
orderingAndLimiting: [
|
|
831
885
|
{
|
|
832
886
|
name: "order",
|
|
833
|
-
signature: "(orderBy: OrderByInput<T>):
|
|
887
|
+
signature: "(orderBy: OrderByInput<T>): this"
|
|
834
888
|
},
|
|
835
889
|
{
|
|
836
890
|
name: "first",
|
|
837
|
-
signature: "(key?: keyof RecordType<T> | string):
|
|
891
|
+
signature: "(key?: keyof RecordType<T> | string): this"
|
|
838
892
|
},
|
|
839
893
|
{
|
|
840
894
|
name: "last",
|
|
841
|
-
signature: "(key?: keyof RecordType<T> | string):
|
|
895
|
+
signature: "(key?: keyof RecordType<T> | string): this"
|
|
842
896
|
},
|
|
843
897
|
{
|
|
844
898
|
name: "limit",
|
|
845
|
-
signature: "(count: number):
|
|
899
|
+
signature: "(count: number): this"
|
|
846
900
|
},
|
|
847
901
|
{
|
|
848
902
|
name: "skip",
|
|
849
|
-
signature: "(count: number):
|
|
903
|
+
signature: "(count: number): this"
|
|
850
904
|
},
|
|
851
905
|
{
|
|
852
906
|
name: "distinct",
|
|
853
|
-
signature: "(fields: DistinctInput<T>):
|
|
907
|
+
signature: "(fields: DistinctInput<T>): this"
|
|
854
908
|
}
|
|
855
909
|
],
|
|
856
910
|
selection: [
|
|
@@ -962,7 +1016,7 @@ var FLARE_BUILDER_METHODS = {
|
|
|
962
1016
|
pagination: [
|
|
963
1017
|
{
|
|
964
1018
|
name: "paginate",
|
|
965
|
-
signature:
|
|
1019
|
+
signature: (ns, useFlareResult) => useFlareResult ? `(page?: number, perPage?: number): Promise<PaginatedResult<FlareResult<T, Args>>>` : `(page?: number, perPage?: number): Promise<PaginatedResult<${ns}.Result<ModelDelegate<T>, Args, 'findFirstOrThrow'>>>`
|
|
966
1020
|
}
|
|
967
1021
|
],
|
|
968
1022
|
existence: [
|
|
@@ -974,11 +1028,11 @@ var FLARE_BUILDER_METHODS = {
|
|
|
974
1028
|
utilities: [
|
|
975
1029
|
{
|
|
976
1030
|
name: "when",
|
|
977
|
-
signature: "(condition: boolean | (() => boolean), callback: (qb:
|
|
1031
|
+
signature: "(condition: boolean | (() => boolean), callback: (qb: this) => void): this"
|
|
978
1032
|
},
|
|
979
1033
|
{
|
|
980
1034
|
name: "chunk",
|
|
981
|
-
signature:
|
|
1035
|
+
signature: (ns, useFlareResult) => useFlareResult ? `(size: number, callback: (results: FlareResultMany<T, Args>) => Promise<void> | void): Promise<void>` : `(size: number, callback: (results: ${ns}.Result<ModelDelegate<T>, Args, 'findMany'>) => Promise<void> | void): Promise<void>`
|
|
982
1036
|
},
|
|
983
1037
|
{
|
|
984
1038
|
name: "clone",
|
|
@@ -1177,9 +1231,10 @@ import {
|
|
|
1177
1231
|
*/
|
|
1178
1232
|
export function beforeCreate<T extends ModelName>(
|
|
1179
1233
|
model: T,
|
|
1180
|
-
callback: BeforeHookCallback<T
|
|
1234
|
+
callback: BeforeHookCallback<T>,
|
|
1235
|
+
options?: HookOptions
|
|
1181
1236
|
): void {
|
|
1182
|
-
_beforeCreate(model as any, callback as any);
|
|
1237
|
+
_beforeCreate(model as any, callback as any, options);
|
|
1183
1238
|
}
|
|
1184
1239
|
|
|
1185
1240
|
/**
|
|
@@ -1187,9 +1242,10 @@ export function beforeCreate<T extends ModelName>(
|
|
|
1187
1242
|
*/
|
|
1188
1243
|
export function afterCreate<T extends ModelName>(
|
|
1189
1244
|
model: T,
|
|
1190
|
-
callback: AfterHookCallback<T
|
|
1245
|
+
callback: AfterHookCallback<T>,
|
|
1246
|
+
options?: HookOptions
|
|
1191
1247
|
): void {
|
|
1192
|
-
_afterCreate(model as any, callback as any);
|
|
1248
|
+
_afterCreate(model as any, callback as any, options);
|
|
1193
1249
|
}
|
|
1194
1250
|
|
|
1195
1251
|
/**
|
|
@@ -1197,9 +1253,10 @@ export function afterCreate<T extends ModelName>(
|
|
|
1197
1253
|
*/
|
|
1198
1254
|
export function beforeUpdate<T extends ModelName>(
|
|
1199
1255
|
model: T,
|
|
1200
|
-
callback: BeforeHookCallback<T
|
|
1256
|
+
callback: BeforeHookCallback<T>,
|
|
1257
|
+
options?: HookOptions
|
|
1201
1258
|
): void {
|
|
1202
|
-
_beforeUpdate(model as any, callback as any);
|
|
1259
|
+
_beforeUpdate(model as any, callback as any, options);
|
|
1203
1260
|
}
|
|
1204
1261
|
|
|
1205
1262
|
/**
|
|
@@ -1207,9 +1264,10 @@ export function beforeUpdate<T extends ModelName>(
|
|
|
1207
1264
|
*/
|
|
1208
1265
|
export function afterUpdate<T extends ModelName>(
|
|
1209
1266
|
model: T,
|
|
1210
|
-
callback: AfterHookCallback<T
|
|
1267
|
+
callback: AfterHookCallback<T>,
|
|
1268
|
+
options?: HookOptions
|
|
1211
1269
|
): void {
|
|
1212
|
-
_afterUpdate(model as any, callback as any);
|
|
1270
|
+
_afterUpdate(model as any, callback as any, options);
|
|
1213
1271
|
}
|
|
1214
1272
|
|
|
1215
1273
|
/**
|
|
@@ -1217,9 +1275,10 @@ export function afterUpdate<T extends ModelName>(
|
|
|
1217
1275
|
*/
|
|
1218
1276
|
export function beforeDelete<T extends ModelName>(
|
|
1219
1277
|
model: T,
|
|
1220
|
-
callback: BeforeHookCallback<T
|
|
1278
|
+
callback: BeforeHookCallback<T>,
|
|
1279
|
+
options?: HookOptions
|
|
1221
1280
|
): void {
|
|
1222
|
-
_beforeDelete(model as any, callback as any);
|
|
1281
|
+
_beforeDelete(model as any, callback as any, options);
|
|
1223
1282
|
}
|
|
1224
1283
|
|
|
1225
1284
|
/**
|
|
@@ -1227,9 +1286,10 @@ export function beforeDelete<T extends ModelName>(
|
|
|
1227
1286
|
*/
|
|
1228
1287
|
export function afterDelete<T extends ModelName>(
|
|
1229
1288
|
model: T,
|
|
1230
|
-
callback: AfterHookCallback<T
|
|
1289
|
+
callback: AfterHookCallback<T>,
|
|
1290
|
+
options?: HookOptions
|
|
1231
1291
|
): void {
|
|
1232
|
-
_afterDelete(model as any, callback as any);
|
|
1292
|
+
_afterDelete(model as any, callback as any, options);
|
|
1233
1293
|
}
|
|
1234
1294
|
|
|
1235
1295
|
/**
|
|
@@ -1249,9 +1309,10 @@ export function afterChange<T extends ModelName>(
|
|
|
1249
1309
|
*/
|
|
1250
1310
|
export function afterUpsert<T extends ModelName>(
|
|
1251
1311
|
model: T,
|
|
1252
|
-
callback: AfterHookCallback<T
|
|
1312
|
+
callback: AfterHookCallback<T>,
|
|
1313
|
+
options?: HookOptions
|
|
1253
1314
|
): void {
|
|
1254
|
-
_afterUpsert(model as any, callback as any);
|
|
1315
|
+
_afterUpsert(model as any, callback as any, options);
|
|
1255
1316
|
}
|
|
1256
1317
|
|
|
1257
1318
|
// Re-export hookRegistry for advanced use cases
|
|
@@ -1331,7 +1392,8 @@ import {
|
|
|
1331
1392
|
*/
|
|
1332
1393
|
export declare function beforeCreate<T extends ModelName>(
|
|
1333
1394
|
model: T,
|
|
1334
|
-
callback: BeforeHookCallback<T
|
|
1395
|
+
callback: BeforeHookCallback<T>,
|
|
1396
|
+
options?: HookOptions
|
|
1335
1397
|
): void;
|
|
1336
1398
|
|
|
1337
1399
|
/**
|
|
@@ -1339,7 +1401,8 @@ export declare function beforeCreate<T extends ModelName>(
|
|
|
1339
1401
|
*/
|
|
1340
1402
|
export declare function afterCreate<T extends ModelName>(
|
|
1341
1403
|
model: T,
|
|
1342
|
-
callback: AfterHookCallback<T
|
|
1404
|
+
callback: AfterHookCallback<T>,
|
|
1405
|
+
options?: HookOptions
|
|
1343
1406
|
): void;
|
|
1344
1407
|
|
|
1345
1408
|
/**
|
|
@@ -1347,7 +1410,8 @@ export declare function afterCreate<T extends ModelName>(
|
|
|
1347
1410
|
*/
|
|
1348
1411
|
export declare function beforeUpdate<T extends ModelName>(
|
|
1349
1412
|
model: T,
|
|
1350
|
-
callback: BeforeHookCallback<T
|
|
1413
|
+
callback: BeforeHookCallback<T>,
|
|
1414
|
+
options?: HookOptions
|
|
1351
1415
|
): void;
|
|
1352
1416
|
|
|
1353
1417
|
/**
|
|
@@ -1355,7 +1419,8 @@ export declare function beforeUpdate<T extends ModelName>(
|
|
|
1355
1419
|
*/
|
|
1356
1420
|
export declare function afterUpdate<T extends ModelName>(
|
|
1357
1421
|
model: T,
|
|
1358
|
-
callback: AfterHookCallback<T
|
|
1422
|
+
callback: AfterHookCallback<T>,
|
|
1423
|
+
options?: HookOptions
|
|
1359
1424
|
): void;
|
|
1360
1425
|
|
|
1361
1426
|
/**
|
|
@@ -1363,7 +1428,8 @@ export declare function afterUpdate<T extends ModelName>(
|
|
|
1363
1428
|
*/
|
|
1364
1429
|
export declare function beforeDelete<T extends ModelName>(
|
|
1365
1430
|
model: T,
|
|
1366
|
-
callback: BeforeHookCallback<T
|
|
1431
|
+
callback: BeforeHookCallback<T>,
|
|
1432
|
+
options?: HookOptions
|
|
1367
1433
|
): void;
|
|
1368
1434
|
|
|
1369
1435
|
/**
|
|
@@ -1371,7 +1437,8 @@ export declare function beforeDelete<T extends ModelName>(
|
|
|
1371
1437
|
*/
|
|
1372
1438
|
export declare function afterDelete<T extends ModelName>(
|
|
1373
1439
|
model: T,
|
|
1374
|
-
callback: AfterHookCallback<T
|
|
1440
|
+
callback: AfterHookCallback<T>,
|
|
1441
|
+
options?: HookOptions
|
|
1375
1442
|
): void;
|
|
1376
1443
|
|
|
1377
1444
|
/**
|
|
@@ -1389,7 +1456,8 @@ export declare function afterChange<T extends ModelName>(
|
|
|
1389
1456
|
*/
|
|
1390
1457
|
export declare function afterUpsert<T extends ModelName>(
|
|
1391
1458
|
model: T,
|
|
1392
|
-
callback: AfterHookCallback<T
|
|
1459
|
+
callback: AfterHookCallback<T>,
|
|
1460
|
+
options?: HookOptions
|
|
1393
1461
|
): void;
|
|
1394
1462
|
|
|
1395
1463
|
// Re-export hookRegistry for advanced use cases
|
|
@@ -1513,6 +1581,7 @@ import type {
|
|
|
1513
1581
|
AfterHookCallback,
|
|
1514
1582
|
ColumnChangeCallback,
|
|
1515
1583
|
ColumnChangeOptions,
|
|
1584
|
+
HookOptions,
|
|
1516
1585
|
FieldName,
|
|
1517
1586
|
HookConfig
|
|
1518
1587
|
} from 'prisma-flare';
|
|
@@ -1561,7 +1630,8 @@ export declare class FlareClient extends BasePrismaClient {
|
|
|
1561
1630
|
*/
|
|
1562
1631
|
export declare function beforeCreate<T extends ModelName>(
|
|
1563
1632
|
model: T,
|
|
1564
|
-
callback: BeforeHookCallback<T
|
|
1633
|
+
callback: BeforeHookCallback<T>,
|
|
1634
|
+
options?: HookOptions
|
|
1565
1635
|
): void;
|
|
1566
1636
|
|
|
1567
1637
|
/**
|
|
@@ -1569,7 +1639,8 @@ export declare function beforeCreate<T extends ModelName>(
|
|
|
1569
1639
|
*/
|
|
1570
1640
|
export declare function afterCreate<T extends ModelName>(
|
|
1571
1641
|
model: T,
|
|
1572
|
-
callback: AfterHookCallback<T
|
|
1642
|
+
callback: AfterHookCallback<T>,
|
|
1643
|
+
options?: HookOptions
|
|
1573
1644
|
): void;
|
|
1574
1645
|
|
|
1575
1646
|
/**
|
|
@@ -1577,7 +1648,8 @@ export declare function afterCreate<T extends ModelName>(
|
|
|
1577
1648
|
*/
|
|
1578
1649
|
export declare function beforeUpdate<T extends ModelName>(
|
|
1579
1650
|
model: T,
|
|
1580
|
-
callback: BeforeHookCallback<T
|
|
1651
|
+
callback: BeforeHookCallback<T>,
|
|
1652
|
+
options?: HookOptions
|
|
1581
1653
|
): void;
|
|
1582
1654
|
|
|
1583
1655
|
/**
|
|
@@ -1585,7 +1657,8 @@ export declare function beforeUpdate<T extends ModelName>(
|
|
|
1585
1657
|
*/
|
|
1586
1658
|
export declare function afterUpdate<T extends ModelName>(
|
|
1587
1659
|
model: T,
|
|
1588
|
-
callback: AfterHookCallback<T
|
|
1660
|
+
callback: AfterHookCallback<T>,
|
|
1661
|
+
options?: HookOptions
|
|
1589
1662
|
): void;
|
|
1590
1663
|
|
|
1591
1664
|
/**
|
|
@@ -1593,7 +1666,8 @@ export declare function afterUpdate<T extends ModelName>(
|
|
|
1593
1666
|
*/
|
|
1594
1667
|
export declare function beforeDelete<T extends ModelName>(
|
|
1595
1668
|
model: T,
|
|
1596
|
-
callback: BeforeHookCallback<T
|
|
1669
|
+
callback: BeforeHookCallback<T>,
|
|
1670
|
+
options?: HookOptions
|
|
1597
1671
|
): void;
|
|
1598
1672
|
|
|
1599
1673
|
/**
|
|
@@ -1601,7 +1675,8 @@ export declare function beforeDelete<T extends ModelName>(
|
|
|
1601
1675
|
*/
|
|
1602
1676
|
export declare function afterDelete<T extends ModelName>(
|
|
1603
1677
|
model: T,
|
|
1604
|
-
callback: AfterHookCallback<T
|
|
1678
|
+
callback: AfterHookCallback<T>,
|
|
1679
|
+
options?: HookOptions
|
|
1605
1680
|
): void;
|
|
1606
1681
|
|
|
1607
1682
|
/**
|
|
@@ -1619,7 +1694,8 @@ export declare function afterChange<T extends ModelName>(
|
|
|
1619
1694
|
*/
|
|
1620
1695
|
export declare function afterUpsert<T extends ModelName>(
|
|
1621
1696
|
model: T,
|
|
1622
|
-
callback: AfterHookCallback<T
|
|
1697
|
+
callback: AfterHookCallback<T>,
|
|
1698
|
+
options?: HookOptions
|
|
1623
1699
|
): void;
|
|
1624
1700
|
|
|
1625
1701
|
// Re-export hookRegistry for advanced use cases
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Prisma } from '@prisma/client';
|
|
2
|
-
import { M as ModelName, b as ModelDelegate, Q as QueryArgs, W as WhereInput, O as OrderByInput, R as RecordType, D as DistinctInput, S as SelectInput, I as IncludeKey, G as GroupByInput, c as HavingInput, d as PaginatedResult, e as CreateData, f as CreateManyData, g as DeleteArgs, h as DeleteManyArgs, U as UpdateData, i as UpdateManyData, j as UpsertArgs, k as SumFields, l as AvgFields, m as MinFields, n as MaxFields } from '../prisma.types-
|
|
2
|
+
import { M as ModelName, b as ModelDelegate, Q as QueryArgs, W as WhereInput, O as OrderByInput, R as RecordType, D as DistinctInput, S as SelectInput, I as IncludeKey, G as GroupByInput, c as HavingInput, d as PaginatedResult, e as CreateData, f as CreateManyData, g as DeleteArgs, h as DeleteManyArgs, U as UpdateData, i as UpdateManyData, j as UpsertArgs, k as SumFields, l as AvgFields, m as MinFields, n as MaxFields } from '../prisma.types-WBv5kOSl.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Global interface for relation-to-model mapping.
|
|
@@ -42,9 +42,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
42
42
|
* .findMany()
|
|
43
43
|
* // Equivalent to: { AND: [{ published: true }, { authorId: 1 }] }
|
|
44
44
|
*/
|
|
45
|
-
where(condition: WhereInput<T>):
|
|
46
|
-
where: WhereInput<T>;
|
|
47
|
-
}>;
|
|
45
|
+
where(condition: WhereInput<T>): this;
|
|
48
46
|
/**
|
|
49
47
|
* Adds a where condition using AND logic (explicit alias for where())
|
|
50
48
|
* @param condition - Where filter matching your Prisma model
|
|
@@ -55,9 +53,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
55
53
|
* .andWhere({ createdAt: { gte: new Date('2024-01-01') } })
|
|
56
54
|
* .findMany()
|
|
57
55
|
*/
|
|
58
|
-
andWhere(condition: WhereInput<T>):
|
|
59
|
-
where: WhereInput<T>;
|
|
60
|
-
}>;
|
|
56
|
+
andWhere(condition: WhereInput<T>): this;
|
|
61
57
|
/**
|
|
62
58
|
* Adds a where condition using OR logic.
|
|
63
59
|
*
|
|
@@ -91,9 +87,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
91
87
|
* .findMany()
|
|
92
88
|
* // Result: published AND (category='news' OR category='tech')
|
|
93
89
|
*/
|
|
94
|
-
orWhere(condition: WhereInput<T>):
|
|
95
|
-
where: WhereInput<T>;
|
|
96
|
-
}>;
|
|
90
|
+
orWhere(condition: WhereInput<T>): this;
|
|
97
91
|
/**
|
|
98
92
|
* Creates a grouped where condition using a callback.
|
|
99
93
|
* Use this for explicit control over boolean logic grouping.
|
|
@@ -122,9 +116,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
122
116
|
* , 'OR')
|
|
123
117
|
* .findMany()
|
|
124
118
|
*/
|
|
125
|
-
whereGroup(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>, mode?: 'AND' | 'OR'):
|
|
126
|
-
where: WhereInput<T>;
|
|
127
|
-
}>;
|
|
119
|
+
whereGroup(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>, mode?: 'AND' | 'OR'): this;
|
|
128
120
|
/**
|
|
129
121
|
* Alias for whereGroup with OR mode.
|
|
130
122
|
* Creates a grouped condition that's OR-ed with existing where.
|
|
@@ -141,56 +133,38 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
141
133
|
* )
|
|
142
134
|
* .findMany()
|
|
143
135
|
*/
|
|
144
|
-
orWhereGroup(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>):
|
|
145
|
-
where: WhereInput<T>;
|
|
146
|
-
}>;
|
|
136
|
+
orWhereGroup(callback: (builder: FlareBuilder<T, Record<string, never>>) => FlareBuilder<T, any>): this;
|
|
147
137
|
/**
|
|
148
138
|
* Adds a where condition to the query for the specified id.
|
|
149
139
|
* Uses the same AND composition as where() for consistency.
|
|
150
140
|
* @param id - The id to search for
|
|
151
141
|
*/
|
|
152
|
-
withId(id: number | string):
|
|
153
|
-
where: {
|
|
154
|
-
id: number | string;
|
|
155
|
-
};
|
|
156
|
-
}>;
|
|
142
|
+
withId(id: number | string): this;
|
|
157
143
|
/**
|
|
158
144
|
* Adds an order by condition to the query
|
|
159
145
|
* @param orderBy - OrderBy object matching your Prisma model
|
|
160
146
|
*/
|
|
161
|
-
order(orderBy: OrderByInput<T>):
|
|
162
|
-
orderBy: OrderByInput<T>;
|
|
163
|
-
}>;
|
|
147
|
+
order(orderBy: OrderByInput<T>): this;
|
|
164
148
|
/**
|
|
165
149
|
* Gets the last record sorted by the specified field
|
|
166
150
|
* @param key - Field to sort by (defaults to 'createdAt')
|
|
167
151
|
*/
|
|
168
|
-
last(key?: keyof RecordType<T> | string):
|
|
169
|
-
orderBy: any;
|
|
170
|
-
take: number;
|
|
171
|
-
}>;
|
|
152
|
+
last(key?: keyof RecordType<T> | string): this;
|
|
172
153
|
/**
|
|
173
154
|
* Gets the first record sorted by the specified field
|
|
174
155
|
* @param key - Field to sort by (defaults to 'createdAt')
|
|
175
156
|
*/
|
|
176
|
-
first(key?: keyof RecordType<T> | string):
|
|
177
|
-
orderBy: any;
|
|
178
|
-
take: number;
|
|
179
|
-
}>;
|
|
157
|
+
first(key?: keyof RecordType<T> | string): this;
|
|
180
158
|
/**
|
|
181
159
|
* Sets a limit on the number of records to retrieve
|
|
182
160
|
* @param limit - Maximum number of records
|
|
183
161
|
*/
|
|
184
|
-
limit(limit: number):
|
|
185
|
-
take: number;
|
|
186
|
-
}>;
|
|
162
|
+
limit(limit: number): this;
|
|
187
163
|
/**
|
|
188
164
|
* Sets distinct fields for the query
|
|
189
165
|
* @param distinct - Fields to be distinct
|
|
190
166
|
*/
|
|
191
|
-
distinct(distinct: DistinctInput<T>):
|
|
192
|
-
distinct: DistinctInput<T>;
|
|
193
|
-
}>;
|
|
167
|
+
distinct(distinct: DistinctInput<T>): this;
|
|
194
168
|
/**
|
|
195
169
|
* Selects specific fields to retrieve
|
|
196
170
|
* @param fields - Select object matching your Prisma model
|
|
@@ -248,9 +222,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
248
222
|
* Skips the specified number of records
|
|
249
223
|
* @param offset - Number of records to skip
|
|
250
224
|
*/
|
|
251
|
-
skip(offset: number):
|
|
252
|
-
skip: number;
|
|
253
|
-
}>;
|
|
225
|
+
skip(offset: number): this;
|
|
254
226
|
/**
|
|
255
227
|
* Checks if any record exists matching the current query
|
|
256
228
|
* @param existenceKey - Key to check for existence (defaults to 'id')
|
|
@@ -261,7 +233,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
261
233
|
* @param page - Page number (1-based)
|
|
262
234
|
* @param perPage - Number of records per page
|
|
263
235
|
*/
|
|
264
|
-
paginate(page?: number, perPage?: number): Promise<PaginatedResult<
|
|
236
|
+
paginate(page?: number, perPage?: number): Promise<PaginatedResult<Prisma.Result<ModelDelegate<T>, Args, 'findFirstOrThrow'>>>;
|
|
265
237
|
/**
|
|
266
238
|
* Conditionally executes a callback on the query builder
|
|
267
239
|
* @param condition - Boolean or function returning boolean
|
|
@@ -273,7 +245,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
273
245
|
* @param size - Size of each chunk
|
|
274
246
|
* @param callback - Function to process each chunk
|
|
275
247
|
*/
|
|
276
|
-
chunk(size: number, callback: (results:
|
|
248
|
+
chunk(size: number, callback: (results: Prisma.Result<ModelDelegate<T>, Args, 'findMany'>) => Promise<void> | void): Promise<void>;
|
|
277
249
|
/**
|
|
278
250
|
* Clones the current query builder instance.
|
|
279
251
|
* Uses structuredClone for proper handling of Date, BigInt, etc.
|
|
@@ -285,7 +257,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
285
257
|
* @throws {Prisma.NotFoundError} When no record matches the query
|
|
286
258
|
* @returns Promise resolving to the found record
|
|
287
259
|
*/
|
|
288
|
-
findFirstOrThrow(): Promise<
|
|
260
|
+
findFirstOrThrow(): Promise<Prisma.Result<ModelDelegate<T>, Args, 'findFirstOrThrow'>>;
|
|
289
261
|
/**
|
|
290
262
|
* Finds a unique record by primary key or throws an error if not found
|
|
291
263
|
* Requires a unique constraint (typically the id field)
|
|
@@ -293,7 +265,7 @@ declare class FlareBuilder<T extends ModelName, Args extends Record<string, any>
|
|
|
293
265
|
* @throws {Prisma.NotFoundError} When no record is found
|
|
294
266
|
* @returns Promise resolving to the found record
|
|
295
267
|
*/
|
|
296
|
-
findUniqueOrThrow(): Promise<
|
|
268
|
+
findUniqueOrThrow(): Promise<Prisma.Result<ModelDelegate<T>, Args, 'findUniqueOrThrow'>>;
|
|
297
269
|
/**
|
|
298
270
|
* Finds all records matching the query
|
|
299
271
|
* Respects all previously set query conditions (where, orderBy, take, skip, include, select, distinct)
|