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