prisma 6.4.0-dev.13 → 6.4.0-dev.15
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 +295 -295
- package/package.json +10 -10
- package/prisma-client/generator-build/index.js +1402 -1282
- package/prisma-client/package.json +8 -8
- package/prisma-client/runtime/binary.js +76 -74
- package/prisma-client/runtime/client.d.ts +0 -2
- package/prisma-client/runtime/client.js +22 -22
- package/prisma-client/runtime/edge-esm.js +13 -13
- package/prisma-client/runtime/edge.js +14 -14
- package/prisma-client/runtime/index-browser.d.ts +0 -2
- package/prisma-client/runtime/index-browser.js +3 -3
- package/prisma-client/runtime/library.d.ts +0 -2
- package/prisma-client/runtime/library.js +36 -36
- package/prisma-client/runtime/react-native.d.ts +0 -2
- package/prisma-client/runtime/react-native.js +16 -16
- package/prisma-client/scripts/default-index.js +1 -1
|
@@ -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.15",
|
|
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",
|
|
@@ -4130,10 +4130,10 @@ var require_package2 = __commonJS({
|
|
|
4130
4130
|
"@libsql/client": "0.8.0",
|
|
4131
4131
|
"@neondatabase/serverless": "0.10.2",
|
|
4132
4132
|
"@opentelemetry/api": "1.9.0",
|
|
4133
|
-
"@opentelemetry/context-async-hooks": "1.
|
|
4134
|
-
"@opentelemetry/instrumentation": "0.
|
|
4135
|
-
"@opentelemetry/resources": "1.
|
|
4136
|
-
"@opentelemetry/sdk-trace-base": "1.
|
|
4133
|
+
"@opentelemetry/context-async-hooks": "1.29.0",
|
|
4134
|
+
"@opentelemetry/instrumentation": "0.56.0",
|
|
4135
|
+
"@opentelemetry/resources": "1.29.0",
|
|
4136
|
+
"@opentelemetry/sdk-trace-base": "1.29.0",
|
|
4137
4137
|
"@opentelemetry/semantic-conventions": "1.28.0",
|
|
4138
4138
|
"@planetscale/database": "1.18.0",
|
|
4139
4139
|
"@prisma/adapter-d1": "workspace:*",
|
|
@@ -4171,7 +4171,7 @@ var require_package2 = __commonJS({
|
|
|
4171
4171
|
arg: "5.0.2",
|
|
4172
4172
|
benchmark: "2.1.4",
|
|
4173
4173
|
"ci-info": "4.0.0",
|
|
4174
|
-
"decimal.js": "10.
|
|
4174
|
+
"decimal.js": "10.4.3",
|
|
4175
4175
|
"detect-runtime": "1.0.4",
|
|
4176
4176
|
"env-paths": "2.2.1",
|
|
4177
4177
|
esbuild: "0.24.2",
|
|
@@ -4191,7 +4191,7 @@ var require_package2 = __commonJS({
|
|
|
4191
4191
|
kleur: "4.1.5",
|
|
4192
4192
|
klona: "2.0.6",
|
|
4193
4193
|
mariadb: "3.3.1",
|
|
4194
|
-
memfs: "4.
|
|
4194
|
+
memfs: "4.15.0",
|
|
4195
4195
|
mssql: "11.0.1",
|
|
4196
4196
|
"new-github-issue-url": "0.2.1",
|
|
4197
4197
|
"node-fetch": "3.3.2",
|
|
@@ -4212,7 +4212,7 @@ var require_package2 = __commonJS({
|
|
|
4212
4212
|
"ts-pattern": "5.6.2",
|
|
4213
4213
|
tsd: "0.31.2",
|
|
4214
4214
|
typescript: "5.4.5",
|
|
4215
|
-
undici: "7.3
|
|
4215
|
+
undici: "7.2.3",
|
|
4216
4216
|
wrangler: "3.91.0",
|
|
4217
4217
|
zx: "7.2.3"
|
|
4218
4218
|
},
|
|
@@ -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
|
/**
|
|
@@ -8123,7 +8137,7 @@ function getNonAggregateMethodArgs(modelName, actionName) {
|
|
|
8123
8137
|
if (actionName === DMMF.ModelAction.findRaw || actionName === DMMF.ModelAction.aggregateRaw) {
|
|
8124
8138
|
return makeParameter(namedType(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);
|
|
@@ -8158,7 +8172,7 @@ function getReturnType({
|
|
|
8158
8172
|
return prismaPromise(namedType("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,1442 @@ 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
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
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));
|
|
8987
8813
|
}
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
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("JsonObject");
|
|
8820
|
+
if (action === "aggregateRaw") return namedType("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']>
|
|
8992
8878
|
}
|
|
8993
8879
|
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
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
|
+
\`\`\`
|
|
9011
8910
|
|
|
9012
|
-
|
|
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>;
|
|
9013
8948
|
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
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>;`;
|
|
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>;
|
|
9017
8976
|
|
|
9018
|
-
|
|
9019
|
-
|
|
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>;`;
|
|
9020
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'
|
|
9021
9003
|
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
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.
|
|
9031
9022
|
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
(
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
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
|
+
\`\`\`
|
|
9045
9047
|
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
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 `
|
|
9105
|
+
import * as runtime from './runtime/library.js'
|
|
9106
|
+
import $Utils = runtime.Types.Utils
|
|
9107
|
+
import $Extensions = runtime.Types.Extensions
|
|
9054
9108
|
|
|
9055
|
-
type
|
|
9109
|
+
import type * as Prisma from './common'
|
|
9056
9110
|
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
(Without<T, U> & U) | (Without<U, T> & T)
|
|
9065
|
-
: U : T
|
|
9111
|
+
${this.jsDoc}
|
|
9112
|
+
export class PrismaClient<
|
|
9113
|
+
ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
|
|
9114
|
+
U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
|
|
9115
|
+
ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs
|
|
9116
|
+
> {
|
|
9117
|
+
[K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
|
|
9066
9118
|
|
|
9119
|
+
${(0, import_indent_string5.default)(this.jsDoc, TAB_SIZE)}
|
|
9067
9120
|
|
|
9068
|
-
|
|
9069
|
-
|
|
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
|
|
9121
|
+
constructor(optionsArg ?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>);
|
|
9122
|
+
${eventRegistrationMethodDeclaration(this.runtimeNameTs)}
|
|
9082
9123
|
|
|
9124
|
+
/**
|
|
9125
|
+
* Connect with the database
|
|
9126
|
+
*/
|
|
9127
|
+
$connect(): $Utils.JsPromise<void>;
|
|
9083
9128
|
|
|
9084
|
-
/**
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9129
|
+
/**
|
|
9130
|
+
* Disconnect from the database
|
|
9131
|
+
*/
|
|
9132
|
+
$disconnect(): $Utils.JsPromise<void>;
|
|
9088
9133
|
|
|
9089
|
-
/**
|
|
9090
|
-
|
|
9091
|
-
|
|
9134
|
+
/**
|
|
9135
|
+
* Add a middleware
|
|
9136
|
+
* @deprecated since 4.16.0. For new code, prefer client extensions instead.
|
|
9137
|
+
* @see https://pris.ly/d/extensions
|
|
9138
|
+
*/
|
|
9139
|
+
$use(cb: Prisma.Middleware): void
|
|
9092
9140
|
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9141
|
+
${[
|
|
9142
|
+
executeRawDefinition(this.context),
|
|
9143
|
+
queryRawDefinition(this.context),
|
|
9144
|
+
queryRawTypedDefinition(this.context),
|
|
9145
|
+
batchingTransactionDefinition(this.context),
|
|
9146
|
+
interactiveTransactionDefinition(this.context),
|
|
9147
|
+
runCommandRawDefinition(this.context),
|
|
9148
|
+
metricDefinition(this.context),
|
|
9149
|
+
applyPendingMigrationsDefinition.bind(this)(),
|
|
9150
|
+
extendsPropertyDefinition()
|
|
9151
|
+
].filter((d) => d !== null).join("\n").trim()}
|
|
9098
9152
|
|
|
9099
|
-
|
|
9153
|
+
${(0, import_indent_string5.default)(
|
|
9154
|
+
dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
|
|
9155
|
+
let methodName = lowerCase(m.model);
|
|
9156
|
+
if (methodName === "constructor") {
|
|
9157
|
+
methodName = '["constructor"]';
|
|
9158
|
+
}
|
|
9159
|
+
const generics = ["ExtArgs", "ClientOptions"];
|
|
9160
|
+
return `/**
|
|
9161
|
+
* \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
|
|
9162
|
+
* Example usage:
|
|
9163
|
+
* \`\`\`ts
|
|
9164
|
+
* // Fetch zero or more ${capitalize2(m.plural)}
|
|
9165
|
+
* const ${lowerCase(m.plural)} = await prisma.${methodName}.findMany()
|
|
9166
|
+
* \`\`\`
|
|
9167
|
+
*/
|
|
9168
|
+
get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
|
|
9169
|
+
}).join("\n\n"),
|
|
9170
|
+
2
|
|
9171
|
+
)}
|
|
9172
|
+
}`;
|
|
9173
|
+
}
|
|
9174
|
+
toTS() {
|
|
9175
|
+
const clientOptions = this.buildClientOptions();
|
|
9176
|
+
return `${new Datasources(this.internalDatasources).toTS()}
|
|
9177
|
+
${clientExtensionsDefinitions(this.context)}
|
|
9178
|
+
export type DefaultPrismaClient = PrismaClient
|
|
9179
|
+
export type ErrorFormat = 'pretty' | 'colorless' | 'minimal'
|
|
9180
|
+
${stringify(moduleExport(clientOptions))}
|
|
9181
|
+
${stringify(globalOmitConfig(this.context.dmmf))}
|
|
9100
9182
|
|
|
9101
|
-
|
|
9183
|
+
/* Types for Logging */
|
|
9184
|
+
export type LogLevel = 'info' | 'query' | 'warn' | 'error'
|
|
9185
|
+
export type LogDefinition = {
|
|
9186
|
+
level: LogLevel
|
|
9187
|
+
emit: 'stdout' | 'event'
|
|
9188
|
+
}
|
|
9102
9189
|
|
|
9103
|
-
type
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
> = {
|
|
9108
|
-
1: EitherStrict<O, K>
|
|
9109
|
-
0: EitherLoose<O, K>
|
|
9110
|
-
}[strict]
|
|
9190
|
+
export type GetLogType<T extends LogLevel | LogDefinition> = T extends LogDefinition ? T['emit'] extends 'event' ? T['level'] : never : never
|
|
9191
|
+
export type GetEvents<T extends any> = T extends Array<LogLevel | LogDefinition> ?
|
|
9192
|
+
GetLogType<T[0]> | GetLogType<T[1]> | GetLogType<T[2]> | GetLogType<T[3]>
|
|
9193
|
+
: never
|
|
9111
9194
|
|
|
9112
|
-
type
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9195
|
+
export type QueryEvent = {
|
|
9196
|
+
timestamp: Date
|
|
9197
|
+
query: string
|
|
9198
|
+
params: string
|
|
9199
|
+
duration: number
|
|
9200
|
+
target: string
|
|
9201
|
+
}
|
|
9117
9202
|
|
|
9118
|
-
export type
|
|
9203
|
+
export type LogEvent = {
|
|
9204
|
+
timestamp: Date
|
|
9205
|
+
message: string
|
|
9206
|
+
target: string
|
|
9207
|
+
}
|
|
9208
|
+
/* End Types for Logging */
|
|
9119
9209
|
|
|
9120
|
-
type PatchUndefined<O extends object, O1 extends object> = {
|
|
9121
|
-
[K in keyof O]: O[K] extends undefined ? At<O1, K> : O[K]
|
|
9122
|
-
} & {}
|
|
9123
9210
|
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9211
|
+
export type PrismaAction =
|
|
9212
|
+
| 'findUnique'
|
|
9213
|
+
| 'findUniqueOrThrow'
|
|
9214
|
+
| 'findMany'
|
|
9215
|
+
| 'findFirst'
|
|
9216
|
+
| 'findFirstOrThrow'
|
|
9217
|
+
| 'create'
|
|
9218
|
+
| 'createMany'
|
|
9219
|
+
| 'createManyAndReturn'
|
|
9220
|
+
| 'update'
|
|
9221
|
+
| 'updateMany'
|
|
9222
|
+
| 'updateManyAndReturn'
|
|
9223
|
+
| 'upsert'
|
|
9224
|
+
| 'delete'
|
|
9225
|
+
| 'deleteMany'
|
|
9226
|
+
| 'executeRaw'
|
|
9227
|
+
| 'queryRaw'
|
|
9228
|
+
| 'aggregate'
|
|
9229
|
+
| 'count'
|
|
9230
|
+
| 'runCommandRaw'
|
|
9231
|
+
| 'findRaw'
|
|
9232
|
+
| 'groupBy'
|
|
9130
9233
|
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9234
|
+
/**
|
|
9235
|
+
* These options are being passed into the middleware as "params"
|
|
9236
|
+
*/
|
|
9237
|
+
export type MiddlewareParams = {
|
|
9238
|
+
model?: ModelName
|
|
9239
|
+
action: PrismaAction
|
|
9240
|
+
args: any
|
|
9241
|
+
dataPath: string[]
|
|
9242
|
+
runInTransaction: boolean
|
|
9243
|
+
}
|
|
9134
9244
|
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9245
|
+
/**
|
|
9246
|
+
* The \`T\` type makes sure, that the \`return proceed\` is not forgotten in the middleware implementation
|
|
9247
|
+
*/
|
|
9248
|
+
export type Middleware<T = any> = (
|
|
9249
|
+
params: MiddlewareParams,
|
|
9250
|
+
next: (params: MiddlewareParams) => $Utils.JsPromise<T>,
|
|
9251
|
+
) => $Utils.JsPromise<T>
|
|
9138
9252
|
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
type AtStrict<O extends object, K extends Key> = O[K & keyof O];
|
|
9142
|
-
type AtLoose<O extends object, K extends Key> = O extends unknown ? AtStrict<O, K> : never;
|
|
9143
|
-
export type At<O extends object, K extends Key, strict extends Boolean = 1> = {
|
|
9144
|
-
1: AtStrict<O, K>;
|
|
9145
|
-
0: AtLoose<O, K>;
|
|
9146
|
-
}[strict];
|
|
9253
|
+
// tested in getLogLevel.test.ts
|
|
9254
|
+
export function getLogLevel(log: Array<LogLevel | LogDefinition>): LogLevel | undefined;
|
|
9147
9255
|
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9256
|
+
/**
|
|
9257
|
+
* \`PrismaClient\` proxy available in interactive transactions.
|
|
9258
|
+
*/
|
|
9259
|
+
export type TransactionClient = Omit<DefaultPrismaClient, runtime.ITXClientDenyList>
|
|
9260
|
+
`;
|
|
9261
|
+
}
|
|
9262
|
+
buildClientOptions() {
|
|
9263
|
+
const clientOptions = interfaceDeclaration("PrismaClientOptions").add(
|
|
9264
|
+
property("datasources", namedType("Datasources")).optional().setDocComment(docComment("Overwrites the datasource url from your schema.prisma file"))
|
|
9265
|
+
).add(
|
|
9266
|
+
property("datasourceUrl", stringType).optional().setDocComment(docComment("Overwrites the datasource url from your schema.prisma file"))
|
|
9267
|
+
).add(
|
|
9268
|
+
property("errorFormat", namedType("ErrorFormat")).optional().setDocComment(docComment('@default "colorless"'))
|
|
9269
|
+
).add(
|
|
9270
|
+
property("log", array(unionType([namedType("LogLevel"), namedType("LogDefinition")]))).optional().setDocComment(docComment`
|
|
9271
|
+
@example
|
|
9272
|
+
\`\`\`
|
|
9273
|
+
// Defaults to stdout
|
|
9274
|
+
log: ['query', 'info', 'warn', 'error']
|
|
9151
9275
|
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9276
|
+
// Emit as events
|
|
9277
|
+
log: [
|
|
9278
|
+
{ emit: 'stdout', level: 'query' },
|
|
9279
|
+
{ emit: 'stdout', level: 'info' },
|
|
9280
|
+
{ emit: 'stdout', level: 'warn' }
|
|
9281
|
+
{ emit: 'stdout', level: 'error' }
|
|
9282
|
+
]
|
|
9283
|
+
\`\`\`
|
|
9284
|
+
Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/logging#the-log-option).
|
|
9285
|
+
`)
|
|
9286
|
+
);
|
|
9287
|
+
const transactionOptions = objectType().add(property("maxWait", numberType).optional()).add(property("timeout", numberType).optional());
|
|
9288
|
+
if (this.context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
9289
|
+
transactionOptions.add(property("isolationLevel", namedType("TransactionIsolationLevel")).optional());
|
|
9290
|
+
}
|
|
9291
|
+
clientOptions.add(
|
|
9292
|
+
property("transactionOptions", transactionOptions).optional().setDocComment(docComment`
|
|
9293
|
+
The default values for transactionOptions
|
|
9294
|
+
maxWait ?= 2000
|
|
9295
|
+
timeout ?= 5000
|
|
9296
|
+
`)
|
|
9297
|
+
);
|
|
9298
|
+
if (["library.js", "client.js"].includes(this.runtimeNameTs) && this.context.isPreviewFeatureOn("driverAdapters")) {
|
|
9299
|
+
clientOptions.add(
|
|
9300
|
+
property("adapter", unionType([namedType("runtime.DriverAdapter"), namedType("null")])).optional().setDocComment(
|
|
9301
|
+
docComment("Instance of a Driver Adapter, e.g., like one provided by `@prisma/adapter-planetscale`")
|
|
9302
|
+
)
|
|
9303
|
+
);
|
|
9304
|
+
}
|
|
9305
|
+
clientOptions.add(
|
|
9306
|
+
property("omit", namedType("GlobalOmitConfig")).optional().setDocComment(docComment`
|
|
9307
|
+
Global configuration for omitting model fields by default.
|
|
9155
9308
|
|
|
9156
|
-
|
|
9157
|
-
|
|
9309
|
+
@example
|
|
9310
|
+
\`\`\`
|
|
9311
|
+
const prisma = new PrismaClient({
|
|
9312
|
+
omit: {
|
|
9313
|
+
user: {
|
|
9314
|
+
password: true
|
|
9315
|
+
}
|
|
9316
|
+
}
|
|
9317
|
+
})
|
|
9318
|
+
\`\`\`
|
|
9319
|
+
`)
|
|
9320
|
+
);
|
|
9321
|
+
return clientOptions;
|
|
9322
|
+
}
|
|
9158
9323
|
};
|
|
9159
9324
|
|
|
9160
|
-
//
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9325
|
+
// src/generation/TSClient/ClientFile.ts
|
|
9326
|
+
function createClientFile(context, options) {
|
|
9327
|
+
const prismaClientClass = new PrismaClientClass(
|
|
9328
|
+
context,
|
|
9329
|
+
options.datasources,
|
|
9330
|
+
options.outputDir,
|
|
9331
|
+
options.runtimeNameTs,
|
|
9332
|
+
options.browser
|
|
9333
|
+
);
|
|
9334
|
+
return prismaClientClass.toTSWithoutNamespace();
|
|
9335
|
+
}
|
|
9169
9336
|
|
|
9170
|
-
|
|
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
|
+
`}
|
|
9171
9404
|
|
|
9172
|
-
|
|
9173
|
-
/** End Helper Types for "Merge" **/
|
|
9405
|
+
const Prisma = {}
|
|
9174
9406
|
|
|
9175
|
-
|
|
9407
|
+
exports.Prisma = Prisma
|
|
9408
|
+
exports.$Enums = {}
|
|
9176
9409
|
|
|
9177
9410
|
/**
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9411
|
+
* Prisma Client JS version: ${clientVersion2}
|
|
9412
|
+
* Query Engine version: ${engineVersion}
|
|
9413
|
+
*/
|
|
9414
|
+
Prisma.prismaVersion = {
|
|
9415
|
+
client: "${clientVersion2}",
|
|
9416
|
+
engine: "${engineVersion}"
|
|
9417
|
+
}
|
|
9181
9418
|
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
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
|
|
9186
9425
|
|
|
9187
9426
|
/**
|
|
9188
|
-
|
|
9189
|
-
*/
|
|
9190
|
-
|
|
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
|
|
9191
9434
|
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
}
|
|
9435
|
+
/**
|
|
9436
|
+
* Extensions
|
|
9437
|
+
*/
|
|
9438
|
+
Prisma.getExtensionContext = ${notSupportOnBrowser("Extensions.getExtensionContext", browser)}
|
|
9439
|
+
Prisma.defineExtension = ${notSupportOnBrowser("Extensions.defineExtension", browser)}
|
|
9196
9440
|
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
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
|
|
9202
9447
|
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9448
|
+
Prisma.NullTypes = {
|
|
9449
|
+
DbNull: objectEnumValues.classes.DbNull,
|
|
9450
|
+
JsonNull: objectEnumValues.classes.JsonNull,
|
|
9451
|
+
AnyNull: objectEnumValues.classes.AnyNull
|
|
9452
|
+
}
|
|
9206
9453
|
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
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
|
+
)}`;
|
|
9215
9463
|
}
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
type Cast<A, B> = A extends B ? A : B;
|
|
9464
|
+
return fnc;
|
|
9465
|
+
};
|
|
9466
|
+
var commonCodeTS = ({ clientVersion: clientVersion2, engineVersion, generator }) => ({
|
|
9467
|
+
ts: () => `export import DMMF = runtime.DMMF
|
|
9221
9468
|
|
|
9222
|
-
export
|
|
9469
|
+
export type PrismaPromise<T> = $Public.PrismaPromise<T>
|
|
9223
9470
|
|
|
9471
|
+
/**
|
|
9472
|
+
* Validator
|
|
9473
|
+
*/
|
|
9474
|
+
export import validator = runtime.Public.validator
|
|
9224
9475
|
|
|
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
|
|
9225
9484
|
|
|
9226
9485
|
/**
|
|
9227
|
-
*
|
|
9486
|
+
* Re-export of sql-template-tag
|
|
9228
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
|
|
9229
9493
|
|
|
9230
|
-
|
|
9231
|
-
[P in keyof T]: P extends keyof O
|
|
9232
|
-
? O[P]
|
|
9233
|
-
: never
|
|
9234
|
-
} : never
|
|
9494
|
+
${buildPrismaSkipTs(generator.previewFeatures)}
|
|
9235
9495
|
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9496
|
+
/**
|
|
9497
|
+
* Decimal.js
|
|
9498
|
+
*/
|
|
9499
|
+
export import Decimal = runtime.Decimal
|
|
9240
9500
|
|
|
9241
|
-
type
|
|
9242
|
-
[K in keyof T]: Or<
|
|
9243
|
-
Or<Extends<'OR', K>, Extends<'AND', K>>,
|
|
9244
|
-
Extends<'NOT', K>
|
|
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]
|
|
9501
|
+
export type DecimalJsLike = runtime.DecimalJsLike
|
|
9256
9502
|
|
|
9257
9503
|
/**
|
|
9258
|
-
*
|
|
9504
|
+
* Metrics
|
|
9259
9505
|
*/
|
|
9260
|
-
type
|
|
9261
|
-
type
|
|
9262
|
-
type
|
|
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
|
|
9263
9510
|
|
|
9264
9511
|
/**
|
|
9265
|
-
|
|
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
|
|
9520
|
+
|
|
9521
|
+
/**
|
|
9522
|
+
* Prisma Client JS version: ${clientVersion2}
|
|
9523
|
+
* Query Engine version: ${engineVersion}
|
|
9266
9524
|
*/
|
|
9267
|
-
type
|
|
9525
|
+
export type PrismaVersion = {
|
|
9526
|
+
client: string
|
|
9527
|
+
}
|
|
9528
|
+
|
|
9529
|
+
export const prismaVersion: PrismaVersion
|
|
9268
9530
|
|
|
9269
9531
|
/**
|
|
9270
|
-
*
|
|
9532
|
+
* Utility Types
|
|
9271
9533
|
*/
|
|
9272
|
-
type ExcludeUnderscoreKeys<T extends string> = T extends \`_\${string}\` ? never : T
|
|
9273
9534
|
|
|
9274
9535
|
|
|
9275
|
-
export
|
|
9536
|
+
export import JsonObject = runtime.JsonObject
|
|
9537
|
+
export import JsonArray = runtime.JsonArray
|
|
9538
|
+
export import JsonValue = runtime.JsonValue
|
|
9539
|
+
export import InputJsonObject = runtime.InputJsonObject
|
|
9540
|
+
export import InputJsonArray = runtime.InputJsonArray
|
|
9541
|
+
export import InputJsonValue = runtime.InputJsonValue
|
|
9276
9542
|
|
|
9277
|
-
|
|
9543
|
+
/**
|
|
9544
|
+
* Types of the values used to represent different kinds of \`null\` values when working with JSON fields.
|
|
9545
|
+
*
|
|
9546
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9547
|
+
*/
|
|
9548
|
+
declare namespace NullTypes {
|
|
9549
|
+
${buildNullClass("DbNull")}
|
|
9278
9550
|
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
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);
|
|
9551
|
+
${buildNullClass("JsonNull")}
|
|
9552
|
+
|
|
9553
|
+
${buildNullClass("AnyNull")}
|
|
9294
9554
|
}
|
|
9295
|
-
|
|
9296
|
-
if (previewFeatures.includes("strictUndefinedChecks")) {
|
|
9297
|
-
return `
|
|
9555
|
+
|
|
9298
9556
|
/**
|
|
9299
|
-
*
|
|
9557
|
+
* Helper for filtering JSON entries that have \`null\` on the database (empty on the db)
|
|
9558
|
+
*
|
|
9559
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9300
9560
|
*/
|
|
9301
|
-
export
|
|
9302
|
-
`;
|
|
9303
|
-
}
|
|
9304
|
-
return "";
|
|
9305
|
-
}
|
|
9306
|
-
function buildPrismaSkipJs(previewFeatures) {
|
|
9307
|
-
if (previewFeatures.includes("strictUndefinedChecks")) {
|
|
9308
|
-
return `
|
|
9309
|
-
Prisma.skip = skip
|
|
9310
|
-
`;
|
|
9311
|
-
}
|
|
9312
|
-
return "";
|
|
9313
|
-
}
|
|
9561
|
+
export const DbNull: NullTypes.DbNull
|
|
9314
9562
|
|
|
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
9563
|
/**
|
|
9342
|
-
*
|
|
9564
|
+
* Helper for filtering JSON entries that have JSON \`null\` values (not empty on the db)
|
|
9565
|
+
*
|
|
9566
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9343
9567
|
*/
|
|
9568
|
+
export const JsonNull: NullTypes.JsonNull
|
|
9344
9569
|
|
|
9345
|
-
|
|
9570
|
+
/**
|
|
9571
|
+
* Helper for filtering JSON entries that are \`Prisma.DbNull\` or \`Prisma.JsonNull\`
|
|
9572
|
+
*
|
|
9573
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9574
|
+
*/
|
|
9575
|
+
export const AnyNull: NullTypes.AnyNull
|
|
9346
9576
|
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
const types = ["boolean"];
|
|
9351
|
-
if (field.outputType.location === "outputObjectTypes") {
|
|
9352
|
-
types.push(getFieldArgName(field, this.type.name));
|
|
9353
|
-
}
|
|
9354
|
-
if (field.args.length > 0) {
|
|
9355
|
-
types.push(getCountArgsType(name, field.name));
|
|
9356
|
-
}
|
|
9357
|
-
return `${field.name}?: ${types.join(" | ")}`;
|
|
9358
|
-
}).join("\n"),
|
|
9359
|
-
TAB_SIZE
|
|
9360
|
-
)}
|
|
9577
|
+
type SelectAndInclude = {
|
|
9578
|
+
select: any
|
|
9579
|
+
include: any
|
|
9361
9580
|
}
|
|
9362
9581
|
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
}
|
|
9367
|
-
};
|
|
9368
|
-
function getCountArgsType(typeName, fieldName) {
|
|
9369
|
-
return `${typeName}Count${capitalize2(fieldName)}Args`;
|
|
9582
|
+
type SelectAndOmit = {
|
|
9583
|
+
select: any
|
|
9584
|
+
omit: any
|
|
9370
9585
|
}
|
|
9371
9586
|
|
|
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
9587
|
/**
|
|
9381
|
-
*
|
|
9588
|
+
* Get the type of the value, that the Promise holds.
|
|
9382
9589
|
*/
|
|
9383
|
-
export type
|
|
9384
|
-
`;
|
|
9385
|
-
}
|
|
9386
|
-
getAllowedTypes() {
|
|
9387
|
-
return this.type.allowTypes.map(getRefAllowedTypeName).join(" | ");
|
|
9388
|
-
}
|
|
9389
|
-
};
|
|
9590
|
+
export type PromiseType<T extends PromiseLike<any>> = T extends PromiseLike<infer U> ? U : T;
|
|
9390
9591
|
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9592
|
+
/**
|
|
9593
|
+
* Get the return type of a function which returns a Promise.
|
|
9594
|
+
*/
|
|
9595
|
+
export type PromiseReturnType<T extends (...args: any) => $Utils.JsPromise<any>> = PromiseType<ReturnType<T>>
|
|
9596
|
+
|
|
9597
|
+
/**
|
|
9598
|
+
* From T, pick a set of properties whose keys are in the union K
|
|
9599
|
+
*/
|
|
9600
|
+
type Prisma__Pick<T, K extends keyof T> = {
|
|
9601
|
+
[P in K]: T[P];
|
|
9401
9602
|
};
|
|
9402
9603
|
|
|
9403
|
-
// src/generation/TSClient/PrismaClient.ts
|
|
9404
|
-
var import_indent_string7 = __toESM(require_indent_string());
|
|
9405
9604
|
|
|
9406
|
-
|
|
9407
|
-
function runtimeImport(name) {
|
|
9408
|
-
return name;
|
|
9409
|
-
}
|
|
9410
|
-
function runtimeImportedType(name) {
|
|
9411
|
-
return namedType(`runtime.${name}`);
|
|
9412
|
-
}
|
|
9605
|
+
export type Enumerable<T> = T | Array<T>;
|
|
9413
9606
|
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
constructor(internalDatasources) {
|
|
9418
|
-
this.internalDatasources = internalDatasources;
|
|
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
|
-
};
|
|
9607
|
+
export type RequiredKeys<T> = {
|
|
9608
|
+
[K in keyof T]-?: {} extends Prisma__Pick<T, K> ? never : K
|
|
9609
|
+
}[keyof T]
|
|
9427
9610
|
|
|
9428
|
-
|
|
9429
|
-
|
|
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));
|
|
9611
|
+
export type TruthyKeys<T> = keyof {
|
|
9612
|
+
[K in keyof T as T[K] extends false | undefined | null ? never : K]: K
|
|
9437
9613
|
}
|
|
9438
9614
|
|
|
9439
|
-
|
|
9440
|
-
function clientTypeMapModelsDefinition(context) {
|
|
9441
|
-
const meta = objectType();
|
|
9442
|
-
const modelNames = context.dmmf.datamodel.models.map((m) => m.name);
|
|
9443
|
-
if (modelNames.length === 0) {
|
|
9444
|
-
meta.add(property("modelProps", neverType));
|
|
9445
|
-
} else {
|
|
9446
|
-
meta.add(property("modelProps", unionType(modelNames.map((name) => stringLiteral(lowerCase(name))))));
|
|
9447
|
-
}
|
|
9448
|
-
const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ? namedType("Prisma.TransactionIsolationLevel") : neverType;
|
|
9449
|
-
meta.add(property("txIsolationLevel", isolationLevel));
|
|
9450
|
-
const model = objectType();
|
|
9451
|
-
model.addMultiple(
|
|
9452
|
-
modelNames.map((modelName) => {
|
|
9453
|
-
const entry = objectType();
|
|
9454
|
-
entry.add(
|
|
9455
|
-
property("payload", namedType(getPayloadName(modelName)).addGenericArgument(extArgsParam.toArgument()))
|
|
9456
|
-
);
|
|
9457
|
-
entry.add(property("fields", namedType(`Prisma.${getFieldRefsTypeName(modelName)}`)));
|
|
9458
|
-
const actions = getModelActions(context.dmmf, modelName);
|
|
9459
|
-
const operations = objectType();
|
|
9460
|
-
operations.addMultiple(
|
|
9461
|
-
actions.map((action) => {
|
|
9462
|
-
const operationType = objectType();
|
|
9463
|
-
const argsType = `Prisma.${getModelArgName(modelName, action)}`;
|
|
9464
|
-
operationType.add(property("args", namedType(argsType).addGenericArgument(extArgsParam.toArgument())));
|
|
9465
|
-
operationType.add(property("result", clientTypeMapModelsResultDefinition(modelName, action)));
|
|
9466
|
-
return property(action, operationType);
|
|
9467
|
-
})
|
|
9468
|
-
);
|
|
9469
|
-
entry.add(property("operations", operations));
|
|
9470
|
-
return property(modelName, entry);
|
|
9471
|
-
})
|
|
9472
|
-
);
|
|
9473
|
-
return objectType().add(property("meta", meta)).add(property("model", model));
|
|
9474
|
-
}
|
|
9475
|
-
function clientTypeMapModelsResultDefinition(modelName, action) {
|
|
9476
|
-
if (action === "count")
|
|
9477
|
-
return unionType([optional(namedType(getCountAggregateOutputName(modelName))), numberType]);
|
|
9478
|
-
if (action === "groupBy") return array(optional(namedType(getGroupByName(modelName))));
|
|
9479
|
-
if (action === "aggregate") return optional(namedType(getAggregateName(modelName)));
|
|
9480
|
-
if (action === "findRaw") return namedType("JsonObject");
|
|
9481
|
-
if (action === "aggregateRaw") return namedType("JsonObject");
|
|
9482
|
-
if (action === "deleteMany") return namedType("BatchPayload");
|
|
9483
|
-
if (action === "createMany") return namedType("BatchPayload");
|
|
9484
|
-
if (action === "createManyAndReturn") return array(payloadToResult(modelName));
|
|
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
|
-
}
|
|
9615
|
+
export type TrueKeys<T> = TruthyKeys<Prisma__Pick<T, RequiredKeys<T>>>
|
|
9540
9616
|
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
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
|
-
\`\`\`
|
|
9617
|
+
/**
|
|
9618
|
+
* Subset
|
|
9619
|
+
* @desc From \`T\` pick properties that exist in \`U\`. Simple version of Intersection
|
|
9620
|
+
*/
|
|
9621
|
+
export type Subset<T, U> = {
|
|
9622
|
+
[key in keyof T]: key extends keyof U ? T[key] : never;
|
|
9623
|
+
};
|
|
9571
9624
|
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
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>;
|
|
9625
|
+
/**
|
|
9626
|
+
* SelectSubset
|
|
9627
|
+
* @desc From \`T\` pick properties that exist in \`U\`. Simple version of Intersection.
|
|
9628
|
+
* Additionally, it validates, if both select and include are present. If the case, it errors.
|
|
9629
|
+
*/
|
|
9630
|
+
export type SelectSubset<T, U> = {
|
|
9631
|
+
[key in keyof T]: key extends keyof U ? T[key] : never
|
|
9632
|
+
} &
|
|
9633
|
+
(T extends SelectAndInclude
|
|
9634
|
+
? 'Please either choose \`select\` or \`include\`.'
|
|
9635
|
+
: T extends SelectAndOmit
|
|
9636
|
+
? 'Please either choose \`select\` or \`omit\`.'
|
|
9637
|
+
: {})
|
|
9609
9638
|
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
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>;
|
|
9639
|
+
/**
|
|
9640
|
+
* Subset + Intersection
|
|
9641
|
+
* @desc From \`T\` pick properties that exist in \`U\` and intersect \`K\`
|
|
9642
|
+
*/
|
|
9643
|
+
export type SubsetIntersection<T, U, K> = {
|
|
9644
|
+
[key in keyof T]: key extends keyof U ? T[key] : never
|
|
9645
|
+
} &
|
|
9646
|
+
K
|
|
9637
9647
|
|
|
9638
|
-
|
|
9639
|
-
* Executes a raw query and returns the number of affected rows.
|
|
9640
|
-
* Susceptible to SQL injections, see documentation.
|
|
9641
|
-
* @example
|
|
9642
|
-
* \`\`\`
|
|
9643
|
-
* const result = await prisma.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com')
|
|
9644
|
-
* \`\`\`
|
|
9645
|
-
*
|
|
9646
|
-
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
9647
|
-
*/
|
|
9648
|
-
$executeRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<number>;`;
|
|
9649
|
-
}
|
|
9650
|
-
function queryRawTypedDefinition(context) {
|
|
9651
|
-
if (!context.isPreviewFeatureOn("typedSql")) {
|
|
9652
|
-
return "";
|
|
9653
|
-
}
|
|
9654
|
-
if (!context.dmmf.mappings.otherOperations.write.includes("queryRaw")) {
|
|
9655
|
-
return "";
|
|
9656
|
-
}
|
|
9657
|
-
const param = genericParameter("T");
|
|
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'
|
|
9648
|
+
export type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
|
|
9664
9649
|
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
)
|
|
9673
|
-
|
|
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.
|
|
9650
|
+
/**
|
|
9651
|
+
* XOR is needed to have a real mutually exclusive union type
|
|
9652
|
+
* https://stackoverflow.com/questions/42123407/does-typescript-support-mutually-exclusive-types
|
|
9653
|
+
*/
|
|
9654
|
+
export type XOR<T, U> =
|
|
9655
|
+
T extends object ?
|
|
9656
|
+
U extends object ?
|
|
9657
|
+
(Without<T, U> & U) | (Without<U, T> & T)
|
|
9658
|
+
: U : T
|
|
9683
9659
|
|
|
9684
|
-
@example
|
|
9685
|
-
\`\`\`
|
|
9686
|
-
const metrics = await prisma.$metrics.json()
|
|
9687
|
-
// or
|
|
9688
|
-
const metrics = await prisma.$metrics.prometheus()
|
|
9689
|
-
\`\`\`
|
|
9690
|
-
`
|
|
9691
|
-
).readonly();
|
|
9692
|
-
return stringify(property2, { indentLevel: 1, newLine: "leading" });
|
|
9693
|
-
}
|
|
9694
|
-
function runCommandRawDefinition(context) {
|
|
9695
|
-
if (!context.dmmf.mappings.otherOperations.write.includes("runCommandRaw")) {
|
|
9696
|
-
return "";
|
|
9697
|
-
}
|
|
9698
|
-
const method2 = method("$runCommandRaw").addParameter(parameter("command", namedType("Prisma.InputJsonObject"))).setReturnType(prismaPromise(namedType("Prisma.JsonObject"))).setDocComment(docComment`
|
|
9699
|
-
Executes a raw MongoDB command and returns the result of it.
|
|
9700
|
-
@example
|
|
9701
|
-
\`\`\`
|
|
9702
|
-
const user = await prisma.$runCommandRaw({
|
|
9703
|
-
aggregate: 'User',
|
|
9704
|
-
pipeline: [{ $match: { name: 'Bob' } }, { $project: { email: true, _id: false } }],
|
|
9705
|
-
explain: false,
|
|
9706
|
-
})
|
|
9707
|
-
\`\`\`
|
|
9708
9660
|
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9661
|
+
/**
|
|
9662
|
+
* Is T a Record?
|
|
9663
|
+
*/
|
|
9664
|
+
export type IsObject<T extends any> = T extends Array<any>
|
|
9665
|
+
? False
|
|
9666
|
+
: T extends Date
|
|
9667
|
+
? False
|
|
9668
|
+
: T extends Uint8Array
|
|
9669
|
+
? False
|
|
9670
|
+
: T extends BigInt
|
|
9671
|
+
? False
|
|
9672
|
+
: T extends object
|
|
9673
|
+
? True
|
|
9674
|
+
: False
|
|
9675
|
+
|
|
9676
|
+
|
|
9677
|
+
/**
|
|
9678
|
+
* If it's T[], return T
|
|
9679
|
+
*/
|
|
9680
|
+
export type UnEnumerate<T extends unknown> = T extends Array<infer U> ? U : T
|
|
9681
|
+
|
|
9682
|
+
/**
|
|
9683
|
+
* From ts-toolbelt
|
|
9684
|
+
*/
|
|
9685
|
+
|
|
9686
|
+
type __Either<O extends object, K extends Key> = Omit<O, K> &
|
|
9687
|
+
{
|
|
9688
|
+
// Merge all but K
|
|
9689
|
+
[P in K]: Prisma__Pick<O, P & keyof O> // With K possibilities
|
|
9690
|
+
}[K]
|
|
9691
|
+
|
|
9692
|
+
type EitherStrict<O extends object, K extends Key> = Strict<__Either<O, K>>
|
|
9693
|
+
|
|
9694
|
+
type EitherLoose<O extends object, K extends Key> = ComputeRaw<__Either<O, K>>
|
|
9695
|
+
|
|
9696
|
+
type _Either<
|
|
9697
|
+
O extends object,
|
|
9698
|
+
K extends Key,
|
|
9699
|
+
strict extends Boolean
|
|
9700
|
+
> = {
|
|
9701
|
+
1: EitherStrict<O, K>
|
|
9702
|
+
0: EitherLoose<O, K>
|
|
9703
|
+
}[strict]
|
|
9704
|
+
|
|
9705
|
+
export type Either<
|
|
9706
|
+
O extends object,
|
|
9707
|
+
K extends Key,
|
|
9708
|
+
strict extends Boolean = 1
|
|
9709
|
+
> = O extends unknown ? _Either<O, K, strict> : never
|
|
9710
|
+
|
|
9711
|
+
export type Union = any
|
|
9712
|
+
|
|
9713
|
+
export type PatchUndefined<O extends object, O1 extends object> = {
|
|
9714
|
+
[K in keyof O]: O[K] extends undefined ? At<O1, K> : O[K]
|
|
9715
|
+
} & {}
|
|
9716
|
+
|
|
9717
|
+
/** Helper Types for "Merge" **/
|
|
9718
|
+
export type IntersectOf<U extends Union> = (
|
|
9719
|
+
U extends unknown ? (k: U) => void : never
|
|
9720
|
+
) extends (k: infer I) => void
|
|
9721
|
+
? I
|
|
9722
|
+
: never
|
|
9723
|
+
|
|
9724
|
+
export type Overwrite<O extends object, O1 extends object> = {
|
|
9725
|
+
[K in keyof O]: K extends keyof O1 ? O1[K] : O[K];
|
|
9726
|
+
} & {};
|
|
9727
|
+
|
|
9728
|
+
type _Merge<U extends object> = IntersectOf<Overwrite<U, {
|
|
9729
|
+
[K in keyof U]-?: At<U, K>;
|
|
9730
|
+
}>>;
|
|
9731
|
+
|
|
9732
|
+
type Key = string | number | symbol;
|
|
9733
|
+
type AtBasic<O extends object, K extends Key> = K extends keyof O ? O[K] : never;
|
|
9734
|
+
type AtStrict<O extends object, K extends Key> = O[K & keyof O];
|
|
9735
|
+
type AtLoose<O extends object, K extends Key> = O extends unknown ? AtStrict<O, K> : never;
|
|
9736
|
+
export type At<O extends object, K extends Key, strict extends Boolean = 1> = {
|
|
9737
|
+
1: AtStrict<O, K>;
|
|
9738
|
+
0: AtLoose<O, K>;
|
|
9739
|
+
}[strict];
|
|
9740
|
+
|
|
9741
|
+
export type ComputeRaw<A extends any> = A extends Function ? A : {
|
|
9742
|
+
[K in keyof A]: A[K];
|
|
9743
|
+
} & {};
|
|
9744
|
+
|
|
9745
|
+
export type OptionalFlat<O> = {
|
|
9746
|
+
[K in keyof O]?: O[K];
|
|
9747
|
+
} & {};
|
|
9748
|
+
|
|
9749
|
+
type _Record<K extends keyof any, T> = {
|
|
9750
|
+
[P in K]: T;
|
|
9751
|
+
};
|
|
9752
|
+
|
|
9753
|
+
// cause typescript not to expand types and preserve names
|
|
9754
|
+
type NoExpand<T> = T extends unknown ? T : never;
|
|
9755
|
+
|
|
9756
|
+
// this type assumes the passed object is entirely optional
|
|
9757
|
+
export type AtLeast<O extends object, K extends string> = NoExpand<
|
|
9758
|
+
O extends unknown
|
|
9759
|
+
? | (K extends keyof O ? { [P in K]: O[P] } & O : O)
|
|
9760
|
+
| {[P in keyof O as P extends K ? K : never]-?: O[P]} & O
|
|
9761
|
+
: never>;
|
|
9762
|
+
|
|
9763
|
+
type _Strict<U, _U = U> = U extends unknown ? U & OptionalFlat<_Record<Exclude<Keys<_U>, keyof U>, never>> : never;
|
|
9764
|
+
|
|
9765
|
+
export type Strict<U extends object> = ComputeRaw<_Strict<U>>;
|
|
9766
|
+
/** End Helper Types for "Merge" **/
|
|
9767
|
+
|
|
9768
|
+
export type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>;
|
|
9769
|
+
|
|
9770
|
+
/**
|
|
9771
|
+
A [[Boolean]]
|
|
9772
|
+
*/
|
|
9773
|
+
export type Boolean = True | False
|
|
9774
|
+
|
|
9775
|
+
// /**
|
|
9776
|
+
// 1
|
|
9777
|
+
// */
|
|
9778
|
+
export type True = 1
|
|
9779
|
+
|
|
9780
|
+
/**
|
|
9781
|
+
0
|
|
9782
|
+
*/
|
|
9783
|
+
export type False = 0
|
|
9784
|
+
|
|
9785
|
+
export type Not<B extends Boolean> = {
|
|
9786
|
+
0: 1
|
|
9787
|
+
1: 0
|
|
9788
|
+
}[B]
|
|
9789
|
+
|
|
9790
|
+
export type Extends<A1 extends any, A2 extends any> = [A1] extends [never]
|
|
9791
|
+
? 0 // anything \`never\` is false
|
|
9792
|
+
: A1 extends A2
|
|
9793
|
+
? 1
|
|
9794
|
+
: 0
|
|
9795
|
+
|
|
9796
|
+
export type Has<U extends Union, U1 extends Union> = Not<
|
|
9797
|
+
Extends<Exclude<U1, U>, U1>
|
|
9798
|
+
>
|
|
9799
|
+
|
|
9800
|
+
export type Or<B1 extends Boolean, B2 extends Boolean> = {
|
|
9801
|
+
0: {
|
|
9802
|
+
0: 0
|
|
9803
|
+
1: 1
|
|
9736
9804
|
}
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
if (dmmf.mappings.modelOperations.length) {
|
|
9741
|
-
example = dmmf.mappings.modelOperations[0];
|
|
9742
|
-
} else {
|
|
9743
|
-
example = {
|
|
9744
|
-
model: "User",
|
|
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
|
-
*/`;
|
|
9805
|
+
1: {
|
|
9806
|
+
0: 1
|
|
9807
|
+
1: 1
|
|
9762
9808
|
}
|
|
9763
|
-
|
|
9764
|
-
const { dmmf } = this.context;
|
|
9765
|
-
return `${this.jsDoc}
|
|
9766
|
-
export class PrismaClient<
|
|
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'] }
|
|
9809
|
+
}[B1][B2]
|
|
9772
9810
|
|
|
9773
|
-
|
|
9811
|
+
export type Keys<U extends Union> = U extends unknown ? keyof U : never
|
|
9774
9812
|
|
|
9775
|
-
|
|
9776
|
-
${eventRegistrationMethodDeclaration(this.runtimeNameTs)}
|
|
9813
|
+
type Cast<A, B> = A extends B ? A : B;
|
|
9777
9814
|
|
|
9778
|
-
|
|
9779
|
-
* Connect with the database
|
|
9780
|
-
*/
|
|
9781
|
-
$connect(): $Utils.JsPromise<void>;
|
|
9815
|
+
export const type: unique symbol;
|
|
9782
9816
|
|
|
9783
|
-
/**
|
|
9784
|
-
* Disconnect from the database
|
|
9785
|
-
*/
|
|
9786
|
-
$disconnect(): $Utils.JsPromise<void>;
|
|
9787
9817
|
|
|
9788
|
-
/**
|
|
9789
|
-
* Add a middleware
|
|
9790
|
-
* @deprecated since 4.16.0. For new code, prefer client extensions instead.
|
|
9791
|
-
* @see https://pris.ly/d/extensions
|
|
9792
|
-
*/
|
|
9793
|
-
$use(cb: Prisma.Middleware): void
|
|
9794
9818
|
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
queryRawTypedDefinition(this.context),
|
|
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()}
|
|
9819
|
+
/**
|
|
9820
|
+
* Used by group by
|
|
9821
|
+
*/
|
|
9806
9822
|
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9823
|
+
export type GetScalarType<T, O> = O extends object ? {
|
|
9824
|
+
[P in keyof T]: P extends keyof O
|
|
9825
|
+
? O[P]
|
|
9826
|
+
: never
|
|
9827
|
+
} : never
|
|
9828
|
+
|
|
9829
|
+
type FieldPaths<
|
|
9830
|
+
T,
|
|
9831
|
+
U = Omit<T, '_avg' | '_sum' | '_count' | '_min' | '_max'>
|
|
9832
|
+
> = IsObject<T> extends True ? U : T
|
|
9833
|
+
|
|
9834
|
+
export type GetHavingFields<T> = {
|
|
9835
|
+
[K in keyof T]: Or<
|
|
9836
|
+
Or<Extends<'OR', K>, Extends<'AND', K>>,
|
|
9837
|
+
Extends<'NOT', K>
|
|
9838
|
+
> extends True
|
|
9839
|
+
? // infer is only needed to not hit TS limit
|
|
9840
|
+
// based on the brilliant idea of Pierre-Antoine Mills
|
|
9841
|
+
// https://github.com/microsoft/TypeScript/issues/30188#issuecomment-478938437
|
|
9842
|
+
T[K] extends infer TK
|
|
9843
|
+
? GetHavingFields<UnEnumerate<TK> extends object ? Merge<UnEnumerate<TK>> : never>
|
|
9844
|
+
: never
|
|
9845
|
+
: {} extends FieldPaths<T[K]>
|
|
9846
|
+
? never
|
|
9847
|
+
: K
|
|
9848
|
+
}[keyof T]
|
|
9849
|
+
|
|
9850
|
+
/**
|
|
9851
|
+
* Convert tuple to union
|
|
9852
|
+
*/
|
|
9853
|
+
type _TupleToUnion<T> = T extends (infer E)[] ? E : never
|
|
9854
|
+
type TupleToUnion<K extends readonly any[]> = _TupleToUnion<K>
|
|
9855
|
+
export type MaybeTupleToUnion<T> = T extends any[] ? TupleToUnion<T> : T
|
|
9856
|
+
|
|
9857
|
+
/**
|
|
9858
|
+
* Like \`Pick\`, but additionally can also accept an array of keys
|
|
9859
|
+
*/
|
|
9860
|
+
export type PickEnumerable<T, K extends Enumerable<keyof T> | keyof T> = Prisma__Pick<T, MaybeTupleToUnion<K>>
|
|
9861
|
+
|
|
9862
|
+
/**
|
|
9863
|
+
* Exclude all keys with underscores
|
|
9864
|
+
*/
|
|
9865
|
+
export type ExcludeUnderscoreKeys<T extends string> = T extends \`_\${string}\` ? never : T
|
|
9866
|
+
|
|
9867
|
+
|
|
9868
|
+
export type FieldRef<Model, FieldType> = runtime.FieldRef<Model, FieldType>
|
|
9869
|
+
|
|
9870
|
+
type FieldRefInputType<Model, FieldType> = Model extends never ? never : FieldRef<Model, FieldType>
|
|
9871
|
+
|
|
9872
|
+
`
|
|
9873
|
+
});
|
|
9874
|
+
function buildNullClass(name) {
|
|
9875
|
+
const source = `/**
|
|
9876
|
+
* Type of \`Prisma.${name}\`.
|
|
9877
|
+
*
|
|
9878
|
+
* You cannot use other instances of this class. Please use the \`Prisma.${name}\` value.
|
|
9879
|
+
*
|
|
9880
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
|
|
9881
|
+
*/
|
|
9882
|
+
class ${name} {
|
|
9883
|
+
private ${name}: never
|
|
9884
|
+
private constructor()
|
|
9826
9885
|
}`;
|
|
9886
|
+
return (0, import_indent_string6.default)(source, TAB_SIZE);
|
|
9887
|
+
}
|
|
9888
|
+
function buildPrismaSkipTs(previewFeatures) {
|
|
9889
|
+
if (previewFeatures.includes("strictUndefinedChecks")) {
|
|
9890
|
+
return `
|
|
9891
|
+
/**
|
|
9892
|
+
* Prisma.skip
|
|
9893
|
+
*/
|
|
9894
|
+
export import skip = runtime.skip
|
|
9895
|
+
`;
|
|
9896
|
+
}
|
|
9897
|
+
return "";
|
|
9898
|
+
}
|
|
9899
|
+
function buildPrismaSkipJs(previewFeatures) {
|
|
9900
|
+
if (previewFeatures.includes("strictUndefinedChecks")) {
|
|
9901
|
+
return `
|
|
9902
|
+
Prisma.skip = skip
|
|
9903
|
+
`;
|
|
9904
|
+
}
|
|
9905
|
+
return "";
|
|
9906
|
+
}
|
|
9907
|
+
|
|
9908
|
+
// src/generation/TSClient/FieldRefInput.ts
|
|
9909
|
+
var FieldRefInput = class {
|
|
9910
|
+
constructor(type) {
|
|
9911
|
+
this.type = type;
|
|
9827
9912
|
}
|
|
9828
9913
|
toTS() {
|
|
9829
|
-
const
|
|
9830
|
-
return
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
${
|
|
9835
|
-
|
|
9914
|
+
const allowedTypes = this.getAllowedTypes();
|
|
9915
|
+
return `
|
|
9916
|
+
/**
|
|
9917
|
+
* Reference to a field of type ${allowedTypes}
|
|
9918
|
+
*/
|
|
9919
|
+
export type ${this.type.name}<$PrismaModel> = FieldRefInputType<$PrismaModel, ${allowedTypes}>
|
|
9920
|
+
`;
|
|
9921
|
+
}
|
|
9922
|
+
getAllowedTypes() {
|
|
9923
|
+
return this.type.allowTypes.map(getRefAllowedTypeName).join(" | ");
|
|
9924
|
+
}
|
|
9925
|
+
};
|
|
9836
9926
|
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9927
|
+
// src/generation/TSClient/CommonFile.ts
|
|
9928
|
+
function createCommonFile(context, options) {
|
|
9929
|
+
const prismaClientClass = new PrismaClientClass(
|
|
9930
|
+
context,
|
|
9931
|
+
options.datasources,
|
|
9932
|
+
options.outputDir,
|
|
9933
|
+
options.runtimeNameTs,
|
|
9934
|
+
options.browser
|
|
9935
|
+
);
|
|
9936
|
+
const commonCode = commonCodeTS(options);
|
|
9937
|
+
const prismaEnums = context.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toTS());
|
|
9938
|
+
const fieldRefs = context.dmmf.schema.fieldRefTypes.prisma?.map((type) => new FieldRefInput(type).toTS()) ?? [];
|
|
9939
|
+
return `
|
|
9940
|
+
import * as runtime from '${context.runtimeJsPath}';
|
|
9941
|
+
import $Types = runtime.Types // general types
|
|
9942
|
+
import $Public = runtime.Types.Public
|
|
9943
|
+
import $Utils = runtime.Types.Utils
|
|
9944
|
+
import $Extensions = runtime.Types.Extensions
|
|
9945
|
+
import $Result = runtime.Types.Result
|
|
9843
9946
|
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
GetLogType<T[0]> | GetLogType<T[1]> | GetLogType<T[2]> | GetLogType<T[3]>
|
|
9847
|
-
: never
|
|
9947
|
+
import type * as Prisma from './models';
|
|
9948
|
+
import type { PrismaClient } from './client';
|
|
9848
9949
|
|
|
9849
|
-
export type
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9950
|
+
export type * from './models';
|
|
9951
|
+
|
|
9952
|
+
${commonCode.ts()}
|
|
9953
|
+
${new Enum(
|
|
9954
|
+
{
|
|
9955
|
+
name: "ModelName",
|
|
9956
|
+
values: context.dmmf.mappings.modelOperations.map((m) => m.model)
|
|
9957
|
+
},
|
|
9958
|
+
true
|
|
9959
|
+
).toTS()}
|
|
9856
9960
|
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
target: string
|
|
9961
|
+
${prismaClientClass.toTS()}
|
|
9962
|
+
export type Datasource = {
|
|
9963
|
+
url?: string
|
|
9861
9964
|
}
|
|
9862
|
-
/* End Types for Logging */
|
|
9863
9965
|
|
|
9966
|
+
/**
|
|
9967
|
+
* Enums
|
|
9968
|
+
*/
|
|
9864
9969
|
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
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'
|
|
9970
|
+
${prismaEnums?.join("\n\n")}
|
|
9971
|
+
|
|
9972
|
+
${fieldRefs.length > 0 ? `
|
|
9973
|
+
/**
|
|
9974
|
+
* Field references
|
|
9975
|
+
*/
|
|
9887
9976
|
|
|
9977
|
+
${fieldRefs.join("\n\n")}` : ""}
|
|
9888
9978
|
/**
|
|
9889
|
-
*
|
|
9979
|
+
* Deep Input Types
|
|
9890
9980
|
*/
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
action: PrismaAction
|
|
9894
|
-
args: any
|
|
9895
|
-
dataPath: string[]
|
|
9896
|
-
runInTransaction: boolean
|
|
9897
|
-
}
|
|
9981
|
+
|
|
9982
|
+
${context.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputType, context).toTS()).join("\n") ?? ""}
|
|
9898
9983
|
|
|
9899
9984
|
/**
|
|
9900
|
-
*
|
|
9985
|
+
* Batch Payload for updateMany & deleteMany & createMany
|
|
9901
9986
|
*/
|
|
9902
|
-
export type Middleware<T = any> = (
|
|
9903
|
-
params: MiddlewareParams,
|
|
9904
|
-
next: (params: MiddlewareParams) => $Utils.JsPromise<T>,
|
|
9905
|
-
) => $Utils.JsPromise<T>
|
|
9906
9987
|
|
|
9907
|
-
|
|
9908
|
-
|
|
9988
|
+
export type BatchPayload = {
|
|
9989
|
+
count: number
|
|
9990
|
+
}
|
|
9909
9991
|
|
|
9910
9992
|
/**
|
|
9911
|
-
*
|
|
9993
|
+
* DMMF
|
|
9912
9994
|
*/
|
|
9913
|
-
export
|
|
9995
|
+
export const dmmf: runtime.BaseDMMF
|
|
9914
9996
|
`;
|
|
9915
|
-
|
|
9916
|
-
buildClientOptions() {
|
|
9917
|
-
const clientOptions = interfaceDeclaration("PrismaClientOptions").add(
|
|
9918
|
-
property("datasources", namedType("Datasources")).optional().setDocComment(docComment("Overwrites the datasource url from your schema.prisma file"))
|
|
9919
|
-
).add(
|
|
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']
|
|
9997
|
+
}
|
|
9929
9998
|
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9999
|
+
// src/generation/TSClient/Count.ts
|
|
10000
|
+
var import_indent_string7 = __toESM(require_indent_string());
|
|
10001
|
+
var Count = class {
|
|
10002
|
+
constructor(type, context) {
|
|
10003
|
+
this.type = type;
|
|
10004
|
+
this.context = context;
|
|
10005
|
+
}
|
|
10006
|
+
get argsTypes() {
|
|
10007
|
+
const argsTypes = [];
|
|
10008
|
+
argsTypes.push(
|
|
10009
|
+
new ArgsTypeBuilder(this.type, this.context).addSelectArg().addIncludeArgIfHasRelations().createExport()
|
|
9940
10010
|
);
|
|
9941
|
-
const
|
|
9942
|
-
|
|
9943
|
-
|
|
10011
|
+
for (const field of this.type.fields) {
|
|
10012
|
+
if (field.args.length > 0) {
|
|
10013
|
+
argsTypes.push(
|
|
10014
|
+
new ArgsTypeBuilder(this.type, this.context).addSchemaArgs(field.args).setGeneratedName(getCountArgsType(this.type.name, field.name)).createExport()
|
|
10015
|
+
);
|
|
10016
|
+
}
|
|
9944
10017
|
}
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
|
|
10018
|
+
return argsTypes;
|
|
10019
|
+
}
|
|
10020
|
+
toTS() {
|
|
10021
|
+
const { type } = this;
|
|
10022
|
+
const { name } = type;
|
|
10023
|
+
const outputType = buildOutputType(type);
|
|
10024
|
+
return `
|
|
10025
|
+
/**
|
|
10026
|
+
* Count Type ${name}
|
|
10027
|
+
*/
|
|
10028
|
+
|
|
10029
|
+
${stringify(outputType)}
|
|
10030
|
+
|
|
10031
|
+
export type ${getSelectName(name)}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
|
|
10032
|
+
${(0, import_indent_string7.default)(
|
|
10033
|
+
type.fields.map((field) => {
|
|
10034
|
+
const types = ["boolean"];
|
|
10035
|
+
if (field.outputType.location === "outputObjectTypes") {
|
|
10036
|
+
types.push(getFieldArgName(field, this.type.name));
|
|
10037
|
+
}
|
|
10038
|
+
if (field.args.length > 0) {
|
|
10039
|
+
types.push(getCountArgsType(name, field.name));
|
|
10040
|
+
}
|
|
10041
|
+
return `${field.name}?: ${types.join(" | ")}`;
|
|
10042
|
+
}).join("\n"),
|
|
10043
|
+
TAB_SIZE
|
|
10044
|
+
)}
|
|
10045
|
+
}
|
|
10046
|
+
|
|
10047
|
+
// Custom InputTypes
|
|
10048
|
+
${this.argsTypes.map((typeExport) => stringify(typeExport)).join("\n\n")}
|
|
10049
|
+
`;
|
|
10050
|
+
}
|
|
10051
|
+
};
|
|
10052
|
+
function getCountArgsType(typeName, fieldName) {
|
|
10053
|
+
return `${typeName}Count${capitalize2(fieldName)}Args`;
|
|
10054
|
+
}
|
|
10055
|
+
|
|
10056
|
+
// src/generation/TSClient/CountTypesFile.ts
|
|
10057
|
+
function createCountTypesFile(context) {
|
|
10058
|
+
const countTypes = context.dmmf.schema.outputObjectTypes.prisma?.filter((t) => t.name.endsWith("CountOutputType")).map((t) => new Count(t, context));
|
|
10059
|
+
return `import * as runtime from '${context.nestedRuntimeJsPath}';
|
|
10060
|
+
import $Types = runtime.Types // general types
|
|
10061
|
+
import $Public = runtime.Types.Public
|
|
10062
|
+
import $Utils = runtime.Types.Utils
|
|
10063
|
+
import $Extensions = runtime.Types.Extensions
|
|
10064
|
+
import $Result = runtime.Types.Result
|
|
10065
|
+
import Decimal = runtime.Decimal
|
|
10066
|
+
import DecimalJsLike = runtime.DecimalJsLike
|
|
10067
|
+
|
|
10068
|
+
import type * as Prisma from '../common'
|
|
10069
|
+
|
|
10070
|
+
${countTypes.map((t) => t.toTS()).join("\n")}
|
|
10071
|
+
`;
|
|
10072
|
+
}
|
|
10073
|
+
|
|
10074
|
+
// src/generation/TSClient/DeepInputTypesFile.ts
|
|
10075
|
+
function createDeepInputTypesFile(context) {
|
|
10076
|
+
return `
|
|
10077
|
+
import * as runtime from '${context.nestedRuntimeJsPath}';
|
|
10078
|
+
import $Types = runtime.Types // general types
|
|
10079
|
+
import $Public = runtime.Types.Public
|
|
10080
|
+
import $Utils = runtime.Types.Utils
|
|
10081
|
+
import $Extensions = runtime.Types.Extensions
|
|
10082
|
+
import $Result = runtime.Types.Result
|
|
10083
|
+
import Decimal = runtime.Decimal
|
|
10084
|
+
import DecimalJsLike = runtime.DecimalJsLike
|
|
10085
|
+
import JsonObject = runtime.JsonObject
|
|
10086
|
+
import JsonArray = runtime.JsonArray
|
|
10087
|
+
import JsonValue = runtime.JsonValue
|
|
10088
|
+
import InputJsonObject = runtime.InputJsonObject
|
|
10089
|
+
import InputJsonArray = runtime.InputJsonArray
|
|
10090
|
+
import InputJsonValue = runtime.InputJsonValue
|
|
10091
|
+
|
|
10092
|
+
import type * as $Enums from '../enums'
|
|
10093
|
+
import type * as Prisma from '../common';
|
|
10094
|
+
|
|
10095
|
+
${context.dmmf.inputObjectTypes.prisma?.reduce((acc, inputType) => {
|
|
10096
|
+
if (inputType.name.includes("Json") && inputType.name.includes("Filter")) {
|
|
10097
|
+
const needsGeneric = context.genericArgsInfo.typeNeedsGenericModelArg(inputType);
|
|
10098
|
+
const innerName = needsGeneric ? `${inputType.name}Base<$PrismaModel>` : `${inputType.name}Base`;
|
|
10099
|
+
const typeName = needsGeneric ? `${inputType.name}<$PrismaModel = never>` : inputType.name;
|
|
10100
|
+
const baseName = `Required<${innerName}>`;
|
|
10101
|
+
acc.push(`export type ${typeName} =
|
|
10102
|
+
| Prisma.PatchUndefined<
|
|
10103
|
+
Prisma.Either<${baseName}, Exclude<keyof ${baseName}, 'path'>>,
|
|
10104
|
+
${baseName}
|
|
10105
|
+
>
|
|
10106
|
+
| Prisma.OptionalFlat<Omit<${baseName}, 'path'>>`);
|
|
10107
|
+
acc.push(new InputType(inputType, context).overrideName(`${inputType.name}Base`).toTS());
|
|
10108
|
+
} else {
|
|
10109
|
+
acc.push(new InputType(inputType, context).toTS());
|
|
9958
10110
|
}
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
10111
|
+
return acc;
|
|
10112
|
+
}, []).join("\n")}
|
|
10113
|
+
`;
|
|
10114
|
+
}
|
|
9962
10115
|
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
10116
|
+
// src/generation/TSClient/EnumsFile.ts
|
|
10117
|
+
function createEnumsFile(context) {
|
|
10118
|
+
const modelEnums = [];
|
|
10119
|
+
for (const datamodelEnum of context.dmmf.datamodel.enums) {
|
|
10120
|
+
modelEnums.push(new Enum(datamodelEnumToSchemaEnum(datamodelEnum), false).toTS());
|
|
10121
|
+
}
|
|
10122
|
+
return modelEnums.join("\n\n");
|
|
10123
|
+
}
|
|
10124
|
+
|
|
10125
|
+
// src/generation/TSClient/GenerateContext.ts
|
|
10126
|
+
var GenerateContext = class {
|
|
10127
|
+
constructor({ dmmf, genericArgsInfo, generator, runtimeJsPath }) {
|
|
10128
|
+
this.dmmf = dmmf;
|
|
10129
|
+
this.genericArgsInfo = genericArgsInfo;
|
|
10130
|
+
this.generator = generator;
|
|
10131
|
+
this.runtimeJsPath = runtimeJsPath;
|
|
10132
|
+
}
|
|
10133
|
+
isPreviewFeatureOn(previewFeature) {
|
|
10134
|
+
return this.generator?.previewFeatures?.includes(previewFeature) ?? false;
|
|
10135
|
+
}
|
|
10136
|
+
get nestedRuntimeJsPath() {
|
|
10137
|
+
if (!this.runtimeJsPath.startsWith(".")) {
|
|
10138
|
+
return this.runtimeJsPath;
|
|
10139
|
+
}
|
|
10140
|
+
if (this.runtimeJsPath.startsWith("./")) {
|
|
10141
|
+
return `.${this.runtimeJsPath}`;
|
|
10142
|
+
}
|
|
10143
|
+
return `../${this.runtimeJsPath}`;
|
|
9976
10144
|
}
|
|
9977
10145
|
};
|
|
9978
10146
|
|
|
10147
|
+
// src/generation/TSClient/ModelFiles.ts
|
|
10148
|
+
function createModelFiles(context) {
|
|
10149
|
+
const importStatements = `import * as runtime from '${context.nestedRuntimeJsPath}';
|
|
10150
|
+
import $Types = runtime.Types // general types
|
|
10151
|
+
import $Public = runtime.Types.Public
|
|
10152
|
+
import $Utils = runtime.Types.Utils
|
|
10153
|
+
import $Extensions = runtime.Types.Extensions
|
|
10154
|
+
import $Result = runtime.Types.Result
|
|
10155
|
+
import Decimal = runtime.Decimal
|
|
10156
|
+
import DecimalJsLike = runtime.DecimalJsLike
|
|
10157
|
+
import JsonObject = runtime.JsonObject
|
|
10158
|
+
import JsonArray = runtime.JsonArray
|
|
10159
|
+
import JsonValue = runtime.JsonValue
|
|
10160
|
+
import InputJsonObject = runtime.InputJsonObject
|
|
10161
|
+
import InputJsonArray = runtime.InputJsonArray
|
|
10162
|
+
import InputJsonValue = runtime.InputJsonValue
|
|
10163
|
+
|
|
10164
|
+
import type * as $Enums from '../enums'
|
|
10165
|
+
import type * as Prisma from '../common'`;
|
|
10166
|
+
const modelAndTypes = Object.values(context.dmmf.typeAndModelMap).filter((modelOrType) => context.dmmf.outputTypeMap.model[modelOrType.name]).map((modelOrType) => new Model(modelOrType, context));
|
|
10167
|
+
const modelsFileMap = {};
|
|
10168
|
+
modelAndTypes.forEach((m) => {
|
|
10169
|
+
return modelsFileMap[m.fileName()] = `
|
|
10170
|
+
${importStatements}
|
|
10171
|
+
|
|
10172
|
+
${m.toTS()}
|
|
10173
|
+
`;
|
|
10174
|
+
});
|
|
10175
|
+
return modelsFileMap;
|
|
10176
|
+
}
|
|
10177
|
+
|
|
9979
10178
|
// src/generation/TSClient/TSClient.ts
|
|
9980
10179
|
var TSClient = class {
|
|
9981
10180
|
constructor(options) {
|
|
@@ -10072,137 +10271,39 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
|
|
|
10072
10271
|
const context = new GenerateContext({
|
|
10073
10272
|
dmmf: this.dmmf,
|
|
10074
10273
|
genericArgsInfo: this.genericsInfo,
|
|
10075
|
-
generator: this.options.generator
|
|
10274
|
+
generator: this.options.generator,
|
|
10275
|
+
runtimeJsPath: `${this.options.runtimeBase}/${this.options.runtimeNameTs}`
|
|
10076
10276
|
});
|
|
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(
|
|
10277
|
+
const modelAndTypes = Object.values(context.dmmf.typeAndModelMap).filter((modelOrType) => context.dmmf.outputTypeMap.model[modelOrType.name]).map((modelOrType) => new Model(modelOrType, context));
|
|
10278
|
+
const modelEnumsAliases = this.dmmf.datamodel.enums.map((datamodelEnum) => {
|
|
10279
|
+
return [
|
|
10097
10280
|
stringify(
|
|
10098
10281
|
moduleExport(typeDeclaration(datamodelEnum.name, namedType(`$Enums.${datamodelEnum.name}`)))
|
|
10099
10282
|
),
|
|
10100
10283
|
stringify(
|
|
10101
10284
|
moduleExport(constDeclaration(datamodelEnum.name, namedType(`typeof $Enums.${datamodelEnum.name}`)))
|
|
10102
10285
|
)
|
|
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
|
-
*/
|
|
10286
|
+
].join("\n");
|
|
10287
|
+
});
|
|
10288
|
+
return `
|
|
10289
|
+
import * as runtime from '${context.runtimeJsPath}';
|
|
10290
|
+
import $Public = runtime.Types.Public
|
|
10291
|
+
import $Result = runtime.Types.Result
|
|
10163
10292
|
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
* Deep Input Types
|
|
10167
|
-
*/
|
|
10293
|
+
import type * as Prisma from './common';
|
|
10294
|
+
import type * as $Enums from './enums'
|
|
10168
10295
|
|
|
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")}
|
|
10296
|
+
export type * as Prisma from './common';
|
|
10297
|
+
export type * as $Enums from './enums';
|
|
10187
10298
|
|
|
10188
|
-
|
|
10299
|
+
export { PrismaClient } from './client';
|
|
10189
10300
|
|
|
10190
|
-
|
|
10191
|
-
* Batch Payload for updateMany & deleteMany & createMany
|
|
10192
|
-
*/
|
|
10301
|
+
export type PrismaPromise<T> = $Public.PrismaPromise<T>
|
|
10193
10302
|
|
|
10194
|
-
|
|
10195
|
-
count: number
|
|
10196
|
-
}
|
|
10303
|
+
${modelAndTypes.map((m) => m.toTSWithoutNamespace()).join("\n")}
|
|
10197
10304
|
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
*/
|
|
10201
|
-
export const dmmf: runtime.BaseDMMF
|
|
10202
|
-
`,
|
|
10203
|
-
2
|
|
10204
|
-
)}}`;
|
|
10205
|
-
return code;
|
|
10305
|
+
${modelEnumsAliases.length > 0 ? `${modelEnumsAliases.join("\n\n")}` : ""}
|
|
10306
|
+
`;
|
|
10206
10307
|
}
|
|
10207
10308
|
toBrowserJS() {
|
|
10208
10309
|
const code = `${commonCodeJS({
|
|
@@ -10258,6 +10359,25 @@ Object.assign(exports, Prisma)
|
|
|
10258
10359
|
`;
|
|
10259
10360
|
return code;
|
|
10260
10361
|
}
|
|
10362
|
+
generateModelAndHelperFiles() {
|
|
10363
|
+
const context = new GenerateContext({
|
|
10364
|
+
dmmf: this.dmmf,
|
|
10365
|
+
genericArgsInfo: this.genericsInfo,
|
|
10366
|
+
generator: this.options.generator,
|
|
10367
|
+
runtimeJsPath: `${this.options.runtimeBase}/${this.options.runtimeNameTs}`
|
|
10368
|
+
});
|
|
10369
|
+
const modelsFileMap = createModelFiles(context);
|
|
10370
|
+
modelsFileMap["deepInputTypes.d.ts"] = createDeepInputTypesFile(context);
|
|
10371
|
+
modelsFileMap["countTypes.d.ts"] = createCountTypesFile(context);
|
|
10372
|
+
const modelsBarrelFileContent = Object.keys(modelsFileMap).map((m) => `export type * from './models/${m}'`).join("\n");
|
|
10373
|
+
return {
|
|
10374
|
+
"models.d.ts": modelsBarrelFileContent,
|
|
10375
|
+
"common.d.ts": createCommonFile(context, this.options),
|
|
10376
|
+
"client.d.ts": createClientFile(context, this.options),
|
|
10377
|
+
"enums.d.ts": createEnumsFile(context),
|
|
10378
|
+
models: modelsFileMap
|
|
10379
|
+
};
|
|
10380
|
+
}
|
|
10261
10381
|
};
|
|
10262
10382
|
|
|
10263
10383
|
// src/generation/typedSql/buildDbEnums.ts
|
|
@@ -10629,7 +10749,7 @@ async function buildClient({
|
|
|
10629
10749
|
version: clientVersion2,
|
|
10630
10750
|
sideEffects: false
|
|
10631
10751
|
};
|
|
10632
|
-
const fileMap =
|
|
10752
|
+
const fileMap = nodeClient.generateModelAndHelperFiles();
|
|
10633
10753
|
fileMap["index.js"] = JS(nodeClient);
|
|
10634
10754
|
fileMap["index.d.ts"] = TS(nodeClient);
|
|
10635
10755
|
fileMap["default.js"] = JS(defaultClient);
|