@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.cjs
CHANGED
|
@@ -667,1568 +667,6 @@ var require_pluralize = __commonJS({
|
|
|
667
667
|
}
|
|
668
668
|
});
|
|
669
669
|
|
|
670
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/comments-helpers.js
|
|
671
|
-
var require_comments_helpers = __commonJS({
|
|
672
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/comments-helpers.js"(exports2) {
|
|
673
|
-
"use strict";
|
|
674
|
-
init_cjs_shims();
|
|
675
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
676
|
-
value: true
|
|
677
|
-
});
|
|
678
|
-
exports2.hideInputObjectTypesAndRelatedFields = exports2.resolveModelsComments = void 0;
|
|
679
|
-
var modelAttributeRegex = /(@@Gen\.)+([A-z])+(\()+(.+)+(\))+/;
|
|
680
|
-
var attributeNameRegex = /(?:\.)+([A-Za-z])+(?:\()+/;
|
|
681
|
-
var attributeArgsRegex = /(?:\()+([A-Za-z])+\:+(.+)+(?:\))+/;
|
|
682
|
-
function resolveModelsComments2(models, modelOperations, enumTypes, hiddenModels, hiddenFields) {
|
|
683
|
-
models = collectHiddenModels(models, hiddenModels);
|
|
684
|
-
collectHiddenFields(models, hiddenModels, hiddenFields);
|
|
685
|
-
hideModelOperations(models, modelOperations);
|
|
686
|
-
hideEnums(enumTypes, hiddenModels);
|
|
687
|
-
}
|
|
688
|
-
__name(resolveModelsComments2, "resolveModelsComments");
|
|
689
|
-
exports2.resolveModelsComments = resolveModelsComments2;
|
|
690
|
-
function collectHiddenModels(models, hiddenModels) {
|
|
691
|
-
return models.map((model) => {
|
|
692
|
-
var _a, _b, _c, _d, _e, _f;
|
|
693
|
-
if (model.documentation) {
|
|
694
|
-
const attribute = (_b = (_a = model.documentation) === null || _a === void 0 ? void 0 : _a.match(modelAttributeRegex)) === null || _b === void 0 ? void 0 : _b[0];
|
|
695
|
-
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);
|
|
696
|
-
if (attributeName !== "model") model;
|
|
697
|
-
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);
|
|
698
|
-
const parsedAttributeArgs = {};
|
|
699
|
-
if (rawAttributeArgs) {
|
|
700
|
-
const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
|
|
701
|
-
for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
|
|
702
|
-
const key = rawAttributeArgsParts[i];
|
|
703
|
-
const value = rawAttributeArgsParts[i + 1];
|
|
704
|
-
parsedAttributeArgs[key] = JSON.parse(value);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
if (parsedAttributeArgs.hide) {
|
|
708
|
-
hiddenModels.push(model.name);
|
|
709
|
-
return null;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
return model;
|
|
713
|
-
}).filter(Boolean);
|
|
714
|
-
}
|
|
715
|
-
__name(collectHiddenModels, "collectHiddenModels");
|
|
716
|
-
function collectHiddenFields(models, hiddenModels, hiddenFields) {
|
|
717
|
-
models.forEach((model) => {
|
|
718
|
-
model.fields.forEach((field) => {
|
|
719
|
-
if (hiddenModels.includes(field.type)) {
|
|
720
|
-
hiddenFields.push(field.name);
|
|
721
|
-
if (field.relationFromFields) {
|
|
722
|
-
field.relationFromFields.forEach((item) => hiddenFields.push(item));
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
__name(collectHiddenFields, "collectHiddenFields");
|
|
729
|
-
function hideEnums(enumTypes, hiddenModels) {
|
|
730
|
-
enumTypes.prisma = enumTypes.prisma.filter((item) => !hiddenModels.find((model) => item.name.startsWith(model)));
|
|
731
|
-
}
|
|
732
|
-
__name(hideEnums, "hideEnums");
|
|
733
|
-
function hideModelOperations(models, modelOperations) {
|
|
734
|
-
let i = modelOperations.length;
|
|
735
|
-
while (i >= 0) {
|
|
736
|
-
--i;
|
|
737
|
-
const modelOperation = modelOperations[i];
|
|
738
|
-
if (modelOperation && !models.find((model) => {
|
|
739
|
-
return model.name === modelOperation.model;
|
|
740
|
-
})) {
|
|
741
|
-
modelOperations.splice(i, 1);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
__name(hideModelOperations, "hideModelOperations");
|
|
746
|
-
function hideInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels, hiddenFields) {
|
|
747
|
-
var _a, _b, _c, _d;
|
|
748
|
-
let j = inputObjectTypes.length;
|
|
749
|
-
while (j >= 0) {
|
|
750
|
-
--j;
|
|
751
|
-
const inputType = inputObjectTypes[j];
|
|
752
|
-
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)))) {
|
|
753
|
-
inputObjectTypes.splice(j, 1);
|
|
754
|
-
} else {
|
|
755
|
-
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;
|
|
756
|
-
while (k >= 0) {
|
|
757
|
-
--k;
|
|
758
|
-
const field = (_d = inputType === null || inputType === void 0 ? void 0 : inputType.fields) === null || _d === void 0 ? void 0 : _d[k];
|
|
759
|
-
if (field && hiddenFields.includes(field.name)) {
|
|
760
|
-
inputObjectTypes[j].fields.splice(k, 1);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
__name(hideInputObjectTypesAndRelatedFields, "hideInputObjectTypesAndRelatedFields");
|
|
767
|
-
exports2.hideInputObjectTypesAndRelatedFields = hideInputObjectTypesAndRelatedFields;
|
|
768
|
-
}
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/aggregate-helpers.js
|
|
772
|
-
var require_aggregate_helpers = __commonJS({
|
|
773
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/aggregate-helpers.js"(exports2) {
|
|
774
|
-
"use strict";
|
|
775
|
-
init_cjs_shims();
|
|
776
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
777
|
-
value: true
|
|
778
|
-
});
|
|
779
|
-
exports2.resolveAggregateOperationSupport = exports2.addMissingInputObjectTypesForAggregate = exports2.isAggregateInputType = void 0;
|
|
780
|
-
var isAggregateOutputType = /* @__PURE__ */ __name((name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name), "isAggregateOutputType");
|
|
781
|
-
var isAggregateInputType = /* @__PURE__ */ __name((name) => name.endsWith("CountAggregateInput") || name.endsWith("SumAggregateInput") || name.endsWith("AvgAggregateInput") || name.endsWith("MinAggregateInput") || name.endsWith("MaxAggregateInput"), "isAggregateInputType");
|
|
782
|
-
exports2.isAggregateInputType = isAggregateInputType;
|
|
783
|
-
function addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes) {
|
|
784
|
-
const aggregateOutputTypes = outputObjectTypes.filter(({ name }) => isAggregateOutputType(name));
|
|
785
|
-
for (const aggregateOutputType of aggregateOutputTypes) {
|
|
786
|
-
const name = aggregateOutputType.name.replace(/(?:OutputType|Output)$/, "");
|
|
787
|
-
inputObjectTypes.push({
|
|
788
|
-
constraints: {
|
|
789
|
-
maxNumFields: null,
|
|
790
|
-
minNumFields: null
|
|
791
|
-
},
|
|
792
|
-
name: `${name}Input`,
|
|
793
|
-
fields: aggregateOutputType.fields.map((field) => ({
|
|
794
|
-
name: field.name,
|
|
795
|
-
isNullable: false,
|
|
796
|
-
isRequired: false,
|
|
797
|
-
inputTypes: [
|
|
798
|
-
{
|
|
799
|
-
isList: false,
|
|
800
|
-
type: "True",
|
|
801
|
-
location: "scalar"
|
|
802
|
-
}
|
|
803
|
-
]
|
|
804
|
-
}))
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
__name(addMissingInputObjectTypesForAggregate, "addMissingInputObjectTypesForAggregate");
|
|
809
|
-
exports2.addMissingInputObjectTypesForAggregate = addMissingInputObjectTypesForAggregate;
|
|
810
|
-
function resolveAggregateOperationSupport(inputObjectTypes) {
|
|
811
|
-
const aggregateOperationSupport = {};
|
|
812
|
-
for (const inputType of inputObjectTypes) {
|
|
813
|
-
if ((0, exports2.isAggregateInputType)(inputType.name)) {
|
|
814
|
-
const name = inputType.name.replace("AggregateInput", "");
|
|
815
|
-
if (name.endsWith("Count")) {
|
|
816
|
-
const model = name.replace("Count", "");
|
|
817
|
-
aggregateOperationSupport[model] = {
|
|
818
|
-
...aggregateOperationSupport[model],
|
|
819
|
-
count: true
|
|
820
|
-
};
|
|
821
|
-
} else if (name.endsWith("Min")) {
|
|
822
|
-
const model = name.replace("Min", "");
|
|
823
|
-
aggregateOperationSupport[model] = {
|
|
824
|
-
...aggregateOperationSupport[model],
|
|
825
|
-
min: true
|
|
826
|
-
};
|
|
827
|
-
} else if (name.endsWith("Max")) {
|
|
828
|
-
const model = name.replace("Max", "");
|
|
829
|
-
aggregateOperationSupport[model] = {
|
|
830
|
-
...aggregateOperationSupport[model],
|
|
831
|
-
max: true
|
|
832
|
-
};
|
|
833
|
-
} else if (name.endsWith("Sum")) {
|
|
834
|
-
const model = name.replace("Sum", "");
|
|
835
|
-
aggregateOperationSupport[model] = {
|
|
836
|
-
...aggregateOperationSupport[model],
|
|
837
|
-
sum: true
|
|
838
|
-
};
|
|
839
|
-
} else if (name.endsWith("Avg")) {
|
|
840
|
-
const model = name.replace("Avg", "");
|
|
841
|
-
aggregateOperationSupport[model] = {
|
|
842
|
-
...aggregateOperationSupport[model],
|
|
843
|
-
avg: true
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
return aggregateOperationSupport;
|
|
849
|
-
}
|
|
850
|
-
__name(resolveAggregateOperationSupport, "resolveAggregateOperationSupport");
|
|
851
|
-
exports2.resolveAggregateOperationSupport = resolveAggregateOperationSupport;
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
|
|
855
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/formatFile.js
|
|
856
|
-
var require_formatFile = __commonJS({
|
|
857
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/formatFile.js"(exports2) {
|
|
858
|
-
"use strict";
|
|
859
|
-
init_cjs_shims();
|
|
860
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
861
|
-
return mod && mod.__esModule ? mod : {
|
|
862
|
-
"default": mod
|
|
863
|
-
};
|
|
864
|
-
};
|
|
865
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
866
|
-
value: true
|
|
867
|
-
});
|
|
868
|
-
exports2.formatFile = void 0;
|
|
869
|
-
var prettier_1 = __importDefault(require("prettier"));
|
|
870
|
-
var formatFile2 = /* @__PURE__ */ __name((content) => {
|
|
871
|
-
return new Promise((res, rej) => prettier_1.default.resolveConfig(process.cwd()).then((options) => {
|
|
872
|
-
let formatOptions = options;
|
|
873
|
-
if (!options) {
|
|
874
|
-
formatOptions = {
|
|
875
|
-
trailingComma: "all",
|
|
876
|
-
tabWidth: 2,
|
|
877
|
-
printWidth: 80,
|
|
878
|
-
bracketSpacing: true,
|
|
879
|
-
semi: true,
|
|
880
|
-
singleQuote: true,
|
|
881
|
-
useTabs: false
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
try {
|
|
885
|
-
const formatted = prettier_1.default.format(content, {
|
|
886
|
-
...formatOptions,
|
|
887
|
-
parser: "typescript"
|
|
888
|
-
});
|
|
889
|
-
res(formatted);
|
|
890
|
-
} catch (error) {
|
|
891
|
-
rej(error);
|
|
892
|
-
}
|
|
893
|
-
}));
|
|
894
|
-
}, "formatFile");
|
|
895
|
-
exports2.formatFile = formatFile2;
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
|
|
899
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/writeIndexFile.js
|
|
900
|
-
var require_writeIndexFile = __commonJS({
|
|
901
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/writeIndexFile.js"(exports2) {
|
|
902
|
-
"use strict";
|
|
903
|
-
init_cjs_shims();
|
|
904
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
905
|
-
return mod && mod.__esModule ? mod : {
|
|
906
|
-
"default": mod
|
|
907
|
-
};
|
|
908
|
-
};
|
|
909
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
910
|
-
value: true
|
|
911
|
-
});
|
|
912
|
-
exports2.writeIndexFile = exports2.addIndexExport = void 0;
|
|
913
|
-
var path_1 = __importDefault(require("path"));
|
|
914
|
-
var writeFileSafely_1 = require_writeFileSafely();
|
|
915
|
-
var indexExports = /* @__PURE__ */ new Set();
|
|
916
|
-
var addIndexExport = /* @__PURE__ */ __name((filePath) => {
|
|
917
|
-
indexExports.add(filePath);
|
|
918
|
-
}, "addIndexExport");
|
|
919
|
-
exports2.addIndexExport = addIndexExport;
|
|
920
|
-
function normalizePath(path7) {
|
|
921
|
-
if (typeof path7 !== "string") {
|
|
922
|
-
throw new TypeError("Expected argument path to be a string");
|
|
923
|
-
}
|
|
924
|
-
if (path7 === "\\" || path7 === "/") return "/";
|
|
925
|
-
let len = path7.length;
|
|
926
|
-
if (len <= 1) return path7;
|
|
927
|
-
let prefix = "";
|
|
928
|
-
if (len > 4 && path7[3] === "\\") {
|
|
929
|
-
let ch = path7[2];
|
|
930
|
-
if ((ch === "?" || ch === ".") && path7.slice(0, 2) === "\\\\") {
|
|
931
|
-
path7 = path7.slice(2);
|
|
932
|
-
prefix = "//";
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
let segs = path7.split(/[/\\]+/);
|
|
936
|
-
return prefix + segs.join("/");
|
|
937
|
-
}
|
|
938
|
-
__name(normalizePath, "normalizePath");
|
|
939
|
-
var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
940
|
-
const rows = Array.from(indexExports).map((filePath) => {
|
|
941
|
-
let relativePath = path_1.default.relative(path_1.default.dirname(indexPath), filePath);
|
|
942
|
-
if (relativePath.endsWith(".ts")) {
|
|
943
|
-
relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
|
|
944
|
-
}
|
|
945
|
-
const normalized = normalizePath(relativePath);
|
|
946
|
-
return `export * from './${normalized}'`;
|
|
947
|
-
});
|
|
948
|
-
const content = rows.join("\n");
|
|
949
|
-
await (0, writeFileSafely_1.writeFileSafely)(indexPath, content, false);
|
|
950
|
-
}, "writeIndexFile");
|
|
951
|
-
exports2.writeIndexFile = writeIndexFile;
|
|
952
|
-
}
|
|
953
|
-
});
|
|
954
|
-
|
|
955
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/writeFileSafely.js
|
|
956
|
-
var require_writeFileSafely = __commonJS({
|
|
957
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/writeFileSafely.js"(exports2) {
|
|
958
|
-
"use strict";
|
|
959
|
-
init_cjs_shims();
|
|
960
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
961
|
-
return mod && mod.__esModule ? mod : {
|
|
962
|
-
"default": mod
|
|
963
|
-
};
|
|
964
|
-
};
|
|
965
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
966
|
-
value: true
|
|
967
|
-
});
|
|
968
|
-
exports2.writeFileSafely = void 0;
|
|
969
|
-
var fs_1 = __importDefault(require("fs"));
|
|
970
|
-
var path_1 = __importDefault(require("path"));
|
|
971
|
-
var formatFile_1 = require_formatFile();
|
|
972
|
-
var writeIndexFile_1 = require_writeIndexFile();
|
|
973
|
-
var writeFileSafely2 = /* @__PURE__ */ __name(async (writeLocation, content, addToIndex = true) => {
|
|
974
|
-
fs_1.default.mkdirSync(path_1.default.dirname(writeLocation), {
|
|
975
|
-
recursive: true
|
|
976
|
-
});
|
|
977
|
-
fs_1.default.writeFileSync(writeLocation, await (0, formatFile_1.formatFile)(content));
|
|
978
|
-
if (addToIndex) {
|
|
979
|
-
(0, writeIndexFile_1.addIndexExport)(writeLocation);
|
|
980
|
-
}
|
|
981
|
-
}, "writeFileSafely");
|
|
982
|
-
exports2.writeFileSafely = writeFileSafely2;
|
|
983
|
-
}
|
|
984
|
-
});
|
|
985
|
-
|
|
986
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/transformer.js
|
|
987
|
-
var require_transformer = __commonJS({
|
|
988
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/transformer.js"(exports2) {
|
|
989
|
-
"use strict";
|
|
990
|
-
init_cjs_shims();
|
|
991
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
992
|
-
return mod && mod.__esModule ? mod : {
|
|
993
|
-
"default": mod
|
|
994
|
-
};
|
|
995
|
-
};
|
|
996
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
997
|
-
value: true
|
|
998
|
-
});
|
|
999
|
-
var path_1 = __importDefault(require("path"));
|
|
1000
|
-
var helpers_1 = require_helpers2();
|
|
1001
|
-
var aggregate_helpers_1 = require_aggregate_helpers();
|
|
1002
|
-
var writeFileSafely_1 = require_writeFileSafely();
|
|
1003
|
-
var writeIndexFile_1 = require_writeIndexFile();
|
|
1004
|
-
var Transformer = class Transformer2 {
|
|
1005
|
-
static {
|
|
1006
|
-
__name(this, "Transformer");
|
|
1007
|
-
}
|
|
1008
|
-
constructor(params) {
|
|
1009
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1010
|
-
this.schemaImports = /* @__PURE__ */ new Set();
|
|
1011
|
-
this.hasJson = false;
|
|
1012
|
-
this.name = (_a = params.name) !== null && _a !== void 0 ? _a : "";
|
|
1013
|
-
this.fields = (_b = params.fields) !== null && _b !== void 0 ? _b : [];
|
|
1014
|
-
this.models = (_c = params.models) !== null && _c !== void 0 ? _c : [];
|
|
1015
|
-
this.modelOperations = (_d = params.modelOperations) !== null && _d !== void 0 ? _d : [];
|
|
1016
|
-
this.aggregateOperationSupport = (_e = params.aggregateOperationSupport) !== null && _e !== void 0 ? _e : {};
|
|
1017
|
-
this.enumTypes = (_f = params.enumTypes) !== null && _f !== void 0 ? _f : [];
|
|
1018
|
-
}
|
|
1019
|
-
static setOutputPath(outPath) {
|
|
1020
|
-
this.outputPath = outPath;
|
|
1021
|
-
}
|
|
1022
|
-
static setIsGenerateSelect(isGenerateSelect) {
|
|
1023
|
-
this.isGenerateSelect = isGenerateSelect;
|
|
1024
|
-
}
|
|
1025
|
-
static setIsGenerateInclude(isGenerateInclude) {
|
|
1026
|
-
this.isGenerateInclude = isGenerateInclude;
|
|
1027
|
-
}
|
|
1028
|
-
static getOutputPath() {
|
|
1029
|
-
return this.outputPath;
|
|
1030
|
-
}
|
|
1031
|
-
static setPrismaClientOutputPath(prismaClientCustomPath) {
|
|
1032
|
-
this.prismaClientOutputPath = prismaClientCustomPath;
|
|
1033
|
-
this.isCustomPrismaClientOutputPath = prismaClientCustomPath !== "@prisma/client";
|
|
1034
|
-
}
|
|
1035
|
-
static async generateIndex() {
|
|
1036
|
-
const indexPath = path_1.default.join(Transformer2.outputPath, "schemas/index.ts");
|
|
1037
|
-
await (0, writeIndexFile_1.writeIndexFile)(indexPath);
|
|
1038
|
-
}
|
|
1039
|
-
async generateEnumSchemas() {
|
|
1040
|
-
for (const enumType2 of this.enumTypes) {
|
|
1041
|
-
const { name, values } = enumType2;
|
|
1042
|
-
await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/enums/${name}.schema.ts`), `${this.generateImportZodStatement()}
|
|
1043
|
-
${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)})`)}`);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
generateImportZodStatement() {
|
|
1047
|
-
return "import { z } from 'zod';\n";
|
|
1048
|
-
}
|
|
1049
|
-
generateExportSchemaStatement(name, schema) {
|
|
1050
|
-
return `export const ${name}Schema = ${schema}`;
|
|
1051
|
-
}
|
|
1052
|
-
async generateObjectSchema() {
|
|
1053
|
-
const zodObjectSchemaFields = this.generateObjectSchemaFields();
|
|
1054
|
-
const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);
|
|
1055
|
-
const objectSchemaName = this.resolveObjectSchemaName();
|
|
1056
|
-
await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(Transformer2.outputPath, `schemas/objects/${objectSchemaName}.schema.ts`), objectSchema);
|
|
1057
|
-
}
|
|
1058
|
-
generateObjectSchemaFields() {
|
|
1059
|
-
const zodObjectSchemaFields = this.fields.map((field) => this.generateObjectSchemaField(field)).flatMap((item) => item).map((item) => {
|
|
1060
|
-
const [zodStringWithMainType, field, skipValidators] = item;
|
|
1061
|
-
const value = skipValidators ? zodStringWithMainType : this.generateFieldValidators(zodStringWithMainType, field);
|
|
1062
|
-
return value.trim();
|
|
1063
|
-
});
|
|
1064
|
-
return zodObjectSchemaFields;
|
|
1065
|
-
}
|
|
1066
|
-
generateObjectSchemaField(field) {
|
|
1067
|
-
let lines = field.inputTypes;
|
|
1068
|
-
if (lines.length === 0) {
|
|
1069
|
-
return [];
|
|
1070
|
-
}
|
|
1071
|
-
let alternatives = lines.reduce((result, inputType) => {
|
|
1072
|
-
if (inputType.type === "String") {
|
|
1073
|
-
result.push(this.wrapWithZodValidators("z.string()", field, inputType));
|
|
1074
|
-
} else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
|
|
1075
|
-
result.push(this.wrapWithZodValidators("z.number()", field, inputType));
|
|
1076
|
-
} else if (inputType.type === "BigInt") {
|
|
1077
|
-
result.push(this.wrapWithZodValidators("z.bigint()", field, inputType));
|
|
1078
|
-
} else if (inputType.type === "Boolean") {
|
|
1079
|
-
result.push(this.wrapWithZodValidators("z.boolean()", field, inputType));
|
|
1080
|
-
} else if (inputType.type === "DateTime") {
|
|
1081
|
-
result.push(this.wrapWithZodValidators("z.coerce.date()", field, inputType));
|
|
1082
|
-
} else if (inputType.type === "Json") {
|
|
1083
|
-
this.hasJson = true;
|
|
1084
|
-
result.push(this.wrapWithZodValidators("jsonSchema", field, inputType));
|
|
1085
|
-
} else if (inputType.type === "True") {
|
|
1086
|
-
result.push(this.wrapWithZodValidators("z.literal(true)", field, inputType));
|
|
1087
|
-
} else if (inputType.type === "Bytes") {
|
|
1088
|
-
result.push(this.wrapWithZodValidators("z.instanceof(Buffer)", field, inputType));
|
|
1089
|
-
} else {
|
|
1090
|
-
const isEnum = inputType.location === "enumTypes";
|
|
1091
|
-
if (inputType.namespace === "prisma" || isEnum) {
|
|
1092
|
-
if (inputType.type !== this.name && typeof inputType.type === "string") {
|
|
1093
|
-
this.addSchemaImport(inputType.type);
|
|
1094
|
-
}
|
|
1095
|
-
result.push(this.generatePrismaStringLine(field, inputType, lines.length));
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
return result;
|
|
1099
|
-
}, []);
|
|
1100
|
-
if (alternatives.length === 0) {
|
|
1101
|
-
return [];
|
|
1102
|
-
}
|
|
1103
|
-
if (alternatives.length > 1) {
|
|
1104
|
-
alternatives = alternatives.map((alter) => alter.replace(".optional()", ""));
|
|
1105
|
-
}
|
|
1106
|
-
const fieldName = alternatives.some((alt) => alt.includes(":")) ? "" : ` ${field.name}:`;
|
|
1107
|
-
const opt = !field.isRequired ? ".optional()" : "";
|
|
1108
|
-
let resString = alternatives.length === 1 ? alternatives.join(",\r\n") : `z.union([${alternatives.join(",\r\n")}])${opt}`;
|
|
1109
|
-
if (field.isNullable) {
|
|
1110
|
-
resString += ".nullable()";
|
|
1111
|
-
}
|
|
1112
|
-
return [
|
|
1113
|
-
[
|
|
1114
|
-
` ${fieldName} ${resString} `,
|
|
1115
|
-
field,
|
|
1116
|
-
true
|
|
1117
|
-
]
|
|
1118
|
-
];
|
|
1119
|
-
}
|
|
1120
|
-
wrapWithZodValidators(mainValidator, field, inputType) {
|
|
1121
|
-
let line = "";
|
|
1122
|
-
line = mainValidator;
|
|
1123
|
-
if (inputType.isList) {
|
|
1124
|
-
line += ".array()";
|
|
1125
|
-
}
|
|
1126
|
-
if (!field.isRequired) {
|
|
1127
|
-
line += ".optional()";
|
|
1128
|
-
}
|
|
1129
|
-
return line;
|
|
1130
|
-
}
|
|
1131
|
-
addSchemaImport(name) {
|
|
1132
|
-
this.schemaImports.add(name);
|
|
1133
|
-
}
|
|
1134
|
-
generatePrismaStringLine(field, inputType, inputsLength) {
|
|
1135
|
-
const isEnum = inputType.location === "enumTypes";
|
|
1136
|
-
const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputType.type);
|
|
1137
|
-
let objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputType.type}ObjectSchema`;
|
|
1138
|
-
let enumSchemaLine = `${inputType.type}Schema`;
|
|
1139
|
-
const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
|
|
1140
|
-
const arr = inputType.isList ? ".array()" : "";
|
|
1141
|
-
const opt = !field.isRequired ? ".optional()" : "";
|
|
1142
|
-
return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}` : `z.lazy(() => ${schema})${arr}${opt}`;
|
|
1143
|
-
}
|
|
1144
|
-
generateFieldValidators(zodStringWithMainType, field) {
|
|
1145
|
-
const { isRequired, isNullable } = field;
|
|
1146
|
-
if (!isRequired) {
|
|
1147
|
-
zodStringWithMainType += ".optional()";
|
|
1148
|
-
}
|
|
1149
|
-
if (isNullable) {
|
|
1150
|
-
zodStringWithMainType += ".nullable()";
|
|
1151
|
-
}
|
|
1152
|
-
return zodStringWithMainType;
|
|
1153
|
-
}
|
|
1154
|
-
prepareObjectSchema(zodObjectSchemaFields) {
|
|
1155
|
-
const objectSchema = `${this.generateExportObjectSchemaStatement(this.addFinalWrappers({
|
|
1156
|
-
zodStringFields: zodObjectSchemaFields
|
|
1157
|
-
}))}
|
|
1158
|
-
`;
|
|
1159
|
-
const prismaImportStatement = this.generateImportPrismaStatement();
|
|
1160
|
-
const json = this.generateJsonSchemaImplementation();
|
|
1161
|
-
return `${this.generateObjectSchemaImportStatements()}${prismaImportStatement}${json}${objectSchema}`;
|
|
1162
|
-
}
|
|
1163
|
-
generateExportObjectSchemaStatement(schema) {
|
|
1164
|
-
let name = this.name;
|
|
1165
|
-
let exportName = this.name;
|
|
1166
|
-
if (Transformer2.provider === "mongodb") {
|
|
1167
|
-
if ((0, helpers_1.isMongodbRawOp)(name)) {
|
|
1168
|
-
name = Transformer2.rawOpsMap[name];
|
|
1169
|
-
exportName = name.replace("Args", "");
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
if ((0, aggregate_helpers_1.isAggregateInputType)(name)) {
|
|
1173
|
-
name = `${name}Type`;
|
|
1174
|
-
}
|
|
1175
|
-
const end = `export const ${exportName}ObjectSchema = Schema`;
|
|
1176
|
-
return `const Schema: z.ZodType<Prisma.${name}> = ${schema};
|
|
1177
|
-
|
|
1178
|
-
${end}`;
|
|
1179
|
-
}
|
|
1180
|
-
addFinalWrappers({ zodStringFields }) {
|
|
1181
|
-
const fields = [
|
|
1182
|
-
...zodStringFields
|
|
1183
|
-
];
|
|
1184
|
-
return this.wrapWithZodObject(fields) + ".strict()";
|
|
1185
|
-
}
|
|
1186
|
-
generateImportPrismaStatement() {
|
|
1187
|
-
let prismaClientImportPath;
|
|
1188
|
-
if (Transformer2.isCustomPrismaClientOutputPath) {
|
|
1189
|
-
const fromPath = path_1.default.join(Transformer2.outputPath, "schemas", "objects");
|
|
1190
|
-
const toPath = Transformer2.prismaClientOutputPath;
|
|
1191
|
-
const relativePathFromOutputToPrismaClient = path_1.default.relative(fromPath, toPath).split(path_1.default.sep).join(path_1.default.posix.sep);
|
|
1192
|
-
prismaClientImportPath = relativePathFromOutputToPrismaClient;
|
|
1193
|
-
} else {
|
|
1194
|
-
prismaClientImportPath = Transformer2.prismaClientOutputPath;
|
|
1195
|
-
}
|
|
1196
|
-
return `import type { Prisma } from '${prismaClientImportPath}';
|
|
1197
|
-
|
|
1198
|
-
`;
|
|
1199
|
-
}
|
|
1200
|
-
generateJsonSchemaImplementation() {
|
|
1201
|
-
let jsonSchemaImplementation = "";
|
|
1202
|
-
if (this.hasJson) {
|
|
1203
|
-
jsonSchemaImplementation += `
|
|
1204
|
-
`;
|
|
1205
|
-
jsonSchemaImplementation += `const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
1206
|
-
`;
|
|
1207
|
-
jsonSchemaImplementation += `const jsonSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>
|
|
1208
|
-
`;
|
|
1209
|
-
jsonSchemaImplementation += ` z.union([literalSchema, z.array(jsonSchema.nullable()), z.record(jsonSchema.nullable())])
|
|
1210
|
-
`;
|
|
1211
|
-
jsonSchemaImplementation += `);
|
|
1212
|
-
|
|
1213
|
-
`;
|
|
1214
|
-
}
|
|
1215
|
-
return jsonSchemaImplementation;
|
|
1216
|
-
}
|
|
1217
|
-
generateObjectSchemaImportStatements() {
|
|
1218
|
-
let generatedImports = this.generateImportZodStatement();
|
|
1219
|
-
generatedImports += this.generateSchemaImports();
|
|
1220
|
-
generatedImports += "\n\n";
|
|
1221
|
-
return generatedImports;
|
|
1222
|
-
}
|
|
1223
|
-
generateSchemaImports() {
|
|
1224
|
-
return [
|
|
1225
|
-
...this.schemaImports
|
|
1226
|
-
].map((name) => {
|
|
1227
|
-
const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(name);
|
|
1228
|
-
if (isModelQueryType) {
|
|
1229
|
-
return `import { ${this.resolveModelQuerySchemaName(modelName, queryName)} } from '../${queryName}${modelName}.schema'`;
|
|
1230
|
-
} else if (Transformer2.enumNames.includes(name)) {
|
|
1231
|
-
return `import { ${name}Schema } from '../enums/${name}.schema'`;
|
|
1232
|
-
} else {
|
|
1233
|
-
return `import { ${name}ObjectSchema } from './${name}.schema'`;
|
|
1234
|
-
}
|
|
1235
|
-
}).join(";\r\n");
|
|
1236
|
-
}
|
|
1237
|
-
checkIsModelQueryType(type) {
|
|
1238
|
-
const modelQueryTypeSuffixToQueryName = {
|
|
1239
|
-
FindManyArgs: "findMany"
|
|
1240
|
-
};
|
|
1241
|
-
for (const modelQueryType of [
|
|
1242
|
-
"FindManyArgs"
|
|
1243
|
-
]) {
|
|
1244
|
-
if (type.includes(modelQueryType)) {
|
|
1245
|
-
const modelQueryTypeSuffixIndex = type.indexOf(modelQueryType);
|
|
1246
|
-
return {
|
|
1247
|
-
isModelQueryType: true,
|
|
1248
|
-
modelName: type.substring(0, modelQueryTypeSuffixIndex),
|
|
1249
|
-
queryName: modelQueryTypeSuffixToQueryName[modelQueryType]
|
|
1250
|
-
};
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
return {
|
|
1254
|
-
isModelQueryType: false
|
|
1255
|
-
};
|
|
1256
|
-
}
|
|
1257
|
-
resolveModelQuerySchemaName(modelName, queryName) {
|
|
1258
|
-
const modelNameCapitalized = modelName.charAt(0).toUpperCase() + modelName.slice(1);
|
|
1259
|
-
const queryNameCapitalized = queryName.charAt(0).toUpperCase() + queryName.slice(1);
|
|
1260
|
-
return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
|
|
1261
|
-
}
|
|
1262
|
-
wrapWithZodUnion(zodStringFields) {
|
|
1263
|
-
let wrapped = "";
|
|
1264
|
-
wrapped += "z.union([";
|
|
1265
|
-
wrapped += "\n";
|
|
1266
|
-
wrapped += " " + zodStringFields.join(",");
|
|
1267
|
-
wrapped += "\n";
|
|
1268
|
-
wrapped += "])";
|
|
1269
|
-
return wrapped;
|
|
1270
|
-
}
|
|
1271
|
-
wrapWithZodObject(zodStringFields) {
|
|
1272
|
-
let wrapped = "";
|
|
1273
|
-
wrapped += "z.object({";
|
|
1274
|
-
wrapped += "\n";
|
|
1275
|
-
wrapped += " " + zodStringFields;
|
|
1276
|
-
wrapped += "\n";
|
|
1277
|
-
wrapped += "})";
|
|
1278
|
-
return wrapped;
|
|
1279
|
-
}
|
|
1280
|
-
resolveObjectSchemaName() {
|
|
1281
|
-
let name = this.name;
|
|
1282
|
-
let exportName = this.name;
|
|
1283
|
-
if ((0, helpers_1.isMongodbRawOp)(name)) {
|
|
1284
|
-
name = Transformer2.rawOpsMap[name];
|
|
1285
|
-
exportName = name.replace("Args", "");
|
|
1286
|
-
}
|
|
1287
|
-
return exportName;
|
|
1288
|
-
}
|
|
1289
|
-
async generateModelSchemas() {
|
|
1290
|
-
for (const modelOperation of this.modelOperations) {
|
|
1291
|
-
const {
|
|
1292
|
-
model: modelName,
|
|
1293
|
-
findUnique,
|
|
1294
|
-
findFirst,
|
|
1295
|
-
findMany,
|
|
1296
|
-
// @ts-ignore
|
|
1297
|
-
createOne,
|
|
1298
|
-
createMany,
|
|
1299
|
-
// @ts-ignore
|
|
1300
|
-
deleteOne,
|
|
1301
|
-
// @ts-ignore
|
|
1302
|
-
updateOne,
|
|
1303
|
-
deleteMany,
|
|
1304
|
-
updateMany,
|
|
1305
|
-
// @ts-ignore
|
|
1306
|
-
upsertOne,
|
|
1307
|
-
aggregate,
|
|
1308
|
-
groupBy
|
|
1309
|
-
} = modelOperation;
|
|
1310
|
-
const model = (0, helpers_1.findModelByName)(this.models, modelName);
|
|
1311
|
-
const { selectImport, includeImport, selectZodSchemaLine, includeZodSchemaLine, selectZodSchemaLineLazy, includeZodSchemaLineLazy } = this.resolveSelectIncludeImportAndZodSchemaLine(model);
|
|
1312
|
-
const { orderByImport, orderByZodSchemaLine } = this.resolveOrderByWithRelationImportAndZodSchemaLine(model);
|
|
1313
|
-
if (findUnique) {
|
|
1314
|
-
const imports = [
|
|
1315
|
-
selectImport,
|
|
1316
|
-
includeImport,
|
|
1317
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
1318
|
-
];
|
|
1319
|
-
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 })`)}`);
|
|
1320
|
-
}
|
|
1321
|
-
if (findFirst) {
|
|
1322
|
-
const imports = [
|
|
1323
|
-
selectImport,
|
|
1324
|
-
includeImport,
|
|
1325
|
-
orderByImport,
|
|
1326
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
|
|
1327
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
1328
|
-
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
1329
|
-
];
|
|
1330
|
-
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() })`)}`);
|
|
1331
|
-
}
|
|
1332
|
-
if (findMany) {
|
|
1333
|
-
const imports = [
|
|
1334
|
-
selectImport,
|
|
1335
|
-
includeImport,
|
|
1336
|
-
orderByImport,
|
|
1337
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
|
|
1338
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
1339
|
-
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
1340
|
-
];
|
|
1341
|
-
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() })`)}`);
|
|
1342
|
-
}
|
|
1343
|
-
if (createOne) {
|
|
1344
|
-
const imports = [
|
|
1345
|
-
selectImport,
|
|
1346
|
-
includeImport,
|
|
1347
|
-
`import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
|
|
1348
|
-
`import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`
|
|
1349
|
-
];
|
|
1350
|
-
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]) })`)}`);
|
|
1351
|
-
}
|
|
1352
|
-
if (createMany) {
|
|
1353
|
-
const imports = [
|
|
1354
|
-
`import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`
|
|
1355
|
-
];
|
|
1356
|
-
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()"} })`)}`);
|
|
1357
|
-
}
|
|
1358
|
-
if (deleteOne) {
|
|
1359
|
-
const imports = [
|
|
1360
|
-
selectImport,
|
|
1361
|
-
includeImport,
|
|
1362
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
1363
|
-
];
|
|
1364
|
-
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 })`)}`);
|
|
1365
|
-
}
|
|
1366
|
-
if (deleteMany) {
|
|
1367
|
-
const imports = [
|
|
1368
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
1369
|
-
];
|
|
1370
|
-
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() })`)}`);
|
|
1371
|
-
}
|
|
1372
|
-
if (updateOne) {
|
|
1373
|
-
const imports = [
|
|
1374
|
-
selectImport,
|
|
1375
|
-
includeImport,
|
|
1376
|
-
`import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
|
|
1377
|
-
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
|
|
1378
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
1379
|
-
];
|
|
1380
|
-
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 })`)}`);
|
|
1381
|
-
}
|
|
1382
|
-
if (updateMany) {
|
|
1383
|
-
const imports = [
|
|
1384
|
-
`import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,
|
|
1385
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
1386
|
-
];
|
|
1387
|
-
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() })`)}`);
|
|
1388
|
-
}
|
|
1389
|
-
if (upsertOne) {
|
|
1390
|
-
const imports = [
|
|
1391
|
-
selectImport,
|
|
1392
|
-
includeImport,
|
|
1393
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
1394
|
-
`import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
|
|
1395
|
-
`import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`,
|
|
1396
|
-
`import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
|
|
1397
|
-
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`
|
|
1398
|
-
];
|
|
1399
|
-
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 ]) })`)}`);
|
|
1400
|
-
}
|
|
1401
|
-
if (aggregate) {
|
|
1402
|
-
const imports = [
|
|
1403
|
-
orderByImport,
|
|
1404
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
|
|
1405
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
1406
|
-
];
|
|
1407
|
-
const aggregateOperations = [];
|
|
1408
|
-
if (this.aggregateOperationSupport[modelName].count) {
|
|
1409
|
-
imports.push(`import { ${modelName}CountAggregateInputObjectSchema } from './objects/${modelName}CountAggregateInput.schema'`);
|
|
1410
|
-
aggregateOperations.push(`_count: z.union([ z.literal(true), ${modelName}CountAggregateInputObjectSchema ]).optional()`);
|
|
1411
|
-
}
|
|
1412
|
-
if (this.aggregateOperationSupport[modelName].min) {
|
|
1413
|
-
imports.push(`import { ${modelName}MinAggregateInputObjectSchema } from './objects/${modelName}MinAggregateInput.schema'`);
|
|
1414
|
-
aggregateOperations.push(`_min: ${modelName}MinAggregateInputObjectSchema.optional()`);
|
|
1415
|
-
}
|
|
1416
|
-
if (this.aggregateOperationSupport[modelName].max) {
|
|
1417
|
-
imports.push(`import { ${modelName}MaxAggregateInputObjectSchema } from './objects/${modelName}MaxAggregateInput.schema'`);
|
|
1418
|
-
aggregateOperations.push(`_max: ${modelName}MaxAggregateInputObjectSchema.optional()`);
|
|
1419
|
-
}
|
|
1420
|
-
if (this.aggregateOperationSupport[modelName].avg) {
|
|
1421
|
-
imports.push(`import { ${modelName}AvgAggregateInputObjectSchema } from './objects/${modelName}AvgAggregateInput.schema'`);
|
|
1422
|
-
aggregateOperations.push(`_avg: ${modelName}AvgAggregateInputObjectSchema.optional()`);
|
|
1423
|
-
}
|
|
1424
|
-
if (this.aggregateOperationSupport[modelName].sum) {
|
|
1425
|
-
imports.push(`import { ${modelName}SumAggregateInputObjectSchema } from './objects/${modelName}SumAggregateInput.schema'`);
|
|
1426
|
-
aggregateOperations.push(`_sum: ${modelName}SumAggregateInputObjectSchema.optional()`);
|
|
1427
|
-
}
|
|
1428
|
-
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(", ")} })`)}`);
|
|
1429
|
-
}
|
|
1430
|
-
if (groupBy) {
|
|
1431
|
-
const imports = [
|
|
1432
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
|
|
1433
|
-
`import { ${modelName}OrderByWithAggregationInputObjectSchema } from './objects/${modelName}OrderByWithAggregationInput.schema'`,
|
|
1434
|
-
`import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,
|
|
1435
|
-
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
1436
|
-
];
|
|
1437
|
-
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) })`)}`);
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
generateImportStatements(imports) {
|
|
1442
|
-
var _a;
|
|
1443
|
-
let generatedImports = this.generateImportZodStatement();
|
|
1444
|
-
generatedImports += (_a = imports === null || imports === void 0 ? void 0 : imports.filter((importItem) => !!importItem).join(";\r\n")) !== null && _a !== void 0 ? _a : "";
|
|
1445
|
-
generatedImports += "\n\n";
|
|
1446
|
-
return generatedImports;
|
|
1447
|
-
}
|
|
1448
|
-
resolveSelectIncludeImportAndZodSchemaLine(model) {
|
|
1449
|
-
const { name: modelName } = model;
|
|
1450
|
-
const hasRelationToAnotherModel = (0, helpers_1.checkModelHasModelRelation)(model);
|
|
1451
|
-
const selectImport = Transformer2.isGenerateSelect ? `import { ${modelName}SelectObjectSchema } from './objects/${modelName}Select.schema'` : "";
|
|
1452
|
-
const includeImport = Transformer2.isGenerateInclude && hasRelationToAnotherModel ? `import { ${modelName}IncludeObjectSchema } from './objects/${modelName}Include.schema'` : "";
|
|
1453
|
-
let selectZodSchemaLine = "";
|
|
1454
|
-
let includeZodSchemaLine = "";
|
|
1455
|
-
let selectZodSchemaLineLazy = "";
|
|
1456
|
-
let includeZodSchemaLineLazy = "";
|
|
1457
|
-
if (Transformer2.isGenerateSelect) {
|
|
1458
|
-
const zodSelectObjectSchema = `${modelName}SelectObjectSchema.optional()`;
|
|
1459
|
-
selectZodSchemaLine = `select: ${zodSelectObjectSchema},`;
|
|
1460
|
-
selectZodSchemaLineLazy = `select: z.lazy(() => ${zodSelectObjectSchema}),`;
|
|
1461
|
-
}
|
|
1462
|
-
if (Transformer2.isGenerateInclude && hasRelationToAnotherModel) {
|
|
1463
|
-
const zodIncludeObjectSchema = `${modelName}IncludeObjectSchema.optional()`;
|
|
1464
|
-
includeZodSchemaLine = `include: ${zodIncludeObjectSchema},`;
|
|
1465
|
-
includeZodSchemaLineLazy = `include: z.lazy(() => ${zodIncludeObjectSchema}),`;
|
|
1466
|
-
}
|
|
1467
|
-
return {
|
|
1468
|
-
selectImport,
|
|
1469
|
-
includeImport,
|
|
1470
|
-
selectZodSchemaLine,
|
|
1471
|
-
includeZodSchemaLine,
|
|
1472
|
-
selectZodSchemaLineLazy,
|
|
1473
|
-
includeZodSchemaLineLazy
|
|
1474
|
-
};
|
|
1475
|
-
}
|
|
1476
|
-
resolveOrderByWithRelationImportAndZodSchemaLine(model) {
|
|
1477
|
-
var _a;
|
|
1478
|
-
const { name: modelName } = model;
|
|
1479
|
-
let modelOrderBy = "";
|
|
1480
|
-
if ([
|
|
1481
|
-
"postgresql",
|
|
1482
|
-
"mysql"
|
|
1483
|
-
].includes(Transformer2.provider) && ((_a = Transformer2.previewFeatures) === null || _a === void 0 ? void 0 : _a.includes("fullTextSearch"))) {
|
|
1484
|
-
modelOrderBy = `${modelName}OrderByWithRelationAndSearchRelevanceInput`;
|
|
1485
|
-
} else {
|
|
1486
|
-
modelOrderBy = `${modelName}OrderByWithRelationInput`;
|
|
1487
|
-
}
|
|
1488
|
-
const orderByImport = `import { ${modelOrderBy}ObjectSchema } from './objects/${modelOrderBy}.schema'`;
|
|
1489
|
-
const orderByZodSchemaLine = `orderBy: z.union([${modelOrderBy}ObjectSchema, ${modelOrderBy}ObjectSchema.array()]).optional(),`;
|
|
1490
|
-
return {
|
|
1491
|
-
orderByImport,
|
|
1492
|
-
orderByZodSchemaLine
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
exports2.default = Transformer;
|
|
1497
|
-
Transformer.enumNames = [];
|
|
1498
|
-
Transformer.rawOpsMap = {};
|
|
1499
|
-
Transformer.outputPath = "./generated";
|
|
1500
|
-
Transformer.prismaClientOutputPath = "@prisma/client";
|
|
1501
|
-
Transformer.isCustomPrismaClientOutputPath = false;
|
|
1502
|
-
Transformer.isGenerateSelect = false;
|
|
1503
|
-
Transformer.isGenerateInclude = false;
|
|
1504
|
-
}
|
|
1505
|
-
});
|
|
1506
|
-
|
|
1507
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/model-helpers.js
|
|
1508
|
-
var require_model_helpers = __commonJS({
|
|
1509
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/model-helpers.js"(exports2) {
|
|
1510
|
-
"use strict";
|
|
1511
|
-
init_cjs_shims();
|
|
1512
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
1513
|
-
value: true
|
|
1514
|
-
});
|
|
1515
|
-
exports2.findModelByName = exports2.checkIsManyModelRelationField = exports2.checkIsModelRelationField = exports2.checkModelHasManyModelRelation = exports2.checkModelHasModelRelation = void 0;
|
|
1516
|
-
function checkModelHasModelRelation(model) {
|
|
1517
|
-
const { fields: modelFields } = model;
|
|
1518
|
-
for (const modelField of modelFields) {
|
|
1519
|
-
const isRelationField = checkIsModelRelationField(modelField);
|
|
1520
|
-
if (isRelationField) {
|
|
1521
|
-
return true;
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
return false;
|
|
1525
|
-
}
|
|
1526
|
-
__name(checkModelHasModelRelation, "checkModelHasModelRelation");
|
|
1527
|
-
exports2.checkModelHasModelRelation = checkModelHasModelRelation;
|
|
1528
|
-
function checkModelHasManyModelRelation(model) {
|
|
1529
|
-
const { fields: modelFields } = model;
|
|
1530
|
-
for (const modelField of modelFields) {
|
|
1531
|
-
const isManyRelationField = checkIsManyModelRelationField(modelField);
|
|
1532
|
-
if (isManyRelationField) {
|
|
1533
|
-
return true;
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
return false;
|
|
1537
|
-
}
|
|
1538
|
-
__name(checkModelHasManyModelRelation, "checkModelHasManyModelRelation");
|
|
1539
|
-
exports2.checkModelHasManyModelRelation = checkModelHasManyModelRelation;
|
|
1540
|
-
function checkIsModelRelationField(modelField) {
|
|
1541
|
-
const { kind, relationName } = modelField;
|
|
1542
|
-
return kind === "object" && !!relationName;
|
|
1543
|
-
}
|
|
1544
|
-
__name(checkIsModelRelationField, "checkIsModelRelationField");
|
|
1545
|
-
exports2.checkIsModelRelationField = checkIsModelRelationField;
|
|
1546
|
-
function checkIsManyModelRelationField(modelField) {
|
|
1547
|
-
return checkIsModelRelationField(modelField) && modelField.isList;
|
|
1548
|
-
}
|
|
1549
|
-
__name(checkIsManyModelRelationField, "checkIsManyModelRelationField");
|
|
1550
|
-
exports2.checkIsManyModelRelationField = checkIsManyModelRelationField;
|
|
1551
|
-
function findModelByName(models, modelName) {
|
|
1552
|
-
return models.find(({ name }) => name === modelName);
|
|
1553
|
-
}
|
|
1554
|
-
__name(findModelByName, "findModelByName");
|
|
1555
|
-
exports2.findModelByName = findModelByName;
|
|
1556
|
-
}
|
|
1557
|
-
});
|
|
1558
|
-
|
|
1559
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/include-helpers.js
|
|
1560
|
-
var require_include_helpers = __commonJS({
|
|
1561
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/include-helpers.js"(exports2) {
|
|
1562
|
-
"use strict";
|
|
1563
|
-
init_cjs_shims();
|
|
1564
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
1565
|
-
value: true
|
|
1566
|
-
});
|
|
1567
|
-
exports2.addMissingInputObjectTypesForInclude = void 0;
|
|
1568
|
-
var model_helpers_1 = require_model_helpers();
|
|
1569
|
-
function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
|
|
1570
|
-
const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
|
|
1571
|
-
for (const includeInputObjectType of generatedIncludeInputObjectTypes) {
|
|
1572
|
-
inputObjectTypes.push(includeInputObjectType);
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
__name(addMissingInputObjectTypesForInclude, "addMissingInputObjectTypesForInclude");
|
|
1576
|
-
exports2.addMissingInputObjectTypesForInclude = addMissingInputObjectTypesForInclude;
|
|
1577
|
-
function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
|
|
1578
|
-
const modelIncludeInputObjectTypes = [];
|
|
1579
|
-
for (const model of models) {
|
|
1580
|
-
const { name: modelName, fields: modelFields } = model;
|
|
1581
|
-
const fields = [];
|
|
1582
|
-
for (const modelField of modelFields) {
|
|
1583
|
-
const { name: modelFieldName, isList, type } = modelField;
|
|
1584
|
-
const isRelationField = (0, model_helpers_1.checkIsModelRelationField)(modelField);
|
|
1585
|
-
if (isRelationField) {
|
|
1586
|
-
const field = {
|
|
1587
|
-
name: modelFieldName,
|
|
1588
|
-
isRequired: false,
|
|
1589
|
-
isNullable: false,
|
|
1590
|
-
inputTypes: [
|
|
1591
|
-
{
|
|
1592
|
-
isList: false,
|
|
1593
|
-
type: "Boolean",
|
|
1594
|
-
location: "scalar"
|
|
1595
|
-
},
|
|
1596
|
-
{
|
|
1597
|
-
isList: false,
|
|
1598
|
-
type: isList ? `${type}FindManyArgs` : `${type}Args`,
|
|
1599
|
-
location: "inputObjectTypes",
|
|
1600
|
-
namespace: "prisma"
|
|
1601
|
-
}
|
|
1602
|
-
]
|
|
1603
|
-
};
|
|
1604
|
-
fields.push(field);
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
const hasRelationToAnotherModel = (0, model_helpers_1.checkModelHasModelRelation)(model);
|
|
1608
|
-
if (!hasRelationToAnotherModel) {
|
|
1609
|
-
continue;
|
|
1610
|
-
}
|
|
1611
|
-
const hasManyRelationToAnotherModel = (0, model_helpers_1.checkModelHasManyModelRelation)(model);
|
|
1612
|
-
const shouldAddCountField = hasManyRelationToAnotherModel;
|
|
1613
|
-
if (shouldAddCountField) {
|
|
1614
|
-
const inputTypes = [
|
|
1615
|
-
{
|
|
1616
|
-
isList: false,
|
|
1617
|
-
type: "Boolean",
|
|
1618
|
-
location: "scalar"
|
|
1619
|
-
}
|
|
1620
|
-
];
|
|
1621
|
-
if (isGenerateSelect) {
|
|
1622
|
-
inputTypes.push({
|
|
1623
|
-
isList: false,
|
|
1624
|
-
type: `${modelName}CountOutputTypeArgs`,
|
|
1625
|
-
location: "inputObjectTypes",
|
|
1626
|
-
namespace: "prisma"
|
|
1627
|
-
});
|
|
1628
|
-
}
|
|
1629
|
-
const _countField = {
|
|
1630
|
-
name: "_count",
|
|
1631
|
-
isRequired: false,
|
|
1632
|
-
isNullable: false,
|
|
1633
|
-
inputTypes
|
|
1634
|
-
};
|
|
1635
|
-
fields.push(_countField);
|
|
1636
|
-
}
|
|
1637
|
-
const modelIncludeInputObjectType = {
|
|
1638
|
-
name: `${modelName}Include`,
|
|
1639
|
-
constraints: {
|
|
1640
|
-
maxNumFields: null,
|
|
1641
|
-
minNumFields: null
|
|
1642
|
-
},
|
|
1643
|
-
fields
|
|
1644
|
-
};
|
|
1645
|
-
modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);
|
|
1646
|
-
}
|
|
1647
|
-
return modelIncludeInputObjectTypes;
|
|
1648
|
-
}
|
|
1649
|
-
__name(generateModelIncludeInputObjectTypes, "generateModelIncludeInputObjectTypes");
|
|
1650
|
-
}
|
|
1651
|
-
});
|
|
1652
|
-
|
|
1653
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/modelArgs-helpers.js
|
|
1654
|
-
var require_modelArgs_helpers = __commonJS({
|
|
1655
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/modelArgs-helpers.js"(exports2) {
|
|
1656
|
-
"use strict";
|
|
1657
|
-
init_cjs_shims();
|
|
1658
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
1659
|
-
value: true
|
|
1660
|
-
});
|
|
1661
|
-
exports2.addMissingInputObjectTypesForModelArgs = void 0;
|
|
1662
|
-
var model_helpers_1 = require_model_helpers();
|
|
1663
|
-
function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
|
|
1664
|
-
const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
|
|
1665
|
-
for (const modelArgsInputObjectType of modelArgsInputObjectTypes) {
|
|
1666
|
-
inputObjectTypes.push(modelArgsInputObjectType);
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
__name(addMissingInputObjectTypesForModelArgs, "addMissingInputObjectTypesForModelArgs");
|
|
1670
|
-
exports2.addMissingInputObjectTypesForModelArgs = addMissingInputObjectTypesForModelArgs;
|
|
1671
|
-
function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude) {
|
|
1672
|
-
const modelArgsInputObjectTypes = [];
|
|
1673
|
-
for (const model of models) {
|
|
1674
|
-
const { name: modelName } = model;
|
|
1675
|
-
const fields = [];
|
|
1676
|
-
if (isGenerateSelect) {
|
|
1677
|
-
const selectField = {
|
|
1678
|
-
name: "select",
|
|
1679
|
-
isRequired: false,
|
|
1680
|
-
isNullable: false,
|
|
1681
|
-
inputTypes: [
|
|
1682
|
-
{
|
|
1683
|
-
isList: false,
|
|
1684
|
-
type: `${modelName}Select`,
|
|
1685
|
-
location: "inputObjectTypes",
|
|
1686
|
-
namespace: "prisma"
|
|
1687
|
-
}
|
|
1688
|
-
]
|
|
1689
|
-
};
|
|
1690
|
-
fields.push(selectField);
|
|
1691
|
-
}
|
|
1692
|
-
const hasRelationToAnotherModel = (0, model_helpers_1.checkModelHasModelRelation)(model);
|
|
1693
|
-
if (isGenerateInclude && hasRelationToAnotherModel) {
|
|
1694
|
-
const includeField = {
|
|
1695
|
-
name: "include",
|
|
1696
|
-
isRequired: false,
|
|
1697
|
-
isNullable: false,
|
|
1698
|
-
inputTypes: [
|
|
1699
|
-
{
|
|
1700
|
-
isList: false,
|
|
1701
|
-
type: `${modelName}Include`,
|
|
1702
|
-
location: "inputObjectTypes",
|
|
1703
|
-
namespace: "prisma"
|
|
1704
|
-
}
|
|
1705
|
-
]
|
|
1706
|
-
};
|
|
1707
|
-
fields.push(includeField);
|
|
1708
|
-
}
|
|
1709
|
-
const modelArgsInputObjectType = {
|
|
1710
|
-
name: `${modelName}Args`,
|
|
1711
|
-
constraints: {
|
|
1712
|
-
maxNumFields: null,
|
|
1713
|
-
minNumFields: null
|
|
1714
|
-
},
|
|
1715
|
-
fields
|
|
1716
|
-
};
|
|
1717
|
-
modelArgsInputObjectTypes.push(modelArgsInputObjectType);
|
|
1718
|
-
}
|
|
1719
|
-
return modelArgsInputObjectTypes;
|
|
1720
|
-
}
|
|
1721
|
-
__name(generateModelArgsInputObjectTypes, "generateModelArgsInputObjectTypes");
|
|
1722
|
-
}
|
|
1723
|
-
});
|
|
1724
|
-
|
|
1725
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/mongodb-helpers.js
|
|
1726
|
-
var require_mongodb_helpers = __commonJS({
|
|
1727
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/mongodb-helpers.js"(exports2) {
|
|
1728
|
-
"use strict";
|
|
1729
|
-
init_cjs_shims();
|
|
1730
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
1731
|
-
return mod && mod.__esModule ? mod : {
|
|
1732
|
-
"default": mod
|
|
1733
|
-
};
|
|
1734
|
-
};
|
|
1735
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
1736
|
-
value: true
|
|
1737
|
-
});
|
|
1738
|
-
exports2.isMongodbRawOp = exports2.addMissingInputObjectTypesForMongoDbRawOpsAndQueries = void 0;
|
|
1739
|
-
var transformer_1 = __importDefault(require_transformer());
|
|
1740
|
-
function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
|
|
1741
|
-
const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
|
|
1742
|
-
transformer_1.default.rawOpsMap = rawOpsMap !== null && rawOpsMap !== void 0 ? rawOpsMap : {};
|
|
1743
|
-
const mongoDbRawQueryInputObjectTypes = resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes);
|
|
1744
|
-
for (const mongoDbRawQueryInputType of mongoDbRawQueryInputObjectTypes) {
|
|
1745
|
-
inputObjectTypes.push(mongoDbRawQueryInputType);
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
__name(addMissingInputObjectTypesForMongoDbRawOpsAndQueries, "addMissingInputObjectTypesForMongoDbRawOpsAndQueries");
|
|
1749
|
-
exports2.addMissingInputObjectTypesForMongoDbRawOpsAndQueries = addMissingInputObjectTypesForMongoDbRawOpsAndQueries;
|
|
1750
|
-
function resolveMongoDbRawOperations(modelOperations) {
|
|
1751
|
-
const rawOpsMap = {};
|
|
1752
|
-
const rawOpsNames = [
|
|
1753
|
-
...new Set(modelOperations.reduce((result, current) => {
|
|
1754
|
-
const keys = Object.keys(current);
|
|
1755
|
-
keys === null || keys === void 0 ? void 0 : keys.forEach((key) => {
|
|
1756
|
-
if (key.includes("Raw")) {
|
|
1757
|
-
result.push(key);
|
|
1758
|
-
}
|
|
1759
|
-
});
|
|
1760
|
-
return result;
|
|
1761
|
-
}, []))
|
|
1762
|
-
];
|
|
1763
|
-
const modelNames = modelOperations.map((item) => item.model);
|
|
1764
|
-
rawOpsNames.forEach((opName) => {
|
|
1765
|
-
modelNames.forEach((modelName) => {
|
|
1766
|
-
const isFind = opName === "findRaw";
|
|
1767
|
-
const opWithModel = `${opName.replace("Raw", "")}${modelName}Raw`;
|
|
1768
|
-
rawOpsMap[opWithModel] = isFind ? `${modelName}FindRawArgs` : `${modelName}AggregateRawArgs`;
|
|
1769
|
-
});
|
|
1770
|
-
});
|
|
1771
|
-
return rawOpsMap;
|
|
1772
|
-
}
|
|
1773
|
-
__name(resolveMongoDbRawOperations, "resolveMongoDbRawOperations");
|
|
1774
|
-
function resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes) {
|
|
1775
|
-
const mongoDbRawQueries = getMongoDbRawQueries(outputObjectTypes);
|
|
1776
|
-
const mongoDbRawQueryInputObjectTypes = mongoDbRawQueries.map((item) => ({
|
|
1777
|
-
name: item.name,
|
|
1778
|
-
constraints: {
|
|
1779
|
-
maxNumFields: null,
|
|
1780
|
-
minNumFields: null
|
|
1781
|
-
},
|
|
1782
|
-
fields: item.args.map((arg) => ({
|
|
1783
|
-
name: arg.name,
|
|
1784
|
-
isRequired: arg.isRequired,
|
|
1785
|
-
isNullable: arg.isNullable,
|
|
1786
|
-
inputTypes: arg.inputTypes
|
|
1787
|
-
}))
|
|
1788
|
-
}));
|
|
1789
|
-
return mongoDbRawQueryInputObjectTypes;
|
|
1790
|
-
}
|
|
1791
|
-
__name(resolveMongoDbRawQueryInputObjectTypes, "resolveMongoDbRawQueryInputObjectTypes");
|
|
1792
|
-
function getMongoDbRawQueries(outputObjectTypes) {
|
|
1793
|
-
var _a;
|
|
1794
|
-
const queryOutputTypes = outputObjectTypes.filter((item) => item.name === "Query");
|
|
1795
|
-
const mongodbRawQueries = (_a = queryOutputTypes === null || queryOutputTypes === void 0 ? void 0 : queryOutputTypes[0].fields.filter((field) => field.name.includes("Raw"))) !== null && _a !== void 0 ? _a : [];
|
|
1796
|
-
return mongodbRawQueries;
|
|
1797
|
-
}
|
|
1798
|
-
__name(getMongoDbRawQueries, "getMongoDbRawQueries");
|
|
1799
|
-
var isMongodbRawOp = /* @__PURE__ */ __name((name) => /find([^]*?)Raw/.test(name) || /aggregate([^]*?)Raw/.test(name), "isMongodbRawOp");
|
|
1800
|
-
exports2.isMongodbRawOp = isMongodbRawOp;
|
|
1801
|
-
}
|
|
1802
|
-
});
|
|
1803
|
-
|
|
1804
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/select-helpers.js
|
|
1805
|
-
var require_select_helpers = __commonJS({
|
|
1806
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/select-helpers.js"(exports2) {
|
|
1807
|
-
"use strict";
|
|
1808
|
-
init_cjs_shims();
|
|
1809
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
1810
|
-
value: true
|
|
1811
|
-
});
|
|
1812
|
-
exports2.addMissingInputObjectTypesForSelect = void 0;
|
|
1813
|
-
var model_helpers_1 = require_model_helpers();
|
|
1814
|
-
function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
|
|
1815
|
-
const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
|
|
1816
|
-
const modelCountOutputTypeSelectInputObjectTypes = generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes);
|
|
1817
|
-
const modelCountOutputTypeArgsInputObjectTypes = generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes);
|
|
1818
|
-
const modelSelectInputObjectTypes = generateModelSelectInputObjectTypes(models);
|
|
1819
|
-
const generatedInputObjectTypes = [
|
|
1820
|
-
modelCountOutputTypeSelectInputObjectTypes,
|
|
1821
|
-
modelCountOutputTypeArgsInputObjectTypes,
|
|
1822
|
-
modelSelectInputObjectTypes
|
|
1823
|
-
].flat();
|
|
1824
|
-
for (const inputObjectType of generatedInputObjectTypes) {
|
|
1825
|
-
inputObjectTypes.push(inputObjectType);
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
__name(addMissingInputObjectTypesForSelect, "addMissingInputObjectTypesForSelect");
|
|
1829
|
-
exports2.addMissingInputObjectTypesForSelect = addMissingInputObjectTypesForSelect;
|
|
1830
|
-
function getModelCountOutputTypes(outputObjectTypes) {
|
|
1831
|
-
return outputObjectTypes.filter(({ name }) => name.includes("CountOutputType"));
|
|
1832
|
-
}
|
|
1833
|
-
__name(getModelCountOutputTypes, "getModelCountOutputTypes");
|
|
1834
|
-
function generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes) {
|
|
1835
|
-
const modelCountOutputTypeSelectInputObjectTypes = [];
|
|
1836
|
-
for (const modelCountOutputType of modelCountOutputTypes) {
|
|
1837
|
-
const { name: modelCountOutputTypeName, fields: modelCountOutputTypeFields } = modelCountOutputType;
|
|
1838
|
-
const modelCountOutputTypeSelectInputObjectType = {
|
|
1839
|
-
name: `${modelCountOutputTypeName}Select`,
|
|
1840
|
-
constraints: {
|
|
1841
|
-
maxNumFields: null,
|
|
1842
|
-
minNumFields: null
|
|
1843
|
-
},
|
|
1844
|
-
fields: modelCountOutputTypeFields.map(({ name }) => ({
|
|
1845
|
-
name,
|
|
1846
|
-
isRequired: false,
|
|
1847
|
-
isNullable: false,
|
|
1848
|
-
inputTypes: [
|
|
1849
|
-
{
|
|
1850
|
-
isList: false,
|
|
1851
|
-
type: `Boolean`,
|
|
1852
|
-
location: "scalar"
|
|
1853
|
-
}
|
|
1854
|
-
]
|
|
1855
|
-
}))
|
|
1856
|
-
};
|
|
1857
|
-
modelCountOutputTypeSelectInputObjectTypes.push(modelCountOutputTypeSelectInputObjectType);
|
|
1858
|
-
}
|
|
1859
|
-
return modelCountOutputTypeSelectInputObjectTypes;
|
|
1860
|
-
}
|
|
1861
|
-
__name(generateModelCountOutputTypeSelectInputObjectTypes, "generateModelCountOutputTypeSelectInputObjectTypes");
|
|
1862
|
-
function generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes) {
|
|
1863
|
-
const modelCountOutputTypeArgsInputObjectTypes = [];
|
|
1864
|
-
for (const modelCountOutputType of modelCountOutputTypes) {
|
|
1865
|
-
const { name: modelCountOutputTypeName } = modelCountOutputType;
|
|
1866
|
-
const modelCountOutputTypeArgsInputObjectType = {
|
|
1867
|
-
name: `${modelCountOutputTypeName}Args`,
|
|
1868
|
-
constraints: {
|
|
1869
|
-
maxNumFields: null,
|
|
1870
|
-
minNumFields: null
|
|
1871
|
-
},
|
|
1872
|
-
fields: [
|
|
1873
|
-
{
|
|
1874
|
-
name: "select",
|
|
1875
|
-
isRequired: false,
|
|
1876
|
-
isNullable: false,
|
|
1877
|
-
inputTypes: [
|
|
1878
|
-
{
|
|
1879
|
-
isList: false,
|
|
1880
|
-
type: `${modelCountOutputTypeName}Select`,
|
|
1881
|
-
location: "inputObjectTypes",
|
|
1882
|
-
namespace: "prisma"
|
|
1883
|
-
}
|
|
1884
|
-
]
|
|
1885
|
-
}
|
|
1886
|
-
]
|
|
1887
|
-
};
|
|
1888
|
-
modelCountOutputTypeArgsInputObjectTypes.push(modelCountOutputTypeArgsInputObjectType);
|
|
1889
|
-
}
|
|
1890
|
-
return modelCountOutputTypeArgsInputObjectTypes;
|
|
1891
|
-
}
|
|
1892
|
-
__name(generateModelCountOutputTypeArgsInputObjectTypes, "generateModelCountOutputTypeArgsInputObjectTypes");
|
|
1893
|
-
function generateModelSelectInputObjectTypes(models) {
|
|
1894
|
-
const modelSelectInputObjectTypes = [];
|
|
1895
|
-
for (const model of models) {
|
|
1896
|
-
const { name: modelName, fields: modelFields } = model;
|
|
1897
|
-
const fields = [];
|
|
1898
|
-
for (const modelField of modelFields) {
|
|
1899
|
-
const { name: modelFieldName, isList, type } = modelField;
|
|
1900
|
-
const isRelationField = (0, model_helpers_1.checkIsModelRelationField)(modelField);
|
|
1901
|
-
const field = {
|
|
1902
|
-
name: modelFieldName,
|
|
1903
|
-
isRequired: false,
|
|
1904
|
-
isNullable: false,
|
|
1905
|
-
inputTypes: [
|
|
1906
|
-
{
|
|
1907
|
-
isList: false,
|
|
1908
|
-
type: "Boolean",
|
|
1909
|
-
location: "scalar"
|
|
1910
|
-
}
|
|
1911
|
-
]
|
|
1912
|
-
};
|
|
1913
|
-
if (isRelationField) {
|
|
1914
|
-
let schemaArgInputType = {
|
|
1915
|
-
isList: false,
|
|
1916
|
-
type: isList ? `${type}FindManyArgs` : `${type}Args`,
|
|
1917
|
-
location: "inputObjectTypes",
|
|
1918
|
-
namespace: "prisma"
|
|
1919
|
-
};
|
|
1920
|
-
field.inputTypes.push(schemaArgInputType);
|
|
1921
|
-
}
|
|
1922
|
-
fields.push(field);
|
|
1923
|
-
}
|
|
1924
|
-
const hasManyRelationToAnotherModel = (0, model_helpers_1.checkModelHasManyModelRelation)(model);
|
|
1925
|
-
const shouldAddCountField = hasManyRelationToAnotherModel;
|
|
1926
|
-
if (shouldAddCountField) {
|
|
1927
|
-
const _countField = {
|
|
1928
|
-
name: "_count",
|
|
1929
|
-
isRequired: false,
|
|
1930
|
-
isNullable: false,
|
|
1931
|
-
inputTypes: [
|
|
1932
|
-
{
|
|
1933
|
-
isList: false,
|
|
1934
|
-
type: "Boolean",
|
|
1935
|
-
location: "scalar"
|
|
1936
|
-
},
|
|
1937
|
-
{
|
|
1938
|
-
isList: false,
|
|
1939
|
-
type: `${modelName}CountOutputTypeArgs`,
|
|
1940
|
-
location: "inputObjectTypes",
|
|
1941
|
-
namespace: "prisma"
|
|
1942
|
-
}
|
|
1943
|
-
]
|
|
1944
|
-
};
|
|
1945
|
-
fields.push(_countField);
|
|
1946
|
-
}
|
|
1947
|
-
const modelSelectInputObjectType = {
|
|
1948
|
-
name: `${modelName}Select`,
|
|
1949
|
-
constraints: {
|
|
1950
|
-
maxNumFields: null,
|
|
1951
|
-
minNumFields: null
|
|
1952
|
-
},
|
|
1953
|
-
fields
|
|
1954
|
-
};
|
|
1955
|
-
modelSelectInputObjectTypes.push(modelSelectInputObjectType);
|
|
1956
|
-
}
|
|
1957
|
-
return modelSelectInputObjectTypes;
|
|
1958
|
-
}
|
|
1959
|
-
__name(generateModelSelectInputObjectTypes, "generateModelSelectInputObjectTypes");
|
|
1960
|
-
}
|
|
1961
|
-
});
|
|
1962
|
-
|
|
1963
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/whereUniqueInput-helpers.js
|
|
1964
|
-
var require_whereUniqueInput_helpers = __commonJS({
|
|
1965
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/whereUniqueInput-helpers.js"(exports2) {
|
|
1966
|
-
"use strict";
|
|
1967
|
-
init_cjs_shims();
|
|
1968
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
1969
|
-
value: true
|
|
1970
|
-
});
|
|
1971
|
-
exports2.changeOptionalToRequiredFields = void 0;
|
|
1972
|
-
function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
1973
|
-
inputObjectTypes.map((item) => {
|
|
1974
|
-
var _a;
|
|
1975
|
-
if (item.name.includes("WhereUniqueInput") && ((_a = item.constraints.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
1976
|
-
item.fields = item.fields.map((subItem) => {
|
|
1977
|
-
var _a2;
|
|
1978
|
-
if ((_a2 = item.constraints.fields) === null || _a2 === void 0 ? void 0 : _a2.includes(subItem.name)) {
|
|
1979
|
-
subItem.isRequired = true;
|
|
1980
|
-
return subItem;
|
|
1981
|
-
}
|
|
1982
|
-
return subItem;
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
return item;
|
|
1986
|
-
});
|
|
1987
|
-
}
|
|
1988
|
-
__name(changeOptionalToRequiredFields, "changeOptionalToRequiredFields");
|
|
1989
|
-
exports2.changeOptionalToRequiredFields = changeOptionalToRequiredFields;
|
|
1990
|
-
}
|
|
1991
|
-
});
|
|
1992
|
-
|
|
1993
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/helpers.js
|
|
1994
|
-
var require_helpers = __commonJS({
|
|
1995
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/helpers.js"(exports2) {
|
|
1996
|
-
"use strict";
|
|
1997
|
-
init_cjs_shims();
|
|
1998
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
1999
|
-
return mod && mod.__esModule ? mod : {
|
|
2000
|
-
"default": mod
|
|
2001
|
-
};
|
|
2002
|
-
};
|
|
2003
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
2004
|
-
value: true
|
|
2005
|
-
});
|
|
2006
|
-
exports2.resolveAddMissingInputObjectTypeOptions = exports2.addMissingInputObjectTypes = void 0;
|
|
2007
|
-
var transformer_1 = __importDefault(require_transformer());
|
|
2008
|
-
var aggregate_helpers_1 = require_aggregate_helpers();
|
|
2009
|
-
var include_helpers_1 = require_include_helpers();
|
|
2010
|
-
var modelArgs_helpers_1 = require_modelArgs_helpers();
|
|
2011
|
-
var mongodb_helpers_1 = require_mongodb_helpers();
|
|
2012
|
-
var select_helpers_1 = require_select_helpers();
|
|
2013
|
-
var whereUniqueInput_helpers_1 = require_whereUniqueInput_helpers();
|
|
2014
|
-
function addMissingInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
|
|
2015
|
-
if (dataSourceProvider === "mongodb") {
|
|
2016
|
-
(0, mongodb_helpers_1.addMissingInputObjectTypesForMongoDbRawOpsAndQueries)(modelOperations, outputObjectTypes, inputObjectTypes);
|
|
2017
|
-
}
|
|
2018
|
-
(0, aggregate_helpers_1.addMissingInputObjectTypesForAggregate)(inputObjectTypes, outputObjectTypes);
|
|
2019
|
-
if (options.isGenerateSelect) {
|
|
2020
|
-
(0, select_helpers_1.addMissingInputObjectTypesForSelect)(inputObjectTypes, outputObjectTypes, models);
|
|
2021
|
-
transformer_1.default.setIsGenerateSelect(true);
|
|
2022
|
-
}
|
|
2023
|
-
if (options.isGenerateSelect || options.isGenerateInclude) {
|
|
2024
|
-
(0, modelArgs_helpers_1.addMissingInputObjectTypesForModelArgs)(inputObjectTypes, models, options.isGenerateSelect, options.isGenerateInclude);
|
|
2025
|
-
}
|
|
2026
|
-
if (options.isGenerateInclude) {
|
|
2027
|
-
(0, include_helpers_1.addMissingInputObjectTypesForInclude)(inputObjectTypes, models, options.isGenerateSelect);
|
|
2028
|
-
transformer_1.default.setIsGenerateInclude(true);
|
|
2029
|
-
}
|
|
2030
|
-
(0, whereUniqueInput_helpers_1.changeOptionalToRequiredFields)(inputObjectTypes);
|
|
2031
|
-
}
|
|
2032
|
-
__name(addMissingInputObjectTypes, "addMissingInputObjectTypes");
|
|
2033
|
-
exports2.addMissingInputObjectTypes = addMissingInputObjectTypes;
|
|
2034
|
-
function resolveAddMissingInputObjectTypeOptions(generatorConfigOptions) {
|
|
2035
|
-
return {
|
|
2036
|
-
isGenerateSelect: generatorConfigOptions.isGenerateSelect === "true",
|
|
2037
|
-
isGenerateInclude: generatorConfigOptions.isGenerateInclude === "true"
|
|
2038
|
-
};
|
|
2039
|
-
}
|
|
2040
|
-
__name(resolveAddMissingInputObjectTypeOptions, "resolveAddMissingInputObjectTypeOptions");
|
|
2041
|
-
exports2.resolveAddMissingInputObjectTypeOptions = resolveAddMissingInputObjectTypeOptions;
|
|
2042
|
-
}
|
|
2043
|
-
});
|
|
2044
|
-
|
|
2045
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/index.js
|
|
2046
|
-
var require_helpers2 = __commonJS({
|
|
2047
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/helpers/index.js"(exports2) {
|
|
2048
|
-
"use strict";
|
|
2049
|
-
init_cjs_shims();
|
|
2050
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2051
|
-
if (k2 === void 0) k2 = k;
|
|
2052
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2053
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2054
|
-
desc = {
|
|
2055
|
-
enumerable: true,
|
|
2056
|
-
get: /* @__PURE__ */ __name(function() {
|
|
2057
|
-
return m[k];
|
|
2058
|
-
}, "get")
|
|
2059
|
-
};
|
|
2060
|
-
}
|
|
2061
|
-
Object.defineProperty(o, k2, desc);
|
|
2062
|
-
} : function(o, m, k, k2) {
|
|
2063
|
-
if (k2 === void 0) k2 = k;
|
|
2064
|
-
o[k2] = m[k];
|
|
2065
|
-
});
|
|
2066
|
-
var __exportStar = exports2 && exports2.__exportStar || function(m, exports1) {
|
|
2067
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports1, p)) __createBinding(exports1, m, p);
|
|
2068
|
-
};
|
|
2069
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
2070
|
-
value: true
|
|
2071
|
-
});
|
|
2072
|
-
__exportStar(require_comments_helpers(), exports2);
|
|
2073
|
-
__exportStar(require_helpers(), exports2);
|
|
2074
|
-
__exportStar(require_model_helpers(), exports2);
|
|
2075
|
-
__exportStar(require_mongodb_helpers(), exports2);
|
|
2076
|
-
__exportStar(require_whereUniqueInput_helpers(), exports2);
|
|
2077
|
-
}
|
|
2078
|
-
});
|
|
2079
|
-
|
|
2080
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/removeDir.js
|
|
2081
|
-
var require_removeDir = __commonJS({
|
|
2082
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/utils/removeDir.js"(exports2) {
|
|
2083
|
-
"use strict";
|
|
2084
|
-
init_cjs_shims();
|
|
2085
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
2086
|
-
return mod && mod.__esModule ? mod : {
|
|
2087
|
-
"default": mod
|
|
2088
|
-
};
|
|
2089
|
-
};
|
|
2090
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
2091
|
-
value: true
|
|
2092
|
-
});
|
|
2093
|
-
var path_1 = __importDefault(require("path"));
|
|
2094
|
-
var fs_1 = require("fs");
|
|
2095
|
-
async function removeDir2(dirPath, onlyContent) {
|
|
2096
|
-
const dirEntries = await fs_1.promises.readdir(dirPath, {
|
|
2097
|
-
withFileTypes: true
|
|
2098
|
-
});
|
|
2099
|
-
await Promise.all(dirEntries.map(async (dirEntry) => {
|
|
2100
|
-
const fullPath = path_1.default.join(dirPath, dirEntry.name);
|
|
2101
|
-
return dirEntry.isDirectory() ? await removeDir2(fullPath, false) : await fs_1.promises.unlink(fullPath);
|
|
2102
|
-
}));
|
|
2103
|
-
if (!onlyContent) {
|
|
2104
|
-
await fs_1.promises.rmdir(dirPath);
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
__name(removeDir2, "removeDir");
|
|
2108
|
-
exports2.default = removeDir2;
|
|
2109
|
-
}
|
|
2110
|
-
});
|
|
2111
|
-
|
|
2112
|
-
// ../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/prisma-generator.js
|
|
2113
|
-
var require_prisma_generator = __commonJS({
|
|
2114
|
-
"../../node_modules/.pnpm/prisma-zod-generator@0.8.13/node_modules/prisma-zod-generator/lib/prisma-generator.js"(exports2) {
|
|
2115
|
-
"use strict";
|
|
2116
|
-
init_cjs_shims();
|
|
2117
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
2118
|
-
return mod && mod.__esModule ? mod : {
|
|
2119
|
-
"default": mod
|
|
2120
|
-
};
|
|
2121
|
-
};
|
|
2122
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
2123
|
-
value: true
|
|
2124
|
-
});
|
|
2125
|
-
exports2.generate = void 0;
|
|
2126
|
-
var internals_1 = require("@prisma/internals");
|
|
2127
|
-
var fs_1 = require("fs");
|
|
2128
|
-
var helpers_1 = require_helpers2();
|
|
2129
|
-
var aggregate_helpers_1 = require_aggregate_helpers();
|
|
2130
|
-
var transformer_1 = __importDefault(require_transformer());
|
|
2131
|
-
var removeDir_1 = __importDefault(require_removeDir());
|
|
2132
|
-
async function generate2(options) {
|
|
2133
|
-
var _a, _b;
|
|
2134
|
-
try {
|
|
2135
|
-
await handleGeneratorOutputValue(options.generator.output);
|
|
2136
|
-
const prismaClientGeneratorConfig = getGeneratorConfigByProvider(options.otherGenerators, "prisma-client-js");
|
|
2137
|
-
const prismaClientDmmf = await (0, internals_1.getDMMF)({
|
|
2138
|
-
datamodel: options.datamodel,
|
|
2139
|
-
previewFeatures: prismaClientGeneratorConfig === null || prismaClientGeneratorConfig === void 0 ? void 0 : prismaClientGeneratorConfig.previewFeatures
|
|
2140
|
-
});
|
|
2141
|
-
checkForCustomPrismaClientOutputPath(prismaClientGeneratorConfig);
|
|
2142
|
-
const modelOperations = prismaClientDmmf.mappings.modelOperations;
|
|
2143
|
-
const inputObjectTypes = prismaClientDmmf.schema.inputObjectTypes.prisma;
|
|
2144
|
-
const outputObjectTypes = prismaClientDmmf.schema.outputObjectTypes.prisma;
|
|
2145
|
-
const enumTypes = prismaClientDmmf.schema.enumTypes;
|
|
2146
|
-
const models = prismaClientDmmf.datamodel.models;
|
|
2147
|
-
const hiddenModels = [];
|
|
2148
|
-
const hiddenFields = [];
|
|
2149
|
-
(0, helpers_1.resolveModelsComments)(models, modelOperations, enumTypes, hiddenModels, hiddenFields);
|
|
2150
|
-
await generateEnumSchemas(prismaClientDmmf.schema.enumTypes.prisma, (_a = prismaClientDmmf.schema.enumTypes.model) !== null && _a !== void 0 ? _a : []);
|
|
2151
|
-
const dataSource = (_b = options.datasources) === null || _b === void 0 ? void 0 : _b[0];
|
|
2152
|
-
const previewFeatures = prismaClientGeneratorConfig === null || prismaClientGeneratorConfig === void 0 ? void 0 : prismaClientGeneratorConfig.previewFeatures;
|
|
2153
|
-
transformer_1.default.provider = dataSource.provider;
|
|
2154
|
-
transformer_1.default.previewFeatures = previewFeatures;
|
|
2155
|
-
const generatorConfigOptions = options.generator.config;
|
|
2156
|
-
const addMissingInputObjectTypeOptions = (0, helpers_1.resolveAddMissingInputObjectTypeOptions)(generatorConfigOptions);
|
|
2157
|
-
(0, helpers_1.addMissingInputObjectTypes)(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSource.provider, addMissingInputObjectTypeOptions);
|
|
2158
|
-
const aggregateOperationSupport = (0, aggregate_helpers_1.resolveAggregateOperationSupport)(inputObjectTypes);
|
|
2159
|
-
(0, helpers_1.hideInputObjectTypesAndRelatedFields)(inputObjectTypes, hiddenModels, hiddenFields);
|
|
2160
|
-
await generateObjectSchemas(inputObjectTypes);
|
|
2161
|
-
await generateModelSchemas(models, modelOperations, aggregateOperationSupport);
|
|
2162
|
-
await generateIndex();
|
|
2163
|
-
} catch (error) {
|
|
2164
|
-
console.error(error);
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
__name(generate2, "generate");
|
|
2168
|
-
exports2.generate = generate2;
|
|
2169
|
-
async function handleGeneratorOutputValue(generatorOutputValue) {
|
|
2170
|
-
const outputDirectoryPath = (0, internals_1.parseEnvValue)(generatorOutputValue);
|
|
2171
|
-
await fs_1.promises.mkdir(outputDirectoryPath, {
|
|
2172
|
-
recursive: true
|
|
2173
|
-
});
|
|
2174
|
-
const isRemoveContentsOnly = true;
|
|
2175
|
-
await (0, removeDir_1.default)(outputDirectoryPath, isRemoveContentsOnly);
|
|
2176
|
-
transformer_1.default.setOutputPath(outputDirectoryPath);
|
|
2177
|
-
}
|
|
2178
|
-
__name(handleGeneratorOutputValue, "handleGeneratorOutputValue");
|
|
2179
|
-
function getGeneratorConfigByProvider(generators, provider2) {
|
|
2180
|
-
return generators.find((it) => (0, internals_1.parseEnvValue)(it.provider) === provider2);
|
|
2181
|
-
}
|
|
2182
|
-
__name(getGeneratorConfigByProvider, "getGeneratorConfigByProvider");
|
|
2183
|
-
function checkForCustomPrismaClientOutputPath(prismaClientGeneratorConfig) {
|
|
2184
|
-
var _a;
|
|
2185
|
-
if (prismaClientGeneratorConfig === null || prismaClientGeneratorConfig === void 0 ? void 0 : prismaClientGeneratorConfig.isCustomOutput) {
|
|
2186
|
-
transformer_1.default.setPrismaClientOutputPath((_a = prismaClientGeneratorConfig.output) === null || _a === void 0 ? void 0 : _a.value);
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
__name(checkForCustomPrismaClientOutputPath, "checkForCustomPrismaClientOutputPath");
|
|
2190
|
-
async function generateEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
|
|
2191
|
-
const enumTypes = [
|
|
2192
|
-
...prismaSchemaEnum,
|
|
2193
|
-
...modelSchemaEnum
|
|
2194
|
-
];
|
|
2195
|
-
const enumNames = enumTypes.map((enumItem) => enumItem.name);
|
|
2196
|
-
transformer_1.default.enumNames = enumNames !== null && enumNames !== void 0 ? enumNames : [];
|
|
2197
|
-
const transformer = new transformer_1.default({
|
|
2198
|
-
enumTypes
|
|
2199
|
-
});
|
|
2200
|
-
await transformer.generateEnumSchemas();
|
|
2201
|
-
}
|
|
2202
|
-
__name(generateEnumSchemas, "generateEnumSchemas");
|
|
2203
|
-
async function generateObjectSchemas(inputObjectTypes) {
|
|
2204
|
-
var _a, _b;
|
|
2205
|
-
for (let i = 0; i < inputObjectTypes.length; i += 1) {
|
|
2206
|
-
const fields = (_a = inputObjectTypes[i]) === null || _a === void 0 ? void 0 : _a.fields;
|
|
2207
|
-
const name = (_b = inputObjectTypes[i]) === null || _b === void 0 ? void 0 : _b.name;
|
|
2208
|
-
const transformer = new transformer_1.default({
|
|
2209
|
-
name,
|
|
2210
|
-
fields
|
|
2211
|
-
});
|
|
2212
|
-
await transformer.generateObjectSchema();
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
__name(generateObjectSchemas, "generateObjectSchemas");
|
|
2216
|
-
async function generateModelSchemas(models, modelOperations, aggregateOperationSupport) {
|
|
2217
|
-
const transformer = new transformer_1.default({
|
|
2218
|
-
models,
|
|
2219
|
-
modelOperations,
|
|
2220
|
-
aggregateOperationSupport
|
|
2221
|
-
});
|
|
2222
|
-
await transformer.generateModelSchemas();
|
|
2223
|
-
}
|
|
2224
|
-
__name(generateModelSchemas, "generateModelSchemas");
|
|
2225
|
-
async function generateIndex() {
|
|
2226
|
-
await transformer_1.default.generateIndex();
|
|
2227
|
-
}
|
|
2228
|
-
__name(generateIndex, "generateIndex");
|
|
2229
|
-
}
|
|
2230
|
-
});
|
|
2231
|
-
|
|
2232
670
|
// ../../node_modules/.pnpm/@dotenvx+dotenvx@1.35.0/node_modules/@dotenvx/dotenvx/package.json
|
|
2233
671
|
var require_package = __commonJS({
|
|
2234
672
|
"../../node_modules/.pnpm/@dotenvx+dotenvx@1.35.0/node_modules/@dotenvx/dotenvx/package.json"(exports2, module2) {
|
|
@@ -3874,9 +2312,9 @@ var require_parse = __commonJS({
|
|
|
3874
2312
|
"../../node_modules/.pnpm/picomatch@4.0.2/node_modules/picomatch/lib/parse.js"(exports2, module2) {
|
|
3875
2313
|
"use strict";
|
|
3876
2314
|
init_cjs_shims();
|
|
3877
|
-
var
|
|
2315
|
+
var constants = require_constants();
|
|
3878
2316
|
var utils = require_utils2();
|
|
3879
|
-
var { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } =
|
|
2317
|
+
var { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
3880
2318
|
var expandRange = /* @__PURE__ */ __name((args, options) => {
|
|
3881
2319
|
if (typeof options.expandRange === "function") {
|
|
3882
2320
|
return options.expandRange(...args, options);
|
|
@@ -3915,8 +2353,8 @@ var require_parse = __commonJS({
|
|
|
3915
2353
|
bos
|
|
3916
2354
|
];
|
|
3917
2355
|
const capture = opts.capture ? "" : "?:";
|
|
3918
|
-
const PLATFORM_CHARS =
|
|
3919
|
-
const EXTGLOB_CHARS =
|
|
2356
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
2357
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
3920
2358
|
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
|
|
3921
2359
|
const globstar = /* @__PURE__ */ __name((opts2) => {
|
|
3922
2360
|
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
@@ -4706,7 +3144,7 @@ var require_parse = __commonJS({
|
|
|
4706
3144
|
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
4707
3145
|
}
|
|
4708
3146
|
input = REPLACEMENTS[input] || input;
|
|
4709
|
-
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } =
|
|
3147
|
+
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
4710
3148
|
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
4711
3149
|
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
4712
3150
|
const capture = opts.capture ? "" : "?:";
|
|
@@ -4768,7 +3206,7 @@ var require_picomatch = __commonJS({
|
|
|
4768
3206
|
var scan = require_scan();
|
|
4769
3207
|
var parse5 = require_parse();
|
|
4770
3208
|
var utils = require_utils2();
|
|
4771
|
-
var
|
|
3209
|
+
var constants = require_constants();
|
|
4772
3210
|
var isObject2 = /* @__PURE__ */ __name((val) => val && typeof val === "object" && !Array.isArray(val), "isObject");
|
|
4773
3211
|
var picomatch = /* @__PURE__ */ __name((glob, options, returnState = false) => {
|
|
4774
3212
|
if (Array.isArray(glob)) {
|
|
@@ -4926,7 +3364,7 @@ var require_picomatch = __commonJS({
|
|
|
4926
3364
|
return /$^/;
|
|
4927
3365
|
}
|
|
4928
3366
|
};
|
|
4929
|
-
picomatch.constants =
|
|
3367
|
+
picomatch.constants = constants;
|
|
4930
3368
|
module2.exports = picomatch;
|
|
4931
3369
|
}
|
|
4932
3370
|
});
|
|
@@ -6079,7 +4517,7 @@ var require_cryptoNode = __commonJS({
|
|
|
6079
4517
|
value: true
|
|
6080
4518
|
});
|
|
6081
4519
|
exports2.crypto = void 0;
|
|
6082
|
-
var nc = require("crypto");
|
|
4520
|
+
var nc = require("node:crypto");
|
|
6083
4521
|
exports2.crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
6084
4522
|
}
|
|
6085
4523
|
});
|
|
@@ -6269,7 +4707,7 @@ var require_cryptoNode2 = __commonJS({
|
|
|
6269
4707
|
value: true
|
|
6270
4708
|
});
|
|
6271
4709
|
exports2.crypto = void 0;
|
|
6272
|
-
var nc = require("crypto");
|
|
4710
|
+
var nc = require("node:crypto");
|
|
6273
4711
|
exports2.crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
6274
4712
|
}
|
|
6275
4713
|
});
|
|
@@ -10861,7 +9299,7 @@ var require_compat = __commonJS({
|
|
|
10861
9299
|
});
|
|
10862
9300
|
exports2._compat = void 0;
|
|
10863
9301
|
var utils_1 = require_utils3();
|
|
10864
|
-
var node_crypto_1 = require("crypto");
|
|
9302
|
+
var node_crypto_1 = require("node:crypto");
|
|
10865
9303
|
var AEAD_TAG_LENGTH = 16;
|
|
10866
9304
|
var IS_DENO = globalThis.Deno !== void 0;
|
|
10867
9305
|
var _compat = /* @__PURE__ */ __name(function(algorithm, key, nonce, AAD) {
|
|
@@ -11037,14 +9475,14 @@ var require_node2 = __commonJS({
|
|
|
11037
9475
|
if (nonce.length !== 24) {
|
|
11038
9476
|
throw new Error("xchacha20's nonce must be 24 bytes");
|
|
11039
9477
|
}
|
|
11040
|
-
var
|
|
9478
|
+
var constants = new Uint32Array([
|
|
11041
9479
|
1634760805,
|
|
11042
9480
|
857760878,
|
|
11043
9481
|
2036477234,
|
|
11044
9482
|
1797285236
|
|
11045
9483
|
]);
|
|
11046
9484
|
var subKey = new Uint32Array(8);
|
|
11047
|
-
(0, hchacha_1._hchacha20)(
|
|
9485
|
+
(0, hchacha_1._hchacha20)(constants, (0, utils_1.u32)(key), (0, utils_1.u32)(nonce.subarray(0, 16)), subKey);
|
|
11048
9486
|
var subNonce = new Uint8Array(12);
|
|
11049
9487
|
subNonce.set([
|
|
11050
9488
|
0,
|
|
@@ -15708,10 +14146,9 @@ init_cjs_shims();
|
|
|
15708
14146
|
|
|
15709
14147
|
// src/prisma-generator.ts
|
|
15710
14148
|
init_cjs_shims();
|
|
15711
|
-
var
|
|
15712
|
-
var import_node_path7 = __toESM(require("path"), 1);
|
|
14149
|
+
var import_node_fs6 = require("node:fs");
|
|
14150
|
+
var import_node_path7 = __toESM(require("node:path"), 1);
|
|
15713
14151
|
var import_pluralize = __toESM(require_pluralize(), 1);
|
|
15714
|
-
var import_prisma_generator = __toESM(require_prisma_generator(), 1);
|
|
15715
14152
|
|
|
15716
14153
|
// src/config.ts
|
|
15717
14154
|
init_cjs_shims();
|
|
@@ -19973,7 +18410,10 @@ var configSchema = z.object({
|
|
|
19973
18410
|
// src/helpers.ts
|
|
19974
18411
|
init_cjs_shims();
|
|
19975
18412
|
|
|
19976
|
-
// src/utils/
|
|
18413
|
+
// src/utils/get-prisma-internals.ts
|
|
18414
|
+
init_cjs_shims();
|
|
18415
|
+
|
|
18416
|
+
// src/utils/get-jiti.ts
|
|
19977
18417
|
init_cjs_shims();
|
|
19978
18418
|
|
|
19979
18419
|
// ../env/src/index.ts
|
|
@@ -20430,8 +18870,8 @@ var isString = /* @__PURE__ */ __name((value) => {
|
|
|
20430
18870
|
}, "isString");
|
|
20431
18871
|
|
|
20432
18872
|
// ../env/src/get-env-paths.ts
|
|
20433
|
-
var import_node_os = __toESM(require("os"), 1);
|
|
20434
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
18873
|
+
var import_node_os = __toESM(require("node:os"), 1);
|
|
18874
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
20435
18875
|
var homedir = import_node_os.default.homedir();
|
|
20436
18876
|
var tmpdir = import_node_os.default.tmpdir();
|
|
20437
18877
|
var macos = /* @__PURE__ */ __name((orgId) => {
|
|
@@ -22775,10 +21215,6 @@ StormJSON.instance.registerCustom({
|
|
|
22775
21215
|
// ../type-checks/src/is-error.ts
|
|
22776
21216
|
init_cjs_shims();
|
|
22777
21217
|
|
|
22778
|
-
// ../fs/src/read-file.ts
|
|
22779
|
-
var import_node_fs = require("fs");
|
|
22780
|
-
var import_promises = require("fs/promises");
|
|
22781
|
-
|
|
22782
21218
|
// ../json/src/index.ts
|
|
22783
21219
|
init_cjs_shims();
|
|
22784
21220
|
|
|
@@ -22841,15 +21277,15 @@ init_cjs_shims();
|
|
|
22841
21277
|
|
|
22842
21278
|
// ../path/src/is-file.ts
|
|
22843
21279
|
init_cjs_shims();
|
|
22844
|
-
var
|
|
21280
|
+
var import_node_fs = require("node:fs");
|
|
22845
21281
|
function isFile(path7, additionalPath) {
|
|
22846
|
-
return Boolean((0,
|
|
21282
|
+
return Boolean((0, import_node_fs.statSync)(additionalPath ? joinPaths(additionalPath, path7) : path7, {
|
|
22847
21283
|
throwIfNoEntry: false
|
|
22848
21284
|
})?.isFile());
|
|
22849
21285
|
}
|
|
22850
21286
|
__name(isFile, "isFile");
|
|
22851
21287
|
function isDirectory(path7, additionalPath) {
|
|
22852
|
-
return Boolean((0,
|
|
21288
|
+
return Boolean((0, import_node_fs.statSync)(additionalPath ? joinPaths(additionalPath, path7) : path7, {
|
|
22853
21289
|
throwIfNoEntry: false
|
|
22854
21290
|
})?.isDirectory());
|
|
22855
21291
|
}
|
|
@@ -22935,8 +21371,6 @@ init_cjs_shims();
|
|
|
22935
21371
|
|
|
22936
21372
|
// ../path/src/exists.ts
|
|
22937
21373
|
init_cjs_shims();
|
|
22938
|
-
var import_node_fs3 = require("fs");
|
|
22939
|
-
var import_promises2 = require("fs/promises");
|
|
22940
21374
|
|
|
22941
21375
|
// ../path/src/file-path-fns.ts
|
|
22942
21376
|
init_cjs_shims();
|
|
@@ -22966,16 +21400,16 @@ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name
|
|
|
22966
21400
|
}), "__name");
|
|
22967
21401
|
|
|
22968
21402
|
// ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
|
|
22969
|
-
var
|
|
22970
|
-
var import_node_path2 = require("path");
|
|
21403
|
+
var import_node_fs2 = require("node:fs");
|
|
21404
|
+
var import_node_path2 = require("node:path");
|
|
22971
21405
|
var MAX_PATH_SEARCH_DEPTH = 30;
|
|
22972
21406
|
var depth = 0;
|
|
22973
21407
|
function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
|
|
22974
21408
|
const _startPath = startPath ?? process.cwd();
|
|
22975
|
-
if (endDirectoryNames.some((endDirName) => (0,
|
|
21409
|
+
if (endDirectoryNames.some((endDirName) => (0, import_node_fs2.existsSync)((0, import_node_path2.join)(_startPath, endDirName)))) {
|
|
22976
21410
|
return _startPath;
|
|
22977
21411
|
}
|
|
22978
|
-
if (endFileNames.some((endFileName) => (0,
|
|
21412
|
+
if (endFileNames.some((endFileName) => (0, import_node_fs2.existsSync)((0, import_node_path2.join)(_startPath, endFileName)))) {
|
|
22979
21413
|
return _startPath;
|
|
22980
21414
|
}
|
|
22981
21415
|
if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
@@ -23343,7 +21777,7 @@ __name(detectRuntime, "detectRuntime");
|
|
|
23343
21777
|
var runtimeInfo = detectRuntime();
|
|
23344
21778
|
var runtime = runtimeInfo?.name || "";
|
|
23345
21779
|
|
|
23346
|
-
// src/utils/
|
|
21780
|
+
// src/utils/get-jiti.ts
|
|
23347
21781
|
var import_jiti = require("jiti");
|
|
23348
21782
|
var jiti;
|
|
23349
21783
|
function getJiti() {
|
|
@@ -23357,6 +21791,8 @@ function getJiti() {
|
|
|
23357
21791
|
return jiti;
|
|
23358
21792
|
}
|
|
23359
21793
|
__name(getJiti, "getJiti");
|
|
21794
|
+
|
|
21795
|
+
// src/utils/get-prisma-internals.ts
|
|
23360
21796
|
async function getPrismaInternals() {
|
|
23361
21797
|
return getJiti().import(getJiti().esmResolve("@prisma/internals"));
|
|
23362
21798
|
}
|
|
@@ -23366,9 +21802,9 @@ async function getPrismaGeneratorHelper() {
|
|
|
23366
21802
|
}
|
|
23367
21803
|
__name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
|
|
23368
21804
|
|
|
23369
|
-
// src/utils/
|
|
21805
|
+
// src/utils/get-relative-path.ts
|
|
23370
21806
|
init_cjs_shims();
|
|
23371
|
-
var import_node_path3 = __toESM(require("path"), 1);
|
|
21807
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
23372
21808
|
function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath) {
|
|
23373
21809
|
const fromPath = import_node_path3.default.join(outputPath, "routers", "helpers");
|
|
23374
21810
|
let toPath = import_node_path3.default.join(outputPath, filePath);
|
|
@@ -23382,7 +21818,7 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath)
|
|
|
23382
21818
|
}
|
|
23383
21819
|
__name(getRelativePath, "getRelativePath");
|
|
23384
21820
|
|
|
23385
|
-
// src/utils/
|
|
21821
|
+
// src/utils/uncapitalize-first-letter.ts
|
|
23386
21822
|
init_cjs_shims();
|
|
23387
21823
|
var uncapitalizeFirstLetter = /* @__PURE__ */ __name((str) => {
|
|
23388
21824
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
@@ -23744,33 +22180,33 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
|
|
|
23744
22180
|
|
|
23745
22181
|
// src/prisma-shield-generator.ts
|
|
23746
22182
|
init_cjs_shims();
|
|
23747
|
-
var
|
|
23748
|
-
var import_node_path6 = __toESM(require("path"), 1);
|
|
22183
|
+
var import_node_fs5 = require("node:fs");
|
|
22184
|
+
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
23749
22185
|
|
|
23750
|
-
// src/utils/
|
|
22186
|
+
// src/utils/remove-dir.ts
|
|
23751
22187
|
init_cjs_shims();
|
|
23752
|
-
var
|
|
23753
|
-
var import_node_path4 = __toESM(require("path"), 1);
|
|
22188
|
+
var import_node_fs3 = require("node:fs");
|
|
22189
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
23754
22190
|
async function removeDir(dirPath, onlyContent) {
|
|
23755
|
-
const dirEntries = await
|
|
22191
|
+
const dirEntries = await import_node_fs3.promises.readdir(dirPath, {
|
|
23756
22192
|
withFileTypes: true
|
|
23757
22193
|
});
|
|
23758
22194
|
await Promise.all(dirEntries.map(async (dirEntry) => {
|
|
23759
22195
|
const fullPath = import_node_path4.default.join(dirPath, dirEntry.name);
|
|
23760
|
-
return dirEntry.isDirectory() ? removeDir(fullPath, false) :
|
|
22196
|
+
return dirEntry.isDirectory() ? removeDir(fullPath, false) : import_node_fs3.promises.unlink(fullPath);
|
|
23761
22197
|
}));
|
|
23762
22198
|
if (!onlyContent) {
|
|
23763
|
-
await
|
|
22199
|
+
await import_node_fs3.promises.rmdir(dirPath);
|
|
23764
22200
|
}
|
|
23765
22201
|
}
|
|
23766
22202
|
__name(removeDir, "removeDir");
|
|
23767
22203
|
|
|
23768
|
-
// src/utils/
|
|
22204
|
+
// src/utils/write-file-safely.ts
|
|
23769
22205
|
init_cjs_shims();
|
|
23770
|
-
var
|
|
23771
|
-
var import_node_path5 = __toESM(require("path"), 1);
|
|
22206
|
+
var import_node_fs4 = __toESM(require("node:fs"), 1);
|
|
22207
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
23772
22208
|
|
|
23773
|
-
// src/utils/
|
|
22209
|
+
// src/utils/format-file.ts
|
|
23774
22210
|
init_cjs_shims();
|
|
23775
22211
|
var import_prettier = __toESM(require("prettier"), 1);
|
|
23776
22212
|
async function formatFile(content) {
|
|
@@ -23795,12 +22231,12 @@ async function formatFile(content) {
|
|
|
23795
22231
|
}
|
|
23796
22232
|
__name(formatFile, "formatFile");
|
|
23797
22233
|
|
|
23798
|
-
// src/utils/
|
|
22234
|
+
// src/utils/write-file-safely.ts
|
|
23799
22235
|
var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content) => {
|
|
23800
|
-
|
|
22236
|
+
import_node_fs4.default.mkdirSync(import_node_path5.default.dirname(writeLocation), {
|
|
23801
22237
|
recursive: true
|
|
23802
22238
|
});
|
|
23803
|
-
|
|
22239
|
+
import_node_fs4.default.writeFileSync(writeLocation, await formatFile(content));
|
|
23804
22240
|
}, "writeFileSafely");
|
|
23805
22241
|
|
|
23806
22242
|
// src/prisma-shield-generator.ts
|
|
@@ -23810,7 +22246,7 @@ async function generateShield(options) {
|
|
|
23810
22246
|
const results = configSchema.safeParse(options.generator.config);
|
|
23811
22247
|
if (!results.success) throw new Error("Invalid options passed");
|
|
23812
22248
|
const config = results.data;
|
|
23813
|
-
await
|
|
22249
|
+
await import_node_fs5.promises.mkdir(outputDir, {
|
|
23814
22250
|
recursive: true
|
|
23815
22251
|
});
|
|
23816
22252
|
await removeDir(outputDir, true);
|
|
@@ -23881,12 +22317,13 @@ async function generate(options) {
|
|
|
23881
22317
|
const results = configSchema.safeParse(options.generator.config);
|
|
23882
22318
|
if (!results.success) throw new Error("Invalid options passed");
|
|
23883
22319
|
const config = results.data;
|
|
23884
|
-
await
|
|
22320
|
+
await import_node_fs6.promises.mkdir(outputDir, {
|
|
23885
22321
|
recursive: true
|
|
23886
22322
|
});
|
|
23887
22323
|
await removeDir(outputDir, true);
|
|
23888
22324
|
if (config.withZod !== false) {
|
|
23889
|
-
await (
|
|
22325
|
+
const prismaZodGenerator = await getJiti().import(getJiti().esmResolve("prisma-zod-generator/lib/prisma-generator"));
|
|
22326
|
+
await prismaZodGenerator.generate(options);
|
|
23890
22327
|
}
|
|
23891
22328
|
if (config.withShield !== false) {
|
|
23892
22329
|
const shieldOutputPath = import_node_path7.default.join(outputDir, "./shield");
|
|
@@ -23895,6 +22332,7 @@ async function generate(options) {
|
|
|
23895
22332
|
generator: {
|
|
23896
22333
|
...options.generator,
|
|
23897
22334
|
output: {
|
|
22335
|
+
fromEnvVar: null,
|
|
23898
22336
|
...options.generator.output,
|
|
23899
22337
|
value: shieldOutputPath
|
|
23900
22338
|
},
|