prisma 6.4.0-dev.20 → 6.4.0-dev.22
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/build/index.js +513 -548
- package/package.json +11 -12
- package/prisma-client/generator-build/index.js +1404 -1280
- package/prisma-client/package.json +5 -5
- package/prisma-client/runtime/binary.js +64 -64
- package/prisma-client/runtime/client.js +31 -31
- package/prisma-client/runtime/edge-esm.js +15 -15
- package/prisma-client/runtime/edge.js +15 -15
- package/prisma-client/runtime/library.js +44 -44
- package/prisma-client/runtime/query_engine_bg.mysql.js +2 -2
- package/prisma-client/runtime/query_engine_bg.postgresql.js +2 -2
- package/prisma-client/runtime/query_engine_bg.sqlite.js +2 -2
- package/prisma-client/runtime/react-native.js +24 -24
- package/prisma-client/scripts/default-index.js +3 -3
|
@@ -33,18 +33,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/@prisma+engines-version@6.
|
|
36
|
+
// ../../node_modules/.pnpm/@prisma+engines-version@6.4.0-4.e2a33755136ec1c2b3a5d7d322f86a8fb1205a40/node_modules/@prisma/engines-version/package.json
|
|
37
37
|
var require_package = __commonJS({
|
|
38
|
-
"../../node_modules/.pnpm/@prisma+engines-version@6.
|
|
38
|
+
"../../node_modules/.pnpm/@prisma+engines-version@6.4.0-4.e2a33755136ec1c2b3a5d7d322f86a8fb1205a40/node_modules/@prisma/engines-version/package.json"(exports2, module2) {
|
|
39
39
|
module2.exports = {
|
|
40
40
|
name: "@prisma/engines-version",
|
|
41
|
-
version: "6.
|
|
41
|
+
version: "6.4.0-4.e2a33755136ec1c2b3a5d7d322f86a8fb1205a40",
|
|
42
42
|
main: "index.js",
|
|
43
43
|
types: "index.d.ts",
|
|
44
44
|
license: "Apache-2.0",
|
|
45
45
|
author: "Tim Suchanek <suchanek@prisma.io>",
|
|
46
46
|
prisma: {
|
|
47
|
-
enginesVersion: "
|
|
47
|
+
enginesVersion: "e2a33755136ec1c2b3a5d7d322f86a8fb1205a40"
|
|
48
48
|
},
|
|
49
49
|
repository: {
|
|
50
50
|
type: "git",
|
|
@@ -66,9 +66,9 @@ var require_package = __commonJS({
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
// ../../node_modules/.pnpm/@prisma+engines-version@6.
|
|
69
|
+
// ../../node_modules/.pnpm/@prisma+engines-version@6.4.0-4.e2a33755136ec1c2b3a5d7d322f86a8fb1205a40/node_modules/@prisma/engines-version/index.js
|
|
70
70
|
var require_engines_version = __commonJS({
|
|
71
|
-
"../../node_modules/.pnpm/@prisma+engines-version@6.
|
|
71
|
+
"../../node_modules/.pnpm/@prisma+engines-version@6.4.0-4.e2a33755136ec1c2b3a5d7d322f86a8fb1205a40/node_modules/@prisma/engines-version/index.js"(exports2) {
|
|
72
72
|
"use strict";
|
|
73
73
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
74
74
|
exports2.enginesVersion = void 0;
|
|
@@ -3946,7 +3946,7 @@ var require_package2 = __commonJS({
|
|
|
3946
3946
|
"package.json"(exports2, module2) {
|
|
3947
3947
|
module2.exports = {
|
|
3948
3948
|
name: "@prisma/client",
|
|
3949
|
-
version: "6.4.0-dev.
|
|
3949
|
+
version: "6.4.0-dev.22",
|
|
3950
3950
|
description: "Prisma Client is an auto-generated, type-safe and modern JavaScript/TypeScript ORM for Node.js that's tailored to your data. Supports PostgreSQL, CockroachDB, MySQL, MariaDB, SQL Server, SQLite & MongoDB databases.",
|
|
3951
3951
|
keywords: [
|
|
3952
3952
|
"ORM",
|
|
@@ -4145,7 +4145,7 @@ var require_package2 = __commonJS({
|
|
|
4145
4145
|
"@prisma/debug": "workspace:*",
|
|
4146
4146
|
"@prisma/driver-adapter-utils": "workspace:*",
|
|
4147
4147
|
"@prisma/engines": "workspace:*",
|
|
4148
|
-
"@prisma/engines-version": "6.
|
|
4148
|
+
"@prisma/engines-version": "6.4.0-4.e2a33755136ec1c2b3a5d7d322f86a8fb1205a40",
|
|
4149
4149
|
"@prisma/fetch-engine": "workspace:*",
|
|
4150
4150
|
"@prisma/generator-helper": "workspace:*",
|
|
4151
4151
|
"@prisma/get-platform": "workspace:*",
|
|
@@ -4154,11 +4154,11 @@ var require_package2 = __commonJS({
|
|
|
4154
4154
|
"@prisma/migrate": "workspace:*",
|
|
4155
4155
|
"@prisma/mini-proxy": "0.9.5",
|
|
4156
4156
|
"@prisma/pg-worker": "workspace:*",
|
|
4157
|
-
"@prisma/query-compiler-wasm": "6.
|
|
4158
|
-
"@prisma/query-engine-wasm": "6.
|
|
4157
|
+
"@prisma/query-compiler-wasm": "6.4.0-4.e2a33755136ec1c2b3a5d7d322f86a8fb1205a40",
|
|
4158
|
+
"@prisma/query-engine-wasm": "6.4.0-4.e2a33755136ec1c2b3a5d7d322f86a8fb1205a40",
|
|
4159
4159
|
"@snaplet/copycat": "0.17.3",
|
|
4160
4160
|
"@swc-node/register": "1.10.9",
|
|
4161
|
-
"@swc/core": "1.10.
|
|
4161
|
+
"@swc/core": "1.10.11",
|
|
4162
4162
|
"@swc/jest": "0.2.37",
|
|
4163
4163
|
"@timsuchanek/copy": "1.4.5",
|
|
4164
4164
|
"@types/debug": "4.1.12",
|
|
@@ -5016,7 +5016,7 @@ var Debug = new Proxy(debugCreate, {
|
|
|
5016
5016
|
get: (_, prop) => topProps[prop],
|
|
5017
5017
|
set: (_, prop, value) => topProps[prop] = value
|
|
5018
5018
|
});
|
|
5019
|
-
function safeStringify(value,
|
|
5019
|
+
function safeStringify(value, indent8 = 2) {
|
|
5020
5020
|
const cache = /* @__PURE__ */ new Set();
|
|
5021
5021
|
return JSON.stringify(
|
|
5022
5022
|
value,
|
|
@@ -5031,7 +5031,7 @@ function safeStringify(value, indent9 = 2) {
|
|
|
5031
5031
|
}
|
|
5032
5032
|
return value2;
|
|
5033
5033
|
},
|
|
5034
|
-
|
|
5034
|
+
indent8
|
|
5035
5035
|
);
|
|
5036
5036
|
}
|
|
5037
5037
|
var src_default = Debug;
|
|
@@ -5696,9 +5696,9 @@ function docCommentTag(strings, args) {
|
|
|
5696
5696
|
if (lines.length === 0) {
|
|
5697
5697
|
return docComment2;
|
|
5698
5698
|
}
|
|
5699
|
-
const
|
|
5699
|
+
const indent8 = getIndent(lines[0]);
|
|
5700
5700
|
for (const line of lines) {
|
|
5701
|
-
docComment2.addText(line.slice(
|
|
5701
|
+
docComment2.addText(line.slice(indent8));
|
|
5702
5702
|
}
|
|
5703
5703
|
return docComment2;
|
|
5704
5704
|
}
|
|
@@ -5724,11 +5724,11 @@ function isEmptyLine(line) {
|
|
|
5724
5724
|
return line.trim().length === 0;
|
|
5725
5725
|
}
|
|
5726
5726
|
function getIndent(line) {
|
|
5727
|
-
let
|
|
5728
|
-
while (line[
|
|
5729
|
-
|
|
5727
|
+
let indent8 = 0;
|
|
5728
|
+
while (line[indent8] === " ") {
|
|
5729
|
+
indent8++;
|
|
5730
5730
|
}
|
|
5731
|
-
return
|
|
5731
|
+
return indent8;
|
|
5732
5732
|
}
|
|
5733
5733
|
|
|
5734
5734
|
// src/generation/ts-builders/Export.ts
|
|
@@ -6786,6 +6786,8 @@ function buildSingleFieldType(t, genericsInfo, source) {
|
|
|
6786
6786
|
return union.mapVariants((variant) => array(variant));
|
|
6787
6787
|
}
|
|
6788
6788
|
return union;
|
|
6789
|
+
} else if (t.namespace === "prisma") {
|
|
6790
|
+
type = namedInputType(`Prisma.${t.type}`);
|
|
6789
6791
|
} else {
|
|
6790
6792
|
type = namedInputType(scalarType ?? t.type);
|
|
6791
6793
|
}
|
|
@@ -6818,7 +6820,7 @@ function buildAllFieldTypes(inputTypes, context, source) {
|
|
|
6818
6820
|
return unionType(xorTypes(tsInputObjectTypes)).addVariants(tsOtherTypes);
|
|
6819
6821
|
}
|
|
6820
6822
|
function xorTypes(types) {
|
|
6821
|
-
return types.reduce((prev, curr) => namedType("XOR").addGenericArgument(prev).addGenericArgument(curr));
|
|
6823
|
+
return types.reduce((prev, curr) => namedType("Prisma.XOR").addGenericArgument(prev).addGenericArgument(curr));
|
|
6822
6824
|
}
|
|
6823
6825
|
var InputType = class {
|
|
6824
6826
|
constructor(type, context) {
|
|
@@ -7420,8 +7422,14 @@ var ArgsTypeBuilder = class {
|
|
|
7420
7422
|
this.addProperty(
|
|
7421
7423
|
property(
|
|
7422
7424
|
"select",
|
|
7423
|
-
unionType([
|
|
7424
|
-
|
|
7425
|
+
unionType([
|
|
7426
|
+
namedType(`Prisma.${selectTypeName}`).addGenericArgument(extArgsParam.toArgument()),
|
|
7427
|
+
nullType
|
|
7428
|
+
])
|
|
7429
|
+
).optional().setDocComment(
|
|
7430
|
+
docComment(`Select specific fields to fetch
|
|
7431
|
+
from the ${this.type.name}`)
|
|
7432
|
+
)
|
|
7425
7433
|
);
|
|
7426
7434
|
return this;
|
|
7427
7435
|
}
|
|
@@ -7433,7 +7441,10 @@ var ArgsTypeBuilder = class {
|
|
|
7433
7441
|
this.addProperty(
|
|
7434
7442
|
property(
|
|
7435
7443
|
"include",
|
|
7436
|
-
unionType([
|
|
7444
|
+
unionType([
|
|
7445
|
+
namedType(`Prisma.${includeTypeName}`).addGenericArgument(extArgsParam.toArgument()),
|
|
7446
|
+
nullType
|
|
7447
|
+
])
|
|
7437
7448
|
).optional().setDocComment(docComment("Choose, which related nodes to fetch as well"))
|
|
7438
7449
|
);
|
|
7439
7450
|
return this;
|
|
@@ -7443,7 +7454,7 @@ var ArgsTypeBuilder = class {
|
|
|
7443
7454
|
property(
|
|
7444
7455
|
"omit",
|
|
7445
7456
|
unionType([
|
|
7446
|
-
namedType(getOmitName(this.type.name)).addGenericArgument(extArgsParam.toArgument()),
|
|
7457
|
+
namedType(`Prisma.${getOmitName(this.type.name)}`).addGenericArgument(extArgsParam.toArgument()),
|
|
7447
7458
|
nullType
|
|
7448
7459
|
])
|
|
7449
7460
|
).optional().setDocComment(docComment(`Omit specific fields from the ${this.type.name}`))
|
|
@@ -7486,7 +7497,7 @@ ${this.stringifyFields()}
|
|
|
7486
7497
|
return this.outputType.fields.filter((field) => field.outputType.location !== "outputObjectTypes").map((field) => {
|
|
7487
7498
|
const fieldOutput = field.outputType;
|
|
7488
7499
|
const refTypeName = getRefAllowedTypeName(fieldOutput);
|
|
7489
|
-
return ` readonly ${field.name}: FieldRef<"${name}", ${refTypeName}>`;
|
|
7500
|
+
return ` readonly ${field.name}: Prisma.FieldRef<"${name}", ${refTypeName}>`;
|
|
7490
7501
|
}).join("\n");
|
|
7491
7502
|
}
|
|
7492
7503
|
};
|
|
@@ -7629,7 +7640,7 @@ function buildSelectOrIncludeObject(modelName, fields, context) {
|
|
|
7629
7640
|
for (const field of fields) {
|
|
7630
7641
|
const fieldType = unionType(booleanType);
|
|
7631
7642
|
if (field.outputType.location === "outputObjectTypes") {
|
|
7632
|
-
const subSelectType = namedType(getFieldArgName(field, modelName));
|
|
7643
|
+
const subSelectType = namedType(`Prisma.${getFieldArgName(field, modelName)}`);
|
|
7633
7644
|
subSelectType.addGenericArgument(extArgsParam.toArgument());
|
|
7634
7645
|
fieldType.addVariant(subSelectType);
|
|
7635
7646
|
}
|
|
@@ -7767,13 +7778,13 @@ ${stringify(buildOutputType(groupByType))}
|
|
|
7767
7778
|
|
|
7768
7779
|
type ${getGroupByPayloadName(model.name)}<T extends ${groupByArgsName}> = Prisma.PrismaPromise<
|
|
7769
7780
|
Array<
|
|
7770
|
-
PickEnumerable<${groupByType.name}, T['by']> &
|
|
7781
|
+
Prisma.PickEnumerable<${groupByType.name}, T['by']> &
|
|
7771
7782
|
{
|
|
7772
7783
|
[P in ((keyof T) & (keyof ${groupByType.name}))]: P extends '_count'
|
|
7773
7784
|
? T[P] extends boolean
|
|
7774
7785
|
? number
|
|
7775
|
-
: GetScalarType<T[P], ${groupByType.name}[P]>
|
|
7776
|
-
: GetScalarType<T[P], ${groupByType.name}[P]>
|
|
7786
|
+
: Prisma.GetScalarType<T[P], ${groupByType.name}[P]>
|
|
7787
|
+
: Prisma.GetScalarType<T[P], ${groupByType.name}[P]>
|
|
7777
7788
|
}
|
|
7778
7789
|
>
|
|
7779
7790
|
>
|
|
@@ -7865,10 +7876,13 @@ export type ${getAggregateGetName(model.name)}<T extends ${getAggregateArgsName(
|
|
|
7865
7876
|
[P in keyof T & keyof ${aggregateName}]: P extends '_count' | 'count'
|
|
7866
7877
|
? T[P] extends true
|
|
7867
7878
|
? number
|
|
7868
|
-
: GetScalarType<T[P], ${aggregateName}[P]>
|
|
7869
|
-
: GetScalarType<T[P], ${aggregateName}[P]>
|
|
7879
|
+
: Prisma.GetScalarType<T[P], ${aggregateName}[P]>
|
|
7880
|
+
: Prisma.GetScalarType<T[P], ${aggregateName}[P]>
|
|
7870
7881
|
}`;
|
|
7871
7882
|
}
|
|
7883
|
+
fileName() {
|
|
7884
|
+
return `${this.model.name}.d.ts`;
|
|
7885
|
+
}
|
|
7872
7886
|
toTSWithoutNamespace() {
|
|
7873
7887
|
const { model } = this;
|
|
7874
7888
|
const docLines = model.documentation ?? "";
|
|
@@ -8016,39 +8030,39 @@ ${nonAggregateActions.map((action) => {
|
|
|
8016
8030
|
|
|
8017
8031
|
${availableActions.includes(DMMF.ModelAction.aggregate) ? `${(0, import_indent_string3.default)(getMethodJSDoc(DMMF.ModelAction.count, mapping, modelOrType), TAB_SIZE)}
|
|
8018
8032
|
count<T extends ${countArgsName}>(
|
|
8019
|
-
args?: Subset<T, ${countArgsName}>,
|
|
8033
|
+
args?: Prisma.Subset<T, ${countArgsName}>,
|
|
8020
8034
|
): Prisma.PrismaPromise<
|
|
8021
8035
|
T extends $Utils.Record<'select', any>
|
|
8022
8036
|
? T['select'] extends true
|
|
8023
8037
|
? number
|
|
8024
|
-
: GetScalarType<T['select'], ${getCountAggregateOutputName(name)}>
|
|
8038
|
+
: Prisma.GetScalarType<T['select'], ${getCountAggregateOutputName(name)}>
|
|
8025
8039
|
: number
|
|
8026
8040
|
>
|
|
8027
8041
|
` : ""}
|
|
8028
8042
|
${availableActions.includes(DMMF.ModelAction.aggregate) ? `${(0, import_indent_string3.default)(getMethodJSDoc(DMMF.ModelAction.aggregate, mapping, modelOrType), TAB_SIZE)}
|
|
8029
|
-
aggregate<T extends ${getAggregateArgsName(name)}>(args: Subset<T, ${getAggregateArgsName(
|
|
8043
|
+
aggregate<T extends ${getAggregateArgsName(name)}>(args: Prisma.Subset<T, ${getAggregateArgsName(
|
|
8030
8044
|
name
|
|
8031
8045
|
)}>): Prisma.PrismaPromise<${getAggregateGetName(name)}<T>>
|
|
8032
8046
|
` : ""}
|
|
8033
8047
|
${availableActions.includes(DMMF.ModelAction.groupBy) ? `${(0, import_indent_string3.default)(getMethodJSDoc(DMMF.ModelAction.groupBy, mapping, modelOrType), TAB_SIZE)}
|
|
8034
8048
|
groupBy<
|
|
8035
8049
|
T extends ${groupByArgsName},
|
|
8036
|
-
HasSelectOrTake extends Or<
|
|
8037
|
-
Extends<'skip', Keys<T>>,
|
|
8038
|
-
Extends<'take', Keys<T>>
|
|
8050
|
+
HasSelectOrTake extends Prisma.Or<
|
|
8051
|
+
Prisma.Extends<'skip', Prisma.Keys<T>>,
|
|
8052
|
+
Prisma.Extends<'take', Prisma.Keys<T>>
|
|
8039
8053
|
>,
|
|
8040
|
-
OrderByArg extends True extends HasSelectOrTake
|
|
8054
|
+
OrderByArg extends Prisma.True extends HasSelectOrTake
|
|
8041
8055
|
? { orderBy: ${groupByArgsName}['orderBy'] }
|
|
8042
8056
|
: { orderBy?: ${groupByArgsName}['orderBy'] },
|
|
8043
|
-
OrderFields extends ExcludeUnderscoreKeys<Keys<MaybeTupleToUnion<T['orderBy']>>>,
|
|
8044
|
-
ByFields extends MaybeTupleToUnion<T['by']>,
|
|
8045
|
-
ByValid extends Has<ByFields, OrderFields>,
|
|
8046
|
-
HavingFields extends GetHavingFields<T['having']>,
|
|
8047
|
-
HavingValid extends Has<ByFields, HavingFields>,
|
|
8048
|
-
ByEmpty extends T['by'] extends never[] ? True : False,
|
|
8049
|
-
InputErrors extends ByEmpty extends True
|
|
8057
|
+
OrderFields extends Prisma.ExcludeUnderscoreKeys<Prisma.Keys<Prisma.MaybeTupleToUnion<T['orderBy']>>>,
|
|
8058
|
+
ByFields extends Prisma.MaybeTupleToUnion<T['by']>,
|
|
8059
|
+
ByValid extends Prisma.Has<ByFields, OrderFields>,
|
|
8060
|
+
HavingFields extends Prisma.GetHavingFields<T['having']>,
|
|
8061
|
+
HavingValid extends Prisma.Has<ByFields, HavingFields>,
|
|
8062
|
+
ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False,
|
|
8063
|
+
InputErrors extends ByEmpty extends Prisma.True
|
|
8050
8064
|
? \`Error: "by" must not be empty.\`
|
|
8051
|
-
: HavingValid extends False
|
|
8065
|
+
: HavingValid extends Prisma.False
|
|
8052
8066
|
? {
|
|
8053
8067
|
[P in HavingFields]: P extends ByFields
|
|
8054
8068
|
? never
|
|
@@ -8061,9 +8075,9 @@ ${availableActions.includes(DMMF.ModelAction.groupBy) ? `${(0, import_indent_str
|
|
|
8061
8075
|
\` in "having" needs to be provided in "by"\`,
|
|
8062
8076
|
]
|
|
8063
8077
|
}[HavingFields]
|
|
8064
|
-
: 'take' extends Keys<T>
|
|
8065
|
-
? 'orderBy' extends Keys<T>
|
|
8066
|
-
? ByValid extends True
|
|
8078
|
+
: 'take' extends Prisma.Keys<T>
|
|
8079
|
+
? 'orderBy' extends Prisma.Keys<T>
|
|
8080
|
+
? ByValid extends Prisma.True
|
|
8067
8081
|
? {}
|
|
8068
8082
|
: {
|
|
8069
8083
|
[P in OrderFields]: P extends ByFields
|
|
@@ -8071,9 +8085,9 @@ ${availableActions.includes(DMMF.ModelAction.groupBy) ? `${(0, import_indent_str
|
|
|
8071
8085
|
: \`Error: Field "\${P}" in "orderBy" needs to be provided in "by"\`
|
|
8072
8086
|
}[OrderFields]
|
|
8073
8087
|
: 'Error: If you provide "take", you also need to provide "orderBy"'
|
|
8074
|
-
: 'skip' extends Keys<T>
|
|
8075
|
-
? 'orderBy' extends Keys<T>
|
|
8076
|
-
? ByValid extends True
|
|
8088
|
+
: 'skip' extends Prisma.Keys<T>
|
|
8089
|
+
? 'orderBy' extends Prisma.Keys<T>
|
|
8090
|
+
? ByValid extends Prisma.True
|
|
8077
8091
|
? {}
|
|
8078
8092
|
: {
|
|
8079
8093
|
[P in OrderFields]: P extends ByFields
|
|
@@ -8081,14 +8095,14 @@ ${availableActions.includes(DMMF.ModelAction.groupBy) ? `${(0, import_indent_str
|
|
|
8081
8095
|
: \`Error: Field "\${P}" in "orderBy" needs to be provided in "by"\`
|
|
8082
8096
|
}[OrderFields]
|
|
8083
8097
|
: 'Error: If you provide "skip", you also need to provide "orderBy"'
|
|
8084
|
-
: ByValid extends True
|
|
8098
|
+
: ByValid extends Prisma.True
|
|
8085
8099
|
? {}
|
|
8086
8100
|
: {
|
|
8087
8101
|
[P in OrderFields]: P extends ByFields
|
|
8088
8102
|
? never
|
|
8089
8103
|
: \`Error: Field "\${P}" in "orderBy" needs to be provided in "by"\`
|
|
8090
8104
|
}[OrderFields]
|
|
8091
|
-
>(args: SubsetIntersection<T, ${groupByArgsName}, OrderByArg> & InputErrors): {} extends InputErrors ? ${getGroupByPayloadName(
|
|
8105
|
+
>(args: Prisma.SubsetIntersection<T, ${groupByArgsName}, OrderByArg> & InputErrors): {} extends InputErrors ? ${getGroupByPayloadName(
|
|
8092
8106
|
name
|
|
8093
8107
|
)}<T> : Prisma.PrismaPromise<InputErrors>` : ""}
|
|
8094
8108
|
/**
|
|
@@ -8121,9 +8135,9 @@ function getNonAggregateMethodArgs(modelName, actionName) {
|
|
|
8121
8135
|
return makeParameter(type2).optional();
|
|
8122
8136
|
}
|
|
8123
8137
|
if (actionName === DMMF.ModelAction.findRaw || actionName === DMMF.ModelAction.aggregateRaw) {
|
|
8124
|
-
return makeParameter(namedType(getModelArgName(modelName, actionName))).optional();
|
|
8138
|
+
return makeParameter(namedType(`Prisma.${getModelArgName(modelName, actionName)}`)).optional();
|
|
8125
8139
|
}
|
|
8126
|
-
const type = namedType("SelectSubset").addGenericArgument(namedType("T")).addGenericArgument(
|
|
8140
|
+
const type = namedType("Prisma.SelectSubset").addGenericArgument(namedType("T")).addGenericArgument(
|
|
8127
8141
|
namedType(getModelArgName(modelName, actionName)).addGenericArgument(extArgsParam.toArgument())
|
|
8128
8142
|
);
|
|
8129
8143
|
const param = makeParameter(type);
|
|
@@ -8155,10 +8169,10 @@ function getReturnType({
|
|
|
8155
8169
|
return promise(namedType(getAggregateGetName(modelName)).addGenericArgument(namedType("T")));
|
|
8156
8170
|
}
|
|
8157
8171
|
if (actionName === DMMF.ModelAction.findRaw || actionName === DMMF.ModelAction.aggregateRaw) {
|
|
8158
|
-
return prismaPromise(namedType("JsonObject"));
|
|
8172
|
+
return prismaPromise(namedType("Prisma.JsonObject"));
|
|
8159
8173
|
}
|
|
8160
8174
|
if (actionName === DMMF.ModelAction.deleteMany || actionName === DMMF.ModelAction.updateMany || actionName === DMMF.ModelAction.createMany) {
|
|
8161
|
-
return prismaPromise(namedType("BatchPayload"));
|
|
8175
|
+
return prismaPromise(namedType("Prisma.BatchPayload"));
|
|
8162
8176
|
}
|
|
8163
8177
|
const isList = actionName === DMMF.ModelAction.findMany || actionName === DMMF.ModelAction.createManyAndReturn || actionName === DMMF.ModelAction.updateManyAndReturn;
|
|
8164
8178
|
if (isList) {
|
|
@@ -8180,7 +8194,7 @@ function getReturnType({
|
|
|
8180
8194
|
return getFluentWrapper(modelName, getResultType(modelName, actionName));
|
|
8181
8195
|
}
|
|
8182
8196
|
function getFluentWrapper(modelName, resultType, nullType2 = neverType) {
|
|
8183
|
-
return namedType(fluentWrapperName(modelName)).addGenericArgument(resultType).addGenericArgument(nullType2).addGenericArgument(extArgsParam.toArgument()).addGenericArgument(namedType("ClientOptions"));
|
|
8197
|
+
return namedType(`Prisma.${fluentWrapperName(modelName)}`).addGenericArgument(resultType).addGenericArgument(nullType2).addGenericArgument(extArgsParam.toArgument()).addGenericArgument(namedType("ClientOptions"));
|
|
8184
8198
|
}
|
|
8185
8199
|
function getResultType(modelName, actionName) {
|
|
8186
8200
|
return namedType("$Result.GetResult").addGenericArgument(namedType(getPayloadName(modelName)).addGenericArgument(extArgsParam.toArgument())).addGenericArgument(namedType("T")).addGenericArgument(stringLiteral(actionName)).addGenericArgument(namedType("ClientOptions"));
|
|
@@ -8193,7 +8207,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
|
|
|
8193
8207
|
outputType.fields.filter(
|
|
8194
8208
|
(field) => field.outputType.location === "outputObjectTypes" && !context.dmmf.isComposite(field.outputType.type) && field.name !== "_count"
|
|
8195
8209
|
).map((field) => {
|
|
8196
|
-
const fieldArgType = namedType(getFieldArgName(field, modelName)).addGenericArgument(extArgsParam.toArgument());
|
|
8210
|
+
const fieldArgType = namedType(`Prisma.${getFieldArgName(field, modelName)}`).addGenericArgument(extArgsParam.toArgument());
|
|
8197
8211
|
const argsParam = genericParameter("T").extends(fieldArgType).default(objectType());
|
|
8198
8212
|
return method(field.name).addGenericParameter(argsParam).addParameter(parameter("args", subset(argsParam.toArgument(), fieldArgType)).optional()).setReturnType(
|
|
8199
8213
|
getReturnType({
|
|
@@ -8257,7 +8271,7 @@ function typeOrPromiseLike(type) {
|
|
|
8257
8271
|
return unionType([type, namedType("PromiseLike").addGenericArgument(type)]);
|
|
8258
8272
|
}
|
|
8259
8273
|
function subset(arg, baseType) {
|
|
8260
|
-
return namedType("Subset").addGenericArgument(arg).addGenericArgument(baseType);
|
|
8274
|
+
return namedType("Prisma.Subset").addGenericArgument(arg).addGenericArgument(baseType);
|
|
8261
8275
|
}
|
|
8262
8276
|
function fluentWrapperName(modelName) {
|
|
8263
8277
|
return `Prisma__${modelName}Client`;
|
|
@@ -8266,7 +8280,6 @@ function fluentWrapperName(modelName) {
|
|
|
8266
8280
|
// src/generation/TSClient/TSClient.ts
|
|
8267
8281
|
var import_ci_info = __toESM(require_ci_info());
|
|
8268
8282
|
var import_crypto = __toESM(require("crypto"));
|
|
8269
|
-
var import_indent_string8 = __toESM(require_indent_string());
|
|
8270
8283
|
var import_path4 = __toESM(require("path"));
|
|
8271
8284
|
|
|
8272
8285
|
// src/generation/dmmf.ts
|
|
@@ -8726,1256 +8739,1435 @@ warnEnvConflicts({
|
|
|
8726
8739
|
})`;
|
|
8727
8740
|
}
|
|
8728
8741
|
|
|
8729
|
-
// src/generation/TSClient/
|
|
8730
|
-
var
|
|
8731
|
-
var commonCodeJS = ({
|
|
8732
|
-
runtimeBase,
|
|
8733
|
-
runtimeNameJs,
|
|
8734
|
-
browser,
|
|
8735
|
-
clientVersion: clientVersion2,
|
|
8736
|
-
engineVersion,
|
|
8737
|
-
generator,
|
|
8738
|
-
deno
|
|
8739
|
-
}) => `${deno ? "const exports = {}" : ""}
|
|
8740
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8741
|
-
${deno ? `
|
|
8742
|
-
import {
|
|
8743
|
-
PrismaClientKnownRequestError,
|
|
8744
|
-
PrismaClientUnknownRequestError,
|
|
8745
|
-
PrismaClientRustPanicError,
|
|
8746
|
-
PrismaClientInitializationError,
|
|
8747
|
-
PrismaClientValidationError,
|
|
8748
|
-
getPrismaClient,
|
|
8749
|
-
sqltag,
|
|
8750
|
-
empty,
|
|
8751
|
-
join,
|
|
8752
|
-
raw,
|
|
8753
|
-
Decimal,
|
|
8754
|
-
Debug,
|
|
8755
|
-
objectEnumValues,
|
|
8756
|
-
makeStrictEnum,
|
|
8757
|
-
Extensions,
|
|
8758
|
-
defineDmmfProperty,
|
|
8759
|
-
Public,
|
|
8760
|
-
getRuntime,
|
|
8761
|
-
skip
|
|
8762
|
-
} from '${runtimeBase}/${runtimeNameJs}.js'` : browser ? `
|
|
8763
|
-
const {
|
|
8764
|
-
Decimal,
|
|
8765
|
-
objectEnumValues,
|
|
8766
|
-
makeStrictEnum,
|
|
8767
|
-
Public,
|
|
8768
|
-
getRuntime,
|
|
8769
|
-
skip
|
|
8770
|
-
} = require('${runtimeBase}/${runtimeNameJs}.js')
|
|
8771
|
-
` : `
|
|
8772
|
-
const {
|
|
8773
|
-
PrismaClientKnownRequestError,
|
|
8774
|
-
PrismaClientUnknownRequestError,
|
|
8775
|
-
PrismaClientRustPanicError,
|
|
8776
|
-
PrismaClientInitializationError,
|
|
8777
|
-
PrismaClientValidationError,
|
|
8778
|
-
getPrismaClient,
|
|
8779
|
-
sqltag,
|
|
8780
|
-
empty,
|
|
8781
|
-
join,
|
|
8782
|
-
raw,
|
|
8783
|
-
skip,
|
|
8784
|
-
Decimal,
|
|
8785
|
-
Debug,
|
|
8786
|
-
objectEnumValues,
|
|
8787
|
-
makeStrictEnum,
|
|
8788
|
-
Extensions,
|
|
8789
|
-
warnOnce,
|
|
8790
|
-
defineDmmfProperty,
|
|
8791
|
-
Public,
|
|
8792
|
-
getRuntime,
|
|
8793
|
-
createParam,
|
|
8794
|
-
} = require('${runtimeBase}/${runtimeNameJs}.js')
|
|
8795
|
-
`}
|
|
8796
|
-
|
|
8797
|
-
const Prisma = {}
|
|
8798
|
-
|
|
8799
|
-
exports.Prisma = Prisma
|
|
8800
|
-
exports.$Enums = {}
|
|
8742
|
+
// src/generation/TSClient/PrismaClient.ts
|
|
8743
|
+
var import_indent_string5 = __toESM(require_indent_string());
|
|
8801
8744
|
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
*/
|
|
8806
|
-
Prisma.prismaVersion = {
|
|
8807
|
-
client: "${clientVersion2}",
|
|
8808
|
-
engine: "${engineVersion}"
|
|
8745
|
+
// src/generation/utils/runtimeImport.ts
|
|
8746
|
+
function runtimeImport(name) {
|
|
8747
|
+
return name;
|
|
8809
8748
|
}
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
Prisma.PrismaClientUnknownRequestError = ${notSupportOnBrowser("PrismaClientUnknownRequestError", browser)}
|
|
8813
|
-
Prisma.PrismaClientRustPanicError = ${notSupportOnBrowser("PrismaClientRustPanicError", browser)}
|
|
8814
|
-
Prisma.PrismaClientInitializationError = ${notSupportOnBrowser("PrismaClientInitializationError", browser)}
|
|
8815
|
-
Prisma.PrismaClientValidationError = ${notSupportOnBrowser("PrismaClientValidationError", browser)}
|
|
8816
|
-
Prisma.Decimal = Decimal
|
|
8817
|
-
|
|
8818
|
-
/**
|
|
8819
|
-
* Re-export of sql-template-tag
|
|
8820
|
-
*/
|
|
8821
|
-
Prisma.sql = ${notSupportOnBrowser("sqltag", browser)}
|
|
8822
|
-
Prisma.empty = ${notSupportOnBrowser("empty", browser)}
|
|
8823
|
-
Prisma.join = ${notSupportOnBrowser("join", browser)}
|
|
8824
|
-
Prisma.raw = ${notSupportOnBrowser("raw", browser)}
|
|
8825
|
-
Prisma.validator = Public.validator
|
|
8826
|
-
|
|
8827
|
-
/**
|
|
8828
|
-
* Extensions
|
|
8829
|
-
*/
|
|
8830
|
-
Prisma.getExtensionContext = ${notSupportOnBrowser("Extensions.getExtensionContext", browser)}
|
|
8831
|
-
Prisma.defineExtension = ${notSupportOnBrowser("Extensions.defineExtension", browser)}
|
|
8832
|
-
|
|
8833
|
-
/**
|
|
8834
|
-
* Shorthand utilities for JSON filtering
|
|
8835
|
-
*/
|
|
8836
|
-
Prisma.DbNull = objectEnumValues.instances.DbNull
|
|
8837
|
-
Prisma.JsonNull = objectEnumValues.instances.JsonNull
|
|
8838
|
-
Prisma.AnyNull = objectEnumValues.instances.AnyNull
|
|
8839
|
-
|
|
8840
|
-
Prisma.NullTypes = {
|
|
8841
|
-
DbNull: objectEnumValues.classes.DbNull,
|
|
8842
|
-
JsonNull: objectEnumValues.classes.JsonNull,
|
|
8843
|
-
AnyNull: objectEnumValues.classes.AnyNull
|
|
8749
|
+
function runtimeImportedType(name) {
|
|
8750
|
+
return namedType(`runtime.${name}`);
|
|
8844
8751
|
}
|
|
8845
8752
|
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
var
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8753
|
+
// src/generation/TSClient/Datasources.ts
|
|
8754
|
+
var import_indent_string4 = __toESM(require_indent_string());
|
|
8755
|
+
var Datasources = class {
|
|
8756
|
+
constructor(internalDatasources) {
|
|
8757
|
+
this.internalDatasources = internalDatasources;
|
|
8758
|
+
}
|
|
8759
|
+
toTS() {
|
|
8760
|
+
const sources = this.internalDatasources;
|
|
8761
|
+
return `export type Datasources = {
|
|
8762
|
+
${(0, import_indent_string4.default)(sources.map((s) => `${s.name}?: Datasource`).join("\n"), 2)}
|
|
8763
|
+
}`;
|
|
8855
8764
|
}
|
|
8856
|
-
return fnc;
|
|
8857
8765
|
};
|
|
8858
|
-
var commonCodeTS = ({
|
|
8859
|
-
runtimeBase,
|
|
8860
|
-
runtimeNameTs,
|
|
8861
|
-
clientVersion: clientVersion2,
|
|
8862
|
-
engineVersion,
|
|
8863
|
-
generator
|
|
8864
|
-
}) => ({
|
|
8865
|
-
tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeNameTs}';
|
|
8866
|
-
import $Types = runtime.Types // general types
|
|
8867
|
-
import $Public = runtime.Types.Public
|
|
8868
|
-
import $Utils = runtime.Types.Utils
|
|
8869
|
-
import $Extensions = runtime.Types.Extensions
|
|
8870
|
-
import $Result = runtime.Types.Result
|
|
8871
|
-
|
|
8872
|
-
export type PrismaPromise<T> = $Public.PrismaPromise<T>
|
|
8873
|
-
`,
|
|
8874
|
-
ts: () => `export import DMMF = runtime.DMMF
|
|
8875
|
-
|
|
8876
|
-
export type PrismaPromise<T> = $Public.PrismaPromise<T>
|
|
8877
|
-
|
|
8878
|
-
/**
|
|
8879
|
-
* Validator
|
|
8880
|
-
*/
|
|
8881
|
-
export import validator = runtime.Public.validator
|
|
8882
|
-
|
|
8883
|
-
/**
|
|
8884
|
-
* Prisma Errors
|
|
8885
|
-
*/
|
|
8886
|
-
export import PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
|
|
8887
|
-
export import PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
|
|
8888
|
-
export import PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
|
|
8889
|
-
export import PrismaClientInitializationError = runtime.PrismaClientInitializationError
|
|
8890
|
-
export import PrismaClientValidationError = runtime.PrismaClientValidationError
|
|
8891
|
-
|
|
8892
|
-
/**
|
|
8893
|
-
* Re-export of sql-template-tag
|
|
8894
|
-
*/
|
|
8895
|
-
export import sql = runtime.sqltag
|
|
8896
|
-
export import empty = runtime.empty
|
|
8897
|
-
export import join = runtime.join
|
|
8898
|
-
export import raw = runtime.raw
|
|
8899
|
-
export import Sql = runtime.Sql
|
|
8900
|
-
|
|
8901
|
-
${buildPrismaSkipTs(generator.previewFeatures)}
|
|
8902
|
-
|
|
8903
|
-
/**
|
|
8904
|
-
* Decimal.js
|
|
8905
|
-
*/
|
|
8906
|
-
export import Decimal = runtime.Decimal
|
|
8907
8766
|
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
/**
|
|
8919
|
-
* Extensions
|
|
8920
|
-
*/
|
|
8921
|
-
export import Extension = $Extensions.UserArgs
|
|
8922
|
-
export import getExtensionContext = runtime.Extensions.getExtensionContext
|
|
8923
|
-
export import Args = $Public.Args
|
|
8924
|
-
export import Payload = $Public.Payload
|
|
8925
|
-
export import Result = $Public.Result
|
|
8926
|
-
export import Exact = $Public.Exact
|
|
8927
|
-
|
|
8928
|
-
/**
|
|
8929
|
-
* Prisma Client JS version: ${clientVersion2}
|
|
8930
|
-
* Query Engine version: ${engineVersion}
|
|
8931
|
-
*/
|
|
8932
|
-
export type PrismaVersion = {
|
|
8933
|
-
client: string
|
|
8934
|
-
}
|
|
8935
|
-
|
|
8936
|
-
export const prismaVersion: PrismaVersion
|
|
8937
|
-
|
|
8938
|
-
/**
|
|
8939
|
-
* Utility Types
|
|
8940
|
-
*/
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
export import JsonObject = runtime.JsonObject
|
|
8944
|
-
export import JsonArray = runtime.JsonArray
|
|
8945
|
-
export import JsonValue = runtime.JsonValue
|
|
8946
|
-
export import InputJsonObject = runtime.InputJsonObject
|
|
8947
|
-
export import InputJsonArray = runtime.InputJsonArray
|
|
8948
|
-
export import InputJsonValue = runtime.InputJsonValue
|
|
8949
|
-
|
|
8950
|
-
/**
|
|
8951
|
-
* Types of the values used to represent different kinds of \`null\` values when working with JSON fields.
|
|
8952
|
-
*
|
|
8953
|
-
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
8954
|
-
*/
|
|
8955
|
-
namespace NullTypes {
|
|
8956
|
-
${buildNullClass("DbNull")}
|
|
8957
|
-
|
|
8958
|
-
${buildNullClass("JsonNull")}
|
|
8959
|
-
|
|
8960
|
-
${buildNullClass("AnyNull")}
|
|
8767
|
+
// src/generation/TSClient/globalOmit.ts
|
|
8768
|
+
function globalOmitConfig(dmmf) {
|
|
8769
|
+
const objectType2 = objectType().addMultiple(
|
|
8770
|
+
dmmf.datamodel.models.map((model) => {
|
|
8771
|
+
const type = namedType(`Prisma.${getOmitName(model.name)}`);
|
|
8772
|
+
return property(lowerCase(model.name), type).optional();
|
|
8773
|
+
})
|
|
8774
|
+
);
|
|
8775
|
+
return moduleExport(typeDeclaration("GlobalOmitConfig", objectType2));
|
|
8961
8776
|
}
|
|
8962
8777
|
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8778
|
+
// src/generation/TSClient/PrismaClient.ts
|
|
8779
|
+
function clientTypeMapModelsDefinition(context) {
|
|
8780
|
+
const meta = objectType();
|
|
8781
|
+
const modelNames = context.dmmf.datamodel.models.map((m) => m.name);
|
|
8782
|
+
if (modelNames.length === 0) {
|
|
8783
|
+
meta.add(property("modelProps", neverType));
|
|
8784
|
+
} else {
|
|
8785
|
+
meta.add(property("modelProps", unionType(modelNames.map((name) => stringLiteral(lowerCase(name))))));
|
|
8786
|
+
}
|
|
8787
|
+
const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ? namedType("TransactionIsolationLevel") : neverType;
|
|
8788
|
+
meta.add(property("txIsolationLevel", isolationLevel));
|
|
8789
|
+
const model = objectType();
|
|
8790
|
+
model.addMultiple(
|
|
8791
|
+
modelNames.map((modelName) => {
|
|
8792
|
+
const entry = objectType();
|
|
8793
|
+
entry.add(
|
|
8794
|
+
property("payload", namedType(getPayloadName(modelName)).addGenericArgument(extArgsParam.toArgument()))
|
|
8795
|
+
);
|
|
8796
|
+
entry.add(property("fields", namedType(`Prisma.${getFieldRefsTypeName(modelName)}`)));
|
|
8797
|
+
const actions = getModelActions(context.dmmf, modelName);
|
|
8798
|
+
const operations = objectType();
|
|
8799
|
+
operations.addMultiple(
|
|
8800
|
+
actions.map((action) => {
|
|
8801
|
+
const operationType = objectType();
|
|
8802
|
+
const argsType = `Prisma.${getModelArgName(modelName, action)}`;
|
|
8803
|
+
operationType.add(property("args", namedType(argsType).addGenericArgument(extArgsParam.toArgument())));
|
|
8804
|
+
operationType.add(property("result", clientTypeMapModelsResultDefinition(modelName, action)));
|
|
8805
|
+
return property(action, operationType);
|
|
8806
|
+
})
|
|
8807
|
+
);
|
|
8808
|
+
entry.add(property("operations", operations));
|
|
8809
|
+
return property(modelName, entry);
|
|
8810
|
+
})
|
|
8811
|
+
);
|
|
8812
|
+
return objectType().add(property("meta", meta)).add(property("model", model));
|
|
8813
|
+
}
|
|
8814
|
+
function clientTypeMapModelsResultDefinition(modelName, action) {
|
|
8815
|
+
if (action === "count")
|
|
8816
|
+
return unionType([optional(namedType(`Prisma.${getCountAggregateOutputName(modelName)}`)), numberType]);
|
|
8817
|
+
if (action === "groupBy") return array(optional(namedType(`Prisma.${getGroupByName(modelName)}`)));
|
|
8818
|
+
if (action === "aggregate") return optional(namedType(`Prisma.${getAggregateName(modelName)}`));
|
|
8819
|
+
if (action === "findRaw") return namedType("Prisma.JsonObject");
|
|
8820
|
+
if (action === "aggregateRaw") return namedType("Prisma.JsonObject");
|
|
8821
|
+
if (action === "deleteMany") return namedType("BatchPayload");
|
|
8822
|
+
if (action === "createMany") return namedType("BatchPayload");
|
|
8823
|
+
if (action === "createManyAndReturn") return array(payloadToResult(modelName));
|
|
8824
|
+
if (action === "updateMany") return namedType("BatchPayload");
|
|
8825
|
+
if (action === "updateManyAndReturn") return array(payloadToResult(modelName));
|
|
8826
|
+
if (action === "findMany") return array(payloadToResult(modelName));
|
|
8827
|
+
if (action === "findFirst") return unionType([payloadToResult(modelName), nullType]);
|
|
8828
|
+
if (action === "findUnique") return unionType([payloadToResult(modelName), nullType]);
|
|
8829
|
+
if (action === "findFirstOrThrow") return payloadToResult(modelName);
|
|
8830
|
+
if (action === "findUniqueOrThrow") return payloadToResult(modelName);
|
|
8831
|
+
if (action === "create") return payloadToResult(modelName);
|
|
8832
|
+
if (action === "update") return payloadToResult(modelName);
|
|
8833
|
+
if (action === "upsert") return payloadToResult(modelName);
|
|
8834
|
+
if (action === "delete") return payloadToResult(modelName);
|
|
8835
|
+
assertNever(action, `Unknown action: ${action}`);
|
|
8836
|
+
}
|
|
8837
|
+
function payloadToResult(modelName) {
|
|
8838
|
+
return namedType("$Utils.PayloadToResult").addGenericArgument(namedType(getPayloadName(modelName)));
|
|
8839
|
+
}
|
|
8840
|
+
function clientTypeMapOthersDefinition(context) {
|
|
8841
|
+
const otherOperationsNames = context.dmmf.getOtherOperationNames().flatMap((name) => {
|
|
8842
|
+
const results = [`$${name}`];
|
|
8843
|
+
if (name === "executeRaw" || name === "queryRaw") {
|
|
8844
|
+
results.push(`$${name}Unsafe`);
|
|
8845
|
+
}
|
|
8846
|
+
if (name === "queryRaw" && context.isPreviewFeatureOn("typedSql")) {
|
|
8847
|
+
results.push(`$queryRawTyped`);
|
|
8848
|
+
}
|
|
8849
|
+
return results;
|
|
8850
|
+
});
|
|
8851
|
+
const argsResultMap = {
|
|
8852
|
+
$executeRaw: { args: "[query: TemplateStringsArray | Sql, ...values: any[]]", result: "any" },
|
|
8853
|
+
$queryRaw: { args: "[query: TemplateStringsArray | Sql, ...values: any[]]", result: "any" },
|
|
8854
|
+
$executeRawUnsafe: { args: "[query: string, ...values: any[]]", result: "any" },
|
|
8855
|
+
$queryRawUnsafe: { args: "[query: string, ...values: any[]]", result: "any" },
|
|
8856
|
+
$runCommandRaw: { args: "Prisma.InputJsonObject", result: "Prisma.JsonObject" },
|
|
8857
|
+
$queryRawTyped: { args: "runtime.UnknownTypedSql", result: "Prisma.JsonObject" }
|
|
8858
|
+
};
|
|
8859
|
+
return `{
|
|
8860
|
+
other: {
|
|
8861
|
+
payload: any
|
|
8862
|
+
operations: {${otherOperationsNames.reduce((acc, action) => {
|
|
8863
|
+
return `${acc}
|
|
8864
|
+
${action}: {
|
|
8865
|
+
args: ${argsResultMap[action].args},
|
|
8866
|
+
result: ${argsResultMap[action].result}
|
|
8867
|
+
}`;
|
|
8868
|
+
}, "")}
|
|
8869
|
+
}
|
|
8870
|
+
}
|
|
8871
|
+
}`;
|
|
8872
|
+
}
|
|
8873
|
+
function clientTypeMapDefinition(context) {
|
|
8874
|
+
const typeMap = `${stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
|
|
8875
|
+
return `
|
|
8876
|
+
export interface TypeMapCb extends $Utils.Fn<{extArgs: $Extensions.InternalArgs, clientOptions: PrismaClientOptions }, $Utils.Record<string, any>> {
|
|
8877
|
+
returns: TypeMap<this['params']['extArgs'], this['params']['clientOptions']>
|
|
8878
|
+
}
|
|
8969
8879
|
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8880
|
+
export type TypeMap<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, ClientOptions = {}> = ${typeMap}`;
|
|
8881
|
+
}
|
|
8882
|
+
function clientExtensionsDefinitions(context) {
|
|
8883
|
+
const typeMap = clientTypeMapDefinition(context);
|
|
8884
|
+
const define2 = moduleExport(
|
|
8885
|
+
constDeclaration(
|
|
8886
|
+
"defineExtension",
|
|
8887
|
+
namedType("$Extensions.ExtendsHook").addGenericArgument(stringLiteral("define")).addGenericArgument(namedType("TypeMapCb")).addGenericArgument(namedType("$Extensions.DefaultArgs"))
|
|
8888
|
+
)
|
|
8889
|
+
);
|
|
8890
|
+
return [typeMap, stringify(define2)].join("\n");
|
|
8891
|
+
}
|
|
8892
|
+
function extendsPropertyDefinition() {
|
|
8893
|
+
const extendsDefinition = namedType("$Extensions.ExtendsHook").addGenericArgument(stringLiteral("extends")).addGenericArgument(namedType("Prisma.TypeMapCb")).addGenericArgument(namedType("ExtArgs")).addGenericArgument(
|
|
8894
|
+
namedType("$Utils.Call").addGenericArgument(namedType("Prisma.TypeMapCb")).addGenericArgument(objectType().add(property("extArgs", namedType("ExtArgs"))))
|
|
8895
|
+
).addGenericArgument(namedType("ClientOptions"));
|
|
8896
|
+
return stringify(property("$extends", extendsDefinition), { indentLevel: 1 });
|
|
8897
|
+
}
|
|
8898
|
+
function batchingTransactionDefinition(context) {
|
|
8899
|
+
const method2 = method("$transaction").setDocComment(
|
|
8900
|
+
docComment`
|
|
8901
|
+
Allows the running of a sequence of read/write operations that are guaranteed to either succeed or fail as a whole.
|
|
8902
|
+
@example
|
|
8903
|
+
\`\`\`
|
|
8904
|
+
const [george, bob, alice] = await prisma.$transaction([
|
|
8905
|
+
prisma.user.create({ data: { name: 'George' } }),
|
|
8906
|
+
prisma.user.create({ data: { name: 'Bob' } }),
|
|
8907
|
+
prisma.user.create({ data: { name: 'Alice' } }),
|
|
8908
|
+
])
|
|
8909
|
+
\`\`\`
|
|
8976
8910
|
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8911
|
+
Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions).
|
|
8912
|
+
`
|
|
8913
|
+
).addGenericParameter(genericParameter("P").extends(array(prismaPromise(anyType)))).addParameter(parameter("arg", arraySpread(namedType("P")))).setReturnType(promise(namedType("runtime.Types.Utils.UnwrapTuple").addGenericArgument(namedType("P"))));
|
|
8914
|
+
if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
8915
|
+
const options = objectType().formatInline().add(property("isolationLevel", namedType("Prisma.TransactionIsolationLevel")).optional());
|
|
8916
|
+
method2.addParameter(parameter("options", options).optional());
|
|
8917
|
+
}
|
|
8918
|
+
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
8919
|
+
}
|
|
8920
|
+
function interactiveTransactionDefinition(context) {
|
|
8921
|
+
const options = objectType().formatInline().add(property("maxWait", numberType).optional()).add(property("timeout", numberType).optional());
|
|
8922
|
+
if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
8923
|
+
const isolationLevel = property("isolationLevel", namedType("Prisma.TransactionIsolationLevel")).optional();
|
|
8924
|
+
options.add(isolationLevel);
|
|
8925
|
+
}
|
|
8926
|
+
const returnType = promise(namedType("R"));
|
|
8927
|
+
const callbackType = functionType().addParameter(
|
|
8928
|
+
parameter("prisma", omit(namedType("PrismaClient"), namedType("runtime.ITXClientDenyList")))
|
|
8929
|
+
).setReturnType(returnType);
|
|
8930
|
+
const method2 = method("$transaction").addGenericParameter(genericParameter("R")).addParameter(parameter("fn", callbackType)).addParameter(parameter("options", options).optional()).setReturnType(returnType);
|
|
8931
|
+
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
8932
|
+
}
|
|
8933
|
+
function queryRawDefinition(context) {
|
|
8934
|
+
if (!context.dmmf.mappings.otherOperations.write.includes("queryRaw")) {
|
|
8935
|
+
return "";
|
|
8936
|
+
}
|
|
8937
|
+
return `
|
|
8938
|
+
/**
|
|
8939
|
+
* Performs a prepared raw query and returns the \`SELECT\` data.
|
|
8940
|
+
* @example
|
|
8941
|
+
* \`\`\`
|
|
8942
|
+
* const result = await prisma.$queryRaw\`SELECT * FROM User WHERE id = \${1} OR email = \${'user@email.com'};\`
|
|
8943
|
+
* \`\`\`
|
|
8944
|
+
*
|
|
8945
|
+
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
8946
|
+
*/
|
|
8947
|
+
$queryRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<T>;
|
|
8983
8948
|
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8949
|
+
/**
|
|
8950
|
+
* Performs a raw query and returns the \`SELECT\` data.
|
|
8951
|
+
* Susceptible to SQL injections, see documentation.
|
|
8952
|
+
* @example
|
|
8953
|
+
* \`\`\`
|
|
8954
|
+
* const result = await prisma.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com')
|
|
8955
|
+
* \`\`\`
|
|
8956
|
+
*
|
|
8957
|
+
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
8958
|
+
*/
|
|
8959
|
+
$queryRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<T>;`;
|
|
8987
8960
|
}
|
|
8961
|
+
function executeRawDefinition(context) {
|
|
8962
|
+
if (!context.dmmf.mappings.otherOperations.write.includes("executeRaw")) {
|
|
8963
|
+
return "";
|
|
8964
|
+
}
|
|
8965
|
+
return `
|
|
8966
|
+
/**
|
|
8967
|
+
* Executes a prepared raw query and returns the number of affected rows.
|
|
8968
|
+
* @example
|
|
8969
|
+
* \`\`\`
|
|
8970
|
+
* const result = await prisma.$executeRaw\`UPDATE User SET cool = \${true} WHERE email = \${'user@email.com'};\`
|
|
8971
|
+
* \`\`\`
|
|
8972
|
+
*
|
|
8973
|
+
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
8974
|
+
*/
|
|
8975
|
+
$executeRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<number>;
|
|
8988
8976
|
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8977
|
+
/**
|
|
8978
|
+
* Executes a raw query and returns the number of affected rows.
|
|
8979
|
+
* Susceptible to SQL injections, see documentation.
|
|
8980
|
+
* @example
|
|
8981
|
+
* \`\`\`
|
|
8982
|
+
* const result = await prisma.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com')
|
|
8983
|
+
* \`\`\`
|
|
8984
|
+
*
|
|
8985
|
+
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
8986
|
+
*/
|
|
8987
|
+
$executeRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<number>;`;
|
|
8992
8988
|
}
|
|
8989
|
+
function queryRawTypedDefinition(context) {
|
|
8990
|
+
if (!context.isPreviewFeatureOn("typedSql")) {
|
|
8991
|
+
return "";
|
|
8992
|
+
}
|
|
8993
|
+
if (!context.dmmf.mappings.otherOperations.write.includes("queryRaw")) {
|
|
8994
|
+
return "";
|
|
8995
|
+
}
|
|
8996
|
+
const param = genericParameter("T");
|
|
8997
|
+
const method2 = method("$queryRawTyped").setDocComment(
|
|
8998
|
+
docComment`
|
|
8999
|
+
Executes a typed SQL query and returns a typed result
|
|
9000
|
+
@example
|
|
9001
|
+
\`\`\`
|
|
9002
|
+
import { myQuery } from '@prisma/client/sql'
|
|
8993
9003
|
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
9004
|
+
const result = await prisma.$queryRawTyped(myQuery())
|
|
9005
|
+
\`\`\`
|
|
9006
|
+
`
|
|
9007
|
+
).addGenericParameter(param).addParameter(
|
|
9008
|
+
parameter(
|
|
9009
|
+
"typedSql",
|
|
9010
|
+
runtimeImportedType("TypedSql").addGenericArgument(array(unknownType)).addGenericArgument(param.toArgument())
|
|
9011
|
+
)
|
|
9012
|
+
).setReturnType(prismaPromise(array(param.toArgument())));
|
|
9013
|
+
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
9014
|
+
}
|
|
9015
|
+
function metricDefinition(context) {
|
|
9016
|
+
if (!context.isPreviewFeatureOn("metrics")) {
|
|
9017
|
+
return "";
|
|
9018
|
+
}
|
|
9019
|
+
const property2 = property("$metrics", namedType(`runtime.${runtimeImport("MetricsClient")}`)).setDocComment(
|
|
9020
|
+
docComment`
|
|
9021
|
+
Gives access to the client metrics in json or prometheus format.
|
|
8998
9022
|
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9023
|
+
@example
|
|
9024
|
+
\`\`\`
|
|
9025
|
+
const metrics = await prisma.$metrics.json()
|
|
9026
|
+
// or
|
|
9027
|
+
const metrics = await prisma.$metrics.prometheus()
|
|
9028
|
+
\`\`\`
|
|
9029
|
+
`
|
|
9030
|
+
).readonly();
|
|
9031
|
+
return stringify(property2, { indentLevel: 1, newLine: "leading" });
|
|
9032
|
+
}
|
|
9033
|
+
function runCommandRawDefinition(context) {
|
|
9034
|
+
if (!context.dmmf.mappings.otherOperations.write.includes("runCommandRaw")) {
|
|
9035
|
+
return "";
|
|
9036
|
+
}
|
|
9037
|
+
const method2 = method("$runCommandRaw").addParameter(parameter("command", namedType("Prisma.InputJsonObject"))).setReturnType(prismaPromise(namedType("Prisma.JsonObject"))).setDocComment(docComment`
|
|
9038
|
+
Executes a raw MongoDB command and returns the result of it.
|
|
9039
|
+
@example
|
|
9040
|
+
\`\`\`
|
|
9041
|
+
const user = await prisma.$runCommandRaw({
|
|
9042
|
+
aggregate: 'User',
|
|
9043
|
+
pipeline: [{ $match: { name: 'Bob' } }, { $project: { email: true, _id: false } }],
|
|
9044
|
+
explain: false,
|
|
9045
|
+
})
|
|
9046
|
+
\`\`\`
|
|
9003
9047
|
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9048
|
+
Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
9049
|
+
`);
|
|
9050
|
+
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
9051
|
+
}
|
|
9052
|
+
function applyPendingMigrationsDefinition() {
|
|
9053
|
+
if (this.runtimeNameTs !== "react-native") {
|
|
9054
|
+
return null;
|
|
9055
|
+
}
|
|
9056
|
+
const method2 = method("$applyPendingMigrations").setReturnType(promise(voidType)).setDocComment(
|
|
9057
|
+
docComment`Tries to apply pending migrations one by one. If a migration fails to apply, the function will stop and throw an error. You are responsible for informing the user and possibly blocking the app as we cannot guarantee the state of the database.`
|
|
9058
|
+
);
|
|
9059
|
+
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
9060
|
+
}
|
|
9061
|
+
function eventRegistrationMethodDeclaration(runtimeNameTs) {
|
|
9062
|
+
if (runtimeNameTs === "binary.js") {
|
|
9063
|
+
return `$on<V extends (U | 'beforeExit')>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : V extends 'beforeExit' ? () => $Utils.JsPromise<void> : Prisma.LogEvent) => void): void;`;
|
|
9064
|
+
} else {
|
|
9065
|
+
return `$on<V extends U>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): void;`;
|
|
9066
|
+
}
|
|
9067
|
+
}
|
|
9068
|
+
var PrismaClientClass = class {
|
|
9069
|
+
constructor(context, internalDatasources, outputDir, runtimeNameTs, browser) {
|
|
9070
|
+
this.context = context;
|
|
9071
|
+
this.internalDatasources = internalDatasources;
|
|
9072
|
+
this.outputDir = outputDir;
|
|
9073
|
+
this.runtimeNameTs = runtimeNameTs;
|
|
9074
|
+
this.browser = browser;
|
|
9075
|
+
}
|
|
9076
|
+
get jsDoc() {
|
|
9077
|
+
const { dmmf } = this.context;
|
|
9078
|
+
let example;
|
|
9079
|
+
if (dmmf.mappings.modelOperations.length) {
|
|
9080
|
+
example = dmmf.mappings.modelOperations[0];
|
|
9081
|
+
} else {
|
|
9082
|
+
example = {
|
|
9083
|
+
model: "User",
|
|
9084
|
+
plural: "users"
|
|
9085
|
+
};
|
|
9086
|
+
}
|
|
9087
|
+
return `/**
|
|
9088
|
+
* ## Prisma Client \u02B2\u02E2
|
|
9089
|
+
*
|
|
9090
|
+
* Type-safe database client for TypeScript & Node.js
|
|
9091
|
+
* @example
|
|
9092
|
+
* \`\`\`
|
|
9093
|
+
* const prisma = new PrismaClient()
|
|
9094
|
+
* // Fetch zero or more ${capitalize2(example.plural)}
|
|
9095
|
+
* const ${lowerCase(example.plural)} = await prisma.${lowerCase(example.model)}.findMany()
|
|
9096
|
+
* \`\`\`
|
|
9097
|
+
*
|
|
9098
|
+
*
|
|
9099
|
+
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
|
|
9100
|
+
*/`;
|
|
9101
|
+
}
|
|
9102
|
+
toTSWithoutNamespace() {
|
|
9103
|
+
const { dmmf } = this.context;
|
|
9104
|
+
return `${this.jsDoc}
|
|
9105
|
+
export class PrismaClient<
|
|
9106
|
+
ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
|
|
9107
|
+
U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
|
|
9108
|
+
ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs
|
|
9109
|
+
> {
|
|
9110
|
+
[K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
|
|
9010
9111
|
|
|
9112
|
+
${(0, import_indent_string5.default)(this.jsDoc, TAB_SIZE)}
|
|
9011
9113
|
|
|
9012
|
-
|
|
9114
|
+
constructor(optionsArg ?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>);
|
|
9115
|
+
${eventRegistrationMethodDeclaration(this.runtimeNameTs)}
|
|
9013
9116
|
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9117
|
+
/**
|
|
9118
|
+
* Connect with the database
|
|
9119
|
+
*/
|
|
9120
|
+
$connect(): $Utils.JsPromise<void>;
|
|
9017
9121
|
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9122
|
+
/**
|
|
9123
|
+
* Disconnect from the database
|
|
9124
|
+
*/
|
|
9125
|
+
$disconnect(): $Utils.JsPromise<void>;
|
|
9021
9126
|
|
|
9022
|
-
|
|
9127
|
+
/**
|
|
9128
|
+
* Add a middleware
|
|
9129
|
+
* @deprecated since 4.16.0. For new code, prefer client extensions instead.
|
|
9130
|
+
* @see https://pris.ly/d/extensions
|
|
9131
|
+
*/
|
|
9132
|
+
$use(cb: Prisma.Middleware): void
|
|
9023
9133
|
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9134
|
+
${[
|
|
9135
|
+
executeRawDefinition(this.context),
|
|
9136
|
+
queryRawDefinition(this.context),
|
|
9137
|
+
queryRawTypedDefinition(this.context),
|
|
9138
|
+
batchingTransactionDefinition(this.context),
|
|
9139
|
+
interactiveTransactionDefinition(this.context),
|
|
9140
|
+
runCommandRawDefinition(this.context),
|
|
9141
|
+
metricDefinition(this.context),
|
|
9142
|
+
applyPendingMigrationsDefinition.bind(this)(),
|
|
9143
|
+
extendsPropertyDefinition()
|
|
9144
|
+
].filter((d) => d !== null).join("\n").trim()}
|
|
9031
9145
|
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9146
|
+
${(0, import_indent_string5.default)(
|
|
9147
|
+
dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
|
|
9148
|
+
let methodName = lowerCase(m.model);
|
|
9149
|
+
if (methodName === "constructor") {
|
|
9150
|
+
methodName = '["constructor"]';
|
|
9151
|
+
}
|
|
9152
|
+
const generics = ["ExtArgs", "ClientOptions"];
|
|
9153
|
+
return `/**
|
|
9154
|
+
* \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
|
|
9155
|
+
* Example usage:
|
|
9156
|
+
* \`\`\`ts
|
|
9157
|
+
* // Fetch zero or more ${capitalize2(m.plural)}
|
|
9158
|
+
* const ${lowerCase(m.plural)} = await prisma.${methodName}.findMany()
|
|
9159
|
+
* \`\`\`
|
|
9160
|
+
*/
|
|
9161
|
+
get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
|
|
9162
|
+
}).join("\n\n"),
|
|
9163
|
+
2
|
|
9164
|
+
)}
|
|
9165
|
+
}`;
|
|
9166
|
+
}
|
|
9167
|
+
toTS() {
|
|
9168
|
+
const clientOptions = this.buildClientOptions();
|
|
9169
|
+
return `${new Datasources(this.internalDatasources).toTS()}
|
|
9170
|
+
${clientExtensionsDefinitions(this.context)}
|
|
9171
|
+
export type DefaultPrismaClient = PrismaClient
|
|
9172
|
+
export type ErrorFormat = 'pretty' | 'colorless' | 'minimal'
|
|
9173
|
+
${stringify(moduleExport(clientOptions))}
|
|
9174
|
+
${stringify(globalOmitConfig(this.context.dmmf))}
|
|
9045
9175
|
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
} &
|
|
9053
|
-
K
|
|
9176
|
+
/* Types for Logging */
|
|
9177
|
+
export type LogLevel = 'info' | 'query' | 'warn' | 'error'
|
|
9178
|
+
export type LogDefinition = {
|
|
9179
|
+
level: LogLevel
|
|
9180
|
+
emit: 'stdout' | 'event'
|
|
9181
|
+
}
|
|
9054
9182
|
|
|
9055
|
-
type
|
|
9183
|
+
export type GetLogType<T extends LogLevel | LogDefinition> = T extends LogDefinition ? T['emit'] extends 'event' ? T['level'] : never : never
|
|
9184
|
+
export type GetEvents<T extends any> = T extends Array<LogLevel | LogDefinition> ?
|
|
9185
|
+
GetLogType<T[0]> | GetLogType<T[1]> | GetLogType<T[2]> | GetLogType<T[3]>
|
|
9186
|
+
: never
|
|
9056
9187
|
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
(Without<T, U> & U) | (Without<U, T> & T)
|
|
9065
|
-
: U : T
|
|
9188
|
+
export type QueryEvent = {
|
|
9189
|
+
timestamp: Date
|
|
9190
|
+
query: string
|
|
9191
|
+
params: string
|
|
9192
|
+
duration: number
|
|
9193
|
+
target: string
|
|
9194
|
+
}
|
|
9066
9195
|
|
|
9196
|
+
export type LogEvent = {
|
|
9197
|
+
timestamp: Date
|
|
9198
|
+
message: string
|
|
9199
|
+
target: string
|
|
9200
|
+
}
|
|
9201
|
+
/* End Types for Logging */
|
|
9067
9202
|
|
|
9068
|
-
/**
|
|
9069
|
-
* Is T a Record?
|
|
9070
|
-
*/
|
|
9071
|
-
type IsObject<T extends any> = T extends Array<any>
|
|
9072
|
-
? False
|
|
9073
|
-
: T extends Date
|
|
9074
|
-
? False
|
|
9075
|
-
: T extends Uint8Array
|
|
9076
|
-
? False
|
|
9077
|
-
: T extends BigInt
|
|
9078
|
-
? False
|
|
9079
|
-
: T extends object
|
|
9080
|
-
? True
|
|
9081
|
-
: False
|
|
9082
9203
|
|
|
9204
|
+
export type PrismaAction =
|
|
9205
|
+
| 'findUnique'
|
|
9206
|
+
| 'findUniqueOrThrow'
|
|
9207
|
+
| 'findMany'
|
|
9208
|
+
| 'findFirst'
|
|
9209
|
+
| 'findFirstOrThrow'
|
|
9210
|
+
| 'create'
|
|
9211
|
+
| 'createMany'
|
|
9212
|
+
| 'createManyAndReturn'
|
|
9213
|
+
| 'update'
|
|
9214
|
+
| 'updateMany'
|
|
9215
|
+
| 'updateManyAndReturn'
|
|
9216
|
+
| 'upsert'
|
|
9217
|
+
| 'delete'
|
|
9218
|
+
| 'deleteMany'
|
|
9219
|
+
| 'executeRaw'
|
|
9220
|
+
| 'queryRaw'
|
|
9221
|
+
| 'aggregate'
|
|
9222
|
+
| 'count'
|
|
9223
|
+
| 'runCommandRaw'
|
|
9224
|
+
| 'findRaw'
|
|
9225
|
+
| 'groupBy'
|
|
9226
|
+
|
|
9227
|
+
/**
|
|
9228
|
+
* These options are being passed into the middleware as "params"
|
|
9229
|
+
*/
|
|
9230
|
+
export type MiddlewareParams = {
|
|
9231
|
+
model?: ModelName
|
|
9232
|
+
action: PrismaAction
|
|
9233
|
+
args: any
|
|
9234
|
+
dataPath: string[]
|
|
9235
|
+
runInTransaction: boolean
|
|
9236
|
+
}
|
|
9083
9237
|
|
|
9084
9238
|
/**
|
|
9085
|
-
*
|
|
9239
|
+
* The \`T\` type makes sure, that the \`return proceed\` is not forgotten in the middleware implementation
|
|
9086
9240
|
*/
|
|
9087
|
-
export type
|
|
9241
|
+
export type Middleware<T = any> = (
|
|
9242
|
+
params: MiddlewareParams,
|
|
9243
|
+
next: (params: MiddlewareParams) => $Utils.JsPromise<T>,
|
|
9244
|
+
) => $Utils.JsPromise<T>
|
|
9245
|
+
|
|
9246
|
+
// tested in getLogLevel.test.ts
|
|
9247
|
+
export function getLogLevel(log: Array<LogLevel | LogDefinition>): LogLevel | undefined;
|
|
9088
9248
|
|
|
9089
9249
|
/**
|
|
9090
|
-
*
|
|
9250
|
+
* \`PrismaClient\` proxy available in interactive transactions.
|
|
9091
9251
|
*/
|
|
9252
|
+
export type TransactionClient = Omit<DefaultPrismaClient, runtime.ITXClientDenyList>
|
|
9253
|
+
`;
|
|
9254
|
+
}
|
|
9255
|
+
buildClientOptions() {
|
|
9256
|
+
const clientOptions = interfaceDeclaration("PrismaClientOptions").add(
|
|
9257
|
+
property("datasources", namedType("Datasources")).optional().setDocComment(docComment("Overwrites the datasource url from your schema.prisma file"))
|
|
9258
|
+
).add(
|
|
9259
|
+
property("datasourceUrl", stringType).optional().setDocComment(docComment("Overwrites the datasource url from your schema.prisma file"))
|
|
9260
|
+
).add(
|
|
9261
|
+
property("errorFormat", namedType("ErrorFormat")).optional().setDocComment(docComment('@default "colorless"'))
|
|
9262
|
+
).add(
|
|
9263
|
+
property("log", array(unionType([namedType("LogLevel"), namedType("LogDefinition")]))).optional().setDocComment(docComment`
|
|
9264
|
+
@example
|
|
9265
|
+
\`\`\`
|
|
9266
|
+
// Defaults to stdout
|
|
9267
|
+
log: ['query', 'info', 'warn', 'error']
|
|
9092
9268
|
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9269
|
+
// Emit as events
|
|
9270
|
+
log: [
|
|
9271
|
+
{ emit: 'stdout', level: 'query' },
|
|
9272
|
+
{ emit: 'stdout', level: 'info' },
|
|
9273
|
+
{ emit: 'stdout', level: 'warn' }
|
|
9274
|
+
{ emit: 'stdout', level: 'error' }
|
|
9275
|
+
]
|
|
9276
|
+
\`\`\`
|
|
9277
|
+
Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/logging#the-log-option).
|
|
9278
|
+
`)
|
|
9279
|
+
);
|
|
9280
|
+
const transactionOptions = objectType().add(property("maxWait", numberType).optional()).add(property("timeout", numberType).optional());
|
|
9281
|
+
if (this.context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
9282
|
+
transactionOptions.add(property("isolationLevel", namedType("TransactionIsolationLevel")).optional());
|
|
9283
|
+
}
|
|
9284
|
+
clientOptions.add(
|
|
9285
|
+
property("transactionOptions", transactionOptions).optional().setDocComment(docComment`
|
|
9286
|
+
The default values for transactionOptions
|
|
9287
|
+
maxWait ?= 2000
|
|
9288
|
+
timeout ?= 5000
|
|
9289
|
+
`)
|
|
9290
|
+
);
|
|
9291
|
+
if (["library.js", "client.js"].includes(this.runtimeNameTs) && this.context.isPreviewFeatureOn("driverAdapters")) {
|
|
9292
|
+
clientOptions.add(
|
|
9293
|
+
property("adapter", unionType([namedType("runtime.DriverAdapter"), namedType("null")])).optional().setDocComment(
|
|
9294
|
+
docComment("Instance of a Driver Adapter, e.g., like one provided by `@prisma/adapter-planetscale`")
|
|
9295
|
+
)
|
|
9296
|
+
);
|
|
9297
|
+
}
|
|
9298
|
+
clientOptions.add(
|
|
9299
|
+
property("omit", namedType("GlobalOmitConfig")).optional().setDocComment(docComment`
|
|
9300
|
+
Global configuration for omitting model fields by default.
|
|
9098
9301
|
|
|
9099
|
-
|
|
9302
|
+
@example
|
|
9303
|
+
\`\`\`
|
|
9304
|
+
const prisma = new PrismaClient({
|
|
9305
|
+
omit: {
|
|
9306
|
+
user: {
|
|
9307
|
+
password: true
|
|
9308
|
+
}
|
|
9309
|
+
}
|
|
9310
|
+
})
|
|
9311
|
+
\`\`\`
|
|
9312
|
+
`)
|
|
9313
|
+
);
|
|
9314
|
+
return clientOptions;
|
|
9315
|
+
}
|
|
9316
|
+
};
|
|
9100
9317
|
|
|
9101
|
-
|
|
9318
|
+
// src/generation/TSClient/ClientFile.ts
|
|
9319
|
+
function createClientFile(context, options) {
|
|
9320
|
+
const prismaClientClass = new PrismaClientClass(
|
|
9321
|
+
context,
|
|
9322
|
+
options.datasources,
|
|
9323
|
+
options.outputDir,
|
|
9324
|
+
options.runtimeNameTs,
|
|
9325
|
+
options.browser
|
|
9326
|
+
);
|
|
9327
|
+
return `import * as runtime from '${context.runtimeJsPath}'
|
|
9328
|
+
import $Utils = runtime.Types.Utils
|
|
9329
|
+
import $Extensions = runtime.Types.Extensions
|
|
9102
9330
|
|
|
9103
|
-
type
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
1: EitherStrict<O, K>
|
|
9109
|
-
0: EitherLoose<O, K>
|
|
9110
|
-
}[strict]
|
|
9331
|
+
import type * as Prisma from './common'
|
|
9332
|
+
|
|
9333
|
+
${prismaClientClass.toTSWithoutNamespace()}
|
|
9334
|
+
`;
|
|
9335
|
+
}
|
|
9111
9336
|
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9337
|
+
// src/generation/TSClient/common.ts
|
|
9338
|
+
var import_indent_string6 = __toESM(require_indent_string());
|
|
9339
|
+
var commonCodeJS = ({
|
|
9340
|
+
runtimeBase,
|
|
9341
|
+
runtimeNameJs,
|
|
9342
|
+
browser,
|
|
9343
|
+
clientVersion: clientVersion2,
|
|
9344
|
+
engineVersion,
|
|
9345
|
+
generator,
|
|
9346
|
+
deno
|
|
9347
|
+
}) => `${deno ? "const exports = {}" : ""}
|
|
9348
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9349
|
+
${deno ? `
|
|
9350
|
+
import {
|
|
9351
|
+
PrismaClientKnownRequestError,
|
|
9352
|
+
PrismaClientUnknownRequestError,
|
|
9353
|
+
PrismaClientRustPanicError,
|
|
9354
|
+
PrismaClientInitializationError,
|
|
9355
|
+
PrismaClientValidationError,
|
|
9356
|
+
getPrismaClient,
|
|
9357
|
+
sqltag,
|
|
9358
|
+
empty,
|
|
9359
|
+
join,
|
|
9360
|
+
raw,
|
|
9361
|
+
Decimal,
|
|
9362
|
+
Debug,
|
|
9363
|
+
objectEnumValues,
|
|
9364
|
+
makeStrictEnum,
|
|
9365
|
+
Extensions,
|
|
9366
|
+
defineDmmfProperty,
|
|
9367
|
+
Public,
|
|
9368
|
+
getRuntime,
|
|
9369
|
+
skip
|
|
9370
|
+
} from '${runtimeBase}/${runtimeNameJs}.js'` : browser ? `
|
|
9371
|
+
const {
|
|
9372
|
+
Decimal,
|
|
9373
|
+
objectEnumValues,
|
|
9374
|
+
makeStrictEnum,
|
|
9375
|
+
Public,
|
|
9376
|
+
getRuntime,
|
|
9377
|
+
skip
|
|
9378
|
+
} = require('${runtimeBase}/${runtimeNameJs}.js')
|
|
9379
|
+
` : `
|
|
9380
|
+
const {
|
|
9381
|
+
PrismaClientKnownRequestError,
|
|
9382
|
+
PrismaClientUnknownRequestError,
|
|
9383
|
+
PrismaClientRustPanicError,
|
|
9384
|
+
PrismaClientInitializationError,
|
|
9385
|
+
PrismaClientValidationError,
|
|
9386
|
+
getPrismaClient,
|
|
9387
|
+
sqltag,
|
|
9388
|
+
empty,
|
|
9389
|
+
join,
|
|
9390
|
+
raw,
|
|
9391
|
+
skip,
|
|
9392
|
+
Decimal,
|
|
9393
|
+
Debug,
|
|
9394
|
+
objectEnumValues,
|
|
9395
|
+
makeStrictEnum,
|
|
9396
|
+
Extensions,
|
|
9397
|
+
warnOnce,
|
|
9398
|
+
defineDmmfProperty,
|
|
9399
|
+
Public,
|
|
9400
|
+
getRuntime,
|
|
9401
|
+
createParam,
|
|
9402
|
+
} = require('${runtimeBase}/${runtimeNameJs}.js')
|
|
9403
|
+
`}
|
|
9117
9404
|
|
|
9118
|
-
|
|
9405
|
+
const Prisma = {}
|
|
9119
9406
|
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
} & {}
|
|
9407
|
+
exports.Prisma = Prisma
|
|
9408
|
+
exports.$Enums = {}
|
|
9123
9409
|
|
|
9124
|
-
/**
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
:
|
|
9410
|
+
/**
|
|
9411
|
+
* Prisma Client JS version: ${clientVersion2}
|
|
9412
|
+
* Query Engine version: ${engineVersion}
|
|
9413
|
+
*/
|
|
9414
|
+
Prisma.prismaVersion = {
|
|
9415
|
+
client: "${clientVersion2}",
|
|
9416
|
+
engine: "${engineVersion}"
|
|
9417
|
+
}
|
|
9130
9418
|
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9419
|
+
Prisma.PrismaClientKnownRequestError = ${notSupportOnBrowser("PrismaClientKnownRequestError", browser)};
|
|
9420
|
+
Prisma.PrismaClientUnknownRequestError = ${notSupportOnBrowser("PrismaClientUnknownRequestError", browser)}
|
|
9421
|
+
Prisma.PrismaClientRustPanicError = ${notSupportOnBrowser("PrismaClientRustPanicError", browser)}
|
|
9422
|
+
Prisma.PrismaClientInitializationError = ${notSupportOnBrowser("PrismaClientInitializationError", browser)}
|
|
9423
|
+
Prisma.PrismaClientValidationError = ${notSupportOnBrowser("PrismaClientValidationError", browser)}
|
|
9424
|
+
Prisma.Decimal = Decimal
|
|
9134
9425
|
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9426
|
+
/**
|
|
9427
|
+
* Re-export of sql-template-tag
|
|
9428
|
+
*/
|
|
9429
|
+
Prisma.sql = ${notSupportOnBrowser("sqltag", browser)}
|
|
9430
|
+
Prisma.empty = ${notSupportOnBrowser("empty", browser)}
|
|
9431
|
+
Prisma.join = ${notSupportOnBrowser("join", browser)}
|
|
9432
|
+
Prisma.raw = ${notSupportOnBrowser("raw", browser)}
|
|
9433
|
+
Prisma.validator = Public.validator
|
|
9138
9434
|
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
1: AtStrict<O, K>;
|
|
9145
|
-
0: AtLoose<O, K>;
|
|
9146
|
-
}[strict];
|
|
9435
|
+
/**
|
|
9436
|
+
* Extensions
|
|
9437
|
+
*/
|
|
9438
|
+
Prisma.getExtensionContext = ${notSupportOnBrowser("Extensions.getExtensionContext", browser)}
|
|
9439
|
+
Prisma.defineExtension = ${notSupportOnBrowser("Extensions.defineExtension", browser)}
|
|
9147
9440
|
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9441
|
+
/**
|
|
9442
|
+
* Shorthand utilities for JSON filtering
|
|
9443
|
+
*/
|
|
9444
|
+
Prisma.DbNull = objectEnumValues.instances.DbNull
|
|
9445
|
+
Prisma.JsonNull = objectEnumValues.instances.JsonNull
|
|
9446
|
+
Prisma.AnyNull = objectEnumValues.instances.AnyNull
|
|
9151
9447
|
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9448
|
+
Prisma.NullTypes = {
|
|
9449
|
+
DbNull: objectEnumValues.classes.DbNull,
|
|
9450
|
+
JsonNull: objectEnumValues.classes.JsonNull,
|
|
9451
|
+
AnyNull: objectEnumValues.classes.AnyNull
|
|
9452
|
+
}
|
|
9155
9453
|
|
|
9156
|
-
|
|
9157
|
-
|
|
9454
|
+
${buildPrismaSkipJs(generator.previewFeatures)}
|
|
9455
|
+
`;
|
|
9456
|
+
var notSupportOnBrowser = (fnc, browser) => {
|
|
9457
|
+
if (browser) {
|
|
9458
|
+
return `() => {
|
|
9459
|
+
const runtimeName = getRuntime().prettyName;
|
|
9460
|
+
throw new Error(\`${fnc} is unable to run in this browser environment, or has been bundled for the browser (running in \${runtimeName}).
|
|
9461
|
+
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report\`,
|
|
9462
|
+
)}`;
|
|
9463
|
+
}
|
|
9464
|
+
return fnc;
|
|
9158
9465
|
};
|
|
9466
|
+
var commonCodeTS = ({ clientVersion: clientVersion2, engineVersion, generator }) => ({
|
|
9467
|
+
ts: () => `export import DMMF = runtime.DMMF
|
|
9159
9468
|
|
|
9160
|
-
|
|
9161
|
-
type NoExpand<T> = T extends unknown ? T : never;
|
|
9469
|
+
export type PrismaPromise<T> = $Public.PrismaPromise<T>
|
|
9162
9470
|
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
| {[P in keyof O as P extends K ? K : never]-?: O[P]} & O
|
|
9168
|
-
: never>;
|
|
9471
|
+
/**
|
|
9472
|
+
* Validator
|
|
9473
|
+
*/
|
|
9474
|
+
export import validator = runtime.Public.validator
|
|
9169
9475
|
|
|
9170
|
-
|
|
9476
|
+
/**
|
|
9477
|
+
* Prisma Errors
|
|
9478
|
+
*/
|
|
9479
|
+
export import PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
|
|
9480
|
+
export import PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
|
|
9481
|
+
export import PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
|
|
9482
|
+
export import PrismaClientInitializationError = runtime.PrismaClientInitializationError
|
|
9483
|
+
export import PrismaClientValidationError = runtime.PrismaClientValidationError
|
|
9171
9484
|
|
|
9172
|
-
|
|
9173
|
-
|
|
9485
|
+
/**
|
|
9486
|
+
* Re-export of sql-template-tag
|
|
9487
|
+
*/
|
|
9488
|
+
export import sql = runtime.sqltag
|
|
9489
|
+
export import empty = runtime.empty
|
|
9490
|
+
export import join = runtime.join
|
|
9491
|
+
export import raw = runtime.raw
|
|
9492
|
+
export import Sql = runtime.Sql
|
|
9174
9493
|
|
|
9175
|
-
|
|
9494
|
+
${buildPrismaSkipTs(generator.previewFeatures)}
|
|
9176
9495
|
|
|
9177
9496
|
/**
|
|
9178
|
-
|
|
9179
|
-
*/
|
|
9180
|
-
export
|
|
9497
|
+
* Decimal.js
|
|
9498
|
+
*/
|
|
9499
|
+
export import Decimal = runtime.Decimal
|
|
9181
9500
|
|
|
9182
|
-
|
|
9183
|
-
// 1
|
|
9184
|
-
// */
|
|
9185
|
-
export type True = 1
|
|
9501
|
+
export type DecimalJsLike = runtime.DecimalJsLike
|
|
9186
9502
|
|
|
9187
9503
|
/**
|
|
9188
|
-
|
|
9189
|
-
*/
|
|
9190
|
-
export type
|
|
9191
|
-
|
|
9192
|
-
export type
|
|
9193
|
-
|
|
9194
|
-
1: 0
|
|
9195
|
-
}[B]
|
|
9504
|
+
* Metrics
|
|
9505
|
+
*/
|
|
9506
|
+
export type Metrics = runtime.Metrics
|
|
9507
|
+
export type Metric<T> = runtime.Metric<T>
|
|
9508
|
+
export type MetricHistogram = runtime.MetricHistogram
|
|
9509
|
+
export type MetricHistogramBucket = runtime.MetricHistogramBucket
|
|
9196
9510
|
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9511
|
+
/**
|
|
9512
|
+
* Extensions
|
|
9513
|
+
*/
|
|
9514
|
+
export import Extension = $Extensions.UserArgs
|
|
9515
|
+
export import getExtensionContext = runtime.Extensions.getExtensionContext
|
|
9516
|
+
export import Args = $Public.Args
|
|
9517
|
+
export import Payload = $Public.Payload
|
|
9518
|
+
export import Result = $Public.Result
|
|
9519
|
+
export import Exact = $Public.Exact
|
|
9202
9520
|
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9521
|
+
/**
|
|
9522
|
+
* Prisma Client JS version: ${clientVersion2}
|
|
9523
|
+
* Query Engine version: ${engineVersion}
|
|
9524
|
+
*/
|
|
9525
|
+
export type PrismaVersion = {
|
|
9526
|
+
client: string
|
|
9527
|
+
}
|
|
9206
9528
|
|
|
9207
|
-
export
|
|
9208
|
-
0: {
|
|
9209
|
-
0: 0
|
|
9210
|
-
1: 1
|
|
9211
|
-
}
|
|
9212
|
-
1: {
|
|
9213
|
-
0: 1
|
|
9214
|
-
1: 1
|
|
9215
|
-
}
|
|
9216
|
-
}[B1][B2]
|
|
9529
|
+
export const prismaVersion: PrismaVersion
|
|
9217
9530
|
|
|
9218
|
-
|
|
9531
|
+
/**
|
|
9532
|
+
* Utility Types
|
|
9533
|
+
*/
|
|
9219
9534
|
|
|
9220
|
-
|
|
9535
|
+
/**
|
|
9536
|
+
* Types of the values used to represent different kinds of \`null\` values when working with JSON fields.
|
|
9537
|
+
*
|
|
9538
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9539
|
+
*/
|
|
9540
|
+
export namespace NullTypes {
|
|
9541
|
+
${buildNullClass("DbNull")}
|
|
9221
9542
|
|
|
9222
|
-
|
|
9543
|
+
${buildNullClass("JsonNull")}
|
|
9223
9544
|
|
|
9545
|
+
${buildNullClass("AnyNull")}
|
|
9546
|
+
}
|
|
9224
9547
|
|
|
9548
|
+
/**
|
|
9549
|
+
* Helper for filtering JSON entries that have \`null\` on the database (empty on the db)
|
|
9550
|
+
*
|
|
9551
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9552
|
+
*/
|
|
9553
|
+
export const DbNull: NullTypes.DbNull
|
|
9225
9554
|
|
|
9226
9555
|
/**
|
|
9227
|
-
*
|
|
9556
|
+
* Helper for filtering JSON entries that have JSON \`null\` values (not empty on the db)
|
|
9557
|
+
*
|
|
9558
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9228
9559
|
*/
|
|
9560
|
+
export const JsonNull: NullTypes.JsonNull
|
|
9229
9561
|
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9562
|
+
/**
|
|
9563
|
+
* Helper for filtering JSON entries that are \`Prisma.DbNull\` or \`Prisma.JsonNull\`
|
|
9564
|
+
*
|
|
9565
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9566
|
+
*/
|
|
9567
|
+
export const AnyNull: NullTypes.AnyNull
|
|
9235
9568
|
|
|
9236
|
-
type
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9569
|
+
type SelectAndInclude = {
|
|
9570
|
+
select: any
|
|
9571
|
+
include: any
|
|
9572
|
+
}
|
|
9240
9573
|
|
|
9241
|
-
type
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
> extends True
|
|
9246
|
-
? // infer is only needed to not hit TS limit
|
|
9247
|
-
// based on the brilliant idea of Pierre-Antoine Mills
|
|
9248
|
-
// https://github.com/microsoft/TypeScript/issues/30188#issuecomment-478938437
|
|
9249
|
-
T[K] extends infer TK
|
|
9250
|
-
? GetHavingFields<UnEnumerate<TK> extends object ? Merge<UnEnumerate<TK>> : never>
|
|
9251
|
-
: never
|
|
9252
|
-
: {} extends FieldPaths<T[K]>
|
|
9253
|
-
? never
|
|
9254
|
-
: K
|
|
9255
|
-
}[keyof T]
|
|
9574
|
+
type SelectAndOmit = {
|
|
9575
|
+
select: any
|
|
9576
|
+
omit: any
|
|
9577
|
+
}
|
|
9256
9578
|
|
|
9257
9579
|
/**
|
|
9258
|
-
*
|
|
9580
|
+
* Get the type of the value, that the Promise holds.
|
|
9259
9581
|
*/
|
|
9260
|
-
type
|
|
9261
|
-
type TupleToUnion<K extends readonly any[]> = _TupleToUnion<K>
|
|
9262
|
-
type MaybeTupleToUnion<T> = T extends any[] ? TupleToUnion<T> : T
|
|
9582
|
+
export type PromiseType<T extends PromiseLike<any>> = T extends PromiseLike<infer U> ? U : T;
|
|
9263
9583
|
|
|
9264
9584
|
/**
|
|
9265
|
-
*
|
|
9585
|
+
* Get the return type of a function which returns a Promise.
|
|
9266
9586
|
*/
|
|
9267
|
-
type
|
|
9587
|
+
export type PromiseReturnType<T extends (...args: any) => $Utils.JsPromise<any>> = PromiseType<ReturnType<T>>
|
|
9268
9588
|
|
|
9269
9589
|
/**
|
|
9270
|
-
*
|
|
9590
|
+
* From T, pick a set of properties whose keys are in the union K
|
|
9271
9591
|
*/
|
|
9272
|
-
type
|
|
9592
|
+
type Prisma__Pick<T, K extends keyof T> = {
|
|
9593
|
+
[P in K]: T[P];
|
|
9594
|
+
};
|
|
9273
9595
|
|
|
9274
9596
|
|
|
9275
|
-
export type
|
|
9597
|
+
export type Enumerable<T> = T | Array<T>;
|
|
9276
9598
|
|
|
9277
|
-
type
|
|
9599
|
+
export type RequiredKeys<T> = {
|
|
9600
|
+
[K in keyof T]-?: {} extends Prisma__Pick<T, K> ? never : K
|
|
9601
|
+
}[keyof T]
|
|
9278
9602
|
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
function buildNullClass(name) {
|
|
9282
|
-
const source = `/**
|
|
9283
|
-
* Type of \`Prisma.${name}\`.
|
|
9284
|
-
*
|
|
9285
|
-
* You cannot use other instances of this class. Please use the \`Prisma.${name}\` value.
|
|
9286
|
-
*
|
|
9287
|
-
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9288
|
-
*/
|
|
9289
|
-
class ${name} {
|
|
9290
|
-
private ${name}: never
|
|
9291
|
-
private constructor()
|
|
9292
|
-
}`;
|
|
9293
|
-
return (0, import_indent_string4.default)(source, TAB_SIZE);
|
|
9603
|
+
export type TruthyKeys<T> = keyof {
|
|
9604
|
+
[K in keyof T as T[K] extends false | undefined | null ? never : K]: K
|
|
9294
9605
|
}
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9606
|
+
|
|
9607
|
+
export type TrueKeys<T> = TruthyKeys<Prisma__Pick<T, RequiredKeys<T>>>
|
|
9608
|
+
|
|
9298
9609
|
/**
|
|
9299
|
-
*
|
|
9610
|
+
* Subset
|
|
9611
|
+
* @desc From \`T\` pick properties that exist in \`U\`. Simple version of Intersection
|
|
9300
9612
|
*/
|
|
9301
|
-
export
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9613
|
+
export type Subset<T, U> = {
|
|
9614
|
+
[key in keyof T]: key extends keyof U ? T[key] : never;
|
|
9615
|
+
};
|
|
9616
|
+
|
|
9617
|
+
/**
|
|
9618
|
+
* SelectSubset
|
|
9619
|
+
* @desc From \`T\` pick properties that exist in \`U\`. Simple version of Intersection.
|
|
9620
|
+
* Additionally, it validates, if both select and include are present. If the case, it errors.
|
|
9621
|
+
*/
|
|
9622
|
+
export type SelectSubset<T, U> = {
|
|
9623
|
+
[key in keyof T]: key extends keyof U ? T[key] : never
|
|
9624
|
+
} &
|
|
9625
|
+
(T extends SelectAndInclude
|
|
9626
|
+
? 'Please either choose \`select\` or \`include\`.'
|
|
9627
|
+
: T extends SelectAndOmit
|
|
9628
|
+
? 'Please either choose \`select\` or \`omit\`.'
|
|
9629
|
+
: {})
|
|
9314
9630
|
|
|
9315
|
-
// src/generation/TSClient/Count.ts
|
|
9316
|
-
var import_indent_string5 = __toESM(require_indent_string());
|
|
9317
|
-
var Count = class {
|
|
9318
|
-
constructor(type, context) {
|
|
9319
|
-
this.type = type;
|
|
9320
|
-
this.context = context;
|
|
9321
|
-
}
|
|
9322
|
-
get argsTypes() {
|
|
9323
|
-
const argsTypes = [];
|
|
9324
|
-
argsTypes.push(
|
|
9325
|
-
new ArgsTypeBuilder(this.type, this.context).addSelectArg().addIncludeArgIfHasRelations().createExport()
|
|
9326
|
-
);
|
|
9327
|
-
for (const field of this.type.fields) {
|
|
9328
|
-
if (field.args.length > 0) {
|
|
9329
|
-
argsTypes.push(
|
|
9330
|
-
new ArgsTypeBuilder(this.type, this.context).addSchemaArgs(field.args).setGeneratedName(getCountArgsType(this.type.name, field.name)).createExport()
|
|
9331
|
-
);
|
|
9332
|
-
}
|
|
9333
|
-
}
|
|
9334
|
-
return argsTypes;
|
|
9335
|
-
}
|
|
9336
|
-
toTS() {
|
|
9337
|
-
const { type } = this;
|
|
9338
|
-
const { name } = type;
|
|
9339
|
-
const outputType = buildOutputType(type);
|
|
9340
|
-
return `
|
|
9341
9631
|
/**
|
|
9342
|
-
*
|
|
9632
|
+
* Subset + Intersection
|
|
9633
|
+
* @desc From \`T\` pick properties that exist in \`U\` and intersect \`K\`
|
|
9343
9634
|
*/
|
|
9635
|
+
export type SubsetIntersection<T, U, K> = {
|
|
9636
|
+
[key in keyof T]: key extends keyof U ? T[key] : never
|
|
9637
|
+
} &
|
|
9638
|
+
K
|
|
9344
9639
|
|
|
9345
|
-
|
|
9640
|
+
export type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
|
|
9346
9641
|
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
}
|
|
9357
|
-
return `${field.name}?: ${types.join(" | ")}`;
|
|
9358
|
-
}).join("\n"),
|
|
9359
|
-
TAB_SIZE
|
|
9360
|
-
)}
|
|
9361
|
-
}
|
|
9642
|
+
/**
|
|
9643
|
+
* XOR is needed to have a real mutually exclusive union type
|
|
9644
|
+
* https://stackoverflow.com/questions/42123407/does-typescript-support-mutually-exclusive-types
|
|
9645
|
+
*/
|
|
9646
|
+
export type XOR<T, U> =
|
|
9647
|
+
T extends object ?
|
|
9648
|
+
U extends object ?
|
|
9649
|
+
(Without<T, U> & U) | (Without<U, T> & T)
|
|
9650
|
+
: U : T
|
|
9362
9651
|
|
|
9363
|
-
// Custom InputTypes
|
|
9364
|
-
${this.argsTypes.map((typeExport) => stringify(typeExport)).join("\n\n")}
|
|
9365
|
-
`;
|
|
9366
|
-
}
|
|
9367
|
-
};
|
|
9368
|
-
function getCountArgsType(typeName, fieldName) {
|
|
9369
|
-
return `${typeName}Count${capitalize2(fieldName)}Args`;
|
|
9370
|
-
}
|
|
9371
9652
|
|
|
9372
|
-
// src/generation/TSClient/FieldRefInput.ts
|
|
9373
|
-
var FieldRefInput = class {
|
|
9374
|
-
constructor(type) {
|
|
9375
|
-
this.type = type;
|
|
9376
|
-
}
|
|
9377
|
-
toTS() {
|
|
9378
|
-
const allowedTypes = this.getAllowedTypes();
|
|
9379
|
-
return `
|
|
9380
9653
|
/**
|
|
9381
|
-
*
|
|
9654
|
+
* Is T a Record?
|
|
9382
9655
|
*/
|
|
9383
|
-
export type
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9656
|
+
export type IsObject<T extends any> = T extends Array<any>
|
|
9657
|
+
? False
|
|
9658
|
+
: T extends Date
|
|
9659
|
+
? False
|
|
9660
|
+
: T extends Uint8Array
|
|
9661
|
+
? False
|
|
9662
|
+
: T extends BigInt
|
|
9663
|
+
? False
|
|
9664
|
+
: T extends object
|
|
9665
|
+
? True
|
|
9666
|
+
: False
|
|
9390
9667
|
|
|
9391
|
-
// src/generation/TSClient/GenerateContext.ts
|
|
9392
|
-
var GenerateContext = class {
|
|
9393
|
-
constructor({ dmmf, genericArgsInfo, generator }) {
|
|
9394
|
-
this.dmmf = dmmf;
|
|
9395
|
-
this.genericArgsInfo = genericArgsInfo;
|
|
9396
|
-
this.generator = generator;
|
|
9397
|
-
}
|
|
9398
|
-
isPreviewFeatureOn(previewFeature) {
|
|
9399
|
-
return this.generator?.previewFeatures?.includes(previewFeature) ?? false;
|
|
9400
|
-
}
|
|
9401
|
-
};
|
|
9402
9668
|
|
|
9403
|
-
|
|
9404
|
-
|
|
9669
|
+
/**
|
|
9670
|
+
* If it's T[], return T
|
|
9671
|
+
*/
|
|
9672
|
+
export type UnEnumerate<T extends unknown> = T extends Array<infer U> ? U : T
|
|
9405
9673
|
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
}
|
|
9410
|
-
function runtimeImportedType(name) {
|
|
9411
|
-
return namedType(`runtime.${name}`);
|
|
9412
|
-
}
|
|
9674
|
+
/**
|
|
9675
|
+
* From ts-toolbelt
|
|
9676
|
+
*/
|
|
9413
9677
|
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
}
|
|
9420
|
-
toTS() {
|
|
9421
|
-
const sources = this.internalDatasources;
|
|
9422
|
-
return `export type Datasources = {
|
|
9423
|
-
${(0, import_indent_string6.default)(sources.map((s) => `${s.name}?: Datasource`).join("\n"), 2)}
|
|
9424
|
-
}`;
|
|
9425
|
-
}
|
|
9426
|
-
};
|
|
9678
|
+
type __Either<O extends object, K extends Key> = Omit<O, K> &
|
|
9679
|
+
{
|
|
9680
|
+
// Merge all but K
|
|
9681
|
+
[P in K]: Prisma__Pick<O, P & keyof O> // With K possibilities
|
|
9682
|
+
}[K]
|
|
9427
9683
|
|
|
9428
|
-
|
|
9429
|
-
function globalOmitConfig(dmmf) {
|
|
9430
|
-
const objectType2 = objectType().addMultiple(
|
|
9431
|
-
dmmf.datamodel.models.map((model) => {
|
|
9432
|
-
const type = namedType(getOmitName(model.name));
|
|
9433
|
-
return property(lowerCase(model.name), type).optional();
|
|
9434
|
-
})
|
|
9435
|
-
);
|
|
9436
|
-
return moduleExport(typeDeclaration("GlobalOmitConfig", objectType2));
|
|
9437
|
-
}
|
|
9684
|
+
type EitherStrict<O extends object, K extends Key> = Strict<__Either<O, K>>
|
|
9438
9685
|
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
if (action === "updateMany") return namedType("BatchPayload");
|
|
9486
|
-
if (action === "updateManyAndReturn") return array(payloadToResult(modelName));
|
|
9487
|
-
if (action === "findMany") return array(payloadToResult(modelName));
|
|
9488
|
-
if (action === "findFirst") return unionType([payloadToResult(modelName), nullType]);
|
|
9489
|
-
if (action === "findUnique") return unionType([payloadToResult(modelName), nullType]);
|
|
9490
|
-
if (action === "findFirstOrThrow") return payloadToResult(modelName);
|
|
9491
|
-
if (action === "findUniqueOrThrow") return payloadToResult(modelName);
|
|
9492
|
-
if (action === "create") return payloadToResult(modelName);
|
|
9493
|
-
if (action === "update") return payloadToResult(modelName);
|
|
9494
|
-
if (action === "upsert") return payloadToResult(modelName);
|
|
9495
|
-
if (action === "delete") return payloadToResult(modelName);
|
|
9496
|
-
assertNever(action, `Unknown action: ${action}`);
|
|
9497
|
-
}
|
|
9498
|
-
function payloadToResult(modelName) {
|
|
9499
|
-
return namedType("$Utils.PayloadToResult").addGenericArgument(namedType(getPayloadName(modelName)));
|
|
9500
|
-
}
|
|
9501
|
-
function clientTypeMapOthersDefinition(context) {
|
|
9502
|
-
const otherOperationsNames = context.dmmf.getOtherOperationNames().flatMap((name) => {
|
|
9503
|
-
const results = [`$${name}`];
|
|
9504
|
-
if (name === "executeRaw" || name === "queryRaw") {
|
|
9505
|
-
results.push(`$${name}Unsafe`);
|
|
9506
|
-
}
|
|
9507
|
-
if (name === "queryRaw" && context.isPreviewFeatureOn("typedSql")) {
|
|
9508
|
-
results.push(`$queryRawTyped`);
|
|
9509
|
-
}
|
|
9510
|
-
return results;
|
|
9511
|
-
});
|
|
9512
|
-
const argsResultMap = {
|
|
9513
|
-
$executeRaw: { args: "[query: TemplateStringsArray | Prisma.Sql, ...values: any[]]", result: "any" },
|
|
9514
|
-
$queryRaw: { args: "[query: TemplateStringsArray | Prisma.Sql, ...values: any[]]", result: "any" },
|
|
9515
|
-
$executeRawUnsafe: { args: "[query: string, ...values: any[]]", result: "any" },
|
|
9516
|
-
$queryRawUnsafe: { args: "[query: string, ...values: any[]]", result: "any" },
|
|
9517
|
-
$runCommandRaw: { args: "Prisma.InputJsonObject", result: "Prisma.JsonObject" },
|
|
9518
|
-
$queryRawTyped: { args: "runtime.UnknownTypedSql", result: "Prisma.JsonObject" }
|
|
9519
|
-
};
|
|
9520
|
-
return `{
|
|
9521
|
-
other: {
|
|
9522
|
-
payload: any
|
|
9523
|
-
operations: {${otherOperationsNames.reduce((acc, action) => {
|
|
9524
|
-
return `${acc}
|
|
9525
|
-
${action}: {
|
|
9526
|
-
args: ${argsResultMap[action].args},
|
|
9527
|
-
result: ${argsResultMap[action].result}
|
|
9528
|
-
}`;
|
|
9529
|
-
}, "")}
|
|
9530
|
-
}
|
|
9531
|
-
}
|
|
9532
|
-
}`;
|
|
9533
|
-
}
|
|
9534
|
-
function clientTypeMapDefinition(context) {
|
|
9535
|
-
const typeMap = `${stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
|
|
9536
|
-
return `
|
|
9537
|
-
interface TypeMapCb extends $Utils.Fn<{extArgs: $Extensions.InternalArgs, clientOptions: PrismaClientOptions }, $Utils.Record<string, any>> {
|
|
9538
|
-
returns: Prisma.TypeMap<this['params']['extArgs'], this['params']['clientOptions']>
|
|
9539
|
-
}
|
|
9686
|
+
type EitherLoose<O extends object, K extends Key> = ComputeRaw<__Either<O, K>>
|
|
9687
|
+
|
|
9688
|
+
type _Either<
|
|
9689
|
+
O extends object,
|
|
9690
|
+
K extends Key,
|
|
9691
|
+
strict extends Boolean
|
|
9692
|
+
> = {
|
|
9693
|
+
1: EitherStrict<O, K>
|
|
9694
|
+
0: EitherLoose<O, K>
|
|
9695
|
+
}[strict]
|
|
9696
|
+
|
|
9697
|
+
export type Either<
|
|
9698
|
+
O extends object,
|
|
9699
|
+
K extends Key,
|
|
9700
|
+
strict extends Boolean = 1
|
|
9701
|
+
> = O extends unknown ? _Either<O, K, strict> : never
|
|
9702
|
+
|
|
9703
|
+
export type Union = any
|
|
9704
|
+
|
|
9705
|
+
export type PatchUndefined<O extends object, O1 extends object> = {
|
|
9706
|
+
[K in keyof O]: O[K] extends undefined ? At<O1, K> : O[K]
|
|
9707
|
+
} & {}
|
|
9708
|
+
|
|
9709
|
+
/** Helper Types for "Merge" **/
|
|
9710
|
+
export type IntersectOf<U extends Union> = (
|
|
9711
|
+
U extends unknown ? (k: U) => void : never
|
|
9712
|
+
) extends (k: infer I) => void
|
|
9713
|
+
? I
|
|
9714
|
+
: never
|
|
9715
|
+
|
|
9716
|
+
export type Overwrite<O extends object, O1 extends object> = {
|
|
9717
|
+
[K in keyof O]: K extends keyof O1 ? O1[K] : O[K];
|
|
9718
|
+
} & {};
|
|
9719
|
+
|
|
9720
|
+
type _Merge<U extends object> = IntersectOf<Overwrite<U, {
|
|
9721
|
+
[K in keyof U]-?: At<U, K>;
|
|
9722
|
+
}>>;
|
|
9723
|
+
|
|
9724
|
+
type Key = string | number | symbol;
|
|
9725
|
+
type AtBasic<O extends object, K extends Key> = K extends keyof O ? O[K] : never;
|
|
9726
|
+
type AtStrict<O extends object, K extends Key> = O[K & keyof O];
|
|
9727
|
+
type AtLoose<O extends object, K extends Key> = O extends unknown ? AtStrict<O, K> : never;
|
|
9728
|
+
export type At<O extends object, K extends Key, strict extends Boolean = 1> = {
|
|
9729
|
+
1: AtStrict<O, K>;
|
|
9730
|
+
0: AtLoose<O, K>;
|
|
9731
|
+
}[strict];
|
|
9540
9732
|
|
|
9541
|
-
export type
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
const typeMap = clientTypeMapDefinition(context);
|
|
9545
|
-
const define2 = moduleExport(
|
|
9546
|
-
constDeclaration(
|
|
9547
|
-
"defineExtension",
|
|
9548
|
-
namedType("$Extensions.ExtendsHook").addGenericArgument(stringLiteral("define")).addGenericArgument(namedType("Prisma.TypeMapCb")).addGenericArgument(namedType("$Extensions.DefaultArgs"))
|
|
9549
|
-
)
|
|
9550
|
-
);
|
|
9551
|
-
return [typeMap, stringify(define2)].join("\n");
|
|
9552
|
-
}
|
|
9553
|
-
function extendsPropertyDefinition() {
|
|
9554
|
-
const extendsDefinition = namedType("$Extensions.ExtendsHook").addGenericArgument(stringLiteral("extends")).addGenericArgument(namedType("Prisma.TypeMapCb")).addGenericArgument(namedType("ExtArgs")).addGenericArgument(
|
|
9555
|
-
namedType("$Utils.Call").addGenericArgument(namedType("Prisma.TypeMapCb")).addGenericArgument(objectType().add(property("extArgs", namedType("ExtArgs"))))
|
|
9556
|
-
).addGenericArgument(namedType("ClientOptions"));
|
|
9557
|
-
return stringify(property("$extends", extendsDefinition), { indentLevel: 1 });
|
|
9558
|
-
}
|
|
9559
|
-
function batchingTransactionDefinition(context) {
|
|
9560
|
-
const method2 = method("$transaction").setDocComment(
|
|
9561
|
-
docComment`
|
|
9562
|
-
Allows the running of a sequence of read/write operations that are guaranteed to either succeed or fail as a whole.
|
|
9563
|
-
@example
|
|
9564
|
-
\`\`\`
|
|
9565
|
-
const [george, bob, alice] = await prisma.$transaction([
|
|
9566
|
-
prisma.user.create({ data: { name: 'George' } }),
|
|
9567
|
-
prisma.user.create({ data: { name: 'Bob' } }),
|
|
9568
|
-
prisma.user.create({ data: { name: 'Alice' } }),
|
|
9569
|
-
])
|
|
9570
|
-
\`\`\`
|
|
9733
|
+
export type ComputeRaw<A extends any> = A extends Function ? A : {
|
|
9734
|
+
[K in keyof A]: A[K];
|
|
9735
|
+
} & {};
|
|
9571
9736
|
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
9576
|
-
const options = objectType().formatInline().add(property("isolationLevel", namedType("Prisma.TransactionIsolationLevel")).optional());
|
|
9577
|
-
method2.addParameter(parameter("options", options).optional());
|
|
9578
|
-
}
|
|
9579
|
-
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
9580
|
-
}
|
|
9581
|
-
function interactiveTransactionDefinition(context) {
|
|
9582
|
-
const options = objectType().formatInline().add(property("maxWait", numberType).optional()).add(property("timeout", numberType).optional());
|
|
9583
|
-
if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
9584
|
-
const isolationLevel = property("isolationLevel", namedType("Prisma.TransactionIsolationLevel")).optional();
|
|
9585
|
-
options.add(isolationLevel);
|
|
9586
|
-
}
|
|
9587
|
-
const returnType = promise(namedType("R"));
|
|
9588
|
-
const callbackType = functionType().addParameter(
|
|
9589
|
-
parameter("prisma", omit(namedType("PrismaClient"), namedType("runtime.ITXClientDenyList")))
|
|
9590
|
-
).setReturnType(returnType);
|
|
9591
|
-
const method2 = method("$transaction").addGenericParameter(genericParameter("R")).addParameter(parameter("fn", callbackType)).addParameter(parameter("options", options).optional()).setReturnType(returnType);
|
|
9592
|
-
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
9593
|
-
}
|
|
9594
|
-
function queryRawDefinition(context) {
|
|
9595
|
-
if (!context.dmmf.mappings.otherOperations.write.includes("queryRaw")) {
|
|
9596
|
-
return "";
|
|
9597
|
-
}
|
|
9598
|
-
return `
|
|
9599
|
-
/**
|
|
9600
|
-
* Performs a prepared raw query and returns the \`SELECT\` data.
|
|
9601
|
-
* @example
|
|
9602
|
-
* \`\`\`
|
|
9603
|
-
* const result = await prisma.$queryRaw\`SELECT * FROM User WHERE id = \${1} OR email = \${'user@email.com'};\`
|
|
9604
|
-
* \`\`\`
|
|
9605
|
-
*
|
|
9606
|
-
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
9607
|
-
*/
|
|
9608
|
-
$queryRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<T>;
|
|
9737
|
+
export type OptionalFlat<O> = {
|
|
9738
|
+
[K in keyof O]?: O[K];
|
|
9739
|
+
} & {};
|
|
9609
9740
|
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
* @example
|
|
9614
|
-
* \`\`\`
|
|
9615
|
-
* const result = await prisma.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com')
|
|
9616
|
-
* \`\`\`
|
|
9617
|
-
*
|
|
9618
|
-
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
9619
|
-
*/
|
|
9620
|
-
$queryRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<T>;`;
|
|
9621
|
-
}
|
|
9622
|
-
function executeRawDefinition(context) {
|
|
9623
|
-
if (!context.dmmf.mappings.otherOperations.write.includes("executeRaw")) {
|
|
9624
|
-
return "";
|
|
9625
|
-
}
|
|
9626
|
-
return `
|
|
9627
|
-
/**
|
|
9628
|
-
* Executes a prepared raw query and returns the number of affected rows.
|
|
9629
|
-
* @example
|
|
9630
|
-
* \`\`\`
|
|
9631
|
-
* const result = await prisma.$executeRaw\`UPDATE User SET cool = \${true} WHERE email = \${'user@email.com'};\`
|
|
9632
|
-
* \`\`\`
|
|
9633
|
-
*
|
|
9634
|
-
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
9635
|
-
*/
|
|
9636
|
-
$executeRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<number>;
|
|
9741
|
+
type _Record<K extends keyof any, T> = {
|
|
9742
|
+
[P in K]: T;
|
|
9743
|
+
};
|
|
9637
9744
|
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9745
|
+
// cause typescript not to expand types and preserve names
|
|
9746
|
+
type NoExpand<T> = T extends unknown ? T : never;
|
|
9747
|
+
|
|
9748
|
+
// this type assumes the passed object is entirely optional
|
|
9749
|
+
export type AtLeast<O extends object, K extends string> = NoExpand<
|
|
9750
|
+
O extends unknown
|
|
9751
|
+
? | (K extends keyof O ? { [P in K]: O[P] } & O : O)
|
|
9752
|
+
| {[P in keyof O as P extends K ? K : never]-?: O[P]} & O
|
|
9753
|
+
: never>;
|
|
9754
|
+
|
|
9755
|
+
type _Strict<U, _U = U> = U extends unknown ? U & OptionalFlat<_Record<Exclude<Keys<_U>, keyof U>, never>> : never;
|
|
9756
|
+
|
|
9757
|
+
export type Strict<U extends object> = ComputeRaw<_Strict<U>>;
|
|
9758
|
+
/** End Helper Types for "Merge" **/
|
|
9759
|
+
|
|
9760
|
+
export type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>;
|
|
9761
|
+
|
|
9762
|
+
/**
|
|
9763
|
+
A [[Boolean]]
|
|
9764
|
+
*/
|
|
9765
|
+
export type Boolean = True | False
|
|
9766
|
+
|
|
9767
|
+
// /**
|
|
9768
|
+
// 1
|
|
9769
|
+
// */
|
|
9770
|
+
export type True = 1
|
|
9771
|
+
|
|
9772
|
+
/**
|
|
9773
|
+
0
|
|
9774
|
+
*/
|
|
9775
|
+
export type False = 0
|
|
9776
|
+
|
|
9777
|
+
export type Not<B extends Boolean> = {
|
|
9778
|
+
0: 1
|
|
9779
|
+
1: 0
|
|
9780
|
+
}[B]
|
|
9781
|
+
|
|
9782
|
+
export type Extends<A1 extends any, A2 extends any> = [A1] extends [never]
|
|
9783
|
+
? 0 // anything \`never\` is false
|
|
9784
|
+
: A1 extends A2
|
|
9785
|
+
? 1
|
|
9786
|
+
: 0
|
|
9787
|
+
|
|
9788
|
+
export type Has<U extends Union, U1 extends Union> = Not<
|
|
9789
|
+
Extends<Exclude<U1, U>, U1>
|
|
9790
|
+
>
|
|
9791
|
+
|
|
9792
|
+
export type Or<B1 extends Boolean, B2 extends Boolean> = {
|
|
9793
|
+
0: {
|
|
9794
|
+
0: 0
|
|
9795
|
+
1: 1
|
|
9653
9796
|
}
|
|
9654
|
-
|
|
9655
|
-
|
|
9797
|
+
1: {
|
|
9798
|
+
0: 1
|
|
9799
|
+
1: 1
|
|
9656
9800
|
}
|
|
9657
|
-
|
|
9658
|
-
const method2 = method("$queryRawTyped").setDocComment(
|
|
9659
|
-
docComment`
|
|
9660
|
-
Executes a typed SQL query and returns a typed result
|
|
9661
|
-
@example
|
|
9662
|
-
\`\`\`
|
|
9663
|
-
import { myQuery } from '@prisma/client/sql'
|
|
9801
|
+
}[B1][B2]
|
|
9664
9802
|
|
|
9665
|
-
|
|
9666
|
-
\`\`\`
|
|
9667
|
-
`
|
|
9668
|
-
).addGenericParameter(param).addParameter(
|
|
9669
|
-
parameter(
|
|
9670
|
-
"typedSql",
|
|
9671
|
-
runtimeImportedType("TypedSql").addGenericArgument(array(unknownType)).addGenericArgument(param.toArgument())
|
|
9672
|
-
)
|
|
9673
|
-
).setReturnType(prismaPromise(array(param.toArgument())));
|
|
9674
|
-
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
9675
|
-
}
|
|
9676
|
-
function metricDefinition(context) {
|
|
9677
|
-
if (!context.isPreviewFeatureOn("metrics")) {
|
|
9678
|
-
return "";
|
|
9679
|
-
}
|
|
9680
|
-
const property2 = property("$metrics", namedType(`runtime.${runtimeImport("MetricsClient")}`)).setDocComment(
|
|
9681
|
-
docComment`
|
|
9682
|
-
Gives access to the client metrics in json or prometheus format.
|
|
9803
|
+
export type Keys<U extends Union> = U extends unknown ? keyof U : never
|
|
9683
9804
|
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9805
|
+
type Cast<A, B> = A extends B ? A : B;
|
|
9806
|
+
|
|
9807
|
+
export const type: unique symbol;
|
|
9808
|
+
|
|
9809
|
+
|
|
9810
|
+
|
|
9811
|
+
/**
|
|
9812
|
+
* Used by group by
|
|
9813
|
+
*/
|
|
9814
|
+
|
|
9815
|
+
export type GetScalarType<T, O> = O extends object ? {
|
|
9816
|
+
[P in keyof T]: P extends keyof O
|
|
9817
|
+
? O[P]
|
|
9818
|
+
: never
|
|
9819
|
+
} : never
|
|
9820
|
+
|
|
9821
|
+
type FieldPaths<
|
|
9822
|
+
T,
|
|
9823
|
+
U = Omit<T, '_avg' | '_sum' | '_count' | '_min' | '_max'>
|
|
9824
|
+
> = IsObject<T> extends True ? U : T
|
|
9825
|
+
|
|
9826
|
+
export type GetHavingFields<T> = {
|
|
9827
|
+
[K in keyof T]: Or<
|
|
9828
|
+
Or<Extends<'OR', K>, Extends<'AND', K>>,
|
|
9829
|
+
Extends<'NOT', K>
|
|
9830
|
+
> extends True
|
|
9831
|
+
? // infer is only needed to not hit TS limit
|
|
9832
|
+
// based on the brilliant idea of Pierre-Antoine Mills
|
|
9833
|
+
// https://github.com/microsoft/TypeScript/issues/30188#issuecomment-478938437
|
|
9834
|
+
T[K] extends infer TK
|
|
9835
|
+
? GetHavingFields<UnEnumerate<TK> extends object ? Merge<UnEnumerate<TK>> : never>
|
|
9836
|
+
: never
|
|
9837
|
+
: {} extends FieldPaths<T[K]>
|
|
9838
|
+
? never
|
|
9839
|
+
: K
|
|
9840
|
+
}[keyof T]
|
|
9708
9841
|
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9842
|
+
/**
|
|
9843
|
+
* Convert tuple to union
|
|
9844
|
+
*/
|
|
9845
|
+
type _TupleToUnion<T> = T extends (infer E)[] ? E : never
|
|
9846
|
+
type TupleToUnion<K extends readonly any[]> = _TupleToUnion<K>
|
|
9847
|
+
export type MaybeTupleToUnion<T> = T extends any[] ? TupleToUnion<T> : T
|
|
9848
|
+
|
|
9849
|
+
/**
|
|
9850
|
+
* Like \`Pick\`, but additionally can also accept an array of keys
|
|
9851
|
+
*/
|
|
9852
|
+
export type PickEnumerable<T, K extends Enumerable<keyof T> | keyof T> = Prisma__Pick<T, MaybeTupleToUnion<K>>
|
|
9853
|
+
|
|
9854
|
+
/**
|
|
9855
|
+
* Exclude all keys with underscores
|
|
9856
|
+
*/
|
|
9857
|
+
export type ExcludeUnderscoreKeys<T extends string> = T extends \`_\${string}\` ? never : T
|
|
9858
|
+
|
|
9859
|
+
|
|
9860
|
+
export type FieldRef<Model, FieldType> = runtime.FieldRef<Model, FieldType>
|
|
9861
|
+
|
|
9862
|
+
type FieldRefInputType<Model, FieldType> = Model extends never ? never : FieldRef<Model, FieldType>
|
|
9863
|
+
|
|
9864
|
+
`
|
|
9865
|
+
});
|
|
9866
|
+
function buildNullClass(name) {
|
|
9867
|
+
const source = `/**
|
|
9868
|
+
* Type of \`Prisma.${name}\`.
|
|
9869
|
+
*
|
|
9870
|
+
* You cannot use other instances of this class. Please use the \`Prisma.${name}\` value.
|
|
9871
|
+
*
|
|
9872
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9873
|
+
*/
|
|
9874
|
+
class ${name} {
|
|
9875
|
+
private ${name}: never
|
|
9876
|
+
private constructor()
|
|
9877
|
+
}`;
|
|
9878
|
+
return (0, import_indent_string6.default)(source, TAB_SIZE);
|
|
9712
9879
|
}
|
|
9713
|
-
function
|
|
9714
|
-
if (
|
|
9715
|
-
return
|
|
9880
|
+
function buildPrismaSkipTs(previewFeatures) {
|
|
9881
|
+
if (previewFeatures.includes("strictUndefinedChecks")) {
|
|
9882
|
+
return `
|
|
9883
|
+
/**
|
|
9884
|
+
* Prisma.skip
|
|
9885
|
+
*/
|
|
9886
|
+
export import skip = runtime.skip
|
|
9887
|
+
`;
|
|
9716
9888
|
}
|
|
9717
|
-
|
|
9718
|
-
docComment`Tries to apply pending migrations one by one. If a migration fails to apply, the function will stop and throw an error. You are responsible for informing the user and possibly blocking the app as we cannot guarantee the state of the database.`
|
|
9719
|
-
);
|
|
9720
|
-
return stringify(method2, { indentLevel: 1, newLine: "leading" });
|
|
9889
|
+
return "";
|
|
9721
9890
|
}
|
|
9722
|
-
function
|
|
9723
|
-
if (
|
|
9724
|
-
return
|
|
9725
|
-
|
|
9726
|
-
|
|
9891
|
+
function buildPrismaSkipJs(previewFeatures) {
|
|
9892
|
+
if (previewFeatures.includes("strictUndefinedChecks")) {
|
|
9893
|
+
return `
|
|
9894
|
+
Prisma.skip = skip
|
|
9895
|
+
`;
|
|
9727
9896
|
}
|
|
9897
|
+
return "";
|
|
9728
9898
|
}
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
this.
|
|
9734
|
-
this.runtimeNameTs = runtimeNameTs;
|
|
9735
|
-
this.browser = browser;
|
|
9899
|
+
|
|
9900
|
+
// src/generation/TSClient/FieldRefInput.ts
|
|
9901
|
+
var FieldRefInput = class {
|
|
9902
|
+
constructor(type) {
|
|
9903
|
+
this.type = type;
|
|
9736
9904
|
}
|
|
9737
|
-
|
|
9738
|
-
const
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
plural: "users"
|
|
9746
|
-
};
|
|
9747
|
-
}
|
|
9748
|
-
return `/**
|
|
9749
|
-
* ## Prisma Client \u02B2\u02E2
|
|
9750
|
-
*
|
|
9751
|
-
* Type-safe database client for TypeScript & Node.js
|
|
9752
|
-
* @example
|
|
9753
|
-
* \`\`\`
|
|
9754
|
-
* const prisma = new PrismaClient()
|
|
9755
|
-
* // Fetch zero or more ${capitalize2(example.plural)}
|
|
9756
|
-
* const ${lowerCase(example.plural)} = await prisma.${lowerCase(example.model)}.findMany()
|
|
9757
|
-
* \`\`\`
|
|
9758
|
-
*
|
|
9759
|
-
*
|
|
9760
|
-
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
|
|
9761
|
-
*/`;
|
|
9905
|
+
toTS() {
|
|
9906
|
+
const allowedTypes = this.getAllowedTypes();
|
|
9907
|
+
return `
|
|
9908
|
+
/**
|
|
9909
|
+
* Reference to a field of type ${allowedTypes}
|
|
9910
|
+
*/
|
|
9911
|
+
export type ${this.type.name}<$PrismaModel> = FieldRefInputType<$PrismaModel, ${allowedTypes}>
|
|
9912
|
+
`;
|
|
9762
9913
|
}
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
|
|
9768
|
-
U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
|
|
9769
|
-
ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs
|
|
9770
|
-
> {
|
|
9771
|
-
[K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
|
|
9772
|
-
|
|
9773
|
-
${(0, import_indent_string7.default)(this.jsDoc, TAB_SIZE)}
|
|
9774
|
-
|
|
9775
|
-
constructor(optionsArg ?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>);
|
|
9776
|
-
${eventRegistrationMethodDeclaration(this.runtimeNameTs)}
|
|
9914
|
+
getAllowedTypes() {
|
|
9915
|
+
return this.type.allowTypes.map(getRefAllowedTypeName).join(" | ");
|
|
9916
|
+
}
|
|
9917
|
+
};
|
|
9777
9918
|
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9919
|
+
// src/generation/TSClient/CommonFile.ts
|
|
9920
|
+
function createCommonFile(context, options) {
|
|
9921
|
+
const prismaClientClass = new PrismaClientClass(
|
|
9922
|
+
context,
|
|
9923
|
+
options.datasources,
|
|
9924
|
+
options.outputDir,
|
|
9925
|
+
options.runtimeNameTs,
|
|
9926
|
+
options.browser
|
|
9927
|
+
);
|
|
9928
|
+
const commonCode = commonCodeTS(options);
|
|
9929
|
+
const prismaEnums = context.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toTS());
|
|
9930
|
+
const fieldRefs = context.dmmf.schema.fieldRefTypes.prisma?.map((type) => new FieldRefInput(type).toTS()) ?? [];
|
|
9931
|
+
return `
|
|
9932
|
+
import * as runtime from '${context.runtimeJsPath}';
|
|
9933
|
+
import $Types = runtime.Types // general types
|
|
9934
|
+
import $Public = runtime.Types.Public
|
|
9935
|
+
import $Utils = runtime.Types.Utils
|
|
9936
|
+
import $Extensions = runtime.Types.Extensions
|
|
9937
|
+
import $Result = runtime.Types.Result
|
|
9782
9938
|
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
*/
|
|
9786
|
-
$disconnect(): $Utils.JsPromise<void>;
|
|
9939
|
+
import type * as Prisma from './models';
|
|
9940
|
+
import type { PrismaClient } from './client';
|
|
9787
9941
|
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9942
|
+
export type * from './models';
|
|
9943
|
+
|
|
9944
|
+
${commonCode.ts()}
|
|
9945
|
+
${new Enum(
|
|
9946
|
+
{
|
|
9947
|
+
name: "ModelName",
|
|
9948
|
+
values: context.dmmf.mappings.modelOperations.map((m) => m.model)
|
|
9949
|
+
},
|
|
9950
|
+
true
|
|
9951
|
+
).toTS()}
|
|
9794
9952
|
|
|
9795
|
-
${
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
batchingTransactionDefinition(this.context),
|
|
9800
|
-
interactiveTransactionDefinition(this.context),
|
|
9801
|
-
runCommandRawDefinition(this.context),
|
|
9802
|
-
metricDefinition(this.context),
|
|
9803
|
-
applyPendingMigrationsDefinition.bind(this)(),
|
|
9804
|
-
extendsPropertyDefinition()
|
|
9805
|
-
].filter((d) => d !== null).join("\n").trim()}
|
|
9953
|
+
${prismaClientClass.toTS()}
|
|
9954
|
+
export type Datasource = {
|
|
9955
|
+
url?: string
|
|
9956
|
+
}
|
|
9806
9957
|
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
if (methodName === "constructor") {
|
|
9811
|
-
methodName = '["constructor"]';
|
|
9812
|
-
}
|
|
9813
|
-
const generics = ["ExtArgs", "ClientOptions"];
|
|
9814
|
-
return `/**
|
|
9815
|
-
* \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
|
|
9816
|
-
* Example usage:
|
|
9817
|
-
* \`\`\`ts
|
|
9818
|
-
* // Fetch zero or more ${capitalize2(m.plural)}
|
|
9819
|
-
* const ${lowerCase(m.plural)} = await prisma.${methodName}.findMany()
|
|
9820
|
-
* \`\`\`
|
|
9821
|
-
*/
|
|
9822
|
-
get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
|
|
9823
|
-
}).join("\n\n"),
|
|
9824
|
-
2
|
|
9825
|
-
)}
|
|
9826
|
-
}`;
|
|
9827
|
-
}
|
|
9828
|
-
toTS() {
|
|
9829
|
-
const clientOptions = this.buildClientOptions();
|
|
9830
|
-
return `${new Datasources(this.internalDatasources).toTS()}
|
|
9831
|
-
${clientExtensionsDefinitions(this.context)}
|
|
9832
|
-
export type DefaultPrismaClient = PrismaClient
|
|
9833
|
-
export type ErrorFormat = 'pretty' | 'colorless' | 'minimal'
|
|
9834
|
-
${stringify(moduleExport(clientOptions))}
|
|
9835
|
-
${stringify(globalOmitConfig(this.context.dmmf))}
|
|
9958
|
+
/**
|
|
9959
|
+
* Enums
|
|
9960
|
+
*/
|
|
9836
9961
|
|
|
9837
|
-
|
|
9838
|
-
export type LogLevel = 'info' | 'query' | 'warn' | 'error'
|
|
9839
|
-
export type LogDefinition = {
|
|
9840
|
-
level: LogLevel
|
|
9841
|
-
emit: 'stdout' | 'event'
|
|
9842
|
-
}
|
|
9962
|
+
${prismaEnums?.join("\n\n")}
|
|
9843
9963
|
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9964
|
+
${fieldRefs.length > 0 ? `
|
|
9965
|
+
/**
|
|
9966
|
+
* Field references
|
|
9967
|
+
*/
|
|
9848
9968
|
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
duration: number
|
|
9854
|
-
target: string
|
|
9855
|
-
}
|
|
9969
|
+
${fieldRefs.join("\n\n")}` : ""}
|
|
9970
|
+
/**
|
|
9971
|
+
* Deep Input Types
|
|
9972
|
+
*/
|
|
9856
9973
|
|
|
9857
|
-
|
|
9858
|
-
timestamp: Date
|
|
9859
|
-
message: string
|
|
9860
|
-
target: string
|
|
9861
|
-
}
|
|
9862
|
-
/* End Types for Logging */
|
|
9974
|
+
${context.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputType, context).toTS()).join("\n") ?? ""}
|
|
9863
9975
|
|
|
9976
|
+
/**
|
|
9977
|
+
* Batch Payload for updateMany & deleteMany & createMany
|
|
9978
|
+
*/
|
|
9864
9979
|
|
|
9865
|
-
export type
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
| 'findMany'
|
|
9869
|
-
| 'findFirst'
|
|
9870
|
-
| 'findFirstOrThrow'
|
|
9871
|
-
| 'create'
|
|
9872
|
-
| 'createMany'
|
|
9873
|
-
| 'createManyAndReturn'
|
|
9874
|
-
| 'update'
|
|
9875
|
-
| 'updateMany'
|
|
9876
|
-
| 'updateManyAndReturn'
|
|
9877
|
-
| 'upsert'
|
|
9878
|
-
| 'delete'
|
|
9879
|
-
| 'deleteMany'
|
|
9880
|
-
| 'executeRaw'
|
|
9881
|
-
| 'queryRaw'
|
|
9882
|
-
| 'aggregate'
|
|
9883
|
-
| 'count'
|
|
9884
|
-
| 'runCommandRaw'
|
|
9885
|
-
| 'findRaw'
|
|
9886
|
-
| 'groupBy'
|
|
9980
|
+
export type BatchPayload = {
|
|
9981
|
+
count: number
|
|
9982
|
+
}
|
|
9887
9983
|
|
|
9888
9984
|
/**
|
|
9889
|
-
*
|
|
9985
|
+
* DMMF
|
|
9890
9986
|
*/
|
|
9891
|
-
export
|
|
9892
|
-
|
|
9893
|
-
action: PrismaAction
|
|
9894
|
-
args: any
|
|
9895
|
-
dataPath: string[]
|
|
9896
|
-
runInTransaction: boolean
|
|
9987
|
+
export const dmmf: runtime.BaseDMMF
|
|
9988
|
+
`;
|
|
9897
9989
|
}
|
|
9898
9990
|
|
|
9991
|
+
// src/generation/TSClient/Count.ts
|
|
9992
|
+
var import_indent_string7 = __toESM(require_indent_string());
|
|
9993
|
+
var Count = class {
|
|
9994
|
+
constructor(type, context) {
|
|
9995
|
+
this.type = type;
|
|
9996
|
+
this.context = context;
|
|
9997
|
+
}
|
|
9998
|
+
get argsTypes() {
|
|
9999
|
+
const argsTypes = [];
|
|
10000
|
+
argsTypes.push(
|
|
10001
|
+
new ArgsTypeBuilder(this.type, this.context).addSelectArg().addIncludeArgIfHasRelations().createExport()
|
|
10002
|
+
);
|
|
10003
|
+
for (const field of this.type.fields) {
|
|
10004
|
+
if (field.args.length > 0) {
|
|
10005
|
+
argsTypes.push(
|
|
10006
|
+
new ArgsTypeBuilder(this.type, this.context).addSchemaArgs(field.args).setGeneratedName(getCountArgsType(this.type.name, field.name)).createExport()
|
|
10007
|
+
);
|
|
10008
|
+
}
|
|
10009
|
+
}
|
|
10010
|
+
return argsTypes;
|
|
10011
|
+
}
|
|
10012
|
+
toTS() {
|
|
10013
|
+
const { type } = this;
|
|
10014
|
+
const { name } = type;
|
|
10015
|
+
const outputType = buildOutputType(type);
|
|
10016
|
+
return `
|
|
9899
10017
|
/**
|
|
9900
|
-
*
|
|
10018
|
+
* Count Type ${name}
|
|
9901
10019
|
*/
|
|
9902
|
-
export type Middleware<T = any> = (
|
|
9903
|
-
params: MiddlewareParams,
|
|
9904
|
-
next: (params: MiddlewareParams) => $Utils.JsPromise<T>,
|
|
9905
|
-
) => $Utils.JsPromise<T>
|
|
9906
10020
|
|
|
9907
|
-
|
|
9908
|
-
export function getLogLevel(log: Array<LogLevel | LogDefinition>): LogLevel | undefined;
|
|
10021
|
+
${stringify(outputType)}
|
|
9909
10022
|
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
10023
|
+
export type ${getSelectName(name)}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
|
|
10024
|
+
${(0, import_indent_string7.default)(
|
|
10025
|
+
type.fields.map((field) => {
|
|
10026
|
+
const types = ["boolean"];
|
|
10027
|
+
if (field.outputType.location === "outputObjectTypes") {
|
|
10028
|
+
types.push(getFieldArgName(field, this.type.name));
|
|
10029
|
+
}
|
|
10030
|
+
if (field.args.length > 0) {
|
|
10031
|
+
types.push(getCountArgsType(name, field.name));
|
|
10032
|
+
}
|
|
10033
|
+
return `${field.name}?: ${types.join(" | ")}`;
|
|
10034
|
+
}).join("\n"),
|
|
10035
|
+
TAB_SIZE
|
|
10036
|
+
)}
|
|
10037
|
+
}
|
|
10038
|
+
|
|
10039
|
+
// Custom InputTypes
|
|
10040
|
+
${this.argsTypes.map((typeExport) => stringify(typeExport)).join("\n\n")}
|
|
9914
10041
|
`;
|
|
9915
10042
|
}
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
property("datasourceUrl", stringType).optional().setDocComment(docComment("Overwrites the datasource url from your schema.prisma file"))
|
|
9921
|
-
).add(
|
|
9922
|
-
property("errorFormat", namedType("ErrorFormat")).optional().setDocComment(docComment('@default "colorless"'))
|
|
9923
|
-
).add(
|
|
9924
|
-
property("log", array(unionType([namedType("LogLevel"), namedType("LogDefinition")]))).optional().setDocComment(docComment`
|
|
9925
|
-
@example
|
|
9926
|
-
\`\`\`
|
|
9927
|
-
// Defaults to stdout
|
|
9928
|
-
log: ['query', 'info', 'warn', 'error']
|
|
10043
|
+
};
|
|
10044
|
+
function getCountArgsType(typeName, fieldName) {
|
|
10045
|
+
return `${typeName}Count${capitalize2(fieldName)}Args`;
|
|
10046
|
+
}
|
|
9929
10047
|
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
|
|
10048
|
+
// src/generation/TSClient/CountTypesFile.ts
|
|
10049
|
+
function createCountTypesFile(context) {
|
|
10050
|
+
const countTypes = context.dmmf.schema.outputObjectTypes.prisma?.filter((t) => t.name.endsWith("CountOutputType")).map((t) => new Count(t, context));
|
|
10051
|
+
return `import * as runtime from '${context.nestedRuntimeJsPath}';
|
|
10052
|
+
import $Types = runtime.Types // general types
|
|
10053
|
+
import $Public = runtime.Types.Public
|
|
10054
|
+
import $Utils = runtime.Types.Utils
|
|
10055
|
+
import $Extensions = runtime.Types.Extensions
|
|
10056
|
+
import $Result = runtime.Types.Result
|
|
10057
|
+
import Decimal = runtime.Decimal
|
|
10058
|
+
import DecimalJsLike = runtime.DecimalJsLike
|
|
10059
|
+
|
|
10060
|
+
import type * as Prisma from '../common'
|
|
10061
|
+
|
|
10062
|
+
${countTypes.map((t) => t.toTS()).join("\n")}
|
|
10063
|
+
`;
|
|
10064
|
+
}
|
|
10065
|
+
|
|
10066
|
+
// src/generation/TSClient/DeepInputTypesFile.ts
|
|
10067
|
+
function createDeepInputTypesFile(context) {
|
|
10068
|
+
return `
|
|
10069
|
+
import * as runtime from '${context.nestedRuntimeJsPath}';
|
|
10070
|
+
import $Types = runtime.Types // general types
|
|
10071
|
+
import $Public = runtime.Types.Public
|
|
10072
|
+
import $Utils = runtime.Types.Utils
|
|
10073
|
+
import $Extensions = runtime.Types.Extensions
|
|
10074
|
+
import $Result = runtime.Types.Result
|
|
10075
|
+
import Decimal = runtime.Decimal
|
|
10076
|
+
import DecimalJsLike = runtime.DecimalJsLike
|
|
10077
|
+
import JsonObject = runtime.JsonObject
|
|
10078
|
+
import JsonArray = runtime.JsonArray
|
|
10079
|
+
import JsonValue = runtime.JsonValue
|
|
10080
|
+
import InputJsonObject = runtime.InputJsonObject
|
|
10081
|
+
import InputJsonArray = runtime.InputJsonArray
|
|
10082
|
+
import InputJsonValue = runtime.InputJsonValue
|
|
10083
|
+
|
|
10084
|
+
${context.dmmf.datamodel.enums.length > 0 ? `import type * as $Enums from '../enums'` : ""}
|
|
10085
|
+
import type * as Prisma from '../common';
|
|
10086
|
+
|
|
10087
|
+
${context.dmmf.inputObjectTypes.prisma?.reduce((acc, inputType) => {
|
|
10088
|
+
if (inputType.name.includes("Json") && inputType.name.includes("Filter")) {
|
|
10089
|
+
const needsGeneric = context.genericArgsInfo.typeNeedsGenericModelArg(inputType);
|
|
10090
|
+
const innerName = needsGeneric ? `${inputType.name}Base<$PrismaModel>` : `${inputType.name}Base`;
|
|
10091
|
+
const typeName = needsGeneric ? `${inputType.name}<$PrismaModel = never>` : inputType.name;
|
|
10092
|
+
const baseName = `Required<${innerName}>`;
|
|
10093
|
+
acc.push(`export type ${typeName} =
|
|
10094
|
+
| Prisma.PatchUndefined<
|
|
10095
|
+
Prisma.Either<${baseName}, Exclude<keyof ${baseName}, 'path'>>,
|
|
10096
|
+
${baseName}
|
|
10097
|
+
>
|
|
10098
|
+
| Prisma.OptionalFlat<Omit<${baseName}, 'path'>>`);
|
|
10099
|
+
acc.push(new InputType(inputType, context).overrideName(`${inputType.name}Base`).toTS());
|
|
10100
|
+
} else {
|
|
10101
|
+
acc.push(new InputType(inputType, context).toTS());
|
|
9958
10102
|
}
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
10103
|
+
return acc;
|
|
10104
|
+
}, []).join("\n")}
|
|
10105
|
+
`;
|
|
10106
|
+
}
|
|
9962
10107
|
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
10108
|
+
// src/generation/TSClient/EnumsFile.ts
|
|
10109
|
+
function createEnumsFile(context) {
|
|
10110
|
+
const modelEnums = [];
|
|
10111
|
+
for (const datamodelEnum of context.dmmf.datamodel.enums) {
|
|
10112
|
+
modelEnums.push(new Enum(datamodelEnumToSchemaEnum(datamodelEnum), false).toTS());
|
|
10113
|
+
}
|
|
10114
|
+
return modelEnums.join("\n\n");
|
|
10115
|
+
}
|
|
10116
|
+
|
|
10117
|
+
// src/generation/TSClient/GenerateContext.ts
|
|
10118
|
+
var GenerateContext = class {
|
|
10119
|
+
constructor({ dmmf, genericArgsInfo, generator, runtimeJsPath }) {
|
|
10120
|
+
this.dmmf = dmmf;
|
|
10121
|
+
this.genericArgsInfo = genericArgsInfo;
|
|
10122
|
+
this.generator = generator;
|
|
10123
|
+
this.runtimeJsPath = runtimeJsPath;
|
|
10124
|
+
}
|
|
10125
|
+
isPreviewFeatureOn(previewFeature) {
|
|
10126
|
+
return this.generator?.previewFeatures?.includes(previewFeature) ?? false;
|
|
10127
|
+
}
|
|
10128
|
+
get nestedRuntimeJsPath() {
|
|
10129
|
+
if (!this.runtimeJsPath.startsWith(".")) {
|
|
10130
|
+
return this.runtimeJsPath;
|
|
10131
|
+
}
|
|
10132
|
+
if (this.runtimeJsPath.startsWith("./")) {
|
|
10133
|
+
return `.${this.runtimeJsPath}`;
|
|
10134
|
+
}
|
|
10135
|
+
return `../${this.runtimeJsPath}`;
|
|
9976
10136
|
}
|
|
9977
10137
|
};
|
|
9978
10138
|
|
|
10139
|
+
// src/generation/TSClient/ModelFiles.ts
|
|
10140
|
+
function createModelFiles(context) {
|
|
10141
|
+
const importStatements = `import * as runtime from '${context.nestedRuntimeJsPath}';
|
|
10142
|
+
import $Types = runtime.Types // general types
|
|
10143
|
+
import $Public = runtime.Types.Public
|
|
10144
|
+
import $Utils = runtime.Types.Utils
|
|
10145
|
+
import $Extensions = runtime.Types.Extensions
|
|
10146
|
+
import $Result = runtime.Types.Result
|
|
10147
|
+
import Decimal = runtime.Decimal
|
|
10148
|
+
import DecimalJsLike = runtime.DecimalJsLike
|
|
10149
|
+
import JsonObject = runtime.JsonObject
|
|
10150
|
+
import JsonArray = runtime.JsonArray
|
|
10151
|
+
import JsonValue = runtime.JsonValue
|
|
10152
|
+
import InputJsonObject = runtime.InputJsonObject
|
|
10153
|
+
import InputJsonArray = runtime.InputJsonArray
|
|
10154
|
+
import InputJsonValue = runtime.InputJsonValue
|
|
10155
|
+
|
|
10156
|
+
${context.dmmf.datamodel.enums.length > 0 ? `import type * as $Enums from '../enums'` : ""}
|
|
10157
|
+
|
|
10158
|
+
import type * as Prisma from '../common'`;
|
|
10159
|
+
const modelAndTypes = Object.values(context.dmmf.typeAndModelMap).filter((modelOrType) => context.dmmf.outputTypeMap.model[modelOrType.name]).map((modelOrType) => new Model(modelOrType, context));
|
|
10160
|
+
const modelsFileMap = {};
|
|
10161
|
+
modelAndTypes.forEach((m) => {
|
|
10162
|
+
return modelsFileMap[m.fileName()] = `
|
|
10163
|
+
${importStatements}
|
|
10164
|
+
|
|
10165
|
+
${m.toTS()}
|
|
10166
|
+
`;
|
|
10167
|
+
});
|
|
10168
|
+
return modelsFileMap;
|
|
10169
|
+
}
|
|
10170
|
+
|
|
9979
10171
|
// src/generation/TSClient/TSClient.ts
|
|
9980
10172
|
var TSClient = class {
|
|
9981
10173
|
constructor(options) {
|
|
@@ -10072,137 +10264,39 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
|
|
|
10072
10264
|
const context = new GenerateContext({
|
|
10073
10265
|
dmmf: this.dmmf,
|
|
10074
10266
|
genericArgsInfo: this.genericsInfo,
|
|
10075
|
-
generator: this.options.generator
|
|
10267
|
+
generator: this.options.generator,
|
|
10268
|
+
runtimeJsPath: `${this.options.runtimeBase}/${this.options.runtimeNameTs}`
|
|
10076
10269
|
});
|
|
10077
|
-
const
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
this.options.outputDir,
|
|
10081
|
-
this.options.runtimeNameTs,
|
|
10082
|
-
this.options.browser
|
|
10083
|
-
);
|
|
10084
|
-
const commonCode = commonCodeTS(this.options);
|
|
10085
|
-
const modelAndTypes = Object.values(this.dmmf.typeAndModelMap).reduce((acc, modelOrType) => {
|
|
10086
|
-
if (this.dmmf.outputTypeMap.model[modelOrType.name]) {
|
|
10087
|
-
acc.push(new Model(modelOrType, context));
|
|
10088
|
-
}
|
|
10089
|
-
return acc;
|
|
10090
|
-
}, []);
|
|
10091
|
-
const prismaEnums = this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toTS());
|
|
10092
|
-
const modelEnums = [];
|
|
10093
|
-
const modelEnumsAliases = [];
|
|
10094
|
-
for (const datamodelEnum of this.dmmf.datamodel.enums) {
|
|
10095
|
-
modelEnums.push(new Enum(datamodelEnumToSchemaEnum(datamodelEnum), false).toTS());
|
|
10096
|
-
modelEnumsAliases.push(
|
|
10270
|
+
const modelAndTypes = Object.values(context.dmmf.typeAndModelMap).filter((modelOrType) => context.dmmf.outputTypeMap.model[modelOrType.name]).map((modelOrType) => new Model(modelOrType, context));
|
|
10271
|
+
const modelEnumsAliases = this.dmmf.datamodel.enums.map((datamodelEnum) => {
|
|
10272
|
+
return [
|
|
10097
10273
|
stringify(
|
|
10098
10274
|
moduleExport(typeDeclaration(datamodelEnum.name, namedType(`$Enums.${datamodelEnum.name}`)))
|
|
10099
10275
|
),
|
|
10100
10276
|
stringify(
|
|
10101
10277
|
moduleExport(constDeclaration(datamodelEnum.name, namedType(`typeof $Enums.${datamodelEnum.name}`)))
|
|
10102
10278
|
)
|
|
10103
|
-
);
|
|
10104
|
-
}
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
* Client
|
|
10110
|
-
**/
|
|
10111
|
-
|
|
10112
|
-
${commonCode.tsWithoutNamespace()}
|
|
10113
|
-
|
|
10114
|
-
${modelAndTypes.map((m) => m.toTSWithoutNamespace()).join("\n")}
|
|
10115
|
-
${modelEnums.length > 0 ? `
|
|
10116
|
-
/**
|
|
10117
|
-
* Enums
|
|
10118
|
-
*/
|
|
10119
|
-
export namespace $Enums {
|
|
10120
|
-
${modelEnums.join("\n\n")}
|
|
10121
|
-
}
|
|
10122
|
-
|
|
10123
|
-
${modelEnumsAliases.join("\n\n")}
|
|
10124
|
-
` : ""}
|
|
10125
|
-
${prismaClientClass.toTSWithoutNamespace()}
|
|
10126
|
-
|
|
10127
|
-
export namespace Prisma {
|
|
10128
|
-
${(0, import_indent_string8.default)(
|
|
10129
|
-
`${commonCode.ts()}
|
|
10130
|
-
${new Enum(
|
|
10131
|
-
{
|
|
10132
|
-
name: "ModelName",
|
|
10133
|
-
values: this.dmmf.mappings.modelOperations.map((m) => m.model)
|
|
10134
|
-
},
|
|
10135
|
-
true
|
|
10136
|
-
).toTS()}
|
|
10137
|
-
|
|
10138
|
-
${prismaClientClass.toTS()}
|
|
10139
|
-
export type Datasource = {
|
|
10140
|
-
url?: string
|
|
10141
|
-
}
|
|
10142
|
-
|
|
10143
|
-
/**
|
|
10144
|
-
* Count Types
|
|
10145
|
-
*/
|
|
10146
|
-
|
|
10147
|
-
${countTypes.map((t) => t.toTS()).join("\n")}
|
|
10148
|
-
|
|
10149
|
-
/**
|
|
10150
|
-
* Models
|
|
10151
|
-
*/
|
|
10152
|
-
${modelAndTypes.map((model) => model.toTS()).join("\n")}
|
|
10153
|
-
|
|
10154
|
-
/**
|
|
10155
|
-
* Enums
|
|
10156
|
-
*/
|
|
10157
|
-
|
|
10158
|
-
${prismaEnums?.join("\n\n")}
|
|
10159
|
-
${fieldRefs.length > 0 ? `
|
|
10160
|
-
/**
|
|
10161
|
-
* Field references
|
|
10162
|
-
*/
|
|
10279
|
+
].join("\n");
|
|
10280
|
+
});
|
|
10281
|
+
return `
|
|
10282
|
+
import * as runtime from '${context.runtimeJsPath}'
|
|
10283
|
+
import $Public = runtime.Types.Public
|
|
10284
|
+
import $Result = runtime.Types.Result
|
|
10163
10285
|
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
* Deep Input Types
|
|
10167
|
-
*/
|
|
10286
|
+
import type * as Prisma from './common'
|
|
10287
|
+
${context.dmmf.datamodel.enums.length > 0 ? `import type * as $Enums from './enums'` : ""}
|
|
10168
10288
|
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
const needsGeneric = this.genericsInfo.typeNeedsGenericModelArg(inputType);
|
|
10172
|
-
const innerName = needsGeneric ? `${inputType.name}Base<$PrismaModel>` : `${inputType.name}Base`;
|
|
10173
|
-
const typeName = needsGeneric ? `${inputType.name}<$PrismaModel = never>` : inputType.name;
|
|
10174
|
-
const baseName = `Required<${innerName}>`;
|
|
10175
|
-
acc.push(`export type ${typeName} =
|
|
10176
|
-
| PatchUndefined<
|
|
10177
|
-
Either<${baseName}, Exclude<keyof ${baseName}, 'path'>>,
|
|
10178
|
-
${baseName}
|
|
10179
|
-
>
|
|
10180
|
-
| OptionalFlat<Omit<${baseName}, 'path'>>`);
|
|
10181
|
-
acc.push(new InputType(inputType, context).overrideName(`${inputType.name}Base`).toTS());
|
|
10182
|
-
} else {
|
|
10183
|
-
acc.push(new InputType(inputType, context).toTS());
|
|
10184
|
-
}
|
|
10185
|
-
return acc;
|
|
10186
|
-
}, []).join("\n")}
|
|
10289
|
+
export * as Prisma from './common'
|
|
10290
|
+
${context.dmmf.datamodel.enums.length > 0 ? `export type * as $Enums from './enums'` : ""}
|
|
10187
10291
|
|
|
10188
|
-
|
|
10292
|
+
export { PrismaClient } from './client'
|
|
10189
10293
|
|
|
10190
|
-
|
|
10191
|
-
* Batch Payload for updateMany & deleteMany & createMany
|
|
10192
|
-
*/
|
|
10294
|
+
export type PrismaPromise<T> = $Public.PrismaPromise<T>
|
|
10193
10295
|
|
|
10194
|
-
|
|
10195
|
-
count: number
|
|
10196
|
-
}
|
|
10296
|
+
${modelAndTypes.map((m) => m.toTSWithoutNamespace()).join("\n")}
|
|
10197
10297
|
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
*/
|
|
10201
|
-
export const dmmf: runtime.BaseDMMF
|
|
10202
|
-
`,
|
|
10203
|
-
2
|
|
10204
|
-
)}}`;
|
|
10205
|
-
return code;
|
|
10298
|
+
${modelEnumsAliases.length > 0 ? `${modelEnumsAliases.join("\n\n")}` : ""}
|
|
10299
|
+
`;
|
|
10206
10300
|
}
|
|
10207
10301
|
toBrowserJS() {
|
|
10208
10302
|
const code = `${commonCodeJS({
|
|
@@ -10258,6 +10352,36 @@ Object.assign(exports, Prisma)
|
|
|
10258
10352
|
`;
|
|
10259
10353
|
return code;
|
|
10260
10354
|
}
|
|
10355
|
+
generateModelAndHelperFiles() {
|
|
10356
|
+
const context = new GenerateContext({
|
|
10357
|
+
dmmf: this.dmmf,
|
|
10358
|
+
genericArgsInfo: this.genericsInfo,
|
|
10359
|
+
generator: this.options.generator,
|
|
10360
|
+
runtimeJsPath: `${this.options.runtimeBase}/${this.options.runtimeNameTs}`
|
|
10361
|
+
});
|
|
10362
|
+
const modelsFileMap = createModelFiles(context);
|
|
10363
|
+
modelsFileMap["deepInputTypes.d.ts"] = createDeepInputTypesFile(context);
|
|
10364
|
+
modelsFileMap["countTypes.d.ts"] = createCountTypesFile(context);
|
|
10365
|
+
const modelsBarrelFileContent = `
|
|
10366
|
+
import * as runtime from '${context.runtimeJsPath}'
|
|
10367
|
+
|
|
10368
|
+
export import JsonObject = runtime.JsonObject
|
|
10369
|
+
export import JsonArray = runtime.JsonArray
|
|
10370
|
+
export import JsonValue = runtime.JsonValue
|
|
10371
|
+
export import InputJsonObject = runtime.InputJsonObject
|
|
10372
|
+
export import InputJsonArray = runtime.InputJsonArray
|
|
10373
|
+
export import InputJsonValue = runtime.InputJsonValue
|
|
10374
|
+
|
|
10375
|
+
${Object.keys(modelsFileMap).map((m) => `export type * from './models/${m}'`).join("\n")}
|
|
10376
|
+
`;
|
|
10377
|
+
return {
|
|
10378
|
+
"models.d.ts": modelsBarrelFileContent,
|
|
10379
|
+
"common.d.ts": createCommonFile(context, this.options),
|
|
10380
|
+
"client.d.ts": createClientFile(context, this.options),
|
|
10381
|
+
"enums.d.ts": createEnumsFile(context),
|
|
10382
|
+
models: modelsFileMap
|
|
10383
|
+
};
|
|
10384
|
+
}
|
|
10261
10385
|
};
|
|
10262
10386
|
|
|
10263
10387
|
// src/generation/typedSql/buildDbEnums.ts
|
|
@@ -10629,7 +10753,7 @@ async function buildClient({
|
|
|
10629
10753
|
version: clientVersion2,
|
|
10630
10754
|
sideEffects: false
|
|
10631
10755
|
};
|
|
10632
|
-
const fileMap =
|
|
10756
|
+
const fileMap = nodeClient.generateModelAndHelperFiles();
|
|
10633
10757
|
fileMap["index.js"] = JS(nodeClient);
|
|
10634
10758
|
fileMap["index.d.ts"] = TS(nodeClient);
|
|
10635
10759
|
fileMap["default.js"] = JS(defaultClient);
|