@prisma/client-generator-ts 6.13.0-dev.3 → 6.13.0-dev.31
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/Args.d.ts +1 -0
- package/dist/index.js +139 -91
- package/dist/index.mjs +77 -29
- package/dist/utils.d.ts +0 -1
- package/package.json +10 -10
package/dist/TSClient/Args.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare class ArgsTypeBuilder {
|
|
|
22
22
|
isNullable: boolean;
|
|
23
23
|
isRequired: boolean;
|
|
24
24
|
inputTypes: DMMF.InputTypeRef[];
|
|
25
|
+
requiresOtherFields?: string[] | undefined;
|
|
25
26
|
deprecation?: import("@prisma/dmmf/dist/util").ReadonlyDeep<{
|
|
26
27
|
sinceVersion: string;
|
|
27
28
|
reason: string;
|
package/dist/index.js
CHANGED
|
@@ -2399,11 +2399,12 @@ export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}]
|
|
|
2399
2399
|
};
|
|
2400
2400
|
|
|
2401
2401
|
// src/TSClient/Input.ts
|
|
2402
|
-
var
|
|
2402
|
+
var import_client_common5 = require("@prisma/client-common");
|
|
2403
2403
|
var ts2 = __toESM(require("@prisma/ts-builders"));
|
|
2404
2404
|
var import_indent_string2 = __toESM(require("indent-string"));
|
|
2405
2405
|
|
|
2406
2406
|
// src/utils.ts
|
|
2407
|
+
var import_client_common4 = require("@prisma/client-common");
|
|
2407
2408
|
var DMMF = __toESM(require("@prisma/dmmf"));
|
|
2408
2409
|
var import_internals2 = require("@prisma/internals");
|
|
2409
2410
|
var ts = __toESM(require("@prisma/ts-builders"));
|
|
@@ -2435,31 +2436,31 @@ function getOmitName(modelName) {
|
|
|
2435
2436
|
return `${modelName}Omit`;
|
|
2436
2437
|
}
|
|
2437
2438
|
function getAggregateName(modelName) {
|
|
2438
|
-
return `Aggregate${
|
|
2439
|
+
return `Aggregate${(0, import_client_common4.capitalize)(modelName)}`;
|
|
2439
2440
|
}
|
|
2440
2441
|
function getCountOutputTypeName(modelName) {
|
|
2441
|
-
return `${
|
|
2442
|
+
return `${(0, import_client_common4.capitalize)(modelName)}CountOutputType`;
|
|
2442
2443
|
}
|
|
2443
2444
|
function getGroupByName(modelName) {
|
|
2444
|
-
return `${
|
|
2445
|
+
return `${(0, import_client_common4.capitalize)(modelName)}GroupByOutputType`;
|
|
2445
2446
|
}
|
|
2446
2447
|
function getAvgAggregateName(modelName) {
|
|
2447
|
-
return `${
|
|
2448
|
+
return `${(0, import_client_common4.capitalize)(modelName)}AvgAggregateOutputType`;
|
|
2448
2449
|
}
|
|
2449
2450
|
function getSumAggregateName(modelName) {
|
|
2450
|
-
return `${
|
|
2451
|
+
return `${(0, import_client_common4.capitalize)(modelName)}SumAggregateOutputType`;
|
|
2451
2452
|
}
|
|
2452
2453
|
function getMinAggregateName(modelName) {
|
|
2453
|
-
return `${
|
|
2454
|
+
return `${(0, import_client_common4.capitalize)(modelName)}MinAggregateOutputType`;
|
|
2454
2455
|
}
|
|
2455
2456
|
function getMaxAggregateName(modelName) {
|
|
2456
|
-
return `${
|
|
2457
|
+
return `${(0, import_client_common4.capitalize)(modelName)}MaxAggregateOutputType`;
|
|
2457
2458
|
}
|
|
2458
2459
|
function getCountAggregateInputName(modelName) {
|
|
2459
|
-
return `${
|
|
2460
|
+
return `${(0, import_client_common4.capitalize)(modelName)}CountAggregateInputType`;
|
|
2460
2461
|
}
|
|
2461
2462
|
function getCountAggregateOutputName(modelName) {
|
|
2462
|
-
return `${
|
|
2463
|
+
return `${(0, import_client_common4.capitalize)(modelName)}CountAggregateOutputType`;
|
|
2463
2464
|
}
|
|
2464
2465
|
function getAggregateInputType(aggregateOutputType) {
|
|
2465
2466
|
return aggregateOutputType.replace(/OutputType$/, "InputType");
|
|
@@ -2468,13 +2469,13 @@ function getGroupByArgsName(modelName) {
|
|
|
2468
2469
|
return `${modelName}GroupByArgs`;
|
|
2469
2470
|
}
|
|
2470
2471
|
function getGroupByPayloadName(modelName) {
|
|
2471
|
-
return `Get${
|
|
2472
|
+
return `Get${(0, import_client_common4.capitalize)(modelName)}GroupByPayload`;
|
|
2472
2473
|
}
|
|
2473
2474
|
function getAggregateArgsName(modelName) {
|
|
2474
|
-
return `${
|
|
2475
|
+
return `${(0, import_client_common4.capitalize)(modelName)}AggregateArgs`;
|
|
2475
2476
|
}
|
|
2476
2477
|
function getAggregateGetName(modelName) {
|
|
2477
|
-
return `Get${
|
|
2478
|
+
return `Get${(0, import_client_common4.capitalize)(modelName)}AggregateType`;
|
|
2478
2479
|
}
|
|
2479
2480
|
function getFieldArgName(field, modelName) {
|
|
2480
2481
|
if (field.args.length) {
|
|
@@ -2541,9 +2542,6 @@ function getPayloadName(modelName, namespace2 = true) {
|
|
|
2541
2542
|
function getFieldRefsTypeName(name) {
|
|
2542
2543
|
return `${name}FieldRefs`;
|
|
2543
2544
|
}
|
|
2544
|
-
function capitalize3(str) {
|
|
2545
|
-
return str[0].toUpperCase() + str.slice(1);
|
|
2546
|
-
}
|
|
2547
2545
|
function getRefAllowedTypeName(type) {
|
|
2548
2546
|
let typeName = type.type;
|
|
2549
2547
|
if (type.isList) {
|
|
@@ -2670,7 +2668,7 @@ var InputType = class {
|
|
|
2670
2668
|
toTS() {
|
|
2671
2669
|
const { type } = this;
|
|
2672
2670
|
const source = type.meta?.source;
|
|
2673
|
-
const fields = (0,
|
|
2671
|
+
const fields = (0, import_client_common5.uniqueBy)(type.fields, (f) => f.name);
|
|
2674
2672
|
const body = `{
|
|
2675
2673
|
${(0, import_indent_string2.default)(
|
|
2676
2674
|
fields.map((arg) => {
|
|
@@ -2708,7 +2706,7 @@ function wrapWithAtLeast(body, input) {
|
|
|
2708
2706
|
}
|
|
2709
2707
|
|
|
2710
2708
|
// src/dmmf.ts
|
|
2711
|
-
var
|
|
2709
|
+
var import_client_common6 = require("@prisma/client-common");
|
|
2712
2710
|
var DMMFHelper = class {
|
|
2713
2711
|
constructor(document) {
|
|
2714
2712
|
this.document = document;
|
|
@@ -2774,33 +2772,33 @@ var DMMFHelper = class {
|
|
|
2774
2772
|
return this.outputObjectTypes[ref.namespace ?? "prisma"].find((outputObject) => outputObject.name === ref.type);
|
|
2775
2773
|
}
|
|
2776
2774
|
buildModelMap() {
|
|
2777
|
-
return (0,
|
|
2775
|
+
return (0, import_client_common6.keyBy)(this.datamodel.models, "name");
|
|
2778
2776
|
}
|
|
2779
2777
|
buildTypeMap() {
|
|
2780
|
-
return (0,
|
|
2778
|
+
return (0, import_client_common6.keyBy)(this.datamodel.types, "name");
|
|
2781
2779
|
}
|
|
2782
2780
|
buildTypeModelMap() {
|
|
2783
2781
|
return { ...this.buildTypeMap(), ...this.buildModelMap() };
|
|
2784
2782
|
}
|
|
2785
2783
|
buildMappingsMap() {
|
|
2786
|
-
return (0,
|
|
2784
|
+
return (0, import_client_common6.keyBy)(this.mappings.modelOperations, "model");
|
|
2787
2785
|
}
|
|
2788
2786
|
buildMergedOutputTypeMap() {
|
|
2789
2787
|
if (!this.schema.outputObjectTypes.prisma) {
|
|
2790
2788
|
return {
|
|
2791
|
-
model: (0,
|
|
2792
|
-
prisma: (0,
|
|
2789
|
+
model: (0, import_client_common6.keyBy)(this.schema.outputObjectTypes.model, "name"),
|
|
2790
|
+
prisma: (0, import_client_common6.keyBy)([], "name")
|
|
2793
2791
|
};
|
|
2794
2792
|
}
|
|
2795
2793
|
return {
|
|
2796
|
-
model: (0,
|
|
2797
|
-
prisma: (0,
|
|
2794
|
+
model: (0, import_client_common6.keyBy)(this.schema.outputObjectTypes.model, "name"),
|
|
2795
|
+
prisma: (0, import_client_common6.keyBy)(this.schema.outputObjectTypes.prisma, "name")
|
|
2798
2796
|
};
|
|
2799
2797
|
}
|
|
2800
2798
|
buildRootFieldMap() {
|
|
2801
2799
|
return {
|
|
2802
|
-
...(0,
|
|
2803
|
-
...(0,
|
|
2800
|
+
...(0, import_client_common6.keyBy)(this.outputTypeMap.prisma.Query.fields, "name"),
|
|
2801
|
+
...(0, import_client_common6.keyBy)(this.outputTypeMap.prisma.Mutation.fields, "name")
|
|
2804
2802
|
};
|
|
2805
2803
|
}
|
|
2806
2804
|
buildInputTypesMap() {
|
|
@@ -2825,12 +2823,12 @@ function fullyQualifiedName(typeName, namespace2) {
|
|
|
2825
2823
|
}
|
|
2826
2824
|
|
|
2827
2825
|
// src/GenericsArgsInfo.ts
|
|
2828
|
-
var
|
|
2826
|
+
var import_client_common7 = require("@prisma/client-common");
|
|
2829
2827
|
var GenericArgsInfo = class {
|
|
2830
2828
|
constructor(_dmmf) {
|
|
2831
2829
|
this._dmmf = _dmmf;
|
|
2832
2830
|
}
|
|
2833
|
-
_cache = new
|
|
2831
|
+
_cache = new import_client_common7.Cache();
|
|
2834
2832
|
/**
|
|
2835
2833
|
* Determines if arg types need generic <$PrismaModel> argument added.
|
|
2836
2834
|
* Essentially, performs breadth-first search for any fieldRefTypes that
|
|
@@ -2952,14 +2950,14 @@ function buildDebugInitialization(edge) {
|
|
|
2952
2950
|
}
|
|
2953
2951
|
|
|
2954
2952
|
// src/utils/buildDMMF.ts
|
|
2955
|
-
var
|
|
2953
|
+
var import_client_common10 = require("@prisma/client-common");
|
|
2956
2954
|
|
|
2957
2955
|
// src/TSClient/helpers.ts
|
|
2958
|
-
var
|
|
2956
|
+
var import_client_common9 = require("@prisma/client-common");
|
|
2959
2957
|
var import_pluralize2 = __toESM(require("pluralize"));
|
|
2960
2958
|
|
|
2961
2959
|
// src/TSClient/jsdoc.ts
|
|
2962
|
-
var
|
|
2960
|
+
var import_client_common8 = require("@prisma/client-common");
|
|
2963
2961
|
var Docs = {
|
|
2964
2962
|
cursor: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}`,
|
|
2965
2963
|
pagination: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs}`,
|
|
@@ -3032,7 +3030,7 @@ const ${ctx.singular} = await ${ctx.method}({
|
|
|
3032
3030
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
|
|
3033
3031
|
@example
|
|
3034
3032
|
// Create many ${ctx.plural}
|
|
3035
|
-
const ${(0,
|
|
3033
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3036
3034
|
data: [
|
|
3037
3035
|
// ... provide data here
|
|
3038
3036
|
]
|
|
@@ -3046,7 +3044,7 @@ const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3046
3044
|
body: (ctx) => {
|
|
3047
3045
|
const onlySelect = ctx.firstScalar ? `
|
|
3048
3046
|
// Create many ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
|
|
3049
|
-
const ${(0,
|
|
3047
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)}With${(0, import_client_common8.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({
|
|
3050
3048
|
select: { ${ctx.firstScalar.name}: true },
|
|
3051
3049
|
data: [
|
|
3052
3050
|
// ... provide data here
|
|
@@ -3056,7 +3054,7 @@ const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)}With${(0, imp
|
|
|
3056
3054
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
|
|
3057
3055
|
@example
|
|
3058
3056
|
// Create many ${ctx.plural}
|
|
3059
|
-
const ${(0,
|
|
3057
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3060
3058
|
data: [
|
|
3061
3059
|
// ... provide data here
|
|
3062
3060
|
]
|
|
@@ -3074,7 +3072,7 @@ ${undefinedNote}
|
|
|
3074
3072
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3075
3073
|
@example
|
|
3076
3074
|
// Get one ${ctx.singular}
|
|
3077
|
-
const ${(0,
|
|
3075
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3078
3076
|
where: {
|
|
3079
3077
|
// ... provide filter here
|
|
3080
3078
|
}
|
|
@@ -3089,7 +3087,7 @@ if no matches were found.
|
|
|
3089
3087
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3090
3088
|
@example
|
|
3091
3089
|
// Get one ${ctx.singular}
|
|
3092
|
-
const ${(0,
|
|
3090
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3093
3091
|
where: {
|
|
3094
3092
|
// ... provide filter here
|
|
3095
3093
|
}
|
|
@@ -3104,7 +3102,7 @@ ${undefinedNote}
|
|
|
3104
3102
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3105
3103
|
@example
|
|
3106
3104
|
// Get one ${ctx.singular}
|
|
3107
|
-
const ${(0,
|
|
3105
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3108
3106
|
where: {
|
|
3109
3107
|
// ... provide filter here
|
|
3110
3108
|
}
|
|
@@ -3125,7 +3123,7 @@ ${undefinedNote}
|
|
|
3125
3123
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3126
3124
|
@example
|
|
3127
3125
|
// Get one ${ctx.singular}
|
|
3128
|
-
const ${(0,
|
|
3126
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3129
3127
|
where: {
|
|
3130
3128
|
// ... provide filter here
|
|
3131
3129
|
}
|
|
@@ -3143,7 +3141,7 @@ const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3143
3141
|
body: (ctx) => {
|
|
3144
3142
|
const onlySelect = ctx.firstScalar ? `
|
|
3145
3143
|
// Only select the \`${ctx.firstScalar.name}\`
|
|
3146
|
-
const ${(0,
|
|
3144
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)}With${(0, import_client_common8.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({ select: { ${ctx.firstScalar.name}: true } })` : "";
|
|
3147
3145
|
return `Find zero or more ${ctx.plural} that matches the filter.
|
|
3148
3146
|
${undefinedNote}
|
|
3149
3147
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to filter and select certain fields only.
|
|
@@ -3169,7 +3167,7 @@ ${onlySelect}
|
|
|
3169
3167
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one ${ctx.singular}.
|
|
3170
3168
|
@example
|
|
3171
3169
|
// Update one ${ctx.singular}
|
|
3172
|
-
const ${(0,
|
|
3170
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3173
3171
|
where: {
|
|
3174
3172
|
// ... provide filter here
|
|
3175
3173
|
},
|
|
@@ -3188,7 +3186,7 @@ const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3188
3186
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update or create a ${ctx.singular}.
|
|
3189
3187
|
@example
|
|
3190
3188
|
// Update or create a ${ctx.singular}
|
|
3191
|
-
const ${(0,
|
|
3189
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3192
3190
|
create: {
|
|
3193
3191
|
// ... data to create a ${ctx.singular}
|
|
3194
3192
|
},
|
|
@@ -3282,7 +3280,7 @@ ${undefinedNote}
|
|
|
3282
3280
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one or more rows.
|
|
3283
3281
|
@example
|
|
3284
3282
|
// Update many ${ctx.plural}
|
|
3285
|
-
const ${(0,
|
|
3283
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3286
3284
|
where: {
|
|
3287
3285
|
// ... provide filter here
|
|
3288
3286
|
},
|
|
@@ -3301,7 +3299,7 @@ const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3301
3299
|
body: (ctx) => {
|
|
3302
3300
|
const onlySelect = ctx.firstScalar ? `
|
|
3303
3301
|
// Update zero or more ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
|
|
3304
|
-
const ${(0,
|
|
3302
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)}With${(0, import_client_common8.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({
|
|
3305
3303
|
select: { ${ctx.firstScalar.name}: true },
|
|
3306
3304
|
where: {
|
|
3307
3305
|
// ... provide filter here
|
|
@@ -3314,7 +3312,7 @@ const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)}With${(0, imp
|
|
|
3314
3312
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update many ${ctx.plural}.
|
|
3315
3313
|
@example
|
|
3316
3314
|
// Update many ${ctx.plural}
|
|
3317
|
-
const ${(0,
|
|
3315
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3318
3316
|
where: {
|
|
3319
3317
|
// ... provide filter here
|
|
3320
3318
|
},
|
|
@@ -3352,7 +3350,7 @@ const { count } = await ${ctx.method}({
|
|
|
3352
3350
|
body: (ctx) => `Perform aggregation operations on a ${ctx.singular}.
|
|
3353
3351
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which aggregations you would like to apply.
|
|
3354
3352
|
@example
|
|
3355
|
-
const ${(0,
|
|
3353
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3356
3354
|
pipeline: [
|
|
3357
3355
|
{ $match: { status: "registered" } },
|
|
3358
3356
|
{ $group: { _id: "$country", total: { $sum: 1 } } }
|
|
@@ -3367,7 +3365,7 @@ const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3367
3365
|
body: (ctx) => `Find zero or more ${ctx.plural} that matches the filter.
|
|
3368
3366
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which filters you would like to apply.
|
|
3369
3367
|
@example
|
|
3370
|
-
const ${(0,
|
|
3368
|
+
const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3371
3369
|
filter: { age: { $gt: 25 } }
|
|
3372
3370
|
})`,
|
|
3373
3371
|
fields: {
|
|
@@ -3380,10 +3378,10 @@ const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3380
3378
|
// src/TSClient/helpers.ts
|
|
3381
3379
|
function getMethodJSDocBody(action, mapping, model) {
|
|
3382
3380
|
const ctx = {
|
|
3383
|
-
singular: (0,
|
|
3384
|
-
plural: (0,
|
|
3381
|
+
singular: (0, import_client_common9.capitalize)(mapping.model),
|
|
3382
|
+
plural: (0, import_client_common9.capitalize)(mapping.plural),
|
|
3385
3383
|
firstScalar: model.fields.find((f) => f.kind === "scalar"),
|
|
3386
|
-
method: `prisma.${(0,
|
|
3384
|
+
method: `prisma.${(0, import_client_common9.uncapitalize)(mapping.model)}.${action}`,
|
|
3387
3385
|
action,
|
|
3388
3386
|
mapping,
|
|
3389
3387
|
model
|
|
@@ -3416,10 +3414,10 @@ function escapeJson(str) {
|
|
|
3416
3414
|
|
|
3417
3415
|
// src/utils/buildDMMF.ts
|
|
3418
3416
|
function buildRuntimeDataModel(datamodel, runtimeName) {
|
|
3419
|
-
const runtimeDataModel = (0,
|
|
3417
|
+
const runtimeDataModel = (0, import_client_common10.dmmfToRuntimeDataModel)(datamodel);
|
|
3420
3418
|
let prunedDataModel;
|
|
3421
3419
|
if (runtimeName === "wasm-engine-edge" || runtimeName === "wasm-compiler-edge" || runtimeName === "client") {
|
|
3422
|
-
prunedDataModel = (0,
|
|
3420
|
+
prunedDataModel = (0, import_client_common10.pruneRuntimeDataModel)(runtimeDataModel);
|
|
3423
3421
|
} else {
|
|
3424
3422
|
prunedDataModel = runtimeDataModel;
|
|
3425
3423
|
}
|
|
@@ -3445,7 +3443,7 @@ function buildInlineDatasource(ds) {
|
|
|
3445
3443
|
// src/utils/wasm.ts
|
|
3446
3444
|
var import_node_fs = __toESM(require("node:fs"));
|
|
3447
3445
|
var import_node_path = __toESM(require("node:path"));
|
|
3448
|
-
var
|
|
3446
|
+
var import_client_common11 = require("@prisma/client-common");
|
|
3449
3447
|
var import_ts_pattern = require("ts-pattern");
|
|
3450
3448
|
function buildDynamicRequireFn() {
|
|
3451
3449
|
return `const dynamicRequireFn = async <const T extends string>(name: T) =>
|
|
@@ -3464,7 +3462,7 @@ function buildGetWasmModule({
|
|
|
3464
3462
|
activeProvider,
|
|
3465
3463
|
moduleFormat
|
|
3466
3464
|
}) {
|
|
3467
|
-
const capitalizedComponent = (0,
|
|
3465
|
+
const capitalizedComponent = (0, import_client_common11.capitalize)(component);
|
|
3468
3466
|
const buildEdgeLoader = usesEdgeWasmRuntime(component, runtimeName);
|
|
3469
3467
|
let wasmBindingsPath;
|
|
3470
3468
|
let wasmModulePath;
|
|
@@ -3543,7 +3541,7 @@ function buildWasmFileMap({ runtimeName, activeProvider }) {
|
|
|
3543
3541
|
}
|
|
3544
3542
|
|
|
3545
3543
|
// src/TSClient/PrismaClient.ts
|
|
3546
|
-
var
|
|
3544
|
+
var import_client_common12 = require("@prisma/client-common");
|
|
3547
3545
|
var ts4 = __toESM(require("@prisma/ts-builders"));
|
|
3548
3546
|
var import_indent_string3 = __toESM(require("indent-string"));
|
|
3549
3547
|
|
|
@@ -3756,8 +3754,8 @@ function getPrismaClientClassDocComment({ dmmf }) {
|
|
|
3756
3754
|
@example
|
|
3757
3755
|
\`\`\`
|
|
3758
3756
|
const prisma = new PrismaClient()
|
|
3759
|
-
// Fetch zero or more ${
|
|
3760
|
-
const ${(0,
|
|
3757
|
+
// Fetch zero or more ${(0, import_client_common12.capitalize)(example.plural)}
|
|
3758
|
+
const ${(0, import_client_common12.uncapitalize)(example.plural)} = await prisma.${(0, import_client_common12.uncapitalize)(example.model)}.findMany()
|
|
3761
3759
|
\`\`\`
|
|
3762
3760
|
|
|
3763
3761
|
Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
|
|
@@ -3780,7 +3778,7 @@ export interface PrismaClientConstructor {
|
|
|
3780
3778
|
${(0, import_indent_string3.default)(this.jsDoc, TAB_SIZE)}
|
|
3781
3779
|
new <
|
|
3782
3780
|
ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
|
|
3783
|
-
U = LogOptions<ClientOptions>,
|
|
3781
|
+
const U = LogOptions<ClientOptions>,
|
|
3784
3782
|
ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
|
|
3785
3783
|
>(options?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>): PrismaClient<ClientOptions, U, ExtArgs>
|
|
3786
3784
|
}
|
|
@@ -3826,7 +3824,7 @@ ${[
|
|
|
3826
3824
|
|
|
3827
3825
|
${(0, import_indent_string3.default)(
|
|
3828
3826
|
dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
|
|
3829
|
-
let methodName = (0,
|
|
3827
|
+
let methodName = (0, import_client_common12.uncapitalize)(m.model);
|
|
3830
3828
|
if (methodName === "constructor") {
|
|
3831
3829
|
methodName = '["constructor"]';
|
|
3832
3830
|
}
|
|
@@ -3835,8 +3833,8 @@ ${[
|
|
|
3835
3833
|
* \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
|
|
3836
3834
|
* Example usage:
|
|
3837
3835
|
* \`\`\`ts
|
|
3838
|
-
* // Fetch zero or more ${
|
|
3839
|
-
* const ${(0,
|
|
3836
|
+
* // Fetch zero or more ${(0, import_client_common12.capitalize)(m.plural)}
|
|
3837
|
+
* const ${(0, import_client_common12.uncapitalize)(m.plural)} = await prisma.${methodName}.findMany()
|
|
3840
3838
|
* \`\`\`
|
|
3841
3839
|
*/
|
|
3842
3840
|
get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
|
|
@@ -4114,6 +4112,7 @@ export {}
|
|
|
4114
4112
|
var ts14 = __toESM(require("@prisma/ts-builders"));
|
|
4115
4113
|
|
|
4116
4114
|
// src/TSClient/Model.ts
|
|
4115
|
+
var import_client_common16 = require("@prisma/client-common");
|
|
4117
4116
|
var DMMF2 = __toESM(require("@prisma/dmmf"));
|
|
4118
4117
|
var ts13 = __toESM(require("@prisma/ts-builders"));
|
|
4119
4118
|
var import_indent_string5 = __toESM(require("indent-string"));
|
|
@@ -4199,6 +4198,7 @@ var ArgsTypeBuilder = class {
|
|
|
4199
4198
|
};
|
|
4200
4199
|
|
|
4201
4200
|
// src/TSClient/Count.ts
|
|
4201
|
+
var import_client_common13 = require("@prisma/client-common");
|
|
4202
4202
|
var ts10 = __toESM(require("@prisma/ts-builders"));
|
|
4203
4203
|
var import_indent_string4 = __toESM(require("indent-string"));
|
|
4204
4204
|
|
|
@@ -4317,7 +4317,7 @@ ${this.argsTypes.map((typeExport) => ts10.stringify(typeExport)).join("\n\n")}
|
|
|
4317
4317
|
}
|
|
4318
4318
|
};
|
|
4319
4319
|
function getCountArgsType(typeName, fieldName) {
|
|
4320
|
-
return `${typeName}Count${
|
|
4320
|
+
return `${typeName}Count${(0, import_client_common13.capitalize)(fieldName)}Args`;
|
|
4321
4321
|
}
|
|
4322
4322
|
|
|
4323
4323
|
// src/TSClient/ModelFieldRefs.ts
|
|
@@ -4348,7 +4348,7 @@ ${this.stringifyFields()}
|
|
|
4348
4348
|
};
|
|
4349
4349
|
|
|
4350
4350
|
// src/TSClient/Payload.ts
|
|
4351
|
-
var
|
|
4351
|
+
var import_client_common14 = require("@prisma/client-common");
|
|
4352
4352
|
var ts11 = __toESM(require("@prisma/ts-builders"));
|
|
4353
4353
|
function buildModelPayload(model, context) {
|
|
4354
4354
|
const isComposite = context.dmmf.isComposite(model.name);
|
|
@@ -4366,7 +4366,7 @@ function buildModelPayload(model, context) {
|
|
|
4366
4366
|
scalars.add(buildModelOutputProperty(field, context.dmmf));
|
|
4367
4367
|
}
|
|
4368
4368
|
}
|
|
4369
|
-
const scalarsType = isComposite ? scalars : ts11.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts11.namedType("ExtArgs").subKey("result").subKey((0,
|
|
4369
|
+
const scalarsType = isComposite ? scalars : ts11.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts11.namedType("ExtArgs").subKey("result").subKey((0, import_client_common14.uncapitalize)(model.name)));
|
|
4370
4370
|
const payloadTypeDeclaration = ts11.typeDeclaration(
|
|
4371
4371
|
getPayloadName(model.name, false),
|
|
4372
4372
|
ts11.objectType().add(ts11.property("name", ts11.stringLiteral(model.name))).add(ts11.property("objects", objects)).add(ts11.property("scalars", scalarsType)).add(ts11.property("composites", composites))
|
|
@@ -4378,7 +4378,7 @@ function buildModelPayload(model, context) {
|
|
|
4378
4378
|
}
|
|
4379
4379
|
|
|
4380
4380
|
// src/TSClient/SelectIncludeOmit.ts
|
|
4381
|
-
var
|
|
4381
|
+
var import_client_common15 = require("@prisma/client-common");
|
|
4382
4382
|
var ts12 = __toESM(require("@prisma/ts-builders"));
|
|
4383
4383
|
function buildIncludeType({
|
|
4384
4384
|
modelName,
|
|
@@ -4412,7 +4412,7 @@ function buildSelectType({
|
|
|
4412
4412
|
return buildExport(typeName, selectType);
|
|
4413
4413
|
}
|
|
4414
4414
|
function modelResultExtensionsType(modelName) {
|
|
4415
|
-
return extArgsParam.toArgument().subKey("result").subKey((0,
|
|
4415
|
+
return extArgsParam.toArgument().subKey("result").subKey((0, import_client_common15.uncapitalize)(modelName));
|
|
4416
4416
|
}
|
|
4417
4417
|
function buildScalarSelectType({ modelName, fields, context }) {
|
|
4418
4418
|
const object = buildSelectOrIncludeObject(
|
|
@@ -4579,7 +4579,7 @@ type ${getGroupByPayloadName(model.name)}<T extends ${groupByArgsName}> = Prisma
|
|
|
4579
4579
|
: Prisma.GetScalarType<T[P], ${groupByType.name}[P]>
|
|
4580
4580
|
}
|
|
4581
4581
|
>
|
|
4582
|
-
>
|
|
4582
|
+
>
|
|
4583
4583
|
`;
|
|
4584
4584
|
}
|
|
4585
4585
|
getAggregationTypes() {
|
|
@@ -4915,15 +4915,24 @@ ${ts13.stringify(buildFluentWrapperDefinition(name, this.outputType, this.contex
|
|
|
4915
4915
|
function buildModelDelegateMethod(modelName, actionName, context) {
|
|
4916
4916
|
const mapping = context.dmmf.mappingsMap[modelName] ?? { model: modelName, plural: `${modelName}s` };
|
|
4917
4917
|
const modelOrType = context.dmmf.typeAndModelMap[modelName];
|
|
4918
|
-
const
|
|
4918
|
+
const dependencyValidators = getNonAggregateMethodDependencyValidations(mapping, actionName, context);
|
|
4919
|
+
const method3 = ts13.method(actionName).setDocComment(ts13.docComment(getMethodJSDocBody(actionName, mapping, modelOrType))).addParameter(getNonAggregateMethodArgs(modelName, actionName, dependencyValidators)).setReturnType(getReturnType({ modelName, actionName }));
|
|
4919
4920
|
const generic = getNonAggregateMethodGenericParam(modelName, actionName);
|
|
4920
4921
|
if (generic) {
|
|
4921
4922
|
method3.addGenericParameter(generic);
|
|
4922
4923
|
}
|
|
4924
|
+
for (const validator of dependencyValidators) {
|
|
4925
|
+
method3.addGenericParameter(validator);
|
|
4926
|
+
}
|
|
4923
4927
|
return method3;
|
|
4924
4928
|
}
|
|
4925
|
-
function getNonAggregateMethodArgs(modelName, actionName) {
|
|
4926
|
-
const makeParameter = (type2) =>
|
|
4929
|
+
function getNonAggregateMethodArgs(modelName, actionName, dependencyValidators) {
|
|
4930
|
+
const makeParameter = (type2) => {
|
|
4931
|
+
if (dependencyValidators.length > 0) {
|
|
4932
|
+
type2 = ts13.intersectionType([type2, ...dependencyValidators.map((validator) => ts13.namedType(validator.name))]);
|
|
4933
|
+
}
|
|
4934
|
+
return ts13.parameter("args", type2);
|
|
4935
|
+
};
|
|
4927
4936
|
if (actionName === DMMF2.ModelAction.count) {
|
|
4928
4937
|
const type2 = omit(
|
|
4929
4938
|
ts13.namedType(getModelArgName(modelName, DMMF2.ModelAction.findMany)),
|
|
@@ -4953,6 +4962,32 @@ function getNonAggregateMethodGenericParam(modelName, actionName) {
|
|
|
4953
4962
|
}
|
|
4954
4963
|
return arg.extends(ts13.namedType(getModelArgName(modelName, actionName)));
|
|
4955
4964
|
}
|
|
4965
|
+
function getNonAggregateMethodDependencyValidations(modelMapping, actionName, context) {
|
|
4966
|
+
const outputFieldName = modelMapping[actionName];
|
|
4967
|
+
if (!outputFieldName) {
|
|
4968
|
+
throw new Error(`Missing mapping for ${modelMapping.model}.${actionName}`);
|
|
4969
|
+
}
|
|
4970
|
+
const outputField = context.dmmf.outputTypeMap.prisma["Query"].fields.find((f) => f.name === outputFieldName) ?? context.dmmf.outputTypeMap.prisma["Mutation"].fields.find((f) => f.name === outputFieldName);
|
|
4971
|
+
if (!outputField) {
|
|
4972
|
+
throw new Error(`Can't find output field ${outputFieldName} in the schema`);
|
|
4973
|
+
}
|
|
4974
|
+
const validators = [];
|
|
4975
|
+
for (const args of outputField.args) {
|
|
4976
|
+
if (args.requiresOtherFields === void 0) {
|
|
4977
|
+
continue;
|
|
4978
|
+
}
|
|
4979
|
+
const objectType11 = ts13.objectType();
|
|
4980
|
+
for (const reqArg of args.requiresOtherFields) {
|
|
4981
|
+
objectType11.add(ts13.property(reqArg, ts13.objectType()));
|
|
4982
|
+
}
|
|
4983
|
+
validators.push(
|
|
4984
|
+
ts13.genericParameter(`${(0, import_client_common16.capitalize)(args.name)}DependenciesValidator`).extends(
|
|
4985
|
+
ts13.conditionalType().check(ts13.stringLiteral(args.name)).extends(ts13.namedType("Prisma.Keys<T>")).then(objectType11).else(ts13.objectType())
|
|
4986
|
+
)
|
|
4987
|
+
);
|
|
4988
|
+
}
|
|
4989
|
+
return validators;
|
|
4990
|
+
}
|
|
4956
4991
|
function getReturnType({
|
|
4957
4992
|
modelName,
|
|
4958
4993
|
actionName,
|
|
@@ -5535,20 +5570,20 @@ export type ${this.type.name}<$PrismaModel> = FieldRefInputType<$PrismaModel, ${
|
|
|
5535
5570
|
};
|
|
5536
5571
|
|
|
5537
5572
|
// src/TSClient/globalOmit.ts
|
|
5538
|
-
var
|
|
5573
|
+
var import_client_common17 = require("@prisma/client-common");
|
|
5539
5574
|
var ts15 = __toESM(require("@prisma/ts-builders"));
|
|
5540
5575
|
function globalOmitConfig(dmmf) {
|
|
5541
5576
|
const objectType11 = ts15.objectType().addMultiple(
|
|
5542
5577
|
dmmf.datamodel.models.map((model) => {
|
|
5543
5578
|
const type = ts15.namedType(`Prisma.${getOmitName(model.name)}`);
|
|
5544
|
-
return ts15.property((0,
|
|
5579
|
+
return ts15.property((0, import_client_common17.uncapitalize)(model.name), type).optional();
|
|
5545
5580
|
})
|
|
5546
5581
|
);
|
|
5547
5582
|
return ts15.moduleExport(ts15.typeDeclaration("GlobalOmitConfig", objectType11));
|
|
5548
5583
|
}
|
|
5549
5584
|
|
|
5550
5585
|
// src/TSClient/TypeMap.ts
|
|
5551
|
-
var
|
|
5586
|
+
var import_client_common18 = require("@prisma/client-common");
|
|
5552
5587
|
var import_internals7 = require("@prisma/internals");
|
|
5553
5588
|
var ts16 = __toESM(require("@prisma/ts-builders"));
|
|
5554
5589
|
function clientTypeMapDefinition(context) {
|
|
@@ -5566,7 +5601,7 @@ function clientTypeMapModelsDefinition(context) {
|
|
|
5566
5601
|
if (modelNames.length === 0) {
|
|
5567
5602
|
meta.add(ts16.property("modelProps", ts16.neverType));
|
|
5568
5603
|
} else {
|
|
5569
|
-
meta.add(ts16.property("modelProps", ts16.unionType(modelNames.map((name) => ts16.stringLiteral((0,
|
|
5604
|
+
meta.add(ts16.property("modelProps", ts16.unionType(modelNames.map((name) => ts16.stringLiteral((0, import_client_common18.uncapitalize)(name))))));
|
|
5570
5605
|
}
|
|
5571
5606
|
const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ? ts16.namedType("TransactionIsolationLevel") : ts16.neverType;
|
|
5572
5607
|
meta.add(ts16.property("txIsolationLevel", isolationLevel));
|
|
@@ -5658,13 +5693,13 @@ function payloadToResult(modelName) {
|
|
|
5658
5693
|
// src/TSClient/file-generators/PrismaNamespaceFile.ts
|
|
5659
5694
|
var jsDocHeader6 = `/**
|
|
5660
5695
|
* WARNING: This is an internal file that is subject to change!
|
|
5661
|
-
*
|
|
5696
|
+
*
|
|
5662
5697
|
* \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
|
|
5663
|
-
*
|
|
5698
|
+
*
|
|
5664
5699
|
* All exports from this file are wrapped under a \`Prisma\` namespace object in the client.ts file.
|
|
5665
5700
|
* While this enables partial backward compatibility, it is not part of the stable public API.
|
|
5666
|
-
*
|
|
5667
|
-
* If you are looking for your Models, Enums, and Input Types, please import them from the respective
|
|
5701
|
+
*
|
|
5702
|
+
* If you are looking for your Models, Enums, and Input Types, please import them from the respective
|
|
5668
5703
|
* model files in the \`model\` directory!
|
|
5669
5704
|
*/
|
|
5670
5705
|
`;
|
|
@@ -5700,7 +5735,7 @@ ${prismaEnums?.join("\n\n")}
|
|
|
5700
5735
|
|
|
5701
5736
|
${fieldRefs.length > 0 ? `
|
|
5702
5737
|
/**
|
|
5703
|
-
* Field references
|
|
5738
|
+
* Field references
|
|
5704
5739
|
*/
|
|
5705
5740
|
|
|
5706
5741
|
${fieldRefs.join("\n\n")}` : ""}
|
|
@@ -5726,10 +5761,15 @@ export type LogDefinition = {
|
|
|
5726
5761
|
emit: 'stdout' | 'event'
|
|
5727
5762
|
}
|
|
5728
5763
|
|
|
5729
|
-
export type
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
:
|
|
5764
|
+
export type CheckIsLogLevel<T> = T extends LogLevel ? T : never;
|
|
5765
|
+
|
|
5766
|
+
export type GetLogType<T> = CheckIsLogLevel<
|
|
5767
|
+
T extends LogDefinition ? T['level'] : T
|
|
5768
|
+
>;
|
|
5769
|
+
|
|
5770
|
+
export type GetEvents<T extends any[]> = T extends Array<LogLevel | LogDefinition>
|
|
5771
|
+
? GetLogType<T[number]>
|
|
5772
|
+
: never;
|
|
5733
5773
|
|
|
5734
5774
|
export type QueryEvent = {
|
|
5735
5775
|
timestamp: Date
|
|
@@ -5767,7 +5807,7 @@ export type PrismaAction =
|
|
|
5767
5807
|
| 'aggregate'
|
|
5768
5808
|
| 'count'
|
|
5769
5809
|
| 'runCommandRaw'
|
|
5770
|
-
| 'findRaw'
|
|
5810
|
+
| 'findRaw'
|
|
5771
5811
|
| 'groupBy'
|
|
5772
5812
|
|
|
5773
5813
|
/**
|
|
@@ -5817,16 +5857,24 @@ function buildClientOptions(context, options) {
|
|
|
5817
5857
|
ts17.property("log", ts17.array(ts17.unionType([ts17.namedType("LogLevel"), ts17.namedType("LogDefinition")]))).optional().setDocComment(ts17.docComment`
|
|
5818
5858
|
@example
|
|
5819
5859
|
\`\`\`
|
|
5820
|
-
//
|
|
5860
|
+
// Shorthand for \`emit: 'stdout'\`
|
|
5821
5861
|
log: ['query', 'info', 'warn', 'error']
|
|
5822
5862
|
|
|
5823
|
-
// Emit as events
|
|
5863
|
+
// Emit as events only
|
|
5824
5864
|
log: [
|
|
5825
|
-
{ emit: '
|
|
5826
|
-
{ emit: '
|
|
5827
|
-
{ emit: '
|
|
5828
|
-
{ emit: '
|
|
5865
|
+
{ emit: 'event', level: 'query' },
|
|
5866
|
+
{ emit: 'event', level: 'info' },
|
|
5867
|
+
{ emit: 'event', level: 'warn' }
|
|
5868
|
+
{ emit: 'event', level: 'error' }
|
|
5829
5869
|
]
|
|
5870
|
+
|
|
5871
|
+
// Emit as events and log to stdout
|
|
5872
|
+
log: [
|
|
5873
|
+
{ emit: 'stdout', level: 'query' },
|
|
5874
|
+
{ emit: 'stdout', level: 'info' },
|
|
5875
|
+
{ emit: 'stdout', level: 'warn' }
|
|
5876
|
+
{ emit: 'stdout', level: 'error' }
|
|
5877
|
+
]
|
|
5830
5878
|
\`\`\`
|
|
5831
5879
|
Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/logging#the-log-option).
|
|
5832
5880
|
`)
|
|
@@ -6539,7 +6587,7 @@ var import_get_tsconfig = require("get-tsconfig");
|
|
|
6539
6587
|
var import_ts_pattern2 = require("ts-pattern");
|
|
6540
6588
|
|
|
6541
6589
|
// package.json
|
|
6542
|
-
var version = "6.13.0-dev.
|
|
6590
|
+
var version = "6.13.0-dev.31";
|
|
6543
6591
|
|
|
6544
6592
|
// src/module-format.ts
|
|
6545
6593
|
function parseModuleFormat(format) {
|
package/dist/index.mjs
CHANGED
|
@@ -2400,6 +2400,7 @@ import * as ts2 from "@prisma/ts-builders";
|
|
|
2400
2400
|
import indent2 from "indent-string";
|
|
2401
2401
|
|
|
2402
2402
|
// src/utils.ts
|
|
2403
|
+
import { capitalize as capitalize3 } from "@prisma/client-common";
|
|
2403
2404
|
import * as DMMF from "@prisma/dmmf";
|
|
2404
2405
|
import { assertNever } from "@prisma/internals";
|
|
2405
2406
|
import * as ts from "@prisma/ts-builders";
|
|
@@ -2537,9 +2538,6 @@ function getPayloadName(modelName, namespace2 = true) {
|
|
|
2537
2538
|
function getFieldRefsTypeName(name) {
|
|
2538
2539
|
return `${name}FieldRefs`;
|
|
2539
2540
|
}
|
|
2540
|
-
function capitalize3(str) {
|
|
2541
|
-
return str[0].toUpperCase() + str.slice(1);
|
|
2542
|
-
}
|
|
2543
2541
|
function getRefAllowedTypeName(type) {
|
|
2544
2542
|
let typeName = type.type;
|
|
2545
2543
|
if (type.isList) {
|
|
@@ -3542,7 +3540,7 @@ function buildWasmFileMap({ runtimeName, activeProvider }) {
|
|
|
3542
3540
|
}
|
|
3543
3541
|
|
|
3544
3542
|
// src/TSClient/PrismaClient.ts
|
|
3545
|
-
import { uncapitalize as uncapitalize4 } from "@prisma/client-common";
|
|
3543
|
+
import { capitalize as capitalize7, uncapitalize as uncapitalize4 } from "@prisma/client-common";
|
|
3546
3544
|
import * as ts4 from "@prisma/ts-builders";
|
|
3547
3545
|
import indent3 from "indent-string";
|
|
3548
3546
|
|
|
@@ -3755,7 +3753,7 @@ function getPrismaClientClassDocComment({ dmmf }) {
|
|
|
3755
3753
|
@example
|
|
3756
3754
|
\`\`\`
|
|
3757
3755
|
const prisma = new PrismaClient()
|
|
3758
|
-
// Fetch zero or more ${
|
|
3756
|
+
// Fetch zero or more ${capitalize7(example.plural)}
|
|
3759
3757
|
const ${uncapitalize4(example.plural)} = await prisma.${uncapitalize4(example.model)}.findMany()
|
|
3760
3758
|
\`\`\`
|
|
3761
3759
|
|
|
@@ -3779,7 +3777,7 @@ export interface PrismaClientConstructor {
|
|
|
3779
3777
|
${indent3(this.jsDoc, TAB_SIZE)}
|
|
3780
3778
|
new <
|
|
3781
3779
|
ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
|
|
3782
|
-
U = LogOptions<ClientOptions>,
|
|
3780
|
+
const U = LogOptions<ClientOptions>,
|
|
3783
3781
|
ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
|
|
3784
3782
|
>(options?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>): PrismaClient<ClientOptions, U, ExtArgs>
|
|
3785
3783
|
}
|
|
@@ -3834,7 +3832,7 @@ ${[
|
|
|
3834
3832
|
* \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
|
|
3835
3833
|
* Example usage:
|
|
3836
3834
|
* \`\`\`ts
|
|
3837
|
-
* // Fetch zero or more ${
|
|
3835
|
+
* // Fetch zero or more ${capitalize7(m.plural)}
|
|
3838
3836
|
* const ${uncapitalize4(m.plural)} = await prisma.${methodName}.findMany()
|
|
3839
3837
|
* \`\`\`
|
|
3840
3838
|
*/
|
|
@@ -4113,6 +4111,7 @@ export {}
|
|
|
4113
4111
|
import * as ts14 from "@prisma/ts-builders";
|
|
4114
4112
|
|
|
4115
4113
|
// src/TSClient/Model.ts
|
|
4114
|
+
import { capitalize as capitalize9 } from "@prisma/client-common";
|
|
4116
4115
|
import * as DMMF2 from "@prisma/dmmf";
|
|
4117
4116
|
import * as ts13 from "@prisma/ts-builders";
|
|
4118
4117
|
import indent5 from "indent-string";
|
|
@@ -4198,6 +4197,7 @@ var ArgsTypeBuilder = class {
|
|
|
4198
4197
|
};
|
|
4199
4198
|
|
|
4200
4199
|
// src/TSClient/Count.ts
|
|
4200
|
+
import { capitalize as capitalize8 } from "@prisma/client-common";
|
|
4201
4201
|
import * as ts10 from "@prisma/ts-builders";
|
|
4202
4202
|
import indent4 from "indent-string";
|
|
4203
4203
|
|
|
@@ -4316,7 +4316,7 @@ ${this.argsTypes.map((typeExport) => ts10.stringify(typeExport)).join("\n\n")}
|
|
|
4316
4316
|
}
|
|
4317
4317
|
};
|
|
4318
4318
|
function getCountArgsType(typeName, fieldName) {
|
|
4319
|
-
return `${typeName}Count${
|
|
4319
|
+
return `${typeName}Count${capitalize8(fieldName)}Args`;
|
|
4320
4320
|
}
|
|
4321
4321
|
|
|
4322
4322
|
// src/TSClient/ModelFieldRefs.ts
|
|
@@ -4578,7 +4578,7 @@ type ${getGroupByPayloadName(model.name)}<T extends ${groupByArgsName}> = Prisma
|
|
|
4578
4578
|
: Prisma.GetScalarType<T[P], ${groupByType.name}[P]>
|
|
4579
4579
|
}
|
|
4580
4580
|
>
|
|
4581
|
-
>
|
|
4581
|
+
>
|
|
4582
4582
|
`;
|
|
4583
4583
|
}
|
|
4584
4584
|
getAggregationTypes() {
|
|
@@ -4914,15 +4914,24 @@ ${ts13.stringify(buildFluentWrapperDefinition(name, this.outputType, this.contex
|
|
|
4914
4914
|
function buildModelDelegateMethod(modelName, actionName, context) {
|
|
4915
4915
|
const mapping = context.dmmf.mappingsMap[modelName] ?? { model: modelName, plural: `${modelName}s` };
|
|
4916
4916
|
const modelOrType = context.dmmf.typeAndModelMap[modelName];
|
|
4917
|
-
const
|
|
4917
|
+
const dependencyValidators = getNonAggregateMethodDependencyValidations(mapping, actionName, context);
|
|
4918
|
+
const method3 = ts13.method(actionName).setDocComment(ts13.docComment(getMethodJSDocBody(actionName, mapping, modelOrType))).addParameter(getNonAggregateMethodArgs(modelName, actionName, dependencyValidators)).setReturnType(getReturnType({ modelName, actionName }));
|
|
4918
4919
|
const generic = getNonAggregateMethodGenericParam(modelName, actionName);
|
|
4919
4920
|
if (generic) {
|
|
4920
4921
|
method3.addGenericParameter(generic);
|
|
4921
4922
|
}
|
|
4923
|
+
for (const validator of dependencyValidators) {
|
|
4924
|
+
method3.addGenericParameter(validator);
|
|
4925
|
+
}
|
|
4922
4926
|
return method3;
|
|
4923
4927
|
}
|
|
4924
|
-
function getNonAggregateMethodArgs(modelName, actionName) {
|
|
4925
|
-
const makeParameter = (type2) =>
|
|
4928
|
+
function getNonAggregateMethodArgs(modelName, actionName, dependencyValidators) {
|
|
4929
|
+
const makeParameter = (type2) => {
|
|
4930
|
+
if (dependencyValidators.length > 0) {
|
|
4931
|
+
type2 = ts13.intersectionType([type2, ...dependencyValidators.map((validator) => ts13.namedType(validator.name))]);
|
|
4932
|
+
}
|
|
4933
|
+
return ts13.parameter("args", type2);
|
|
4934
|
+
};
|
|
4926
4935
|
if (actionName === DMMF2.ModelAction.count) {
|
|
4927
4936
|
const type2 = omit(
|
|
4928
4937
|
ts13.namedType(getModelArgName(modelName, DMMF2.ModelAction.findMany)),
|
|
@@ -4952,6 +4961,32 @@ function getNonAggregateMethodGenericParam(modelName, actionName) {
|
|
|
4952
4961
|
}
|
|
4953
4962
|
return arg.extends(ts13.namedType(getModelArgName(modelName, actionName)));
|
|
4954
4963
|
}
|
|
4964
|
+
function getNonAggregateMethodDependencyValidations(modelMapping, actionName, context) {
|
|
4965
|
+
const outputFieldName = modelMapping[actionName];
|
|
4966
|
+
if (!outputFieldName) {
|
|
4967
|
+
throw new Error(`Missing mapping for ${modelMapping.model}.${actionName}`);
|
|
4968
|
+
}
|
|
4969
|
+
const outputField = context.dmmf.outputTypeMap.prisma["Query"].fields.find((f) => f.name === outputFieldName) ?? context.dmmf.outputTypeMap.prisma["Mutation"].fields.find((f) => f.name === outputFieldName);
|
|
4970
|
+
if (!outputField) {
|
|
4971
|
+
throw new Error(`Can't find output field ${outputFieldName} in the schema`);
|
|
4972
|
+
}
|
|
4973
|
+
const validators = [];
|
|
4974
|
+
for (const args of outputField.args) {
|
|
4975
|
+
if (args.requiresOtherFields === void 0) {
|
|
4976
|
+
continue;
|
|
4977
|
+
}
|
|
4978
|
+
const objectType11 = ts13.objectType();
|
|
4979
|
+
for (const reqArg of args.requiresOtherFields) {
|
|
4980
|
+
objectType11.add(ts13.property(reqArg, ts13.objectType()));
|
|
4981
|
+
}
|
|
4982
|
+
validators.push(
|
|
4983
|
+
ts13.genericParameter(`${capitalize9(args.name)}DependenciesValidator`).extends(
|
|
4984
|
+
ts13.conditionalType().check(ts13.stringLiteral(args.name)).extends(ts13.namedType("Prisma.Keys<T>")).then(objectType11).else(ts13.objectType())
|
|
4985
|
+
)
|
|
4986
|
+
);
|
|
4987
|
+
}
|
|
4988
|
+
return validators;
|
|
4989
|
+
}
|
|
4955
4990
|
function getReturnType({
|
|
4956
4991
|
modelName,
|
|
4957
4992
|
actionName,
|
|
@@ -5657,13 +5692,13 @@ function payloadToResult(modelName) {
|
|
|
5657
5692
|
// src/TSClient/file-generators/PrismaNamespaceFile.ts
|
|
5658
5693
|
var jsDocHeader6 = `/**
|
|
5659
5694
|
* WARNING: This is an internal file that is subject to change!
|
|
5660
|
-
*
|
|
5695
|
+
*
|
|
5661
5696
|
* \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
|
|
5662
|
-
*
|
|
5697
|
+
*
|
|
5663
5698
|
* All exports from this file are wrapped under a \`Prisma\` namespace object in the client.ts file.
|
|
5664
5699
|
* While this enables partial backward compatibility, it is not part of the stable public API.
|
|
5665
|
-
*
|
|
5666
|
-
* If you are looking for your Models, Enums, and Input Types, please import them from the respective
|
|
5700
|
+
*
|
|
5701
|
+
* If you are looking for your Models, Enums, and Input Types, please import them from the respective
|
|
5667
5702
|
* model files in the \`model\` directory!
|
|
5668
5703
|
*/
|
|
5669
5704
|
`;
|
|
@@ -5699,7 +5734,7 @@ ${prismaEnums?.join("\n\n")}
|
|
|
5699
5734
|
|
|
5700
5735
|
${fieldRefs.length > 0 ? `
|
|
5701
5736
|
/**
|
|
5702
|
-
* Field references
|
|
5737
|
+
* Field references
|
|
5703
5738
|
*/
|
|
5704
5739
|
|
|
5705
5740
|
${fieldRefs.join("\n\n")}` : ""}
|
|
@@ -5725,10 +5760,15 @@ export type LogDefinition = {
|
|
|
5725
5760
|
emit: 'stdout' | 'event'
|
|
5726
5761
|
}
|
|
5727
5762
|
|
|
5728
|
-
export type
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
:
|
|
5763
|
+
export type CheckIsLogLevel<T> = T extends LogLevel ? T : never;
|
|
5764
|
+
|
|
5765
|
+
export type GetLogType<T> = CheckIsLogLevel<
|
|
5766
|
+
T extends LogDefinition ? T['level'] : T
|
|
5767
|
+
>;
|
|
5768
|
+
|
|
5769
|
+
export type GetEvents<T extends any[]> = T extends Array<LogLevel | LogDefinition>
|
|
5770
|
+
? GetLogType<T[number]>
|
|
5771
|
+
: never;
|
|
5732
5772
|
|
|
5733
5773
|
export type QueryEvent = {
|
|
5734
5774
|
timestamp: Date
|
|
@@ -5766,7 +5806,7 @@ export type PrismaAction =
|
|
|
5766
5806
|
| 'aggregate'
|
|
5767
5807
|
| 'count'
|
|
5768
5808
|
| 'runCommandRaw'
|
|
5769
|
-
| 'findRaw'
|
|
5809
|
+
| 'findRaw'
|
|
5770
5810
|
| 'groupBy'
|
|
5771
5811
|
|
|
5772
5812
|
/**
|
|
@@ -5816,16 +5856,24 @@ function buildClientOptions(context, options) {
|
|
|
5816
5856
|
ts17.property("log", ts17.array(ts17.unionType([ts17.namedType("LogLevel"), ts17.namedType("LogDefinition")]))).optional().setDocComment(ts17.docComment`
|
|
5817
5857
|
@example
|
|
5818
5858
|
\`\`\`
|
|
5819
|
-
//
|
|
5859
|
+
// Shorthand for \`emit: 'stdout'\`
|
|
5820
5860
|
log: ['query', 'info', 'warn', 'error']
|
|
5821
5861
|
|
|
5822
|
-
// Emit as events
|
|
5862
|
+
// Emit as events only
|
|
5823
5863
|
log: [
|
|
5824
|
-
{ emit: '
|
|
5825
|
-
{ emit: '
|
|
5826
|
-
{ emit: '
|
|
5827
|
-
{ emit: '
|
|
5864
|
+
{ emit: 'event', level: 'query' },
|
|
5865
|
+
{ emit: 'event', level: 'info' },
|
|
5866
|
+
{ emit: 'event', level: 'warn' }
|
|
5867
|
+
{ emit: 'event', level: 'error' }
|
|
5828
5868
|
]
|
|
5869
|
+
|
|
5870
|
+
// Emit as events and log to stdout
|
|
5871
|
+
log: [
|
|
5872
|
+
{ emit: 'stdout', level: 'query' },
|
|
5873
|
+
{ emit: 'stdout', level: 'info' },
|
|
5874
|
+
{ emit: 'stdout', level: 'warn' }
|
|
5875
|
+
{ emit: 'stdout', level: 'error' }
|
|
5876
|
+
]
|
|
5829
5877
|
\`\`\`
|
|
5830
5878
|
Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/logging#the-log-option).
|
|
5831
5879
|
`)
|
|
@@ -6538,7 +6586,7 @@ import { getTsconfig } from "get-tsconfig";
|
|
|
6538
6586
|
import { match as match2 } from "ts-pattern";
|
|
6539
6587
|
|
|
6540
6588
|
// package.json
|
|
6541
|
-
var version = "6.13.0-dev.
|
|
6589
|
+
var version = "6.13.0-dev.31";
|
|
6542
6590
|
|
|
6543
6591
|
// src/module-format.ts
|
|
6544
6592
|
function parseModuleFormat(format) {
|
package/dist/utils.d.ts
CHANGED
|
@@ -31,7 +31,6 @@ export declare function getModelArgName(modelName: string, action?: DMMF.ModelAc
|
|
|
31
31
|
export declare function getPayloadName(modelName: string, namespace?: boolean): string;
|
|
32
32
|
export declare function getFieldRefsTypeName(name: string): string;
|
|
33
33
|
export declare function getType(name: string, isList: boolean, isOptional?: boolean): string;
|
|
34
|
-
export declare function capitalize(str: string): string;
|
|
35
34
|
export declare function getRefAllowedTypeName(type: DMMF.OutputTypeRef): string;
|
|
36
35
|
export declare function appendSkipType(context: GenerateContext, type: ts.TypeBuilder): ts.TypeBuilder;
|
|
37
36
|
export declare const extArgsParam: ts.GenericParameter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-generator-ts",
|
|
3
|
-
"version": "6.13.0-dev.
|
|
3
|
+
"version": "6.13.0-dev.31",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@antfu/ni": "0.21.12",
|
|
28
|
-
"@prisma/engines-version": "6.
|
|
28
|
+
"@prisma/engines-version": "6.13.0-35.361e86d0ea4987e9f53a565309b3eed797a6bcbd",
|
|
29
29
|
"ci-info": "4.2.0",
|
|
30
30
|
"fast-glob": "3.3.3",
|
|
31
31
|
"get-tsconfig": "4.10.0",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"pkg-up": "3.1.0",
|
|
35
35
|
"pluralize": "8.0.0",
|
|
36
36
|
"ts-pattern": "5.6.2",
|
|
37
|
-
"@prisma/client-common": "6.13.0-dev.
|
|
38
|
-
"@prisma/
|
|
39
|
-
"@prisma/
|
|
40
|
-
"@prisma/
|
|
41
|
-
"@prisma/get-platform": "6.13.0-dev.
|
|
42
|
-
"@prisma/generator": "6.13.0-dev.
|
|
43
|
-
"@prisma/internals": "6.13.0-dev.
|
|
44
|
-
"@prisma/ts-builders": "6.13.0-dev.
|
|
37
|
+
"@prisma/client-common": "6.13.0-dev.31",
|
|
38
|
+
"@prisma/debug": "6.13.0-dev.31",
|
|
39
|
+
"@prisma/fetch-engine": "6.13.0-dev.31",
|
|
40
|
+
"@prisma/dmmf": "6.13.0-dev.31",
|
|
41
|
+
"@prisma/get-platform": "6.13.0-dev.31",
|
|
42
|
+
"@prisma/generator": "6.13.0-dev.31",
|
|
43
|
+
"@prisma/internals": "6.13.0-dev.31",
|
|
44
|
+
"@prisma/ts-builders": "6.13.0-dev.31"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/pluralize": "0.0.33",
|