@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.
Files changed (104) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +31 -1
  2. package/dist/_virtual/rolldown_runtime.mjs +32 -1
  3. package/dist/config.cjs +50 -1
  4. package/dist/config.mjs +49 -1
  5. package/dist/config.mjs.map +1 -1
  6. package/dist/generator.cjs +1 -1
  7. package/dist/generator.mjs +3 -1
  8. package/dist/helpers.cjs +281 -32
  9. package/dist/helpers.mjs +271 -32
  10. package/dist/helpers.mjs.map +1 -1
  11. package/dist/index.cjs +26 -1
  12. package/dist/index.mjs +27 -1
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/packages/env/src/get-env-paths.cjs +87 -1
  15. package/dist/packages/env/src/get-env-paths.mjs +84 -1
  16. package/dist/packages/env/src/get-env-paths.mjs.map +1 -1
  17. package/dist/packages/string-format/src/acronyms.cjs +408 -1
  18. package/dist/packages/string-format/src/acronyms.mjs +407 -1
  19. package/dist/packages/string-format/src/acronyms.mjs.map +1 -1
  20. package/dist/packages/string-format/src/articles.cjs +10 -1
  21. package/dist/packages/string-format/src/articles.mjs +9 -1
  22. package/dist/packages/string-format/src/articles.mjs.map +1 -1
  23. package/dist/packages/string-format/src/combine.cjs +15 -1
  24. package/dist/packages/string-format/src/combine.mjs +14 -1
  25. package/dist/packages/string-format/src/combine.mjs.map +1 -1
  26. package/dist/packages/string-format/src/conjunctions.cjs +32 -1
  27. package/dist/packages/string-format/src/conjunctions.mjs +31 -1
  28. package/dist/packages/string-format/src/conjunctions.mjs.map +1 -1
  29. package/dist/packages/string-format/src/decamelize.cjs +14 -1
  30. package/dist/packages/string-format/src/decamelize.mjs +13 -1
  31. package/dist/packages/string-format/src/decamelize.mjs.map +1 -1
  32. package/dist/packages/string-format/src/format-special-cases.cjs +33 -1
  33. package/dist/packages/string-format/src/format-special-cases.mjs +33 -1
  34. package/dist/packages/string-format/src/format-special-cases.mjs.map +1 -1
  35. package/dist/packages/string-format/src/lower-case-first.cjs +17 -1
  36. package/dist/packages/string-format/src/lower-case-first.mjs +16 -1
  37. package/dist/packages/string-format/src/lower-case-first.mjs.map +1 -1
  38. package/dist/packages/string-format/src/prepositions.cjs +68 -1
  39. package/dist/packages/string-format/src/prepositions.mjs +67 -1
  40. package/dist/packages/string-format/src/prepositions.mjs.map +1 -1
  41. package/dist/packages/string-format/src/special-cases.cjs +53 -1
  42. package/dist/packages/string-format/src/special-cases.mjs +52 -1
  43. package/dist/packages/string-format/src/special-cases.mjs.map +1 -1
  44. package/dist/packages/string-format/src/title-case.cjs +19 -1
  45. package/dist/packages/string-format/src/title-case.mjs +19 -1
  46. package/dist/packages/string-format/src/title-case.mjs.map +1 -1
  47. package/dist/packages/string-format/src/upper-case-first.cjs +17 -1
  48. package/dist/packages/string-format/src/upper-case-first.mjs +16 -1
  49. package/dist/packages/string-format/src/upper-case-first.mjs.map +1 -1
  50. package/dist/prisma-generator.cjs +185 -8
  51. package/dist/prisma-generator.mjs +184 -8
  52. package/dist/prisma-generator.mjs.map +1 -1
  53. package/dist/project.cjs +15 -1
  54. package/dist/project.mjs +14 -1
  55. package/dist/project.mjs.map +1 -1
  56. package/dist/utils/format-file.cjs +25 -1
  57. package/dist/utils/format-file.mjs +23 -1
  58. package/dist/utils/format-file.mjs.map +1 -1
  59. package/dist/utils/get-jiti.cjs +21 -1
  60. package/dist/utils/get-jiti.mjs +20 -1
  61. package/dist/utils/get-jiti.mjs.map +1 -1
  62. package/dist/utils/get-prisma-internals.cjs +13 -1
  63. package/dist/utils/get-prisma-internals.mjs +12 -1
  64. package/dist/utils/get-prisma-internals.mjs.map +1 -1
  65. package/dist/utils/write-file-safely.cjs +32 -2
  66. package/dist/utils/write-file-safely.mjs +29 -2
  67. package/dist/utils/write-file-safely.mjs.map +1 -1
  68. package/dist/zod/aggregate-helpers.cjs +70 -1
  69. package/dist/zod/aggregate-helpers.mjs +67 -1
  70. package/dist/zod/aggregate-helpers.mjs.map +1 -1
  71. package/dist/zod/comments-helpers.cjs +77 -1
  72. package/dist/zod/comments-helpers.mjs +75 -1
  73. package/dist/zod/comments-helpers.mjs.map +1 -1
  74. package/dist/zod/docs-helpers.cjs +23 -3
  75. package/dist/zod/docs-helpers.mjs +20 -3
  76. package/dist/zod/docs-helpers.mjs.map +1 -1
  77. package/dist/zod/generator-helpers.cjs +34 -1
  78. package/dist/zod/generator-helpers.mjs +31 -1
  79. package/dist/zod/generator-helpers.mjs.map +1 -1
  80. package/dist/zod/helpers.cjs +26 -1
  81. package/dist/zod/helpers.mjs +26 -1
  82. package/dist/zod/helpers.mjs.map +1 -1
  83. package/dist/zod/include-helpers.cjs +69 -1
  84. package/dist/zod/include-helpers.mjs +69 -1
  85. package/dist/zod/include-helpers.mjs.map +1 -1
  86. package/dist/zod/model-helpers.cjs +244 -1
  87. package/dist/zod/model-helpers.mjs +236 -1
  88. package/dist/zod/model-helpers.mjs.map +1 -1
  89. package/dist/zod/modelArgs-helpers.cjs +56 -1
  90. package/dist/zod/modelArgs-helpers.mjs +56 -1
  91. package/dist/zod/modelArgs-helpers.mjs.map +1 -1
  92. package/dist/zod/mongodb-helpers.cjs +49 -1
  93. package/dist/zod/mongodb-helpers.mjs +48 -1
  94. package/dist/zod/mongodb-helpers.mjs.map +1 -1
  95. package/dist/zod/select-helpers.cjs +128 -1
  96. package/dist/zod/select-helpers.mjs +128 -1
  97. package/dist/zod/select-helpers.mjs.map +1 -1
  98. package/dist/zod/transformer.cjs +434 -19
  99. package/dist/zod/transformer.mjs +432 -19
  100. package/dist/zod/transformer.mjs.map +1 -1
  101. package/dist/zod/whereUniqueInput-helpers.cjs +17 -1
  102. package/dist/zod/whereUniqueInput-helpers.mjs +16 -1
  103. package/dist/zod/whereUniqueInput-helpers.mjs.map +1 -1
  104. package/package.json +4 -4
@@ -1,3 +1,23 @@
1
- const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`./model-helpers.cjs`);let n=require(`parenthesis`);n=e.__toESM(n);const r=e=>{let t=[];if(e){let n=e.split(`
2
- `).filter(e=>!e.trimStart().startsWith(`@zod`));n.length&&(t.push(`/**`),n.forEach(e=>t.push(` * ${e}`)),t.push(` */`))}return t},i=e=>e.split(`
3
- `).filter(e=>e.trimStart().startsWith(`@zod`)).map(e=>e.trimStart().slice(4)).flatMap(e=>t.chunk(n.default.parse(e),2).slice(0,-1).map(([e,t])=>`${e.replace(/\)?\./,``)}${n.default.stringify(t)})`));exports.getJSDocs=r,exports.getZodDocElements=i;
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 as e}from"./model-helpers.mjs";import t from"parenthesis";const n=e=>{let t=[];if(e){let n=e.split(`
2
- `).filter(e=>!e.trimStart().startsWith(`@zod`));n.length&&(t.push(`/**`),n.forEach(e=>t.push(` * ${e}`)),t.push(` */`))}return t},r=n=>n.split(`
3
- `).filter(e=>e.trimStart().startsWith(`@zod`)).map(e=>e.trimStart().slice(4)).flatMap(n=>e(t.parse(n),2).slice(0,-1).map(([e,n])=>`${e.replace(/\)?\./,``)}${t.stringify(n)})`));export{n as getJSDocs,r as getZodDocElements};
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":"uEAqBA,MAAa,EAAa,GAAuB,CAC/C,IAAMA,EAAkB,EAAE,CAE1B,GAAI,EAAW,CACb,IAAM,EAAW,EACd,MAAM;EAAK,CACX,OAAO,GAAM,CAAC,EAAG,WAAW,CAAC,WAAW,OAAO,CAAC,CAE/C,EAAS,SACX,EAAM,KAAK,MAAM,CACjB,EAAS,QAAQ,GAAM,EAAM,KAAK,MAAM,IAAK,CAAC,CAC9C,EAAM,KAAK,MAAM,EAIrB,OAAO,GAGI,EAAqB,GAChC,EACG,MAAM;EAAK,CACX,OAAO,GAAQ,EAAK,WAAW,CAAC,WAAW,OAAO,CAAC,CACnD,IAAI,GAAQ,EAAK,WAAW,CAAC,MAAM,EAAE,CAAC,CACtC,QAAQ,GAEP,EAAM,EAAY,MAAM,EAAK,CAAE,EAAE,CAC9B,MAAM,EAAG,GAAG,CACZ,KACE,CAAC,EAAM,KACN,GAAI,EAAgB,QAClB,QACA,GACD,GAAG,EAAY,UAAU,EAAsB,CAAC,GACpD,CACJ"}
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 e=require(`./transformer.cjs`);async function t(t,n){let r=[...t,...n];e.default.enumNames=r.map(e=>e.name)??[],await new e.default({enumTypes:r}).generateEnumSchemas()}async function n(t){for(let n=0;n<t.length;n+=1){let r=t[n]?.fields,i=t[n]?.name;await new e.default({name:i,fields:r}).generateObjectSchema()}}async function r(t,n,r){await new e.default({models:t,modelOperations:n,aggregateOperationSupport:r}).generateModelSchemas()}async function i(){await e.default.generateIndex()}exports.generateZodEnumSchemas=t,exports.generateZodIndex=i,exports.generateZodModelSchemas=r,exports.generateZodObjectSchemas=n;
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 e from"./transformer.mjs";async function t(t,n){let r=[...t,...n];e.enumNames=r.map(e=>e.name)??[],await new e({enumTypes:r}).generateEnumSchemas()}async function n(t){for(let n=0;n<t.length;n+=1){let r=t[n]?.fields,i=t[n]?.name;await new e({name:i,fields:r}).generateObjectSchema()}}async function r(t,n,r){await new e({models:t,modelOperations:n,aggregateOperationSupport:r}).generateModelSchemas()}async function i(){await e.generateIndex()}export{t as generateZodEnumSchemas,i as generateZodIndex,r as generateZodModelSchemas,n as generateZodObjectSchemas};
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":"iCAqBA,eAAsB,EACpB,EACA,EACA,CACA,IAAM,EAAY,CAAC,GAAG,EAAkB,GAAG,EAAgB,CAE3D,EAAY,UADM,EAAU,IAAI,GAAY,EAAS,KAAK,EACrB,EAAE,CAIvC,MAHoB,IAAI,EAAY,CAClC,YACD,CAAC,CACgB,qBAAqB,CAGzC,eAAsB,EACpB,EACA,CACA,IAAK,IAAI,EAAI,EAAG,EAAI,EAAiB,OAAQ,GAAK,EAAG,CACnD,IAAM,EAAS,EAAiB,IAAI,OAC9B,EAAO,EAAiB,IAAI,KAElC,MADoB,IAAI,EAAY,CAAE,OAAM,SAAQ,CAAC,CACnC,sBAAsB,EAI5C,eAAsB,EACpB,EACA,EACA,EACA,CAMA,MALoB,IAAI,EAAY,CAClC,SACA,kBACA,4BACD,CAAC,CACgB,sBAAsB,CAG1C,eAAsB,GAAmB,CACvC,MAAM,EAAY,eAAe"}
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"}
@@ -1 +1,26 @@
1
- const e=require(`./aggregate-helpers.cjs`),t=require(`./mongodb-helpers.cjs`),n=require(`./transformer.cjs`),r=require(`./include-helpers.cjs`),i=require(`./modelArgs-helpers.cjs`),a=require(`./select-helpers.cjs`),o=require(`./whereUniqueInput-helpers.cjs`);function s(s,c,l,u,d,f){d===`mongodb`&&t.addMissingInputObjectTypesForMongoDbRawOpsAndQueries(u,c,s),e.addMissingInputObjectTypesForAggregate(s,c),f.isGenerateSelect&&(a.addMissingInputObjectTypesForSelect(s,c,l),n.default.setIsGenerateSelect(!0)),(f.isGenerateSelect||f.isGenerateInclude)&&i.addMissingInputObjectTypesForModelArgs(s,l,f.isGenerateSelect,f.isGenerateInclude),f.isGenerateInclude&&(r.addMissingInputObjectTypesForInclude(s,l,f.isGenerateSelect),n.default.setIsGenerateInclude(!0)),o.changeOptionalToRequiredFields(s)}exports.addMissingZodInputObjectTypes=s;
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;
@@ -1,2 +1,27 @@
1
- import{addMissingInputObjectTypesForAggregate as e}from"./aggregate-helpers.mjs";import{addMissingInputObjectTypesForMongoDbRawOpsAndQueries as t}from"./mongodb-helpers.mjs";import n from"./transformer.mjs";import{addMissingInputObjectTypesForInclude as r}from"./include-helpers.mjs";import{addMissingInputObjectTypesForModelArgs as i}from"./modelArgs-helpers.mjs";import{addMissingInputObjectTypesForSelect as a}from"./select-helpers.mjs";import{changeOptionalToRequiredFields as o}from"./whereUniqueInput-helpers.mjs";function s(s,c,l,u,d,f){d===`mongodb`&&t(u,c,s),e(s,c),f.isGenerateSelect&&(a(s,c,l),n.setIsGenerateSelect(!0)),(f.isGenerateSelect||f.isGenerateInclude)&&i(s,l,f.isGenerateSelect,f.isGenerateInclude),f.isGenerateInclude&&(r(s,l,f.isGenerateSelect),n.setIsGenerateInclude(!0)),o(s)}export{s as addMissingZodInputObjectTypes};
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
@@ -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":"wgBAgCA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,EACA,CAEI,IAAuB,WACzB,EACE,EACA,EACA,EACD,CAEH,EAAuC,EAAkB,EAAkB,CACvE,EAAQ,mBACV,EACE,EACA,EACA,EACD,CACD,EAAY,oBAAoB,GAAK,GAEnC,EAAQ,kBAAoB,EAAQ,oBACtC,EACE,EACA,EACA,EAAQ,iBACR,EAAQ,kBACT,CAEC,EAAQ,oBACV,EACE,EACA,EACA,EAAQ,iBACT,CACD,EAAY,qBAAqB,GAAK,EAGxC,EACE,EACD"}
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 e=require(`./model-helpers.cjs`);function t(e,t,r){let i=n(t,r);for(let t of i)e.push(t)}function n(t,n){let r=[];for(let i of t){let{name:t,fields:a}=i,o=[];for(let t of a){let{name:n,isList:r,type:i}=t;if(e.checkIsModelRelationField(t)){let e={name:n,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`},{isList:!1,type:r?`${i}FindManyArgs`:`${i}DefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`}]};o.push(e)}}if(!e.checkModelHasModelRelation(i))continue;if(e.checkModelHasManyModelRelation(i)){let e=[{isList:!1,type:`Boolean`,location:`scalar`}];n&&e.push({isList:!1,type:`${t}CountOutputTypeDefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`});let r={name:`_count`,isRequired:!1,isNullable:!1,inputTypes:e};o.push(r)}let s={name:`${t}Include`,constraints:{maxNumFields:null,minNumFields:null},fields:o};r.push(s)}return r}exports.addMissingInputObjectTypesForInclude=t;
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 as e,checkModelHasManyModelRelation as t,checkModelHasModelRelation as n}from"./model-helpers.mjs";function r(e,t,n){let r=i(t,n);for(let t of r)e.push(t)}function i(r,i){let a=[];for(let o of r){let{name:r,fields:s}=o,c=[];for(let t of s){let{name:n,isList:r,type:i}=t;if(e(t)){let e={name:n,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`},{isList:!1,type:r?`${i}FindManyArgs`:`${i}DefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`}]};c.push(e)}}if(!n(o))continue;if(t(o)){let e=[{isList:!1,type:`Boolean`,location:`scalar`}];i&&e.push({isList:!1,type:`${r}CountOutputTypeDefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`});let t={name:`_count`,isRequired:!1,isNullable:!1,inputTypes:e};c.push(t)}let l={name:`${r}Include`,constraints:{maxNumFields:null,minNumFields:null},fields:c};a.push(l)}return a}export{r as addMissingInputObjectTypesForInclude};
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":"oIAyBA,SAAgB,EACd,EACA,EACA,EACA,CAEA,IAAM,EAAmC,EACvC,EACA,EACD,CAED,IAAK,IAAM,KAA0B,EACnC,EAAiB,KAAK,EAAuB,CAIjD,SAAS,EACP,EACA,EACA,CACA,IAAMA,EAAiD,EAAE,CACzD,IAAK,IAAM,KAAS,EAAQ,CAC1B,GAAM,CAAE,KAAM,EAAW,OAAQ,GAAgB,EAC3CC,EAA2B,EAAE,CAEnC,IAAK,IAAM,KAAc,EAAa,CACpC,GAAM,CAAE,KAAM,EAAgB,SAAQ,QAAS,EAI/C,GAFwB,EAA0B,EAAW,CAExC,CACnB,IAAMC,EAAwB,CAC5B,KAAM,EACN,WAAY,GACZ,WAAY,GACZ,WAAY,CACV,CAAE,OAAQ,GAAO,KAAM,UAAW,SAAU,SAAU,CACtD,CACE,OAAQ,GACR,KAAM,EAAS,GAAG,EAAK,cAAgB,GAAG,EAAK,aAC/C,SAAU,mBACV,UAAW,SACZ,CACF,CACF,CACD,EAAO,KAAK,EAAM,EAQtB,GAAI,CAD8B,EAA2B,EAAM,CAEjE,SAMF,GAHsC,EAA+B,EAAM,CAGlD,CACvB,IAAMC,EAAkC,CACtC,CAAE,OAAQ,GAAO,KAAM,UAAW,SAAU,SAAU,CACvD,CACG,GACF,EAAW,KAAK,CACd,OAAQ,GACR,KAAM,GAAG,EAAU,4BACnB,SAAU,mBACV,UAAW,SACZ,CAAC,CAEJ,IAAMC,EAA8B,CAClC,KAAM,SACN,WAAY,GACZ,WAAY,GACZ,aACD,CACD,EAAO,KAAK,EAAY,CAG1B,IAAMC,EAA8C,CAClD,KAAM,GAAG,EAAU,SACnB,YAAa,CACX,aAAc,KACd,aAAc,KACf,CACD,SACD,CACD,EAA6B,KAAK,EAA4B,CAEhE,OAAO"}
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"}