@prisma/client-generator-ts 6.16.0-dev.35 → 6.16.0-dev.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TSClient/GenerateContext.d.ts +3 -1
- package/dist/TSClient/ModelExports.d.ts +2 -0
- package/dist/TSClient/file-generators/BrowserFile.d.ts +3 -0
- package/dist/TSClient/file-generators/PrismaNamespaceBrowserFile.d.ts +2 -0
- package/dist/index.js +479 -405
- package/dist/index.mjs +456 -382
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1850,7 +1850,7 @@ var require_ensure = __commonJS({
|
|
|
1850
1850
|
var require_utils2 = __commonJS({
|
|
1851
1851
|
"../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/utils.js"(exports2, module2) {
|
|
1852
1852
|
"use strict";
|
|
1853
|
-
function
|
|
1853
|
+
function stringify16(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
|
|
1854
1854
|
const EOF = finalEOL ? EOL : "";
|
|
1855
1855
|
const str = JSON.stringify(obj, replacer, spaces);
|
|
1856
1856
|
return str.replace(/\n/g, EOL) + EOF;
|
|
@@ -1859,7 +1859,7 @@ var require_utils2 = __commonJS({
|
|
|
1859
1859
|
if (Buffer.isBuffer(content)) content = content.toString("utf8");
|
|
1860
1860
|
return content.replace(/^\uFEFF/, "");
|
|
1861
1861
|
}
|
|
1862
|
-
module2.exports = { stringify:
|
|
1862
|
+
module2.exports = { stringify: stringify16, stripBom };
|
|
1863
1863
|
}
|
|
1864
1864
|
});
|
|
1865
1865
|
|
|
@@ -1874,7 +1874,7 @@ var require_jsonfile = __commonJS({
|
|
|
1874
1874
|
_fs = require("fs");
|
|
1875
1875
|
}
|
|
1876
1876
|
var universalify = require_universalify();
|
|
1877
|
-
var { stringify:
|
|
1877
|
+
var { stringify: stringify16, stripBom } = require_utils2();
|
|
1878
1878
|
async function _readFile(file4, options = {}) {
|
|
1879
1879
|
if (typeof options === "string") {
|
|
1880
1880
|
options = { encoding: options };
|
|
@@ -1918,13 +1918,13 @@ var require_jsonfile = __commonJS({
|
|
|
1918
1918
|
}
|
|
1919
1919
|
async function _writeFile(file4, obj, options = {}) {
|
|
1920
1920
|
const fs3 = options.fs || _fs;
|
|
1921
|
-
const str =
|
|
1921
|
+
const str = stringify16(obj, options);
|
|
1922
1922
|
await universalify.fromCallback(fs3.writeFile)(file4, str, options);
|
|
1923
1923
|
}
|
|
1924
1924
|
var writeFile = universalify.fromPromise(_writeFile);
|
|
1925
1925
|
function writeFileSync(file4, obj, options = {}) {
|
|
1926
1926
|
const fs3 = options.fs || _fs;
|
|
1927
|
-
const str =
|
|
1927
|
+
const str = stringify16(obj, options);
|
|
1928
1928
|
return fs3.writeFileSync(file4, str, options);
|
|
1929
1929
|
}
|
|
1930
1930
|
var jsonfile = {
|
|
@@ -1986,10 +1986,10 @@ var require_output_file = __commonJS({
|
|
|
1986
1986
|
var require_output_json = __commonJS({
|
|
1987
1987
|
"../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/output-json.js"(exports2, module2) {
|
|
1988
1988
|
"use strict";
|
|
1989
|
-
var { stringify:
|
|
1989
|
+
var { stringify: stringify16 } = require_utils2();
|
|
1990
1990
|
var { outputFile } = require_output_file();
|
|
1991
1991
|
async function outputJson(file4, data, options = {}) {
|
|
1992
|
-
const str =
|
|
1992
|
+
const str = stringify16(data, options);
|
|
1993
1993
|
await outputFile(file4, str, options);
|
|
1994
1994
|
}
|
|
1995
1995
|
module2.exports = outputJson;
|
|
@@ -2000,10 +2000,10 @@ var require_output_json = __commonJS({
|
|
|
2000
2000
|
var require_output_json_sync = __commonJS({
|
|
2001
2001
|
"../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/output-json-sync.js"(exports2, module2) {
|
|
2002
2002
|
"use strict";
|
|
2003
|
-
var { stringify:
|
|
2003
|
+
var { stringify: stringify16 } = require_utils2();
|
|
2004
2004
|
var { outputFileSync } = require_output_file();
|
|
2005
2005
|
function outputJsonSync(file4, data, options) {
|
|
2006
|
-
const str =
|
|
2006
|
+
const str = stringify16(data, options);
|
|
2007
2007
|
outputFileSync(file4, str, options);
|
|
2008
2008
|
}
|
|
2009
2009
|
module2.exports = outputJsonSync;
|
|
@@ -2225,7 +2225,7 @@ function getMappings(mappings, datamodel) {
|
|
|
2225
2225
|
var import_promises = __toESM(require("node:fs/promises"));
|
|
2226
2226
|
var import_node_path4 = __toESM(require("node:path"));
|
|
2227
2227
|
var import_fetch_engine = require("@prisma/fetch-engine");
|
|
2228
|
-
var
|
|
2228
|
+
var import_internals10 = require("@prisma/internals");
|
|
2229
2229
|
var import_fast_glob = require("fast-glob");
|
|
2230
2230
|
var import_fs_extra = __toESM(require_lib());
|
|
2231
2231
|
|
|
@@ -2898,11 +2898,51 @@ var GenericArgsInfo = class {
|
|
|
2898
2898
|
}
|
|
2899
2899
|
};
|
|
2900
2900
|
|
|
2901
|
+
// src/TSClient/file-generators/BrowserFile.ts
|
|
2902
|
+
var import_internals3 = require("@prisma/internals");
|
|
2903
|
+
|
|
2904
|
+
// src/TSClient/ModelExports.ts
|
|
2905
|
+
var ts3 = __toESM(require("@prisma/ts-builders"));
|
|
2906
|
+
function modelExports(context) {
|
|
2907
|
+
return Object.values(context.dmmf.typeAndModelMap).filter((model) => context.dmmf.outputTypeMap.model[model.name]).map((model) => {
|
|
2908
|
+
const docLines = model.documentation ?? "";
|
|
2909
|
+
const modelLine = `Model ${model.name}
|
|
2910
|
+
`;
|
|
2911
|
+
const docs = `${modelLine}${docLines}`;
|
|
2912
|
+
const suffix = "Model";
|
|
2913
|
+
const modelTypeExport = ts3.moduleExport(ts3.typeDeclaration(model.name, ts3.namedType(`Prisma.${model.name}${suffix}`))).setDocComment(ts3.docComment(docs));
|
|
2914
|
+
return ts3.stringify(modelTypeExport);
|
|
2915
|
+
});
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
// src/TSClient/file-generators/BrowserFile.ts
|
|
2919
|
+
var jsDocHeader = `/*
|
|
2920
|
+
* This file should be your main import to use Prisma-related types and utilities in a browser.
|
|
2921
|
+
* Use it to get access to models, enums, and input types.
|
|
2922
|
+
*
|
|
2923
|
+
* This file does not contain a \`PrismaClient\` class, nor several other helpers that are intended as server-side only.
|
|
2924
|
+
* See \`client.ts\` for the standard, server-side entry point.
|
|
2925
|
+
*
|
|
2926
|
+
* \u{1F7E2} You can import this file directly.
|
|
2927
|
+
*/
|
|
2928
|
+
`;
|
|
2929
|
+
function createBrowserFile(context, options) {
|
|
2930
|
+
const clientEngineType = (0, import_internals3.getClientEngineType)(options.generator);
|
|
2931
|
+
options.generator.config.engineType = clientEngineType;
|
|
2932
|
+
return `${jsDocHeader}
|
|
2933
|
+
import * as Prisma from '${context.importFileName("./internal/prismaNamespaceBrowser")}'
|
|
2934
|
+
export { Prisma }
|
|
2935
|
+
export * as $Enums from '${context.importFileName("./enums")}'
|
|
2936
|
+
export * from '${context.importFileName("./enums")}';
|
|
2937
|
+
${modelExports(context).join("\n")}
|
|
2938
|
+
`;
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2901
2941
|
// src/TSClient/file-generators/ClassFile.ts
|
|
2902
2942
|
var import_node_crypto = __toESM(require("node:crypto"));
|
|
2903
2943
|
var import_node_path2 = __toESM(require("node:path"));
|
|
2904
|
-
var
|
|
2905
|
-
var
|
|
2944
|
+
var import_internals4 = require("@prisma/internals");
|
|
2945
|
+
var ts6 = __toESM(require("@prisma/ts-builders"));
|
|
2906
2946
|
var import_ci_info = __toESM(require("ci-info"));
|
|
2907
2947
|
|
|
2908
2948
|
// src/utils/buildInjectableEdgeEnv.ts
|
|
@@ -3539,16 +3579,16 @@ function buildWasmFileMap({ activeProvider, runtimeName }) {
|
|
|
3539
3579
|
|
|
3540
3580
|
// src/TSClient/PrismaClient.ts
|
|
3541
3581
|
var import_client_common12 = require("@prisma/client-common");
|
|
3542
|
-
var
|
|
3582
|
+
var ts5 = __toESM(require("@prisma/ts-builders"));
|
|
3543
3583
|
var import_indent_string3 = __toESM(require("indent-string"));
|
|
3544
3584
|
|
|
3545
3585
|
// src/utils/runtimeImport.ts
|
|
3546
|
-
var
|
|
3586
|
+
var ts4 = __toESM(require("@prisma/ts-builders"));
|
|
3547
3587
|
function runtimeImport(name) {
|
|
3548
3588
|
return name;
|
|
3549
3589
|
}
|
|
3550
3590
|
function runtimeImportedType(name) {
|
|
3551
|
-
return
|
|
3591
|
+
return ts4.namedType(`runtime.${name}`);
|
|
3552
3592
|
}
|
|
3553
3593
|
|
|
3554
3594
|
// src/TSClient/utils/type-builders.ts
|
|
@@ -3568,14 +3608,14 @@ function optional(innerType) {
|
|
|
3568
3608
|
|
|
3569
3609
|
// src/TSClient/PrismaClient.ts
|
|
3570
3610
|
function extendsPropertyDefinition() {
|
|
3571
|
-
const extendsDefinition =
|
|
3572
|
-
|
|
3611
|
+
const extendsDefinition = ts5.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts5.stringLiteral("extends")).addGenericArgument(ts5.namedType("Prisma.TypeMapCb").addGenericArgument(ts5.namedType("OmitOpts"))).addGenericArgument(ts5.namedType("ExtArgs")).addGenericArgument(
|
|
3612
|
+
ts5.namedType("runtime.Types.Utils.Call").addGenericArgument(ts5.namedType("Prisma.TypeMapCb").addGenericArgument(ts5.namedType("OmitOpts"))).addGenericArgument(ts5.objectType().add(ts5.property("extArgs", ts5.namedType("ExtArgs"))))
|
|
3573
3613
|
);
|
|
3574
|
-
return
|
|
3614
|
+
return ts5.stringify(ts5.property("$extends", extendsDefinition), { indentLevel: 1 });
|
|
3575
3615
|
}
|
|
3576
3616
|
function batchingTransactionDefinition(context) {
|
|
3577
|
-
const method3 =
|
|
3578
|
-
|
|
3617
|
+
const method3 = ts5.method("$transaction").setDocComment(
|
|
3618
|
+
ts5.docComment`
|
|
3579
3619
|
Allows the running of a sequence of read/write operations that are guaranteed to either succeed or fail as a whole.
|
|
3580
3620
|
@example
|
|
3581
3621
|
\`\`\`
|
|
@@ -3588,25 +3628,25 @@ function batchingTransactionDefinition(context) {
|
|
|
3588
3628
|
|
|
3589
3629
|
Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions).
|
|
3590
3630
|
`
|
|
3591
|
-
).addGenericParameter(
|
|
3631
|
+
).addGenericParameter(ts5.genericParameter("P").extends(ts5.array(prismaPromise(ts5.anyType)))).addParameter(ts5.parameter("arg", ts5.arraySpread(ts5.namedType("P")))).setReturnType(promise(ts5.namedType("runtime.Types.Utils.UnwrapTuple").addGenericArgument(ts5.namedType("P"))));
|
|
3592
3632
|
if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
3593
|
-
const options =
|
|
3594
|
-
method3.addParameter(
|
|
3633
|
+
const options = ts5.objectType().formatInline().add(ts5.property("isolationLevel", ts5.namedType("Prisma.TransactionIsolationLevel")).optional());
|
|
3634
|
+
method3.addParameter(ts5.parameter("options", options).optional());
|
|
3595
3635
|
}
|
|
3596
|
-
return
|
|
3636
|
+
return ts5.stringify(method3, { indentLevel: 1, newLine: "leading" });
|
|
3597
3637
|
}
|
|
3598
3638
|
function interactiveTransactionDefinition(context) {
|
|
3599
|
-
const options =
|
|
3639
|
+
const options = ts5.objectType().formatInline().add(ts5.property("maxWait", ts5.numberType).optional()).add(ts5.property("timeout", ts5.numberType).optional());
|
|
3600
3640
|
if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
3601
|
-
const isolationLevel =
|
|
3641
|
+
const isolationLevel = ts5.property("isolationLevel", ts5.namedType("Prisma.TransactionIsolationLevel")).optional();
|
|
3602
3642
|
options.add(isolationLevel);
|
|
3603
3643
|
}
|
|
3604
|
-
const returnType = promise(
|
|
3605
|
-
const callbackType =
|
|
3606
|
-
|
|
3644
|
+
const returnType = promise(ts5.namedType("R"));
|
|
3645
|
+
const callbackType = ts5.functionType().addParameter(
|
|
3646
|
+
ts5.parameter("prisma", omit(ts5.namedType("PrismaClient"), ts5.namedType("runtime.ITXClientDenyList")))
|
|
3607
3647
|
).setReturnType(returnType);
|
|
3608
|
-
const method3 =
|
|
3609
|
-
return
|
|
3648
|
+
const method3 = ts5.method("$transaction").addGenericParameter(ts5.genericParameter("R")).addParameter(ts5.parameter("fn", callbackType)).addParameter(ts5.parameter("options", options).optional()).setReturnType(returnType);
|
|
3649
|
+
return ts5.stringify(method3, { indentLevel: 1, newLine: "leading" });
|
|
3610
3650
|
}
|
|
3611
3651
|
function queryRawDefinition(context) {
|
|
3612
3652
|
if (!context.dmmf.mappings.otherOperations.write.includes("queryRaw")) {
|
|
@@ -3671,9 +3711,9 @@ function queryRawTypedDefinition(context) {
|
|
|
3671
3711
|
if (!context.dmmf.mappings.otherOperations.write.includes("queryRaw")) {
|
|
3672
3712
|
return "";
|
|
3673
3713
|
}
|
|
3674
|
-
const param =
|
|
3675
|
-
const method3 =
|
|
3676
|
-
|
|
3714
|
+
const param = ts5.genericParameter("T");
|
|
3715
|
+
const method3 = ts5.method("$queryRawTyped").setDocComment(
|
|
3716
|
+
ts5.docComment`
|
|
3677
3717
|
Executes a typed SQL query and returns a typed result
|
|
3678
3718
|
@example
|
|
3679
3719
|
\`\`\`
|
|
@@ -3683,19 +3723,19 @@ function queryRawTypedDefinition(context) {
|
|
|
3683
3723
|
\`\`\`
|
|
3684
3724
|
`
|
|
3685
3725
|
).addGenericParameter(param).addParameter(
|
|
3686
|
-
|
|
3726
|
+
ts5.parameter(
|
|
3687
3727
|
"typedSql",
|
|
3688
|
-
runtimeImportedType("TypedSql").addGenericArgument(
|
|
3728
|
+
runtimeImportedType("TypedSql").addGenericArgument(ts5.array(ts5.unknownType)).addGenericArgument(param.toArgument())
|
|
3689
3729
|
)
|
|
3690
|
-
).setReturnType(prismaPromise(
|
|
3691
|
-
return
|
|
3730
|
+
).setReturnType(prismaPromise(ts5.array(param.toArgument())));
|
|
3731
|
+
return ts5.stringify(method3, { indentLevel: 1, newLine: "leading" });
|
|
3692
3732
|
}
|
|
3693
3733
|
function metricDefinition(context) {
|
|
3694
3734
|
if (!context.isPreviewFeatureOn("metrics")) {
|
|
3695
3735
|
return "";
|
|
3696
3736
|
}
|
|
3697
|
-
const property13 =
|
|
3698
|
-
|
|
3737
|
+
const property13 = ts5.property("$metrics", ts5.namedType(`runtime.${runtimeImport("MetricsClient")}`)).setDocComment(
|
|
3738
|
+
ts5.docComment`
|
|
3699
3739
|
Gives access to the client metrics in json or prometheus format.
|
|
3700
3740
|
|
|
3701
3741
|
@example
|
|
@@ -3706,13 +3746,13 @@ function metricDefinition(context) {
|
|
|
3706
3746
|
\`\`\`
|
|
3707
3747
|
`
|
|
3708
3748
|
).readonly();
|
|
3709
|
-
return
|
|
3749
|
+
return ts5.stringify(property13, { indentLevel: 1, newLine: "leading" });
|
|
3710
3750
|
}
|
|
3711
3751
|
function runCommandRawDefinition(context) {
|
|
3712
3752
|
if (!context.dmmf.mappings.otherOperations.write.includes("runCommandRaw")) {
|
|
3713
3753
|
return "";
|
|
3714
3754
|
}
|
|
3715
|
-
const method3 =
|
|
3755
|
+
const method3 = ts5.method("$runCommandRaw").addParameter(ts5.parameter("command", ts5.namedType("Prisma.InputJsonObject"))).setReturnType(prismaPromise(ts5.namedType("Prisma.JsonObject"))).setDocComment(ts5.docComment`
|
|
3716
3756
|
Executes a raw MongoDB command and returns the result of it.
|
|
3717
3757
|
@example
|
|
3718
3758
|
\`\`\`
|
|
@@ -3725,7 +3765,7 @@ function runCommandRawDefinition(context) {
|
|
|
3725
3765
|
|
|
3726
3766
|
Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
|
|
3727
3767
|
`);
|
|
3728
|
-
return
|
|
3768
|
+
return ts5.stringify(method3, { indentLevel: 1, newLine: "leading" });
|
|
3729
3769
|
}
|
|
3730
3770
|
function eventRegistrationMethodDeclaration(runtimeName) {
|
|
3731
3771
|
if (runtimeName === "binary") {
|
|
@@ -3744,7 +3784,7 @@ function getPrismaClientClassDocComment({ dmmf }) {
|
|
|
3744
3784
|
plural: "users"
|
|
3745
3785
|
};
|
|
3746
3786
|
}
|
|
3747
|
-
return
|
|
3787
|
+
return ts5.docComment`
|
|
3748
3788
|
## Prisma Client
|
|
3749
3789
|
|
|
3750
3790
|
Type-safe database client for TypeScript
|
|
@@ -3764,7 +3804,7 @@ var PrismaClientClass = class {
|
|
|
3764
3804
|
this.runtimeName = runtimeName;
|
|
3765
3805
|
}
|
|
3766
3806
|
get jsDoc() {
|
|
3767
|
-
return
|
|
3807
|
+
return ts5.stringify(getPrismaClientClassDocComment(this.context));
|
|
3768
3808
|
}
|
|
3769
3809
|
toTS() {
|
|
3770
3810
|
const { dmmf } = this.context;
|
|
@@ -3838,15 +3878,15 @@ get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
|
|
|
3838
3878
|
if (this.runtimeName !== "react-native") {
|
|
3839
3879
|
return null;
|
|
3840
3880
|
}
|
|
3841
|
-
const method3 =
|
|
3842
|
-
|
|
3881
|
+
const method3 = ts5.method("$applyPendingMigrations").setReturnType(promise(ts5.voidType)).setDocComment(
|
|
3882
|
+
ts5.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.`
|
|
3843
3883
|
);
|
|
3844
|
-
return
|
|
3884
|
+
return ts5.stringify(method3, { indentLevel: 1, newLine: "leading" });
|
|
3845
3885
|
}
|
|
3846
3886
|
};
|
|
3847
3887
|
|
|
3848
3888
|
// src/TSClient/file-generators/ClassFile.ts
|
|
3849
|
-
var
|
|
3889
|
+
var jsDocHeader2 = `/*
|
|
3850
3890
|
* WARNING: This is an internal file that is subject to change!
|
|
3851
3891
|
*
|
|
3852
3892
|
* \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
|
|
@@ -3856,12 +3896,12 @@ var jsDocHeader = `/*
|
|
|
3856
3896
|
`;
|
|
3857
3897
|
function createClassFile(context, options) {
|
|
3858
3898
|
const imports = [
|
|
3859
|
-
|
|
3860
|
-
|
|
3899
|
+
ts6.moduleImport(context.runtimeImport).asNamespace("runtime"),
|
|
3900
|
+
ts6.moduleImport(context.importFileName(`./prismaNamespace`)).asNamespace("Prisma").typeOnly()
|
|
3861
3901
|
];
|
|
3862
|
-
const stringifiedImports = imports.map((i) =>
|
|
3902
|
+
const stringifiedImports = imports.map((i) => ts6.stringify(i));
|
|
3863
3903
|
const prismaClientClass = new PrismaClientClass(context, options.runtimeName);
|
|
3864
|
-
return `${
|
|
3904
|
+
return `${jsDocHeader2}
|
|
3865
3905
|
${stringifiedImports.join("\n")}
|
|
3866
3906
|
|
|
3867
3907
|
${clientConfig(context, options)}
|
|
@@ -3888,13 +3928,13 @@ function clientConfig(context, options) {
|
|
|
3888
3928
|
activeProvider,
|
|
3889
3929
|
moduleFormat
|
|
3890
3930
|
} = options;
|
|
3891
|
-
const clientEngineType = (0,
|
|
3931
|
+
const clientEngineType = (0, import_internals4.getClientEngineType)(generator);
|
|
3892
3932
|
generator.config.engineType = clientEngineType;
|
|
3893
3933
|
const inlineSchemaHash = import_node_crypto.default.createHash("sha256").update(Buffer.from(inlineSchema, "utf8").toString("base64")).digest("hex");
|
|
3894
3934
|
const datasourceFilePath = datasources[0].sourceFilePath;
|
|
3895
3935
|
const config = {
|
|
3896
3936
|
generator,
|
|
3897
|
-
relativePath: (0,
|
|
3937
|
+
relativePath: (0, import_internals4.pathToPosix)(import_node_path2.default.relative(outputDir, import_node_path2.default.dirname(datasourceFilePath))),
|
|
3898
3938
|
clientVersion: options.clientVersion,
|
|
3899
3939
|
engineVersion: options.engineVersion,
|
|
3900
3940
|
datasourceNames: datasources.map((d) => d.name),
|
|
@@ -3920,12 +3960,12 @@ ${buildDebugInitialization(edge)}
|
|
|
3920
3960
|
|
|
3921
3961
|
// src/TSClient/file-generators/ClientFile.ts
|
|
3922
3962
|
var import_node_path3 = __toESM(require("node:path"));
|
|
3923
|
-
var
|
|
3924
|
-
var
|
|
3963
|
+
var import_internals6 = require("@prisma/internals");
|
|
3964
|
+
var ts7 = __toESM(require("@prisma/ts-builders"));
|
|
3925
3965
|
|
|
3926
3966
|
// src/utils/buildNFTAnnotations.ts
|
|
3927
3967
|
var import_get_platform = require("@prisma/get-platform");
|
|
3928
|
-
var
|
|
3968
|
+
var import_internals5 = require("@prisma/internals");
|
|
3929
3969
|
var import_path = __toESM(require("path"));
|
|
3930
3970
|
function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir) {
|
|
3931
3971
|
if (noEngine === true) return "";
|
|
@@ -3934,7 +3974,7 @@ function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir
|
|
|
3934
3974
|
}
|
|
3935
3975
|
if (process.env.NETLIFY) {
|
|
3936
3976
|
const isNodeMajor20OrUp = parseInt(process.versions.node.split(".")[0]) >= 20;
|
|
3937
|
-
const awsRuntimeVersion = (0,
|
|
3977
|
+
const awsRuntimeVersion = (0, import_internals5.parseAWSNodejsRuntimeEnvVarVersion)();
|
|
3938
3978
|
const isRuntimeEnvVar20OrUp = awsRuntimeVersion && awsRuntimeVersion >= 20;
|
|
3939
3979
|
const isRuntimeEnvVar18OrDown = awsRuntimeVersion && awsRuntimeVersion <= 18;
|
|
3940
3980
|
if ((isNodeMajor20OrUp || isRuntimeEnvVar20OrUp) && !isRuntimeEnvVar18OrDown) {
|
|
@@ -3950,10 +3990,10 @@ function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir
|
|
|
3950
3990
|
return `${engineAnnotations}`;
|
|
3951
3991
|
}
|
|
3952
3992
|
function getQueryEngineFilename(engineType, binaryTarget) {
|
|
3953
|
-
if (engineType ===
|
|
3993
|
+
if (engineType === import_internals5.ClientEngineType.Library) {
|
|
3954
3994
|
return (0, import_get_platform.getNodeAPIName)(binaryTarget, "fs");
|
|
3955
3995
|
}
|
|
3956
|
-
if (engineType ===
|
|
3996
|
+
if (engineType === import_internals5.ClientEngineType.Binary) {
|
|
3957
3997
|
return `query-engine-${binaryTarget}`;
|
|
3958
3998
|
}
|
|
3959
3999
|
return void 0;
|
|
@@ -3962,56 +4002,49 @@ function buildNFTAnnotation(fileName, relativeOutdir) {
|
|
|
3962
4002
|
const relativeFilePath = import_path.default.join(relativeOutdir, fileName);
|
|
3963
4003
|
return `
|
|
3964
4004
|
// file annotations for bundling tools to include these files
|
|
3965
|
-
path.join(__dirname, ${JSON.stringify((0,
|
|
3966
|
-
path.join(process.cwd(), ${JSON.stringify((0,
|
|
4005
|
+
path.join(__dirname, ${JSON.stringify((0, import_internals5.pathToPosix)(fileName))})
|
|
4006
|
+
path.join(process.cwd(), ${JSON.stringify((0, import_internals5.pathToPosix)(relativeFilePath))})`;
|
|
3967
4007
|
}
|
|
3968
4008
|
|
|
3969
4009
|
// src/TSClient/file-generators/ClientFile.ts
|
|
3970
|
-
var
|
|
4010
|
+
var jsDocHeader3 = `/*
|
|
3971
4011
|
* This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types.
|
|
3972
|
-
*
|
|
4012
|
+
* If you're looking for something you can import in the client-side of your application, please refer to the \`browser.ts\` file instead.
|
|
4013
|
+
*
|
|
3973
4014
|
* \u{1F7E2} You can import this file directly.
|
|
3974
4015
|
*/
|
|
3975
4016
|
`;
|
|
3976
4017
|
function createClientFile(context, options) {
|
|
3977
|
-
const clientEngineType = (0,
|
|
4018
|
+
const clientEngineType = (0, import_internals6.getClientEngineType)(options.generator);
|
|
3978
4019
|
options.generator.config.engineType = clientEngineType;
|
|
3979
4020
|
const imports = [
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
].map((i) =>
|
|
4021
|
+
ts7.moduleImport(context.runtimeImport).asNamespace("runtime"),
|
|
4022
|
+
ts7.moduleImport(context.importFileName("./enums")).asNamespace("$Enums"),
|
|
4023
|
+
ts7.moduleImport(context.importFileName("./internal/class")).asNamespace("$Class"),
|
|
4024
|
+
ts7.moduleImport(context.importFileName("./internal/prismaNamespace")).asNamespace("Prisma")
|
|
4025
|
+
].map((i) => ts7.stringify(i));
|
|
3985
4026
|
const exports2 = [
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
4027
|
+
ts7.moduleExportFrom(context.importFileName("./enums")).asNamespace("$Enums"),
|
|
4028
|
+
ts7.moduleExportFrom(context.importFileName("./enums")),
|
|
4029
|
+
ts7.moduleExport(
|
|
4030
|
+
ts7.constDeclaration("PrismaClient").setValue(ts7.functionCall("$Class.getPrismaClientClass", [ts7.namedValue("__dirname")]))
|
|
3990
4031
|
).setDocComment(getPrismaClientClassDocComment(context)),
|
|
3991
|
-
|
|
3992
|
-
|
|
4032
|
+
ts7.moduleExport(
|
|
4033
|
+
ts7.typeDeclaration(
|
|
3993
4034
|
"PrismaClient",
|
|
3994
|
-
|
|
4035
|
+
ts7.namedType("$Class.PrismaClient").addGenericArgument(ts7.namedType("LogOpts")).addGenericArgument(ts7.namedType("OmitOpts")).addGenericArgument(ts7.namedType("ExtArgs"))
|
|
3995
4036
|
).addGenericParameter(
|
|
3996
|
-
|
|
4037
|
+
ts7.genericParameter("LogOpts").extends(ts7.namedType("Prisma.LogLevel")).default(ts7.neverType)
|
|
3997
4038
|
).addGenericParameter(
|
|
3998
|
-
|
|
4039
|
+
ts7.genericParameter("OmitOpts").extends(ts7.namedType("Prisma.PrismaClientOptions").subKey("omit")).default(ts7.namedType("Prisma.PrismaClientOptions").subKey("omit"))
|
|
3999
4040
|
).addGenericParameter(
|
|
4000
|
-
|
|
4041
|
+
ts7.genericParameter("ExtArgs").extends(ts7.namedType("runtime.Types.Extensions.InternalArgs")).default(ts7.namedType("runtime.Types.Extensions.DefaultArgs"))
|
|
4001
4042
|
)
|
|
4002
4043
|
)
|
|
4003
|
-
].map((e) =>
|
|
4004
|
-
const
|
|
4005
|
-
const docLines = model.documentation ?? "";
|
|
4006
|
-
const modelLine = `Model ${model.name}
|
|
4007
|
-
`;
|
|
4008
|
-
const docs = `${modelLine}${docLines}`;
|
|
4009
|
-
const modelTypeExport = ts6.moduleExport(ts6.typeDeclaration(model.name, ts6.namedType(`Prisma.${model.name}Model`))).setDocComment(ts6.docComment(docs));
|
|
4010
|
-
return ts6.stringify(modelTypeExport);
|
|
4011
|
-
});
|
|
4012
|
-
const binaryTargets = clientEngineType === import_internals5.ClientEngineType.Library ? Object.keys(options.binaryPaths.libqueryEngine ?? {}) : Object.keys(options.binaryPaths.queryEngine ?? {});
|
|
4044
|
+
].map((e) => ts7.stringify(e));
|
|
4045
|
+
const binaryTargets = clientEngineType === import_internals6.ClientEngineType.Library ? Object.keys(options.binaryPaths.libqueryEngine ?? {}) : Object.keys(options.binaryPaths.queryEngine ?? {});
|
|
4013
4046
|
const relativeOutdir = import_node_path3.default.relative(process.cwd(), options.outputDir);
|
|
4014
|
-
return `${
|
|
4047
|
+
return `${jsDocHeader3}
|
|
4015
4048
|
${buildPreamble(options.edge, options.moduleFormat)}
|
|
4016
4049
|
${imports.join("\n")}
|
|
4017
4050
|
|
|
@@ -4020,7 +4053,7 @@ export { Prisma }
|
|
|
4020
4053
|
|
|
4021
4054
|
${buildNFTAnnotations(options.edge || !options.copyEngine, clientEngineType, binaryTargets, relativeOutdir)}
|
|
4022
4055
|
|
|
4023
|
-
${modelExports.join("\n")}
|
|
4056
|
+
${modelExports(context).join("\n")}
|
|
4024
4057
|
`;
|
|
4025
4058
|
}
|
|
4026
4059
|
function buildPreamble(edge, moduleFormat) {
|
|
@@ -4040,8 +4073,8 @@ globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url))
|
|
|
4040
4073
|
}
|
|
4041
4074
|
|
|
4042
4075
|
// src/TSClient/file-generators/CommonInputTypesFile.ts
|
|
4043
|
-
var
|
|
4044
|
-
var
|
|
4076
|
+
var ts8 = __toESM(require("@prisma/ts-builders"));
|
|
4077
|
+
var jsDocHeader4 = `/*
|
|
4045
4078
|
* This file exports various common sort, input & filter types that are not directly linked to a particular model.
|
|
4046
4079
|
*
|
|
4047
4080
|
* \u{1F7E2} You can import this file directly.
|
|
@@ -4049,12 +4082,12 @@ var jsDocHeader3 = `/*
|
|
|
4049
4082
|
`;
|
|
4050
4083
|
function createCommonInputTypeFiles(context) {
|
|
4051
4084
|
const imports = [
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
].map((i) =>
|
|
4085
|
+
ts8.moduleImport(context.runtimeImport).asNamespace("runtime").typeOnly(),
|
|
4086
|
+
ts8.moduleImport(context.importFileName(`./enums`)).asNamespace("$Enums"),
|
|
4087
|
+
ts8.moduleImport(context.importFileName(`./internal/prismaNamespace`)).asNamespace("Prisma").typeOnly()
|
|
4088
|
+
].map((i) => ts8.stringify(i));
|
|
4056
4089
|
const genericInputTypes = context.dmmf.inputObjectTypes.prisma?.filter((i) => !i.meta?.grouping)?.map((inputType) => new InputType(inputType, context).toTS()) ?? [];
|
|
4057
|
-
return `${
|
|
4090
|
+
return `${jsDocHeader4}
|
|
4058
4091
|
${imports.join("\n")}
|
|
4059
4092
|
|
|
4060
4093
|
${genericInputTypes.join("\n")}
|
|
@@ -4065,7 +4098,7 @@ ${context.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputTyp
|
|
|
4065
4098
|
|
|
4066
4099
|
// src/TSClient/file-generators/EnumsFile.ts
|
|
4067
4100
|
var import_dmmf = require("@prisma/dmmf");
|
|
4068
|
-
var
|
|
4101
|
+
var jsDocHeader5 = `/*
|
|
4069
4102
|
* This file exports all enum related types from the schema.
|
|
4070
4103
|
*
|
|
4071
4104
|
* \u{1F7E2} You can import this file directly.
|
|
@@ -4078,35 +4111,35 @@ function createEnumsFile(context) {
|
|
|
4078
4111
|
modelEnums.push(new Enum((0, import_dmmf.datamodelEnumToSchemaEnum)(datamodelEnum), false).toTS());
|
|
4079
4112
|
}
|
|
4080
4113
|
if (modelEnums.length === 0) {
|
|
4081
|
-
return `${
|
|
4114
|
+
return `${jsDocHeader5}
|
|
4082
4115
|
|
|
4083
4116
|
// This file is empty because there are no enums in the schema.
|
|
4084
4117
|
export {}
|
|
4085
4118
|
`;
|
|
4086
4119
|
}
|
|
4087
|
-
return
|
|
4120
|
+
return jsDocHeader5 + modelEnums.join("\n\n");
|
|
4088
4121
|
}
|
|
4089
4122
|
|
|
4090
4123
|
// src/TSClient/file-generators/ModelFile.ts
|
|
4091
|
-
var
|
|
4124
|
+
var ts15 = __toESM(require("@prisma/ts-builders"));
|
|
4092
4125
|
|
|
4093
4126
|
// src/TSClient/Model.ts
|
|
4094
4127
|
var import_client_common16 = require("@prisma/client-common");
|
|
4095
4128
|
var DMMF2 = __toESM(require("@prisma/dmmf"));
|
|
4096
|
-
var
|
|
4129
|
+
var ts14 = __toESM(require("@prisma/ts-builders"));
|
|
4097
4130
|
var import_indent_string5 = __toESM(require("indent-string"));
|
|
4098
4131
|
var import_klona = require("klona");
|
|
4099
4132
|
|
|
4100
4133
|
// src/TSClient/Args.ts
|
|
4101
|
-
var
|
|
4134
|
+
var ts9 = __toESM(require("@prisma/ts-builders"));
|
|
4102
4135
|
var ArgsTypeBuilder = class {
|
|
4103
4136
|
constructor(type, context, action) {
|
|
4104
4137
|
this.type = type;
|
|
4105
4138
|
this.context = context;
|
|
4106
4139
|
this.action = action;
|
|
4107
|
-
this.moduleExport =
|
|
4108
|
-
|
|
4109
|
-
).setDocComment(
|
|
4140
|
+
this.moduleExport = ts9.moduleExport(
|
|
4141
|
+
ts9.typeDeclaration(getModelArgName(type.name, action), ts9.objectType()).addGenericParameter(extArgsParam)
|
|
4142
|
+
).setDocComment(ts9.docComment(`${type.name} ${action ?? "without action"}`));
|
|
4110
4143
|
}
|
|
4111
4144
|
moduleExport;
|
|
4112
4145
|
addProperty(prop) {
|
|
@@ -4117,7 +4150,7 @@ var ArgsTypeBuilder = class {
|
|
|
4117
4150
|
const inputField = buildInputField(arg, this.context);
|
|
4118
4151
|
const docComment9 = getArgFieldJSDoc(this.type, this.action, arg);
|
|
4119
4152
|
if (docComment9) {
|
|
4120
|
-
inputField.setDocComment(
|
|
4153
|
+
inputField.setDocComment(ts9.docComment(docComment9));
|
|
4121
4154
|
}
|
|
4122
4155
|
this.addProperty(inputField);
|
|
4123
4156
|
}
|
|
@@ -4125,13 +4158,13 @@ var ArgsTypeBuilder = class {
|
|
|
4125
4158
|
}
|
|
4126
4159
|
addSelectArg(selectTypeName = getSelectName(this.type.name)) {
|
|
4127
4160
|
this.addProperty(
|
|
4128
|
-
|
|
4161
|
+
ts9.property(
|
|
4129
4162
|
"select",
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4163
|
+
ts9.unionType([
|
|
4164
|
+
ts9.namedType(`Prisma.${selectTypeName}`).addGenericArgument(extArgsParam.toArgument()),
|
|
4165
|
+
ts9.nullType
|
|
4133
4166
|
])
|
|
4134
|
-
).optional().setDocComment(
|
|
4167
|
+
).optional().setDocComment(ts9.docComment(`Select specific fields to fetch from the ${this.type.name}`))
|
|
4135
4168
|
);
|
|
4136
4169
|
return this;
|
|
4137
4170
|
}
|
|
@@ -4141,25 +4174,25 @@ var ArgsTypeBuilder = class {
|
|
|
4141
4174
|
return this;
|
|
4142
4175
|
}
|
|
4143
4176
|
this.addProperty(
|
|
4144
|
-
|
|
4177
|
+
ts9.property(
|
|
4145
4178
|
"include",
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4179
|
+
ts9.unionType([
|
|
4180
|
+
ts9.namedType(`Prisma.${includeTypeName}`).addGenericArgument(extArgsParam.toArgument()),
|
|
4181
|
+
ts9.nullType
|
|
4149
4182
|
])
|
|
4150
|
-
).optional().setDocComment(
|
|
4183
|
+
).optional().setDocComment(ts9.docComment("Choose, which related nodes to fetch as well"))
|
|
4151
4184
|
);
|
|
4152
4185
|
return this;
|
|
4153
4186
|
}
|
|
4154
4187
|
addOmitArg() {
|
|
4155
4188
|
this.addProperty(
|
|
4156
|
-
|
|
4189
|
+
ts9.property(
|
|
4157
4190
|
"omit",
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4191
|
+
ts9.unionType([
|
|
4192
|
+
ts9.namedType(`Prisma.${getOmitName(this.type.name)}`).addGenericArgument(extArgsParam.toArgument()),
|
|
4193
|
+
ts9.nullType
|
|
4161
4194
|
])
|
|
4162
|
-
).optional().setDocComment(
|
|
4195
|
+
).optional().setDocComment(ts9.docComment(`Omit specific fields from the ${this.type.name}`))
|
|
4163
4196
|
);
|
|
4164
4197
|
return this;
|
|
4165
4198
|
}
|
|
@@ -4168,7 +4201,7 @@ var ArgsTypeBuilder = class {
|
|
|
4168
4201
|
return this;
|
|
4169
4202
|
}
|
|
4170
4203
|
setComment(comment) {
|
|
4171
|
-
this.moduleExport.setDocComment(
|
|
4204
|
+
this.moduleExport.setDocComment(ts9.docComment(comment));
|
|
4172
4205
|
return this;
|
|
4173
4206
|
}
|
|
4174
4207
|
createExport() {
|
|
@@ -4178,60 +4211,60 @@ var ArgsTypeBuilder = class {
|
|
|
4178
4211
|
|
|
4179
4212
|
// src/TSClient/Count.ts
|
|
4180
4213
|
var import_client_common13 = require("@prisma/client-common");
|
|
4181
|
-
var
|
|
4214
|
+
var ts11 = __toESM(require("@prisma/ts-builders"));
|
|
4182
4215
|
var import_indent_string4 = __toESM(require("indent-string"));
|
|
4183
4216
|
|
|
4184
4217
|
// src/TSClient/Output.ts
|
|
4185
|
-
var
|
|
4186
|
-
var
|
|
4218
|
+
var import_internals7 = require("@prisma/internals");
|
|
4219
|
+
var ts10 = __toESM(require("@prisma/ts-builders"));
|
|
4187
4220
|
function buildModelOutputProperty(field, dmmf) {
|
|
4188
|
-
let fieldTypeName = (0,
|
|
4221
|
+
let fieldTypeName = (0, import_internals7.hasOwnProperty)(GraphQLScalarToJSTypeTable, field.type) ? GraphQLScalarToJSTypeTable[field.type] : field.type;
|
|
4189
4222
|
if (Array.isArray(fieldTypeName)) {
|
|
4190
4223
|
fieldTypeName = fieldTypeName[0];
|
|
4191
4224
|
}
|
|
4192
4225
|
let fieldType;
|
|
4193
4226
|
if (field.kind === "object") {
|
|
4194
|
-
const payloadType =
|
|
4227
|
+
const payloadType = ts10.namedType(getPayloadName(field.type));
|
|
4195
4228
|
if (!dmmf.isComposite(field.type)) {
|
|
4196
|
-
payloadType.addGenericArgument(
|
|
4229
|
+
payloadType.addGenericArgument(ts10.namedType("ExtArgs"));
|
|
4197
4230
|
}
|
|
4198
4231
|
fieldType = payloadType;
|
|
4199
4232
|
} else if (field.kind === "enum") {
|
|
4200
|
-
fieldType =
|
|
4233
|
+
fieldType = ts10.namedType(`$Enums.${fieldTypeName}`);
|
|
4201
4234
|
} else {
|
|
4202
|
-
fieldType =
|
|
4235
|
+
fieldType = ts10.namedType(fieldTypeName);
|
|
4203
4236
|
}
|
|
4204
4237
|
if (field.isList) {
|
|
4205
|
-
fieldType =
|
|
4238
|
+
fieldType = ts10.array(fieldType);
|
|
4206
4239
|
} else if (!field.isRequired) {
|
|
4207
|
-
fieldType =
|
|
4240
|
+
fieldType = ts10.unionType(fieldType).addVariant(ts10.nullType);
|
|
4208
4241
|
}
|
|
4209
|
-
const property13 =
|
|
4242
|
+
const property13 = ts10.property(field.name, fieldType);
|
|
4210
4243
|
if (field.documentation) {
|
|
4211
|
-
property13.setDocComment(
|
|
4244
|
+
property13.setDocComment(ts10.docComment(field.documentation));
|
|
4212
4245
|
}
|
|
4213
4246
|
return property13;
|
|
4214
4247
|
}
|
|
4215
4248
|
function buildOutputType(type) {
|
|
4216
|
-
return
|
|
4249
|
+
return ts10.moduleExport(ts10.typeDeclaration(type.name, ts10.objectType().addMultiple(type.fields.map(buildOutputField))));
|
|
4217
4250
|
}
|
|
4218
4251
|
function buildOutputField(field) {
|
|
4219
4252
|
let fieldType;
|
|
4220
4253
|
if (field.outputType.location === "enumTypes" && field.outputType.namespace === "model") {
|
|
4221
|
-
fieldType =
|
|
4254
|
+
fieldType = ts10.namedType(enumTypeName(field.outputType));
|
|
4222
4255
|
} else {
|
|
4223
4256
|
const typeNames = GraphQLScalarToJSTypeTable[field.outputType.type] ?? field.outputType.type;
|
|
4224
|
-
fieldType = Array.isArray(typeNames) ?
|
|
4257
|
+
fieldType = Array.isArray(typeNames) ? ts10.namedType(typeNames[0]) : ts10.namedType(typeNames);
|
|
4225
4258
|
}
|
|
4226
4259
|
if (field.outputType.isList) {
|
|
4227
|
-
fieldType =
|
|
4260
|
+
fieldType = ts10.array(fieldType);
|
|
4228
4261
|
} else if (field.isNullable) {
|
|
4229
|
-
fieldType =
|
|
4262
|
+
fieldType = ts10.unionType(fieldType).addVariant(ts10.nullType);
|
|
4230
4263
|
}
|
|
4231
|
-
const property13 =
|
|
4264
|
+
const property13 = ts10.property(field.name, fieldType);
|
|
4232
4265
|
if (field.deprecation) {
|
|
4233
4266
|
property13.setDocComment(
|
|
4234
|
-
|
|
4267
|
+
ts10.docComment(`@deprecated since ${field.deprecation.sinceVersion} because ${field.deprecation.reason}`)
|
|
4235
4268
|
);
|
|
4236
4269
|
}
|
|
4237
4270
|
return property13;
|
|
@@ -4271,7 +4304,7 @@ var Count = class {
|
|
|
4271
4304
|
* Count Type ${name}
|
|
4272
4305
|
*/
|
|
4273
4306
|
|
|
4274
|
-
${
|
|
4307
|
+
${ts11.stringify(outputType)}
|
|
4275
4308
|
|
|
4276
4309
|
export type ${getSelectName(
|
|
4277
4310
|
name
|
|
@@ -4291,7 +4324,7 @@ ${(0, import_indent_string4.default)(
|
|
|
4291
4324
|
)}
|
|
4292
4325
|
}
|
|
4293
4326
|
|
|
4294
|
-
${this.argsTypes.map((typeExport) =>
|
|
4327
|
+
${this.argsTypes.map((typeExport) => ts11.stringify(typeExport)).join("\n\n")}
|
|
4295
4328
|
`;
|
|
4296
4329
|
}
|
|
4297
4330
|
};
|
|
@@ -4328,12 +4361,12 @@ ${this.stringifyFields()}
|
|
|
4328
4361
|
|
|
4329
4362
|
// src/TSClient/Payload.ts
|
|
4330
4363
|
var import_client_common14 = require("@prisma/client-common");
|
|
4331
|
-
var
|
|
4364
|
+
var ts12 = __toESM(require("@prisma/ts-builders"));
|
|
4332
4365
|
function buildModelPayload(model, context) {
|
|
4333
4366
|
const isComposite = context.dmmf.isComposite(model.name);
|
|
4334
|
-
const objects =
|
|
4335
|
-
const scalars =
|
|
4336
|
-
const composites =
|
|
4367
|
+
const objects = ts12.objectType();
|
|
4368
|
+
const scalars = ts12.objectType();
|
|
4369
|
+
const composites = ts12.objectType();
|
|
4337
4370
|
for (const field of model.fields) {
|
|
4338
4371
|
if (field.kind === "object") {
|
|
4339
4372
|
if (context.dmmf.isComposite(field.type)) {
|
|
@@ -4345,20 +4378,20 @@ function buildModelPayload(model, context) {
|
|
|
4345
4378
|
scalars.add(buildModelOutputProperty(field, context.dmmf));
|
|
4346
4379
|
}
|
|
4347
4380
|
}
|
|
4348
|
-
const scalarsType = isComposite ? scalars :
|
|
4349
|
-
const payloadTypeDeclaration =
|
|
4381
|
+
const scalarsType = isComposite ? scalars : ts12.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts12.namedType("ExtArgs").subKey("result").subKey((0, import_client_common14.uncapitalize)(model.name)));
|
|
4382
|
+
const payloadTypeDeclaration = ts12.typeDeclaration(
|
|
4350
4383
|
getPayloadName(model.name, false),
|
|
4351
|
-
|
|
4384
|
+
ts12.objectType().add(ts12.property("name", ts12.stringLiteral(model.name))).add(ts12.property("objects", objects)).add(ts12.property("scalars", scalarsType)).add(ts12.property("composites", composites))
|
|
4352
4385
|
);
|
|
4353
4386
|
if (!isComposite) {
|
|
4354
4387
|
payloadTypeDeclaration.addGenericParameter(extArgsParam);
|
|
4355
4388
|
}
|
|
4356
|
-
return
|
|
4389
|
+
return ts12.moduleExport(payloadTypeDeclaration);
|
|
4357
4390
|
}
|
|
4358
4391
|
|
|
4359
4392
|
// src/TSClient/SelectIncludeOmit.ts
|
|
4360
4393
|
var import_client_common15 = require("@prisma/client-common");
|
|
4361
|
-
var
|
|
4394
|
+
var ts13 = __toESM(require("@prisma/ts-builders"));
|
|
4362
4395
|
function buildIncludeType({
|
|
4363
4396
|
modelName,
|
|
4364
4397
|
typeName = getIncludeName(modelName),
|
|
@@ -4369,14 +4402,14 @@ function buildIncludeType({
|
|
|
4369
4402
|
return buildExport(typeName, type);
|
|
4370
4403
|
}
|
|
4371
4404
|
function buildOmitType({ modelName, fields, context }) {
|
|
4372
|
-
const keysType =
|
|
4405
|
+
const keysType = ts13.unionType(
|
|
4373
4406
|
fields.filter(
|
|
4374
4407
|
(field) => field.outputType.location === "scalar" || field.outputType.location === "enumTypes" || context.dmmf.isComposite(field.outputType.type)
|
|
4375
|
-
).map((field) =>
|
|
4408
|
+
).map((field) => ts13.stringLiteral(field.name))
|
|
4376
4409
|
);
|
|
4377
|
-
const omitType =
|
|
4410
|
+
const omitType = ts13.namedType("runtime.Types.Extensions.GetOmit").addGenericArgument(keysType).addGenericArgument(modelResultExtensionsType(modelName));
|
|
4378
4411
|
if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
|
|
4379
|
-
omitType.addGenericArgument(
|
|
4412
|
+
omitType.addGenericArgument(ts13.namedType("runtime.Types.Skip"));
|
|
4380
4413
|
}
|
|
4381
4414
|
return buildExport(getOmitName(modelName), omitType);
|
|
4382
4415
|
}
|
|
@@ -4387,7 +4420,7 @@ function buildSelectType({
|
|
|
4387
4420
|
context
|
|
4388
4421
|
}) {
|
|
4389
4422
|
const objectType11 = buildSelectOrIncludeObject(modelName, fields, context);
|
|
4390
|
-
const selectType =
|
|
4423
|
+
const selectType = ts13.namedType("runtime.Types.Extensions.GetSelect").addGenericArgument(objectType11).addGenericArgument(modelResultExtensionsType(modelName));
|
|
4391
4424
|
return buildExport(typeName, selectType);
|
|
4392
4425
|
}
|
|
4393
4426
|
function modelResultExtensionsType(modelName) {
|
|
@@ -4399,24 +4432,24 @@ function buildScalarSelectType({ modelName, fields, context }) {
|
|
|
4399
4432
|
fields.filter((field) => field.outputType.location === "scalar" || field.outputType.location === "enumTypes"),
|
|
4400
4433
|
context
|
|
4401
4434
|
);
|
|
4402
|
-
return
|
|
4435
|
+
return ts13.moduleExport(ts13.typeDeclaration(`${getSelectName(modelName)}Scalar`, object));
|
|
4403
4436
|
}
|
|
4404
4437
|
function buildSelectOrIncludeObject(modelName, fields, context) {
|
|
4405
|
-
const objectType11 =
|
|
4438
|
+
const objectType11 = ts13.objectType();
|
|
4406
4439
|
for (const field of fields) {
|
|
4407
|
-
const fieldType =
|
|
4440
|
+
const fieldType = ts13.unionType(ts13.booleanType);
|
|
4408
4441
|
if (field.outputType.location === "outputObjectTypes") {
|
|
4409
|
-
const subSelectType =
|
|
4442
|
+
const subSelectType = ts13.namedType(`Prisma.${getFieldArgName(field, modelName)}`);
|
|
4410
4443
|
subSelectType.addGenericArgument(extArgsParam.toArgument());
|
|
4411
4444
|
fieldType.addVariant(subSelectType);
|
|
4412
4445
|
}
|
|
4413
|
-
objectType11.add(
|
|
4446
|
+
objectType11.add(ts13.property(field.name, appendSkipType(context, fieldType)).optional());
|
|
4414
4447
|
}
|
|
4415
4448
|
return objectType11;
|
|
4416
4449
|
}
|
|
4417
4450
|
function buildExport(typeName, type) {
|
|
4418
|
-
const declaration =
|
|
4419
|
-
return
|
|
4451
|
+
const declaration = ts13.typeDeclaration(typeName, type);
|
|
4452
|
+
return ts13.moduleExport(declaration.addGenericParameter(extArgsParam));
|
|
4420
4453
|
}
|
|
4421
4454
|
function getIncludeFields(fields, dmmf) {
|
|
4422
4455
|
return fields.filter((field) => {
|
|
@@ -4545,7 +4578,7 @@ ${(0, import_indent_string5.default)(
|
|
|
4545
4578
|
)}
|
|
4546
4579
|
}
|
|
4547
4580
|
|
|
4548
|
-
${
|
|
4581
|
+
${ts14.stringify(buildOutputType(groupByType))}
|
|
4549
4582
|
|
|
4550
4583
|
type ${getGroupByPayloadName(model.name)}<T extends ${groupByArgsName}> = Prisma.PrismaPromise<
|
|
4551
4584
|
Array<
|
|
@@ -4595,7 +4628,7 @@ type ${getGroupByPayloadName(model.name)}<T extends ${groupByArgsName}> = Prisma
|
|
|
4595
4628
|
}
|
|
4596
4629
|
const aggregateArgsName = getAggregateArgsName(model.name);
|
|
4597
4630
|
const aggregateName = getAggregateName(model.name);
|
|
4598
|
-
return `${aggregateTypes.map(buildOutputType).map((type) =>
|
|
4631
|
+
return `${aggregateTypes.map(buildOutputType).map((type) => ts14.stringify(type)).join("\n\n")}
|
|
4599
4632
|
|
|
4600
4633
|
${aggregateTypes.length > 1 ? aggregateTypes.slice(1).map((type) => {
|
|
4601
4634
|
const newType = {
|
|
@@ -4663,31 +4696,31 @@ export type ${getAggregateGetName(model.name)}<T extends ${getAggregateArgsName(
|
|
|
4663
4696
|
const modelLine = `Model ${this.model.name}
|
|
4664
4697
|
`;
|
|
4665
4698
|
const docs = `${modelLine}${docLines}`;
|
|
4666
|
-
const modelTypeExport =
|
|
4667
|
-
|
|
4699
|
+
const modelTypeExport = ts14.moduleExport(
|
|
4700
|
+
ts14.typeDeclaration(
|
|
4668
4701
|
`${this.model.name}Model`,
|
|
4669
|
-
|
|
4702
|
+
ts14.namedType(`runtime.Types.Result.DefaultSelection`).addGenericArgument(ts14.namedType(getPayloadName(this.model.name)))
|
|
4670
4703
|
)
|
|
4671
|
-
).setDocComment(
|
|
4672
|
-
return
|
|
4704
|
+
).setDocComment(ts14.docComment(docs));
|
|
4705
|
+
return ts14.stringify(modelTypeExport);
|
|
4673
4706
|
}
|
|
4674
4707
|
toTS() {
|
|
4675
4708
|
const { model } = this;
|
|
4676
4709
|
const isComposite = this.dmmf.isComposite(model.name);
|
|
4677
|
-
const omitType =
|
|
4710
|
+
const omitType = ts14.stringify(
|
|
4678
4711
|
buildOmitType({ modelName: this.model.name, context: this.context, fields: this.type.fields }),
|
|
4679
4712
|
{
|
|
4680
4713
|
newLine: "leading"
|
|
4681
4714
|
}
|
|
4682
4715
|
);
|
|
4683
4716
|
const hasRelationField = model.fields.some((f) => f.kind === "object");
|
|
4684
|
-
const includeType = hasRelationField ?
|
|
4717
|
+
const includeType = hasRelationField ? ts14.stringify(
|
|
4685
4718
|
buildIncludeType({ modelName: this.model.name, context: this.context, fields: this.type.fields }),
|
|
4686
4719
|
{
|
|
4687
4720
|
newLine: "leading"
|
|
4688
4721
|
}
|
|
4689
4722
|
) : "";
|
|
4690
|
-
const createManyAndReturnIncludeType = hasRelationField && this.createManyAndReturnType ?
|
|
4723
|
+
const createManyAndReturnIncludeType = hasRelationField && this.createManyAndReturnType ? ts14.stringify(
|
|
4691
4724
|
buildIncludeType({
|
|
4692
4725
|
typeName: getIncludeCreateManyAndReturnName(this.model.name),
|
|
4693
4726
|
modelName: this.model.name,
|
|
@@ -4698,7 +4731,7 @@ export type ${getAggregateGetName(model.name)}<T extends ${getAggregateArgsName(
|
|
|
4698
4731
|
newLine: "leading"
|
|
4699
4732
|
}
|
|
4700
4733
|
) : "";
|
|
4701
|
-
const updateManyAndReturnIncludeType = hasRelationField && this.updateManyAndReturnType ?
|
|
4734
|
+
const updateManyAndReturnIncludeType = hasRelationField && this.updateManyAndReturnType ? ts14.stringify(
|
|
4702
4735
|
buildIncludeType({
|
|
4703
4736
|
typeName: getIncludeUpdateManyAndReturnName(this.model.name),
|
|
4704
4737
|
modelName: this.model.name,
|
|
@@ -4720,8 +4753,8 @@ ${this.getDeepInputTypes()}
|
|
|
4720
4753
|
|
|
4721
4754
|
${this.getCountTypes()}
|
|
4722
4755
|
|
|
4723
|
-
${
|
|
4724
|
-
${this.createManyAndReturnType ?
|
|
4756
|
+
${ts14.stringify(buildSelectType({ modelName: this.model.name, fields: this.type.fields, context: this.context }))}
|
|
4757
|
+
${this.createManyAndReturnType ? ts14.stringify(
|
|
4725
4758
|
buildSelectType({
|
|
4726
4759
|
modelName: this.model.name,
|
|
4727
4760
|
fields: this.createManyAndReturnType.fields,
|
|
@@ -4730,7 +4763,7 @@ ${this.createManyAndReturnType ? ts13.stringify(
|
|
|
4730
4763
|
}),
|
|
4731
4764
|
{ newLine: "leading" }
|
|
4732
4765
|
) : ""}
|
|
4733
|
-
${this.updateManyAndReturnType ?
|
|
4766
|
+
${this.updateManyAndReturnType ? ts14.stringify(
|
|
4734
4767
|
buildSelectType({
|
|
4735
4768
|
modelName: this.model.name,
|
|
4736
4769
|
fields: this.updateManyAndReturnType.fields,
|
|
@@ -4739,12 +4772,12 @@ ${this.updateManyAndReturnType ? ts13.stringify(
|
|
|
4739
4772
|
}),
|
|
4740
4773
|
{ newLine: "leading" }
|
|
4741
4774
|
) : ""}
|
|
4742
|
-
${
|
|
4775
|
+
${ts14.stringify(buildScalarSelectType({ modelName: this.model.name, fields: this.type.fields, context: this.context }), {
|
|
4743
4776
|
newLine: "leading"
|
|
4744
4777
|
})}
|
|
4745
4778
|
${omitType}${includeType}${createManyAndReturnIncludeType}${updateManyAndReturnIncludeType}
|
|
4746
4779
|
|
|
4747
|
-
${
|
|
4780
|
+
${ts14.stringify(buildModelPayload(this.model, this.context), { newLine: "none" })}
|
|
4748
4781
|
|
|
4749
4782
|
export type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
|
|
4750
4783
|
model.name
|
|
@@ -4755,7 +4788,7 @@ ${isComposite ? "" : new ModelDelegate(this.type, this.context).toTS()}
|
|
|
4755
4788
|
${new ModelFieldRefs(this.type).toTS()}
|
|
4756
4789
|
|
|
4757
4790
|
// Custom InputTypes
|
|
4758
|
-
${this.argsTypes.map((type) =>
|
|
4791
|
+
${this.argsTypes.map((type) => ts14.stringify(type)).join("\n\n")}
|
|
4759
4792
|
`;
|
|
4760
4793
|
}
|
|
4761
4794
|
};
|
|
@@ -4786,7 +4819,7 @@ var ModelDelegate = class {
|
|
|
4786
4819
|
const nonAggregateActions = this.getNonAggregateActions(availableActions);
|
|
4787
4820
|
const groupByArgsName = getGroupByArgsName(name);
|
|
4788
4821
|
const countArgsName = getModelArgName(name, DMMF2.ModelAction.count);
|
|
4789
|
-
const genericDelegateParams = [extArgsParam,
|
|
4822
|
+
const genericDelegateParams = [extArgsParam, ts14.genericParameter("GlobalOmitOptions").default(ts14.objectType())];
|
|
4790
4823
|
const excludedArgsForCount = ["select", "include", "distinct", "omit"];
|
|
4791
4824
|
if (this.context.isPreviewFeatureOn("relationJoins")) {
|
|
4792
4825
|
excludedArgsForCount.push("relationLoadStrategy");
|
|
@@ -4797,11 +4830,11 @@ var ModelDelegate = class {
|
|
|
4797
4830
|
select?: ${getCountAggregateInputName(name)} | true
|
|
4798
4831
|
}
|
|
4799
4832
|
` : ""}
|
|
4800
|
-
export interface ${name}Delegate<${genericDelegateParams.map((param) =>
|
|
4833
|
+
export interface ${name}Delegate<${genericDelegateParams.map((param) => ts14.stringify(param)).join(", ")}> {
|
|
4801
4834
|
${(0, import_indent_string5.default)(`[K: symbol]: { types: Prisma.TypeMap<ExtArgs>['model']['${name}'], meta: { name: '${name}' } }`, TAB_SIZE)}
|
|
4802
4835
|
${nonAggregateActions.map((action) => {
|
|
4803
4836
|
const method3 = buildModelDelegateMethod(name, action, this.context);
|
|
4804
|
-
return
|
|
4837
|
+
return ts14.stringify(method3, { indentLevel: 1, newLine: "trailing" });
|
|
4805
4838
|
}).join("\n")}
|
|
4806
4839
|
|
|
4807
4840
|
${availableActions.includes(DMMF2.ModelAction.aggregate) ? `${(0, import_indent_string5.default)(getMethodJSDoc(DMMF2.ModelAction.count, mapping, modelOrType), TAB_SIZE)}
|
|
@@ -4887,7 +4920,7 @@ ${availableActions.includes(DMMF2.ModelAction.groupBy) ? `${(0, import_indent_st
|
|
|
4887
4920
|
readonly fields: ${getFieldRefsTypeName(name)};
|
|
4888
4921
|
}
|
|
4889
4922
|
|
|
4890
|
-
${
|
|
4923
|
+
${ts14.stringify(buildFluentWrapperDefinition(name, this.outputType, this.context))}
|
|
4891
4924
|
`;
|
|
4892
4925
|
}
|
|
4893
4926
|
};
|
|
@@ -4895,7 +4928,7 @@ function buildModelDelegateMethod(modelName, actionName, context) {
|
|
|
4895
4928
|
const mapping = context.dmmf.mappingsMap[modelName] ?? { model: modelName, plural: `${modelName}s` };
|
|
4896
4929
|
const modelOrType = context.dmmf.typeAndModelMap[modelName];
|
|
4897
4930
|
const dependencyValidators = getNonAggregateMethodDependencyValidations(mapping, actionName, context);
|
|
4898
|
-
const method3 =
|
|
4931
|
+
const method3 = ts14.method(actionName).setDocComment(ts14.docComment(getMethodJSDocBody(actionName, mapping, modelOrType))).addParameter(getNonAggregateMethodArgs(modelName, actionName, dependencyValidators)).setReturnType(getReturnType({ modelName, actionName }));
|
|
4899
4932
|
const generic = getNonAggregateMethodGenericParam(modelName, actionName);
|
|
4900
4933
|
if (generic) {
|
|
4901
4934
|
method3.addGenericParameter(generic);
|
|
@@ -4908,22 +4941,22 @@ function buildModelDelegateMethod(modelName, actionName, context) {
|
|
|
4908
4941
|
function getNonAggregateMethodArgs(modelName, actionName, dependencyValidators) {
|
|
4909
4942
|
const makeParameter = (type2) => {
|
|
4910
4943
|
if (dependencyValidators.length > 0) {
|
|
4911
|
-
type2 =
|
|
4944
|
+
type2 = ts14.intersectionType([type2, ...dependencyValidators.map((validator) => ts14.namedType(validator.name))]);
|
|
4912
4945
|
}
|
|
4913
|
-
return
|
|
4946
|
+
return ts14.parameter("args", type2);
|
|
4914
4947
|
};
|
|
4915
4948
|
if (actionName === DMMF2.ModelAction.count) {
|
|
4916
4949
|
const type2 = omit(
|
|
4917
|
-
|
|
4918
|
-
|
|
4950
|
+
ts14.namedType(getModelArgName(modelName, DMMF2.ModelAction.findMany)),
|
|
4951
|
+
ts14.unionType(ts14.stringLiteral("select")).addVariant(ts14.stringLiteral("include")).addVariant(ts14.stringLiteral("distinct"))
|
|
4919
4952
|
);
|
|
4920
4953
|
return makeParameter(type2).optional();
|
|
4921
4954
|
}
|
|
4922
4955
|
if (actionName === DMMF2.ModelAction.findRaw || actionName === DMMF2.ModelAction.aggregateRaw) {
|
|
4923
|
-
return makeParameter(
|
|
4956
|
+
return makeParameter(ts14.namedType(`Prisma.${getModelArgName(modelName, actionName)}`)).optional();
|
|
4924
4957
|
}
|
|
4925
|
-
const type =
|
|
4926
|
-
|
|
4958
|
+
const type = ts14.namedType("Prisma.SelectSubset").addGenericArgument(ts14.namedType("T")).addGenericArgument(
|
|
4959
|
+
ts14.namedType(getModelArgName(modelName, actionName)).addGenericArgument(extArgsParam.toArgument())
|
|
4927
4960
|
);
|
|
4928
4961
|
const param = makeParameter(type);
|
|
4929
4962
|
if (actionName === DMMF2.ModelAction.findMany || actionName === DMMF2.ModelAction.findFirst || actionName === DMMF2.ModelAction.deleteMany || actionName === DMMF2.ModelAction.createMany || actionName === DMMF2.ModelAction.createManyAndReturn || actionName === DMMF2.ModelAction.findFirstOrThrow) {
|
|
@@ -4935,11 +4968,11 @@ function getNonAggregateMethodGenericParam(modelName, actionName) {
|
|
|
4935
4968
|
if (actionName === DMMF2.ModelAction.count || actionName === DMMF2.ModelAction.findRaw || actionName === DMMF2.ModelAction.aggregateRaw) {
|
|
4936
4969
|
return null;
|
|
4937
4970
|
}
|
|
4938
|
-
const arg =
|
|
4971
|
+
const arg = ts14.genericParameter("T");
|
|
4939
4972
|
if (actionName === DMMF2.ModelAction.aggregate) {
|
|
4940
|
-
return arg.extends(
|
|
4973
|
+
return arg.extends(ts14.namedType(getAggregateArgsName(modelName)));
|
|
4941
4974
|
}
|
|
4942
|
-
return arg.extends(
|
|
4975
|
+
return arg.extends(ts14.namedType(getModelArgName(modelName, actionName)));
|
|
4943
4976
|
}
|
|
4944
4977
|
function getNonAggregateMethodDependencyValidations(modelMapping, actionName, context) {
|
|
4945
4978
|
const outputFieldName = modelMapping[actionName];
|
|
@@ -4955,13 +4988,13 @@ function getNonAggregateMethodDependencyValidations(modelMapping, actionName, co
|
|
|
4955
4988
|
if (args.requiresOtherFields === void 0) {
|
|
4956
4989
|
continue;
|
|
4957
4990
|
}
|
|
4958
|
-
const objectType11 =
|
|
4991
|
+
const objectType11 = ts14.objectType();
|
|
4959
4992
|
for (const reqArg of args.requiresOtherFields) {
|
|
4960
|
-
objectType11.add(
|
|
4993
|
+
objectType11.add(ts14.property(reqArg, ts14.objectType()));
|
|
4961
4994
|
}
|
|
4962
4995
|
validators.push(
|
|
4963
|
-
|
|
4964
|
-
|
|
4996
|
+
ts14.genericParameter(`${(0, import_client_common16.capitalize)(args.name)}DependenciesValidator`).extends(
|
|
4997
|
+
ts14.conditionalType().check(ts14.stringLiteral(args.name)).extends(ts14.namedType("Prisma.Keys<T>")).then(objectType11).else(ts14.objectType())
|
|
4965
4998
|
)
|
|
4966
4999
|
);
|
|
4967
5000
|
}
|
|
@@ -4974,53 +5007,53 @@ function getReturnType({
|
|
|
4974
5007
|
isNullable = false
|
|
4975
5008
|
}) {
|
|
4976
5009
|
if (actionName === DMMF2.ModelAction.count) {
|
|
4977
|
-
return promise(
|
|
5010
|
+
return promise(ts14.numberType);
|
|
4978
5011
|
}
|
|
4979
5012
|
if (actionName === DMMF2.ModelAction.aggregate) {
|
|
4980
|
-
return promise(
|
|
5013
|
+
return promise(ts14.namedType(getAggregateGetName(modelName)).addGenericArgument(ts14.namedType("T")));
|
|
4981
5014
|
}
|
|
4982
5015
|
if (actionName === DMMF2.ModelAction.findRaw || actionName === DMMF2.ModelAction.aggregateRaw) {
|
|
4983
|
-
return prismaPromise(
|
|
5016
|
+
return prismaPromise(ts14.namedType("Prisma.JsonObject"));
|
|
4984
5017
|
}
|
|
4985
5018
|
if (actionName === DMMF2.ModelAction.deleteMany || actionName === DMMF2.ModelAction.updateMany || actionName === DMMF2.ModelAction.createMany) {
|
|
4986
|
-
return prismaPromise(
|
|
5019
|
+
return prismaPromise(ts14.namedType("Prisma.BatchPayload"));
|
|
4987
5020
|
}
|
|
4988
5021
|
const isList = actionName === DMMF2.ModelAction.findMany || actionName === DMMF2.ModelAction.createManyAndReturn || actionName === DMMF2.ModelAction.updateManyAndReturn;
|
|
4989
5022
|
if (isList) {
|
|
4990
5023
|
let result = getResultType(modelName, actionName);
|
|
4991
5024
|
if (isChaining) {
|
|
4992
|
-
result =
|
|
5025
|
+
result = ts14.unionType(result).addVariant(ts14.namedType("Null"));
|
|
4993
5026
|
}
|
|
4994
5027
|
return prismaPromise(result);
|
|
4995
5028
|
}
|
|
4996
5029
|
if (isChaining && actionName === DMMF2.ModelAction.findUniqueOrThrow) {
|
|
4997
|
-
const nullType7 = isNullable ?
|
|
4998
|
-
const result =
|
|
5030
|
+
const nullType7 = isNullable ? ts14.nullType : ts14.namedType("Null");
|
|
5031
|
+
const result = ts14.unionType(getResultType(modelName, actionName)).addVariant(nullType7);
|
|
4999
5032
|
return getFluentWrapper(modelName, result, nullType7);
|
|
5000
5033
|
}
|
|
5001
5034
|
if (actionName === DMMF2.ModelAction.findFirst || actionName === DMMF2.ModelAction.findUnique) {
|
|
5002
|
-
const result =
|
|
5003
|
-
return getFluentWrapper(modelName, result,
|
|
5035
|
+
const result = ts14.unionType(getResultType(modelName, actionName)).addVariant(ts14.nullType);
|
|
5036
|
+
return getFluentWrapper(modelName, result, ts14.nullType);
|
|
5004
5037
|
}
|
|
5005
5038
|
return getFluentWrapper(modelName, getResultType(modelName, actionName));
|
|
5006
5039
|
}
|
|
5007
|
-
function getFluentWrapper(modelName, resultType, nullType7 =
|
|
5008
|
-
return
|
|
5040
|
+
function getFluentWrapper(modelName, resultType, nullType7 = ts14.neverType) {
|
|
5041
|
+
return ts14.namedType(`Prisma.${fluentWrapperName(modelName)}`).addGenericArgument(resultType).addGenericArgument(nullType7).addGenericArgument(extArgsParam.toArgument()).addGenericArgument(ts14.namedType("GlobalOmitOptions"));
|
|
5009
5042
|
}
|
|
5010
5043
|
function getResultType(modelName, actionName) {
|
|
5011
|
-
return
|
|
5044
|
+
return ts14.namedType("runtime.Types.Result.GetResult").addGenericArgument(ts14.namedType(getPayloadName(modelName)).addGenericArgument(extArgsParam.toArgument())).addGenericArgument(ts14.namedType("T")).addGenericArgument(ts14.stringLiteral(actionName)).addGenericArgument(ts14.namedType("GlobalOmitOptions"));
|
|
5012
5045
|
}
|
|
5013
5046
|
function buildFluentWrapperDefinition(modelName, outputType, context) {
|
|
5014
|
-
const definition =
|
|
5015
|
-
definition.addGenericParameter(
|
|
5016
|
-
definition.add(
|
|
5047
|
+
const definition = ts14.interfaceDeclaration(fluentWrapperName(modelName));
|
|
5048
|
+
definition.addGenericParameter(ts14.genericParameter("T")).addGenericParameter(ts14.genericParameter("Null").default(ts14.neverType)).addGenericParameter(extArgsParam).addGenericParameter(ts14.genericParameter("GlobalOmitOptions").default(ts14.objectType())).extends(prismaPromise(ts14.namedType("T")));
|
|
5049
|
+
definition.add(ts14.property(ts14.toStringTag, ts14.stringLiteral("PrismaPromise")).readonly());
|
|
5017
5050
|
definition.addMultiple(
|
|
5018
5051
|
outputType.fields.filter(
|
|
5019
5052
|
(field) => field.outputType.location === "outputObjectTypes" && !context.dmmf.isComposite(field.outputType.type) && field.name !== "_count"
|
|
5020
5053
|
).map((field) => {
|
|
5021
|
-
const fieldArgType =
|
|
5022
|
-
const argsParam =
|
|
5023
|
-
return
|
|
5054
|
+
const fieldArgType = ts14.namedType(`Prisma.${getFieldArgName(field, modelName)}`).addGenericArgument(extArgsParam.toArgument());
|
|
5055
|
+
const argsParam = ts14.genericParameter("T").extends(fieldArgType).default(ts14.objectType());
|
|
5056
|
+
return ts14.method(field.name).addGenericParameter(argsParam).addParameter(ts14.parameter("args", subset(argsParam.toArgument(), fieldArgType)).optional()).setReturnType(
|
|
5024
5057
|
getReturnType({
|
|
5025
5058
|
modelName: field.outputType.type,
|
|
5026
5059
|
actionName: field.outputType.isList ? DMMF2.ModelAction.findMany : DMMF2.ModelAction.findUniqueOrThrow,
|
|
@@ -5031,37 +5064,37 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
|
|
|
5031
5064
|
})
|
|
5032
5065
|
);
|
|
5033
5066
|
definition.add(
|
|
5034
|
-
|
|
5035
|
-
|
|
5067
|
+
ts14.method("then").setDocComment(
|
|
5068
|
+
ts14.docComment`
|
|
5036
5069
|
Attaches callbacks for the resolution and/or rejection of the Promise.
|
|
5037
5070
|
@param onfulfilled The callback to execute when the Promise is resolved.
|
|
5038
5071
|
@param onrejected The callback to execute when the Promise is rejected.
|
|
5039
5072
|
@returns A Promise for the completion of which ever callback is executed.
|
|
5040
5073
|
`
|
|
5041
|
-
).addGenericParameter(
|
|
5074
|
+
).addGenericParameter(ts14.genericParameter("TResult1").default(ts14.namedType("T"))).addGenericParameter(ts14.genericParameter("TResult2").default(ts14.neverType)).addParameter(promiseCallback("onfulfilled", ts14.parameter("value", ts14.namedType("T")), ts14.namedType("TResult1"))).addParameter(promiseCallback("onrejected", ts14.parameter("reason", ts14.anyType), ts14.namedType("TResult2"))).setReturnType(promise(ts14.unionType([ts14.namedType("TResult1"), ts14.namedType("TResult2")])))
|
|
5042
5075
|
);
|
|
5043
5076
|
definition.add(
|
|
5044
|
-
|
|
5045
|
-
|
|
5077
|
+
ts14.method("catch").setDocComment(
|
|
5078
|
+
ts14.docComment`
|
|
5046
5079
|
Attaches a callback for only the rejection of the Promise.
|
|
5047
5080
|
@param onrejected The callback to execute when the Promise is rejected.
|
|
5048
5081
|
@returns A Promise for the completion of the callback.
|
|
5049
5082
|
`
|
|
5050
|
-
).addGenericParameter(
|
|
5083
|
+
).addGenericParameter(ts14.genericParameter("TResult").default(ts14.neverType)).addParameter(promiseCallback("onrejected", ts14.parameter("reason", ts14.anyType), ts14.namedType("TResult"))).setReturnType(promise(ts14.unionType([ts14.namedType("T"), ts14.namedType("TResult")])))
|
|
5051
5084
|
);
|
|
5052
5085
|
definition.add(
|
|
5053
|
-
|
|
5054
|
-
|
|
5086
|
+
ts14.method("finally").setDocComment(
|
|
5087
|
+
ts14.docComment`
|
|
5055
5088
|
Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
5056
5089
|
resolved value cannot be modified from the callback.
|
|
5057
5090
|
@param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
5058
5091
|
@returns A Promise for the completion of the callback.
|
|
5059
5092
|
`
|
|
5060
5093
|
).addParameter(
|
|
5061
|
-
|
|
5062
|
-
).setReturnType(promise(
|
|
5094
|
+
ts14.parameter("onfinally", ts14.unionType([ts14.functionType(), ts14.undefinedType, ts14.nullType])).optional()
|
|
5095
|
+
).setReturnType(promise(ts14.namedType("T")))
|
|
5063
5096
|
);
|
|
5064
|
-
return
|
|
5097
|
+
return ts14.moduleExport(definition).setDocComment(ts14.docComment`
|
|
5065
5098
|
The delegate class that acts as a "Promise-like" for ${modelName}.
|
|
5066
5099
|
Why is this prefixed with \`Prisma__\`?
|
|
5067
5100
|
Because we want to prevent naming conflicts as mentioned in
|
|
@@ -5069,20 +5102,20 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
|
|
|
5069
5102
|
`);
|
|
5070
5103
|
}
|
|
5071
5104
|
function promiseCallback(name, callbackParam, returnType) {
|
|
5072
|
-
return
|
|
5105
|
+
return ts14.parameter(
|
|
5073
5106
|
name,
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5107
|
+
ts14.unionType([
|
|
5108
|
+
ts14.functionType().addParameter(callbackParam).setReturnType(typeOrPromiseLike(returnType)),
|
|
5109
|
+
ts14.undefinedType,
|
|
5110
|
+
ts14.nullType
|
|
5078
5111
|
])
|
|
5079
5112
|
).optional();
|
|
5080
5113
|
}
|
|
5081
5114
|
function typeOrPromiseLike(type) {
|
|
5082
|
-
return
|
|
5115
|
+
return ts14.unionType([type, ts14.namedType("PromiseLike").addGenericArgument(type)]);
|
|
5083
5116
|
}
|
|
5084
5117
|
function subset(arg, baseType) {
|
|
5085
|
-
return
|
|
5118
|
+
return ts14.namedType("Prisma.Subset").addGenericArgument(arg).addGenericArgument(baseType);
|
|
5086
5119
|
}
|
|
5087
5120
|
function fluentWrapperName(modelName) {
|
|
5088
5121
|
return `Prisma__${modelName}Client`;
|
|
@@ -5090,24 +5123,24 @@ function fluentWrapperName(modelName) {
|
|
|
5090
5123
|
|
|
5091
5124
|
// src/TSClient/file-generators/ModelFile.ts
|
|
5092
5125
|
function createModelFile(context, modelName) {
|
|
5093
|
-
const
|
|
5126
|
+
const jsDocHeader9 = `/*
|
|
5094
5127
|
* This file exports the \`${modelName}\` model and its related types.
|
|
5095
5128
|
*
|
|
5096
5129
|
* \u{1F7E2} You can import this file directly.
|
|
5097
5130
|
*/
|
|
5098
5131
|
`;
|
|
5099
5132
|
const imports = [
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5133
|
+
ts15.moduleImport(context.runtimeImport).asNamespace("runtime").typeOnly(),
|
|
5134
|
+
ts15.moduleImport(context.importFileName(`../enums`)).asNamespace("$Enums").typeOnly(),
|
|
5135
|
+
ts15.moduleImport(context.importFileName(`../internal/prismaNamespace`)).asNamespace("Prisma").typeOnly()
|
|
5103
5136
|
];
|
|
5104
|
-
const importsString = imports.map((i) =>
|
|
5137
|
+
const importsString = imports.map((i) => ts15.stringify(i)).join("\n");
|
|
5105
5138
|
const model = context.dmmf.typeAndModelMap[modelName];
|
|
5106
|
-
return
|
|
5139
|
+
return jsDocHeader9 + importsString + "\n" + new Model(model, context).toTS();
|
|
5107
5140
|
}
|
|
5108
5141
|
|
|
5109
5142
|
// src/TSClient/file-generators/ModelsFile.ts
|
|
5110
|
-
var
|
|
5143
|
+
var jsDocHeader6 = `/*
|
|
5111
5144
|
* This is a barrel export file for all models and their related types.
|
|
5112
5145
|
*
|
|
5113
5146
|
* \u{1F7E2} You can import this file directly.
|
|
@@ -5116,11 +5149,46 @@ var jsDocHeader5 = `/*
|
|
|
5116
5149
|
function createModelsFile(context, modelsNames) {
|
|
5117
5150
|
const exports2 = modelsNames.map((m) => `export type * from './models/${context.importFileName(m)}'`);
|
|
5118
5151
|
exports2.push(`export type * from './${context.importFileName("commonInputTypes")}'`);
|
|
5119
|
-
return
|
|
5152
|
+
return jsDocHeader6 + exports2.join("\n");
|
|
5153
|
+
}
|
|
5154
|
+
|
|
5155
|
+
// src/TSClient/file-generators/PrismaNamespaceBrowserFile.ts
|
|
5156
|
+
var ts16 = __toESM(require("@prisma/ts-builders"));
|
|
5157
|
+
var jsDocHeader7 = `/*
|
|
5158
|
+
* WARNING: This is an internal file that is subject to change!
|
|
5159
|
+
*
|
|
5160
|
+
* \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
|
|
5161
|
+
*
|
|
5162
|
+
* All exports from this file are wrapped under a \`Prisma\` namespace object in the browser.ts file.
|
|
5163
|
+
* While this enables partial backward compatibility, it is not part of the stable public API.
|
|
5164
|
+
*
|
|
5165
|
+
* If you are looking for your Models, Enums, and Input Types, please import them from the respective
|
|
5166
|
+
* model files in the \`model\` directory!
|
|
5167
|
+
*/
|
|
5168
|
+
`;
|
|
5169
|
+
function createPrismaNamespaceBrowserFile(context) {
|
|
5170
|
+
const prismaEnums = context.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toTS());
|
|
5171
|
+
return `${jsDocHeader7}
|
|
5172
|
+
${ts16.stringify(ts16.moduleImport(`${context.runtimeBase}/index-browser`).asNamespace("runtime"))}
|
|
5173
|
+
export type * from '${context.importFileName(`../models`)}'
|
|
5174
|
+
export type * from '${context.importFileName(`./prismaNamespace`)}'
|
|
5175
|
+
export const Decimal = runtime.Decimal
|
|
5176
|
+
${new Enum(
|
|
5177
|
+
{
|
|
5178
|
+
name: "ModelName",
|
|
5179
|
+
values: context.dmmf.mappings.modelOperations.map((m) => m.model)
|
|
5180
|
+
},
|
|
5181
|
+
true
|
|
5182
|
+
).toTS()}
|
|
5183
|
+
/**
|
|
5184
|
+
* Enums
|
|
5185
|
+
*/
|
|
5186
|
+
${prismaEnums?.join("\n\n")}
|
|
5187
|
+
`;
|
|
5120
5188
|
}
|
|
5121
5189
|
|
|
5122
5190
|
// src/TSClient/file-generators/PrismaNamespaceFile.ts
|
|
5123
|
-
var
|
|
5191
|
+
var ts19 = __toESM(require("@prisma/ts-builders"));
|
|
5124
5192
|
|
|
5125
5193
|
// src/TSClient/common.ts
|
|
5126
5194
|
var commonCodeTS = ({ clientVersion, engineVersion, generator }) => {
|
|
@@ -5545,23 +5613,23 @@ export type ${this.type.name}<$PrismaModel> = FieldRefInputType<$PrismaModel, ${
|
|
|
5545
5613
|
|
|
5546
5614
|
// src/TSClient/globalOmit.ts
|
|
5547
5615
|
var import_client_common17 = require("@prisma/client-common");
|
|
5548
|
-
var
|
|
5616
|
+
var ts17 = __toESM(require("@prisma/ts-builders"));
|
|
5549
5617
|
function globalOmitConfig(dmmf) {
|
|
5550
|
-
const objectType11 =
|
|
5618
|
+
const objectType11 = ts17.objectType().addMultiple(
|
|
5551
5619
|
dmmf.datamodel.models.map((model) => {
|
|
5552
|
-
const type =
|
|
5553
|
-
return
|
|
5620
|
+
const type = ts17.namedType(`Prisma.${getOmitName(model.name)}`);
|
|
5621
|
+
return ts17.property((0, import_client_common17.uncapitalize)(model.name), type).optional();
|
|
5554
5622
|
})
|
|
5555
5623
|
);
|
|
5556
|
-
return
|
|
5624
|
+
return ts17.moduleExport(ts17.typeDeclaration("GlobalOmitConfig", objectType11));
|
|
5557
5625
|
}
|
|
5558
5626
|
|
|
5559
5627
|
// src/TSClient/TypeMap.ts
|
|
5560
5628
|
var import_client_common18 = require("@prisma/client-common");
|
|
5561
|
-
var
|
|
5562
|
-
var
|
|
5629
|
+
var import_internals8 = require("@prisma/internals");
|
|
5630
|
+
var ts18 = __toESM(require("@prisma/ts-builders"));
|
|
5563
5631
|
function clientTypeMapDefinition(context) {
|
|
5564
|
-
const typeMap = `${
|
|
5632
|
+
const typeMap = `${ts18.stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
|
|
5565
5633
|
return `
|
|
5566
5634
|
export interface TypeMapCb<GlobalOmitOptions = {}> extends runtime.Types.Utils.Fn<{extArgs: runtime.Types.Extensions.InternalArgs }, runtime.Types.Utils.Record<string, any>> {
|
|
5567
5635
|
returns: TypeMap<this['params']['extArgs'], GlobalOmitOptions>
|
|
@@ -5570,39 +5638,39 @@ export interface TypeMapCb<GlobalOmitOptions = {}> extends runtime.Types.Utils.F
|
|
|
5570
5638
|
export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> = ${typeMap}`;
|
|
5571
5639
|
}
|
|
5572
5640
|
function clientTypeMapModelsDefinition(context) {
|
|
5573
|
-
const meta =
|
|
5641
|
+
const meta = ts18.objectType();
|
|
5574
5642
|
const modelNames = context.dmmf.datamodel.models.map((m) => m.name);
|
|
5575
5643
|
if (modelNames.length === 0) {
|
|
5576
|
-
meta.add(
|
|
5644
|
+
meta.add(ts18.property("modelProps", ts18.neverType));
|
|
5577
5645
|
} else {
|
|
5578
|
-
meta.add(
|
|
5646
|
+
meta.add(ts18.property("modelProps", ts18.unionType(modelNames.map((name) => ts18.stringLiteral((0, import_client_common18.uncapitalize)(name))))));
|
|
5579
5647
|
}
|
|
5580
|
-
const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ?
|
|
5581
|
-
meta.add(
|
|
5582
|
-
const model =
|
|
5648
|
+
const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ? ts18.namedType("TransactionIsolationLevel") : ts18.neverType;
|
|
5649
|
+
meta.add(ts18.property("txIsolationLevel", isolationLevel));
|
|
5650
|
+
const model = ts18.objectType();
|
|
5583
5651
|
model.addMultiple(
|
|
5584
5652
|
modelNames.map((modelName) => {
|
|
5585
|
-
const entry =
|
|
5653
|
+
const entry = ts18.objectType();
|
|
5586
5654
|
entry.add(
|
|
5587
|
-
|
|
5655
|
+
ts18.property("payload", ts18.namedType(getPayloadName(modelName)).addGenericArgument(extArgsParam.toArgument()))
|
|
5588
5656
|
);
|
|
5589
|
-
entry.add(
|
|
5657
|
+
entry.add(ts18.property("fields", ts18.namedType(`Prisma.${getFieldRefsTypeName(modelName)}`)));
|
|
5590
5658
|
const actions = getModelActions(context.dmmf, modelName);
|
|
5591
|
-
const operations =
|
|
5659
|
+
const operations = ts18.objectType();
|
|
5592
5660
|
operations.addMultiple(
|
|
5593
5661
|
actions.map((action) => {
|
|
5594
|
-
const operationType =
|
|
5662
|
+
const operationType = ts18.objectType();
|
|
5595
5663
|
const argsType = `Prisma.${getModelArgName(modelName, action)}`;
|
|
5596
|
-
operationType.add(
|
|
5597
|
-
operationType.add(
|
|
5598
|
-
return
|
|
5664
|
+
operationType.add(ts18.property("args", ts18.namedType(argsType).addGenericArgument(extArgsParam.toArgument())));
|
|
5665
|
+
operationType.add(ts18.property("result", clientTypeMapModelsResultDefinition(modelName, action)));
|
|
5666
|
+
return ts18.property(action, operationType);
|
|
5599
5667
|
})
|
|
5600
5668
|
);
|
|
5601
|
-
entry.add(
|
|
5602
|
-
return
|
|
5669
|
+
entry.add(ts18.property("operations", operations));
|
|
5670
|
+
return ts18.property(modelName, entry);
|
|
5603
5671
|
})
|
|
5604
5672
|
);
|
|
5605
|
-
return
|
|
5673
|
+
return ts18.objectType().add(ts18.property("globalOmitOptions", ts18.objectType().add(ts18.property("omit", ts18.namedType("GlobalOmitOptions"))))).add(ts18.property("meta", meta)).add(ts18.property("model", model));
|
|
5606
5674
|
}
|
|
5607
5675
|
function clientTypeMapOthersDefinition(context) {
|
|
5608
5676
|
const otherOperationsNames = context.dmmf.getOtherOperationNames().flatMap((name) => {
|
|
@@ -5639,33 +5707,33 @@ function clientTypeMapOthersDefinition(context) {
|
|
|
5639
5707
|
}
|
|
5640
5708
|
function clientTypeMapModelsResultDefinition(modelName, action) {
|
|
5641
5709
|
if (action === "count")
|
|
5642
|
-
return
|
|
5643
|
-
if (action === "groupBy") return
|
|
5644
|
-
if (action === "aggregate") return optional(
|
|
5645
|
-
if (action === "findRaw") return
|
|
5646
|
-
if (action === "aggregateRaw") return
|
|
5647
|
-
if (action === "deleteMany") return
|
|
5648
|
-
if (action === "createMany") return
|
|
5649
|
-
if (action === "createManyAndReturn") return
|
|
5650
|
-
if (action === "updateMany") return
|
|
5651
|
-
if (action === "updateManyAndReturn") return
|
|
5652
|
-
if (action === "findMany") return
|
|
5653
|
-
if (action === "findFirst") return
|
|
5654
|
-
if (action === "findUnique") return
|
|
5710
|
+
return ts18.unionType([optional(ts18.namedType(`Prisma.${getCountAggregateOutputName(modelName)}`)), ts18.numberType]);
|
|
5711
|
+
if (action === "groupBy") return ts18.array(optional(ts18.namedType(`Prisma.${getGroupByName(modelName)}`)));
|
|
5712
|
+
if (action === "aggregate") return optional(ts18.namedType(`Prisma.${getAggregateName(modelName)}`));
|
|
5713
|
+
if (action === "findRaw") return ts18.namedType("Prisma.JsonObject");
|
|
5714
|
+
if (action === "aggregateRaw") return ts18.namedType("Prisma.JsonObject");
|
|
5715
|
+
if (action === "deleteMany") return ts18.namedType("BatchPayload");
|
|
5716
|
+
if (action === "createMany") return ts18.namedType("BatchPayload");
|
|
5717
|
+
if (action === "createManyAndReturn") return ts18.array(payloadToResult(modelName));
|
|
5718
|
+
if (action === "updateMany") return ts18.namedType("BatchPayload");
|
|
5719
|
+
if (action === "updateManyAndReturn") return ts18.array(payloadToResult(modelName));
|
|
5720
|
+
if (action === "findMany") return ts18.array(payloadToResult(modelName));
|
|
5721
|
+
if (action === "findFirst") return ts18.unionType([payloadToResult(modelName), ts18.nullType]);
|
|
5722
|
+
if (action === "findUnique") return ts18.unionType([payloadToResult(modelName), ts18.nullType]);
|
|
5655
5723
|
if (action === "findFirstOrThrow") return payloadToResult(modelName);
|
|
5656
5724
|
if (action === "findUniqueOrThrow") return payloadToResult(modelName);
|
|
5657
5725
|
if (action === "create") return payloadToResult(modelName);
|
|
5658
5726
|
if (action === "update") return payloadToResult(modelName);
|
|
5659
5727
|
if (action === "upsert") return payloadToResult(modelName);
|
|
5660
5728
|
if (action === "delete") return payloadToResult(modelName);
|
|
5661
|
-
(0,
|
|
5729
|
+
(0, import_internals8.assertNever)(action, `Unknown action: ${action}`);
|
|
5662
5730
|
}
|
|
5663
5731
|
function payloadToResult(modelName) {
|
|
5664
|
-
return
|
|
5732
|
+
return ts18.namedType("runtime.Types.Utils.PayloadToResult").addGenericArgument(ts18.namedType(getPayloadName(modelName)));
|
|
5665
5733
|
}
|
|
5666
5734
|
|
|
5667
5735
|
// src/TSClient/file-generators/PrismaNamespaceFile.ts
|
|
5668
|
-
var
|
|
5736
|
+
var jsDocHeader8 = `/*
|
|
5669
5737
|
* WARNING: This is an internal file that is subject to change!
|
|
5670
5738
|
*
|
|
5671
5739
|
* \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
|
|
@@ -5679,13 +5747,13 @@ var jsDocHeader6 = `/*
|
|
|
5679
5747
|
`;
|
|
5680
5748
|
function createPrismaNamespaceFile(context, options) {
|
|
5681
5749
|
const imports = [
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
].map((i) =>
|
|
5750
|
+
ts19.moduleImport(context.runtimeImport).asNamespace("runtime"),
|
|
5751
|
+
ts19.moduleImport(context.importFileName(`../models`)).asNamespace("Prisma").typeOnly(),
|
|
5752
|
+
ts19.moduleImport(context.importFileName(`./class`)).named(ts19.namedImport("PrismaClient").typeOnly())
|
|
5753
|
+
].map((i) => ts19.stringify(i));
|
|
5686
5754
|
const prismaEnums = context.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toTS());
|
|
5687
5755
|
const fieldRefs = context.dmmf.schema.fieldRefTypes.prisma?.map((type) => new FieldRefInput(type).toTS()) ?? [];
|
|
5688
|
-
return `${
|
|
5756
|
+
return `${jsDocHeader8}
|
|
5689
5757
|
${imports.join("\n")}
|
|
5690
5758
|
|
|
5691
5759
|
export type * from '${context.importFileName(`../models`)}'
|
|
@@ -5725,8 +5793,8 @@ ${new Datasources(options.datasources).toTS()}
|
|
|
5725
5793
|
${clientExtensionsDefinitions()}
|
|
5726
5794
|
export type DefaultPrismaClient = PrismaClient
|
|
5727
5795
|
export type ErrorFormat = 'pretty' | 'colorless' | 'minimal'
|
|
5728
|
-
${
|
|
5729
|
-
${
|
|
5796
|
+
${ts19.stringify(ts19.moduleExport(buildClientOptions(context, options)))}
|
|
5797
|
+
${ts19.stringify(globalOmitConfig(context.dmmf))}
|
|
5730
5798
|
|
|
5731
5799
|
/* Types for Logging */
|
|
5732
5800
|
export type LogLevel = 'info' | 'query' | 'warn' | 'error'
|
|
@@ -5792,24 +5860,24 @@ export type TransactionClient = Omit<DefaultPrismaClient, runtime.ITXClientDenyL
|
|
|
5792
5860
|
`;
|
|
5793
5861
|
}
|
|
5794
5862
|
function clientExtensionsDefinitions() {
|
|
5795
|
-
const define =
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5863
|
+
const define = ts19.moduleExport(
|
|
5864
|
+
ts19.constDeclaration("defineExtension").setValue(
|
|
5865
|
+
ts19.namedValue("runtime.Extensions.defineExtension").as(ts19.namedType("unknown")).as(
|
|
5866
|
+
ts19.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts19.stringLiteral("define")).addGenericArgument(ts19.namedType("TypeMapCb")).addGenericArgument(ts19.namedType("runtime.Types.Extensions.DefaultArgs"))
|
|
5799
5867
|
)
|
|
5800
5868
|
)
|
|
5801
5869
|
);
|
|
5802
|
-
return
|
|
5870
|
+
return ts19.stringify(define);
|
|
5803
5871
|
}
|
|
5804
5872
|
function buildClientOptions(context, options) {
|
|
5805
|
-
const clientOptions =
|
|
5806
|
-
|
|
5873
|
+
const clientOptions = ts19.interfaceDeclaration("PrismaClientOptions").add(
|
|
5874
|
+
ts19.property("datasources", ts19.namedType("Datasources")).optional().setDocComment(ts19.docComment("Overwrites the datasource url from your schema.prisma file"))
|
|
5807
5875
|
).add(
|
|
5808
|
-
|
|
5876
|
+
ts19.property("datasourceUrl", ts19.stringType).optional().setDocComment(ts19.docComment("Overwrites the datasource url from your schema.prisma file"))
|
|
5809
5877
|
).add(
|
|
5810
|
-
|
|
5878
|
+
ts19.property("errorFormat", ts19.namedType("ErrorFormat")).optional().setDocComment(ts19.docComment('@default "colorless"'))
|
|
5811
5879
|
).add(
|
|
5812
|
-
|
|
5880
|
+
ts19.property("log", ts19.array(ts19.unionType([ts19.namedType("LogLevel"), ts19.namedType("LogDefinition")]))).optional().setDocComment(ts19.docComment`
|
|
5813
5881
|
@example
|
|
5814
5882
|
\`\`\`
|
|
5815
5883
|
// Shorthand for \`emit: 'stdout'\`
|
|
@@ -5834,12 +5902,12 @@ function buildClientOptions(context, options) {
|
|
|
5834
5902
|
Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/logging#the-log-option).
|
|
5835
5903
|
`)
|
|
5836
5904
|
);
|
|
5837
|
-
const transactionOptions =
|
|
5905
|
+
const transactionOptions = ts19.objectType().add(ts19.property("maxWait", ts19.numberType).optional()).add(ts19.property("timeout", ts19.numberType).optional());
|
|
5838
5906
|
if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
|
|
5839
|
-
transactionOptions.add(
|
|
5907
|
+
transactionOptions.add(ts19.property("isolationLevel", ts19.namedType("TransactionIsolationLevel")).optional());
|
|
5840
5908
|
}
|
|
5841
5909
|
clientOptions.add(
|
|
5842
|
-
|
|
5910
|
+
ts19.property("transactionOptions", transactionOptions).optional().setDocComment(ts19.docComment`
|
|
5843
5911
|
The default values for transactionOptions
|
|
5844
5912
|
maxWait ?= 2000
|
|
5845
5913
|
timeout ?= 5000
|
|
@@ -5847,13 +5915,13 @@ function buildClientOptions(context, options) {
|
|
|
5847
5915
|
);
|
|
5848
5916
|
if (["library", "client", "wasm-compiler-edge", "wasm-engine-edge"].includes(options.runtimeName)) {
|
|
5849
5917
|
clientOptions.add(
|
|
5850
|
-
|
|
5851
|
-
|
|
5918
|
+
ts19.property("adapter", ts19.unionType([ts19.namedType("runtime.SqlDriverAdapterFactory"), ts19.namedType("null")])).optional().setDocComment(
|
|
5919
|
+
ts19.docComment("Instance of a Driver Adapter, e.g., like one provided by `@prisma/adapter-planetscale`")
|
|
5852
5920
|
)
|
|
5853
5921
|
);
|
|
5854
5922
|
}
|
|
5855
5923
|
clientOptions.add(
|
|
5856
|
-
|
|
5924
|
+
ts19.property("omit", ts19.namedType("GlobalOmitConfig")).optional().setDocComment(ts19.docComment`
|
|
5857
5925
|
Global configuration for omitting model fields by default.
|
|
5858
5926
|
|
|
5859
5927
|
@example
|
|
@@ -5875,6 +5943,7 @@ function buildClientOptions(context, options) {
|
|
|
5875
5943
|
var GenerateContext = class {
|
|
5876
5944
|
dmmf;
|
|
5877
5945
|
genericArgsInfo;
|
|
5946
|
+
runtimeBase;
|
|
5878
5947
|
runtimeImport;
|
|
5879
5948
|
outputFileName;
|
|
5880
5949
|
importFileName;
|
|
@@ -5882,6 +5951,7 @@ var GenerateContext = class {
|
|
|
5882
5951
|
constructor({
|
|
5883
5952
|
dmmf,
|
|
5884
5953
|
genericArgsInfo,
|
|
5954
|
+
runtimeBase,
|
|
5885
5955
|
runtimeImport: runtimeImport2,
|
|
5886
5956
|
outputFileName,
|
|
5887
5957
|
importFileName,
|
|
@@ -5889,6 +5959,7 @@ var GenerateContext = class {
|
|
|
5889
5959
|
}) {
|
|
5890
5960
|
this.dmmf = dmmf;
|
|
5891
5961
|
this.genericArgsInfo = genericArgsInfo;
|
|
5962
|
+
this.runtimeBase = runtimeBase;
|
|
5892
5963
|
this.runtimeImport = runtimeImport2;
|
|
5893
5964
|
this.outputFileName = outputFileName;
|
|
5894
5965
|
this.importFileName = importFileName;
|
|
@@ -5912,6 +5983,7 @@ var TSClient = class {
|
|
|
5912
5983
|
const context = new GenerateContext({
|
|
5913
5984
|
dmmf: this.dmmf,
|
|
5914
5985
|
genericArgsInfo: this.genericsInfo,
|
|
5986
|
+
runtimeBase: this.options.runtimeBase,
|
|
5915
5987
|
runtimeImport: `${this.options.runtimeBase}/${this.options.runtimeName}`,
|
|
5916
5988
|
outputFileName: generatedFileNameMapper(this.options.generatedFileExtension),
|
|
5917
5989
|
importFileName: importFileNameMapper(this.options.importFileExtension),
|
|
@@ -5924,12 +5996,14 @@ var TSClient = class {
|
|
|
5924
5996
|
}, {});
|
|
5925
5997
|
return {
|
|
5926
5998
|
[context.outputFileName("client")]: createClientFile(context, this.options),
|
|
5999
|
+
[context.outputFileName("browser")]: createBrowserFile(context, this.options),
|
|
5927
6000
|
[context.outputFileName("enums")]: createEnumsFile(context),
|
|
5928
6001
|
[context.outputFileName("commonInputTypes")]: createCommonInputTypeFiles(context),
|
|
5929
6002
|
[context.outputFileName("models")]: createModelsFile(context, modelNames),
|
|
5930
6003
|
models: modelsFileMap,
|
|
5931
6004
|
internal: {
|
|
5932
6005
|
[context.outputFileName("prismaNamespace")]: createPrismaNamespaceFile(context, this.options),
|
|
6006
|
+
[context.outputFileName("prismaNamespaceBrowser")]: createPrismaNamespaceBrowserFile(context),
|
|
5933
6007
|
[context.outputFileName("class")]: createClassFile(context, this.options)
|
|
5934
6008
|
}
|
|
5935
6009
|
};
|
|
@@ -5937,8 +6011,8 @@ var TSClient = class {
|
|
|
5937
6011
|
};
|
|
5938
6012
|
|
|
5939
6013
|
// src/typedSql/buildDbEnums.ts
|
|
5940
|
-
var
|
|
5941
|
-
var
|
|
6014
|
+
var import_internals9 = require("@prisma/internals");
|
|
6015
|
+
var ts20 = __toESM(require("@prisma/ts-builders"));
|
|
5942
6016
|
var DbEnumsList = class {
|
|
5943
6017
|
enums;
|
|
5944
6018
|
constructor(enums) {
|
|
@@ -5955,30 +6029,30 @@ var DbEnumsList = class {
|
|
|
5955
6029
|
}
|
|
5956
6030
|
*validJsIdentifiers() {
|
|
5957
6031
|
for (const dbEnum of this.enums) {
|
|
5958
|
-
if ((0,
|
|
6032
|
+
if ((0, import_internals9.isValidJsIdentifier)(dbEnum.name)) {
|
|
5959
6033
|
yield dbEnum;
|
|
5960
6034
|
}
|
|
5961
6035
|
}
|
|
5962
6036
|
}
|
|
5963
6037
|
*invalidJsIdentifiers() {
|
|
5964
6038
|
for (const dbEnum of this.enums) {
|
|
5965
|
-
if (!(0,
|
|
6039
|
+
if (!(0, import_internals9.isValidJsIdentifier)(dbEnum.name)) {
|
|
5966
6040
|
yield dbEnum;
|
|
5967
6041
|
}
|
|
5968
6042
|
}
|
|
5969
6043
|
}
|
|
5970
6044
|
};
|
|
5971
6045
|
function buildDbEnums(list) {
|
|
5972
|
-
const file4 =
|
|
5973
|
-
const iface =
|
|
6046
|
+
const file4 = ts20.file();
|
|
6047
|
+
const iface = ts20.interfaceDeclaration("$DbEnums");
|
|
5974
6048
|
for (const dbEnum of list.enums) {
|
|
5975
|
-
iface.add(
|
|
6049
|
+
iface.add(ts20.property(dbEnum.name, enumToUnion(dbEnum)));
|
|
5976
6050
|
}
|
|
5977
|
-
file4.add(
|
|
5978
|
-
return
|
|
6051
|
+
file4.add(ts20.moduleExport(iface));
|
|
6052
|
+
return ts20.stringify(file4);
|
|
5979
6053
|
}
|
|
5980
6054
|
function enumToUnion(dbEnum) {
|
|
5981
|
-
return
|
|
6055
|
+
return ts20.unionType(dbEnum.values.map(ts20.stringLiteral));
|
|
5982
6056
|
}
|
|
5983
6057
|
function queryUsesEnums(query, enums) {
|
|
5984
6058
|
if (enums.isEmpty()) {
|
|
@@ -5988,82 +6062,82 @@ function queryUsesEnums(query, enums) {
|
|
|
5988
6062
|
}
|
|
5989
6063
|
|
|
5990
6064
|
// src/typedSql/buildIndex.ts
|
|
5991
|
-
var
|
|
6065
|
+
var ts21 = __toESM(require("@prisma/ts-builders"));
|
|
5992
6066
|
function buildIndex({ queries, enums, importName }) {
|
|
5993
|
-
const file4 =
|
|
6067
|
+
const file4 = ts21.file();
|
|
5994
6068
|
if (!enums.isEmpty()) {
|
|
5995
|
-
file4.add(
|
|
6069
|
+
file4.add(ts21.moduleExportFrom(importName("./sql/$DbEnums")).named(ts21.namedExport("$DbEnums").typeOnly()));
|
|
5996
6070
|
}
|
|
5997
6071
|
for (const query of queries) {
|
|
5998
|
-
file4.add(
|
|
6072
|
+
file4.add(ts21.moduleExportFrom(importName(`./sql/${query.name}`)));
|
|
5999
6073
|
}
|
|
6000
|
-
return
|
|
6074
|
+
return ts21.stringify(file4);
|
|
6001
6075
|
}
|
|
6002
6076
|
|
|
6003
6077
|
// src/typedSql/buildTypedQuery.ts
|
|
6004
|
-
var
|
|
6078
|
+
var ts23 = __toESM(require("@prisma/ts-builders"));
|
|
6005
6079
|
|
|
6006
6080
|
// src/typedSql/mapTypes.ts
|
|
6007
|
-
var
|
|
6008
|
-
var decimal =
|
|
6009
|
-
var uint8Array =
|
|
6010
|
-
var date =
|
|
6011
|
-
var inputJsonValue =
|
|
6012
|
-
var jsonValue =
|
|
6013
|
-
var bigintIn =
|
|
6014
|
-
var decimalIn =
|
|
6081
|
+
var ts22 = __toESM(require("@prisma/ts-builders"));
|
|
6082
|
+
var decimal = ts22.namedType("$runtime.Decimal");
|
|
6083
|
+
var uint8Array = ts22.namedType("Uint8Array");
|
|
6084
|
+
var date = ts22.namedType("Date");
|
|
6085
|
+
var inputJsonValue = ts22.namedType("$runtime.InputJsonObject");
|
|
6086
|
+
var jsonValue = ts22.namedType("$runtime.JsonValue");
|
|
6087
|
+
var bigintIn = ts22.unionType([ts22.numberType, ts22.bigintType]);
|
|
6088
|
+
var decimalIn = ts22.unionType([ts22.numberType, decimal]);
|
|
6015
6089
|
var typeMappings = {
|
|
6016
|
-
unknown:
|
|
6017
|
-
string:
|
|
6018
|
-
int:
|
|
6090
|
+
unknown: ts22.unknownType,
|
|
6091
|
+
string: ts22.stringType,
|
|
6092
|
+
int: ts22.numberType,
|
|
6019
6093
|
bigint: {
|
|
6020
6094
|
in: bigintIn,
|
|
6021
|
-
out:
|
|
6095
|
+
out: ts22.bigintType
|
|
6022
6096
|
},
|
|
6023
6097
|
decimal: {
|
|
6024
6098
|
in: decimalIn,
|
|
6025
6099
|
out: decimal
|
|
6026
6100
|
},
|
|
6027
|
-
float:
|
|
6028
|
-
double:
|
|
6029
|
-
enum:
|
|
6101
|
+
float: ts22.numberType,
|
|
6102
|
+
double: ts22.numberType,
|
|
6103
|
+
enum: ts22.stringType,
|
|
6030
6104
|
// TODO:
|
|
6031
6105
|
bytes: uint8Array,
|
|
6032
|
-
bool:
|
|
6033
|
-
char:
|
|
6106
|
+
bool: ts22.booleanType,
|
|
6107
|
+
char: ts22.stringType,
|
|
6034
6108
|
json: {
|
|
6035
6109
|
in: inputJsonValue,
|
|
6036
6110
|
out: jsonValue
|
|
6037
6111
|
},
|
|
6038
|
-
xml:
|
|
6039
|
-
uuid:
|
|
6112
|
+
xml: ts22.stringType,
|
|
6113
|
+
uuid: ts22.stringType,
|
|
6040
6114
|
date,
|
|
6041
6115
|
datetime: date,
|
|
6042
6116
|
time: date,
|
|
6043
|
-
null:
|
|
6044
|
-
"int-array":
|
|
6045
|
-
"string-array":
|
|
6117
|
+
null: ts22.nullType,
|
|
6118
|
+
"int-array": ts22.array(ts22.numberType),
|
|
6119
|
+
"string-array": ts22.array(ts22.stringType),
|
|
6046
6120
|
"json-array": {
|
|
6047
|
-
in:
|
|
6048
|
-
out:
|
|
6121
|
+
in: ts22.array(inputJsonValue),
|
|
6122
|
+
out: ts22.array(jsonValue)
|
|
6049
6123
|
},
|
|
6050
|
-
"uuid-array":
|
|
6051
|
-
"xml-array":
|
|
6124
|
+
"uuid-array": ts22.array(ts22.stringType),
|
|
6125
|
+
"xml-array": ts22.array(ts22.stringType),
|
|
6052
6126
|
"bigint-array": {
|
|
6053
|
-
in:
|
|
6054
|
-
out:
|
|
6127
|
+
in: ts22.array(bigintIn),
|
|
6128
|
+
out: ts22.array(ts22.bigintType)
|
|
6055
6129
|
},
|
|
6056
|
-
"float-array":
|
|
6057
|
-
"double-array":
|
|
6058
|
-
"char-array":
|
|
6059
|
-
"bytes-array":
|
|
6060
|
-
"bool-array":
|
|
6061
|
-
"date-array":
|
|
6062
|
-
"time-array":
|
|
6063
|
-
"datetime-array":
|
|
6130
|
+
"float-array": ts22.array(ts22.numberType),
|
|
6131
|
+
"double-array": ts22.array(ts22.numberType),
|
|
6132
|
+
"char-array": ts22.array(ts22.stringType),
|
|
6133
|
+
"bytes-array": ts22.array(uint8Array),
|
|
6134
|
+
"bool-array": ts22.array(ts22.booleanType),
|
|
6135
|
+
"date-array": ts22.array(date),
|
|
6136
|
+
"time-array": ts22.array(date),
|
|
6137
|
+
"datetime-array": ts22.array(date),
|
|
6064
6138
|
"decimal-array": {
|
|
6065
|
-
in:
|
|
6066
|
-
out:
|
|
6139
|
+
in: ts22.array(decimalIn),
|
|
6140
|
+
out: ts22.array(decimal)
|
|
6067
6141
|
}
|
|
6068
6142
|
};
|
|
6069
6143
|
function getInputType(introspectionType, nullable, enums) {
|
|
@@ -6071,7 +6145,7 @@ function getInputType(introspectionType, nullable, enums) {
|
|
|
6071
6145
|
if (!nullable) {
|
|
6072
6146
|
return inn;
|
|
6073
6147
|
} else {
|
|
6074
|
-
return new
|
|
6148
|
+
return new ts22.UnionType(inn).addVariant(ts22.nullType);
|
|
6075
6149
|
}
|
|
6076
6150
|
}
|
|
6077
6151
|
function getOutputType(introspectionType, nullable, enums) {
|
|
@@ -6079,7 +6153,7 @@ function getOutputType(introspectionType, nullable, enums) {
|
|
|
6079
6153
|
if (!nullable) {
|
|
6080
6154
|
return out;
|
|
6081
6155
|
} else {
|
|
6082
|
-
return new
|
|
6156
|
+
return new ts22.UnionType(out).addVariant(ts22.nullType);
|
|
6083
6157
|
}
|
|
6084
6158
|
}
|
|
6085
6159
|
function getMappingConfig(introspectionType, enums) {
|
|
@@ -6091,29 +6165,29 @@ function getMappingConfig(introspectionType, enums) {
|
|
|
6091
6165
|
}
|
|
6092
6166
|
throw new Error("Unknown type");
|
|
6093
6167
|
}
|
|
6094
|
-
if (config instanceof
|
|
6168
|
+
if (config instanceof ts22.TypeBuilder) {
|
|
6095
6169
|
return { in: config, out: config };
|
|
6096
6170
|
}
|
|
6097
6171
|
return config;
|
|
6098
6172
|
}
|
|
6099
6173
|
function getEnumType(name) {
|
|
6100
|
-
return
|
|
6174
|
+
return ts22.namedType("$DbEnums").subKey(name);
|
|
6101
6175
|
}
|
|
6102
6176
|
|
|
6103
6177
|
// src/typedSql/buildTypedQuery.ts
|
|
6104
6178
|
function buildTypedQuery({ query, runtimeBase, runtimeName, enums, importName }) {
|
|
6105
|
-
const file4 =
|
|
6106
|
-
file4.addImport(
|
|
6179
|
+
const file4 = ts23.file();
|
|
6180
|
+
file4.addImport(ts23.moduleImport(`${runtimeBase}/${runtimeName}`).asNamespace("$runtime"));
|
|
6107
6181
|
if (queryUsesEnums(query, enums)) {
|
|
6108
|
-
file4.addImport(
|
|
6182
|
+
file4.addImport(ts23.moduleImport(importName("./$DbEnums")).named(ts23.namedImport("$DbEnums").typeOnly()));
|
|
6109
6183
|
}
|
|
6110
|
-
const doc =
|
|
6111
|
-
const factoryType =
|
|
6112
|
-
const parametersType =
|
|
6184
|
+
const doc = ts23.docComment(query.documentation ?? void 0);
|
|
6185
|
+
const factoryType = ts23.functionType();
|
|
6186
|
+
const parametersType = ts23.tupleType();
|
|
6113
6187
|
for (const param of query.parameters) {
|
|
6114
6188
|
const paramType = getInputType(param.typ, param.nullable, enums);
|
|
6115
|
-
factoryType.addParameter(
|
|
6116
|
-
parametersType.add(
|
|
6189
|
+
factoryType.addParameter(ts23.parameter(param.name, paramType));
|
|
6190
|
+
parametersType.add(ts23.tupleItem(paramType).setName(param.name));
|
|
6117
6191
|
if (param.documentation) {
|
|
6118
6192
|
doc.addText(`@param ${param.name} ${param.documentation}`);
|
|
6119
6193
|
} else {
|
|
@@ -6121,26 +6195,26 @@ function buildTypedQuery({ query, runtimeBase, runtimeName, enums, importName })
|
|
|
6121
6195
|
}
|
|
6122
6196
|
}
|
|
6123
6197
|
factoryType.setReturnType(
|
|
6124
|
-
|
|
6198
|
+
ts23.namedType("$runtime.TypedSql").addGenericArgument(ts23.namedType(`${query.name}.Parameters`)).addGenericArgument(ts23.namedType(`${query.name}.Result`))
|
|
6125
6199
|
);
|
|
6126
6200
|
file4.add(
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6201
|
+
ts23.moduleExport(
|
|
6202
|
+
ts23.constDeclaration(query.name).setValue(
|
|
6203
|
+
ts23.functionCall("$runtime.makeTypedQueryFactory").addArgument(ts23.stringLiteral(query.source).asValue()).as(factoryType)
|
|
6130
6204
|
)
|
|
6131
6205
|
).setDocComment(doc)
|
|
6132
6206
|
);
|
|
6133
|
-
const namespace2 =
|
|
6134
|
-
namespace2.add(
|
|
6207
|
+
const namespace2 = ts23.namespace(query.name);
|
|
6208
|
+
namespace2.add(ts23.moduleExport(ts23.typeDeclaration("Parameters", parametersType)));
|
|
6135
6209
|
namespace2.add(buildResultType(query, enums));
|
|
6136
|
-
file4.add(
|
|
6137
|
-
return
|
|
6210
|
+
file4.add(ts23.moduleExport(namespace2));
|
|
6211
|
+
return ts23.stringify(file4);
|
|
6138
6212
|
}
|
|
6139
6213
|
function buildResultType(query, enums) {
|
|
6140
|
-
const type =
|
|
6141
|
-
query.resultColumns.map((column) =>
|
|
6214
|
+
const type = ts23.objectType().addMultiple(
|
|
6215
|
+
query.resultColumns.map((column) => ts23.property(column.name, getOutputType(column.typ, column.nullable, enums)))
|
|
6142
6216
|
);
|
|
6143
|
-
return
|
|
6217
|
+
return ts23.moduleExport(ts23.typeDeclaration("Result", type));
|
|
6144
6218
|
}
|
|
6145
6219
|
|
|
6146
6220
|
// src/typedSql/typedSql.ts
|
|
@@ -6192,7 +6266,7 @@ var DenylistError = class extends Error {
|
|
|
6192
6266
|
this.stack = void 0;
|
|
6193
6267
|
}
|
|
6194
6268
|
};
|
|
6195
|
-
(0,
|
|
6269
|
+
(0, import_internals10.setClassName)(DenylistError, "DenylistError");
|
|
6196
6270
|
function buildClient({
|
|
6197
6271
|
schemaPath,
|
|
6198
6272
|
runtimeBase,
|
|
@@ -6215,7 +6289,7 @@ function buildClient({
|
|
|
6215
6289
|
moduleFormat,
|
|
6216
6290
|
tsNoCheckPreamble: tsNoCheckPreamble2
|
|
6217
6291
|
}) {
|
|
6218
|
-
const clientEngineType = (0,
|
|
6292
|
+
const clientEngineType = (0, import_internals10.getClientEngineType)(generator);
|
|
6219
6293
|
const runtimeName = getRuntimeNameForTarget(target, clientEngineType, generator.previewFeatures);
|
|
6220
6294
|
const outputName = generatedFileNameMapper(generatedFileExtension);
|
|
6221
6295
|
const importName = importFileNameMapper(importFileExtension);
|
|
@@ -6308,7 +6382,7 @@ async function generateClient(options) {
|
|
|
6308
6382
|
moduleFormat,
|
|
6309
6383
|
tsNoCheckPreamble: tsNoCheckPreamble2
|
|
6310
6384
|
} = options;
|
|
6311
|
-
const clientEngineType = (0,
|
|
6385
|
+
const clientEngineType = (0, import_internals10.getClientEngineType)(generator);
|
|
6312
6386
|
const { runtimeBase, outputDir } = await getGenerationDirs(options);
|
|
6313
6387
|
const { prismaClientDmmf, fileMap } = buildClient({
|
|
6314
6388
|
datamodel,
|
|
@@ -6348,7 +6422,7 @@ To learn more about how to rename models, check out https://pris.ly/d/naming-mod
|
|
|
6348
6422
|
await deleteOutputDir(outputDir);
|
|
6349
6423
|
await (0, import_fs_extra.ensureDir)(outputDir);
|
|
6350
6424
|
await writeFileMap(outputDir, fileMap);
|
|
6351
|
-
const enginePath = clientEngineType ===
|
|
6425
|
+
const enginePath = clientEngineType === import_internals10.ClientEngineType.Library ? binaryPaths.libqueryEngine : binaryPaths.queryEngine;
|
|
6352
6426
|
if (copyEngine && enginePath) {
|
|
6353
6427
|
if (process.env.NETLIFY) {
|
|
6354
6428
|
await (0, import_fs_extra.ensureDir)("/tmp/prisma-engines");
|
|
@@ -6458,7 +6532,7 @@ function validateDmmfAgainstDenylists(prismaClientDmmf) {
|
|
|
6458
6532
|
}
|
|
6459
6533
|
async function getGenerationDirs({ runtimeBase, outputDir }) {
|
|
6460
6534
|
const normalizedOutputDir = import_node_path4.default.normalize(outputDir);
|
|
6461
|
-
const normalizedRuntimeBase = (0,
|
|
6535
|
+
const normalizedRuntimeBase = (0, import_internals10.pathToPosix)(runtimeBase);
|
|
6462
6536
|
const userPackageRoot = await (0, import_package_up.packageUp)({ cwd: import_node_path4.default.dirname(normalizedOutputDir) });
|
|
6463
6537
|
const userProjectRoot = userPackageRoot ? import_node_path4.default.dirname(userPackageRoot) : process.cwd();
|
|
6464
6538
|
return {
|
|
@@ -6475,27 +6549,27 @@ function getRuntimeNameForTarget(target, engineType, previewFeatures) {
|
|
|
6475
6549
|
case "workerd":
|
|
6476
6550
|
case "vercel-edge":
|
|
6477
6551
|
if (previewFeatures.includes("driverAdapters")) {
|
|
6478
|
-
return engineType ===
|
|
6552
|
+
return engineType === import_internals10.ClientEngineType.Client ? "wasm-compiler-edge" : "wasm-engine-edge";
|
|
6479
6553
|
} else {
|
|
6480
6554
|
return "edge";
|
|
6481
6555
|
}
|
|
6482
6556
|
case "react-native":
|
|
6483
6557
|
return "react-native";
|
|
6484
6558
|
default:
|
|
6485
|
-
(0,
|
|
6559
|
+
(0, import_internals10.assertNever)(target, "Unknown runtime target");
|
|
6486
6560
|
}
|
|
6487
6561
|
}
|
|
6488
6562
|
function getNodeRuntimeName(engineType) {
|
|
6489
|
-
if (engineType ===
|
|
6563
|
+
if (engineType === import_internals10.ClientEngineType.Binary) {
|
|
6490
6564
|
return "binary";
|
|
6491
6565
|
}
|
|
6492
|
-
if (engineType ===
|
|
6566
|
+
if (engineType === import_internals10.ClientEngineType.Library) {
|
|
6493
6567
|
return "library";
|
|
6494
6568
|
}
|
|
6495
|
-
if (engineType ===
|
|
6569
|
+
if (engineType === import_internals10.ClientEngineType.Client) {
|
|
6496
6570
|
return "client";
|
|
6497
6571
|
}
|
|
6498
|
-
(0,
|
|
6572
|
+
(0, import_internals10.assertNever)(engineType, "Unknown engine type");
|
|
6499
6573
|
}
|
|
6500
6574
|
async function deleteOutputDir(outputDir) {
|
|
6501
6575
|
try {
|
|
@@ -6533,12 +6607,12 @@ async function deleteOutputDir(outputDir) {
|
|
|
6533
6607
|
// src/generator.ts
|
|
6534
6608
|
var import_debug2 = require("@prisma/debug");
|
|
6535
6609
|
var import_engines_version = require("@prisma/engines-version");
|
|
6536
|
-
var
|
|
6610
|
+
var import_internals11 = require("@prisma/internals");
|
|
6537
6611
|
var import_get_tsconfig = require("get-tsconfig");
|
|
6538
6612
|
var import_ts_pattern2 = require("ts-pattern");
|
|
6539
6613
|
|
|
6540
6614
|
// package.json
|
|
6541
|
-
var version = "6.16.0-dev.
|
|
6615
|
+
var version = "6.16.0-dev.37";
|
|
6542
6616
|
|
|
6543
6617
|
// src/module-format.ts
|
|
6544
6618
|
function parseModuleFormat(format) {
|
|
@@ -6634,12 +6708,12 @@ function getOutputPath(config) {
|
|
|
6634
6708
|
if (!config.output) {
|
|
6635
6709
|
throw new Error(missingOutputErrorMessage);
|
|
6636
6710
|
}
|
|
6637
|
-
return (0,
|
|
6711
|
+
return (0, import_internals11.parseEnvValue)(config.output);
|
|
6638
6712
|
}
|
|
6639
6713
|
var PrismaClientTsGenerator = class {
|
|
6640
6714
|
name = "prisma-client-ts";
|
|
6641
6715
|
getManifest(config) {
|
|
6642
|
-
const requiresEngines = (0, import_ts_pattern2.match)((0,
|
|
6716
|
+
const requiresEngines = (0, import_ts_pattern2.match)((0, import_internals11.getClientEngineType)(config)).with(import_internals11.ClientEngineType.Library, () => ["libqueryEngine"]).with(import_internals11.ClientEngineType.Binary, () => ["queryEngine"]).with(import_internals11.ClientEngineType.Client, () => []).exhaustive();
|
|
6643
6717
|
debug2("requiresEngines", requiresEngines);
|
|
6644
6718
|
return Promise.resolve({
|
|
6645
6719
|
defaultOutput: getOutputPath(config),
|