@prisma/client-generator-ts 7.7.0-dev.1 → 7.7.0-dev.2
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/getDMMF.d.ts +1 -4
- package/dist/index.d.mts +3 -9
- package/dist/index.d.ts +3 -9
- package/dist/index.js +78 -132
- package/dist/index.mjs +59 -112
- package/package.json +10 -10
- package/dist/externalToInternalDmmf.d.ts +0 -7
package/dist/getDMMF.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { GetDMMFOptions } from '@prisma/internals';
|
|
3
|
-
export declare function getPrismaClientDMMF(dmmf: DMMF.Document): DMMF.Document;
|
|
4
|
-
export declare function getDMMF(options: GetDMMFOptions): Promise<DMMF.Document>;
|
|
1
|
+
export { getInternalDMMF as getDMMF, externalToInternalDmmf as getPrismaClientDMMF } from '@prisma/internals';
|
package/dist/index.d.mts
CHANGED
|
@@ -3,24 +3,18 @@
|
|
|
3
3
|
import type { ActiveConnectorType } from '@prisma/generator';
|
|
4
4
|
import type { BinaryPaths } from '@prisma/generator';
|
|
5
5
|
import type { DataSource } from '@prisma/generator';
|
|
6
|
-
import * as DMMF from '@prisma/dmmf';
|
|
6
|
+
import type * as DMMF from '@prisma/dmmf';
|
|
7
7
|
import { Generator as Generator_2 } from '@prisma/generator';
|
|
8
8
|
import { GeneratorConfig } from '@prisma/generator';
|
|
9
9
|
import { GeneratorManifest } from '@prisma/generator';
|
|
10
10
|
import { GeneratorOptions } from '@prisma/generator';
|
|
11
|
-
import
|
|
11
|
+
import { getInternalDMMF as getDMMF } from '@prisma/internals';
|
|
12
12
|
import type { SqlQueryOutput } from '@prisma/generator';
|
|
13
13
|
|
|
14
14
|
declare const expectedGeneratedFileExtensions: readonly ["ts", "mts", "cts"];
|
|
15
15
|
|
|
16
16
|
declare const expectedImportFileExtensions: readonly ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Turns type: string into type: string[] for all args in order to support union input types
|
|
20
|
-
* @param document
|
|
21
|
-
*/
|
|
22
|
-
export declare function externalToInternalDmmf(document: DMMF.Document): DMMF.Document;
|
|
23
|
-
|
|
24
18
|
export declare function generateClient(options: GenerateClientOptions): Promise<void>;
|
|
25
19
|
|
|
26
20
|
export declare interface GenerateClientOptions {
|
|
@@ -48,7 +42,7 @@ export declare interface GenerateClientOptions {
|
|
|
48
42
|
|
|
49
43
|
declare type GeneratedFileExtension = (typeof expectedGeneratedFileExtensions)[number] | (string & {});
|
|
50
44
|
|
|
51
|
-
export
|
|
45
|
+
export { getDMMF }
|
|
52
46
|
|
|
53
47
|
declare type ImportFileExtension = (typeof expectedImportFileExtensions)[number] | (string & {});
|
|
54
48
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,24 +3,18 @@
|
|
|
3
3
|
import type { ActiveConnectorType } from '@prisma/generator';
|
|
4
4
|
import type { BinaryPaths } from '@prisma/generator';
|
|
5
5
|
import type { DataSource } from '@prisma/generator';
|
|
6
|
-
import * as DMMF from '@prisma/dmmf';
|
|
6
|
+
import type * as DMMF from '@prisma/dmmf';
|
|
7
7
|
import { Generator as Generator_2 } from '@prisma/generator';
|
|
8
8
|
import { GeneratorConfig } from '@prisma/generator';
|
|
9
9
|
import { GeneratorManifest } from '@prisma/generator';
|
|
10
10
|
import { GeneratorOptions } from '@prisma/generator';
|
|
11
|
-
import
|
|
11
|
+
import { getInternalDMMF as getDMMF } from '@prisma/internals';
|
|
12
12
|
import type { SqlQueryOutput } from '@prisma/generator';
|
|
13
13
|
|
|
14
14
|
declare const expectedGeneratedFileExtensions: readonly ["ts", "mts", "cts"];
|
|
15
15
|
|
|
16
16
|
declare const expectedImportFileExtensions: readonly ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Turns type: string into type: string[] for all args in order to support union input types
|
|
20
|
-
* @param document
|
|
21
|
-
*/
|
|
22
|
-
export declare function externalToInternalDmmf(document: DMMF.Document): DMMF.Document;
|
|
23
|
-
|
|
24
18
|
export declare function generateClient(options: GenerateClientOptions): Promise<void>;
|
|
25
19
|
|
|
26
20
|
export declare interface GenerateClientOptions {
|
|
@@ -48,7 +42,7 @@ export declare interface GenerateClientOptions {
|
|
|
48
42
|
|
|
49
43
|
declare type GeneratedFileExtension = (typeof expectedGeneratedFileExtensions)[number] | (string & {});
|
|
50
44
|
|
|
51
|
-
export
|
|
45
|
+
export { getDMMF }
|
|
52
46
|
|
|
53
47
|
declare type ImportFileExtension = (typeof expectedImportFileExtensions)[number] | (string & {});
|
|
54
48
|
|
package/dist/index.js
CHANGED
|
@@ -2170,57 +2170,11 @@ var require_lib = __commonJS({
|
|
|
2170
2170
|
var index_exports = {};
|
|
2171
2171
|
__export(index_exports, {
|
|
2172
2172
|
PrismaClientTsGenerator: () => PrismaClientTsGenerator,
|
|
2173
|
-
externalToInternalDmmf: () => externalToInternalDmmf,
|
|
2174
2173
|
generateClient: () => generateClient,
|
|
2175
|
-
getDMMF: () =>
|
|
2174
|
+
getDMMF: () => import_internals.getInternalDMMF
|
|
2176
2175
|
});
|
|
2177
2176
|
module.exports = __toCommonJS(index_exports);
|
|
2178
2177
|
|
|
2179
|
-
// src/externalToInternalDmmf.ts
|
|
2180
|
-
var import_client_common = require("@prisma/client-common");
|
|
2181
|
-
var import_pluralize = __toESM(require("pluralize"));
|
|
2182
|
-
function externalToInternalDmmf(document) {
|
|
2183
|
-
return {
|
|
2184
|
-
...document,
|
|
2185
|
-
mappings: getMappings(document.mappings, document.datamodel)
|
|
2186
|
-
};
|
|
2187
|
-
}
|
|
2188
|
-
function getMappings(mappings, datamodel) {
|
|
2189
|
-
const modelOperations = mappings.modelOperations.filter((mapping) => {
|
|
2190
|
-
const model = datamodel.models.find((m) => m.name === mapping.model);
|
|
2191
|
-
if (!model) {
|
|
2192
|
-
throw new Error(`Mapping without model ${mapping.model}`);
|
|
2193
|
-
}
|
|
2194
|
-
return model.fields.some((f) => f.kind !== "object");
|
|
2195
|
-
}).map((mapping) => ({
|
|
2196
|
-
model: mapping.model,
|
|
2197
|
-
plural: (0, import_pluralize.default)((0, import_client_common.uncapitalize)(mapping.model)),
|
|
2198
|
-
// TODO not needed anymore
|
|
2199
|
-
findUnique: mapping.findUnique || mapping.findSingle,
|
|
2200
|
-
findUniqueOrThrow: mapping.findUniqueOrThrow,
|
|
2201
|
-
findFirst: mapping.findFirst,
|
|
2202
|
-
findFirstOrThrow: mapping.findFirstOrThrow,
|
|
2203
|
-
findMany: mapping.findMany,
|
|
2204
|
-
create: mapping.createOne || mapping.createSingle || mapping.create,
|
|
2205
|
-
createMany: mapping.createMany,
|
|
2206
|
-
createManyAndReturn: mapping.createManyAndReturn,
|
|
2207
|
-
delete: mapping.deleteOne || mapping.deleteSingle || mapping.delete,
|
|
2208
|
-
update: mapping.updateOne || mapping.updateSingle || mapping.update,
|
|
2209
|
-
deleteMany: mapping.deleteMany,
|
|
2210
|
-
updateMany: mapping.updateMany,
|
|
2211
|
-
updateManyAndReturn: mapping.updateManyAndReturn,
|
|
2212
|
-
upsert: mapping.upsertOne || mapping.upsertSingle || mapping.upsert,
|
|
2213
|
-
aggregate: mapping.aggregate,
|
|
2214
|
-
groupBy: mapping.groupBy,
|
|
2215
|
-
findRaw: mapping.findRaw,
|
|
2216
|
-
aggregateRaw: mapping.aggregateRaw
|
|
2217
|
-
}));
|
|
2218
|
-
return {
|
|
2219
|
-
modelOperations,
|
|
2220
|
-
otherOperations: mappings.otherOperations
|
|
2221
|
-
};
|
|
2222
|
-
}
|
|
2223
|
-
|
|
2224
2178
|
// src/generateClient.ts
|
|
2225
2179
|
var import_promises = __toESM(require("node:fs/promises"));
|
|
2226
2180
|
var import_node_path2 = __toESM(require("node:path"));
|
|
@@ -2280,13 +2234,13 @@ var bgWhite = init(47, 49);
|
|
|
2280
2234
|
var import_package_up = require("package-up");
|
|
2281
2235
|
|
|
2282
2236
|
// src/file-extensions.ts
|
|
2283
|
-
var
|
|
2237
|
+
var import_client_common = require("@prisma/client-common");
|
|
2284
2238
|
var expectedGeneratedFileExtensions = ["ts", "mts", "cts"];
|
|
2285
2239
|
var expectedImportFileExtensions = ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
|
|
2286
2240
|
function validateFileExtension(extension, kind, recommended) {
|
|
2287
2241
|
if (!recommended.includes(extension) && !process.env.PRISMA_DISABLE_WARNINGS) {
|
|
2288
2242
|
console.warn(
|
|
2289
|
-
`${(0,
|
|
2243
|
+
`${(0, import_client_common.capitalize)(kind)} file extension ${JSON.stringify(
|
|
2290
2244
|
extension
|
|
2291
2245
|
)} is unexpected and may be a mistake. Expected one of: ${recommended.map((ext) => JSON.stringify(ext)).join(", ")}`
|
|
2292
2246
|
);
|
|
@@ -2354,16 +2308,9 @@ function matchingJsExtension(generatedFileExtension) {
|
|
|
2354
2308
|
|
|
2355
2309
|
// src/getDMMF.ts
|
|
2356
2310
|
var import_internals = require("@prisma/internals");
|
|
2357
|
-
function getPrismaClientDMMF(dmmf) {
|
|
2358
|
-
return externalToInternalDmmf(dmmf);
|
|
2359
|
-
}
|
|
2360
|
-
async function getDMMF(options) {
|
|
2361
|
-
const dmmf = await (0, import_internals.getDMMF)(options);
|
|
2362
|
-
return getPrismaClientDMMF(dmmf);
|
|
2363
|
-
}
|
|
2364
2311
|
|
|
2365
2312
|
// src/TSClient/Enum.ts
|
|
2366
|
-
var
|
|
2313
|
+
var import_client_common2 = require("@prisma/client-common");
|
|
2367
2314
|
var import_indent_string = __toESM(require("indent-string"));
|
|
2368
2315
|
|
|
2369
2316
|
// src/TSClient/constants.ts
|
|
@@ -2376,10 +2323,10 @@ var Enum = class {
|
|
|
2376
2323
|
this.useNamespace = useNamespace;
|
|
2377
2324
|
}
|
|
2378
2325
|
isObjectEnum() {
|
|
2379
|
-
return this.useNamespace &&
|
|
2326
|
+
return this.useNamespace && import_client_common2.objectEnumNames.includes(this.type.name);
|
|
2380
2327
|
}
|
|
2381
2328
|
isStrictEnum() {
|
|
2382
|
-
return this.useNamespace &&
|
|
2329
|
+
return this.useNamespace && import_client_common2.strictEnumNames.includes(this.type.name);
|
|
2383
2330
|
}
|
|
2384
2331
|
toTS() {
|
|
2385
2332
|
const { type } = this;
|
|
@@ -2398,12 +2345,12 @@ export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}]
|
|
|
2398
2345
|
};
|
|
2399
2346
|
|
|
2400
2347
|
// src/TSClient/Input.ts
|
|
2401
|
-
var
|
|
2348
|
+
var import_client_common4 = require("@prisma/client-common");
|
|
2402
2349
|
var ts2 = __toESM(require("@prisma/ts-builders"));
|
|
2403
2350
|
var import_indent_string2 = __toESM(require("indent-string"));
|
|
2404
2351
|
|
|
2405
2352
|
// src/utils.ts
|
|
2406
|
-
var
|
|
2353
|
+
var import_client_common3 = require("@prisma/client-common");
|
|
2407
2354
|
var DMMF = __toESM(require("@prisma/dmmf"));
|
|
2408
2355
|
var import_internals2 = require("@prisma/internals");
|
|
2409
2356
|
var ts = __toESM(require("@prisma/ts-builders"));
|
|
@@ -2435,31 +2382,31 @@ function getOmitName(modelName) {
|
|
|
2435
2382
|
return `${modelName}Omit`;
|
|
2436
2383
|
}
|
|
2437
2384
|
function getAggregateName(modelName) {
|
|
2438
|
-
return `Aggregate${(0,
|
|
2385
|
+
return `Aggregate${(0, import_client_common3.capitalize)(modelName)}`;
|
|
2439
2386
|
}
|
|
2440
2387
|
function getCountOutputTypeName(modelName) {
|
|
2441
|
-
return `${(0,
|
|
2388
|
+
return `${(0, import_client_common3.capitalize)(modelName)}CountOutputType`;
|
|
2442
2389
|
}
|
|
2443
2390
|
function getGroupByName(modelName) {
|
|
2444
|
-
return `${(0,
|
|
2391
|
+
return `${(0, import_client_common3.capitalize)(modelName)}GroupByOutputType`;
|
|
2445
2392
|
}
|
|
2446
2393
|
function getAvgAggregateName(modelName) {
|
|
2447
|
-
return `${(0,
|
|
2394
|
+
return `${(0, import_client_common3.capitalize)(modelName)}AvgAggregateOutputType`;
|
|
2448
2395
|
}
|
|
2449
2396
|
function getSumAggregateName(modelName) {
|
|
2450
|
-
return `${(0,
|
|
2397
|
+
return `${(0, import_client_common3.capitalize)(modelName)}SumAggregateOutputType`;
|
|
2451
2398
|
}
|
|
2452
2399
|
function getMinAggregateName(modelName) {
|
|
2453
|
-
return `${(0,
|
|
2400
|
+
return `${(0, import_client_common3.capitalize)(modelName)}MinAggregateOutputType`;
|
|
2454
2401
|
}
|
|
2455
2402
|
function getMaxAggregateName(modelName) {
|
|
2456
|
-
return `${(0,
|
|
2403
|
+
return `${(0, import_client_common3.capitalize)(modelName)}MaxAggregateOutputType`;
|
|
2457
2404
|
}
|
|
2458
2405
|
function getCountAggregateInputName(modelName) {
|
|
2459
|
-
return `${(0,
|
|
2406
|
+
return `${(0, import_client_common3.capitalize)(modelName)}CountAggregateInputType`;
|
|
2460
2407
|
}
|
|
2461
2408
|
function getCountAggregateOutputName(modelName) {
|
|
2462
|
-
return `${(0,
|
|
2409
|
+
return `${(0, import_client_common3.capitalize)(modelName)}CountAggregateOutputType`;
|
|
2463
2410
|
}
|
|
2464
2411
|
function getAggregateInputType(aggregateOutputType) {
|
|
2465
2412
|
return aggregateOutputType.replace(/OutputType$/, "InputType");
|
|
@@ -2468,13 +2415,13 @@ function getGroupByArgsName(modelName) {
|
|
|
2468
2415
|
return `${modelName}GroupByArgs`;
|
|
2469
2416
|
}
|
|
2470
2417
|
function getGroupByPayloadName(modelName) {
|
|
2471
|
-
return `Get${(0,
|
|
2418
|
+
return `Get${(0, import_client_common3.capitalize)(modelName)}GroupByPayload`;
|
|
2472
2419
|
}
|
|
2473
2420
|
function getAggregateArgsName(modelName) {
|
|
2474
|
-
return `${(0,
|
|
2421
|
+
return `${(0, import_client_common3.capitalize)(modelName)}AggregateArgs`;
|
|
2475
2422
|
}
|
|
2476
2423
|
function getAggregateGetName(modelName) {
|
|
2477
|
-
return `Get${(0,
|
|
2424
|
+
return `Get${(0, import_client_common3.capitalize)(modelName)}AggregateType`;
|
|
2478
2425
|
}
|
|
2479
2426
|
function getFieldArgName(field, modelName) {
|
|
2480
2427
|
if (field.args.length) {
|
|
@@ -2667,7 +2614,7 @@ var InputType = class {
|
|
|
2667
2614
|
toTS() {
|
|
2668
2615
|
const { type } = this;
|
|
2669
2616
|
const source = type.meta?.source;
|
|
2670
|
-
const fields = (0,
|
|
2617
|
+
const fields = (0, import_client_common4.uniqueBy)(type.fields, (f) => f.name);
|
|
2671
2618
|
const body = `{
|
|
2672
2619
|
${(0, import_indent_string2.default)(
|
|
2673
2620
|
fields.map((arg) => {
|
|
@@ -2705,7 +2652,7 @@ function wrapWithAtLeast(body, input) {
|
|
|
2705
2652
|
}
|
|
2706
2653
|
|
|
2707
2654
|
// src/dmmf.ts
|
|
2708
|
-
var
|
|
2655
|
+
var import_client_common5 = require("@prisma/client-common");
|
|
2709
2656
|
var DMMFHelper = class {
|
|
2710
2657
|
constructor(document) {
|
|
2711
2658
|
this.document = document;
|
|
@@ -2771,33 +2718,33 @@ var DMMFHelper = class {
|
|
|
2771
2718
|
return this.outputObjectTypes[ref.namespace ?? "prisma"].find((outputObject) => outputObject.name === ref.type);
|
|
2772
2719
|
}
|
|
2773
2720
|
buildModelMap() {
|
|
2774
|
-
return (0,
|
|
2721
|
+
return (0, import_client_common5.keyBy)(this.datamodel.models, "name");
|
|
2775
2722
|
}
|
|
2776
2723
|
buildTypeMap() {
|
|
2777
|
-
return (0,
|
|
2724
|
+
return (0, import_client_common5.keyBy)(this.datamodel.types, "name");
|
|
2778
2725
|
}
|
|
2779
2726
|
buildTypeModelMap() {
|
|
2780
2727
|
return { ...this.buildTypeMap(), ...this.buildModelMap() };
|
|
2781
2728
|
}
|
|
2782
2729
|
buildMappingsMap() {
|
|
2783
|
-
return (0,
|
|
2730
|
+
return (0, import_client_common5.keyBy)(this.mappings.modelOperations, "model");
|
|
2784
2731
|
}
|
|
2785
2732
|
buildMergedOutputTypeMap() {
|
|
2786
2733
|
if (!this.schema.outputObjectTypes.prisma) {
|
|
2787
2734
|
return {
|
|
2788
|
-
model: (0,
|
|
2789
|
-
prisma: (0,
|
|
2735
|
+
model: (0, import_client_common5.keyBy)(this.schema.outputObjectTypes.model, "name"),
|
|
2736
|
+
prisma: (0, import_client_common5.keyBy)([], "name")
|
|
2790
2737
|
};
|
|
2791
2738
|
}
|
|
2792
2739
|
return {
|
|
2793
|
-
model: (0,
|
|
2794
|
-
prisma: (0,
|
|
2740
|
+
model: (0, import_client_common5.keyBy)(this.schema.outputObjectTypes.model, "name"),
|
|
2741
|
+
prisma: (0, import_client_common5.keyBy)(this.schema.outputObjectTypes.prisma, "name")
|
|
2795
2742
|
};
|
|
2796
2743
|
}
|
|
2797
2744
|
buildRootFieldMap() {
|
|
2798
2745
|
return {
|
|
2799
|
-
...(0,
|
|
2800
|
-
...(0,
|
|
2746
|
+
...(0, import_client_common5.keyBy)(this.outputTypeMap.prisma.Query.fields, "name"),
|
|
2747
|
+
...(0, import_client_common5.keyBy)(this.outputTypeMap.prisma.Mutation.fields, "name")
|
|
2801
2748
|
};
|
|
2802
2749
|
}
|
|
2803
2750
|
buildInputTypesMap() {
|
|
@@ -2822,12 +2769,12 @@ function fullyQualifiedName(typeName, namespace2) {
|
|
|
2822
2769
|
}
|
|
2823
2770
|
|
|
2824
2771
|
// src/GenericsArgsInfo.ts
|
|
2825
|
-
var
|
|
2772
|
+
var import_client_common6 = require("@prisma/client-common");
|
|
2826
2773
|
var GenericArgsInfo = class {
|
|
2827
2774
|
constructor(_dmmf) {
|
|
2828
2775
|
this._dmmf = _dmmf;
|
|
2829
2776
|
}
|
|
2830
|
-
_cache = new
|
|
2777
|
+
_cache = new import_client_common6.Cache();
|
|
2831
2778
|
/**
|
|
2832
2779
|
* Determines if arg types need generic <$PrismaModel> argument added.
|
|
2833
2780
|
* Essentially, performs breadth-first search for any fieldRefTypes that
|
|
@@ -2949,14 +2896,14 @@ function buildDebugInitialization(edge) {
|
|
|
2949
2896
|
}
|
|
2950
2897
|
|
|
2951
2898
|
// src/utils/buildDMMF.ts
|
|
2952
|
-
var
|
|
2899
|
+
var import_client_common9 = require("@prisma/client-common");
|
|
2953
2900
|
|
|
2954
2901
|
// src/TSClient/helpers.ts
|
|
2955
|
-
var
|
|
2956
|
-
var
|
|
2902
|
+
var import_client_common8 = require("@prisma/client-common");
|
|
2903
|
+
var import_pluralize = __toESM(require("pluralize"));
|
|
2957
2904
|
|
|
2958
2905
|
// src/TSClient/jsdoc.ts
|
|
2959
|
-
var
|
|
2906
|
+
var import_client_common7 = require("@prisma/client-common");
|
|
2960
2907
|
var Docs = {
|
|
2961
2908
|
cursor: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}`,
|
|
2962
2909
|
pagination: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs}`,
|
|
@@ -3029,7 +2976,7 @@ const ${ctx.singular} = await ${ctx.method}({
|
|
|
3029
2976
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
|
|
3030
2977
|
@example
|
|
3031
2978
|
// Create many ${ctx.plural}
|
|
3032
|
-
const ${(0,
|
|
2979
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3033
2980
|
data: [
|
|
3034
2981
|
// ... provide data here
|
|
3035
2982
|
]
|
|
@@ -3043,7 +2990,7 @@ const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3043
2990
|
body: (ctx) => {
|
|
3044
2991
|
const onlySelect = ctx.firstScalar ? `
|
|
3045
2992
|
// Create many ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
|
|
3046
|
-
const ${(0,
|
|
2993
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)}With${(0, import_client_common7.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({
|
|
3047
2994
|
select: { ${ctx.firstScalar.name}: true },
|
|
3048
2995
|
data: [
|
|
3049
2996
|
// ... provide data here
|
|
@@ -3053,7 +3000,7 @@ const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)}With${(0, imp
|
|
|
3053
3000
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
|
|
3054
3001
|
@example
|
|
3055
3002
|
// Create many ${ctx.plural}
|
|
3056
|
-
const ${(0,
|
|
3003
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3057
3004
|
data: [
|
|
3058
3005
|
// ... provide data here
|
|
3059
3006
|
]
|
|
@@ -3071,7 +3018,7 @@ ${undefinedNote}
|
|
|
3071
3018
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3072
3019
|
@example
|
|
3073
3020
|
// Get one ${ctx.singular}
|
|
3074
|
-
const ${(0,
|
|
3021
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3075
3022
|
where: {
|
|
3076
3023
|
// ... provide filter here
|
|
3077
3024
|
}
|
|
@@ -3086,7 +3033,7 @@ if no matches were found.
|
|
|
3086
3033
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3087
3034
|
@example
|
|
3088
3035
|
// Get one ${ctx.singular}
|
|
3089
|
-
const ${(0,
|
|
3036
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3090
3037
|
where: {
|
|
3091
3038
|
// ... provide filter here
|
|
3092
3039
|
}
|
|
@@ -3101,7 +3048,7 @@ ${undefinedNote}
|
|
|
3101
3048
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3102
3049
|
@example
|
|
3103
3050
|
// Get one ${ctx.singular}
|
|
3104
|
-
const ${(0,
|
|
3051
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3105
3052
|
where: {
|
|
3106
3053
|
// ... provide filter here
|
|
3107
3054
|
}
|
|
@@ -3122,7 +3069,7 @@ ${undefinedNote}
|
|
|
3122
3069
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3123
3070
|
@example
|
|
3124
3071
|
// Get one ${ctx.singular}
|
|
3125
|
-
const ${(0,
|
|
3072
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3126
3073
|
where: {
|
|
3127
3074
|
// ... provide filter here
|
|
3128
3075
|
}
|
|
@@ -3140,7 +3087,7 @@ const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3140
3087
|
body: (ctx) => {
|
|
3141
3088
|
const onlySelect = ctx.firstScalar ? `
|
|
3142
3089
|
// Only select the \`${ctx.firstScalar.name}\`
|
|
3143
|
-
const ${(0,
|
|
3090
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)}With${(0, import_client_common7.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({ select: { ${ctx.firstScalar.name}: true } })` : "";
|
|
3144
3091
|
return `Find zero or more ${ctx.plural} that matches the filter.
|
|
3145
3092
|
${undefinedNote}
|
|
3146
3093
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to filter and select certain fields only.
|
|
@@ -3167,7 +3114,7 @@ ${onlySelect}
|
|
|
3167
3114
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one ${ctx.singular}.
|
|
3168
3115
|
@example
|
|
3169
3116
|
// Update one ${ctx.singular}
|
|
3170
|
-
const ${(0,
|
|
3117
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3171
3118
|
where: {
|
|
3172
3119
|
// ... provide filter here
|
|
3173
3120
|
},
|
|
@@ -3186,7 +3133,7 @@ const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3186
3133
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update or create a ${ctx.singular}.
|
|
3187
3134
|
@example
|
|
3188
3135
|
// Update or create a ${ctx.singular}
|
|
3189
|
-
const ${(0,
|
|
3136
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3190
3137
|
create: {
|
|
3191
3138
|
// ... data to create a ${ctx.singular}
|
|
3192
3139
|
},
|
|
@@ -3280,7 +3227,7 @@ ${undefinedNote}
|
|
|
3280
3227
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one or more rows.
|
|
3281
3228
|
@example
|
|
3282
3229
|
// Update many ${ctx.plural}
|
|
3283
|
-
const ${(0,
|
|
3230
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3284
3231
|
where: {
|
|
3285
3232
|
// ... provide filter here
|
|
3286
3233
|
},
|
|
@@ -3299,7 +3246,7 @@ const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3299
3246
|
body: (ctx) => {
|
|
3300
3247
|
const onlySelect = ctx.firstScalar ? `
|
|
3301
3248
|
// Update zero or more ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
|
|
3302
|
-
const ${(0,
|
|
3249
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)}With${(0, import_client_common7.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({
|
|
3303
3250
|
select: { ${ctx.firstScalar.name}: true },
|
|
3304
3251
|
where: {
|
|
3305
3252
|
// ... provide filter here
|
|
@@ -3312,7 +3259,7 @@ const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)}With${(0, imp
|
|
|
3312
3259
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update many ${ctx.plural}.
|
|
3313
3260
|
@example
|
|
3314
3261
|
// Update many ${ctx.plural}
|
|
3315
|
-
const ${(0,
|
|
3262
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3316
3263
|
where: {
|
|
3317
3264
|
// ... provide filter here
|
|
3318
3265
|
},
|
|
@@ -3350,7 +3297,7 @@ const { count } = await ${ctx.method}({
|
|
|
3350
3297
|
body: (ctx) => `Perform aggregation operations on a ${ctx.singular}.
|
|
3351
3298
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which aggregations you would like to apply.
|
|
3352
3299
|
@example
|
|
3353
|
-
const ${(0,
|
|
3300
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3354
3301
|
pipeline: [
|
|
3355
3302
|
{ $match: { status: "registered" } },
|
|
3356
3303
|
{ $group: { _id: "$country", total: { $sum: 1 } } }
|
|
@@ -3365,7 +3312,7 @@ const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3365
3312
|
body: (ctx) => `Find zero or more ${ctx.plural} that matches the filter.
|
|
3366
3313
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which filters you would like to apply.
|
|
3367
3314
|
@example
|
|
3368
|
-
const ${(0,
|
|
3315
|
+
const ${(0, import_client_common7.uncapitalize)(ctx.mapping.model)} = await ${ctx.method}({
|
|
3369
3316
|
filter: { age: { $gt: 25 } }
|
|
3370
3317
|
})`,
|
|
3371
3318
|
fields: {
|
|
@@ -3378,10 +3325,10 @@ const ${(0, import_client_common8.uncapitalize)(ctx.mapping.model)} = await ${ct
|
|
|
3378
3325
|
// src/TSClient/helpers.ts
|
|
3379
3326
|
function getMethodJSDocBody(action, mapping, model) {
|
|
3380
3327
|
const ctx = {
|
|
3381
|
-
singular: (0,
|
|
3382
|
-
plural: (0,
|
|
3328
|
+
singular: (0, import_client_common8.capitalize)(mapping.model),
|
|
3329
|
+
plural: (0, import_client_common8.capitalize)(mapping.plural),
|
|
3383
3330
|
firstScalar: model.fields.find((f) => f.kind === "scalar"),
|
|
3384
|
-
method: `prisma.${(0,
|
|
3331
|
+
method: `prisma.${(0, import_client_common8.uncapitalize)(mapping.model)}.${action}`,
|
|
3385
3332
|
action,
|
|
3386
3333
|
mapping,
|
|
3387
3334
|
model
|
|
@@ -3402,7 +3349,7 @@ function getArgFieldJSDoc(type, action, field) {
|
|
|
3402
3349
|
const fieldName = typeof field === "string" ? field : field.name;
|
|
3403
3350
|
if (JSDocs[action] && JSDocs[action]?.fields[fieldName]) {
|
|
3404
3351
|
const singular = type.name;
|
|
3405
|
-
const plural = (0,
|
|
3352
|
+
const plural = (0, import_pluralize.default)(type.name);
|
|
3406
3353
|
const comment = JSDocs[action]?.fields[fieldName](singular, plural);
|
|
3407
3354
|
return comment;
|
|
3408
3355
|
}
|
|
@@ -3414,10 +3361,10 @@ function escapeJson(str) {
|
|
|
3414
3361
|
|
|
3415
3362
|
// src/utils/buildDMMF.ts
|
|
3416
3363
|
function buildRuntimeDataModel(datamodel, runtimeName) {
|
|
3417
|
-
const runtimeDataModel = (0,
|
|
3364
|
+
const runtimeDataModel = (0, import_client_common9.dmmfToRuntimeDataModel)(datamodel);
|
|
3418
3365
|
let prunedDataModel;
|
|
3419
3366
|
if (runtimeName === "wasm-compiler-edge" || runtimeName === "client") {
|
|
3420
|
-
prunedDataModel = (0,
|
|
3367
|
+
prunedDataModel = (0, import_client_common9.pruneRuntimeDataModel)(runtimeDataModel);
|
|
3421
3368
|
} else {
|
|
3422
3369
|
prunedDataModel = runtimeDataModel;
|
|
3423
3370
|
}
|
|
@@ -3526,7 +3473,7 @@ function buildWasmFileMap({ activeProvider, runtimeName, compilerBuild }) {
|
|
|
3526
3473
|
}
|
|
3527
3474
|
|
|
3528
3475
|
// src/TSClient/PrismaClient.ts
|
|
3529
|
-
var
|
|
3476
|
+
var import_client_common10 = require("@prisma/client-common");
|
|
3530
3477
|
var ts5 = __toESM(require("@prisma/ts-builders"));
|
|
3531
3478
|
var import_indent_string3 = __toESM(require("indent-string"));
|
|
3532
3479
|
|
|
@@ -3717,8 +3664,8 @@ function getPrismaClientClassDocComment({ dmmf }) {
|
|
|
3717
3664
|
const prisma = new PrismaClient({
|
|
3718
3665
|
adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL })
|
|
3719
3666
|
})
|
|
3720
|
-
// Fetch zero or more ${(0,
|
|
3721
|
-
const ${(0,
|
|
3667
|
+
// Fetch zero or more ${(0, import_client_common10.capitalize)(example.plural)}
|
|
3668
|
+
const ${(0, import_client_common10.uncapitalize)(example.plural)} = await prisma.${(0, import_client_common10.uncapitalize)(example.model)}.findMany()
|
|
3722
3669
|
\`\`\`
|
|
3723
3670
|
|
|
3724
3671
|
Read more in our [docs](https://pris.ly/d/client).
|
|
@@ -3779,7 +3726,7 @@ ${[
|
|
|
3779
3726
|
|
|
3780
3727
|
${(0, import_indent_string3.default)(
|
|
3781
3728
|
dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
|
|
3782
|
-
let methodName = (0,
|
|
3729
|
+
let methodName = (0, import_client_common10.uncapitalize)(m.model);
|
|
3783
3730
|
if (methodName === "constructor") {
|
|
3784
3731
|
methodName = '["constructor"]';
|
|
3785
3732
|
}
|
|
@@ -3788,8 +3735,8 @@ ${[
|
|
|
3788
3735
|
* \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
|
|
3789
3736
|
* Example usage:
|
|
3790
3737
|
* \`\`\`ts
|
|
3791
|
-
* // Fetch zero or more ${(0,
|
|
3792
|
-
* const ${(0,
|
|
3738
|
+
* // Fetch zero or more ${(0, import_client_common10.capitalize)(m.plural)}
|
|
3739
|
+
* const ${(0, import_client_common10.uncapitalize)(m.plural)} = await prisma.${methodName}.findMany()
|
|
3793
3740
|
* \`\`\`
|
|
3794
3741
|
*/
|
|
3795
3742
|
get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
|
|
@@ -3978,7 +3925,7 @@ export {}
|
|
|
3978
3925
|
var ts15 = __toESM(require("@prisma/ts-builders"));
|
|
3979
3926
|
|
|
3980
3927
|
// src/TSClient/Model.ts
|
|
3981
|
-
var
|
|
3928
|
+
var import_client_common14 = require("@prisma/client-common");
|
|
3982
3929
|
var DMMF2 = __toESM(require("@prisma/dmmf"));
|
|
3983
3930
|
var ts14 = __toESM(require("@prisma/ts-builders"));
|
|
3984
3931
|
var import_indent_string5 = __toESM(require("indent-string"));
|
|
@@ -4064,7 +4011,7 @@ var ArgsTypeBuilder = class {
|
|
|
4064
4011
|
};
|
|
4065
4012
|
|
|
4066
4013
|
// src/TSClient/Count.ts
|
|
4067
|
-
var
|
|
4014
|
+
var import_client_common11 = require("@prisma/client-common");
|
|
4068
4015
|
var ts11 = __toESM(require("@prisma/ts-builders"));
|
|
4069
4016
|
var import_indent_string4 = __toESM(require("indent-string"));
|
|
4070
4017
|
|
|
@@ -4183,7 +4130,7 @@ ${this.argsTypes.map((typeExport) => ts11.stringify(typeExport)).join("\n\n")}
|
|
|
4183
4130
|
}
|
|
4184
4131
|
};
|
|
4185
4132
|
function getCountArgsType(typeName, fieldName) {
|
|
4186
|
-
return `${typeName}Count${(0,
|
|
4133
|
+
return `${typeName}Count${(0, import_client_common11.capitalize)(fieldName)}Args`;
|
|
4187
4134
|
}
|
|
4188
4135
|
|
|
4189
4136
|
// src/TSClient/ModelFieldRefs.ts
|
|
@@ -4214,7 +4161,7 @@ ${this.stringifyFields()}
|
|
|
4214
4161
|
};
|
|
4215
4162
|
|
|
4216
4163
|
// src/TSClient/Payload.ts
|
|
4217
|
-
var
|
|
4164
|
+
var import_client_common12 = require("@prisma/client-common");
|
|
4218
4165
|
var ts12 = __toESM(require("@prisma/ts-builders"));
|
|
4219
4166
|
function buildModelPayload(model, context) {
|
|
4220
4167
|
const isComposite = context.dmmf.isComposite(model.name);
|
|
@@ -4232,7 +4179,7 @@ function buildModelPayload(model, context) {
|
|
|
4232
4179
|
scalars.add(buildModelOutputProperty(field, context.dmmf));
|
|
4233
4180
|
}
|
|
4234
4181
|
}
|
|
4235
|
-
const scalarsType = isComposite ? scalars : ts12.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts12.namedType("ExtArgs").subKey("result").subKey((0,
|
|
4182
|
+
const scalarsType = isComposite ? scalars : ts12.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts12.namedType("ExtArgs").subKey("result").subKey((0, import_client_common12.uncapitalize)(model.name)));
|
|
4236
4183
|
const payloadTypeDeclaration = ts12.typeDeclaration(
|
|
4237
4184
|
getPayloadName(model.name, false),
|
|
4238
4185
|
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))
|
|
@@ -4244,7 +4191,7 @@ function buildModelPayload(model, context) {
|
|
|
4244
4191
|
}
|
|
4245
4192
|
|
|
4246
4193
|
// src/TSClient/SelectIncludeOmit.ts
|
|
4247
|
-
var
|
|
4194
|
+
var import_client_common13 = require("@prisma/client-common");
|
|
4248
4195
|
var ts13 = __toESM(require("@prisma/ts-builders"));
|
|
4249
4196
|
function buildIncludeType({
|
|
4250
4197
|
modelName,
|
|
@@ -4278,7 +4225,7 @@ function buildSelectType({
|
|
|
4278
4225
|
return buildExport(typeName, selectType);
|
|
4279
4226
|
}
|
|
4280
4227
|
function modelResultExtensionsType(modelName) {
|
|
4281
|
-
return extArgsParam.toArgument().subKey("result").subKey((0,
|
|
4228
|
+
return extArgsParam.toArgument().subKey("result").subKey((0, import_client_common13.uncapitalize)(modelName));
|
|
4282
4229
|
}
|
|
4283
4230
|
function buildScalarSelectType({ modelName, fields, context }) {
|
|
4284
4231
|
const object = buildSelectOrIncludeObject(
|
|
@@ -4848,7 +4795,7 @@ function getNonAggregateMethodDependencyValidations(modelMapping, actionName, co
|
|
|
4848
4795
|
objectType11.add(ts14.property(reqArg, ts14.objectType()));
|
|
4849
4796
|
}
|
|
4850
4797
|
validators.push(
|
|
4851
|
-
ts14.genericParameter(`${(0,
|
|
4798
|
+
ts14.genericParameter(`${(0, import_client_common14.capitalize)(args.name)}DependenciesValidator`).extends(
|
|
4852
4799
|
ts14.conditionalType().check(ts14.stringLiteral(args.name)).extends(ts14.namedType("Prisma.Keys<T>")).then(objectType11).else(ts14.objectType())
|
|
4853
4800
|
)
|
|
4854
4801
|
);
|
|
@@ -5453,20 +5400,20 @@ export type ${this.type.name}<$PrismaModel> = FieldRefInputType<$PrismaModel, ${
|
|
|
5453
5400
|
};
|
|
5454
5401
|
|
|
5455
5402
|
// src/TSClient/globalOmit.ts
|
|
5456
|
-
var
|
|
5403
|
+
var import_client_common15 = require("@prisma/client-common");
|
|
5457
5404
|
var ts17 = __toESM(require("@prisma/ts-builders"));
|
|
5458
5405
|
function globalOmitConfig(dmmf) {
|
|
5459
5406
|
const objectType11 = ts17.objectType().addMultiple(
|
|
5460
5407
|
dmmf.datamodel.models.map((model) => {
|
|
5461
5408
|
const type = ts17.namedType(`Prisma.${getOmitName(model.name)}`);
|
|
5462
|
-
return ts17.property((0,
|
|
5409
|
+
return ts17.property((0, import_client_common15.uncapitalize)(model.name), type).optional();
|
|
5463
5410
|
})
|
|
5464
5411
|
);
|
|
5465
5412
|
return ts17.moduleExport(ts17.typeDeclaration("GlobalOmitConfig", objectType11));
|
|
5466
5413
|
}
|
|
5467
5414
|
|
|
5468
5415
|
// src/TSClient/TypeMap.ts
|
|
5469
|
-
var
|
|
5416
|
+
var import_client_common16 = require("@prisma/client-common");
|
|
5470
5417
|
var import_internals4 = require("@prisma/internals");
|
|
5471
5418
|
var ts18 = __toESM(require("@prisma/ts-builders"));
|
|
5472
5419
|
function clientTypeMapDefinition(context) {
|
|
@@ -5484,7 +5431,7 @@ function clientTypeMapModelsDefinition(context) {
|
|
|
5484
5431
|
if (modelNames.length === 0) {
|
|
5485
5432
|
meta.add(ts18.property("modelProps", ts18.neverType));
|
|
5486
5433
|
} else {
|
|
5487
|
-
meta.add(ts18.property("modelProps", ts18.unionType(modelNames.map((name) => ts18.stringLiteral((0,
|
|
5434
|
+
meta.add(ts18.property("modelProps", ts18.unionType(modelNames.map((name) => ts18.stringLiteral((0, import_client_common16.uncapitalize)(name))))));
|
|
5488
5435
|
}
|
|
5489
5436
|
const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ? ts18.namedType("TransactionIsolationLevel") : ts18.neverType;
|
|
5490
5437
|
meta.add(ts18.property("txIsolationLevel", isolationLevel));
|
|
@@ -6160,7 +6107,7 @@ function buildClient({
|
|
|
6160
6107
|
const outputName = generatedFileNameMapper(generatedFileExtension);
|
|
6161
6108
|
const importName = importFileNameMapper(importFileExtension);
|
|
6162
6109
|
const clientOptions = {
|
|
6163
|
-
dmmf:
|
|
6110
|
+
dmmf: (0, import_internals.externalToInternalDmmf)(dmmf),
|
|
6164
6111
|
datasources,
|
|
6165
6112
|
generator,
|
|
6166
6113
|
binaryPaths,
|
|
@@ -6433,7 +6380,7 @@ var import_internals7 = require("@prisma/internals");
|
|
|
6433
6380
|
var import_get_tsconfig = require("get-tsconfig");
|
|
6434
6381
|
|
|
6435
6382
|
// package.json
|
|
6436
|
-
var version = "7.7.0-dev.
|
|
6383
|
+
var version = "7.7.0-dev.2";
|
|
6437
6384
|
|
|
6438
6385
|
// src/module-format.ts
|
|
6439
6386
|
function parseModuleFormat(format) {
|
|
@@ -6581,7 +6528,6 @@ function parseCompilerBuildFromUnknown(value, target) {
|
|
|
6581
6528
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6582
6529
|
0 && (module.exports = {
|
|
6583
6530
|
PrismaClientTsGenerator,
|
|
6584
|
-
externalToInternalDmmf,
|
|
6585
6531
|
generateClient,
|
|
6586
6532
|
getDMMF
|
|
6587
6533
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2166,51 +2166,6 @@ var require_lib = __commonJS({
|
|
|
2166
2166
|
}
|
|
2167
2167
|
});
|
|
2168
2168
|
|
|
2169
|
-
// src/externalToInternalDmmf.ts
|
|
2170
|
-
import { capitalize, uncapitalize } from "@prisma/client-common";
|
|
2171
|
-
import pluralize from "pluralize";
|
|
2172
|
-
function externalToInternalDmmf(document) {
|
|
2173
|
-
return {
|
|
2174
|
-
...document,
|
|
2175
|
-
mappings: getMappings(document.mappings, document.datamodel)
|
|
2176
|
-
};
|
|
2177
|
-
}
|
|
2178
|
-
function getMappings(mappings, datamodel) {
|
|
2179
|
-
const modelOperations = mappings.modelOperations.filter((mapping) => {
|
|
2180
|
-
const model = datamodel.models.find((m) => m.name === mapping.model);
|
|
2181
|
-
if (!model) {
|
|
2182
|
-
throw new Error(`Mapping without model ${mapping.model}`);
|
|
2183
|
-
}
|
|
2184
|
-
return model.fields.some((f) => f.kind !== "object");
|
|
2185
|
-
}).map((mapping) => ({
|
|
2186
|
-
model: mapping.model,
|
|
2187
|
-
plural: pluralize(uncapitalize(mapping.model)),
|
|
2188
|
-
// TODO not needed anymore
|
|
2189
|
-
findUnique: mapping.findUnique || mapping.findSingle,
|
|
2190
|
-
findUniqueOrThrow: mapping.findUniqueOrThrow,
|
|
2191
|
-
findFirst: mapping.findFirst,
|
|
2192
|
-
findFirstOrThrow: mapping.findFirstOrThrow,
|
|
2193
|
-
findMany: mapping.findMany,
|
|
2194
|
-
create: mapping.createOne || mapping.createSingle || mapping.create,
|
|
2195
|
-
createMany: mapping.createMany,
|
|
2196
|
-
createManyAndReturn: mapping.createManyAndReturn,
|
|
2197
|
-
delete: mapping.deleteOne || mapping.deleteSingle || mapping.delete,
|
|
2198
|
-
update: mapping.updateOne || mapping.updateSingle || mapping.update,
|
|
2199
|
-
deleteMany: mapping.deleteMany,
|
|
2200
|
-
updateMany: mapping.updateMany,
|
|
2201
|
-
updateManyAndReturn: mapping.updateManyAndReturn,
|
|
2202
|
-
upsert: mapping.upsertOne || mapping.upsertSingle || mapping.upsert,
|
|
2203
|
-
aggregate: mapping.aggregate,
|
|
2204
|
-
groupBy: mapping.groupBy,
|
|
2205
|
-
findRaw: mapping.findRaw,
|
|
2206
|
-
aggregateRaw: mapping.aggregateRaw
|
|
2207
|
-
}));
|
|
2208
|
-
return {
|
|
2209
|
-
modelOperations,
|
|
2210
|
-
otherOperations: mappings.otherOperations
|
|
2211
|
-
};
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
2169
|
// src/generateClient.ts
|
|
2215
2170
|
var import_fs_extra = __toESM(require_lib());
|
|
2216
2171
|
import fs2 from "node:fs/promises";
|
|
@@ -2270,13 +2225,13 @@ var bgWhite = init(47, 49);
|
|
|
2270
2225
|
import { packageUp } from "package-up";
|
|
2271
2226
|
|
|
2272
2227
|
// src/file-extensions.ts
|
|
2273
|
-
import { capitalize
|
|
2228
|
+
import { capitalize } from "@prisma/client-common";
|
|
2274
2229
|
var expectedGeneratedFileExtensions = ["ts", "mts", "cts"];
|
|
2275
2230
|
var expectedImportFileExtensions = ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
|
|
2276
2231
|
function validateFileExtension(extension, kind, recommended) {
|
|
2277
2232
|
if (!recommended.includes(extension) && !process.env.PRISMA_DISABLE_WARNINGS) {
|
|
2278
2233
|
console.warn(
|
|
2279
|
-
`${
|
|
2234
|
+
`${capitalize(kind)} file extension ${JSON.stringify(
|
|
2280
2235
|
extension
|
|
2281
2236
|
)} is unexpected and may be a mistake. Expected one of: ${recommended.map((ext) => JSON.stringify(ext)).join(", ")}`
|
|
2282
2237
|
);
|
|
@@ -2343,14 +2298,7 @@ function matchingJsExtension(generatedFileExtension) {
|
|
|
2343
2298
|
}
|
|
2344
2299
|
|
|
2345
2300
|
// src/getDMMF.ts
|
|
2346
|
-
import {
|
|
2347
|
-
function getPrismaClientDMMF(dmmf) {
|
|
2348
|
-
return externalToInternalDmmf(dmmf);
|
|
2349
|
-
}
|
|
2350
|
-
async function getDMMF(options) {
|
|
2351
|
-
const dmmf = await getRawDMMF(options);
|
|
2352
|
-
return getPrismaClientDMMF(dmmf);
|
|
2353
|
-
}
|
|
2301
|
+
import { getInternalDMMF, externalToInternalDmmf } from "@prisma/internals";
|
|
2354
2302
|
|
|
2355
2303
|
// src/TSClient/Enum.ts
|
|
2356
2304
|
import { objectEnumNames, strictEnumNames } from "@prisma/client-common";
|
|
@@ -2393,7 +2341,7 @@ import * as ts2 from "@prisma/ts-builders";
|
|
|
2393
2341
|
import indent2 from "indent-string";
|
|
2394
2342
|
|
|
2395
2343
|
// src/utils.ts
|
|
2396
|
-
import { capitalize as
|
|
2344
|
+
import { capitalize as capitalize2 } from "@prisma/client-common";
|
|
2397
2345
|
import * as DMMF from "@prisma/dmmf";
|
|
2398
2346
|
import { assertNever } from "@prisma/internals";
|
|
2399
2347
|
import * as ts from "@prisma/ts-builders";
|
|
@@ -2425,31 +2373,31 @@ function getOmitName(modelName) {
|
|
|
2425
2373
|
return `${modelName}Omit`;
|
|
2426
2374
|
}
|
|
2427
2375
|
function getAggregateName(modelName) {
|
|
2428
|
-
return `Aggregate${
|
|
2376
|
+
return `Aggregate${capitalize2(modelName)}`;
|
|
2429
2377
|
}
|
|
2430
2378
|
function getCountOutputTypeName(modelName) {
|
|
2431
|
-
return `${
|
|
2379
|
+
return `${capitalize2(modelName)}CountOutputType`;
|
|
2432
2380
|
}
|
|
2433
2381
|
function getGroupByName(modelName) {
|
|
2434
|
-
return `${
|
|
2382
|
+
return `${capitalize2(modelName)}GroupByOutputType`;
|
|
2435
2383
|
}
|
|
2436
2384
|
function getAvgAggregateName(modelName) {
|
|
2437
|
-
return `${
|
|
2385
|
+
return `${capitalize2(modelName)}AvgAggregateOutputType`;
|
|
2438
2386
|
}
|
|
2439
2387
|
function getSumAggregateName(modelName) {
|
|
2440
|
-
return `${
|
|
2388
|
+
return `${capitalize2(modelName)}SumAggregateOutputType`;
|
|
2441
2389
|
}
|
|
2442
2390
|
function getMinAggregateName(modelName) {
|
|
2443
|
-
return `${
|
|
2391
|
+
return `${capitalize2(modelName)}MinAggregateOutputType`;
|
|
2444
2392
|
}
|
|
2445
2393
|
function getMaxAggregateName(modelName) {
|
|
2446
|
-
return `${
|
|
2394
|
+
return `${capitalize2(modelName)}MaxAggregateOutputType`;
|
|
2447
2395
|
}
|
|
2448
2396
|
function getCountAggregateInputName(modelName) {
|
|
2449
|
-
return `${
|
|
2397
|
+
return `${capitalize2(modelName)}CountAggregateInputType`;
|
|
2450
2398
|
}
|
|
2451
2399
|
function getCountAggregateOutputName(modelName) {
|
|
2452
|
-
return `${
|
|
2400
|
+
return `${capitalize2(modelName)}CountAggregateOutputType`;
|
|
2453
2401
|
}
|
|
2454
2402
|
function getAggregateInputType(aggregateOutputType) {
|
|
2455
2403
|
return aggregateOutputType.replace(/OutputType$/, "InputType");
|
|
@@ -2458,13 +2406,13 @@ function getGroupByArgsName(modelName) {
|
|
|
2458
2406
|
return `${modelName}GroupByArgs`;
|
|
2459
2407
|
}
|
|
2460
2408
|
function getGroupByPayloadName(modelName) {
|
|
2461
|
-
return `Get${
|
|
2409
|
+
return `Get${capitalize2(modelName)}GroupByPayload`;
|
|
2462
2410
|
}
|
|
2463
2411
|
function getAggregateArgsName(modelName) {
|
|
2464
|
-
return `${
|
|
2412
|
+
return `${capitalize2(modelName)}AggregateArgs`;
|
|
2465
2413
|
}
|
|
2466
2414
|
function getAggregateGetName(modelName) {
|
|
2467
|
-
return `Get${
|
|
2415
|
+
return `Get${capitalize2(modelName)}AggregateType`;
|
|
2468
2416
|
}
|
|
2469
2417
|
function getFieldArgName(field, modelName) {
|
|
2470
2418
|
if (field.args.length) {
|
|
@@ -2945,11 +2893,11 @@ import {
|
|
|
2945
2893
|
} from "@prisma/client-common";
|
|
2946
2894
|
|
|
2947
2895
|
// src/TSClient/helpers.ts
|
|
2948
|
-
import { capitalize as
|
|
2949
|
-
import
|
|
2896
|
+
import { capitalize as capitalize4, uncapitalize as uncapitalize2 } from "@prisma/client-common";
|
|
2897
|
+
import pluralize from "pluralize";
|
|
2950
2898
|
|
|
2951
2899
|
// src/TSClient/jsdoc.ts
|
|
2952
|
-
import { capitalize as
|
|
2900
|
+
import { capitalize as capitalize3, uncapitalize } from "@prisma/client-common";
|
|
2953
2901
|
var Docs = {
|
|
2954
2902
|
cursor: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}`,
|
|
2955
2903
|
pagination: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs}`,
|
|
@@ -3022,7 +2970,7 @@ const ${ctx.singular} = await ${ctx.method}({
|
|
|
3022
2970
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
|
|
3023
2971
|
@example
|
|
3024
2972
|
// Create many ${ctx.plural}
|
|
3025
|
-
const ${
|
|
2973
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3026
2974
|
data: [
|
|
3027
2975
|
// ... provide data here
|
|
3028
2976
|
]
|
|
@@ -3036,7 +2984,7 @@ const ${uncapitalize2(ctx.mapping.model)} = await ${ctx.method}({
|
|
|
3036
2984
|
body: (ctx) => {
|
|
3037
2985
|
const onlySelect = ctx.firstScalar ? `
|
|
3038
2986
|
// Create many ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
|
|
3039
|
-
const ${
|
|
2987
|
+
const ${uncapitalize(ctx.mapping.model)}With${capitalize3(ctx.firstScalar.name)}Only = await ${ctx.method}({
|
|
3040
2988
|
select: { ${ctx.firstScalar.name}: true },
|
|
3041
2989
|
data: [
|
|
3042
2990
|
// ... provide data here
|
|
@@ -3046,7 +2994,7 @@ const ${uncapitalize2(ctx.mapping.model)}With${capitalize4(ctx.firstScalar.name)
|
|
|
3046
2994
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
|
|
3047
2995
|
@example
|
|
3048
2996
|
// Create many ${ctx.plural}
|
|
3049
|
-
const ${
|
|
2997
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3050
2998
|
data: [
|
|
3051
2999
|
// ... provide data here
|
|
3052
3000
|
]
|
|
@@ -3064,7 +3012,7 @@ ${undefinedNote}
|
|
|
3064
3012
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3065
3013
|
@example
|
|
3066
3014
|
// Get one ${ctx.singular}
|
|
3067
|
-
const ${
|
|
3015
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3068
3016
|
where: {
|
|
3069
3017
|
// ... provide filter here
|
|
3070
3018
|
}
|
|
@@ -3079,7 +3027,7 @@ if no matches were found.
|
|
|
3079
3027
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3080
3028
|
@example
|
|
3081
3029
|
// Get one ${ctx.singular}
|
|
3082
|
-
const ${
|
|
3030
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3083
3031
|
where: {
|
|
3084
3032
|
// ... provide filter here
|
|
3085
3033
|
}
|
|
@@ -3094,7 +3042,7 @@ ${undefinedNote}
|
|
|
3094
3042
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3095
3043
|
@example
|
|
3096
3044
|
// Get one ${ctx.singular}
|
|
3097
|
-
const ${
|
|
3045
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3098
3046
|
where: {
|
|
3099
3047
|
// ... provide filter here
|
|
3100
3048
|
}
|
|
@@ -3115,7 +3063,7 @@ ${undefinedNote}
|
|
|
3115
3063
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
|
|
3116
3064
|
@example
|
|
3117
3065
|
// Get one ${ctx.singular}
|
|
3118
|
-
const ${
|
|
3066
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3119
3067
|
where: {
|
|
3120
3068
|
// ... provide filter here
|
|
3121
3069
|
}
|
|
@@ -3133,7 +3081,7 @@ const ${uncapitalize2(ctx.mapping.model)} = await ${ctx.method}({
|
|
|
3133
3081
|
body: (ctx) => {
|
|
3134
3082
|
const onlySelect = ctx.firstScalar ? `
|
|
3135
3083
|
// Only select the \`${ctx.firstScalar.name}\`
|
|
3136
|
-
const ${
|
|
3084
|
+
const ${uncapitalize(ctx.mapping.model)}With${capitalize3(ctx.firstScalar.name)}Only = await ${ctx.method}({ select: { ${ctx.firstScalar.name}: true } })` : "";
|
|
3137
3085
|
return `Find zero or more ${ctx.plural} that matches the filter.
|
|
3138
3086
|
${undefinedNote}
|
|
3139
3087
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to filter and select certain fields only.
|
|
@@ -3160,7 +3108,7 @@ ${onlySelect}
|
|
|
3160
3108
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one ${ctx.singular}.
|
|
3161
3109
|
@example
|
|
3162
3110
|
// Update one ${ctx.singular}
|
|
3163
|
-
const ${
|
|
3111
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3164
3112
|
where: {
|
|
3165
3113
|
// ... provide filter here
|
|
3166
3114
|
},
|
|
@@ -3179,7 +3127,7 @@ const ${uncapitalize2(ctx.mapping.model)} = await ${ctx.method}({
|
|
|
3179
3127
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update or create a ${ctx.singular}.
|
|
3180
3128
|
@example
|
|
3181
3129
|
// Update or create a ${ctx.singular}
|
|
3182
|
-
const ${
|
|
3130
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3183
3131
|
create: {
|
|
3184
3132
|
// ... data to create a ${ctx.singular}
|
|
3185
3133
|
},
|
|
@@ -3273,7 +3221,7 @@ ${undefinedNote}
|
|
|
3273
3221
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one or more rows.
|
|
3274
3222
|
@example
|
|
3275
3223
|
// Update many ${ctx.plural}
|
|
3276
|
-
const ${
|
|
3224
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3277
3225
|
where: {
|
|
3278
3226
|
// ... provide filter here
|
|
3279
3227
|
},
|
|
@@ -3292,7 +3240,7 @@ const ${uncapitalize2(ctx.mapping.model)} = await ${ctx.method}({
|
|
|
3292
3240
|
body: (ctx) => {
|
|
3293
3241
|
const onlySelect = ctx.firstScalar ? `
|
|
3294
3242
|
// Update zero or more ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
|
|
3295
|
-
const ${
|
|
3243
|
+
const ${uncapitalize(ctx.mapping.model)}With${capitalize3(ctx.firstScalar.name)}Only = await ${ctx.method}({
|
|
3296
3244
|
select: { ${ctx.firstScalar.name}: true },
|
|
3297
3245
|
where: {
|
|
3298
3246
|
// ... provide filter here
|
|
@@ -3305,7 +3253,7 @@ const ${uncapitalize2(ctx.mapping.model)}With${capitalize4(ctx.firstScalar.name)
|
|
|
3305
3253
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update many ${ctx.plural}.
|
|
3306
3254
|
@example
|
|
3307
3255
|
// Update many ${ctx.plural}
|
|
3308
|
-
const ${
|
|
3256
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3309
3257
|
where: {
|
|
3310
3258
|
// ... provide filter here
|
|
3311
3259
|
},
|
|
@@ -3343,7 +3291,7 @@ const { count } = await ${ctx.method}({
|
|
|
3343
3291
|
body: (ctx) => `Perform aggregation operations on a ${ctx.singular}.
|
|
3344
3292
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which aggregations you would like to apply.
|
|
3345
3293
|
@example
|
|
3346
|
-
const ${
|
|
3294
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3347
3295
|
pipeline: [
|
|
3348
3296
|
{ $match: { status: "registered" } },
|
|
3349
3297
|
{ $group: { _id: "$country", total: { $sum: 1 } } }
|
|
@@ -3358,7 +3306,7 @@ const ${uncapitalize2(ctx.mapping.model)} = await ${ctx.method}({
|
|
|
3358
3306
|
body: (ctx) => `Find zero or more ${ctx.plural} that matches the filter.
|
|
3359
3307
|
@param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which filters you would like to apply.
|
|
3360
3308
|
@example
|
|
3361
|
-
const ${
|
|
3309
|
+
const ${uncapitalize(ctx.mapping.model)} = await ${ctx.method}({
|
|
3362
3310
|
filter: { age: { $gt: 25 } }
|
|
3363
3311
|
})`,
|
|
3364
3312
|
fields: {
|
|
@@ -3371,10 +3319,10 @@ const ${uncapitalize2(ctx.mapping.model)} = await ${ctx.method}({
|
|
|
3371
3319
|
// src/TSClient/helpers.ts
|
|
3372
3320
|
function getMethodJSDocBody(action, mapping, model) {
|
|
3373
3321
|
const ctx = {
|
|
3374
|
-
singular:
|
|
3375
|
-
plural:
|
|
3322
|
+
singular: capitalize4(mapping.model),
|
|
3323
|
+
plural: capitalize4(mapping.plural),
|
|
3376
3324
|
firstScalar: model.fields.find((f) => f.kind === "scalar"),
|
|
3377
|
-
method: `prisma.${
|
|
3325
|
+
method: `prisma.${uncapitalize2(mapping.model)}.${action}`,
|
|
3378
3326
|
action,
|
|
3379
3327
|
mapping,
|
|
3380
3328
|
model
|
|
@@ -3395,7 +3343,7 @@ function getArgFieldJSDoc(type, action, field) {
|
|
|
3395
3343
|
const fieldName = typeof field === "string" ? field : field.name;
|
|
3396
3344
|
if (JSDocs[action] && JSDocs[action]?.fields[fieldName]) {
|
|
3397
3345
|
const singular = type.name;
|
|
3398
|
-
const plural =
|
|
3346
|
+
const plural = pluralize(type.name);
|
|
3399
3347
|
const comment = JSDocs[action]?.fields[fieldName](singular, plural);
|
|
3400
3348
|
return comment;
|
|
3401
3349
|
}
|
|
@@ -3519,7 +3467,7 @@ function buildWasmFileMap({ activeProvider, runtimeName, compilerBuild }) {
|
|
|
3519
3467
|
}
|
|
3520
3468
|
|
|
3521
3469
|
// src/TSClient/PrismaClient.ts
|
|
3522
|
-
import { capitalize as
|
|
3470
|
+
import { capitalize as capitalize5, uncapitalize as uncapitalize3 } from "@prisma/client-common";
|
|
3523
3471
|
import * as ts5 from "@prisma/ts-builders";
|
|
3524
3472
|
import indent3 from "indent-string";
|
|
3525
3473
|
|
|
@@ -3710,8 +3658,8 @@ function getPrismaClientClassDocComment({ dmmf }) {
|
|
|
3710
3658
|
const prisma = new PrismaClient({
|
|
3711
3659
|
adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL })
|
|
3712
3660
|
})
|
|
3713
|
-
// Fetch zero or more ${
|
|
3714
|
-
const ${
|
|
3661
|
+
// Fetch zero or more ${capitalize5(example.plural)}
|
|
3662
|
+
const ${uncapitalize3(example.plural)} = await prisma.${uncapitalize3(example.model)}.findMany()
|
|
3715
3663
|
\`\`\`
|
|
3716
3664
|
|
|
3717
3665
|
Read more in our [docs](https://pris.ly/d/client).
|
|
@@ -3772,7 +3720,7 @@ ${[
|
|
|
3772
3720
|
|
|
3773
3721
|
${indent3(
|
|
3774
3722
|
dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
|
|
3775
|
-
let methodName =
|
|
3723
|
+
let methodName = uncapitalize3(m.model);
|
|
3776
3724
|
if (methodName === "constructor") {
|
|
3777
3725
|
methodName = '["constructor"]';
|
|
3778
3726
|
}
|
|
@@ -3781,8 +3729,8 @@ ${[
|
|
|
3781
3729
|
* \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
|
|
3782
3730
|
* Example usage:
|
|
3783
3731
|
* \`\`\`ts
|
|
3784
|
-
* // Fetch zero or more ${
|
|
3785
|
-
* const ${
|
|
3732
|
+
* // Fetch zero or more ${capitalize5(m.plural)}
|
|
3733
|
+
* const ${uncapitalize3(m.plural)} = await prisma.${methodName}.findMany()
|
|
3786
3734
|
* \`\`\`
|
|
3787
3735
|
*/
|
|
3788
3736
|
get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
|
|
@@ -3971,7 +3919,7 @@ export {}
|
|
|
3971
3919
|
import * as ts15 from "@prisma/ts-builders";
|
|
3972
3920
|
|
|
3973
3921
|
// src/TSClient/Model.ts
|
|
3974
|
-
import { capitalize as
|
|
3922
|
+
import { capitalize as capitalize7 } from "@prisma/client-common";
|
|
3975
3923
|
import * as DMMF2 from "@prisma/dmmf";
|
|
3976
3924
|
import * as ts14 from "@prisma/ts-builders";
|
|
3977
3925
|
import indent5 from "indent-string";
|
|
@@ -4057,7 +4005,7 @@ var ArgsTypeBuilder = class {
|
|
|
4057
4005
|
};
|
|
4058
4006
|
|
|
4059
4007
|
// src/TSClient/Count.ts
|
|
4060
|
-
import { capitalize as
|
|
4008
|
+
import { capitalize as capitalize6 } from "@prisma/client-common";
|
|
4061
4009
|
import * as ts11 from "@prisma/ts-builders";
|
|
4062
4010
|
import indent4 from "indent-string";
|
|
4063
4011
|
|
|
@@ -4176,7 +4124,7 @@ ${this.argsTypes.map((typeExport) => ts11.stringify(typeExport)).join("\n\n")}
|
|
|
4176
4124
|
}
|
|
4177
4125
|
};
|
|
4178
4126
|
function getCountArgsType(typeName, fieldName) {
|
|
4179
|
-
return `${typeName}Count${
|
|
4127
|
+
return `${typeName}Count${capitalize6(fieldName)}Args`;
|
|
4180
4128
|
}
|
|
4181
4129
|
|
|
4182
4130
|
// src/TSClient/ModelFieldRefs.ts
|
|
@@ -4207,7 +4155,7 @@ ${this.stringifyFields()}
|
|
|
4207
4155
|
};
|
|
4208
4156
|
|
|
4209
4157
|
// src/TSClient/Payload.ts
|
|
4210
|
-
import { uncapitalize as
|
|
4158
|
+
import { uncapitalize as uncapitalize4 } from "@prisma/client-common";
|
|
4211
4159
|
import * as ts12 from "@prisma/ts-builders";
|
|
4212
4160
|
function buildModelPayload(model, context) {
|
|
4213
4161
|
const isComposite = context.dmmf.isComposite(model.name);
|
|
@@ -4225,7 +4173,7 @@ function buildModelPayload(model, context) {
|
|
|
4225
4173
|
scalars.add(buildModelOutputProperty(field, context.dmmf));
|
|
4226
4174
|
}
|
|
4227
4175
|
}
|
|
4228
|
-
const scalarsType = isComposite ? scalars : ts12.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts12.namedType("ExtArgs").subKey("result").subKey(
|
|
4176
|
+
const scalarsType = isComposite ? scalars : ts12.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts12.namedType("ExtArgs").subKey("result").subKey(uncapitalize4(model.name)));
|
|
4229
4177
|
const payloadTypeDeclaration = ts12.typeDeclaration(
|
|
4230
4178
|
getPayloadName(model.name, false),
|
|
4231
4179
|
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))
|
|
@@ -4237,7 +4185,7 @@ function buildModelPayload(model, context) {
|
|
|
4237
4185
|
}
|
|
4238
4186
|
|
|
4239
4187
|
// src/TSClient/SelectIncludeOmit.ts
|
|
4240
|
-
import { uncapitalize as
|
|
4188
|
+
import { uncapitalize as uncapitalize5 } from "@prisma/client-common";
|
|
4241
4189
|
import * as ts13 from "@prisma/ts-builders";
|
|
4242
4190
|
function buildIncludeType({
|
|
4243
4191
|
modelName,
|
|
@@ -4271,7 +4219,7 @@ function buildSelectType({
|
|
|
4271
4219
|
return buildExport(typeName, selectType);
|
|
4272
4220
|
}
|
|
4273
4221
|
function modelResultExtensionsType(modelName) {
|
|
4274
|
-
return extArgsParam.toArgument().subKey("result").subKey(
|
|
4222
|
+
return extArgsParam.toArgument().subKey("result").subKey(uncapitalize5(modelName));
|
|
4275
4223
|
}
|
|
4276
4224
|
function buildScalarSelectType({ modelName, fields, context }) {
|
|
4277
4225
|
const object = buildSelectOrIncludeObject(
|
|
@@ -4841,7 +4789,7 @@ function getNonAggregateMethodDependencyValidations(modelMapping, actionName, co
|
|
|
4841
4789
|
objectType11.add(ts14.property(reqArg, ts14.objectType()));
|
|
4842
4790
|
}
|
|
4843
4791
|
validators.push(
|
|
4844
|
-
ts14.genericParameter(`${
|
|
4792
|
+
ts14.genericParameter(`${capitalize7(args.name)}DependenciesValidator`).extends(
|
|
4845
4793
|
ts14.conditionalType().check(ts14.stringLiteral(args.name)).extends(ts14.namedType("Prisma.Keys<T>")).then(objectType11).else(ts14.objectType())
|
|
4846
4794
|
)
|
|
4847
4795
|
);
|
|
@@ -5446,20 +5394,20 @@ export type ${this.type.name}<$PrismaModel> = FieldRefInputType<$PrismaModel, ${
|
|
|
5446
5394
|
};
|
|
5447
5395
|
|
|
5448
5396
|
// src/TSClient/globalOmit.ts
|
|
5449
|
-
import { uncapitalize as
|
|
5397
|
+
import { uncapitalize as uncapitalize6 } from "@prisma/client-common";
|
|
5450
5398
|
import * as ts17 from "@prisma/ts-builders";
|
|
5451
5399
|
function globalOmitConfig(dmmf) {
|
|
5452
5400
|
const objectType11 = ts17.objectType().addMultiple(
|
|
5453
5401
|
dmmf.datamodel.models.map((model) => {
|
|
5454
5402
|
const type = ts17.namedType(`Prisma.${getOmitName(model.name)}`);
|
|
5455
|
-
return ts17.property(
|
|
5403
|
+
return ts17.property(uncapitalize6(model.name), type).optional();
|
|
5456
5404
|
})
|
|
5457
5405
|
);
|
|
5458
5406
|
return ts17.moduleExport(ts17.typeDeclaration("GlobalOmitConfig", objectType11));
|
|
5459
5407
|
}
|
|
5460
5408
|
|
|
5461
5409
|
// src/TSClient/TypeMap.ts
|
|
5462
|
-
import { uncapitalize as
|
|
5410
|
+
import { uncapitalize as uncapitalize7 } from "@prisma/client-common";
|
|
5463
5411
|
import { assertNever as assertNever2 } from "@prisma/internals";
|
|
5464
5412
|
import * as ts18 from "@prisma/ts-builders";
|
|
5465
5413
|
function clientTypeMapDefinition(context) {
|
|
@@ -5477,7 +5425,7 @@ function clientTypeMapModelsDefinition(context) {
|
|
|
5477
5425
|
if (modelNames.length === 0) {
|
|
5478
5426
|
meta.add(ts18.property("modelProps", ts18.neverType));
|
|
5479
5427
|
} else {
|
|
5480
|
-
meta.add(ts18.property("modelProps", ts18.unionType(modelNames.map((name) => ts18.stringLiteral(
|
|
5428
|
+
meta.add(ts18.property("modelProps", ts18.unionType(modelNames.map((name) => ts18.stringLiteral(uncapitalize7(name))))));
|
|
5481
5429
|
}
|
|
5482
5430
|
const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ? ts18.namedType("TransactionIsolationLevel") : ts18.neverType;
|
|
5483
5431
|
meta.add(ts18.property("txIsolationLevel", isolationLevel));
|
|
@@ -6153,7 +6101,7 @@ function buildClient({
|
|
|
6153
6101
|
const outputName = generatedFileNameMapper(generatedFileExtension);
|
|
6154
6102
|
const importName = importFileNameMapper(importFileExtension);
|
|
6155
6103
|
const clientOptions = {
|
|
6156
|
-
dmmf:
|
|
6104
|
+
dmmf: externalToInternalDmmf(dmmf),
|
|
6157
6105
|
datasources,
|
|
6158
6106
|
generator,
|
|
6159
6107
|
binaryPaths,
|
|
@@ -6426,7 +6374,7 @@ import { parseEnvValue } from "@prisma/internals";
|
|
|
6426
6374
|
import { getTsconfig } from "get-tsconfig";
|
|
6427
6375
|
|
|
6428
6376
|
// package.json
|
|
6429
|
-
var version = "7.7.0-dev.
|
|
6377
|
+
var version = "7.7.0-dev.2";
|
|
6430
6378
|
|
|
6431
6379
|
// src/module-format.ts
|
|
6432
6380
|
function parseModuleFormat(format) {
|
|
@@ -6573,7 +6521,6 @@ function parseCompilerBuildFromUnknown(value, target) {
|
|
|
6573
6521
|
}
|
|
6574
6522
|
export {
|
|
6575
6523
|
PrismaClientTsGenerator,
|
|
6576
|
-
externalToInternalDmmf,
|
|
6577
6524
|
generateClient,
|
|
6578
|
-
getDMMF
|
|
6525
|
+
getInternalDMMF as getDMMF
|
|
6579
6526
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-generator-ts",
|
|
3
|
-
"version": "7.7.0-dev.
|
|
3
|
+
"version": "7.7.0-dev.2",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"package-up": "5.0.0",
|
|
34
34
|
"pluralize": "8.0.0",
|
|
35
35
|
"ts-pattern": "5.6.2",
|
|
36
|
-
"@prisma/client-common": "7.7.0-dev.
|
|
37
|
-
"@prisma/debug": "7.7.0-dev.
|
|
38
|
-
"@prisma/fetch-engine": "7.7.0-dev.
|
|
39
|
-
"@prisma/generator": "7.7.0-dev.
|
|
40
|
-
"@prisma/
|
|
41
|
-
"@prisma/
|
|
42
|
-
"@prisma/internals": "7.7.0-dev.
|
|
43
|
-
"@prisma/
|
|
44
|
-
"@prisma/ts-builders": "7.7.0-dev.
|
|
36
|
+
"@prisma/client-common": "7.7.0-dev.2",
|
|
37
|
+
"@prisma/debug": "7.7.0-dev.2",
|
|
38
|
+
"@prisma/fetch-engine": "7.7.0-dev.2",
|
|
39
|
+
"@prisma/generator": "7.7.0-dev.2",
|
|
40
|
+
"@prisma/get-platform": "7.7.0-dev.2",
|
|
41
|
+
"@prisma/param-graph-builder": "7.7.0-dev.2",
|
|
42
|
+
"@prisma/internals": "7.7.0-dev.2",
|
|
43
|
+
"@prisma/dmmf": "7.7.0-dev.2",
|
|
44
|
+
"@prisma/ts-builders": "7.7.0-dev.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/pluralize": "0.0.33"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as DMMF from '@prisma/dmmf';
|
|
2
|
-
export declare function getCountAggregateOutputName(modelName: string): string;
|
|
3
|
-
/**
|
|
4
|
-
* Turns type: string into type: string[] for all args in order to support union input types
|
|
5
|
-
* @param document
|
|
6
|
-
*/
|
|
7
|
-
export declare function externalToInternalDmmf(document: DMMF.Document): DMMF.Document;
|