@stryke/prisma-trpc-generator 0.9.4 → 0.10.1
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/generator.cjs +25 -29
- package/dist/generator.js +25 -29
- package/dist/index.cjs +25 -29
- package/dist/index.js +25 -29
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -6872,15 +6872,15 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
|
|
|
6872
6872
|
ModelAction2["findRaw"] = "findRaw";
|
|
6873
6873
|
ModelAction2["aggregateRaw"] = "aggregateRaw";
|
|
6874
6874
|
return ModelAction2;
|
|
6875
|
-
}(
|
|
6875
|
+
}({});
|
|
6876
6876
|
var modelActionEnum = z.nativeEnum(ModelAction);
|
|
6877
6877
|
var configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
|
|
6878
6878
|
var configSchema = z.object({
|
|
6879
6879
|
debug: configBoolean.default("false"),
|
|
6880
|
-
withMiddleware: configBoolean.default("false"),
|
|
6881
|
-
withShield: configBoolean.default("true"),
|
|
6882
6880
|
withZod: configBoolean.default("true"),
|
|
6883
6881
|
withNext: configBoolean.default("true"),
|
|
6882
|
+
withMiddleware: configBoolean.default("false"),
|
|
6883
|
+
withShield: configBoolean.default("false"),
|
|
6884
6884
|
contextPath: z.string().trim().default("../context"),
|
|
6885
6885
|
trpcOptions: configBoolean.default("true"),
|
|
6886
6886
|
showModelNameInProcedure: configBoolean.default("true"),
|
|
@@ -7625,9 +7625,6 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7625
7625
|
"permissions"
|
|
7626
7626
|
]
|
|
7627
7627
|
});
|
|
7628
|
-
sourceFile.formatText({
|
|
7629
|
-
indentSize: 2
|
|
7630
|
-
});
|
|
7631
7628
|
}
|
|
7632
7629
|
sourceFile.addStatements(
|
|
7633
7630
|
/* ts */
|
|
@@ -7745,6 +7742,9 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7745
7742
|
`
|
|
7746
7743
|
);
|
|
7747
7744
|
}
|
|
7745
|
+
sourceFile.formatText({
|
|
7746
|
+
indentSize: 2
|
|
7747
|
+
});
|
|
7748
7748
|
}
|
|
7749
7749
|
__name(generateTRPCExports, "generateTRPCExports");
|
|
7750
7750
|
function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
|
|
@@ -10355,7 +10355,7 @@ var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
|
10355
10355
|
await writeFileSafely(indexPath, rows.join("\n"), false);
|
|
10356
10356
|
}, "writeIndexFile");
|
|
10357
10357
|
|
|
10358
|
-
// src/zod
|
|
10358
|
+
// src/zod/aggregate-helpers.ts
|
|
10359
10359
|
init_cjs_shims();
|
|
10360
10360
|
var isAggregateOutputType = /* @__PURE__ */ __name((name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name), "isAggregateOutputType");
|
|
10361
10361
|
var isAggregateInputType = /* @__PURE__ */ __name((name) => name.endsWith("CountAggregateInput") || name.endsWith("SumAggregateInput") || name.endsWith("AvgAggregateInput") || name.endsWith("MinAggregateInput") || name.endsWith("MaxAggregateInput"), "isAggregateInputType");
|
|
@@ -10427,7 +10427,7 @@ function resolveZodAggregateOperationSupport(inputObjectTypes) {
|
|
|
10427
10427
|
}
|
|
10428
10428
|
__name(resolveZodAggregateOperationSupport, "resolveZodAggregateOperationSupport");
|
|
10429
10429
|
|
|
10430
|
-
// src/zod
|
|
10430
|
+
// src/zod/comments-helpers.ts
|
|
10431
10431
|
init_cjs_shims();
|
|
10432
10432
|
var modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
|
|
10433
10433
|
var attributeNameRegex = /\.+[A-Z]+\(+/i;
|
|
@@ -10517,14 +10517,14 @@ function hideZodInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels,
|
|
|
10517
10517
|
}
|
|
10518
10518
|
__name(hideZodInputObjectTypesAndRelatedFields, "hideZodInputObjectTypesAndRelatedFields");
|
|
10519
10519
|
|
|
10520
|
-
// src/zod
|
|
10520
|
+
// src/zod/generator-helpers.ts
|
|
10521
10521
|
init_cjs_shims();
|
|
10522
10522
|
|
|
10523
|
-
// src/zod
|
|
10523
|
+
// src/zod/transformer.ts
|
|
10524
10524
|
init_cjs_shims();
|
|
10525
10525
|
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
10526
10526
|
|
|
10527
|
-
// src/zod
|
|
10527
|
+
// src/zod/model-helpers.ts
|
|
10528
10528
|
init_cjs_shims();
|
|
10529
10529
|
function checkModelHasModelRelation(model) {
|
|
10530
10530
|
const { fields: modelFields } = model;
|
|
@@ -10562,7 +10562,7 @@ function findModelByName(models, modelName) {
|
|
|
10562
10562
|
}
|
|
10563
10563
|
__name(findModelByName, "findModelByName");
|
|
10564
10564
|
|
|
10565
|
-
// src/zod
|
|
10565
|
+
// src/zod/mongodb-helpers.ts
|
|
10566
10566
|
init_cjs_shims();
|
|
10567
10567
|
function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
|
|
10568
10568
|
const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
|
|
@@ -10623,7 +10623,7 @@ function getMongoDbRawQueries(outputObjectTypes) {
|
|
|
10623
10623
|
__name(getMongoDbRawQueries, "getMongoDbRawQueries");
|
|
10624
10624
|
var isMongodbRawOp = /* @__PURE__ */ __name((name) => /find[\s\S]*?Raw/.test(name) || /aggregate[\s\S]*?Raw/.test(name), "isMongodbRawOp");
|
|
10625
10625
|
|
|
10626
|
-
// src/zod
|
|
10626
|
+
// src/zod/transformer.ts
|
|
10627
10627
|
var Transformer = class _Transformer {
|
|
10628
10628
|
static {
|
|
10629
10629
|
__name(this, "Transformer");
|
|
@@ -10705,7 +10705,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10705
10705
|
if (lines.length === 0) {
|
|
10706
10706
|
return [];
|
|
10707
10707
|
}
|
|
10708
|
-
let alternatives = lines.reduce((result, inputType) => {
|
|
10708
|
+
let alternatives = lines.slice(0, 1).reduce((result, inputType) => {
|
|
10709
10709
|
if (inputType.type === "String") {
|
|
10710
10710
|
result.push(this.wrapWithZodValidators("z.string()", field));
|
|
10711
10711
|
} else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
|
|
@@ -10729,7 +10729,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10729
10729
|
if (inputType.type !== this.name && typeof inputType.type === "string") {
|
|
10730
10730
|
this.addSchemaImport(inputType.type);
|
|
10731
10731
|
}
|
|
10732
|
-
result.push(this.generatePrismaStringLine(field, lines.length));
|
|
10732
|
+
result.push(this.generatePrismaStringLine(field, inputType, lines.length));
|
|
10733
10733
|
}
|
|
10734
10734
|
}
|
|
10735
10735
|
return result;
|
|
@@ -10768,11 +10768,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10768
10768
|
addSchemaImport(name) {
|
|
10769
10769
|
this.schemaImports.add(name);
|
|
10770
10770
|
}
|
|
10771
|
-
generatePrismaStringLine(field, inputsLength) {
|
|
10772
|
-
if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
|
|
10773
|
-
return "";
|
|
10774
|
-
}
|
|
10775
|
-
const inputType = field.inputTypes[0];
|
|
10771
|
+
generatePrismaStringLine(field, inputType, inputsLength) {
|
|
10776
10772
|
const isEnum = inputType.location === "enumTypes";
|
|
10777
10773
|
const inputTypeString = inputType.type;
|
|
10778
10774
|
const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
|
|
@@ -10898,8 +10894,8 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10898
10894
|
};
|
|
10899
10895
|
}
|
|
10900
10896
|
resolveModelQuerySchemaName(modelName, queryName) {
|
|
10901
|
-
const modelNameCapitalized =
|
|
10902
|
-
const queryNameCapitalized =
|
|
10897
|
+
const modelNameCapitalized = upperCaseFirst(modelName);
|
|
10898
|
+
const queryNameCapitalized = upperCaseFirst(queryName);
|
|
10903
10899
|
return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
|
|
10904
10900
|
}
|
|
10905
10901
|
wrapWithZodUnion(zodStringFields) {
|
|
@@ -11151,7 +11147,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11151
11147
|
}
|
|
11152
11148
|
};
|
|
11153
11149
|
|
|
11154
|
-
// src/zod
|
|
11150
|
+
// src/zod/generator-helpers.ts
|
|
11155
11151
|
async function generateZodEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
|
|
11156
11152
|
const enumTypes = [
|
|
11157
11153
|
...prismaSchemaEnum,
|
|
@@ -11191,10 +11187,10 @@ async function generateZodIndex() {
|
|
|
11191
11187
|
}
|
|
11192
11188
|
__name(generateZodIndex, "generateZodIndex");
|
|
11193
11189
|
|
|
11194
|
-
// src/zod
|
|
11190
|
+
// src/zod/helpers.ts
|
|
11195
11191
|
init_cjs_shims();
|
|
11196
11192
|
|
|
11197
|
-
// src/zod
|
|
11193
|
+
// src/zod/include-helpers.ts
|
|
11198
11194
|
init_cjs_shims();
|
|
11199
11195
|
function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
|
|
11200
11196
|
const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
|
|
@@ -11277,7 +11273,7 @@ function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
|
|
|
11277
11273
|
}
|
|
11278
11274
|
__name(generateModelIncludeInputObjectTypes, "generateModelIncludeInputObjectTypes");
|
|
11279
11275
|
|
|
11280
|
-
// src/zod
|
|
11276
|
+
// src/zod/modelArgs-helpers.ts
|
|
11281
11277
|
init_cjs_shims();
|
|
11282
11278
|
function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
|
|
11283
11279
|
const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
|
|
@@ -11338,7 +11334,7 @@ function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateI
|
|
|
11338
11334
|
}
|
|
11339
11335
|
__name(generateModelArgsInputObjectTypes, "generateModelArgsInputObjectTypes");
|
|
11340
11336
|
|
|
11341
|
-
// src/zod
|
|
11337
|
+
// src/zod/select-helpers.ts
|
|
11342
11338
|
init_cjs_shims();
|
|
11343
11339
|
function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
|
|
11344
11340
|
const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
|
|
@@ -11486,7 +11482,7 @@ function generateModelSelectInputObjectTypes(models) {
|
|
|
11486
11482
|
}
|
|
11487
11483
|
__name(generateModelSelectInputObjectTypes, "generateModelSelectInputObjectTypes");
|
|
11488
11484
|
|
|
11489
|
-
// src/zod
|
|
11485
|
+
// src/zod/whereUniqueInput-helpers.ts
|
|
11490
11486
|
init_cjs_shims();
|
|
11491
11487
|
function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
11492
11488
|
inputObjectTypes.map((item) => {
|
|
@@ -11505,7 +11501,7 @@ function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
|
11505
11501
|
}
|
|
11506
11502
|
__name(changeOptionalToRequiredFields, "changeOptionalToRequiredFields");
|
|
11507
11503
|
|
|
11508
|
-
// src/zod
|
|
11504
|
+
// src/zod/helpers.ts
|
|
11509
11505
|
function addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
|
|
11510
11506
|
if (dataSourceProvider === "mongodb") {
|
|
11511
11507
|
addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes);
|
package/dist/generator.js
CHANGED
|
@@ -6877,15 +6877,15 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
|
|
|
6877
6877
|
ModelAction2["findRaw"] = "findRaw";
|
|
6878
6878
|
ModelAction2["aggregateRaw"] = "aggregateRaw";
|
|
6879
6879
|
return ModelAction2;
|
|
6880
|
-
}(
|
|
6880
|
+
}({});
|
|
6881
6881
|
var modelActionEnum = z.nativeEnum(ModelAction);
|
|
6882
6882
|
var configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
|
|
6883
6883
|
var configSchema = z.object({
|
|
6884
6884
|
debug: configBoolean.default("false"),
|
|
6885
|
-
withMiddleware: configBoolean.default("false"),
|
|
6886
|
-
withShield: configBoolean.default("true"),
|
|
6887
6885
|
withZod: configBoolean.default("true"),
|
|
6888
6886
|
withNext: configBoolean.default("true"),
|
|
6887
|
+
withMiddleware: configBoolean.default("false"),
|
|
6888
|
+
withShield: configBoolean.default("false"),
|
|
6889
6889
|
contextPath: z.string().trim().default("../context"),
|
|
6890
6890
|
trpcOptions: configBoolean.default("true"),
|
|
6891
6891
|
showModelNameInProcedure: configBoolean.default("true"),
|
|
@@ -7630,9 +7630,6 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7630
7630
|
"permissions"
|
|
7631
7631
|
]
|
|
7632
7632
|
});
|
|
7633
|
-
sourceFile.formatText({
|
|
7634
|
-
indentSize: 2
|
|
7635
|
-
});
|
|
7636
7633
|
}
|
|
7637
7634
|
sourceFile.addStatements(
|
|
7638
7635
|
/* ts */
|
|
@@ -7750,6 +7747,9 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7750
7747
|
`
|
|
7751
7748
|
);
|
|
7752
7749
|
}
|
|
7750
|
+
sourceFile.formatText({
|
|
7751
|
+
indentSize: 2
|
|
7752
|
+
});
|
|
7753
7753
|
}
|
|
7754
7754
|
__name(generateTRPCExports, "generateTRPCExports");
|
|
7755
7755
|
function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
|
|
@@ -10360,7 +10360,7 @@ var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
|
10360
10360
|
await writeFileSafely(indexPath, rows.join("\n"), false);
|
|
10361
10361
|
}, "writeIndexFile");
|
|
10362
10362
|
|
|
10363
|
-
// src/zod
|
|
10363
|
+
// src/zod/aggregate-helpers.ts
|
|
10364
10364
|
init_esm_shims();
|
|
10365
10365
|
var isAggregateOutputType = /* @__PURE__ */ __name((name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name), "isAggregateOutputType");
|
|
10366
10366
|
var isAggregateInputType = /* @__PURE__ */ __name((name) => name.endsWith("CountAggregateInput") || name.endsWith("SumAggregateInput") || name.endsWith("AvgAggregateInput") || name.endsWith("MinAggregateInput") || name.endsWith("MaxAggregateInput"), "isAggregateInputType");
|
|
@@ -10432,7 +10432,7 @@ function resolveZodAggregateOperationSupport(inputObjectTypes) {
|
|
|
10432
10432
|
}
|
|
10433
10433
|
__name(resolveZodAggregateOperationSupport, "resolveZodAggregateOperationSupport");
|
|
10434
10434
|
|
|
10435
|
-
// src/zod
|
|
10435
|
+
// src/zod/comments-helpers.ts
|
|
10436
10436
|
init_esm_shims();
|
|
10437
10437
|
var modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
|
|
10438
10438
|
var attributeNameRegex = /\.+[A-Z]+\(+/i;
|
|
@@ -10522,14 +10522,14 @@ function hideZodInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels,
|
|
|
10522
10522
|
}
|
|
10523
10523
|
__name(hideZodInputObjectTypesAndRelatedFields, "hideZodInputObjectTypesAndRelatedFields");
|
|
10524
10524
|
|
|
10525
|
-
// src/zod
|
|
10525
|
+
// src/zod/generator-helpers.ts
|
|
10526
10526
|
init_esm_shims();
|
|
10527
10527
|
|
|
10528
|
-
// src/zod
|
|
10528
|
+
// src/zod/transformer.ts
|
|
10529
10529
|
init_esm_shims();
|
|
10530
10530
|
import path3 from "node:path";
|
|
10531
10531
|
|
|
10532
|
-
// src/zod
|
|
10532
|
+
// src/zod/model-helpers.ts
|
|
10533
10533
|
init_esm_shims();
|
|
10534
10534
|
function checkModelHasModelRelation(model) {
|
|
10535
10535
|
const { fields: modelFields } = model;
|
|
@@ -10567,7 +10567,7 @@ function findModelByName(models, modelName) {
|
|
|
10567
10567
|
}
|
|
10568
10568
|
__name(findModelByName, "findModelByName");
|
|
10569
10569
|
|
|
10570
|
-
// src/zod
|
|
10570
|
+
// src/zod/mongodb-helpers.ts
|
|
10571
10571
|
init_esm_shims();
|
|
10572
10572
|
function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
|
|
10573
10573
|
const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
|
|
@@ -10628,7 +10628,7 @@ function getMongoDbRawQueries(outputObjectTypes) {
|
|
|
10628
10628
|
__name(getMongoDbRawQueries, "getMongoDbRawQueries");
|
|
10629
10629
|
var isMongodbRawOp = /* @__PURE__ */ __name((name) => /find[\s\S]*?Raw/.test(name) || /aggregate[\s\S]*?Raw/.test(name), "isMongodbRawOp");
|
|
10630
10630
|
|
|
10631
|
-
// src/zod
|
|
10631
|
+
// src/zod/transformer.ts
|
|
10632
10632
|
var Transformer = class _Transformer {
|
|
10633
10633
|
static {
|
|
10634
10634
|
__name(this, "Transformer");
|
|
@@ -10710,7 +10710,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10710
10710
|
if (lines.length === 0) {
|
|
10711
10711
|
return [];
|
|
10712
10712
|
}
|
|
10713
|
-
let alternatives = lines.reduce((result, inputType) => {
|
|
10713
|
+
let alternatives = lines.slice(0, 1).reduce((result, inputType) => {
|
|
10714
10714
|
if (inputType.type === "String") {
|
|
10715
10715
|
result.push(this.wrapWithZodValidators("z.string()", field));
|
|
10716
10716
|
} else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
|
|
@@ -10734,7 +10734,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10734
10734
|
if (inputType.type !== this.name && typeof inputType.type === "string") {
|
|
10735
10735
|
this.addSchemaImport(inputType.type);
|
|
10736
10736
|
}
|
|
10737
|
-
result.push(this.generatePrismaStringLine(field, lines.length));
|
|
10737
|
+
result.push(this.generatePrismaStringLine(field, inputType, lines.length));
|
|
10738
10738
|
}
|
|
10739
10739
|
}
|
|
10740
10740
|
return result;
|
|
@@ -10773,11 +10773,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10773
10773
|
addSchemaImport(name) {
|
|
10774
10774
|
this.schemaImports.add(name);
|
|
10775
10775
|
}
|
|
10776
|
-
generatePrismaStringLine(field, inputsLength) {
|
|
10777
|
-
if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
|
|
10778
|
-
return "";
|
|
10779
|
-
}
|
|
10780
|
-
const inputType = field.inputTypes[0];
|
|
10776
|
+
generatePrismaStringLine(field, inputType, inputsLength) {
|
|
10781
10777
|
const isEnum = inputType.location === "enumTypes";
|
|
10782
10778
|
const inputTypeString = inputType.type;
|
|
10783
10779
|
const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
|
|
@@ -10903,8 +10899,8 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10903
10899
|
};
|
|
10904
10900
|
}
|
|
10905
10901
|
resolveModelQuerySchemaName(modelName, queryName) {
|
|
10906
|
-
const modelNameCapitalized =
|
|
10907
|
-
const queryNameCapitalized =
|
|
10902
|
+
const modelNameCapitalized = upperCaseFirst(modelName);
|
|
10903
|
+
const queryNameCapitalized = upperCaseFirst(queryName);
|
|
10908
10904
|
return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
|
|
10909
10905
|
}
|
|
10910
10906
|
wrapWithZodUnion(zodStringFields) {
|
|
@@ -11156,7 +11152,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11156
11152
|
}
|
|
11157
11153
|
};
|
|
11158
11154
|
|
|
11159
|
-
// src/zod
|
|
11155
|
+
// src/zod/generator-helpers.ts
|
|
11160
11156
|
async function generateZodEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
|
|
11161
11157
|
const enumTypes = [
|
|
11162
11158
|
...prismaSchemaEnum,
|
|
@@ -11196,10 +11192,10 @@ async function generateZodIndex() {
|
|
|
11196
11192
|
}
|
|
11197
11193
|
__name(generateZodIndex, "generateZodIndex");
|
|
11198
11194
|
|
|
11199
|
-
// src/zod
|
|
11195
|
+
// src/zod/helpers.ts
|
|
11200
11196
|
init_esm_shims();
|
|
11201
11197
|
|
|
11202
|
-
// src/zod
|
|
11198
|
+
// src/zod/include-helpers.ts
|
|
11203
11199
|
init_esm_shims();
|
|
11204
11200
|
function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
|
|
11205
11201
|
const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
|
|
@@ -11282,7 +11278,7 @@ function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
|
|
|
11282
11278
|
}
|
|
11283
11279
|
__name(generateModelIncludeInputObjectTypes, "generateModelIncludeInputObjectTypes");
|
|
11284
11280
|
|
|
11285
|
-
// src/zod
|
|
11281
|
+
// src/zod/modelArgs-helpers.ts
|
|
11286
11282
|
init_esm_shims();
|
|
11287
11283
|
function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
|
|
11288
11284
|
const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
|
|
@@ -11343,7 +11339,7 @@ function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateI
|
|
|
11343
11339
|
}
|
|
11344
11340
|
__name(generateModelArgsInputObjectTypes, "generateModelArgsInputObjectTypes");
|
|
11345
11341
|
|
|
11346
|
-
// src/zod
|
|
11342
|
+
// src/zod/select-helpers.ts
|
|
11347
11343
|
init_esm_shims();
|
|
11348
11344
|
function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
|
|
11349
11345
|
const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
|
|
@@ -11491,7 +11487,7 @@ function generateModelSelectInputObjectTypes(models) {
|
|
|
11491
11487
|
}
|
|
11492
11488
|
__name(generateModelSelectInputObjectTypes, "generateModelSelectInputObjectTypes");
|
|
11493
11489
|
|
|
11494
|
-
// src/zod
|
|
11490
|
+
// src/zod/whereUniqueInput-helpers.ts
|
|
11495
11491
|
init_esm_shims();
|
|
11496
11492
|
function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
11497
11493
|
inputObjectTypes.map((item) => {
|
|
@@ -11510,7 +11506,7 @@ function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
|
11510
11506
|
}
|
|
11511
11507
|
__name(changeOptionalToRequiredFields, "changeOptionalToRequiredFields");
|
|
11512
11508
|
|
|
11513
|
-
// src/zod
|
|
11509
|
+
// src/zod/helpers.ts
|
|
11514
11510
|
function addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
|
|
11515
11511
|
if (dataSourceProvider === "mongodb") {
|
|
11516
11512
|
addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes);
|
package/dist/index.cjs
CHANGED
|
@@ -6868,15 +6868,15 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
|
|
|
6868
6868
|
ModelAction2["findRaw"] = "findRaw";
|
|
6869
6869
|
ModelAction2["aggregateRaw"] = "aggregateRaw";
|
|
6870
6870
|
return ModelAction2;
|
|
6871
|
-
}(
|
|
6871
|
+
}({});
|
|
6872
6872
|
var modelActionEnum = z.nativeEnum(ModelAction);
|
|
6873
6873
|
var configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
|
|
6874
6874
|
var configSchema = z.object({
|
|
6875
6875
|
debug: configBoolean.default("false"),
|
|
6876
|
-
withMiddleware: configBoolean.default("false"),
|
|
6877
|
-
withShield: configBoolean.default("true"),
|
|
6878
6876
|
withZod: configBoolean.default("true"),
|
|
6879
6877
|
withNext: configBoolean.default("true"),
|
|
6878
|
+
withMiddleware: configBoolean.default("false"),
|
|
6879
|
+
withShield: configBoolean.default("false"),
|
|
6880
6880
|
contextPath: z.string().trim().default("../context"),
|
|
6881
6881
|
trpcOptions: configBoolean.default("true"),
|
|
6882
6882
|
showModelNameInProcedure: configBoolean.default("true"),
|
|
@@ -7621,9 +7621,6 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7621
7621
|
"permissions"
|
|
7622
7622
|
]
|
|
7623
7623
|
});
|
|
7624
|
-
sourceFile.formatText({
|
|
7625
|
-
indentSize: 2
|
|
7626
|
-
});
|
|
7627
7624
|
}
|
|
7628
7625
|
sourceFile.addStatements(
|
|
7629
7626
|
/* ts */
|
|
@@ -7741,6 +7738,9 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7741
7738
|
`
|
|
7742
7739
|
);
|
|
7743
7740
|
}
|
|
7741
|
+
sourceFile.formatText({
|
|
7742
|
+
indentSize: 2
|
|
7743
|
+
});
|
|
7744
7744
|
}
|
|
7745
7745
|
__name(generateTRPCExports, "generateTRPCExports");
|
|
7746
7746
|
function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
|
|
@@ -10351,7 +10351,7 @@ var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
|
10351
10351
|
await writeFileSafely(indexPath, rows.join("\n"), false);
|
|
10352
10352
|
}, "writeIndexFile");
|
|
10353
10353
|
|
|
10354
|
-
// src/zod
|
|
10354
|
+
// src/zod/aggregate-helpers.ts
|
|
10355
10355
|
init_cjs_shims();
|
|
10356
10356
|
var isAggregateOutputType = /* @__PURE__ */ __name((name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name), "isAggregateOutputType");
|
|
10357
10357
|
var isAggregateInputType = /* @__PURE__ */ __name((name) => name.endsWith("CountAggregateInput") || name.endsWith("SumAggregateInput") || name.endsWith("AvgAggregateInput") || name.endsWith("MinAggregateInput") || name.endsWith("MaxAggregateInput"), "isAggregateInputType");
|
|
@@ -10423,7 +10423,7 @@ function resolveZodAggregateOperationSupport(inputObjectTypes) {
|
|
|
10423
10423
|
}
|
|
10424
10424
|
__name(resolveZodAggregateOperationSupport, "resolveZodAggregateOperationSupport");
|
|
10425
10425
|
|
|
10426
|
-
// src/zod
|
|
10426
|
+
// src/zod/comments-helpers.ts
|
|
10427
10427
|
init_cjs_shims();
|
|
10428
10428
|
var modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
|
|
10429
10429
|
var attributeNameRegex = /\.+[A-Z]+\(+/i;
|
|
@@ -10513,14 +10513,14 @@ function hideZodInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels,
|
|
|
10513
10513
|
}
|
|
10514
10514
|
__name(hideZodInputObjectTypesAndRelatedFields, "hideZodInputObjectTypesAndRelatedFields");
|
|
10515
10515
|
|
|
10516
|
-
// src/zod
|
|
10516
|
+
// src/zod/generator-helpers.ts
|
|
10517
10517
|
init_cjs_shims();
|
|
10518
10518
|
|
|
10519
|
-
// src/zod
|
|
10519
|
+
// src/zod/transformer.ts
|
|
10520
10520
|
init_cjs_shims();
|
|
10521
10521
|
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
10522
10522
|
|
|
10523
|
-
// src/zod
|
|
10523
|
+
// src/zod/model-helpers.ts
|
|
10524
10524
|
init_cjs_shims();
|
|
10525
10525
|
function checkModelHasModelRelation(model) {
|
|
10526
10526
|
const { fields: modelFields } = model;
|
|
@@ -10558,7 +10558,7 @@ function findModelByName(models, modelName) {
|
|
|
10558
10558
|
}
|
|
10559
10559
|
__name(findModelByName, "findModelByName");
|
|
10560
10560
|
|
|
10561
|
-
// src/zod
|
|
10561
|
+
// src/zod/mongodb-helpers.ts
|
|
10562
10562
|
init_cjs_shims();
|
|
10563
10563
|
function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
|
|
10564
10564
|
const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
|
|
@@ -10619,7 +10619,7 @@ function getMongoDbRawQueries(outputObjectTypes) {
|
|
|
10619
10619
|
__name(getMongoDbRawQueries, "getMongoDbRawQueries");
|
|
10620
10620
|
var isMongodbRawOp = /* @__PURE__ */ __name((name) => /find[\s\S]*?Raw/.test(name) || /aggregate[\s\S]*?Raw/.test(name), "isMongodbRawOp");
|
|
10621
10621
|
|
|
10622
|
-
// src/zod
|
|
10622
|
+
// src/zod/transformer.ts
|
|
10623
10623
|
var Transformer = class _Transformer {
|
|
10624
10624
|
static {
|
|
10625
10625
|
__name(this, "Transformer");
|
|
@@ -10701,7 +10701,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10701
10701
|
if (lines.length === 0) {
|
|
10702
10702
|
return [];
|
|
10703
10703
|
}
|
|
10704
|
-
let alternatives = lines.reduce((result, inputType) => {
|
|
10704
|
+
let alternatives = lines.slice(0, 1).reduce((result, inputType) => {
|
|
10705
10705
|
if (inputType.type === "String") {
|
|
10706
10706
|
result.push(this.wrapWithZodValidators("z.string()", field));
|
|
10707
10707
|
} else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
|
|
@@ -10725,7 +10725,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10725
10725
|
if (inputType.type !== this.name && typeof inputType.type === "string") {
|
|
10726
10726
|
this.addSchemaImport(inputType.type);
|
|
10727
10727
|
}
|
|
10728
|
-
result.push(this.generatePrismaStringLine(field, lines.length));
|
|
10728
|
+
result.push(this.generatePrismaStringLine(field, inputType, lines.length));
|
|
10729
10729
|
}
|
|
10730
10730
|
}
|
|
10731
10731
|
return result;
|
|
@@ -10764,11 +10764,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10764
10764
|
addSchemaImport(name) {
|
|
10765
10765
|
this.schemaImports.add(name);
|
|
10766
10766
|
}
|
|
10767
|
-
generatePrismaStringLine(field, inputsLength) {
|
|
10768
|
-
if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
|
|
10769
|
-
return "";
|
|
10770
|
-
}
|
|
10771
|
-
const inputType = field.inputTypes[0];
|
|
10767
|
+
generatePrismaStringLine(field, inputType, inputsLength) {
|
|
10772
10768
|
const isEnum = inputType.location === "enumTypes";
|
|
10773
10769
|
const inputTypeString = inputType.type;
|
|
10774
10770
|
const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
|
|
@@ -10894,8 +10890,8 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10894
10890
|
};
|
|
10895
10891
|
}
|
|
10896
10892
|
resolveModelQuerySchemaName(modelName, queryName) {
|
|
10897
|
-
const modelNameCapitalized =
|
|
10898
|
-
const queryNameCapitalized =
|
|
10893
|
+
const modelNameCapitalized = upperCaseFirst(modelName);
|
|
10894
|
+
const queryNameCapitalized = upperCaseFirst(queryName);
|
|
10899
10895
|
return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
|
|
10900
10896
|
}
|
|
10901
10897
|
wrapWithZodUnion(zodStringFields) {
|
|
@@ -11147,7 +11143,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11147
11143
|
}
|
|
11148
11144
|
};
|
|
11149
11145
|
|
|
11150
|
-
// src/zod
|
|
11146
|
+
// src/zod/generator-helpers.ts
|
|
11151
11147
|
async function generateZodEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
|
|
11152
11148
|
const enumTypes = [
|
|
11153
11149
|
...prismaSchemaEnum,
|
|
@@ -11187,10 +11183,10 @@ async function generateZodIndex() {
|
|
|
11187
11183
|
}
|
|
11188
11184
|
__name(generateZodIndex, "generateZodIndex");
|
|
11189
11185
|
|
|
11190
|
-
// src/zod
|
|
11186
|
+
// src/zod/helpers.ts
|
|
11191
11187
|
init_cjs_shims();
|
|
11192
11188
|
|
|
11193
|
-
// src/zod
|
|
11189
|
+
// src/zod/include-helpers.ts
|
|
11194
11190
|
init_cjs_shims();
|
|
11195
11191
|
function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
|
|
11196
11192
|
const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
|
|
@@ -11273,7 +11269,7 @@ function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
|
|
|
11273
11269
|
}
|
|
11274
11270
|
__name(generateModelIncludeInputObjectTypes, "generateModelIncludeInputObjectTypes");
|
|
11275
11271
|
|
|
11276
|
-
// src/zod
|
|
11272
|
+
// src/zod/modelArgs-helpers.ts
|
|
11277
11273
|
init_cjs_shims();
|
|
11278
11274
|
function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
|
|
11279
11275
|
const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
|
|
@@ -11334,7 +11330,7 @@ function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateI
|
|
|
11334
11330
|
}
|
|
11335
11331
|
__name(generateModelArgsInputObjectTypes, "generateModelArgsInputObjectTypes");
|
|
11336
11332
|
|
|
11337
|
-
// src/zod
|
|
11333
|
+
// src/zod/select-helpers.ts
|
|
11338
11334
|
init_cjs_shims();
|
|
11339
11335
|
function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
|
|
11340
11336
|
const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
|
|
@@ -11482,7 +11478,7 @@ function generateModelSelectInputObjectTypes(models) {
|
|
|
11482
11478
|
}
|
|
11483
11479
|
__name(generateModelSelectInputObjectTypes, "generateModelSelectInputObjectTypes");
|
|
11484
11480
|
|
|
11485
|
-
// src/zod
|
|
11481
|
+
// src/zod/whereUniqueInput-helpers.ts
|
|
11486
11482
|
init_cjs_shims();
|
|
11487
11483
|
function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
11488
11484
|
inputObjectTypes.map((item) => {
|
|
@@ -11501,7 +11497,7 @@ function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
|
11501
11497
|
}
|
|
11502
11498
|
__name(changeOptionalToRequiredFields, "changeOptionalToRequiredFields");
|
|
11503
11499
|
|
|
11504
|
-
// src/zod
|
|
11500
|
+
// src/zod/helpers.ts
|
|
11505
11501
|
function addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
|
|
11506
11502
|
if (dataSourceProvider === "mongodb") {
|
|
11507
11503
|
addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes);
|
package/dist/index.js
CHANGED
|
@@ -6873,15 +6873,15 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
|
|
|
6873
6873
|
ModelAction2["findRaw"] = "findRaw";
|
|
6874
6874
|
ModelAction2["aggregateRaw"] = "aggregateRaw";
|
|
6875
6875
|
return ModelAction2;
|
|
6876
|
-
}(
|
|
6876
|
+
}({});
|
|
6877
6877
|
var modelActionEnum = z.nativeEnum(ModelAction);
|
|
6878
6878
|
var configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
|
|
6879
6879
|
var configSchema = z.object({
|
|
6880
6880
|
debug: configBoolean.default("false"),
|
|
6881
|
-
withMiddleware: configBoolean.default("false"),
|
|
6882
|
-
withShield: configBoolean.default("true"),
|
|
6883
6881
|
withZod: configBoolean.default("true"),
|
|
6884
6882
|
withNext: configBoolean.default("true"),
|
|
6883
|
+
withMiddleware: configBoolean.default("false"),
|
|
6884
|
+
withShield: configBoolean.default("false"),
|
|
6885
6885
|
contextPath: z.string().trim().default("../context"),
|
|
6886
6886
|
trpcOptions: configBoolean.default("true"),
|
|
6887
6887
|
showModelNameInProcedure: configBoolean.default("true"),
|
|
@@ -7626,9 +7626,6 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7626
7626
|
"permissions"
|
|
7627
7627
|
]
|
|
7628
7628
|
});
|
|
7629
|
-
sourceFile.formatText({
|
|
7630
|
-
indentSize: 2
|
|
7631
|
-
});
|
|
7632
7629
|
}
|
|
7633
7630
|
sourceFile.addStatements(
|
|
7634
7631
|
/* ts */
|
|
@@ -7746,6 +7743,9 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7746
7743
|
`
|
|
7747
7744
|
);
|
|
7748
7745
|
}
|
|
7746
|
+
sourceFile.formatText({
|
|
7747
|
+
indentSize: 2
|
|
7748
|
+
});
|
|
7749
7749
|
}
|
|
7750
7750
|
__name(generateTRPCExports, "generateTRPCExports");
|
|
7751
7751
|
function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
|
|
@@ -10356,7 +10356,7 @@ var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
|
10356
10356
|
await writeFileSafely(indexPath, rows.join("\n"), false);
|
|
10357
10357
|
}, "writeIndexFile");
|
|
10358
10358
|
|
|
10359
|
-
// src/zod
|
|
10359
|
+
// src/zod/aggregate-helpers.ts
|
|
10360
10360
|
init_esm_shims();
|
|
10361
10361
|
var isAggregateOutputType = /* @__PURE__ */ __name((name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name), "isAggregateOutputType");
|
|
10362
10362
|
var isAggregateInputType = /* @__PURE__ */ __name((name) => name.endsWith("CountAggregateInput") || name.endsWith("SumAggregateInput") || name.endsWith("AvgAggregateInput") || name.endsWith("MinAggregateInput") || name.endsWith("MaxAggregateInput"), "isAggregateInputType");
|
|
@@ -10428,7 +10428,7 @@ function resolveZodAggregateOperationSupport(inputObjectTypes) {
|
|
|
10428
10428
|
}
|
|
10429
10429
|
__name(resolveZodAggregateOperationSupport, "resolveZodAggregateOperationSupport");
|
|
10430
10430
|
|
|
10431
|
-
// src/zod
|
|
10431
|
+
// src/zod/comments-helpers.ts
|
|
10432
10432
|
init_esm_shims();
|
|
10433
10433
|
var modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
|
|
10434
10434
|
var attributeNameRegex = /\.+[A-Z]+\(+/i;
|
|
@@ -10518,14 +10518,14 @@ function hideZodInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels,
|
|
|
10518
10518
|
}
|
|
10519
10519
|
__name(hideZodInputObjectTypesAndRelatedFields, "hideZodInputObjectTypesAndRelatedFields");
|
|
10520
10520
|
|
|
10521
|
-
// src/zod
|
|
10521
|
+
// src/zod/generator-helpers.ts
|
|
10522
10522
|
init_esm_shims();
|
|
10523
10523
|
|
|
10524
|
-
// src/zod
|
|
10524
|
+
// src/zod/transformer.ts
|
|
10525
10525
|
init_esm_shims();
|
|
10526
10526
|
import path3 from "node:path";
|
|
10527
10527
|
|
|
10528
|
-
// src/zod
|
|
10528
|
+
// src/zod/model-helpers.ts
|
|
10529
10529
|
init_esm_shims();
|
|
10530
10530
|
function checkModelHasModelRelation(model) {
|
|
10531
10531
|
const { fields: modelFields } = model;
|
|
@@ -10563,7 +10563,7 @@ function findModelByName(models, modelName) {
|
|
|
10563
10563
|
}
|
|
10564
10564
|
__name(findModelByName, "findModelByName");
|
|
10565
10565
|
|
|
10566
|
-
// src/zod
|
|
10566
|
+
// src/zod/mongodb-helpers.ts
|
|
10567
10567
|
init_esm_shims();
|
|
10568
10568
|
function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
|
|
10569
10569
|
const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
|
|
@@ -10624,7 +10624,7 @@ function getMongoDbRawQueries(outputObjectTypes) {
|
|
|
10624
10624
|
__name(getMongoDbRawQueries, "getMongoDbRawQueries");
|
|
10625
10625
|
var isMongodbRawOp = /* @__PURE__ */ __name((name) => /find[\s\S]*?Raw/.test(name) || /aggregate[\s\S]*?Raw/.test(name), "isMongodbRawOp");
|
|
10626
10626
|
|
|
10627
|
-
// src/zod
|
|
10627
|
+
// src/zod/transformer.ts
|
|
10628
10628
|
var Transformer = class _Transformer {
|
|
10629
10629
|
static {
|
|
10630
10630
|
__name(this, "Transformer");
|
|
@@ -10706,7 +10706,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10706
10706
|
if (lines.length === 0) {
|
|
10707
10707
|
return [];
|
|
10708
10708
|
}
|
|
10709
|
-
let alternatives = lines.reduce((result, inputType) => {
|
|
10709
|
+
let alternatives = lines.slice(0, 1).reduce((result, inputType) => {
|
|
10710
10710
|
if (inputType.type === "String") {
|
|
10711
10711
|
result.push(this.wrapWithZodValidators("z.string()", field));
|
|
10712
10712
|
} else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
|
|
@@ -10730,7 +10730,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10730
10730
|
if (inputType.type !== this.name && typeof inputType.type === "string") {
|
|
10731
10731
|
this.addSchemaImport(inputType.type);
|
|
10732
10732
|
}
|
|
10733
|
-
result.push(this.generatePrismaStringLine(field, lines.length));
|
|
10733
|
+
result.push(this.generatePrismaStringLine(field, inputType, lines.length));
|
|
10734
10734
|
}
|
|
10735
10735
|
}
|
|
10736
10736
|
return result;
|
|
@@ -10769,11 +10769,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10769
10769
|
addSchemaImport(name) {
|
|
10770
10770
|
this.schemaImports.add(name);
|
|
10771
10771
|
}
|
|
10772
|
-
generatePrismaStringLine(field, inputsLength) {
|
|
10773
|
-
if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
|
|
10774
|
-
return "";
|
|
10775
|
-
}
|
|
10776
|
-
const inputType = field.inputTypes[0];
|
|
10772
|
+
generatePrismaStringLine(field, inputType, inputsLength) {
|
|
10777
10773
|
const isEnum = inputType.location === "enumTypes";
|
|
10778
10774
|
const inputTypeString = inputType.type;
|
|
10779
10775
|
const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
|
|
@@ -10899,8 +10895,8 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10899
10895
|
};
|
|
10900
10896
|
}
|
|
10901
10897
|
resolveModelQuerySchemaName(modelName, queryName) {
|
|
10902
|
-
const modelNameCapitalized =
|
|
10903
|
-
const queryNameCapitalized =
|
|
10898
|
+
const modelNameCapitalized = upperCaseFirst(modelName);
|
|
10899
|
+
const queryNameCapitalized = upperCaseFirst(queryName);
|
|
10904
10900
|
return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
|
|
10905
10901
|
}
|
|
10906
10902
|
wrapWithZodUnion(zodStringFields) {
|
|
@@ -11152,7 +11148,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11152
11148
|
}
|
|
11153
11149
|
};
|
|
11154
11150
|
|
|
11155
|
-
// src/zod
|
|
11151
|
+
// src/zod/generator-helpers.ts
|
|
11156
11152
|
async function generateZodEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
|
|
11157
11153
|
const enumTypes = [
|
|
11158
11154
|
...prismaSchemaEnum,
|
|
@@ -11192,10 +11188,10 @@ async function generateZodIndex() {
|
|
|
11192
11188
|
}
|
|
11193
11189
|
__name(generateZodIndex, "generateZodIndex");
|
|
11194
11190
|
|
|
11195
|
-
// src/zod
|
|
11191
|
+
// src/zod/helpers.ts
|
|
11196
11192
|
init_esm_shims();
|
|
11197
11193
|
|
|
11198
|
-
// src/zod
|
|
11194
|
+
// src/zod/include-helpers.ts
|
|
11199
11195
|
init_esm_shims();
|
|
11200
11196
|
function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
|
|
11201
11197
|
const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
|
|
@@ -11278,7 +11274,7 @@ function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
|
|
|
11278
11274
|
}
|
|
11279
11275
|
__name(generateModelIncludeInputObjectTypes, "generateModelIncludeInputObjectTypes");
|
|
11280
11276
|
|
|
11281
|
-
// src/zod
|
|
11277
|
+
// src/zod/modelArgs-helpers.ts
|
|
11282
11278
|
init_esm_shims();
|
|
11283
11279
|
function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
|
|
11284
11280
|
const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
|
|
@@ -11339,7 +11335,7 @@ function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateI
|
|
|
11339
11335
|
}
|
|
11340
11336
|
__name(generateModelArgsInputObjectTypes, "generateModelArgsInputObjectTypes");
|
|
11341
11337
|
|
|
11342
|
-
// src/zod
|
|
11338
|
+
// src/zod/select-helpers.ts
|
|
11343
11339
|
init_esm_shims();
|
|
11344
11340
|
function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
|
|
11345
11341
|
const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
|
|
@@ -11487,7 +11483,7 @@ function generateModelSelectInputObjectTypes(models) {
|
|
|
11487
11483
|
}
|
|
11488
11484
|
__name(generateModelSelectInputObjectTypes, "generateModelSelectInputObjectTypes");
|
|
11489
11485
|
|
|
11490
|
-
// src/zod
|
|
11486
|
+
// src/zod/whereUniqueInput-helpers.ts
|
|
11491
11487
|
init_esm_shims();
|
|
11492
11488
|
function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
11493
11489
|
inputObjectTypes.map((item) => {
|
|
@@ -11506,7 +11502,7 @@ function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
|
11506
11502
|
}
|
|
11507
11503
|
__name(changeOptionalToRequiredFields, "changeOptionalToRequiredFields");
|
|
11508
11504
|
|
|
11509
|
-
// src/zod
|
|
11505
|
+
// src/zod/helpers.ts
|
|
11510
11506
|
function addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
|
|
11511
11507
|
if (dataSourceProvider === "mongodb") {
|
|
11512
11508
|
addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes);
|