@stryke/prisma-trpc-generator 0.2.12 → 0.2.13

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.js CHANGED
@@ -673,1568 +673,6 @@ var require_pluralize = __commonJS({
673
673
  }
674
674
  });
675
675
 
676
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/comments-helpers.js
677
- var require_comments_helpers = __commonJS({
678
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/comments-helpers.js"(exports) {
679
- "use strict";
680
- init_esm_shims();
681
- Object.defineProperty(exports, "__esModule", {
682
- value: true
683
- });
684
- exports.hideInputObjectTypesAndRelatedFields = exports.resolveModelsComments = void 0;
685
- var modelAttributeRegex = /(@@Gen\.)+([A-z])+(\()+(.+)+(\))+/;
686
- var attributeNameRegex = /(?:\.)+([A-Za-z])+(?:\()+/;
687
- var attributeArgsRegex = /(?:\()+([A-Za-z])+\:+(.+)+(?:\))+/;
688
- function resolveModelsComments2(models, modelOperations, enumTypes, hiddenModels, hiddenFields) {
689
- models = collectHiddenModels(models, hiddenModels);
690
- collectHiddenFields(models, hiddenModels, hiddenFields);
691
- hideModelOperations(models, modelOperations);
692
- hideEnums(enumTypes, hiddenModels);
693
- }
694
- __name(resolveModelsComments2, "resolveModelsComments");
695
- exports.resolveModelsComments = resolveModelsComments2;
696
- function collectHiddenModels(models, hiddenModels) {
697
- return models.map((model) => {
698
- var _a, _b, _c, _d, _e, _f;
699
- if (model.documentation) {
700
- const attribute = (_b = (_a = model.documentation) === null || _a === void 0 ? void 0 : _a.match(modelAttributeRegex)) === null || _b === void 0 ? void 0 : _b[0];
701
- const attributeName = (_d = (_c = attribute === null || attribute === void 0 ? void 0 : attribute.match(attributeNameRegex)) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.slice(1, -1);
702
- if (attributeName !== "model") model;
703
- const rawAttributeArgs = (_f = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.match(attributeArgsRegex)) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.slice(1, -1);
704
- const parsedAttributeArgs = {};
705
- if (rawAttributeArgs) {
706
- const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
707
- for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
708
- const key = rawAttributeArgsParts[i];
709
- const value = rawAttributeArgsParts[i + 1];
710
- parsedAttributeArgs[key] = JSON.parse(value);
711
- }
712
- }
713
- if (parsedAttributeArgs.hide) {
714
- hiddenModels.push(model.name);
715
- return null;
716
- }
717
- }
718
- return model;
719
- }).filter(Boolean);
720
- }
721
- __name(collectHiddenModels, "collectHiddenModels");
722
- function collectHiddenFields(models, hiddenModels, hiddenFields) {
723
- models.forEach((model) => {
724
- model.fields.forEach((field) => {
725
- if (hiddenModels.includes(field.type)) {
726
- hiddenFields.push(field.name);
727
- if (field.relationFromFields) {
728
- field.relationFromFields.forEach((item) => hiddenFields.push(item));
729
- }
730
- }
731
- });
732
- });
733
- }
734
- __name(collectHiddenFields, "collectHiddenFields");
735
- function hideEnums(enumTypes, hiddenModels) {
736
- enumTypes.prisma = enumTypes.prisma.filter((item) => !hiddenModels.find((model) => item.name.startsWith(model)));
737
- }
738
- __name(hideEnums, "hideEnums");
739
- function hideModelOperations(models, modelOperations) {
740
- let i = modelOperations.length;
741
- while (i >= 0) {
742
- --i;
743
- const modelOperation = modelOperations[i];
744
- if (modelOperation && !models.find((model) => {
745
- return model.name === modelOperation.model;
746
- })) {
747
- modelOperations.splice(i, 1);
748
- }
749
- }
750
- }
751
- __name(hideModelOperations, "hideModelOperations");
752
- function hideInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels, hiddenFields) {
753
- var _a, _b, _c, _d;
754
- let j = inputObjectTypes.length;
755
- while (j >= 0) {
756
- --j;
757
- const inputType = inputObjectTypes[j];
758
- if (inputType && (hiddenModels.includes((_a = inputType === null || inputType === void 0 ? void 0 : inputType.meta) === null || _a === void 0 ? void 0 : _a.source) || hiddenModels.find((model) => inputType.name.startsWith(model)))) {
759
- inputObjectTypes.splice(j, 1);
760
- } else {
761
- let k = (_c = (_b = inputType === null || inputType === void 0 ? void 0 : inputType.fields) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
762
- while (k >= 0) {
763
- --k;
764
- const field = (_d = inputType === null || inputType === void 0 ? void 0 : inputType.fields) === null || _d === void 0 ? void 0 : _d[k];
765
- if (field && hiddenFields.includes(field.name)) {
766
- inputObjectTypes[j].fields.splice(k, 1);
767
- }
768
- }
769
- }
770
- }
771
- }
772
- __name(hideInputObjectTypesAndRelatedFields, "hideInputObjectTypesAndRelatedFields");
773
- exports.hideInputObjectTypesAndRelatedFields = hideInputObjectTypesAndRelatedFields;
774
- }
775
- });
776
-
777
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/aggregate-helpers.js
778
- var require_aggregate_helpers = __commonJS({
779
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/aggregate-helpers.js"(exports) {
780
- "use strict";
781
- init_esm_shims();
782
- Object.defineProperty(exports, "__esModule", {
783
- value: true
784
- });
785
- exports.resolveAggregateOperationSupport = exports.addMissingInputObjectTypesForAggregate = exports.isAggregateInputType = void 0;
786
- var isAggregateOutputType = /* @__PURE__ */ __name((name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name), "isAggregateOutputType");
787
- var isAggregateInputType = /* @__PURE__ */ __name((name) => name.endsWith("CountAggregateInput") || name.endsWith("SumAggregateInput") || name.endsWith("AvgAggregateInput") || name.endsWith("MinAggregateInput") || name.endsWith("MaxAggregateInput"), "isAggregateInputType");
788
- exports.isAggregateInputType = isAggregateInputType;
789
- function addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes) {
790
- const aggregateOutputTypes = outputObjectTypes.filter(({ name }) => isAggregateOutputType(name));
791
- for (const aggregateOutputType of aggregateOutputTypes) {
792
- const name = aggregateOutputType.name.replace(/(?:OutputType|Output)$/, "");
793
- inputObjectTypes.push({
794
- constraints: {
795
- maxNumFields: null,
796
- minNumFields: null
797
- },
798
- name: `${name}Input`,
799
- fields: aggregateOutputType.fields.map((field) => ({
800
- name: field.name,
801
- isNullable: false,
802
- isRequired: false,
803
- inputTypes: [
804
- {
805
- isList: false,
806
- type: "True",
807
- location: "scalar"
808
- }
809
- ]
810
- }))
811
- });
812
- }
813
- }
814
- __name(addMissingInputObjectTypesForAggregate, "addMissingInputObjectTypesForAggregate");
815
- exports.addMissingInputObjectTypesForAggregate = addMissingInputObjectTypesForAggregate;
816
- function resolveAggregateOperationSupport(inputObjectTypes) {
817
- const aggregateOperationSupport = {};
818
- for (const inputType of inputObjectTypes) {
819
- if ((0, exports.isAggregateInputType)(inputType.name)) {
820
- const name = inputType.name.replace("AggregateInput", "");
821
- if (name.endsWith("Count")) {
822
- const model = name.replace("Count", "");
823
- aggregateOperationSupport[model] = {
824
- ...aggregateOperationSupport[model],
825
- count: true
826
- };
827
- } else if (name.endsWith("Min")) {
828
- const model = name.replace("Min", "");
829
- aggregateOperationSupport[model] = {
830
- ...aggregateOperationSupport[model],
831
- min: true
832
- };
833
- } else if (name.endsWith("Max")) {
834
- const model = name.replace("Max", "");
835
- aggregateOperationSupport[model] = {
836
- ...aggregateOperationSupport[model],
837
- max: true
838
- };
839
- } else if (name.endsWith("Sum")) {
840
- const model = name.replace("Sum", "");
841
- aggregateOperationSupport[model] = {
842
- ...aggregateOperationSupport[model],
843
- sum: true
844
- };
845
- } else if (name.endsWith("Avg")) {
846
- const model = name.replace("Avg", "");
847
- aggregateOperationSupport[model] = {
848
- ...aggregateOperationSupport[model],
849
- avg: true
850
- };
851
- }
852
- }
853
- }
854
- return aggregateOperationSupport;
855
- }
856
- __name(resolveAggregateOperationSupport, "resolveAggregateOperationSupport");
857
- exports.resolveAggregateOperationSupport = resolveAggregateOperationSupport;
858
- }
859
- });
860
-
861
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/formatFile.js
862
- var require_formatFile = __commonJS({
863
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/formatFile.js"(exports) {
864
- "use strict";
865
- init_esm_shims();
866
- var __importDefault = exports && exports.__importDefault || function(mod) {
867
- return mod && mod.__esModule ? mod : {
868
- "default": mod
869
- };
870
- };
871
- Object.defineProperty(exports, "__esModule", {
872
- value: true
873
- });
874
- exports.formatFile = void 0;
875
- var prettier_1 = __importDefault(__require("prettier"));
876
- var formatFile2 = /* @__PURE__ */ __name((content) => {
877
- return new Promise((res, rej) => prettier_1.default.resolveConfig(process.cwd()).then((options) => {
878
- let formatOptions = options;
879
- if (!options) {
880
- formatOptions = {
881
- trailingComma: "all",
882
- tabWidth: 2,
883
- printWidth: 80,
884
- bracketSpacing: true,
885
- semi: true,
886
- singleQuote: true,
887
- useTabs: false
888
- };
889
- }
890
- try {
891
- const formatted = prettier_1.default.format(content, {
892
- ...formatOptions,
893
- parser: "typescript"
894
- });
895
- res(formatted);
896
- } catch (error) {
897
- rej(error);
898
- }
899
- }));
900
- }, "formatFile");
901
- exports.formatFile = formatFile2;
902
- }
903
- });
904
-
905
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/writeIndexFile.js
906
- var require_writeIndexFile = __commonJS({
907
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/writeIndexFile.js"(exports) {
908
- "use strict";
909
- init_esm_shims();
910
- var __importDefault = exports && exports.__importDefault || function(mod) {
911
- return mod && mod.__esModule ? mod : {
912
- "default": mod
913
- };
914
- };
915
- Object.defineProperty(exports, "__esModule", {
916
- value: true
917
- });
918
- exports.writeIndexFile = exports.addIndexExport = void 0;
919
- var path_1 = __importDefault(__require("path"));
920
- var writeFileSafely_1 = require_writeFileSafely();
921
- var indexExports = /* @__PURE__ */ new Set();
922
- var addIndexExport = /* @__PURE__ */ __name((filePath) => {
923
- indexExports.add(filePath);
924
- }, "addIndexExport");
925
- exports.addIndexExport = addIndexExport;
926
- function normalizePath(path7) {
927
- if (typeof path7 !== "string") {
928
- throw new TypeError("Expected argument path to be a string");
929
- }
930
- if (path7 === "\\" || path7 === "/") return "/";
931
- let len = path7.length;
932
- if (len <= 1) return path7;
933
- let prefix = "";
934
- if (len > 4 && path7[3] === "\\") {
935
- let ch = path7[2];
936
- if ((ch === "?" || ch === ".") && path7.slice(0, 2) === "\\\\") {
937
- path7 = path7.slice(2);
938
- prefix = "//";
939
- }
940
- }
941
- let segs = path7.split(/[/\\]+/);
942
- return prefix + segs.join("/");
943
- }
944
- __name(normalizePath, "normalizePath");
945
- var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
946
- const rows = Array.from(indexExports).map((filePath) => {
947
- let relativePath = path_1.default.relative(path_1.default.dirname(indexPath), filePath);
948
- if (relativePath.endsWith(".ts")) {
949
- relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
950
- }
951
- const normalized = normalizePath(relativePath);
952
- return `export * from './${normalized}'`;
953
- });
954
- const content = rows.join("\n");
955
- await (0, writeFileSafely_1.writeFileSafely)(indexPath, content, false);
956
- }, "writeIndexFile");
957
- exports.writeIndexFile = writeIndexFile;
958
- }
959
- });
960
-
961
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/writeFileSafely.js
962
- var require_writeFileSafely = __commonJS({
963
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/writeFileSafely.js"(exports) {
964
- "use strict";
965
- init_esm_shims();
966
- var __importDefault = exports && exports.__importDefault || function(mod) {
967
- return mod && mod.__esModule ? mod : {
968
- "default": mod
969
- };
970
- };
971
- Object.defineProperty(exports, "__esModule", {
972
- value: true
973
- });
974
- exports.writeFileSafely = void 0;
975
- var fs_1 = __importDefault(__require("fs"));
976
- var path_1 = __importDefault(__require("path"));
977
- var formatFile_1 = require_formatFile();
978
- var writeIndexFile_1 = require_writeIndexFile();
979
- var writeFileSafely2 = /* @__PURE__ */ __name(async (writeLocation, content, addToIndex = true) => {
980
- fs_1.default.mkdirSync(path_1.default.dirname(writeLocation), {
981
- recursive: true
982
- });
983
- fs_1.default.writeFileSync(writeLocation, await (0, formatFile_1.formatFile)(content));
984
- if (addToIndex) {
985
- (0, writeIndexFile_1.addIndexExport)(writeLocation);
986
- }
987
- }, "writeFileSafely");
988
- exports.writeFileSafely = writeFileSafely2;
989
- }
990
- });
991
-
992
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/transformer.js
993
- var require_transformer = __commonJS({
994
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/transformer.js"(exports) {
995
- "use strict";
996
- init_esm_shims();
997
- var __importDefault = exports && exports.__importDefault || function(mod) {
998
- return mod && mod.__esModule ? mod : {
999
- "default": mod
1000
- };
1001
- };
1002
- Object.defineProperty(exports, "__esModule", {
1003
- value: true
1004
- });
1005
- var path_1 = __importDefault(__require("path"));
1006
- var helpers_1 = require_helpers2();
1007
- var aggregate_helpers_1 = require_aggregate_helpers();
1008
- var writeFileSafely_1 = require_writeFileSafely();
1009
- var writeIndexFile_1 = require_writeIndexFile();
1010
- var Transformer = class Transformer2 {
1011
- static {
1012
- __name(this, "Transformer");
1013
- }
1014
- constructor(params) {
1015
- var _a, _b, _c, _d, _e, _f;
1016
- this.schemaImports = /* @__PURE__ */ new Set();
1017
- this.hasJson = false;
1018
- this.name = (_a = params.name) !== null && _a !== void 0 ? _a : "";
1019
- this.fields = (_b = params.fields) !== null && _b !== void 0 ? _b : [];
1020
- this.models = (_c = params.models) !== null && _c !== void 0 ? _c : [];
1021
- this.modelOperations = (_d = params.modelOperations) !== null && _d !== void 0 ? _d : [];
1022
- this.aggregateOperationSupport = (_e = params.aggregateOperationSupport) !== null && _e !== void 0 ? _e : {};
1023
- this.enumTypes = (_f = params.enumTypes) !== null && _f !== void 0 ? _f : [];
1024
- }
1025
- static setOutputPath(outPath) {
1026
- this.outputPath = outPath;
1027
- }
1028
- static setIsGenerateSelect(isGenerateSelect) {
1029
- this.isGenerateSelect = isGenerateSelect;
1030
- }
1031
- static setIsGenerateInclude(isGenerateInclude) {
1032
- this.isGenerateInclude = isGenerateInclude;
1033
- }
1034
- static getOutputPath() {
1035
- return this.outputPath;
1036
- }
1037
- static setPrismaClientOutputPath(prismaClientCustomPath) {
1038
- this.prismaClientOutputPath = prismaClientCustomPath;
1039
- this.isCustomPrismaClientOutputPath = prismaClientCustomPath !== "@prisma/client";
1040
- }
1041
- static async generateIndex() {
1042
- const indexPath = path_1.default.join(Transformer2.outputPath, "schemas/index.ts");
1043
- await (0, writeIndexFile_1.writeIndexFile)(indexPath);
1044
- }
1045
- async generateEnumSchemas() {
1046
- for (const enumType2 of this.enumTypes) {
1047
- const { name, values } = enumType2;
1048
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/enums/${name}.schema.ts`), `${this.generateImportZodStatement()}
1049
- ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)})`)}`);
1050
- }
1051
- }
1052
- generateImportZodStatement() {
1053
- return "import { z } from 'zod';\n";
1054
- }
1055
- generateExportSchemaStatement(name, schema) {
1056
- return `export const ${name}Schema = ${schema}`;
1057
- }
1058
- async generateObjectSchema() {
1059
- const zodObjectSchemaFields = this.generateObjectSchemaFields();
1060
- const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);
1061
- const objectSchemaName = this.resolveObjectSchemaName();
1062
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/objects/${objectSchemaName}.schema.ts`), objectSchema);
1063
- }
1064
- generateObjectSchemaFields() {
1065
- const zodObjectSchemaFields = this.fields.map((field) => this.generateObjectSchemaField(field)).flatMap((item) => item).map((item) => {
1066
- const [zodStringWithMainType, field, skipValidators] = item;
1067
- const value = skipValidators ? zodStringWithMainType : this.generateFieldValidators(zodStringWithMainType, field);
1068
- return value.trim();
1069
- });
1070
- return zodObjectSchemaFields;
1071
- }
1072
- generateObjectSchemaField(field) {
1073
- let lines = field.inputTypes;
1074
- if (lines.length === 0) {
1075
- return [];
1076
- }
1077
- let alternatives = lines.reduce((result, inputType) => {
1078
- if (inputType.type === "String") {
1079
- result.push(this.wrapWithZodValidators("z.string()", field, inputType));
1080
- } else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
1081
- result.push(this.wrapWithZodValidators("z.number()", field, inputType));
1082
- } else if (inputType.type === "BigInt") {
1083
- result.push(this.wrapWithZodValidators("z.bigint()", field, inputType));
1084
- } else if (inputType.type === "Boolean") {
1085
- result.push(this.wrapWithZodValidators("z.boolean()", field, inputType));
1086
- } else if (inputType.type === "DateTime") {
1087
- result.push(this.wrapWithZodValidators("z.coerce.date()", field, inputType));
1088
- } else if (inputType.type === "Json") {
1089
- this.hasJson = true;
1090
- result.push(this.wrapWithZodValidators("jsonSchema", field, inputType));
1091
- } else if (inputType.type === "True") {
1092
- result.push(this.wrapWithZodValidators("z.literal(true)", field, inputType));
1093
- } else if (inputType.type === "Bytes") {
1094
- result.push(this.wrapWithZodValidators("z.instanceof(Buffer)", field, inputType));
1095
- } else {
1096
- const isEnum = inputType.location === "enumTypes";
1097
- if (inputType.namespace === "prisma" || isEnum) {
1098
- if (inputType.type !== this.name && typeof inputType.type === "string") {
1099
- this.addSchemaImport(inputType.type);
1100
- }
1101
- result.push(this.generatePrismaStringLine(field, inputType, lines.length));
1102
- }
1103
- }
1104
- return result;
1105
- }, []);
1106
- if (alternatives.length === 0) {
1107
- return [];
1108
- }
1109
- if (alternatives.length > 1) {
1110
- alternatives = alternatives.map((alter) => alter.replace(".optional()", ""));
1111
- }
1112
- const fieldName = alternatives.some((alt) => alt.includes(":")) ? "" : ` ${field.name}:`;
1113
- const opt = !field.isRequired ? ".optional()" : "";
1114
- let resString = alternatives.length === 1 ? alternatives.join(",\r\n") : `z.union([${alternatives.join(",\r\n")}])${opt}`;
1115
- if (field.isNullable) {
1116
- resString += ".nullable()";
1117
- }
1118
- return [
1119
- [
1120
- ` ${fieldName} ${resString} `,
1121
- field,
1122
- true
1123
- ]
1124
- ];
1125
- }
1126
- wrapWithZodValidators(mainValidator, field, inputType) {
1127
- let line = "";
1128
- line = mainValidator;
1129
- if (inputType.isList) {
1130
- line += ".array()";
1131
- }
1132
- if (!field.isRequired) {
1133
- line += ".optional()";
1134
- }
1135
- return line;
1136
- }
1137
- addSchemaImport(name) {
1138
- this.schemaImports.add(name);
1139
- }
1140
- generatePrismaStringLine(field, inputType, inputsLength) {
1141
- const isEnum = inputType.location === "enumTypes";
1142
- const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputType.type);
1143
- let objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputType.type}ObjectSchema`;
1144
- let enumSchemaLine = `${inputType.type}Schema`;
1145
- const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
1146
- const arr = inputType.isList ? ".array()" : "";
1147
- const opt = !field.isRequired ? ".optional()" : "";
1148
- return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}` : `z.lazy(() => ${schema})${arr}${opt}`;
1149
- }
1150
- generateFieldValidators(zodStringWithMainType, field) {
1151
- const { isRequired, isNullable } = field;
1152
- if (!isRequired) {
1153
- zodStringWithMainType += ".optional()";
1154
- }
1155
- if (isNullable) {
1156
- zodStringWithMainType += ".nullable()";
1157
- }
1158
- return zodStringWithMainType;
1159
- }
1160
- prepareObjectSchema(zodObjectSchemaFields) {
1161
- const objectSchema = `${this.generateExportObjectSchemaStatement(this.addFinalWrappers({
1162
- zodStringFields: zodObjectSchemaFields
1163
- }))}
1164
- `;
1165
- const prismaImportStatement = this.generateImportPrismaStatement();
1166
- const json = this.generateJsonSchemaImplementation();
1167
- return `${this.generateObjectSchemaImportStatements()}${prismaImportStatement}${json}${objectSchema}`;
1168
- }
1169
- generateExportObjectSchemaStatement(schema) {
1170
- let name = this.name;
1171
- let exportName = this.name;
1172
- if (Transformer2.provider === "mongodb") {
1173
- if ((0, helpers_1.isMongodbRawOp)(name)) {
1174
- name = Transformer2.rawOpsMap[name];
1175
- exportName = name.replace("Args", "");
1176
- }
1177
- }
1178
- if ((0, aggregate_helpers_1.isAggregateInputType)(name)) {
1179
- name = `${name}Type`;
1180
- }
1181
- const end = `export const ${exportName}ObjectSchema = Schema`;
1182
- return `const Schema: z.ZodType<Prisma.${name}> = ${schema};
1183
-
1184
- ${end}`;
1185
- }
1186
- addFinalWrappers({ zodStringFields }) {
1187
- const fields = [
1188
- ...zodStringFields
1189
- ];
1190
- return this.wrapWithZodObject(fields) + ".strict()";
1191
- }
1192
- generateImportPrismaStatement() {
1193
- let prismaClientImportPath;
1194
- if (Transformer2.isCustomPrismaClientOutputPath) {
1195
- const fromPath = path_1.default.join(Transformer2.outputPath, "schemas", "objects");
1196
- const toPath = Transformer2.prismaClientOutputPath;
1197
- const relativePathFromOutputToPrismaClient = path_1.default.relative(fromPath, toPath).split(path_1.default.sep).join(path_1.default.posix.sep);
1198
- prismaClientImportPath = relativePathFromOutputToPrismaClient;
1199
- } else {
1200
- prismaClientImportPath = Transformer2.prismaClientOutputPath;
1201
- }
1202
- return `import type { Prisma } from '${prismaClientImportPath}';
1203
-
1204
- `;
1205
- }
1206
- generateJsonSchemaImplementation() {
1207
- let jsonSchemaImplementation = "";
1208
- if (this.hasJson) {
1209
- jsonSchemaImplementation += `
1210
- `;
1211
- jsonSchemaImplementation += `const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
1212
- `;
1213
- jsonSchemaImplementation += `const jsonSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>
1214
- `;
1215
- jsonSchemaImplementation += ` z.union([literalSchema, z.array(jsonSchema.nullable()), z.record(jsonSchema.nullable())])
1216
- `;
1217
- jsonSchemaImplementation += `);
1218
-
1219
- `;
1220
- }
1221
- return jsonSchemaImplementation;
1222
- }
1223
- generateObjectSchemaImportStatements() {
1224
- let generatedImports = this.generateImportZodStatement();
1225
- generatedImports += this.generateSchemaImports();
1226
- generatedImports += "\n\n";
1227
- return generatedImports;
1228
- }
1229
- generateSchemaImports() {
1230
- return [
1231
- ...this.schemaImports
1232
- ].map((name) => {
1233
- const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(name);
1234
- if (isModelQueryType) {
1235
- return `import { ${this.resolveModelQuerySchemaName(modelName, queryName)} } from '../${queryName}${modelName}.schema'`;
1236
- } else if (Transformer2.enumNames.includes(name)) {
1237
- return `import { ${name}Schema } from '../enums/${name}.schema'`;
1238
- } else {
1239
- return `import { ${name}ObjectSchema } from './${name}.schema'`;
1240
- }
1241
- }).join(";\r\n");
1242
- }
1243
- checkIsModelQueryType(type) {
1244
- const modelQueryTypeSuffixToQueryName = {
1245
- FindManyArgs: "findMany"
1246
- };
1247
- for (const modelQueryType of [
1248
- "FindManyArgs"
1249
- ]) {
1250
- if (type.includes(modelQueryType)) {
1251
- const modelQueryTypeSuffixIndex = type.indexOf(modelQueryType);
1252
- return {
1253
- isModelQueryType: true,
1254
- modelName: type.substring(0, modelQueryTypeSuffixIndex),
1255
- queryName: modelQueryTypeSuffixToQueryName[modelQueryType]
1256
- };
1257
- }
1258
- }
1259
- return {
1260
- isModelQueryType: false
1261
- };
1262
- }
1263
- resolveModelQuerySchemaName(modelName, queryName) {
1264
- const modelNameCapitalized = modelName.charAt(0).toUpperCase() + modelName.slice(1);
1265
- const queryNameCapitalized = queryName.charAt(0).toUpperCase() + queryName.slice(1);
1266
- return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
1267
- }
1268
- wrapWithZodUnion(zodStringFields) {
1269
- let wrapped = "";
1270
- wrapped += "z.union([";
1271
- wrapped += "\n";
1272
- wrapped += " " + zodStringFields.join(",");
1273
- wrapped += "\n";
1274
- wrapped += "])";
1275
- return wrapped;
1276
- }
1277
- wrapWithZodObject(zodStringFields) {
1278
- let wrapped = "";
1279
- wrapped += "z.object({";
1280
- wrapped += "\n";
1281
- wrapped += " " + zodStringFields;
1282
- wrapped += "\n";
1283
- wrapped += "})";
1284
- return wrapped;
1285
- }
1286
- resolveObjectSchemaName() {
1287
- let name = this.name;
1288
- let exportName = this.name;
1289
- if ((0, helpers_1.isMongodbRawOp)(name)) {
1290
- name = Transformer2.rawOpsMap[name];
1291
- exportName = name.replace("Args", "");
1292
- }
1293
- return exportName;
1294
- }
1295
- async generateModelSchemas() {
1296
- for (const modelOperation of this.modelOperations) {
1297
- const {
1298
- model: modelName,
1299
- findUnique,
1300
- findFirst,
1301
- findMany,
1302
- // @ts-ignore
1303
- createOne,
1304
- createMany,
1305
- // @ts-ignore
1306
- deleteOne,
1307
- // @ts-ignore
1308
- updateOne,
1309
- deleteMany,
1310
- updateMany,
1311
- // @ts-ignore
1312
- upsertOne,
1313
- aggregate,
1314
- groupBy
1315
- } = modelOperation;
1316
- const model = (0, helpers_1.findModelByName)(this.models, modelName);
1317
- const { selectImport, includeImport, selectZodSchemaLine, includeZodSchemaLine, selectZodSchemaLineLazy, includeZodSchemaLineLazy } = this.resolveSelectIncludeImportAndZodSchemaLine(model);
1318
- const { orderByImport, orderByZodSchemaLine } = this.resolveOrderByWithRelationImportAndZodSchemaLine(model);
1319
- if (findUnique) {
1320
- const imports = [
1321
- selectImport,
1322
- includeImport,
1323
- `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
1324
- ];
1325
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${findUnique}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindUnique`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
1326
- }
1327
- if (findFirst) {
1328
- const imports = [
1329
- selectImport,
1330
- includeImport,
1331
- orderByImport,
1332
- `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
1333
- `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
1334
- `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
1335
- ];
1336
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${findFirst}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindFirst`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`)}`);
1337
- }
1338
- if (findMany) {
1339
- const imports = [
1340
- selectImport,
1341
- includeImport,
1342
- orderByImport,
1343
- `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
1344
- `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
1345
- `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
1346
- ];
1347
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${findMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindMany`, `z.object({ ${selectZodSchemaLineLazy} ${includeZodSchemaLineLazy} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`)}`);
1348
- }
1349
- if (createOne) {
1350
- const imports = [
1351
- selectImport,
1352
- includeImport,
1353
- `import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
1354
- `import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`
1355
- ];
1356
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${createOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema]) })`)}`);
1357
- }
1358
- if (createMany) {
1359
- const imports = [
1360
- `import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`
1361
- ];
1362
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${createMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateMany`, `z.object({ data: z.union([ ${modelName}CreateManyInputObjectSchema, z.array(${modelName}CreateManyInputObjectSchema) ]), ${Transformer2.provider === "mongodb" || Transformer2.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
1363
- }
1364
- if (deleteOne) {
1365
- const imports = [
1366
- selectImport,
1367
- includeImport,
1368
- `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
1369
- ];
1370
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${deleteOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
1371
- }
1372
- if (deleteMany) {
1373
- const imports = [
1374
- `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
1375
- ];
1376
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${deleteMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteMany`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
1377
- }
1378
- if (updateOne) {
1379
- const imports = [
1380
- selectImport,
1381
- includeImport,
1382
- `import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
1383
- `import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
1384
- `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
1385
- ];
1386
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${updateOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema]), where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
1387
- }
1388
- if (updateMany) {
1389
- const imports = [
1390
- `import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,
1391
- `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
1392
- ];
1393
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${updateMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateMany`, `z.object({ data: ${modelName}UpdateManyMutationInputObjectSchema, where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
1394
- }
1395
- if (upsertOne) {
1396
- const imports = [
1397
- selectImport,
1398
- includeImport,
1399
- `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
1400
- `import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
1401
- `import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`,
1402
- `import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
1403
- `import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`
1404
- ];
1405
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${upsertOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}Upsert`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema, create: z.union([ ${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema ]), update: z.union([ ${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema ]) })`)}`);
1406
- }
1407
- if (aggregate) {
1408
- const imports = [
1409
- orderByImport,
1410
- `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
1411
- `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
1412
- ];
1413
- const aggregateOperations = [];
1414
- if (this.aggregateOperationSupport[modelName].count) {
1415
- imports.push(`import { ${modelName}CountAggregateInputObjectSchema } from './objects/${modelName}CountAggregateInput.schema'`);
1416
- aggregateOperations.push(`_count: z.union([ z.literal(true), ${modelName}CountAggregateInputObjectSchema ]).optional()`);
1417
- }
1418
- if (this.aggregateOperationSupport[modelName].min) {
1419
- imports.push(`import { ${modelName}MinAggregateInputObjectSchema } from './objects/${modelName}MinAggregateInput.schema'`);
1420
- aggregateOperations.push(`_min: ${modelName}MinAggregateInputObjectSchema.optional()`);
1421
- }
1422
- if (this.aggregateOperationSupport[modelName].max) {
1423
- imports.push(`import { ${modelName}MaxAggregateInputObjectSchema } from './objects/${modelName}MaxAggregateInput.schema'`);
1424
- aggregateOperations.push(`_max: ${modelName}MaxAggregateInputObjectSchema.optional()`);
1425
- }
1426
- if (this.aggregateOperationSupport[modelName].avg) {
1427
- imports.push(`import { ${modelName}AvgAggregateInputObjectSchema } from './objects/${modelName}AvgAggregateInput.schema'`);
1428
- aggregateOperations.push(`_avg: ${modelName}AvgAggregateInputObjectSchema.optional()`);
1429
- }
1430
- if (this.aggregateOperationSupport[modelName].sum) {
1431
- imports.push(`import { ${modelName}SumAggregateInputObjectSchema } from './objects/${modelName}SumAggregateInput.schema'`);
1432
- aggregateOperations.push(`_sum: ${modelName}SumAggregateInputObjectSchema.optional()`);
1433
- }
1434
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${aggregate}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}Aggregate`, `z.object({ ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), ${aggregateOperations.join(", ")} })`)}`);
1435
- }
1436
- if (groupBy) {
1437
- const imports = [
1438
- `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
1439
- `import { ${modelName}OrderByWithAggregationInputObjectSchema } from './objects/${modelName}OrderByWithAggregationInput.schema'`,
1440
- `import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,
1441
- `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
1442
- ];
1443
- await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/${groupBy}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}GroupBy`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional(), orderBy: z.union([${modelName}OrderByWithAggregationInputObjectSchema, ${modelName}OrderByWithAggregationInputObjectSchema.array()]).optional(), having: ${modelName}ScalarWhereWithAggregatesInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), by: z.array(${modelName}ScalarFieldEnumSchema) })`)}`);
1444
- }
1445
- }
1446
- }
1447
- generateImportStatements(imports) {
1448
- var _a;
1449
- let generatedImports = this.generateImportZodStatement();
1450
- generatedImports += (_a = imports === null || imports === void 0 ? void 0 : imports.filter((importItem) => !!importItem).join(";\r\n")) !== null && _a !== void 0 ? _a : "";
1451
- generatedImports += "\n\n";
1452
- return generatedImports;
1453
- }
1454
- resolveSelectIncludeImportAndZodSchemaLine(model) {
1455
- const { name: modelName } = model;
1456
- const hasRelationToAnotherModel = (0, helpers_1.checkModelHasModelRelation)(model);
1457
- const selectImport = Transformer2.isGenerateSelect ? `import { ${modelName}SelectObjectSchema } from './objects/${modelName}Select.schema'` : "";
1458
- const includeImport = Transformer2.isGenerateInclude && hasRelationToAnotherModel ? `import { ${modelName}IncludeObjectSchema } from './objects/${modelName}Include.schema'` : "";
1459
- let selectZodSchemaLine = "";
1460
- let includeZodSchemaLine = "";
1461
- let selectZodSchemaLineLazy = "";
1462
- let includeZodSchemaLineLazy = "";
1463
- if (Transformer2.isGenerateSelect) {
1464
- const zodSelectObjectSchema = `${modelName}SelectObjectSchema.optional()`;
1465
- selectZodSchemaLine = `select: ${zodSelectObjectSchema},`;
1466
- selectZodSchemaLineLazy = `select: z.lazy(() => ${zodSelectObjectSchema}),`;
1467
- }
1468
- if (Transformer2.isGenerateInclude && hasRelationToAnotherModel) {
1469
- const zodIncludeObjectSchema = `${modelName}IncludeObjectSchema.optional()`;
1470
- includeZodSchemaLine = `include: ${zodIncludeObjectSchema},`;
1471
- includeZodSchemaLineLazy = `include: z.lazy(() => ${zodIncludeObjectSchema}),`;
1472
- }
1473
- return {
1474
- selectImport,
1475
- includeImport,
1476
- selectZodSchemaLine,
1477
- includeZodSchemaLine,
1478
- selectZodSchemaLineLazy,
1479
- includeZodSchemaLineLazy
1480
- };
1481
- }
1482
- resolveOrderByWithRelationImportAndZodSchemaLine(model) {
1483
- var _a;
1484
- const { name: modelName } = model;
1485
- let modelOrderBy = "";
1486
- if ([
1487
- "postgresql",
1488
- "mysql"
1489
- ].includes(Transformer2.provider) && ((_a = Transformer2.previewFeatures) === null || _a === void 0 ? void 0 : _a.includes("fullTextSearch"))) {
1490
- modelOrderBy = `${modelName}OrderByWithRelationAndSearchRelevanceInput`;
1491
- } else {
1492
- modelOrderBy = `${modelName}OrderByWithRelationInput`;
1493
- }
1494
- const orderByImport = `import { ${modelOrderBy}ObjectSchema } from './objects/${modelOrderBy}.schema'`;
1495
- const orderByZodSchemaLine = `orderBy: z.union([${modelOrderBy}ObjectSchema, ${modelOrderBy}ObjectSchema.array()]).optional(),`;
1496
- return {
1497
- orderByImport,
1498
- orderByZodSchemaLine
1499
- };
1500
- }
1501
- };
1502
- exports.default = Transformer;
1503
- Transformer.enumNames = [];
1504
- Transformer.rawOpsMap = {};
1505
- Transformer.outputPath = "./generated";
1506
- Transformer.prismaClientOutputPath = "@prisma/client";
1507
- Transformer.isCustomPrismaClientOutputPath = false;
1508
- Transformer.isGenerateSelect = false;
1509
- Transformer.isGenerateInclude = false;
1510
- }
1511
- });
1512
-
1513
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/model-helpers.js
1514
- var require_model_helpers = __commonJS({
1515
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/model-helpers.js"(exports) {
1516
- "use strict";
1517
- init_esm_shims();
1518
- Object.defineProperty(exports, "__esModule", {
1519
- value: true
1520
- });
1521
- exports.findModelByName = exports.checkIsManyModelRelationField = exports.checkIsModelRelationField = exports.checkModelHasManyModelRelation = exports.checkModelHasModelRelation = void 0;
1522
- function checkModelHasModelRelation(model) {
1523
- const { fields: modelFields } = model;
1524
- for (const modelField of modelFields) {
1525
- const isRelationField = checkIsModelRelationField(modelField);
1526
- if (isRelationField) {
1527
- return true;
1528
- }
1529
- }
1530
- return false;
1531
- }
1532
- __name(checkModelHasModelRelation, "checkModelHasModelRelation");
1533
- exports.checkModelHasModelRelation = checkModelHasModelRelation;
1534
- function checkModelHasManyModelRelation(model) {
1535
- const { fields: modelFields } = model;
1536
- for (const modelField of modelFields) {
1537
- const isManyRelationField = checkIsManyModelRelationField(modelField);
1538
- if (isManyRelationField) {
1539
- return true;
1540
- }
1541
- }
1542
- return false;
1543
- }
1544
- __name(checkModelHasManyModelRelation, "checkModelHasManyModelRelation");
1545
- exports.checkModelHasManyModelRelation = checkModelHasManyModelRelation;
1546
- function checkIsModelRelationField(modelField) {
1547
- const { kind, relationName } = modelField;
1548
- return kind === "object" && !!relationName;
1549
- }
1550
- __name(checkIsModelRelationField, "checkIsModelRelationField");
1551
- exports.checkIsModelRelationField = checkIsModelRelationField;
1552
- function checkIsManyModelRelationField(modelField) {
1553
- return checkIsModelRelationField(modelField) && modelField.isList;
1554
- }
1555
- __name(checkIsManyModelRelationField, "checkIsManyModelRelationField");
1556
- exports.checkIsManyModelRelationField = checkIsManyModelRelationField;
1557
- function findModelByName(models, modelName) {
1558
- return models.find(({ name }) => name === modelName);
1559
- }
1560
- __name(findModelByName, "findModelByName");
1561
- exports.findModelByName = findModelByName;
1562
- }
1563
- });
1564
-
1565
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/include-helpers.js
1566
- var require_include_helpers = __commonJS({
1567
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/include-helpers.js"(exports) {
1568
- "use strict";
1569
- init_esm_shims();
1570
- Object.defineProperty(exports, "__esModule", {
1571
- value: true
1572
- });
1573
- exports.addMissingInputObjectTypesForInclude = void 0;
1574
- var model_helpers_1 = require_model_helpers();
1575
- function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
1576
- const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
1577
- for (const includeInputObjectType of generatedIncludeInputObjectTypes) {
1578
- inputObjectTypes.push(includeInputObjectType);
1579
- }
1580
- }
1581
- __name(addMissingInputObjectTypesForInclude, "addMissingInputObjectTypesForInclude");
1582
- exports.addMissingInputObjectTypesForInclude = addMissingInputObjectTypesForInclude;
1583
- function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
1584
- const modelIncludeInputObjectTypes = [];
1585
- for (const model of models) {
1586
- const { name: modelName, fields: modelFields } = model;
1587
- const fields = [];
1588
- for (const modelField of modelFields) {
1589
- const { name: modelFieldName, isList, type } = modelField;
1590
- const isRelationField = (0, model_helpers_1.checkIsModelRelationField)(modelField);
1591
- if (isRelationField) {
1592
- const field = {
1593
- name: modelFieldName,
1594
- isRequired: false,
1595
- isNullable: false,
1596
- inputTypes: [
1597
- {
1598
- isList: false,
1599
- type: "Boolean",
1600
- location: "scalar"
1601
- },
1602
- {
1603
- isList: false,
1604
- type: isList ? `${type}FindManyArgs` : `${type}Args`,
1605
- location: "inputObjectTypes",
1606
- namespace: "prisma"
1607
- }
1608
- ]
1609
- };
1610
- fields.push(field);
1611
- }
1612
- }
1613
- const hasRelationToAnotherModel = (0, model_helpers_1.checkModelHasModelRelation)(model);
1614
- if (!hasRelationToAnotherModel) {
1615
- continue;
1616
- }
1617
- const hasManyRelationToAnotherModel = (0, model_helpers_1.checkModelHasManyModelRelation)(model);
1618
- const shouldAddCountField = hasManyRelationToAnotherModel;
1619
- if (shouldAddCountField) {
1620
- const inputTypes = [
1621
- {
1622
- isList: false,
1623
- type: "Boolean",
1624
- location: "scalar"
1625
- }
1626
- ];
1627
- if (isGenerateSelect) {
1628
- inputTypes.push({
1629
- isList: false,
1630
- type: `${modelName}CountOutputTypeArgs`,
1631
- location: "inputObjectTypes",
1632
- namespace: "prisma"
1633
- });
1634
- }
1635
- const _countField = {
1636
- name: "_count",
1637
- isRequired: false,
1638
- isNullable: false,
1639
- inputTypes
1640
- };
1641
- fields.push(_countField);
1642
- }
1643
- const modelIncludeInputObjectType = {
1644
- name: `${modelName}Include`,
1645
- constraints: {
1646
- maxNumFields: null,
1647
- minNumFields: null
1648
- },
1649
- fields
1650
- };
1651
- modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);
1652
- }
1653
- return modelIncludeInputObjectTypes;
1654
- }
1655
- __name(generateModelIncludeInputObjectTypes, "generateModelIncludeInputObjectTypes");
1656
- }
1657
- });
1658
-
1659
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/modelArgs-helpers.js
1660
- var require_modelArgs_helpers = __commonJS({
1661
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/modelArgs-helpers.js"(exports) {
1662
- "use strict";
1663
- init_esm_shims();
1664
- Object.defineProperty(exports, "__esModule", {
1665
- value: true
1666
- });
1667
- exports.addMissingInputObjectTypesForModelArgs = void 0;
1668
- var model_helpers_1 = require_model_helpers();
1669
- function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
1670
- const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
1671
- for (const modelArgsInputObjectType of modelArgsInputObjectTypes) {
1672
- inputObjectTypes.push(modelArgsInputObjectType);
1673
- }
1674
- }
1675
- __name(addMissingInputObjectTypesForModelArgs, "addMissingInputObjectTypesForModelArgs");
1676
- exports.addMissingInputObjectTypesForModelArgs = addMissingInputObjectTypesForModelArgs;
1677
- function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude) {
1678
- const modelArgsInputObjectTypes = [];
1679
- for (const model of models) {
1680
- const { name: modelName } = model;
1681
- const fields = [];
1682
- if (isGenerateSelect) {
1683
- const selectField = {
1684
- name: "select",
1685
- isRequired: false,
1686
- isNullable: false,
1687
- inputTypes: [
1688
- {
1689
- isList: false,
1690
- type: `${modelName}Select`,
1691
- location: "inputObjectTypes",
1692
- namespace: "prisma"
1693
- }
1694
- ]
1695
- };
1696
- fields.push(selectField);
1697
- }
1698
- const hasRelationToAnotherModel = (0, model_helpers_1.checkModelHasModelRelation)(model);
1699
- if (isGenerateInclude && hasRelationToAnotherModel) {
1700
- const includeField = {
1701
- name: "include",
1702
- isRequired: false,
1703
- isNullable: false,
1704
- inputTypes: [
1705
- {
1706
- isList: false,
1707
- type: `${modelName}Include`,
1708
- location: "inputObjectTypes",
1709
- namespace: "prisma"
1710
- }
1711
- ]
1712
- };
1713
- fields.push(includeField);
1714
- }
1715
- const modelArgsInputObjectType = {
1716
- name: `${modelName}Args`,
1717
- constraints: {
1718
- maxNumFields: null,
1719
- minNumFields: null
1720
- },
1721
- fields
1722
- };
1723
- modelArgsInputObjectTypes.push(modelArgsInputObjectType);
1724
- }
1725
- return modelArgsInputObjectTypes;
1726
- }
1727
- __name(generateModelArgsInputObjectTypes, "generateModelArgsInputObjectTypes");
1728
- }
1729
- });
1730
-
1731
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/mongodb-helpers.js
1732
- var require_mongodb_helpers = __commonJS({
1733
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/mongodb-helpers.js"(exports) {
1734
- "use strict";
1735
- init_esm_shims();
1736
- var __importDefault = exports && exports.__importDefault || function(mod) {
1737
- return mod && mod.__esModule ? mod : {
1738
- "default": mod
1739
- };
1740
- };
1741
- Object.defineProperty(exports, "__esModule", {
1742
- value: true
1743
- });
1744
- exports.isMongodbRawOp = exports.addMissingInputObjectTypesForMongoDbRawOpsAndQueries = void 0;
1745
- var transformer_1 = __importDefault(require_transformer());
1746
- function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
1747
- const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
1748
- transformer_1.default.rawOpsMap = rawOpsMap !== null && rawOpsMap !== void 0 ? rawOpsMap : {};
1749
- const mongoDbRawQueryInputObjectTypes = resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes);
1750
- for (const mongoDbRawQueryInputType of mongoDbRawQueryInputObjectTypes) {
1751
- inputObjectTypes.push(mongoDbRawQueryInputType);
1752
- }
1753
- }
1754
- __name(addMissingInputObjectTypesForMongoDbRawOpsAndQueries, "addMissingInputObjectTypesForMongoDbRawOpsAndQueries");
1755
- exports.addMissingInputObjectTypesForMongoDbRawOpsAndQueries = addMissingInputObjectTypesForMongoDbRawOpsAndQueries;
1756
- function resolveMongoDbRawOperations(modelOperations) {
1757
- const rawOpsMap = {};
1758
- const rawOpsNames = [
1759
- ...new Set(modelOperations.reduce((result, current) => {
1760
- const keys = Object.keys(current);
1761
- keys === null || keys === void 0 ? void 0 : keys.forEach((key) => {
1762
- if (key.includes("Raw")) {
1763
- result.push(key);
1764
- }
1765
- });
1766
- return result;
1767
- }, []))
1768
- ];
1769
- const modelNames = modelOperations.map((item) => item.model);
1770
- rawOpsNames.forEach((opName) => {
1771
- modelNames.forEach((modelName) => {
1772
- const isFind = opName === "findRaw";
1773
- const opWithModel = `${opName.replace("Raw", "")}${modelName}Raw`;
1774
- rawOpsMap[opWithModel] = isFind ? `${modelName}FindRawArgs` : `${modelName}AggregateRawArgs`;
1775
- });
1776
- });
1777
- return rawOpsMap;
1778
- }
1779
- __name(resolveMongoDbRawOperations, "resolveMongoDbRawOperations");
1780
- function resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes) {
1781
- const mongoDbRawQueries = getMongoDbRawQueries(outputObjectTypes);
1782
- const mongoDbRawQueryInputObjectTypes = mongoDbRawQueries.map((item) => ({
1783
- name: item.name,
1784
- constraints: {
1785
- maxNumFields: null,
1786
- minNumFields: null
1787
- },
1788
- fields: item.args.map((arg) => ({
1789
- name: arg.name,
1790
- isRequired: arg.isRequired,
1791
- isNullable: arg.isNullable,
1792
- inputTypes: arg.inputTypes
1793
- }))
1794
- }));
1795
- return mongoDbRawQueryInputObjectTypes;
1796
- }
1797
- __name(resolveMongoDbRawQueryInputObjectTypes, "resolveMongoDbRawQueryInputObjectTypes");
1798
- function getMongoDbRawQueries(outputObjectTypes) {
1799
- var _a;
1800
- const queryOutputTypes = outputObjectTypes.filter((item) => item.name === "Query");
1801
- const mongodbRawQueries = (_a = queryOutputTypes === null || queryOutputTypes === void 0 ? void 0 : queryOutputTypes[0].fields.filter((field) => field.name.includes("Raw"))) !== null && _a !== void 0 ? _a : [];
1802
- return mongodbRawQueries;
1803
- }
1804
- __name(getMongoDbRawQueries, "getMongoDbRawQueries");
1805
- var isMongodbRawOp = /* @__PURE__ */ __name((name) => /find([^]*?)Raw/.test(name) || /aggregate([^]*?)Raw/.test(name), "isMongodbRawOp");
1806
- exports.isMongodbRawOp = isMongodbRawOp;
1807
- }
1808
- });
1809
-
1810
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/select-helpers.js
1811
- var require_select_helpers = __commonJS({
1812
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/select-helpers.js"(exports) {
1813
- "use strict";
1814
- init_esm_shims();
1815
- Object.defineProperty(exports, "__esModule", {
1816
- value: true
1817
- });
1818
- exports.addMissingInputObjectTypesForSelect = void 0;
1819
- var model_helpers_1 = require_model_helpers();
1820
- function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
1821
- const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
1822
- const modelCountOutputTypeSelectInputObjectTypes = generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes);
1823
- const modelCountOutputTypeArgsInputObjectTypes = generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes);
1824
- const modelSelectInputObjectTypes = generateModelSelectInputObjectTypes(models);
1825
- const generatedInputObjectTypes = [
1826
- modelCountOutputTypeSelectInputObjectTypes,
1827
- modelCountOutputTypeArgsInputObjectTypes,
1828
- modelSelectInputObjectTypes
1829
- ].flat();
1830
- for (const inputObjectType of generatedInputObjectTypes) {
1831
- inputObjectTypes.push(inputObjectType);
1832
- }
1833
- }
1834
- __name(addMissingInputObjectTypesForSelect, "addMissingInputObjectTypesForSelect");
1835
- exports.addMissingInputObjectTypesForSelect = addMissingInputObjectTypesForSelect;
1836
- function getModelCountOutputTypes(outputObjectTypes) {
1837
- return outputObjectTypes.filter(({ name }) => name.includes("CountOutputType"));
1838
- }
1839
- __name(getModelCountOutputTypes, "getModelCountOutputTypes");
1840
- function generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes) {
1841
- const modelCountOutputTypeSelectInputObjectTypes = [];
1842
- for (const modelCountOutputType of modelCountOutputTypes) {
1843
- const { name: modelCountOutputTypeName, fields: modelCountOutputTypeFields } = modelCountOutputType;
1844
- const modelCountOutputTypeSelectInputObjectType = {
1845
- name: `${modelCountOutputTypeName}Select`,
1846
- constraints: {
1847
- maxNumFields: null,
1848
- minNumFields: null
1849
- },
1850
- fields: modelCountOutputTypeFields.map(({ name }) => ({
1851
- name,
1852
- isRequired: false,
1853
- isNullable: false,
1854
- inputTypes: [
1855
- {
1856
- isList: false,
1857
- type: `Boolean`,
1858
- location: "scalar"
1859
- }
1860
- ]
1861
- }))
1862
- };
1863
- modelCountOutputTypeSelectInputObjectTypes.push(modelCountOutputTypeSelectInputObjectType);
1864
- }
1865
- return modelCountOutputTypeSelectInputObjectTypes;
1866
- }
1867
- __name(generateModelCountOutputTypeSelectInputObjectTypes, "generateModelCountOutputTypeSelectInputObjectTypes");
1868
- function generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes) {
1869
- const modelCountOutputTypeArgsInputObjectTypes = [];
1870
- for (const modelCountOutputType of modelCountOutputTypes) {
1871
- const { name: modelCountOutputTypeName } = modelCountOutputType;
1872
- const modelCountOutputTypeArgsInputObjectType = {
1873
- name: `${modelCountOutputTypeName}Args`,
1874
- constraints: {
1875
- maxNumFields: null,
1876
- minNumFields: null
1877
- },
1878
- fields: [
1879
- {
1880
- name: "select",
1881
- isRequired: false,
1882
- isNullable: false,
1883
- inputTypes: [
1884
- {
1885
- isList: false,
1886
- type: `${modelCountOutputTypeName}Select`,
1887
- location: "inputObjectTypes",
1888
- namespace: "prisma"
1889
- }
1890
- ]
1891
- }
1892
- ]
1893
- };
1894
- modelCountOutputTypeArgsInputObjectTypes.push(modelCountOutputTypeArgsInputObjectType);
1895
- }
1896
- return modelCountOutputTypeArgsInputObjectTypes;
1897
- }
1898
- __name(generateModelCountOutputTypeArgsInputObjectTypes, "generateModelCountOutputTypeArgsInputObjectTypes");
1899
- function generateModelSelectInputObjectTypes(models) {
1900
- const modelSelectInputObjectTypes = [];
1901
- for (const model of models) {
1902
- const { name: modelName, fields: modelFields } = model;
1903
- const fields = [];
1904
- for (const modelField of modelFields) {
1905
- const { name: modelFieldName, isList, type } = modelField;
1906
- const isRelationField = (0, model_helpers_1.checkIsModelRelationField)(modelField);
1907
- const field = {
1908
- name: modelFieldName,
1909
- isRequired: false,
1910
- isNullable: false,
1911
- inputTypes: [
1912
- {
1913
- isList: false,
1914
- type: "Boolean",
1915
- location: "scalar"
1916
- }
1917
- ]
1918
- };
1919
- if (isRelationField) {
1920
- let schemaArgInputType = {
1921
- isList: false,
1922
- type: isList ? `${type}FindManyArgs` : `${type}Args`,
1923
- location: "inputObjectTypes",
1924
- namespace: "prisma"
1925
- };
1926
- field.inputTypes.push(schemaArgInputType);
1927
- }
1928
- fields.push(field);
1929
- }
1930
- const hasManyRelationToAnotherModel = (0, model_helpers_1.checkModelHasManyModelRelation)(model);
1931
- const shouldAddCountField = hasManyRelationToAnotherModel;
1932
- if (shouldAddCountField) {
1933
- const _countField = {
1934
- name: "_count",
1935
- isRequired: false,
1936
- isNullable: false,
1937
- inputTypes: [
1938
- {
1939
- isList: false,
1940
- type: "Boolean",
1941
- location: "scalar"
1942
- },
1943
- {
1944
- isList: false,
1945
- type: `${modelName}CountOutputTypeArgs`,
1946
- location: "inputObjectTypes",
1947
- namespace: "prisma"
1948
- }
1949
- ]
1950
- };
1951
- fields.push(_countField);
1952
- }
1953
- const modelSelectInputObjectType = {
1954
- name: `${modelName}Select`,
1955
- constraints: {
1956
- maxNumFields: null,
1957
- minNumFields: null
1958
- },
1959
- fields
1960
- };
1961
- modelSelectInputObjectTypes.push(modelSelectInputObjectType);
1962
- }
1963
- return modelSelectInputObjectTypes;
1964
- }
1965
- __name(generateModelSelectInputObjectTypes, "generateModelSelectInputObjectTypes");
1966
- }
1967
- });
1968
-
1969
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/whereUniqueInput-helpers.js
1970
- var require_whereUniqueInput_helpers = __commonJS({
1971
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/whereUniqueInput-helpers.js"(exports) {
1972
- "use strict";
1973
- init_esm_shims();
1974
- Object.defineProperty(exports, "__esModule", {
1975
- value: true
1976
- });
1977
- exports.changeOptionalToRequiredFields = void 0;
1978
- function changeOptionalToRequiredFields(inputObjectTypes) {
1979
- inputObjectTypes.map((item) => {
1980
- var _a;
1981
- if (item.name.includes("WhereUniqueInput") && ((_a = item.constraints.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1982
- item.fields = item.fields.map((subItem) => {
1983
- var _a2;
1984
- if ((_a2 = item.constraints.fields) === null || _a2 === void 0 ? void 0 : _a2.includes(subItem.name)) {
1985
- subItem.isRequired = true;
1986
- return subItem;
1987
- }
1988
- return subItem;
1989
- });
1990
- }
1991
- return item;
1992
- });
1993
- }
1994
- __name(changeOptionalToRequiredFields, "changeOptionalToRequiredFields");
1995
- exports.changeOptionalToRequiredFields = changeOptionalToRequiredFields;
1996
- }
1997
- });
1998
-
1999
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/helpers.js
2000
- var require_helpers = __commonJS({
2001
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/helpers.js"(exports) {
2002
- "use strict";
2003
- init_esm_shims();
2004
- var __importDefault = exports && exports.__importDefault || function(mod) {
2005
- return mod && mod.__esModule ? mod : {
2006
- "default": mod
2007
- };
2008
- };
2009
- Object.defineProperty(exports, "__esModule", {
2010
- value: true
2011
- });
2012
- exports.resolveAddMissingInputObjectTypeOptions = exports.addMissingInputObjectTypes = void 0;
2013
- var transformer_1 = __importDefault(require_transformer());
2014
- var aggregate_helpers_1 = require_aggregate_helpers();
2015
- var include_helpers_1 = require_include_helpers();
2016
- var modelArgs_helpers_1 = require_modelArgs_helpers();
2017
- var mongodb_helpers_1 = require_mongodb_helpers();
2018
- var select_helpers_1 = require_select_helpers();
2019
- var whereUniqueInput_helpers_1 = require_whereUniqueInput_helpers();
2020
- function addMissingInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
2021
- if (dataSourceProvider === "mongodb") {
2022
- (0, mongodb_helpers_1.addMissingInputObjectTypesForMongoDbRawOpsAndQueries)(modelOperations, outputObjectTypes, inputObjectTypes);
2023
- }
2024
- (0, aggregate_helpers_1.addMissingInputObjectTypesForAggregate)(inputObjectTypes, outputObjectTypes);
2025
- if (options.isGenerateSelect) {
2026
- (0, select_helpers_1.addMissingInputObjectTypesForSelect)(inputObjectTypes, outputObjectTypes, models);
2027
- transformer_1.default.setIsGenerateSelect(true);
2028
- }
2029
- if (options.isGenerateSelect || options.isGenerateInclude) {
2030
- (0, modelArgs_helpers_1.addMissingInputObjectTypesForModelArgs)(inputObjectTypes, models, options.isGenerateSelect, options.isGenerateInclude);
2031
- }
2032
- if (options.isGenerateInclude) {
2033
- (0, include_helpers_1.addMissingInputObjectTypesForInclude)(inputObjectTypes, models, options.isGenerateSelect);
2034
- transformer_1.default.setIsGenerateInclude(true);
2035
- }
2036
- (0, whereUniqueInput_helpers_1.changeOptionalToRequiredFields)(inputObjectTypes);
2037
- }
2038
- __name(addMissingInputObjectTypes, "addMissingInputObjectTypes");
2039
- exports.addMissingInputObjectTypes = addMissingInputObjectTypes;
2040
- function resolveAddMissingInputObjectTypeOptions(generatorConfigOptions) {
2041
- return {
2042
- isGenerateSelect: generatorConfigOptions.isGenerateSelect === "true",
2043
- isGenerateInclude: generatorConfigOptions.isGenerateInclude === "true"
2044
- };
2045
- }
2046
- __name(resolveAddMissingInputObjectTypeOptions, "resolveAddMissingInputObjectTypeOptions");
2047
- exports.resolveAddMissingInputObjectTypeOptions = resolveAddMissingInputObjectTypeOptions;
2048
- }
2049
- });
2050
-
2051
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/index.js
2052
- var require_helpers2 = __commonJS({
2053
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/index.js"(exports) {
2054
- "use strict";
2055
- init_esm_shims();
2056
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
2057
- if (k2 === void 0) k2 = k;
2058
- var desc = Object.getOwnPropertyDescriptor(m, k);
2059
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2060
- desc = {
2061
- enumerable: true,
2062
- get: /* @__PURE__ */ __name(function() {
2063
- return m[k];
2064
- }, "get")
2065
- };
2066
- }
2067
- Object.defineProperty(o, k2, desc);
2068
- } : function(o, m, k, k2) {
2069
- if (k2 === void 0) k2 = k;
2070
- o[k2] = m[k];
2071
- });
2072
- var __exportStar = exports && exports.__exportStar || function(m, exports1) {
2073
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports1, p)) __createBinding(exports1, m, p);
2074
- };
2075
- Object.defineProperty(exports, "__esModule", {
2076
- value: true
2077
- });
2078
- __exportStar(require_comments_helpers(), exports);
2079
- __exportStar(require_helpers(), exports);
2080
- __exportStar(require_model_helpers(), exports);
2081
- __exportStar(require_mongodb_helpers(), exports);
2082
- __exportStar(require_whereUniqueInput_helpers(), exports);
2083
- }
2084
- });
2085
-
2086
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/removeDir.js
2087
- var require_removeDir = __commonJS({
2088
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/removeDir.js"(exports) {
2089
- "use strict";
2090
- init_esm_shims();
2091
- var __importDefault = exports && exports.__importDefault || function(mod) {
2092
- return mod && mod.__esModule ? mod : {
2093
- "default": mod
2094
- };
2095
- };
2096
- Object.defineProperty(exports, "__esModule", {
2097
- value: true
2098
- });
2099
- var path_1 = __importDefault(__require("path"));
2100
- var fs_1 = __require("fs");
2101
- async function removeDir2(dirPath, onlyContent) {
2102
- const dirEntries = await fs_1.promises.readdir(dirPath, {
2103
- withFileTypes: true
2104
- });
2105
- await Promise.all(dirEntries.map(async (dirEntry) => {
2106
- const fullPath = path_1.default.join(dirPath, dirEntry.name);
2107
- return dirEntry.isDirectory() ? await removeDir2(fullPath, false) : await fs_1.promises.unlink(fullPath);
2108
- }));
2109
- if (!onlyContent) {
2110
- await fs_1.promises.rmdir(dirPath);
2111
- }
2112
- }
2113
- __name(removeDir2, "removeDir");
2114
- exports.default = removeDir2;
2115
- }
2116
- });
2117
-
2118
- // ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/prisma-generator.js
2119
- var require_prisma_generator = __commonJS({
2120
- "../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/prisma-generator.js"(exports) {
2121
- "use strict";
2122
- init_esm_shims();
2123
- var __importDefault = exports && exports.__importDefault || function(mod) {
2124
- return mod && mod.__esModule ? mod : {
2125
- "default": mod
2126
- };
2127
- };
2128
- Object.defineProperty(exports, "__esModule", {
2129
- value: true
2130
- });
2131
- exports.generate = void 0;
2132
- var internals_1 = __require("@prisma/internals");
2133
- var fs_1 = __require("fs");
2134
- var helpers_1 = require_helpers2();
2135
- var aggregate_helpers_1 = require_aggregate_helpers();
2136
- var transformer_1 = __importDefault(require_transformer());
2137
- var removeDir_1 = __importDefault(require_removeDir());
2138
- async function generate2(options) {
2139
- var _a, _b;
2140
- try {
2141
- await handleGeneratorOutputValue(options.generator.output);
2142
- const prismaClientGeneratorConfig = getGeneratorConfigByProvider(options.otherGenerators, "prisma-client-js");
2143
- const prismaClientDmmf = await (0, internals_1.getDMMF)({
2144
- datamodel: options.datamodel,
2145
- previewFeatures: prismaClientGeneratorConfig === null || prismaClientGeneratorConfig === void 0 ? void 0 : prismaClientGeneratorConfig.previewFeatures
2146
- });
2147
- checkForCustomPrismaClientOutputPath(prismaClientGeneratorConfig);
2148
- const modelOperations = prismaClientDmmf.mappings.modelOperations;
2149
- const inputObjectTypes = prismaClientDmmf.schema.inputObjectTypes.prisma;
2150
- const outputObjectTypes = prismaClientDmmf.schema.outputObjectTypes.prisma;
2151
- const enumTypes = prismaClientDmmf.schema.enumTypes;
2152
- const models = prismaClientDmmf.datamodel.models;
2153
- const hiddenModels = [];
2154
- const hiddenFields = [];
2155
- (0, helpers_1.resolveModelsComments)(models, modelOperations, enumTypes, hiddenModels, hiddenFields);
2156
- await generateEnumSchemas(prismaClientDmmf.schema.enumTypes.prisma, (_a = prismaClientDmmf.schema.enumTypes.model) !== null && _a !== void 0 ? _a : []);
2157
- const dataSource = (_b = options.datasources) === null || _b === void 0 ? void 0 : _b[0];
2158
- const previewFeatures = prismaClientGeneratorConfig === null || prismaClientGeneratorConfig === void 0 ? void 0 : prismaClientGeneratorConfig.previewFeatures;
2159
- transformer_1.default.provider = dataSource.provider;
2160
- transformer_1.default.previewFeatures = previewFeatures;
2161
- const generatorConfigOptions = options.generator.config;
2162
- const addMissingInputObjectTypeOptions = (0, helpers_1.resolveAddMissingInputObjectTypeOptions)(generatorConfigOptions);
2163
- (0, helpers_1.addMissingInputObjectTypes)(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSource.provider, addMissingInputObjectTypeOptions);
2164
- const aggregateOperationSupport = (0, aggregate_helpers_1.resolveAggregateOperationSupport)(inputObjectTypes);
2165
- (0, helpers_1.hideInputObjectTypesAndRelatedFields)(inputObjectTypes, hiddenModels, hiddenFields);
2166
- await generateObjectSchemas(inputObjectTypes);
2167
- await generateModelSchemas(models, modelOperations, aggregateOperationSupport);
2168
- await generateIndex();
2169
- } catch (error) {
2170
- console.error(error);
2171
- }
2172
- }
2173
- __name(generate2, "generate");
2174
- exports.generate = generate2;
2175
- async function handleGeneratorOutputValue(generatorOutputValue) {
2176
- const outputDirectoryPath = (0, internals_1.parseEnvValue)(generatorOutputValue);
2177
- await fs_1.promises.mkdir(outputDirectoryPath, {
2178
- recursive: true
2179
- });
2180
- const isRemoveContentsOnly = true;
2181
- await (0, removeDir_1.default)(outputDirectoryPath, isRemoveContentsOnly);
2182
- transformer_1.default.setOutputPath(outputDirectoryPath);
2183
- }
2184
- __name(handleGeneratorOutputValue, "handleGeneratorOutputValue");
2185
- function getGeneratorConfigByProvider(generators, provider2) {
2186
- return generators.find((it) => (0, internals_1.parseEnvValue)(it.provider) === provider2);
2187
- }
2188
- __name(getGeneratorConfigByProvider, "getGeneratorConfigByProvider");
2189
- function checkForCustomPrismaClientOutputPath(prismaClientGeneratorConfig) {
2190
- var _a;
2191
- if (prismaClientGeneratorConfig === null || prismaClientGeneratorConfig === void 0 ? void 0 : prismaClientGeneratorConfig.isCustomOutput) {
2192
- transformer_1.default.setPrismaClientOutputPath((_a = prismaClientGeneratorConfig.output) === null || _a === void 0 ? void 0 : _a.value);
2193
- }
2194
- }
2195
- __name(checkForCustomPrismaClientOutputPath, "checkForCustomPrismaClientOutputPath");
2196
- async function generateEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
2197
- const enumTypes = [
2198
- ...prismaSchemaEnum,
2199
- ...modelSchemaEnum
2200
- ];
2201
- const enumNames = enumTypes.map((enumItem) => enumItem.name);
2202
- transformer_1.default.enumNames = enumNames !== null && enumNames !== void 0 ? enumNames : [];
2203
- const transformer = new transformer_1.default({
2204
- enumTypes
2205
- });
2206
- await transformer.generateEnumSchemas();
2207
- }
2208
- __name(generateEnumSchemas, "generateEnumSchemas");
2209
- async function generateObjectSchemas(inputObjectTypes) {
2210
- var _a, _b;
2211
- for (let i = 0; i < inputObjectTypes.length; i += 1) {
2212
- const fields = (_a = inputObjectTypes[i]) === null || _a === void 0 ? void 0 : _a.fields;
2213
- const name = (_b = inputObjectTypes[i]) === null || _b === void 0 ? void 0 : _b.name;
2214
- const transformer = new transformer_1.default({
2215
- name,
2216
- fields
2217
- });
2218
- await transformer.generateObjectSchema();
2219
- }
2220
- }
2221
- __name(generateObjectSchemas, "generateObjectSchemas");
2222
- async function generateModelSchemas(models, modelOperations, aggregateOperationSupport) {
2223
- const transformer = new transformer_1.default({
2224
- models,
2225
- modelOperations,
2226
- aggregateOperationSupport
2227
- });
2228
- await transformer.generateModelSchemas();
2229
- }
2230
- __name(generateModelSchemas, "generateModelSchemas");
2231
- async function generateIndex() {
2232
- await transformer_1.default.generateIndex();
2233
- }
2234
- __name(generateIndex, "generateIndex");
2235
- }
2236
- });
2237
-
2238
676
  // ../../node_modules/.pnpm/@dotenvx+dotenvx@1.35.0/node_modules/@dotenvx/dotenvx/package.json
2239
677
  var require_package = __commonJS({
2240
678
  "../../node_modules/.pnpm/@dotenvx+dotenvx@1.35.0/node_modules/@dotenvx/dotenvx/package.json"(exports, module) {
@@ -15718,7 +14156,6 @@ init_esm_shims();
15718
14156
  // src/prisma-generator.ts
15719
14157
  init_esm_shims();
15720
14158
  var import_pluralize = __toESM(require_pluralize(), 1);
15721
- var import_prisma_generator = __toESM(require_prisma_generator(), 1);
15722
14159
  import { promises as fs4 } from "node:fs";
15723
14160
  import path6 from "node:path";
15724
14161
 
@@ -19982,7 +18419,10 @@ var configSchema = z.object({
19982
18419
  // src/helpers.ts
19983
18420
  init_esm_shims();
19984
18421
 
19985
- // src/utils/getPrismaInternals.ts
18422
+ // src/utils/get-prisma-internals.ts
18423
+ init_esm_shims();
18424
+
18425
+ // src/utils/get-jiti.ts
19986
18426
  init_esm_shims();
19987
18427
 
19988
18428
  // ../env/src/index.ts
@@ -23346,7 +21786,7 @@ __name(detectRuntime, "detectRuntime");
23346
21786
  var runtimeInfo = detectRuntime();
23347
21787
  var runtime = runtimeInfo?.name || "";
23348
21788
 
23349
- // src/utils/getPrismaInternals.ts
21789
+ // src/utils/get-jiti.ts
23350
21790
  import { createJiti } from "jiti";
23351
21791
  var jiti;
23352
21792
  function getJiti() {
@@ -23360,6 +21800,8 @@ function getJiti() {
23360
21800
  return jiti;
23361
21801
  }
23362
21802
  __name(getJiti, "getJiti");
21803
+
21804
+ // src/utils/get-prisma-internals.ts
23363
21805
  async function getPrismaInternals() {
23364
21806
  return getJiti().import(getJiti().esmResolve("@prisma/internals"));
23365
21807
  }
@@ -23369,7 +21811,7 @@ async function getPrismaGeneratorHelper() {
23369
21811
  }
23370
21812
  __name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
23371
21813
 
23372
- // src/utils/getRelativePath.ts
21814
+ // src/utils/get-relative-path.ts
23373
21815
  init_esm_shims();
23374
21816
  import path2 from "node:path";
23375
21817
  function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath) {
@@ -23385,7 +21827,7 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath)
23385
21827
  }
23386
21828
  __name(getRelativePath, "getRelativePath");
23387
21829
 
23388
- // src/utils/uncapitalizeFirstLetter.ts
21830
+ // src/utils/uncapitalize-first-letter.ts
23389
21831
  init_esm_shims();
23390
21832
  var uncapitalizeFirstLetter = /* @__PURE__ */ __name((str) => {
23391
21833
  return str.charAt(0).toLowerCase() + str.slice(1);
@@ -23750,7 +22192,7 @@ init_esm_shims();
23750
22192
  import { promises as fs3 } from "node:fs";
23751
22193
  import path5 from "node:path";
23752
22194
 
23753
- // src/utils/removeDir.ts
22195
+ // src/utils/remove-dir.ts
23754
22196
  init_esm_shims();
23755
22197
  import { promises as fs } from "node:fs";
23756
22198
  import path3 from "node:path";
@@ -23768,12 +22210,12 @@ async function removeDir(dirPath, onlyContent) {
23768
22210
  }
23769
22211
  __name(removeDir, "removeDir");
23770
22212
 
23771
- // src/utils/writeFileSafely.ts
22213
+ // src/utils/write-file-safely.ts
23772
22214
  init_esm_shims();
23773
22215
  import fs2 from "node:fs";
23774
22216
  import path4 from "node:path";
23775
22217
 
23776
- // src/utils/formatFile.ts
22218
+ // src/utils/format-file.ts
23777
22219
  init_esm_shims();
23778
22220
  import prettier from "prettier";
23779
22221
  async function formatFile(content) {
@@ -23798,7 +22240,7 @@ async function formatFile(content) {
23798
22240
  }
23799
22241
  __name(formatFile, "formatFile");
23800
22242
 
23801
- // src/utils/writeFileSafely.ts
22243
+ // src/utils/write-file-safely.ts
23802
22244
  var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content) => {
23803
22245
  fs2.mkdirSync(path4.dirname(writeLocation), {
23804
22246
  recursive: true
@@ -23889,7 +22331,8 @@ async function generate(options) {
23889
22331
  });
23890
22332
  await removeDir(outputDir, true);
23891
22333
  if (config.withZod !== false) {
23892
- await (0, import_prisma_generator.generate)(options);
22334
+ const prismaZodGenerator = await getJiti().import(getJiti().esmResolve("prisma-zod-generator/lib/prisma-generator"));
22335
+ await prismaZodGenerator.generate(options);
23893
22336
  }
23894
22337
  if (config.withShield !== false) {
23895
22338
  const shieldOutputPath = path6.join(outputDir, "./shield");
@@ -23898,6 +22341,7 @@ async function generate(options) {
23898
22341
  generator: {
23899
22342
  ...options.generator,
23900
22343
  output: {
22344
+ fromEnvVar: null,
23901
22345
  ...options.generator.output,
23902
22346
  value: shieldOutputPath
23903
22347
  },