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