@stryke/prisma-trpc-generator 0.4.0 → 0.4.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.
@@ -10721,17 +10721,20 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10721
10721
  this.schemaImports.add(name);
10722
10722
  }
10723
10723
  generatePrismaStringLine(field, inputsLength) {
10724
- return field.inputTypes.map((inputType) => {
10725
- const isEnum = inputType.location === "enumTypes";
10726
- const inputTypeString = inputType.type;
10727
- const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10728
- const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10729
- const enumSchemaLine = `${inputTypeString}Schema`;
10730
- const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10731
- const arr = inputType.isList ? ".array()" : "";
10732
- const opt = !field.isRequired ? ".optional()" : "";
10733
- return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}` : `z.lazy(() => ${schema})${arr}${opt}`;
10734
- }).join(",\r\n");
10724
+ if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10725
+ return "";
10726
+ }
10727
+ const inputType = field.inputTypes[0];
10728
+ const isEnum = inputType.location === "enumTypes";
10729
+ const inputTypeString = inputType.type;
10730
+ const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10731
+ const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10732
+ const enumSchemaLine = `${inputTypeString}Schema`;
10733
+ const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10734
+ const arr = inputType.isList ? ".array()" : "";
10735
+ const opt = !field.isRequired ? ".optional()" : "";
10736
+ const nullable = field.inputTypes.length > 1 && field.inputTypes[1]?.type === "Null" ? ".nullable()" : "";
10737
+ return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}${nullable}` : `z.lazy(() => ${schema})${arr}${opt}${nullable}`;
10735
10738
  }
10736
10739
  generateFieldValidators(zodStringWithMainType, field) {
10737
10740
  const { isRequired, isNullable } = field;
package/dist/generator.js CHANGED
@@ -10726,17 +10726,20 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10726
10726
  this.schemaImports.add(name);
10727
10727
  }
10728
10728
  generatePrismaStringLine(field, inputsLength) {
10729
- return field.inputTypes.map((inputType) => {
10730
- const isEnum = inputType.location === "enumTypes";
10731
- const inputTypeString = inputType.type;
10732
- const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10733
- const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10734
- const enumSchemaLine = `${inputTypeString}Schema`;
10735
- const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10736
- const arr = inputType.isList ? ".array()" : "";
10737
- const opt = !field.isRequired ? ".optional()" : "";
10738
- return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}` : `z.lazy(() => ${schema})${arr}${opt}`;
10739
- }).join(",\r\n");
10729
+ if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10730
+ return "";
10731
+ }
10732
+ const inputType = field.inputTypes[0];
10733
+ const isEnum = inputType.location === "enumTypes";
10734
+ const inputTypeString = inputType.type;
10735
+ const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10736
+ const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10737
+ const enumSchemaLine = `${inputTypeString}Schema`;
10738
+ const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10739
+ const arr = inputType.isList ? ".array()" : "";
10740
+ const opt = !field.isRequired ? ".optional()" : "";
10741
+ const nullable = field.inputTypes.length > 1 && field.inputTypes[1]?.type === "Null" ? ".nullable()" : "";
10742
+ return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}${nullable}` : `z.lazy(() => ${schema})${arr}${opt}${nullable}`;
10740
10743
  }
10741
10744
  generateFieldValidators(zodStringWithMainType, field) {
10742
10745
  const { isRequired, isNullable } = field;
package/dist/index.cjs CHANGED
@@ -10717,17 +10717,20 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10717
10717
  this.schemaImports.add(name);
10718
10718
  }
10719
10719
  generatePrismaStringLine(field, inputsLength) {
10720
- return field.inputTypes.map((inputType) => {
10721
- const isEnum = inputType.location === "enumTypes";
10722
- const inputTypeString = inputType.type;
10723
- const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10724
- const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10725
- const enumSchemaLine = `${inputTypeString}Schema`;
10726
- const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10727
- const arr = inputType.isList ? ".array()" : "";
10728
- const opt = !field.isRequired ? ".optional()" : "";
10729
- return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}` : `z.lazy(() => ${schema})${arr}${opt}`;
10730
- }).join(",\r\n");
10720
+ if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10721
+ return "";
10722
+ }
10723
+ const inputType = field.inputTypes[0];
10724
+ const isEnum = inputType.location === "enumTypes";
10725
+ const inputTypeString = inputType.type;
10726
+ const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10727
+ const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10728
+ const enumSchemaLine = `${inputTypeString}Schema`;
10729
+ const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10730
+ const arr = inputType.isList ? ".array()" : "";
10731
+ const opt = !field.isRequired ? ".optional()" : "";
10732
+ const nullable = field.inputTypes.length > 1 && field.inputTypes[1]?.type === "Null" ? ".nullable()" : "";
10733
+ return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}${nullable}` : `z.lazy(() => ${schema})${arr}${opt}${nullable}`;
10731
10734
  }
10732
10735
  generateFieldValidators(zodStringWithMainType, field) {
10733
10736
  const { isRequired, isNullable } = field;
package/dist/index.js CHANGED
@@ -10722,17 +10722,20 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10722
10722
  this.schemaImports.add(name);
10723
10723
  }
10724
10724
  generatePrismaStringLine(field, inputsLength) {
10725
- return field.inputTypes.map((inputType) => {
10726
- const isEnum = inputType.location === "enumTypes";
10727
- const inputTypeString = inputType.type;
10728
- const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10729
- const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10730
- const enumSchemaLine = `${inputTypeString}Schema`;
10731
- const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10732
- const arr = inputType.isList ? ".array()" : "";
10733
- const opt = !field.isRequired ? ".optional()" : "";
10734
- return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}` : `z.lazy(() => ${schema})${arr}${opt}`;
10735
- }).join(",\r\n");
10725
+ if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10726
+ return "";
10727
+ }
10728
+ const inputType = field.inputTypes[0];
10729
+ const isEnum = inputType.location === "enumTypes";
10730
+ const inputTypeString = inputType.type;
10731
+ const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10732
+ const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10733
+ const enumSchemaLine = `${inputTypeString}Schema`;
10734
+ const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10735
+ const arr = inputType.isList ? ".array()" : "";
10736
+ const opt = !field.isRequired ? ".optional()" : "";
10737
+ const nullable = field.inputTypes.length > 1 && field.inputTypes[1]?.type === "Null" ? ".nullable()" : "";
10738
+ return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}${nullable}` : `z.lazy(() => ${schema})${arr}${opt}${nullable}`;
10736
10739
  }
10737
10740
  generateFieldValidators(zodStringWithMainType, field) {
10738
10741
  const { isRequired, isNullable } = field;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-trpc-generator",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "A fork of the prisma-trpc-generator code to work in ESM with Prisma v6.",
6
6
  "repository": {