@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.
- package/dist/generator.cjs +14 -11
- package/dist/generator.js +14 -11
- package/dist/index.cjs +14 -11
- package/dist/index.js +14 -11
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -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
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
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
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
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
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
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
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
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;
|