@prisma-idb/idb-client-generator 0.19.1 → 0.21.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/.release-it.json +3 -0
- package/LICENSE +661 -0
- package/dist/fileCreators/apply-pull/create.js +59 -0
- package/dist/fileCreators/apply-pull/create.js.map +1 -0
- package/dist/fileCreators/batch-processor/create.js +225 -0
- package/dist/fileCreators/batch-processor/create.js.map +1 -0
- package/dist/fileCreators/batch-processor/model-validator.js +31 -0
- package/dist/fileCreators/batch-processor/model-validator.js.map +1 -0
- package/dist/fileCreators/idb-interface/create.js +60 -18
- package/dist/fileCreators/idb-interface/create.js.map +1 -1
- package/dist/fileCreators/idb-utils/comparator/genericComparator.js +24 -26
- package/dist/fileCreators/idb-utils/comparator/genericComparator.js.map +1 -1
- package/dist/fileCreators/idb-utils/create.js +43 -60
- package/dist/fileCreators/idb-utils/create.js.map +1 -1
- package/dist/fileCreators/idb-utils/filters/BigIntFilter.js +26 -38
- package/dist/fileCreators/idb-utils/filters/BigIntFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/filters/BoolFilter.js +20 -32
- package/dist/fileCreators/idb-utils/filters/BoolFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/filters/BytesFilter.js +30 -42
- package/dist/fileCreators/idb-utils/filters/BytesFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/filters/DateTimeFilter.js +27 -39
- package/dist/fileCreators/idb-utils/filters/DateTimeFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/filters/NumberFilter.js +26 -38
- package/dist/fileCreators/idb-utils/filters/NumberFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/filters/StringFilter.js +29 -41
- package/dist/fileCreators/idb-utils/filters/StringFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/listFilters/BigIntListFilter.js +15 -24
- package/dist/fileCreators/idb-utils/listFilters/BigIntListFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/listFilters/BooleanListFilter.js +15 -24
- package/dist/fileCreators/idb-utils/listFilters/BooleanListFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/listFilters/BytesListFilter.js +15 -24
- package/dist/fileCreators/idb-utils/listFilters/BytesListFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/listFilters/DateTimeListFilter.js +15 -24
- package/dist/fileCreators/idb-utils/listFilters/DateTimeListFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/listFilters/NumberListFilter.js +15 -27
- package/dist/fileCreators/idb-utils/listFilters/NumberListFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/listFilters/StringListFilter.js +15 -24
- package/dist/fileCreators/idb-utils/listFilters/StringListFilter.js.map +1 -1
- package/dist/fileCreators/idb-utils/logicalFilters/applyLogicalFilters.js +8 -24
- package/dist/fileCreators/idb-utils/logicalFilters/applyLogicalFilters.js.map +1 -1
- package/dist/fileCreators/idb-utils/logicalFilters/intersectArraysByNestedKey.js +8 -16
- package/dist/fileCreators/idb-utils/logicalFilters/intersectArraysByNestedKey.js.map +1 -1
- package/dist/fileCreators/idb-utils/logicalFilters/removeDuplicatesByKeyPath.js +12 -22
- package/dist/fileCreators/idb-utils/logicalFilters/removeDuplicatesByKeyPath.js.map +1 -1
- package/dist/fileCreators/idb-utils/syncWorker/create.js +7 -0
- package/dist/fileCreators/idb-utils/syncWorker/create.js.map +1 -0
- package/dist/fileCreators/idb-utils/updateHandlers/BigIntHandler.js +40 -53
- package/dist/fileCreators/idb-utils/updateHandlers/BigIntHandler.js.map +1 -1
- package/dist/fileCreators/idb-utils/updateHandlers/BooleanHandler.js +13 -26
- package/dist/fileCreators/idb-utils/updateHandlers/BooleanHandler.js.map +1 -1
- package/dist/fileCreators/idb-utils/updateHandlers/BytesHandler.js +13 -26
- package/dist/fileCreators/idb-utils/updateHandlers/BytesHandler.js.map +1 -1
- package/dist/fileCreators/idb-utils/updateHandlers/DateTimeHandler.js +23 -32
- package/dist/fileCreators/idb-utils/updateHandlers/DateTimeHandler.js.map +1 -1
- package/dist/fileCreators/idb-utils/updateHandlers/EnumHandler.js +13 -26
- package/dist/fileCreators/idb-utils/updateHandlers/EnumHandler.js.map +1 -1
- package/dist/fileCreators/idb-utils/updateHandlers/FloatHandler.js +30 -43
- package/dist/fileCreators/idb-utils/updateHandlers/FloatHandler.js.map +1 -1
- package/dist/fileCreators/idb-utils/updateHandlers/IntHandler.js +30 -43
- package/dist/fileCreators/idb-utils/updateHandlers/IntHandler.js.map +1 -1
- package/dist/fileCreators/idb-utils/updateHandlers/ScalarListHandler.js +21 -32
- package/dist/fileCreators/idb-utils/updateHandlers/ScalarListHandler.js.map +1 -1
- package/dist/fileCreators/idb-utils/updateHandlers/StringHandler.js +13 -26
- package/dist/fileCreators/idb-utils/updateHandlers/StringHandler.js.map +1 -1
- package/dist/fileCreators/outbox/utils.js +17 -0
- package/dist/fileCreators/outbox/utils.js.map +1 -0
- package/dist/fileCreators/prisma-idb-client/classes/BaseIDBModelClass.js +36 -11
- package/dist/fileCreators/prisma-idb-client/classes/BaseIDBModelClass.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/OutboxEventIDBClass.js +153 -0
- package/dist/fileCreators/prisma-idb-client/classes/OutboxEventIDBClass.js.map +1 -0
- package/dist/fileCreators/prisma-idb-client/classes/PrismaIDBClient.js +169 -4
- package/dist/fileCreators/prisma-idb-client/classes/PrismaIDBClient.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/IDBModelClass.js +9 -0
- package/dist/fileCreators/prisma-idb-client/classes/models/IDBModelClass.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/aggregate.js +3 -4
- package/dist/fileCreators/prisma-idb-client/classes/models/api/aggregate.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/create.js +12 -11
- package/dist/fileCreators/prisma-idb-client/classes/models/api/create.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/createMany.js +2 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/createMany.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/createManyAndReturn.js +2 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/createManyAndReturn.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/delete.js +2 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/delete.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/deleteMany.js +3 -2
- package/dist/fileCreators/prisma-idb-client/classes/models/api/deleteMany.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/update.js +2 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/update.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/updateMany.js +3 -2
- package/dist/fileCreators/prisma-idb-client/classes/models/api/updateMany.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/classes/models/api/upsert.js +3 -2
- package/dist/fileCreators/prisma-idb-client/classes/models/api/upsert.js.map +1 -1
- package/dist/fileCreators/prisma-idb-client/create.js +19 -8
- package/dist/fileCreators/prisma-idb-client/create.js.map +1 -1
- package/dist/fileCreators/validators/create.js +35 -0
- package/dist/fileCreators/validators/create.js.map +1 -0
- package/dist/generator.js +25 -12
- package/dist/generator.js.map +1 -1
- package/dist/helpers/fileWriting.js +0 -8
- package/dist/helpers/fileWriting.js.map +1 -1
- package/dist/helpers/parseGeneratorConfig.js +103 -0
- package/dist/helpers/parseGeneratorConfig.js.map +1 -0
- package/dist/helpers/utils.js +21 -11
- package/dist/helpers/utils.js.map +1 -1
- package/package.json +22 -22
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addIntersectArraysByNestedKeyFunction = addIntersectArraysByNestedKeyFunction;
|
|
4
|
-
function addIntersectArraysByNestedKeyFunction(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
],
|
|
13
|
-
returnType: "T[]",
|
|
14
|
-
statements: (writer) => {
|
|
15
|
-
writer
|
|
16
|
-
.writeLine(`return arrays.reduce((acc, array) =>`)
|
|
17
|
-
.writeLine(`acc.filter((item) => array.some((el) => keyPath.every((key) => el[key as keyof T] === item[key as keyof T]))),`)
|
|
18
|
-
.writeLine(`);`);
|
|
19
|
-
},
|
|
4
|
+
function addIntersectArraysByNestedKeyFunction(writer) {
|
|
5
|
+
writer.writeLine(`export function intersectArraysByNestedKey<T>(arrays: T[][], keyPath: string[]): T[]`).block(() => {
|
|
6
|
+
writer
|
|
7
|
+
.writeLine(`const safeArrays = arrays ?? [];`)
|
|
8
|
+
.writeLine(`if (safeArrays.length === 0) return [];`)
|
|
9
|
+
.writeLine(`return safeArrays.reduce((acc, array) =>`)
|
|
10
|
+
.writeLine(`acc.filter((item) => array.some((el) => keyPath.every((key) => el[key as keyof T] === item[key as keyof T]))),`)
|
|
11
|
+
.writeLine(`safeArrays[0] ?? []);`);
|
|
20
12
|
});
|
|
21
13
|
}
|
|
22
14
|
//# sourceMappingURL=intersectArraysByNestedKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersectArraysByNestedKey.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/logicalFilters/intersectArraysByNestedKey.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"intersectArraysByNestedKey.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/logicalFilters/intersectArraysByNestedKey.ts"],"names":[],"mappings":";;AAEA,sFAWC;AAXD,SAAgB,qCAAqC,CAAC,MAAuB;IAC3E,MAAM,CAAC,SAAS,CAAC,sFAAsF,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;QAClH,MAAM;aACH,SAAS,CAAC,kCAAkC,CAAC;aAC7C,SAAS,CAAC,yCAAyC,CAAC;aACpD,SAAS,CAAC,0CAA0C,CAAC;aACrD,SAAS,CACR,gHAAgH,CACjH;aACA,SAAS,CAAC,uBAAuB,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addRemoveDuplicatesByKeyPath = addRemoveDuplicatesByKeyPath;
|
|
4
|
-
function addRemoveDuplicatesByKeyPath(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.writeLine(`const seen = new Set<string>();`)
|
|
17
|
-
.writeLine(`return arrays`)
|
|
18
|
-
.writeLine(`.flatMap((el) => el)`)
|
|
19
|
-
.writeLine(`.filter((item) => {`)
|
|
20
|
-
.writeLine(`const key = JSON.stringify(keyPath.map((key) => item[key as keyof T]));`)
|
|
21
|
-
.writeLine(`if (seen.has(key)) return false;`)
|
|
22
|
-
.writeLine(`seen.add(key);`)
|
|
23
|
-
.writeLine(`return true;`)
|
|
24
|
-
.writeLine(`});`);
|
|
25
|
-
},
|
|
4
|
+
function addRemoveDuplicatesByKeyPath(writer) {
|
|
5
|
+
writer.writeLine(`export function removeDuplicatesByKeyPath<T>(arrays: T[][], keyPath: string[]): T[]`).block(() => {
|
|
6
|
+
writer
|
|
7
|
+
.writeLine(`const seen = new Set<string>();`)
|
|
8
|
+
.writeLine(`return arrays`)
|
|
9
|
+
.writeLine(`.flatMap((el) => el)`)
|
|
10
|
+
.writeLine(`.filter((item) => {`)
|
|
11
|
+
.writeLine(`const key = JSON.stringify(keyPath.map((key) => item[key as keyof T]));`)
|
|
12
|
+
.writeLine(`if (seen.has(key)) return false;`)
|
|
13
|
+
.writeLine(`seen.add(key);`)
|
|
14
|
+
.writeLine(`return true;`)
|
|
15
|
+
.writeLine(`});`);
|
|
26
16
|
});
|
|
27
17
|
}
|
|
28
18
|
//# sourceMappingURL=removeDuplicatesByKeyPath.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeDuplicatesByKeyPath.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/logicalFilters/removeDuplicatesByKeyPath.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"removeDuplicatesByKeyPath.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/logicalFilters/removeDuplicatesByKeyPath.ts"],"names":[],"mappings":";;AAEA,oEAaC;AAbD,SAAgB,4BAA4B,CAAC,MAAuB;IAClE,MAAM,CAAC,SAAS,CAAC,qFAAqF,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;QACjH,MAAM;aACH,SAAS,CAAC,iCAAiC,CAAC;aAC5C,SAAS,CAAC,eAAe,CAAC;aAC1B,SAAS,CAAC,sBAAsB,CAAC;aACjC,SAAS,CAAC,qBAAqB,CAAC;aAChC,SAAS,CAAC,yEAAyE,CAAC;aACpF,SAAS,CAAC,kCAAkC,CAAC;aAC7C,SAAS,CAAC,gBAAgB,CAAC;aAC3B,SAAS,CAAC,cAAc,CAAC;aACzB,SAAS,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addSyncWorkerCode = addSyncWorkerCode;
|
|
4
|
+
function addSyncWorkerCode(writer) {
|
|
5
|
+
writer.writeLine(`export type { AppliedResult, SyncWorkerOptions, SyncWorker } from "./idb-interface";`);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/syncWorker/create.ts"],"names":[],"mappings":";;AAMA,8CAGC;AAHD,SAAgB,iBAAiB,CAAC,MAAuB;IAEvD,MAAM,CAAC,SAAS,CAAC,sFAAsF,CAAC,CAAC;AAC3G,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addBigIntUpdateHandler = addBigIntUpdateHandler;
|
|
4
|
-
function addBigIntUpdateHandler(
|
|
4
|
+
function addBigIntUpdateHandler(writer, models) {
|
|
5
5
|
const bigIntFields = models.flatMap(({ fields }) => fields).filter((field) => field.type === "BigInt");
|
|
6
6
|
if (bigIntFields.length === 0)
|
|
7
7
|
return;
|
|
@@ -16,58 +16,45 @@ function addBigIntUpdateHandler(utilsFile, models) {
|
|
|
16
16
|
updateOperationType += " | null | Prisma.NullableBigIntFieldUpdateOperationsInput";
|
|
17
17
|
fieldType += " | null";
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.writeLine(`)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.writeLine(`else if (bigIntUpdate.decrement !== undefined && record[fieldName] !== null)`)
|
|
59
|
-
.block(() => {
|
|
60
|
-
writer.writeLine(`(record[fieldName] as bigint) -= BigInt(bigIntUpdate.decrement);`);
|
|
61
|
-
})
|
|
62
|
-
.writeLine(`else if (bigIntUpdate.multiply !== undefined && record[fieldName] !== null)`)
|
|
63
|
-
.block(() => {
|
|
64
|
-
writer.writeLine(`(record[fieldName] as bigint) *= BigInt(bigIntUpdate.multiply);`);
|
|
65
|
-
})
|
|
66
|
-
.writeLine(`else if (bigIntUpdate.divide !== undefined && record[fieldName] !== null)`)
|
|
67
|
-
.block(() => {
|
|
68
|
-
writer.writeLine(`(record[fieldName] as bigint) /= BigInt(bigIntUpdate.divide);`);
|
|
69
|
-
});
|
|
70
|
-
},
|
|
19
|
+
writer
|
|
20
|
+
.writeLine(`export function handleBigIntUpdateField<T, R extends Prisma.Result<T, object, "findFirstOrThrow">>(record: R, fieldName: keyof R, bigIntUpdate: ${updateOperationType}): void`)
|
|
21
|
+
.block(() => {
|
|
22
|
+
writer
|
|
23
|
+
.writeLine(`if (bigIntUpdate === undefined) return;`)
|
|
24
|
+
.writeLine(`if (typeof bigIntUpdate === "bigint" || typeof bigIntUpdate === "number"${nullableBigIntFieldPresent ? ` || bigIntUpdate === null` : ""})`)
|
|
25
|
+
.block(() => {
|
|
26
|
+
if (nullableBigIntFieldPresent) {
|
|
27
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = bigIntUpdate === null ? null : BigInt(bigIntUpdate);`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = BigInt(bigIntUpdate);`);
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.writeLine(`else if (bigIntUpdate.set !== undefined)`)
|
|
34
|
+
.block(() => {
|
|
35
|
+
if (nullableBigIntFieldPresent) {
|
|
36
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = bigIntUpdate.set === null ? null : BigInt(bigIntUpdate.set);`);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = BigInt(bigIntUpdate.set);`);
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
.writeLine(`else if (bigIntUpdate.increment !== undefined && record[fieldName] !== null)`)
|
|
43
|
+
.block(() => {
|
|
44
|
+
writer.writeLine(`(record[fieldName] as bigint) += BigInt(bigIntUpdate.increment);`);
|
|
45
|
+
})
|
|
46
|
+
.writeLine(`else if (bigIntUpdate.decrement !== undefined && record[fieldName] !== null)`)
|
|
47
|
+
.block(() => {
|
|
48
|
+
writer.writeLine(`(record[fieldName] as bigint) -= BigInt(bigIntUpdate.decrement);`);
|
|
49
|
+
})
|
|
50
|
+
.writeLine(`else if (bigIntUpdate.multiply !== undefined && record[fieldName] !== null)`)
|
|
51
|
+
.block(() => {
|
|
52
|
+
writer.writeLine(`(record[fieldName] as bigint) *= BigInt(bigIntUpdate.multiply);`);
|
|
53
|
+
})
|
|
54
|
+
.writeLine(`else if (bigIntUpdate.divide !== undefined && record[fieldName] !== null)`)
|
|
55
|
+
.block(() => {
|
|
56
|
+
writer.writeLine(`(record[fieldName] as bigint) /= BigInt(bigIntUpdate.divide);`);
|
|
57
|
+
});
|
|
71
58
|
});
|
|
72
59
|
}
|
|
73
60
|
//# sourceMappingURL=BigIntHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BigIntHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/BigIntHandler.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"BigIntHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/BigIntHandler.ts"],"names":[],"mappings":";;AAGA,wDAgEC;AAhED,SAAgB,sBAAsB,CAAC,MAAuB,EAAE,MAAwB;IACtF,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IACvG,IAAI,YAAY,CAAC,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A+B,CAAC,CAAC;YACtF,CAAC;QACH,CAAC,CAAC;aACD,SAAS,CAAC,8EAA8E,CAAC;aACzF,KAAK,CAAC,GAAG,EAAE;YACV,MAAM,CAAC,SAAS,CAAC,kEAAkE,CAAC,CAAC;QACvF,CAAC,CAAC;aACD,SAAS,CAAC,8EAA8E,CAAC;aACzF,KAAK,CAAC,GAAG,EAAE;YACV,MAAM,CAAC,SAAS,CAAC,kEAAkE,CAAC,CAAC;QACvF,CAAC,CAAC;aACD,SAAS,CAAC,6EAA6E,CAAC;aACxF,KAAK,CAAC,GAAG,EAAE;YACV,MAAM,CAAC,SAAS,CAAC,iEAAiE,CAAC,CAAC;QACtF,CAAC,CAAC;aACD,SAAS,CAAC,2EAA2E,CAAC;aACtF,KAAK,CAAC,GAAG,EAAE;YACV,MAAM,CAAC,SAAS,CAAC,+DAA+D,CAAC,CAAC;QACpF,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addBooleanUpdateHandler = addBooleanUpdateHandler;
|
|
4
|
-
function addBooleanUpdateHandler(
|
|
4
|
+
function addBooleanUpdateHandler(writer, models) {
|
|
5
5
|
const booleanFields = models.flatMap(({ fields }) => fields).filter((field) => field.type === "Boolean");
|
|
6
6
|
if (booleanFields.length === 0)
|
|
7
7
|
return;
|
|
@@ -16,31 +16,18 @@ function addBooleanUpdateHandler(utilsFile, models) {
|
|
|
16
16
|
updateOperationType += " | null | Prisma.NullableBoolFieldUpdateOperationsInput";
|
|
17
17
|
fieldType += " | null";
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
statements: (writer) => {
|
|
32
|
-
writer
|
|
33
|
-
.writeLine(`if (booleanUpdate === undefined) return;`)
|
|
34
|
-
.write(`if (typeof booleanUpdate === "boolean"`)
|
|
35
|
-
.conditionalWrite(nullableBooleanFieldPresent, ` || booleanUpdate === null`)
|
|
36
|
-
.writeLine(`)`)
|
|
37
|
-
.block(() => {
|
|
38
|
-
writer.writeLine(`(record[fieldName] as ${fieldType}) = booleanUpdate;`);
|
|
39
|
-
});
|
|
40
|
-
writer.writeLine(`else if (booleanUpdate.set !== undefined)`).block(() => {
|
|
41
|
-
writer.writeLine(`(record[fieldName] as ${fieldType}) = booleanUpdate.set;`);
|
|
42
|
-
});
|
|
43
|
-
},
|
|
19
|
+
writer
|
|
20
|
+
.writeLine(`export function handleBooleanUpdateField<T, R extends Prisma.Result<T, object, "findFirstOrThrow">>(record: R, fieldName: keyof R, booleanUpdate: ${updateOperationType}): void`)
|
|
21
|
+
.block(() => {
|
|
22
|
+
writer
|
|
23
|
+
.writeLine(`if (booleanUpdate === undefined) return;`)
|
|
24
|
+
.writeLine(`if (typeof booleanUpdate === "boolean"${nullableBooleanFieldPresent ? ` || booleanUpdate === null` : ""})`)
|
|
25
|
+
.block(() => {
|
|
26
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = booleanUpdate;`);
|
|
27
|
+
});
|
|
28
|
+
writer.writeLine(`else if (booleanUpdate.set !== undefined)`).block(() => {
|
|
29
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = booleanUpdate.set;`);
|
|
30
|
+
});
|
|
44
31
|
});
|
|
45
32
|
}
|
|
46
33
|
//# sourceMappingURL=BooleanHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/BooleanHandler.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"BooleanHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/B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CAAC,GAAG,EAAE;YACvE,MAAM,CAAC,SAAS,CAAC,yBAAyB,SAAS,wBAAwB,CAAC,CAAC;QAC/E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addBytesUpdateHandler = addBytesUpdateHandler;
|
|
4
|
-
function addBytesUpdateHandler(
|
|
4
|
+
function addBytesUpdateHandler(writer, models) {
|
|
5
5
|
const bytesFields = models.flatMap(({ fields }) => fields).filter((field) => field.type === "Bytes");
|
|
6
6
|
if (bytesFields.length === 0)
|
|
7
7
|
return;
|
|
@@ -16,31 +16,18 @@ function addBytesUpdateHandler(utilsFile, models) {
|
|
|
16
16
|
updateOperationType += " | null | Prisma.NullableBytesFieldUpdateOperationsInput";
|
|
17
17
|
fieldType += " | null";
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
statements: (writer) => {
|
|
32
|
-
writer
|
|
33
|
-
.writeLine(`if (bytesUpdate === undefined) return;`)
|
|
34
|
-
.write(`if (bytesUpdate instanceof Uint8Array`)
|
|
35
|
-
.conditionalWrite(nullableBytesFieldPresent, ` || bytesUpdate === null`)
|
|
36
|
-
.writeLine(`)`)
|
|
37
|
-
.block(() => {
|
|
38
|
-
writer.writeLine(`(record[fieldName] as ${fieldType}) = bytesUpdate;`);
|
|
39
|
-
});
|
|
40
|
-
writer.writeLine(`else if (bytesUpdate.set !== undefined)`).block(() => {
|
|
41
|
-
writer.writeLine(`(record[fieldName] as ${fieldType}) = bytesUpdate.set;`);
|
|
42
|
-
});
|
|
43
|
-
},
|
|
19
|
+
writer
|
|
20
|
+
.writeLine(`export function handleBytesUpdateField<T, R extends Prisma.Result<T, object, "findFirstOrThrow">>(record: R, fieldName: keyof R, bytesUpdate: ${updateOperationType}): void`)
|
|
21
|
+
.block(() => {
|
|
22
|
+
writer
|
|
23
|
+
.writeLine(`if (bytesUpdate === undefined) return;`)
|
|
24
|
+
.writeLine(`if (bytesUpdate instanceof Uint8Array${nullableBytesFieldPresent ? ` || bytesUpdate === null` : ""})`)
|
|
25
|
+
.block(() => {
|
|
26
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = bytesUpdate;`);
|
|
27
|
+
});
|
|
28
|
+
writer.writeLine(`else if (bytesUpdate.set !== undefined)`).block(() => {
|
|
29
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = bytesUpdate.set;`);
|
|
30
|
+
});
|
|
44
31
|
});
|
|
45
32
|
}
|
|
46
33
|
//# sourceMappingURL=BytesHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BytesHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/BytesHandler.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"BytesHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/BytesHandler.ts"],"names":[],"mappings":";;AAGA,sDAmCC;AAnCD,SAAgB,qBAAqB,CAAC,MAAuB,EAAE,MAAwB;IACrF,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;IACrG,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAErC,IAAI,mBAAmB,GAAG,wBAAwB,CAAC;IACnD,IAAI,SAAS,GAAG,YAAY,CAAC;IAE7B,MAAM,4BAA4B,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;IACtF,MAAM,yBAAyB,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAEpF,IAAI,4BAA4B,EAAE,CAAC;QACjC,mBAAmB,IAAI,2CAA2C,CAAC;IACrE,CAAC;IACD,IAAI,yBAAyB,EAAE,CAAC;QAC9B,mBAAmB,IAAI,0DAA0D,CAAC;QAClF,SAAS,IAAI,SAAS,CAAC;IACzB,CAAC;IAED,MAAM;SACH,SAAS,CACR,iJAAiJ,mBAAmB,SAAS,CAC9K;SACA,KAAK,CAAC,GAAG,EAAE;QACV,MAAM;aACH,SAAS,CAAC,wCAAwC,CAAC;aACnD,SAAS,CACR,wCAAwC,yBAAyB,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,GAAG,CACvG;aACA,KAAK,CAAC,GAAG,EAAE;YACV,MAAM,CAAC,SAAS,CAAC,yBAAyB,SAAS,kBAAkB,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;QACL,MAAM,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACrE,MAAM,CAAC,SAAS,CAAC,yBAAyB,SAAS,sBAAsB,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addDateTimeUpdateHandler = addDateTimeUpdateHandler;
|
|
4
|
-
function addDateTimeUpdateHandler(
|
|
4
|
+
function addDateTimeUpdateHandler(writer, models) {
|
|
5
5
|
const dateTimeFields = models.flatMap(({ fields }) => fields).filter((field) => field.type === "DateTime");
|
|
6
6
|
if (dateTimeFields.length === 0)
|
|
7
7
|
return;
|
|
@@ -16,37 +16,28 @@ function addDateTimeUpdateHandler(utilsFile, models) {
|
|
|
16
16
|
updateOperationType += " | null | Prisma.NullableDateTimeFieldUpdateOperationsInput";
|
|
17
17
|
fieldType += " | null";
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
writer
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.write(`new Date(dateTimeUpdate);`);
|
|
42
|
-
});
|
|
43
|
-
writer.writeLine(`else if (dateTimeUpdate.set !== undefined)`).block(() => {
|
|
44
|
-
writer
|
|
45
|
-
.writeLine(`(record[fieldName] as ${fieldType}) = `)
|
|
46
|
-
.conditionalWrite(nullableDateTimeFieldPresent, () => `dateTimeUpdate.set === null ? null : `)
|
|
47
|
-
.write(`new Date(dateTimeUpdate.set);`);
|
|
48
|
-
});
|
|
49
|
-
},
|
|
19
|
+
writer
|
|
20
|
+
.writeLine(`export function handleDateTimeUpdateField<T, R extends Prisma.Result<T, object, "findFirstOrThrow">>(record: R, fieldName: keyof R, dateTimeUpdate: ${updateOperationType}): void`)
|
|
21
|
+
.block(() => {
|
|
22
|
+
writer
|
|
23
|
+
.writeLine(`if (dateTimeUpdate === undefined) return;`)
|
|
24
|
+
.writeLine(`if (typeof dateTimeUpdate === "string" || dateTimeUpdate instanceof Date${nullableDateTimeFieldPresent ? ` || dateTimeUpdate === null` : ""})`)
|
|
25
|
+
.block(() => {
|
|
26
|
+
if (nullableDateTimeFieldPresent) {
|
|
27
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = dateTimeUpdate === null ? null : new Date(dateTimeUpdate);`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = new Date(dateTimeUpdate);`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
writer.writeLine(`else if (dateTimeUpdate.set !== undefined)`).block(() => {
|
|
34
|
+
if (nullableDateTimeFieldPresent) {
|
|
35
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = dateTimeUpdate.set === null ? null : new Date(dateTimeUpdate.set);`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = new Date(dateTimeUpdate.set);`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
50
41
|
});
|
|
51
42
|
}
|
|
52
43
|
//# sourceMappingURL=DateTimeHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/DateTimeHandler.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"DateTimeHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/DateTimeHandler.ts"],"names":[],"mappings":";;AAGA,4DA+CC;AA/CD,SAAgB,wBAAwB,CAAC,MAAuB,EAAE,MAAwB;IACxF,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IAC3G,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAExC,IAAI,mBAAmB,GAAG,2BAA2B,CAAC;IACtD,IAAI,SAAS,GAAG,MAAM,CAAC;IAEvB,MAAM,+BAA+B,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;IAC5F,MAAM,4BAA4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|
4
|
-
function addEnumUpdateHandler(
|
|
4
|
+
function addEnumUpdateHandler(writer, models) {
|
|
5
5
|
const enumFields = models.flatMap(({ fields }) => fields).filter((field) => field.kind === "enum" && !field.isList);
|
|
6
6
|
if (enumFields.length === 0)
|
|
7
7
|
return;
|
|
@@ -16,31 +16,18 @@ function addEnumUpdateHandler(utilsFile, models) {
|
|
|
16
16
|
updateOperationType += " | null | { set?: string | null }";
|
|
17
17
|
fieldType += " | null";
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
statements: (writer) => {
|
|
32
|
-
writer
|
|
33
|
-
.writeLine(`if (enumUpdate === undefined) return;`)
|
|
34
|
-
.write(`if (typeof enumUpdate === "string"`)
|
|
35
|
-
.conditionalWrite(nullableEnumFieldPresent, ` || enumUpdate === null`)
|
|
36
|
-
.writeLine(`)`)
|
|
37
|
-
.block(() => {
|
|
38
|
-
writer.writeLine(`(record[fieldName] as ${fieldType}) = enumUpdate;`);
|
|
39
|
-
});
|
|
40
|
-
writer.writeLine(`else if (enumUpdate.set !== undefined)`).block(() => {
|
|
41
|
-
writer.writeLine(`(record[fieldName] as ${fieldType}) = enumUpdate.set;`);
|
|
42
|
-
});
|
|
43
|
-
},
|
|
19
|
+
writer
|
|
20
|
+
.writeLine(`export function handleEnumUpdateField<T, R extends Prisma.Result<T, object, "findFirstOrThrow">>(record: R, fieldName: keyof R, enumUpdate: ${updateOperationType}): void`)
|
|
21
|
+
.block(() => {
|
|
22
|
+
writer
|
|
23
|
+
.writeLine(`if (enumUpdate === undefined) return;`)
|
|
24
|
+
.writeLine(`if (typeof enumUpdate === "string"${nullableEnumFieldPresent ? ` || enumUpdate === null` : ""})`)
|
|
25
|
+
.block(() => {
|
|
26
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = enumUpdate;`);
|
|
27
|
+
});
|
|
28
|
+
writer.writeLine(`else if (enumUpdate.set !== undefined)`).block(() => {
|
|
29
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = enumUpdate.set;`);
|
|
30
|
+
});
|
|
44
31
|
});
|
|
45
32
|
}
|
|
46
33
|
//# sourceMappingURL=EnumHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/EnumHandler.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"EnumHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/EnumHandler.ts"],"names":[],"mappings":";;AAGA,oDAiCC;AAjCD,SAAgB,oBAAoB,CAAC,MAAuB,EAAE,MAAwB;IACpF,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpH,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEpC,IAAI,mBAAmB,GAAG,oBAAoB,CAAC;IAC/C,IAAI,SAAS,GAAG,QAAQ,CAAC;IAEzB,MAAM,2BAA2B,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;IACpF,MAAM,wBAAwB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAElF,IAAI,2BAA2B,EAAE,CAAC;QAChC,mBAAmB,IAAI,qBAAqB,CAAC;IAC/C,CAAC;IACD,IAAI,wBAAwB,EAAE,CAAC;QAC7B,mBAAmB,IAAI,mCAAmC,CAAC;QAC3D,SAAS,IAAI,SAAS,CAAC;IACzB,CAAC;IAED,MAAM;SACH,SAAS,CACR,+IAA+I,mBAAmB,SAAS,CAC5K;SACA,KAAK,CAAC,GAAG,EAAE;QACV,MAAM;aACH,SAAS,CAAC,uCAAuC,CAAC;aAClD,SAAS,CAAC,qCAAqC,wBAAwB,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;aAC5G,KAAK,CAAC,GAAG,EAAE;YACV,MAAM,CAAC,SAAS,CAAC,yBAAyB,SAAS,iBAAiB,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;QACL,MAAM,CAAC,SAAS,CAAC,wCAAwC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACpE,MAAM,CAAC,SAAS,CAAC,yBAAyB,SAAS,qBAAqB,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addFloatUpdateHandler = addFloatUpdateHandler;
|
|
4
|
-
function addFloatUpdateHandler(
|
|
4
|
+
function addFloatUpdateHandler(writer, models) {
|
|
5
5
|
const floatFields = models.flatMap(({ fields }) => fields).filter((field) => field.type === "Float");
|
|
6
6
|
if (floatFields.length === 0)
|
|
7
7
|
return;
|
|
@@ -16,48 +16,35 @@ function addFloatUpdateHandler(utilsFile, models) {
|
|
|
16
16
|
updateOperationType += " | null | Prisma.NullableFloatFieldUpdateOperationsInput";
|
|
17
17
|
fieldType += " | null";
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.writeLine(`else if (floatUpdate.decrement !== undefined && record[fieldName] !== null)`)
|
|
49
|
-
.block(() => {
|
|
50
|
-
writer.writeLine(`(record[fieldName] as number) -= floatUpdate.decrement;`);
|
|
51
|
-
})
|
|
52
|
-
.writeLine(`else if (floatUpdate.multiply !== undefined && record[fieldName] !== null)`)
|
|
53
|
-
.block(() => {
|
|
54
|
-
writer.writeLine(`(record[fieldName] as number) *= floatUpdate.multiply;`);
|
|
55
|
-
})
|
|
56
|
-
.writeLine(`else if (floatUpdate.divide !== undefined && record[fieldName] !== null)`)
|
|
57
|
-
.block(() => {
|
|
58
|
-
writer.writeLine(`(record[fieldName] as number) /= floatUpdate.divide;`);
|
|
59
|
-
});
|
|
60
|
-
},
|
|
19
|
+
writer
|
|
20
|
+
.writeLine(`export function handleFloatUpdateField<T, R extends Prisma.Result<T, object, "findFirstOrThrow">>(record: R, fieldName: keyof R, floatUpdate: ${updateOperationType}): void`)
|
|
21
|
+
.block(() => {
|
|
22
|
+
writer
|
|
23
|
+
.writeLine(`if (floatUpdate === undefined) return;`)
|
|
24
|
+
.writeLine(`if (typeof floatUpdate === "number"${nullableFloatFieldPresent ? ` || floatUpdate === null` : ""})`)
|
|
25
|
+
.block(() => {
|
|
26
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = floatUpdate;`);
|
|
27
|
+
})
|
|
28
|
+
.writeLine(`else if (floatUpdate.set !== undefined)`)
|
|
29
|
+
.block(() => {
|
|
30
|
+
writer.writeLine(`(record[fieldName] as ${fieldType}) = floatUpdate.set;`);
|
|
31
|
+
})
|
|
32
|
+
.writeLine(`else if (floatUpdate.increment !== undefined && record[fieldName] !== null)`)
|
|
33
|
+
.block(() => {
|
|
34
|
+
writer.writeLine(`(record[fieldName] as number) += floatUpdate.increment;`);
|
|
35
|
+
})
|
|
36
|
+
.writeLine(`else if (floatUpdate.decrement !== undefined && record[fieldName] !== null)`)
|
|
37
|
+
.block(() => {
|
|
38
|
+
writer.writeLine(`(record[fieldName] as number) -= floatUpdate.decrement;`);
|
|
39
|
+
})
|
|
40
|
+
.writeLine(`else if (floatUpdate.multiply !== undefined && record[fieldName] !== null)`)
|
|
41
|
+
.block(() => {
|
|
42
|
+
writer.writeLine(`(record[fieldName] as number) *= floatUpdate.multiply;`);
|
|
43
|
+
})
|
|
44
|
+
.writeLine(`else if (floatUpdate.divide !== undefined && record[fieldName] !== null)`)
|
|
45
|
+
.block(() => {
|
|
46
|
+
writer.writeLine(`(record[fieldName] as number) /= floatUpdate.divide;`);
|
|
47
|
+
});
|
|
61
48
|
});
|
|
62
49
|
}
|
|
63
50
|
//# sourceMappingURL=FloatHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/FloatHandler.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"FloatHandler.js","sourceRoot":"","sources":["../../../../src/fileCreators/idb-utils/updateHandlers/FloatHandler.ts"],"names":[],"mappings":";;AAGA,sDAkDC;AAlDD,SAAgB,qBAAqB,CAAC,MAAuB,EAAE,MAAwB;IACrF,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;IACrG,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAErC,IAAI,mBAAmB,GAAG,oBAAoB,CAAC;IAC/C,IAAI,SAAS,GAAG,QAAQ,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