@stryke/prisma-trpc-generator 0.13.48 → 0.13.50
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/_virtual/rolldown_runtime.cjs +31 -1
- package/dist/_virtual/rolldown_runtime.mjs +32 -1
- package/dist/config.cjs +50 -1
- package/dist/config.mjs +49 -1
- package/dist/config.mjs.map +1 -1
- package/dist/generator.cjs +1 -1
- package/dist/generator.mjs +3 -1
- package/dist/helpers.cjs +281 -32
- package/dist/helpers.mjs +271 -32
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.cjs +26 -1
- package/dist/index.mjs +27 -1
- package/dist/index.mjs.map +1 -1
- package/dist/packages/env/src/get-env-paths.cjs +87 -1
- package/dist/packages/env/src/get-env-paths.mjs +84 -1
- package/dist/packages/env/src/get-env-paths.mjs.map +1 -1
- package/dist/packages/string-format/src/acronyms.cjs +408 -1
- package/dist/packages/string-format/src/acronyms.mjs +407 -1
- package/dist/packages/string-format/src/acronyms.mjs.map +1 -1
- package/dist/packages/string-format/src/articles.cjs +10 -1
- package/dist/packages/string-format/src/articles.mjs +9 -1
- package/dist/packages/string-format/src/articles.mjs.map +1 -1
- package/dist/packages/string-format/src/combine.cjs +15 -1
- package/dist/packages/string-format/src/combine.mjs +14 -1
- package/dist/packages/string-format/src/combine.mjs.map +1 -1
- package/dist/packages/string-format/src/conjunctions.cjs +32 -1
- package/dist/packages/string-format/src/conjunctions.mjs +31 -1
- package/dist/packages/string-format/src/conjunctions.mjs.map +1 -1
- package/dist/packages/string-format/src/decamelize.cjs +14 -1
- package/dist/packages/string-format/src/decamelize.mjs +13 -1
- package/dist/packages/string-format/src/decamelize.mjs.map +1 -1
- package/dist/packages/string-format/src/format-special-cases.cjs +33 -1
- package/dist/packages/string-format/src/format-special-cases.mjs +33 -1
- package/dist/packages/string-format/src/format-special-cases.mjs.map +1 -1
- package/dist/packages/string-format/src/lower-case-first.cjs +17 -1
- package/dist/packages/string-format/src/lower-case-first.mjs +16 -1
- package/dist/packages/string-format/src/lower-case-first.mjs.map +1 -1
- package/dist/packages/string-format/src/prepositions.cjs +68 -1
- package/dist/packages/string-format/src/prepositions.mjs +67 -1
- package/dist/packages/string-format/src/prepositions.mjs.map +1 -1
- package/dist/packages/string-format/src/special-cases.cjs +53 -1
- package/dist/packages/string-format/src/special-cases.mjs +52 -1
- package/dist/packages/string-format/src/special-cases.mjs.map +1 -1
- package/dist/packages/string-format/src/title-case.cjs +19 -1
- package/dist/packages/string-format/src/title-case.mjs +19 -1
- package/dist/packages/string-format/src/title-case.mjs.map +1 -1
- package/dist/packages/string-format/src/upper-case-first.cjs +17 -1
- package/dist/packages/string-format/src/upper-case-first.mjs +16 -1
- package/dist/packages/string-format/src/upper-case-first.mjs.map +1 -1
- package/dist/prisma-generator.cjs +185 -8
- package/dist/prisma-generator.mjs +184 -8
- package/dist/prisma-generator.mjs.map +1 -1
- package/dist/project.cjs +15 -1
- package/dist/project.mjs +14 -1
- package/dist/project.mjs.map +1 -1
- package/dist/utils/format-file.cjs +25 -1
- package/dist/utils/format-file.mjs +23 -1
- package/dist/utils/format-file.mjs.map +1 -1
- package/dist/utils/get-jiti.cjs +21 -1
- package/dist/utils/get-jiti.mjs +20 -1
- package/dist/utils/get-jiti.mjs.map +1 -1
- package/dist/utils/get-prisma-internals.cjs +13 -1
- package/dist/utils/get-prisma-internals.mjs +12 -1
- package/dist/utils/get-prisma-internals.mjs.map +1 -1
- package/dist/utils/write-file-safely.cjs +32 -2
- package/dist/utils/write-file-safely.mjs +29 -2
- package/dist/utils/write-file-safely.mjs.map +1 -1
- package/dist/zod/aggregate-helpers.cjs +70 -1
- package/dist/zod/aggregate-helpers.mjs +67 -1
- package/dist/zod/aggregate-helpers.mjs.map +1 -1
- package/dist/zod/comments-helpers.cjs +77 -1
- package/dist/zod/comments-helpers.mjs +75 -1
- package/dist/zod/comments-helpers.mjs.map +1 -1
- package/dist/zod/docs-helpers.cjs +23 -3
- package/dist/zod/docs-helpers.mjs +20 -3
- package/dist/zod/docs-helpers.mjs.map +1 -1
- package/dist/zod/generator-helpers.cjs +34 -1
- package/dist/zod/generator-helpers.mjs +31 -1
- package/dist/zod/generator-helpers.mjs.map +1 -1
- package/dist/zod/helpers.cjs +26 -1
- package/dist/zod/helpers.mjs +26 -1
- package/dist/zod/helpers.mjs.map +1 -1
- package/dist/zod/include-helpers.cjs +69 -1
- package/dist/zod/include-helpers.mjs +69 -1
- package/dist/zod/include-helpers.mjs.map +1 -1
- package/dist/zod/model-helpers.cjs +244 -1
- package/dist/zod/model-helpers.mjs +236 -1
- package/dist/zod/model-helpers.mjs.map +1 -1
- package/dist/zod/modelArgs-helpers.cjs +56 -1
- package/dist/zod/modelArgs-helpers.mjs +56 -1
- package/dist/zod/modelArgs-helpers.mjs.map +1 -1
- package/dist/zod/mongodb-helpers.cjs +49 -1
- package/dist/zod/mongodb-helpers.mjs +48 -1
- package/dist/zod/mongodb-helpers.mjs.map +1 -1
- package/dist/zod/select-helpers.cjs +128 -1
- package/dist/zod/select-helpers.mjs +128 -1
- package/dist/zod/select-helpers.mjs.map +1 -1
- package/dist/zod/transformer.cjs +434 -19
- package/dist/zod/transformer.mjs +432 -19
- package/dist/zod/transformer.mjs.map +1 -1
- package/dist/zod/whereUniqueInput-helpers.cjs +17 -1
- package/dist/zod/whereUniqueInput-helpers.mjs +16 -1
- package/dist/zod/whereUniqueInput-helpers.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_model_helpers = require('./model-helpers.cjs');
|
|
3
|
+
let parenthesis = require("parenthesis");
|
|
4
|
+
parenthesis = require_rolldown_runtime.__toESM(parenthesis);
|
|
5
|
+
|
|
6
|
+
//#region src/zod/docs-helpers.ts
|
|
7
|
+
const getJSDocs = (docString) => {
|
|
8
|
+
const lines = [];
|
|
9
|
+
if (docString) {
|
|
10
|
+
const docLines = docString.split("\n").filter((dL) => !dL.trimStart().startsWith("@zod"));
|
|
11
|
+
if (docLines.length) {
|
|
12
|
+
lines.push("/**");
|
|
13
|
+
docLines.forEach((dL) => lines.push(` * ${dL}`));
|
|
14
|
+
lines.push(" */");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return lines;
|
|
18
|
+
};
|
|
19
|
+
const getZodDocElements = (docString) => docString.split("\n").filter((line) => line.trimStart().startsWith("@zod")).map((line) => line.trimStart().slice(4)).flatMap((line) => require_model_helpers.chunk(parenthesis.default.parse(line), 2).slice(0, -1).map(([each, contents]) => `${each.replace(/\)?\./, "")}${parenthesis.default.stringify(contents)})`));
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.getJSDocs = getJSDocs;
|
|
23
|
+
exports.getZodDocElements = getZodDocElements;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import{chunk
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { chunk } from "./model-helpers.mjs";
|
|
2
|
+
import parenthesis from "parenthesis";
|
|
3
|
+
|
|
4
|
+
//#region src/zod/docs-helpers.ts
|
|
5
|
+
const getJSDocs = (docString) => {
|
|
6
|
+
const lines = [];
|
|
7
|
+
if (docString) {
|
|
8
|
+
const docLines = docString.split("\n").filter((dL) => !dL.trimStart().startsWith("@zod"));
|
|
9
|
+
if (docLines.length) {
|
|
10
|
+
lines.push("/**");
|
|
11
|
+
docLines.forEach((dL) => lines.push(` * ${dL}`));
|
|
12
|
+
lines.push(" */");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return lines;
|
|
16
|
+
};
|
|
17
|
+
const getZodDocElements = (docString) => docString.split("\n").filter((line) => line.trimStart().startsWith("@zod")).map((line) => line.trimStart().slice(4)).flatMap((line) => chunk(parenthesis.parse(line), 2).slice(0, -1).map(([each, contents]) => `${each.replace(/\)?\./, "")}${parenthesis.stringify(contents)})`));
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getJSDocs, getZodDocElements };
|
|
4
21
|
//# sourceMappingURL=docs-helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-helpers.mjs","names":["lines: string[]"],"sources":["../../src/zod/docs-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { ArrayTree } from \"parenthesis\";\nimport parenthesis from \"parenthesis\";\nimport { chunk } from \"./model-helpers\";\n\nexport const getJSDocs = (docString?: string) => {\n const lines: string[] = [];\n\n if (docString) {\n const docLines = docString\n .split(\"\\n\")\n .filter(dL => !dL.trimStart().startsWith(\"@zod\"));\n\n if (docLines.length) {\n lines.push(\"/**\");\n docLines.forEach(dL => lines.push(` * ${dL}`));\n lines.push(\" */\");\n }\n }\n\n return lines;\n};\n\nexport const getZodDocElements = (docString: string) =>\n docString\n .split(\"\\n\")\n .filter(line => line.trimStart().startsWith(\"@zod\"))\n .map(line => line.trimStart().slice(4))\n .flatMap(line =>\n // Array.from(line.matchAll(/\\.([^().]+\\(.*?\\))/g), (m) => m.slice(1)).flat()\n chunk(parenthesis.parse(line), 2)\n .slice(0, -1)\n .map(\n ([each, contents]) =>\n `${(each as string).replace(\n /\\)?\\./,\n \"\"\n )}${parenthesis.stringify(contents as ArrayTree)})`\n )\n );\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"docs-helpers.mjs","names":["lines: string[]"],"sources":["../../src/zod/docs-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { ArrayTree } from \"parenthesis\";\nimport parenthesis from \"parenthesis\";\nimport { chunk } from \"./model-helpers\";\n\nexport const getJSDocs = (docString?: string) => {\n const lines: string[] = [];\n\n if (docString) {\n const docLines = docString\n .split(\"\\n\")\n .filter(dL => !dL.trimStart().startsWith(\"@zod\"));\n\n if (docLines.length) {\n lines.push(\"/**\");\n docLines.forEach(dL => lines.push(` * ${dL}`));\n lines.push(\" */\");\n }\n }\n\n return lines;\n};\n\nexport const getZodDocElements = (docString: string) =>\n docString\n .split(\"\\n\")\n .filter(line => line.trimStart().startsWith(\"@zod\"))\n .map(line => line.trimStart().slice(4))\n .flatMap(line =>\n // Array.from(line.matchAll(/\\.([^().]+\\(.*?\\))/g), (m) => m.slice(1)).flat()\n chunk(parenthesis.parse(line), 2)\n .slice(0, -1)\n .map(\n ([each, contents]) =>\n `${(each as string).replace(\n /\\)?\\./,\n \"\"\n )}${parenthesis.stringify(contents as ArrayTree)})`\n )\n );\n"],"mappings":";;;;AAqBA,MAAa,aAAa,cAAuB;CAC/C,MAAMA,QAAkB,EAAE;AAE1B,KAAI,WAAW;EACb,MAAM,WAAW,UACd,MAAM,KAAK,CACX,QAAO,OAAM,CAAC,GAAG,WAAW,CAAC,WAAW,OAAO,CAAC;AAEnD,MAAI,SAAS,QAAQ;AACnB,SAAM,KAAK,MAAM;AACjB,YAAS,SAAQ,OAAM,MAAM,KAAK,MAAM,KAAK,CAAC;AAC9C,SAAM,KAAK,MAAM;;;AAIrB,QAAO;;AAGT,MAAa,qBAAqB,cAChC,UACG,MAAM,KAAK,CACX,QAAO,SAAQ,KAAK,WAAW,CAAC,WAAW,OAAO,CAAC,CACnD,KAAI,SAAQ,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC,CACtC,SAAQ,SAEP,MAAM,YAAY,MAAM,KAAK,EAAE,EAAE,CAC9B,MAAM,GAAG,GAAG,CACZ,KACE,CAAC,MAAM,cACN,GAAI,KAAgB,QAClB,SACA,GACD,GAAG,YAAY,UAAU,SAAsB,CAAC,GACpD,CACJ"}
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_transformer = require('./transformer.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/zod/generator-helpers.ts
|
|
4
|
+
async function generateZodEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
|
|
5
|
+
const enumTypes = [...prismaSchemaEnum, ...modelSchemaEnum];
|
|
6
|
+
require_transformer.default.enumNames = enumTypes.map((enumItem) => enumItem.name) ?? [];
|
|
7
|
+
await new require_transformer.default({ enumTypes }).generateEnumSchemas();
|
|
8
|
+
}
|
|
9
|
+
async function generateZodObjectSchemas(inputObjectTypes) {
|
|
10
|
+
for (let i = 0; i < inputObjectTypes.length; i += 1) {
|
|
11
|
+
const fields = inputObjectTypes[i]?.fields;
|
|
12
|
+
const name = inputObjectTypes[i]?.name;
|
|
13
|
+
await new require_transformer.default({
|
|
14
|
+
name,
|
|
15
|
+
fields
|
|
16
|
+
}).generateObjectSchema();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function generateZodModelSchemas(models, modelOperations, aggregateOperationSupport) {
|
|
20
|
+
await new require_transformer.default({
|
|
21
|
+
models,
|
|
22
|
+
modelOperations,
|
|
23
|
+
aggregateOperationSupport
|
|
24
|
+
}).generateModelSchemas();
|
|
25
|
+
}
|
|
26
|
+
async function generateZodIndex() {
|
|
27
|
+
await require_transformer.default.generateIndex();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.generateZodEnumSchemas = generateZodEnumSchemas;
|
|
32
|
+
exports.generateZodIndex = generateZodIndex;
|
|
33
|
+
exports.generateZodModelSchemas = generateZodModelSchemas;
|
|
34
|
+
exports.generateZodObjectSchemas = generateZodObjectSchemas;
|
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Transformer from "./transformer.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/zod/generator-helpers.ts
|
|
4
|
+
async function generateZodEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
|
|
5
|
+
const enumTypes = [...prismaSchemaEnum, ...modelSchemaEnum];
|
|
6
|
+
Transformer.enumNames = enumTypes.map((enumItem) => enumItem.name) ?? [];
|
|
7
|
+
await new Transformer({ enumTypes }).generateEnumSchemas();
|
|
8
|
+
}
|
|
9
|
+
async function generateZodObjectSchemas(inputObjectTypes) {
|
|
10
|
+
for (let i = 0; i < inputObjectTypes.length; i += 1) {
|
|
11
|
+
const fields = inputObjectTypes[i]?.fields;
|
|
12
|
+
const name = inputObjectTypes[i]?.name;
|
|
13
|
+
await new Transformer({
|
|
14
|
+
name,
|
|
15
|
+
fields
|
|
16
|
+
}).generateObjectSchema();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function generateZodModelSchemas(models, modelOperations, aggregateOperationSupport) {
|
|
20
|
+
await new Transformer({
|
|
21
|
+
models,
|
|
22
|
+
modelOperations,
|
|
23
|
+
aggregateOperationSupport
|
|
24
|
+
}).generateModelSchemas();
|
|
25
|
+
}
|
|
26
|
+
async function generateZodIndex() {
|
|
27
|
+
await Transformer.generateIndex();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { generateZodEnumSchemas, generateZodIndex, generateZodModelSchemas, generateZodObjectSchemas };
|
|
2
32
|
//# sourceMappingURL=generator-helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator-helpers.mjs","names":[],"sources":["../../src/zod/generator-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { DMMF } from \"@prisma/generator-helper\";\nimport type { AggregateOperationSupport, Writeable } from \"../types\";\nimport Transformer from \"./transformer\";\n\nexport async function generateZodEnumSchemas(\n prismaSchemaEnum: Writeable<DMMF.SchemaEnum[]>,\n modelSchemaEnum: Writeable<DMMF.SchemaEnum[]>\n) {\n const enumTypes = [...prismaSchemaEnum, ...modelSchemaEnum];\n const enumNames = enumTypes.map(enumItem => enumItem.name);\n Transformer.enumNames = enumNames ?? [];\n const transformer = new Transformer({\n enumTypes\n });\n await transformer.generateEnumSchemas();\n}\n\nexport async function generateZodObjectSchemas(\n inputObjectTypes: Writeable<DMMF.InputType[]>\n) {\n for (let i = 0; i < inputObjectTypes.length; i += 1) {\n const fields = inputObjectTypes[i]?.fields;\n const name = inputObjectTypes[i]?.name;\n const transformer = new Transformer({ name, fields });\n await transformer.generateObjectSchema();\n }\n}\n\nexport async function generateZodModelSchemas(\n models: Writeable<DMMF.Model[]>,\n modelOperations: Writeable<DMMF.ModelMapping[]>,\n aggregateOperationSupport: AggregateOperationSupport\n) {\n const transformer = new Transformer({\n models,\n modelOperations,\n aggregateOperationSupport\n });\n await transformer.generateModelSchemas();\n}\n\nexport async function generateZodIndex() {\n await Transformer.generateIndex();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator-helpers.mjs","names":[],"sources":["../../src/zod/generator-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { DMMF } from \"@prisma/generator-helper\";\nimport type { AggregateOperationSupport, Writeable } from \"../types\";\nimport Transformer from \"./transformer\";\n\nexport async function generateZodEnumSchemas(\n prismaSchemaEnum: Writeable<DMMF.SchemaEnum[]>,\n modelSchemaEnum: Writeable<DMMF.SchemaEnum[]>\n) {\n const enumTypes = [...prismaSchemaEnum, ...modelSchemaEnum];\n const enumNames = enumTypes.map(enumItem => enumItem.name);\n Transformer.enumNames = enumNames ?? [];\n const transformer = new Transformer({\n enumTypes\n });\n await transformer.generateEnumSchemas();\n}\n\nexport async function generateZodObjectSchemas(\n inputObjectTypes: Writeable<DMMF.InputType[]>\n) {\n for (let i = 0; i < inputObjectTypes.length; i += 1) {\n const fields = inputObjectTypes[i]?.fields;\n const name = inputObjectTypes[i]?.name;\n const transformer = new Transformer({ name, fields });\n await transformer.generateObjectSchema();\n }\n}\n\nexport async function generateZodModelSchemas(\n models: Writeable<DMMF.Model[]>,\n modelOperations: Writeable<DMMF.ModelMapping[]>,\n aggregateOperationSupport: AggregateOperationSupport\n) {\n const transformer = new Transformer({\n models,\n modelOperations,\n aggregateOperationSupport\n });\n await transformer.generateModelSchemas();\n}\n\nexport async function generateZodIndex() {\n await Transformer.generateIndex();\n}\n"],"mappings":";;;AAqBA,eAAsB,uBACpB,kBACA,iBACA;CACA,MAAM,YAAY,CAAC,GAAG,kBAAkB,GAAG,gBAAgB;AAE3D,aAAY,YADM,UAAU,KAAI,aAAY,SAAS,KAAK,IACrB,EAAE;AAIvC,OAHoB,IAAI,YAAY,EAClC,WACD,CAAC,CACgB,qBAAqB;;AAGzC,eAAsB,yBACpB,kBACA;AACA,MAAK,IAAI,IAAI,GAAG,IAAI,iBAAiB,QAAQ,KAAK,GAAG;EACnD,MAAM,SAAS,iBAAiB,IAAI;EACpC,MAAM,OAAO,iBAAiB,IAAI;AAElC,QADoB,IAAI,YAAY;GAAE;GAAM;GAAQ,CAAC,CACnC,sBAAsB;;;AAI5C,eAAsB,wBACpB,QACA,iBACA,2BACA;AAMA,OALoB,IAAI,YAAY;EAClC;EACA;EACA;EACD,CAAC,CACgB,sBAAsB;;AAG1C,eAAsB,mBAAmB;AACvC,OAAM,YAAY,eAAe"}
|
package/dist/zod/helpers.cjs
CHANGED
|
@@ -1 +1,26 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_aggregate_helpers = require('./aggregate-helpers.cjs');
|
|
2
|
+
const require_mongodb_helpers = require('./mongodb-helpers.cjs');
|
|
3
|
+
const require_transformer = require('./transformer.cjs');
|
|
4
|
+
const require_include_helpers = require('./include-helpers.cjs');
|
|
5
|
+
const require_modelArgs_helpers = require('./modelArgs-helpers.cjs');
|
|
6
|
+
const require_select_helpers = require('./select-helpers.cjs');
|
|
7
|
+
const require_whereUniqueInput_helpers = require('./whereUniqueInput-helpers.cjs');
|
|
8
|
+
|
|
9
|
+
//#region src/zod/helpers.ts
|
|
10
|
+
function addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
|
|
11
|
+
if (dataSourceProvider === "mongodb") require_mongodb_helpers.addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes);
|
|
12
|
+
require_aggregate_helpers.addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes);
|
|
13
|
+
if (options.isGenerateSelect) {
|
|
14
|
+
require_select_helpers.addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models);
|
|
15
|
+
require_transformer.default.setIsGenerateSelect(true);
|
|
16
|
+
}
|
|
17
|
+
if (options.isGenerateSelect || options.isGenerateInclude) require_modelArgs_helpers.addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, options.isGenerateSelect, options.isGenerateInclude);
|
|
18
|
+
if (options.isGenerateInclude) {
|
|
19
|
+
require_include_helpers.addMissingInputObjectTypesForInclude(inputObjectTypes, models, options.isGenerateSelect);
|
|
20
|
+
require_transformer.default.setIsGenerateInclude(true);
|
|
21
|
+
}
|
|
22
|
+
require_whereUniqueInput_helpers.changeOptionalToRequiredFields(inputObjectTypes);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.addMissingZodInputObjectTypes = addMissingZodInputObjectTypes;
|
package/dist/zod/helpers.mjs
CHANGED
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { addMissingInputObjectTypesForAggregate } from "./aggregate-helpers.mjs";
|
|
2
|
+
import { addMissingInputObjectTypesForMongoDbRawOpsAndQueries } from "./mongodb-helpers.mjs";
|
|
3
|
+
import Transformer from "./transformer.mjs";
|
|
4
|
+
import { addMissingInputObjectTypesForInclude } from "./include-helpers.mjs";
|
|
5
|
+
import { addMissingInputObjectTypesForModelArgs } from "./modelArgs-helpers.mjs";
|
|
6
|
+
import { addMissingInputObjectTypesForSelect } from "./select-helpers.mjs";
|
|
7
|
+
import { changeOptionalToRequiredFields } from "./whereUniqueInput-helpers.mjs";
|
|
8
|
+
|
|
9
|
+
//#region src/zod/helpers.ts
|
|
10
|
+
function addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
|
|
11
|
+
if (dataSourceProvider === "mongodb") addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes);
|
|
12
|
+
addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes);
|
|
13
|
+
if (options.isGenerateSelect) {
|
|
14
|
+
addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models);
|
|
15
|
+
Transformer.setIsGenerateSelect(true);
|
|
16
|
+
}
|
|
17
|
+
if (options.isGenerateSelect || options.isGenerateInclude) addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, options.isGenerateSelect, options.isGenerateInclude);
|
|
18
|
+
if (options.isGenerateInclude) {
|
|
19
|
+
addMissingInputObjectTypesForInclude(inputObjectTypes, models, options.isGenerateSelect);
|
|
20
|
+
Transformer.setIsGenerateInclude(true);
|
|
21
|
+
}
|
|
22
|
+
changeOptionalToRequiredFields(inputObjectTypes);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { addMissingZodInputObjectTypes };
|
|
2
27
|
//# sourceMappingURL=helpers.mjs.map
|
package/dist/zod/helpers.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/zod/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { ConnectorType, DMMF } from \"@prisma/generator-helper\";\nimport type { Writeable } from \"../types\";\nimport { addMissingInputObjectTypesForAggregate } from \"./aggregate-helpers\";\nimport { addMissingInputObjectTypesForInclude } from \"./include-helpers\";\nimport { addMissingInputObjectTypesForModelArgs } from \"./modelArgs-helpers\";\nimport { addMissingInputObjectTypesForMongoDbRawOpsAndQueries } from \"./mongodb-helpers\";\nimport { addMissingInputObjectTypesForSelect } from \"./select-helpers\";\nimport Transformer from \"./transformer\";\nimport { changeOptionalToRequiredFields } from \"./whereUniqueInput-helpers\";\n\ninterface AddMissingInputObjectTypeOptions {\n isGenerateSelect: boolean;\n isGenerateInclude: boolean;\n}\n\nexport function addMissingZodInputObjectTypes(\n inputObjectTypes: DMMF.InputType[],\n outputObjectTypes: DMMF.OutputType[],\n models: DMMF.Model[],\n modelOperations: DMMF.ModelMapping[],\n dataSourceProvider: ConnectorType,\n options: AddMissingInputObjectTypeOptions\n) {\n // TODO: remove once Prisma fix this issue: https://github.com/prisma/prisma/issues/14900\n if (dataSourceProvider === \"mongodb\") {\n addMissingInputObjectTypesForMongoDbRawOpsAndQueries(\n modelOperations,\n outputObjectTypes,\n inputObjectTypes\n );\n }\n addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes);\n if (options.isGenerateSelect) {\n addMissingInputObjectTypesForSelect(\n inputObjectTypes,\n outputObjectTypes,\n models\n );\n Transformer.setIsGenerateSelect(true);\n }\n if (options.isGenerateSelect || options.isGenerateInclude) {\n addMissingInputObjectTypesForModelArgs(\n inputObjectTypes,\n models,\n options.isGenerateSelect,\n options.isGenerateInclude\n );\n }\n if (options.isGenerateInclude) {\n addMissingInputObjectTypesForInclude(\n inputObjectTypes,\n models,\n options.isGenerateSelect\n );\n Transformer.setIsGenerateInclude(true);\n }\n\n changeOptionalToRequiredFields(\n inputObjectTypes as Writeable<DMMF.InputType[]>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/zod/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { ConnectorType, DMMF } from \"@prisma/generator-helper\";\nimport type { Writeable } from \"../types\";\nimport { addMissingInputObjectTypesForAggregate } from \"./aggregate-helpers\";\nimport { addMissingInputObjectTypesForInclude } from \"./include-helpers\";\nimport { addMissingInputObjectTypesForModelArgs } from \"./modelArgs-helpers\";\nimport { addMissingInputObjectTypesForMongoDbRawOpsAndQueries } from \"./mongodb-helpers\";\nimport { addMissingInputObjectTypesForSelect } from \"./select-helpers\";\nimport Transformer from \"./transformer\";\nimport { changeOptionalToRequiredFields } from \"./whereUniqueInput-helpers\";\n\ninterface AddMissingInputObjectTypeOptions {\n isGenerateSelect: boolean;\n isGenerateInclude: boolean;\n}\n\nexport function addMissingZodInputObjectTypes(\n inputObjectTypes: DMMF.InputType[],\n outputObjectTypes: DMMF.OutputType[],\n models: DMMF.Model[],\n modelOperations: DMMF.ModelMapping[],\n dataSourceProvider: ConnectorType,\n options: AddMissingInputObjectTypeOptions\n) {\n // TODO: remove once Prisma fix this issue: https://github.com/prisma/prisma/issues/14900\n if (dataSourceProvider === \"mongodb\") {\n addMissingInputObjectTypesForMongoDbRawOpsAndQueries(\n modelOperations,\n outputObjectTypes,\n inputObjectTypes\n );\n }\n addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes);\n if (options.isGenerateSelect) {\n addMissingInputObjectTypesForSelect(\n inputObjectTypes,\n outputObjectTypes,\n models\n );\n Transformer.setIsGenerateSelect(true);\n }\n if (options.isGenerateSelect || options.isGenerateInclude) {\n addMissingInputObjectTypesForModelArgs(\n inputObjectTypes,\n models,\n options.isGenerateSelect,\n options.isGenerateInclude\n );\n }\n if (options.isGenerateInclude) {\n addMissingInputObjectTypesForInclude(\n inputObjectTypes,\n models,\n options.isGenerateSelect\n );\n Transformer.setIsGenerateInclude(true);\n }\n\n changeOptionalToRequiredFields(\n inputObjectTypes as Writeable<DMMF.InputType[]>\n );\n}\n"],"mappings":";;;;;;;;;AAgCA,SAAgB,8BACd,kBACA,mBACA,QACA,iBACA,oBACA,SACA;AAEA,KAAI,uBAAuB,UACzB,sDACE,iBACA,mBACA,iBACD;AAEH,wCAAuC,kBAAkB,kBAAkB;AAC3E,KAAI,QAAQ,kBAAkB;AAC5B,sCACE,kBACA,mBACA,OACD;AACD,cAAY,oBAAoB,KAAK;;AAEvC,KAAI,QAAQ,oBAAoB,QAAQ,kBACtC,wCACE,kBACA,QACA,QAAQ,kBACR,QAAQ,kBACT;AAEH,KAAI,QAAQ,mBAAmB;AAC7B,uCACE,kBACA,QACA,QAAQ,iBACT;AACD,cAAY,qBAAqB,KAAK;;AAGxC,gCACE,iBACD"}
|
|
@@ -1 +1,69 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_model_helpers = require('./model-helpers.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/zod/include-helpers.ts
|
|
4
|
+
function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
|
|
5
|
+
const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
|
|
6
|
+
for (const includeInputObjectType of generatedIncludeInputObjectTypes) inputObjectTypes.push(includeInputObjectType);
|
|
7
|
+
}
|
|
8
|
+
function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
|
|
9
|
+
const modelIncludeInputObjectTypes = [];
|
|
10
|
+
for (const model of models) {
|
|
11
|
+
const { name: modelName, fields: modelFields } = model;
|
|
12
|
+
const fields = [];
|
|
13
|
+
for (const modelField of modelFields) {
|
|
14
|
+
const { name: modelFieldName, isList, type } = modelField;
|
|
15
|
+
if (require_model_helpers.checkIsModelRelationField(modelField)) {
|
|
16
|
+
const field = {
|
|
17
|
+
name: modelFieldName,
|
|
18
|
+
isRequired: false,
|
|
19
|
+
isNullable: false,
|
|
20
|
+
inputTypes: [{
|
|
21
|
+
isList: false,
|
|
22
|
+
type: "Boolean",
|
|
23
|
+
location: "scalar"
|
|
24
|
+
}, {
|
|
25
|
+
isList: false,
|
|
26
|
+
type: isList ? `${type}FindManyArgs` : `${type}DefaultArgs`,
|
|
27
|
+
location: "inputObjectTypes",
|
|
28
|
+
namespace: "prisma"
|
|
29
|
+
}]
|
|
30
|
+
};
|
|
31
|
+
fields.push(field);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!require_model_helpers.checkModelHasModelRelation(model)) continue;
|
|
35
|
+
if (require_model_helpers.checkModelHasManyModelRelation(model)) {
|
|
36
|
+
const inputTypes = [{
|
|
37
|
+
isList: false,
|
|
38
|
+
type: "Boolean",
|
|
39
|
+
location: "scalar"
|
|
40
|
+
}];
|
|
41
|
+
if (isGenerateSelect) inputTypes.push({
|
|
42
|
+
isList: false,
|
|
43
|
+
type: `${modelName}CountOutputTypeDefaultArgs`,
|
|
44
|
+
location: "inputObjectTypes",
|
|
45
|
+
namespace: "prisma"
|
|
46
|
+
});
|
|
47
|
+
const _countField = {
|
|
48
|
+
name: "_count",
|
|
49
|
+
isRequired: false,
|
|
50
|
+
isNullable: false,
|
|
51
|
+
inputTypes
|
|
52
|
+
};
|
|
53
|
+
fields.push(_countField);
|
|
54
|
+
}
|
|
55
|
+
const modelIncludeInputObjectType = {
|
|
56
|
+
name: `${modelName}Include`,
|
|
57
|
+
constraints: {
|
|
58
|
+
maxNumFields: null,
|
|
59
|
+
minNumFields: null
|
|
60
|
+
},
|
|
61
|
+
fields
|
|
62
|
+
};
|
|
63
|
+
modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);
|
|
64
|
+
}
|
|
65
|
+
return modelIncludeInputObjectTypes;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
exports.addMissingInputObjectTypesForInclude = addMissingInputObjectTypesForInclude;
|
|
@@ -1,2 +1,70 @@
|
|
|
1
|
-
import{checkIsModelRelationField
|
|
1
|
+
import { checkIsModelRelationField, checkModelHasManyModelRelation, checkModelHasModelRelation } from "./model-helpers.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/zod/include-helpers.ts
|
|
4
|
+
function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
|
|
5
|
+
const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
|
|
6
|
+
for (const includeInputObjectType of generatedIncludeInputObjectTypes) inputObjectTypes.push(includeInputObjectType);
|
|
7
|
+
}
|
|
8
|
+
function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
|
|
9
|
+
const modelIncludeInputObjectTypes = [];
|
|
10
|
+
for (const model of models) {
|
|
11
|
+
const { name: modelName, fields: modelFields } = model;
|
|
12
|
+
const fields = [];
|
|
13
|
+
for (const modelField of modelFields) {
|
|
14
|
+
const { name: modelFieldName, isList, type } = modelField;
|
|
15
|
+
if (checkIsModelRelationField(modelField)) {
|
|
16
|
+
const field = {
|
|
17
|
+
name: modelFieldName,
|
|
18
|
+
isRequired: false,
|
|
19
|
+
isNullable: false,
|
|
20
|
+
inputTypes: [{
|
|
21
|
+
isList: false,
|
|
22
|
+
type: "Boolean",
|
|
23
|
+
location: "scalar"
|
|
24
|
+
}, {
|
|
25
|
+
isList: false,
|
|
26
|
+
type: isList ? `${type}FindManyArgs` : `${type}DefaultArgs`,
|
|
27
|
+
location: "inputObjectTypes",
|
|
28
|
+
namespace: "prisma"
|
|
29
|
+
}]
|
|
30
|
+
};
|
|
31
|
+
fields.push(field);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!checkModelHasModelRelation(model)) continue;
|
|
35
|
+
if (checkModelHasManyModelRelation(model)) {
|
|
36
|
+
const inputTypes = [{
|
|
37
|
+
isList: false,
|
|
38
|
+
type: "Boolean",
|
|
39
|
+
location: "scalar"
|
|
40
|
+
}];
|
|
41
|
+
if (isGenerateSelect) inputTypes.push({
|
|
42
|
+
isList: false,
|
|
43
|
+
type: `${modelName}CountOutputTypeDefaultArgs`,
|
|
44
|
+
location: "inputObjectTypes",
|
|
45
|
+
namespace: "prisma"
|
|
46
|
+
});
|
|
47
|
+
const _countField = {
|
|
48
|
+
name: "_count",
|
|
49
|
+
isRequired: false,
|
|
50
|
+
isNullable: false,
|
|
51
|
+
inputTypes
|
|
52
|
+
};
|
|
53
|
+
fields.push(_countField);
|
|
54
|
+
}
|
|
55
|
+
const modelIncludeInputObjectType = {
|
|
56
|
+
name: `${modelName}Include`,
|
|
57
|
+
constraints: {
|
|
58
|
+
maxNumFields: null,
|
|
59
|
+
minNumFields: null
|
|
60
|
+
},
|
|
61
|
+
fields
|
|
62
|
+
};
|
|
63
|
+
modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);
|
|
64
|
+
}
|
|
65
|
+
return modelIncludeInputObjectTypes;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
export { addMissingInputObjectTypesForInclude };
|
|
2
70
|
//# sourceMappingURL=include-helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"include-helpers.mjs","names":["modelIncludeInputObjectTypes: DMMF.InputType[]","fields: DMMF.SchemaArg[]","field: DMMF.SchemaArg","inputTypes: SchemaArgInputTypes","_countField: DMMF.SchemaArg","modelIncludeInputObjectType: DMMF.InputType"],"sources":["../../src/zod/include-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { DMMF } from \"@prisma/generator-helper\";\nimport type { SchemaArgInputTypes } from \"../types\";\nimport {\n checkIsModelRelationField,\n checkModelHasManyModelRelation,\n checkModelHasModelRelation\n} from \"./model-helpers\";\n\nexport function addMissingInputObjectTypesForInclude(\n inputObjectTypes: DMMF.InputType[],\n models: DMMF.Model[],\n isGenerateSelect: boolean\n) {\n // generate input object types necessary to support ModelInclude with relation support\n const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(\n models,\n isGenerateSelect\n );\n\n for (const includeInputObjectType of generatedIncludeInputObjectTypes) {\n inputObjectTypes.push(includeInputObjectType);\n }\n}\n\nfunction generateModelIncludeInputObjectTypes(\n models: DMMF.Model[],\n isGenerateSelect: boolean\n) {\n const modelIncludeInputObjectTypes: DMMF.InputType[] = [];\n for (const model of models) {\n const { name: modelName, fields: modelFields } = model;\n const fields: DMMF.SchemaArg[] = [];\n\n for (const modelField of modelFields) {\n const { name: modelFieldName, isList, type } = modelField;\n\n const isRelationField = checkIsModelRelationField(modelField);\n\n if (isRelationField) {\n const field: DMMF.SchemaArg = {\n name: modelFieldName,\n isRequired: false,\n isNullable: false,\n inputTypes: [\n { isList: false, type: \"Boolean\", location: \"scalar\" },\n {\n isList: false,\n type: isList ? `${type}FindManyArgs` : `${type}DefaultArgs`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n }\n ]\n };\n fields.push(field);\n }\n }\n\n /**\n * include is not generated for models that do not have a relation with any other models continue onto the next model\n */\n const hasRelationToAnotherModel = checkModelHasModelRelation(model);\n if (!hasRelationToAnotherModel) {\n continue;\n }\n\n const hasManyRelationToAnotherModel = checkModelHasManyModelRelation(model);\n\n const shouldAddCountField = hasManyRelationToAnotherModel;\n if (shouldAddCountField) {\n const inputTypes: SchemaArgInputTypes = [\n { isList: false, type: \"Boolean\", location: \"scalar\" }\n ];\n if (isGenerateSelect) {\n inputTypes.push({\n isList: false,\n type: `${modelName}CountOutputTypeDefaultArgs`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n });\n }\n const _countField: DMMF.SchemaArg = {\n name: \"_count\",\n isRequired: false,\n isNullable: false,\n inputTypes\n };\n fields.push(_countField);\n }\n\n const modelIncludeInputObjectType: DMMF.InputType = {\n name: `${modelName}Include`,\n constraints: {\n maxNumFields: null,\n minNumFields: null\n },\n fields\n };\n modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);\n }\n return modelIncludeInputObjectTypes;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"include-helpers.mjs","names":["modelIncludeInputObjectTypes: DMMF.InputType[]","fields: DMMF.SchemaArg[]","field: DMMF.SchemaArg","inputTypes: SchemaArgInputTypes","_countField: DMMF.SchemaArg","modelIncludeInputObjectType: DMMF.InputType"],"sources":["../../src/zod/include-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { DMMF } from \"@prisma/generator-helper\";\nimport type { SchemaArgInputTypes } from \"../types\";\nimport {\n checkIsModelRelationField,\n checkModelHasManyModelRelation,\n checkModelHasModelRelation\n} from \"./model-helpers\";\n\nexport function addMissingInputObjectTypesForInclude(\n inputObjectTypes: DMMF.InputType[],\n models: DMMF.Model[],\n isGenerateSelect: boolean\n) {\n // generate input object types necessary to support ModelInclude with relation support\n const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(\n models,\n isGenerateSelect\n );\n\n for (const includeInputObjectType of generatedIncludeInputObjectTypes) {\n inputObjectTypes.push(includeInputObjectType);\n }\n}\n\nfunction generateModelIncludeInputObjectTypes(\n models: DMMF.Model[],\n isGenerateSelect: boolean\n) {\n const modelIncludeInputObjectTypes: DMMF.InputType[] = [];\n for (const model of models) {\n const { name: modelName, fields: modelFields } = model;\n const fields: DMMF.SchemaArg[] = [];\n\n for (const modelField of modelFields) {\n const { name: modelFieldName, isList, type } = modelField;\n\n const isRelationField = checkIsModelRelationField(modelField);\n\n if (isRelationField) {\n const field: DMMF.SchemaArg = {\n name: modelFieldName,\n isRequired: false,\n isNullable: false,\n inputTypes: [\n { isList: false, type: \"Boolean\", location: \"scalar\" },\n {\n isList: false,\n type: isList ? `${type}FindManyArgs` : `${type}DefaultArgs`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n }\n ]\n };\n fields.push(field);\n }\n }\n\n /**\n * include is not generated for models that do not have a relation with any other models continue onto the next model\n */\n const hasRelationToAnotherModel = checkModelHasModelRelation(model);\n if (!hasRelationToAnotherModel) {\n continue;\n }\n\n const hasManyRelationToAnotherModel = checkModelHasManyModelRelation(model);\n\n const shouldAddCountField = hasManyRelationToAnotherModel;\n if (shouldAddCountField) {\n const inputTypes: SchemaArgInputTypes = [\n { isList: false, type: \"Boolean\", location: \"scalar\" }\n ];\n if (isGenerateSelect) {\n inputTypes.push({\n isList: false,\n type: `${modelName}CountOutputTypeDefaultArgs`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n });\n }\n const _countField: DMMF.SchemaArg = {\n name: \"_count\",\n isRequired: false,\n isNullable: false,\n inputTypes\n };\n fields.push(_countField);\n }\n\n const modelIncludeInputObjectType: DMMF.InputType = {\n name: `${modelName}Include`,\n constraints: {\n maxNumFields: null,\n minNumFields: null\n },\n fields\n };\n modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);\n }\n return modelIncludeInputObjectTypes;\n}\n"],"mappings":";;;AAyBA,SAAgB,qCACd,kBACA,QACA,kBACA;CAEA,MAAM,mCAAmC,qCACvC,QACA,iBACD;AAED,MAAK,MAAM,0BAA0B,iCACnC,kBAAiB,KAAK,uBAAuB;;AAIjD,SAAS,qCACP,QACA,kBACA;CACA,MAAMA,+BAAiD,EAAE;AACzD,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,EAAE,MAAM,WAAW,QAAQ,gBAAgB;EACjD,MAAMC,SAA2B,EAAE;AAEnC,OAAK,MAAM,cAAc,aAAa;GACpC,MAAM,EAAE,MAAM,gBAAgB,QAAQ,SAAS;AAI/C,OAFwB,0BAA0B,WAAW,EAExC;IACnB,MAAMC,QAAwB;KAC5B,MAAM;KACN,YAAY;KACZ,YAAY;KACZ,YAAY,CACV;MAAE,QAAQ;MAAO,MAAM;MAAW,UAAU;MAAU,EACtD;MACE,QAAQ;MACR,MAAM,SAAS,GAAG,KAAK,gBAAgB,GAAG,KAAK;MAC/C,UAAU;MACV,WAAW;MACZ,CACF;KACF;AACD,WAAO,KAAK,MAAM;;;AAQtB,MAAI,CAD8B,2BAA2B,MAAM,CAEjE;AAMF,MAHsC,+BAA+B,MAAM,EAGlD;GACvB,MAAMC,aAAkC,CACtC;IAAE,QAAQ;IAAO,MAAM;IAAW,UAAU;IAAU,CACvD;AACD,OAAI,iBACF,YAAW,KAAK;IACd,QAAQ;IACR,MAAM,GAAG,UAAU;IACnB,UAAU;IACV,WAAW;IACZ,CAAC;GAEJ,MAAMC,cAA8B;IAClC,MAAM;IACN,YAAY;IACZ,YAAY;IACZ;IACD;AACD,UAAO,KAAK,YAAY;;EAG1B,MAAMC,8BAA8C;GAClD,MAAM,GAAG,UAAU;GACnB,aAAa;IACX,cAAc;IACd,cAAc;IACf;GACD;GACD;AACD,+BAA6B,KAAK,4BAA4B;;AAEhE,QAAO"}
|