@stryke/prisma-trpc-generator 0.13.37 → 0.13.38
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 +1 -0
- package/dist/_virtual/rolldown_runtime.mjs +1 -0
- package/dist/config.cjs +1 -0
- package/dist/config.mjs +2 -0
- package/dist/config.mjs.map +1 -0
- package/dist/generator.d.cts +1 -2
- package/dist/generator.d.mts +1 -2
- package/dist/helpers.cjs +85 -0
- package/dist/helpers.mjs +86 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/index.cjs +1 -116
- package/dist/index.mjs +1 -116
- package/dist/index.mjs.map +1 -1
- package/dist/packages/env/src/get-env-paths.cjs +1 -0
- package/dist/packages/env/src/get-env-paths.mjs +2 -0
- package/dist/packages/env/src/get-env-paths.mjs.map +1 -0
- package/dist/packages/string-format/src/acronyms.cjs +1 -0
- package/dist/packages/string-format/src/acronyms.mjs +2 -0
- package/dist/packages/string-format/src/acronyms.mjs.map +1 -0
- package/dist/packages/string-format/src/articles.cjs +1 -0
- package/dist/packages/string-format/src/articles.mjs +2 -0
- package/dist/packages/string-format/src/articles.mjs.map +1 -0
- package/dist/packages/string-format/src/combine.cjs +1 -0
- package/dist/packages/string-format/src/combine.mjs +2 -0
- package/dist/packages/string-format/src/combine.mjs.map +1 -0
- package/dist/packages/string-format/src/conjunctions.cjs +1 -0
- package/dist/packages/string-format/src/conjunctions.mjs +2 -0
- package/dist/packages/string-format/src/conjunctions.mjs.map +1 -0
- package/dist/packages/string-format/src/decamelize.cjs +1 -0
- package/dist/packages/string-format/src/decamelize.mjs +2 -0
- package/dist/packages/string-format/src/decamelize.mjs.map +1 -0
- package/dist/packages/string-format/src/format-special-cases.cjs +1 -0
- package/dist/packages/string-format/src/format-special-cases.mjs +2 -0
- package/dist/packages/string-format/src/format-special-cases.mjs.map +1 -0
- package/dist/packages/string-format/src/lower-case-first.cjs +1 -0
- package/dist/packages/string-format/src/lower-case-first.mjs +2 -0
- package/dist/packages/string-format/src/lower-case-first.mjs.map +1 -0
- package/dist/packages/string-format/src/prepositions.cjs +1 -0
- package/dist/packages/string-format/src/prepositions.mjs +2 -0
- package/dist/packages/string-format/src/prepositions.mjs.map +1 -0
- package/dist/packages/string-format/src/special-cases.cjs +1 -0
- package/dist/packages/string-format/src/special-cases.mjs +2 -0
- package/dist/packages/string-format/src/special-cases.mjs.map +1 -0
- package/dist/packages/string-format/src/title-case.cjs +1 -0
- package/dist/packages/string-format/src/title-case.mjs +2 -0
- package/dist/packages/string-format/src/title-case.mjs.map +1 -0
- package/dist/packages/string-format/src/upper-case-first.cjs +1 -0
- package/dist/packages/string-format/src/upper-case-first.mjs +2 -0
- package/dist/packages/string-format/src/upper-case-first.mjs.map +1 -0
- package/dist/prisma-generator.cjs +9 -0
- package/dist/prisma-generator.mjs +10 -0
- package/dist/prisma-generator.mjs.map +1 -0
- package/dist/project.cjs +1 -0
- package/dist/project.mjs +2 -0
- package/dist/project.mjs.map +1 -0
- package/dist/utils/format-file.cjs +1 -0
- package/dist/utils/format-file.mjs +2 -0
- package/dist/utils/format-file.mjs.map +1 -0
- package/dist/utils/get-jiti.cjs +1 -0
- package/dist/utils/get-jiti.mjs +2 -0
- package/dist/utils/get-jiti.mjs.map +1 -0
- package/dist/utils/get-prisma-internals.cjs +1 -0
- package/dist/utils/get-prisma-internals.mjs +2 -0
- package/dist/utils/get-prisma-internals.mjs.map +1 -0
- package/dist/utils/write-file-safely.cjs +2 -0
- package/dist/utils/write-file-safely.mjs +3 -0
- package/dist/utils/write-file-safely.mjs.map +1 -0
- package/dist/zod/aggregate-helpers.cjs +1 -0
- package/dist/zod/aggregate-helpers.mjs +2 -0
- package/dist/zod/aggregate-helpers.mjs.map +1 -0
- package/dist/zod/comments-helpers.cjs +1 -0
- package/dist/zod/comments-helpers.mjs +2 -0
- package/dist/zod/comments-helpers.mjs.map +1 -0
- package/dist/zod/docs-helpers.cjs +3 -0
- package/dist/zod/docs-helpers.mjs +4 -0
- package/dist/zod/docs-helpers.mjs.map +1 -0
- package/dist/zod/generator-helpers.cjs +1 -0
- package/dist/zod/generator-helpers.mjs +2 -0
- package/dist/zod/generator-helpers.mjs.map +1 -0
- package/dist/zod/helpers.cjs +1 -0
- package/dist/zod/helpers.mjs +2 -0
- package/dist/zod/helpers.mjs.map +1 -0
- package/dist/zod/include-helpers.cjs +1 -0
- package/dist/zod/include-helpers.mjs +2 -0
- package/dist/zod/include-helpers.mjs.map +1 -0
- package/dist/zod/model-helpers.cjs +1 -0
- package/dist/zod/model-helpers.mjs +2 -0
- package/dist/zod/model-helpers.mjs.map +1 -0
- package/dist/zod/modelArgs-helpers.cjs +1 -0
- package/dist/zod/modelArgs-helpers.mjs +2 -0
- package/dist/zod/modelArgs-helpers.mjs.map +1 -0
- package/dist/zod/mongodb-helpers.cjs +1 -0
- package/dist/zod/mongodb-helpers.mjs +2 -0
- package/dist/zod/mongodb-helpers.mjs.map +1 -0
- package/dist/zod/select-helpers.cjs +1 -0
- package/dist/zod/select-helpers.mjs +2 -0
- package/dist/zod/select-helpers.mjs.map +1 -0
- package/dist/zod/transformer.cjs +21 -0
- package/dist/zod/transformer.mjs +22 -0
- package/dist/zod/transformer.mjs.map +1 -0
- package/dist/zod/whereUniqueInput-helpers.cjs +1 -0
- package/dist/zod/whereUniqueInput-helpers.mjs +2 -0
- package/dist/zod/whereUniqueInput-helpers.mjs.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=/(?:@@Gen\.)+[A-z]+\(.+\)/,t=/\.+[A-Z]+\(+/i,n=/\(+[A-Z]+:.+\)/i;function r(e,t,n,r,c){e=i(e,r),a(e,r,c),s(e,t),o(n,r)}function i(r,i){return r.map(r=>{if(r.documentation){let a=r.documentation?.match(e)?.[0];if(a?.match(t)?.[0]?.slice(1,-1)!==`model`)return r;let o=a?.match(n)?.[0]?.slice(1,-1),s={};if(o){let e=o.split(`:`).map(e=>e.trim()).map(e=>e.startsWith(`[`)?e:e.split(`,`)).flat().map(e=>e.trim());for(let t=0;t<e.length;t+=2){let n=e[t],r=e[t+1];s[n]=JSON.parse(r)}}if(s.hide)return i.push(r.name),null}return r}).filter(Boolean)}function a(e,t,n){e.forEach(e=>{e.fields.forEach(e=>{t.includes(e.type)&&(n.push(e.name),e.relationFromFields&&e.relationFromFields.forEach(e=>n.push(e)))})})}function o(e,t){e.prisma=e.prisma.filter(e=>!t.find(t=>e.name.startsWith(t)))}function s(e,t){let n=t.length;for(;n>=0;){--n;let r=t[n];r&&!e.find(e=>e.name===r.model)&&t.splice(n,1)}}function c(e,t,n){let r=e.length;for(;r>=0;){--r;let i=e[r];if(i&&(t.includes(i?.meta?.source)||t.find(e=>i.name.startsWith(e))))e.splice(r,1);else{let t=i?.fields?.length??0;for(;t>=0;){--t;let a=i?.fields?.[t];a&&n.includes(a.name)&&e[r].fields.slice(t,1)}}}}export{c as hideZodInputObjectTypesAndRelatedFields,r as resolveZodModelsComments};
|
|
2
|
+
//# sourceMappingURL=comments-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments-helpers.mjs","names":["parsedAttributeArgs: Record<string, unknown>"],"sources":["../../src/zod/comments-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\";\n\n// eslint-disable-next-line regexp/no-obscure-range\nconst modelAttributeRegex = /(?:@@Gen\\.)+[A-z]+\\(.+\\)/;\nconst attributeNameRegex = /\\.+[A-Z]+\\(+/i;\nconst attributeArgsRegex = /\\(+[A-Z]+:.+\\)/i;\n\nexport function resolveZodModelsComments(\n models: DMMF.Model[],\n modelOperations: DMMF.ModelMapping[],\n enumTypes: { model?: DMMF.SchemaEnum[]; prisma: DMMF.SchemaEnum[] },\n hiddenModels: string[],\n hiddenFields: string[]\n) {\n models = collectHiddenModels(models, hiddenModels);\n collectHiddenFields(models, hiddenModels, hiddenFields);\n hideModelOperations(models, modelOperations);\n hideEnums(enumTypes, hiddenModels);\n}\n\nfunction collectHiddenModels(models: DMMF.Model[], hiddenModels: string[]) {\n return models\n .map(model => {\n if (model.documentation) {\n const attribute = model.documentation?.match(modelAttributeRegex)?.[0];\n const attributeName = attribute\n ?.match(attributeNameRegex)?.[0]\n ?.slice(1, -1);\n if (attributeName !== \"model\") {\n return model;\n }\n\n const rawAttributeArgs = attribute\n ?.match(attributeArgsRegex)?.[0]\n ?.slice(1, -1);\n\n const parsedAttributeArgs: Record<string, unknown> = {};\n if (rawAttributeArgs) {\n const rawAttributeArgsParts = rawAttributeArgs\n .split(\":\")\n .map(it => it.trim())\n .map(part => (part.startsWith(\"[\") ? part : part.split(\",\")))\n .flat()\n .map(it => it.trim());\n\n for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {\n const key = rawAttributeArgsParts[i];\n const value = rawAttributeArgsParts[i + 1];\n parsedAttributeArgs[key!] = JSON.parse(value!);\n }\n }\n if (parsedAttributeArgs.hide) {\n hiddenModels.push(model.name);\n return null as unknown as DMMF.Model;\n }\n }\n\n return model;\n })\n .filter(Boolean);\n}\n\nfunction collectHiddenFields(\n models: DMMF.Model[],\n hiddenModels: string[],\n hiddenFields: string[]\n) {\n models.forEach(model => {\n model.fields.forEach(field => {\n if (hiddenModels.includes(field.type)) {\n hiddenFields.push(field.name);\n if (field.relationFromFields) {\n field.relationFromFields.forEach(item => hiddenFields.push(item));\n }\n }\n });\n });\n}\nfunction hideEnums(\n enumTypes: { model?: DMMF.SchemaEnum[]; prisma: DMMF.SchemaEnum[] },\n hiddenModels: string[]\n) {\n enumTypes.prisma = enumTypes.prisma.filter(\n item => !hiddenModels.find(model => item.name.startsWith(model))\n );\n}\n\nfunction hideModelOperations(\n models: DMMF.Model[],\n modelOperations: DMMF.ModelMapping[]\n) {\n let i = modelOperations.length;\n while (i >= 0) {\n --i;\n const modelOperation = modelOperations[i];\n if (\n modelOperation &&\n !models.find(model => {\n return model.name === modelOperation.model;\n })\n ) {\n modelOperations.splice(i, 1);\n }\n }\n}\n\nexport function hideZodInputObjectTypesAndRelatedFields(\n inputObjectTypes: DMMF.InputType[],\n hiddenModels: string[],\n hiddenFields: string[]\n) {\n let j = inputObjectTypes.length;\n while (j >= 0) {\n --j;\n const inputType = inputObjectTypes[j];\n if (\n inputType &&\n (hiddenModels.includes(inputType?.meta?.source as string) ||\n hiddenModels.find(model => inputType.name.startsWith(model)))\n ) {\n inputObjectTypes.splice(j, 1);\n } else {\n let k = inputType?.fields?.length ?? 0;\n while (k >= 0) {\n --k;\n const field = inputType?.fields?.[k];\n if (field && hiddenFields.includes(field.name)) {\n inputObjectTypes[j]!.fields.slice(k, 1);\n }\n }\n }\n }\n}\n"],"mappings":"AAoBA,MAAM,EAAsB,2BACtB,EAAqB,gBACrB,EAAqB,kBAE3B,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,CACA,EAAS,EAAoB,EAAQ,EAAa,CAClD,EAAoB,EAAQ,EAAc,EAAa,CACvD,EAAoB,EAAQ,EAAgB,CAC5C,EAAU,EAAW,EAAa,CAGpC,SAAS,EAAoB,EAAsB,EAAwB,CACzE,OAAO,EACJ,IAAI,GAAS,CACZ,GAAI,EAAM,cAAe,CACvB,IAAM,EAAY,EAAM,eAAe,MAAM,EAAoB,GAAG,GAIpE,GAHsB,GAClB,MAAM,EAAmB,GAAG,IAC5B,MAAM,EAAG,GAAG,GACM,QACpB,OAAO,EAGT,IAAM,EAAmB,GACrB,MAAM,EAAmB,GAAG,IAC5B,MAAM,EAAG,GAAG,CAEVA,EAA+C,E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WAAW,EAAM,CAAC,EAE9D,EAAiB,OAAO,EAAG,EAAE,KACxB,CACL,IAAI,EAAI,GAAW,QAAQ,QAAU,EACrC,KAAO,GAAK,GAAG,CACb,EAAE,EACF,IAAM,EAAQ,GAAW,SAAS,GAC9B,GAAS,EAAa,SAAS,EAAM,KAAK,EAC5C,EAAiB,GAAI,OAAO,MAAM,EAAG,EAAE"}
|
|
@@ -0,0 +1,3 @@
|
|
|
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;
|
|
@@ -0,0 +1,4 @@
|
|
|
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};
|
|
4
|
+
//# sourceMappingURL=docs-helpers.mjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
2
|
+
//# sourceMappingURL=generator-helpers.mjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
2
|
+
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
2
|
+
//# sourceMappingURL=include-helpers.mjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../packages/string-format/src/lower-case-first.cjs`),n=require(`../utils/get-prisma-internals.cjs`),r=require(`./docs-helpers.cjs`);let i=require(`node:path`);i=e.__toESM(i);let a=require(`ts-morph`);function o(e){let{fields:t}=e;for(let e of t)if(c(e))return!0;return!1}function s(e){let{fields:t}=e;for(let e of t)if(l(e))return!0;return!1}function c(e){let{kind:t,relationName:n}=e;return t===`object`&&!!n}function l(e){return c(e)&&e.isList}function u(e,t){return e.find(({name:e})=>e===t)}const d=(e,t,n=!0)=>t.forEach(t=>e.write(t).conditionalNewLine(n)),f=({modelCase:e,modelSuffix:t,relationModel:n})=>{let r=(n,r=``)=>(e===`camelCase`&&(n=n.slice(0,1).toLowerCase()+n.slice(1)),`${r}${n}${t}`);return{modelName:e=>r(e,n===`default`?`_`:``),relatedModelName:e=>r(n===`default`?e.toString():`Related${e.toString()}`)}},p=e=>{let t=e.replace(/^\\\\\?\\/,``).replace(/\\/g,`/`).replace(/\/{2,}/g,`/`);return t.includes(`/node_modules/`)?t.split(`/node_modules/`).slice(-1)[0]:t.startsWith(`../`)?t:`./${t}`},m=(e,t)=>e.reduce((e,n,r)=>r%t===0?[...e,[n]]:[...e.slice(0,-1),[...e.slice(-1)[0],n]],[]),h=(e,t)=>e.fields.some(e=>e.kind===`object`)&&t.relationModel!==!1,g=async(e,t,r,o)=>{let s=(await n.getPrismaInternals()).parseEnvValue(o.generator.output),{relatedModelName:c}=f(r),l=[{kind:a.StructureKind.ImportDeclaration,namespaceImport:`z`,moduleSpecifier:`zod`}];r.imports&&l.push({kind:a.StructureKind.ImportDeclaration,namespaceImport:`imports`,moduleSpecifier:p(i.default.relative(s,i.default.resolve(i.default.dirname(o.schemaPath),r.imports)))}),r.useDecimalJs&&e.fields.some(e=>e.type===`Decimal`)&&l.push({kind:a.StructureKind.ImportDeclaration,namedImports:[`Decimal`],moduleSpecifier:`decimal.js`});let u=e.fields.filter(e=>e.kind===`enum`),d=e.fields.filter(e=>e.kind===`object`),m=o.otherGenerators.find(e=>e.provider.value===`prisma-client-js`).output.value,h=i.default.relative(s,m);if(u.length>0&&l.push({kind:a.StructureKind.ImportDeclaration,isTypeOnly:u.length===0,moduleSpecifier:p(h),namedImports:u.map(e=>e.type)}),r.relationModel!==!1&&d.length>0){let t=d.filter(t=>t.type!==e.name);t.length>0&&l.push({kind:a.StructureKind.ImportDeclaration,moduleSpecifier:`./index`,namedImports:Array.from(new Set(t.flatMap(e=>[`${e.type}`,c(e.type)])))})}t.addImportDeclarations(l)},_=e=>r.getZodDocElements(e).find(e=>e.startsWith(`custom(`))?.slice(7).slice(0,-1),v=e=>r.getZodDocElements(e).filter(e=>!e.startsWith(`custom(`)),y=(e,t=e=>e.toString())=>{let n=`z.unknown()`,r=[``];if(e.kind===`scalar`)switch(e.type){case`String`:n=`z.string()`;break;case`Int`:n=`z.number()`,r.push(`int()`);break;case`BigInt`:n=`z.bigint()`;break;case`DateTime`:n=`z.date()`;break;case`Float`:n=`z.number()`;break;case`Decimal`:n=`z.number()`;break;case`Json`:n=`jsonSchema`;break;case`Boolean`:n=`z.boolean()`;break;case`Bytes`:n=`z.unknown()`;break}else e.kind===`enum`?n=`z.nativeEnum(${e.type})`:e.kind===`object`&&(n=t(e.type));return e.isList&&r.push(`array()`),e.documentation&&(n=_(e.documentation)??n,r.push(...v(e.documentation))),!e.isRequired&&e.type!==`Json`&&r.push(`nullish()`),`${n}${r.join(`.`)}`},b=(e,t,n)=>{e.fields.some(e=>e.type===`Json`)&&t.addStatements(e=>{e.newLine(),d(e,[`// Helper schema for JSON fields`,`type Literal = boolean | number | string${n.prismaJsonNullability?``:`| null`}`,`type Json = Literal | { [key: string]: Json } | Json[]`,`const literalSchema = z.union([z.string(), z.number(), z.boolean()${n.prismaJsonNullability?``:`, z.null()`}])`,`const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))`])}),n.useDecimalJs&&e.fields.some(e=>e.type===`Decimal`)&&t.addStatements(e=>{e.newLine(),d(e,[`// Helper schema for Decimal fields`,`z`,`.instanceof(Decimal)`,`.or(z.string())`,`.or(z.number())`,`.refine((value) => {`,` try {`,` return new Decimal(value);`,` } catch (error) {`,` return false;`,` }`,`})`,`.transform((value) => new Decimal(value));`])})},x=(e,t,n)=>{let{modelName:i}=f(n);t.addVariableStatement({declarationKind:a.VariableDeclarationKind.Const,isExported:!0,leadingTrivia:e=>e.blankLineIfLastNot(),declarations:[{name:i(e.name),initializer(t){t.write(`z.object(`).inlineBlock(()=>{e.fields.filter(e=>e.kind!==`object`).forEach(e=>{d(t,r.getJSDocs(e.documentation)),t.write(`${e.name}: ${y(e)}`).write(`,`).newLine()})}).write(`)`)}}]})},S=(e,t,n)=>{let{modelName:i,relatedModelName:o}=f(n),s=e.fields.filter(e=>e.kind===`object`);t.addInterface({name:`${e.name}`,isExported:!0,extends:[`z.infer<typeof ${i(e.name)}>`],properties:s.map(e=>({hasQuestionToken:!e.isRequired,name:e.name,type:`${e.type}${e.isList?`[]`:``}${e.isRequired?``:` | null`}`}))}),t.addStatements(t=>d(t,[``,`/**`,` * ${o(e.name)} contains all relations on your model in addition to the scalars`,` *`,` * NOTE: Lazy required in case of potential circular dependencies within schema`,` */`])),t.addVariableStatement({declarationKind:a.VariableDeclarationKind.Const,isExported:!0,declarations:[{name:o(e.name),type:`z.ZodSchema<${e.name}>`,initializer(t){t.write(`z.lazy(() => ${i(e.name)}.extend(`).inlineBlock(()=>{s.forEach(e=>{d(t,r.getJSDocs(e.documentation)),t.write(`${e.name}: ${y(e,o)}`).write(`,`).newLine()})}).write(`))`)}}]})},C=async(e,t,n,r)=>{await g(e,t,n,r),b(e,t,n),x(e,t,n),h(e,n)&&S(e,t,n)},w=(e,n)=>{e.forEach(e=>n.addExportDeclaration({moduleSpecifier:`./${t.lowerCaseFirst(e.name)}.schema`}))};exports.checkIsModelRelationField=c,exports.checkModelHasManyModelRelation=s,exports.checkModelHasModelRelation=o,exports.chunk=m,exports.findModelByName=u,exports.generateBarrelFile=w,exports.populateModelFile=C;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{lowerCaseFirst as e}from"../packages/string-format/src/lower-case-first.mjs";import{getPrismaInternals as t}from"../utils/get-prisma-internals.mjs";import{getJSDocs as n,getZodDocElements as r}from"./docs-helpers.mjs";import i from"node:path";import{StructureKind as a,VariableDeclarationKind as o}from"ts-morph";function s(e){let{fields:t}=e;for(let e of t)if(l(e))return!0;return!1}function c(e){let{fields:t}=e;for(let e of t)if(u(e))return!0;return!1}function l(e){let{kind:t,relationName:n}=e;return t===`object`&&!!n}function u(e){return l(e)&&e.isList}function d(e,t){return e.find(({name:e})=>e===t)}const f=(e,t,n=!0)=>t.forEach(t=>e.write(t).conditionalNewLine(n)),p=({modelCase:e,modelSuffix:t,relationModel:n})=>{let r=(n,r=``)=>(e===`camelCase`&&(n=n.slice(0,1).toLowerCase()+n.slice(1)),`${r}${n}${t}`);return{modelName:e=>r(e,n===`default`?`_`:``),relatedModelName:e=>r(n===`default`?e.toString():`Related${e.toString()}`)}},m=e=>{let t=e.replace(/^\\\\\?\\/,``).replace(/\\/g,`/`).replace(/\/{2,}/g,`/`);return t.includes(`/node_modules/`)?t.split(`/node_modules/`).slice(-1)[0]:t.startsWith(`../`)?t:`./${t}`},h=(e,t)=>e.reduce((e,n,r)=>r%t===0?[...e,[n]]:[...e.slice(0,-1),[...e.slice(-1)[0],n]],[]),g=(e,t)=>e.fields.some(e=>e.kind===`object`)&&t.relationModel!==!1,_=async(e,n,r,o)=>{let s=(await t()).parseEnvValue(o.generator.output),{relatedModelName:c}=p(r),l=[{kind:a.ImportDeclaration,namespaceImport:`z`,moduleSpecifier:`zod`}];r.imports&&l.push({kind:a.ImportDeclaration,namespaceImport:`imports`,moduleSpecifier:m(i.relative(s,i.resolve(i.dirname(o.schemaPath),r.imports)))}),r.useDecimalJs&&e.fields.some(e=>e.type===`Decimal`)&&l.push({kind:a.ImportDeclaration,namedImports:[`Decimal`],moduleSpecifier:`decimal.js`});let u=e.fields.filter(e=>e.kind===`enum`),d=e.fields.filter(e=>e.kind===`object`),f=o.otherGenerators.find(e=>e.provider.value===`prisma-client-js`).output.value,h=i.relative(s,f);if(u.length>0&&l.push({kind:a.ImportDeclaration,isTypeOnly:u.length===0,moduleSpecifier:m(h),namedImports:u.map(e=>e.type)}),r.relationModel!==!1&&d.length>0){let t=d.filter(t=>t.type!==e.name);t.length>0&&l.push({kind:a.ImportDeclaration,moduleSpecifier:`./index`,namedImports:Array.from(new Set(t.flatMap(e=>[`${e.type}`,c(e.type)])))})}n.addImportDeclarations(l)},v=e=>r(e).find(e=>e.startsWith(`custom(`))?.slice(7).slice(0,-1),y=e=>r(e).filter(e=>!e.startsWith(`custom(`)),b=(e,t=e=>e.toString())=>{let n=`z.unknown()`,r=[``];if(e.kind===`scalar`)switch(e.type){case`String`:n=`z.string()`;break;case`Int`:n=`z.number()`,r.push(`int()`);break;case`BigInt`:n=`z.bigint()`;break;case`DateTime`:n=`z.date()`;break;case`Float`:n=`z.number()`;break;case`Decimal`:n=`z.number()`;break;case`Json`:n=`jsonSchema`;break;case`Boolean`:n=`z.boolean()`;break;case`Bytes`:n=`z.unknown()`;break}else e.kind===`enum`?n=`z.nativeEnum(${e.type})`:e.kind===`object`&&(n=t(e.type));return e.isList&&r.push(`array()`),e.documentation&&(n=v(e.documentation)??n,r.push(...y(e.documentation))),!e.isRequired&&e.type!==`Json`&&r.push(`nullish()`),`${n}${r.join(`.`)}`},x=(e,t,n)=>{e.fields.some(e=>e.type===`Json`)&&t.addStatements(e=>{e.newLine(),f(e,[`// Helper schema for JSON fields`,`type Literal = boolean | number | string${n.prismaJsonNullability?``:`| null`}`,`type Json = Literal | { [key: string]: Json } | Json[]`,`const literalSchema = z.union([z.string(), z.number(), z.boolean()${n.prismaJsonNullability?``:`, z.null()`}])`,`const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))`])}),n.useDecimalJs&&e.fields.some(e=>e.type===`Decimal`)&&t.addStatements(e=>{e.newLine(),f(e,[`// Helper schema for Decimal fields`,`z`,`.instanceof(Decimal)`,`.or(z.string())`,`.or(z.number())`,`.refine((value) => {`,` try {`,` return new Decimal(value);`,` } catch (error) {`,` return false;`,` }`,`})`,`.transform((value) => new Decimal(value));`])})},S=(e,t,r)=>{let{modelName:i}=p(r);t.addVariableStatement({declarationKind:o.Const,isExported:!0,leadingTrivia:e=>e.blankLineIfLastNot(),declarations:[{name:i(e.name),initializer(t){t.write(`z.object(`).inlineBlock(()=>{e.fields.filter(e=>e.kind!==`object`).forEach(e=>{f(t,n(e.documentation)),t.write(`${e.name}: ${b(e)}`).write(`,`).newLine()})}).write(`)`)}}]})},C=(e,t,r)=>{let{modelName:i,relatedModelName:a}=p(r),s=e.fields.filter(e=>e.kind===`object`);t.addInterface({name:`${e.name}`,isExported:!0,extends:[`z.infer<typeof ${i(e.name)}>`],properties:s.map(e=>({hasQuestionToken:!e.isRequired,name:e.name,type:`${e.type}${e.isList?`[]`:``}${e.isRequired?``:` | null`}`}))}),t.addStatements(t=>f(t,[``,`/**`,` * ${a(e.name)} contains all relations on your model in addition to the scalars`,` *`,` * NOTE: Lazy required in case of potential circular dependencies within schema`,` */`])),t.addVariableStatement({declarationKind:o.Const,isExported:!0,declarations:[{name:a(e.name),type:`z.ZodSchema<${e.name}>`,initializer(t){t.write(`z.lazy(() => ${i(e.name)}.extend(`).inlineBlock(()=>{s.forEach(e=>{f(t,n(e.documentation)),t.write(`${e.name}: ${b(e,a)}`).write(`,`).newLine()})}).write(`))`)}}]})},w=async(e,t,n,r)=>{await _(e,t,n,r),x(e,t,n),S(e,t,n),g(e,n)&&C(e,t,n)},T=(t,n)=>{t.forEach(t=>n.addExportDeclaration({moduleSpecifier:`./${e(t.name)}.schema`}))};export{l as checkIsModelRelationField,c as checkModelHasManyModelRelation,s as checkModelHasModelRelation,h as chunk,d as findModelByName,T as generateBarrelFile,w as populateModelFile};
|
|
2
|
+
//# sourceMappingURL=model-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-helpers.mjs","names":["importList: ImportDeclarationStructure[]","extraModifiers: string[]"],"sources":["../../src/zod/model-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 {\n DMMF,\n EnvValue,\n GeneratorOptions\n} from \"@prisma/generator-helper\";\nimport { lowerCaseFirst } from \"@stryke/string-format/lower-case-first\";\nimport path from \"node:path\";\nimport type {\n CodeBlockWriter,\n ImportDeclarationStructure,\n SourceFile\n} from \"ts-morph\";\nimport { StructureKind, VariableDeclarationKind } from \"ts-morph\";\nimport type { Config } from \"../config\";\nimport { getPrismaInternals } from \"../utils/get-prisma-internals\";\nimport { getJSDocs, getZodDocElements } from \"./docs-helpers\";\n\nexport function checkModelHasModelRelation(model: DMMF.Model) {\n const { fields: modelFields } = model;\n for (const modelField of modelFields) {\n const isRelationField = checkIsModelRelationField(modelField);\n if (isRelationField) {\n return true;\n }\n }\n return false;\n}\n\nexport function checkModelHasManyModelRelation(model: DMMF.Model) {\n const { fields: modelFields } = model;\n for (const modelField of modelFields) {\n const isManyRelationField = checkIsManyModelRelationField(modelField);\n if (isManyRelationField) {\n return true;\n }\n }\n return false;\n}\n\nexport function checkIsModelRelationField(modelField: DMMF.Field) {\n const { kind, relationName } = modelField;\n\n return kind === \"object\" && !!relationName;\n}\n\nexport function checkIsManyModelRelationField(modelField: DMMF.Field) {\n return checkIsModelRelationField(modelField) && modelField.isList;\n}\n\nexport function findModelByName(models: DMMF.Model[], modelName: string) {\n return models.find(({ name }) => name === modelName);\n}\n\nexport const writeArray = (\n writer: CodeBlockWriter,\n array: string[],\n newLine = true\n) => array.forEach(line => writer.write(line).conditionalNewLine(newLine));\n\nexport const useModelNames = ({\n modelCase,\n modelSuffix,\n relationModel\n}: Config) => {\n const formatModelName = (name: string, prefix = \"\") => {\n if (modelCase === \"camelCase\") {\n name = name.slice(0, 1).toLowerCase() + name.slice(1);\n }\n return `${prefix}${name}${modelSuffix}`;\n };\n\n return {\n modelName: (name: string) =>\n formatModelName(name, relationModel === \"default\" ? \"_\" : \"\"),\n relatedModelName: (\n name: string | DMMF.SchemaEnum | DMMF.OutputType | DMMF.SchemaArg\n ) =>\n formatModelName(\n relationModel === \"default\"\n ? name.toString()\n : `Related${name.toString()}`\n )\n };\n};\n\nexport const dotSlash = (input: string) => {\n const converted = input\n .replace(/^\\\\\\\\\\?\\\\/, \"\")\n .replace(/\\\\/g, \"/\")\n .replace(/\\/{2,}/g, \"/\");\n\n if (converted.includes(`/node_modules/`))\n return converted.split(`/node_modules/`).slice(-1)[0];\n\n if (converted.startsWith(`../`)) return converted;\n\n return `./${converted}`;\n};\n\nexport const chunk = <T extends any[]>(input: T, size: number): T[] => {\n return input.reduce((arr, item, idx) => {\n return idx % size === 0\n ? [...arr, [item]]\n : [...(arr as T).slice(0, -1), [...(arr as T).slice(-1)[0], item]];\n }, []);\n};\n\nexport const needsRelatedModel = (model: DMMF.Model, config: Config) =>\n model.fields.some(field => field.kind === \"object\") &&\n config.relationModel !== false;\n\nexport const writeImportsForModel = async (\n model: DMMF.Model,\n sourceFile: SourceFile,\n config: Config,\n options: GeneratorOptions\n) => {\n const internals = await getPrismaInternals();\n\n const outputPath = internals.parseEnvValue(\n options.generator.output as EnvValue\n );\n\n const { relatedModelName } = useModelNames(config);\n const importList: ImportDeclarationStructure[] = [\n {\n kind: StructureKind.ImportDeclaration,\n namespaceImport: \"z\",\n moduleSpecifier: \"zod\"\n }\n ];\n\n if (config.imports) {\n importList.push({\n kind: StructureKind.ImportDeclaration,\n namespaceImport: \"imports\",\n moduleSpecifier: dotSlash(\n path.relative(\n outputPath,\n path.resolve(path.dirname(options.schemaPath), config.imports)\n )\n )!\n });\n }\n\n if (config.useDecimalJs && model.fields.some(f => f.type === \"Decimal\")) {\n importList.push({\n kind: StructureKind.ImportDeclaration,\n namedImports: [\"Decimal\"],\n moduleSpecifier: \"decimal.js\"\n });\n }\n\n const enumFields = model.fields.filter(f => f.kind === \"enum\");\n const relationFields = model.fields.filter(f => f.kind === \"object\");\n\n const clientPath = options.otherGenerators.find(\n each => each.provider.value === \"prisma-client-js\"\n )!.output!.value!;\n\n const relativePath = path.relative(outputPath, clientPath);\n\n if (enumFields.length > 0) {\n importList.push({\n kind: StructureKind.ImportDeclaration,\n isTypeOnly: enumFields.length === 0,\n moduleSpecifier: dotSlash(relativePath)!,\n namedImports: enumFields.map(f => f.type)\n });\n }\n\n if (config.relationModel !== false && relationFields.length > 0) {\n const filteredFields = relationFields.filter(f => f.type !== model.name);\n\n if (filteredFields.length > 0) {\n importList.push({\n kind: StructureKind.ImportDeclaration,\n moduleSpecifier: \"./index\",\n namedImports: Array.from(\n new Set(\n filteredFields.flatMap(f => [`${f.type}`, relatedModelName(f.type)])\n )\n )\n });\n }\n }\n\n sourceFile.addImportDeclarations(importList);\n};\n\nexport const computeCustomSchema = (docString: string) => {\n return getZodDocElements(docString)\n .find(modifier => modifier.startsWith(\"custom(\"))\n ?.slice(7)\n .slice(0, -1);\n};\n\nexport const computeModifiers = (docString: string) => {\n return getZodDocElements(docString).filter(\n each => !each.startsWith(\"custom(\")\n );\n};\n\nexport const getZodConstructor = (\n field: DMMF.Field,\n getRelatedModelName = (\n name: string | DMMF.SchemaEnum | DMMF.OutputType | DMMF.SchemaArg\n ) => name.toString()\n) => {\n let zodType = \"z.unknown()\";\n const extraModifiers: string[] = [\"\"];\n if (field.kind === \"scalar\") {\n switch (field.type) {\n case \"String\":\n zodType = \"z.string()\";\n break;\n case \"Int\":\n zodType = \"z.number()\";\n extraModifiers.push(\"int()\");\n break;\n case \"BigInt\":\n zodType = \"z.bigint()\";\n break;\n case \"DateTime\":\n zodType = \"z.date()\";\n break;\n case \"Float\":\n zodType = \"z.number()\";\n break;\n case \"Decimal\":\n zodType = \"z.number()\";\n break;\n case \"Json\":\n zodType = \"jsonSchema\";\n break;\n case \"Boolean\":\n zodType = \"z.boolean()\";\n break;\n // TODO: Proper type for bytes fields\n case \"Bytes\":\n zodType = \"z.unknown()\";\n break;\n }\n } else if (field.kind === \"enum\") {\n zodType = `z.nativeEnum(${field.type})`;\n } else if (field.kind === \"object\") {\n zodType = getRelatedModelName(field.type);\n }\n\n if (field.isList) extraModifiers.push(\"array()\");\n if (field.documentation) {\n zodType = computeCustomSchema(field.documentation) ?? zodType;\n extraModifiers.push(...computeModifiers(field.documentation));\n }\n if (!field.isRequired && field.type !== \"Json\")\n extraModifiers.push(\"nullish()\");\n // if (field.hasDefaultValue) extraModifiers.push('optional()')\n\n return `${zodType}${extraModifiers.join(\".\")}`;\n};\n\nexport const writeTypeSpecificSchemas = (\n model: DMMF.Model,\n sourceFile: SourceFile,\n config: Config\n) => {\n if (model.fields.some(f => f.type === \"Json\")) {\n sourceFile.addStatements(writer => {\n writer.newLine();\n writeArray(writer, [\n \"// Helper schema for JSON fields\",\n `type Literal = boolean | number | string${\n config.prismaJsonNullability ? \"\" : \"| null\"\n }`,\n \"type Json = Literal | { [key: string]: Json } | Json[]\",\n `const literalSchema = z.union([z.string(), z.number(), z.boolean()${\n config.prismaJsonNullability ? \"\" : \", z.null()\"\n }])`,\n \"const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))\"\n ]);\n });\n }\n\n if (config.useDecimalJs && model.fields.some(f => f.type === \"Decimal\")) {\n sourceFile.addStatements(writer => {\n writer.newLine();\n writeArray(writer, [\n \"// Helper schema for Decimal fields\",\n \"z\",\n \".instanceof(Decimal)\",\n \".or(z.string())\",\n \".or(z.number())\",\n \".refine((value) => {\",\n \" try {\",\n \" return new Decimal(value);\",\n \" } catch (error) {\",\n \" return false;\",\n \" }\",\n \"})\",\n \".transform((value) => new Decimal(value));\"\n ]);\n });\n }\n};\n\nexport const generateSchemaForModel = (\n model: DMMF.Model,\n sourceFile: SourceFile,\n config: Config\n) => {\n const { modelName } = useModelNames(config);\n\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n leadingTrivia: writer => writer.blankLineIfLastNot(),\n declarations: [\n {\n name: modelName(model.name),\n initializer(writer) {\n writer\n .write(\"z.object(\")\n .inlineBlock(() => {\n model.fields\n .filter(f => f.kind !== \"object\")\n .forEach(field => {\n writeArray(writer, getJSDocs(field.documentation));\n writer\n .write(`${field.name}: ${getZodConstructor(field)}`)\n .write(\",\")\n .newLine();\n });\n })\n .write(\")\");\n }\n }\n ]\n });\n};\n\nexport const generateRelatedSchemaForModel = (\n model: DMMF.Model,\n sourceFile: SourceFile,\n config: Config\n) => {\n const { modelName, relatedModelName } = useModelNames(config);\n\n const relationFields = model.fields.filter(f => f.kind === \"object\");\n\n sourceFile.addInterface({\n name: `${model.name}`,\n isExported: true,\n extends: [`z.infer<typeof ${modelName(model.name)}>`],\n properties: relationFields.map(f => ({\n hasQuestionToken: !f.isRequired,\n name: f.name,\n type: `${f.type}${f.isList ? \"[]\" : \"\"}${!f.isRequired ? \" | null\" : \"\"}`\n }))\n });\n\n sourceFile.addStatements(writer =>\n writeArray(writer, [\n \"\",\n \"/**\",\n ` * ${relatedModelName(\n model.name\n )} contains all relations on your model in addition to the scalars`,\n \" *\",\n \" * NOTE: Lazy required in case of potential circular dependencies within schema\",\n \" */\"\n ])\n );\n\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: relatedModelName(model.name),\n type: `z.ZodSchema<${model.name}>`,\n initializer(writer) {\n writer\n .write(`z.lazy(() => ${modelName(model.name)}.extend(`)\n .inlineBlock(() => {\n relationFields.forEach(field => {\n writeArray(writer, getJSDocs(field.documentation));\n\n writer\n .write(\n `${field.name}: ${getZodConstructor(\n field,\n relatedModelName\n )}`\n )\n .write(\",\")\n .newLine();\n });\n })\n .write(\"))\");\n }\n }\n ]\n });\n};\n\nexport const populateModelFile = async (\n model: DMMF.Model,\n sourceFile: SourceFile,\n config: Config,\n options: GeneratorOptions\n) => {\n await writeImportsForModel(model, sourceFile, config, options);\n writeTypeSpecificSchemas(model, sourceFile, config);\n generateSchemaForModel(model, sourceFile, config);\n if (needsRelatedModel(model, config))\n generateRelatedSchemaForModel(model, sourceFile, config);\n};\n\nexport const generateBarrelFile = (\n models: DMMF.Model[],\n indexFile: SourceFile\n) => {\n models.forEach(model =>\n indexFile.addExportDeclaration({\n moduleSpecifier: `./${lowerCaseFirst(model.name)}.schema`\n })\n );\n};\n"],"mappings":"gUAkCA,SAAgB,EAA2B,EAAmB,CAC5D,GAAM,CAAE,OAAQ,GAAgB,EAChC,IAAK,IAAM,KAAc,EAEvB,GADw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AG,EAAE,OAAO,EAAE,OAAS,KAAO,KAAM,EAAE,WAAyB,GAAZ,YAC1D,EAAE,CACJ,CAAC,CAEF,EAAW,cAAc,GACvB,EAAW,EAAQ,CACjB,GACA,MACA,MAAM,EACJ,EAAM,KACP,CAAC,kEACF,KACA,kFACA,MACD,CAAC,CACH,CAED,EAAW,qBAAqB,CAC9B,gBAAiB,EAAwB,MACzC,WAAY,GACZ,aAAc,CACZ,CACE,KAAM,EAAiB,EAAM,KAAK,CAClC,KAAM,eAAe,EAAM,KAAK,GAChC,YAAY,EAAQ,CAClB,EACG,MAAM,gBAAgB,EAAU,EAAM,KAAK,CAAC,UAAU,CACtD,gBAAkB,CACjB,EAAe,QAAQ,GAAS,CAC9B,EAAW,EAAQ,EAAU,EAAM,cAAc,CAAC,CAElD,EACG,MACC,GAAG,EAAM,KAAK,IAAI,EAChB,EACA,EACD,GACF,CACA,MAAM,IAAI,CACV,SAAS,EACZ,EACF,CACD,MAAM,KAAK,EAEjB,CACF,CACF,CAAC,EAGS,EAAoB,MAC/B,EACA,EACA,EACA,IACG,CACH,MAAM,EAAqB,EAAO,EAAY,EAAQ,EAAQ,CAC9D,EAAyB,EAAO,EAAY,EAAO,CACnD,EAAuB,EAAO,EAAY,EAAO,CAC7C,EAAkB,EAAO,EAAO,EAClC,EAA8B,EAAO,EAAY,EAAO,EAG/C,GACX,EACA,IACG,CACH,EAAO,QAAQ,GACb,EAAU,qBAAqB,CAC7B,gBAAiB,KAAK,EAAe,EAAM,KAAK,CAAC,SAClD,CAAC,CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./model-helpers.cjs`);function t(e,t,r,i){let a=n(t,r,i);for(let t of a)e.push(t)}function n(t,n,r){let i=[];for(let a of t){let{name:t}=a,o=[];if(n){let e={name:`select`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${t}Select`,location:`inputObjectTypes`,namespace:`prisma`}]};o.push(e)}let s=e.checkModelHasModelRelation(a);if(r&&s){let e={name:`include`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${t}Include`,location:`inputObjectTypes`,namespace:`prisma`}]};o.push(e)}let c={name:`${t}DefaultArgs`,constraints:{maxNumFields:null,minNumFields:null},fields:o};i.push(c)}return i}exports.addMissingInputObjectTypesForModelArgs=t;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{checkModelHasModelRelation as e}from"./model-helpers.mjs";function t(e,t,r,i){let a=n(t,r,i);for(let t of a)e.push(t)}function n(t,n,r){let i=[];for(let a of t){let{name:t}=a,o=[];if(n){let e={name:`select`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${t}Select`,location:`inputObjectTypes`,namespace:`prisma`}]};o.push(e)}let s=e(a);if(r&&s){let e={name:`include`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${t}Include`,location:`inputObjectTypes`,namespace:`prisma`}]};o.push(e)}let c={name:`${t}DefaultArgs`,constraints:{maxNumFields:null,minNumFields:null},fields:o};i.push(c)}return i}export{t as addMissingInputObjectTypesForModelArgs};
|
|
2
|
+
//# sourceMappingURL=modelArgs-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelArgs-helpers.mjs","names":["modelArgsInputObjectTypes: DMMF.InputType[]","fields: DMMF.SchemaArg[]","selectField: DMMF.SchemaArg","includeField: DMMF.SchemaArg","modelArgsInputObjectType: DMMF.InputType"],"sources":["../../src/zod/modelArgs-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 { checkModelHasModelRelation } from \"./model-helpers\";\n\nexport function addMissingInputObjectTypesForModelArgs(\n inputObjectTypes: DMMF.InputType[],\n models: DMMF.Model[],\n isGenerateSelect: boolean,\n isGenerateInclude: boolean\n) {\n const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(\n models,\n isGenerateSelect,\n isGenerateInclude\n );\n\n for (const modelArgsInputObjectType of modelArgsInputObjectTypes) {\n inputObjectTypes.push(modelArgsInputObjectType);\n }\n}\nfunction generateModelArgsInputObjectTypes(\n models: DMMF.Model[],\n isGenerateSelect: boolean,\n isGenerateInclude: boolean\n) {\n const modelArgsInputObjectTypes: DMMF.InputType[] = [];\n for (const model of models) {\n const { name: modelName } = model;\n const fields: DMMF.SchemaArg[] = [];\n\n if (isGenerateSelect) {\n const selectField: DMMF.SchemaArg = {\n name: \"select\",\n isRequired: false,\n isNullable: false,\n inputTypes: [\n {\n isList: false,\n type: `${modelName}Select`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n }\n ]\n };\n fields.push(selectField);\n }\n\n const hasRelationToAnotherModel = checkModelHasModelRelation(model);\n\n if (isGenerateInclude && hasRelationToAnotherModel) {\n const includeField: DMMF.SchemaArg = {\n name: \"include\",\n isRequired: false,\n isNullable: false,\n inputTypes: [\n {\n isList: false,\n type: `${modelName}Include`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n }\n ]\n };\n fields.push(includeField);\n }\n\n const modelArgsInputObjectType: DMMF.InputType = {\n name: `${modelName}DefaultArgs`,\n constraints: {\n maxNumFields: null,\n minNumFields: null\n },\n fields\n };\n modelArgsInputObjectTypes.push(modelArgsInputObjectType);\n }\n\n return modelArgsInputObjectTypes;\n}\n"],"mappings":"iEAoBA,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,IAAM,EAA4B,EAChC,EACA,EACA,EACD,CAED,IAAK,IAAM,KAA4B,EACrC,EAAiB,KAAK,EAAyB,CAGnD,SAAS,EACP,EACA,EACA,EACA,CACA,IAAMA,EAA8C,EAAE,CACtD,IAAK,IAAM,KAAS,EAAQ,CAC1B,GAAM,CAAE,KAAM,GAAc,EACtBC,EAA2B,EAAE,CAEnC,GAAI,EAAkB,CACpB,IAAMC,EAA8B,CAClC,KAAM,SACN,WAAY,GACZ,WAAY,GACZ,WAAY,CACV,CACE,OAAQ,GACR,KAAM,GAAG,EAAU,QACnB,SAAU,mBACV,UAAW,SACZ,CACF,CACF,CACD,EAAO,KAAK,EAAY,CAG1B,IAAM,EAA4B,EAA2B,EAAM,CAEnE,GAAI,GAAqB,EAA2B,CAClD,IAAMC,EAA+B,CACnC,KAAM,UACN,WAAY,GACZ,WAAY,GACZ,WAAY,CACV,CACE,OAAQ,GACR,KAAM,GAAG,EAAU,SACnB,SAAU,mBACV,UAAW,SACZ,CACF,CACF,CACD,EAAO,KAAK,EAAa,CAG3B,IAAMC,EAA2C,CAC/C,KAAM,GAAG,EAAU,aACnB,YAAa,CACX,aAAc,KACd,aAAc,KACf,CACD,SACD,CACD,EAA0B,KAAK,EAAyB,CAG1D,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./transformer.cjs`);function t(t,i,a){e.default.rawOpsMap=n(t)??{};let o=r(i);for(let e of o)a.push(e)}function n(e){let t={},n=[...new Set(e.reduce((e,t)=>(Object.keys(t)?.forEach(t=>{t.includes(`Raw`)&&e.push(t)}),e),[]))],r=e.map(e=>e.model);return n.forEach(e=>{r.forEach(n=>{let r=e===`findRaw`,i=`${e.replace(`Raw`,``)}${n}Raw`;t[i]=r?`${n}FindRawArgs`:`${n}AggregateRawArgs`})}),t}function r(e){return i(e).map(e=>({name:e.name,constraints:{maxNumFields:null,minNumFields:null},fields:e.args.map(e=>({name:e.name,isRequired:e.isRequired,isNullable:e.isNullable,inputTypes:e.inputTypes}))}))}function i(e){return e.filter(e=>e.name===`Query`)?.[0].fields.filter(e=>e.name.includes(`Raw`))??[]}const a=e=>/find[\s\S]*?Raw/.test(e)||/aggregate[\s\S]*?Raw/.test(e);exports.addMissingInputObjectTypesForMongoDbRawOpsAndQueries=t,exports.isMongodbRawOp=a;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"./transformer.mjs";function t(t,i,a){e.rawOpsMap=n(t)??{};let o=r(i);for(let e of o)a.push(e)}function n(e){let t={},n=[...new Set(e.reduce((e,t)=>(Object.keys(t)?.forEach(t=>{t.includes(`Raw`)&&e.push(t)}),e),[]))],r=e.map(e=>e.model);return n.forEach(e=>{r.forEach(n=>{let r=e===`findRaw`,i=`${e.replace(`Raw`,``)}${n}Raw`;t[i]=r?`${n}FindRawArgs`:`${n}AggregateRawArgs`})}),t}function r(e){return i(e).map(e=>({name:e.name,constraints:{maxNumFields:null,minNumFields:null},fields:e.args.map(e=>({name:e.name,isRequired:e.isRequired,isNullable:e.isNullable,inputTypes:e.inputTypes}))}))}function i(e){return e.filter(e=>e.name===`Query`)?.[0].fields.filter(e=>e.name.includes(`Raw`))??[]}const a=e=>/find[\s\S]*?Raw/.test(e)||/aggregate[\s\S]*?Raw/.test(e);export{t as addMissingInputObjectTypesForMongoDbRawOpsAndQueries,a as isMongodbRawOp};
|
|
2
|
+
//# sourceMappingURL=mongodb-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb-helpers.mjs","names":["rawOpsMap: { [name: string]: string }"],"sources":["../../src/zod/mongodb-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 Transformer from \"./transformer\";\n\nexport function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(\n modelOperations: DMMF.ModelMapping[],\n outputObjectTypes: DMMF.OutputType[],\n inputObjectTypes: DMMF.InputType[]\n) {\n const rawOpsMap = resolveMongoDbRawOperations(modelOperations);\n Transformer.rawOpsMap = rawOpsMap ?? {};\n\n const mongoDbRawQueryInputObjectTypes =\n resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes);\n for (const mongoDbRawQueryInputType of mongoDbRawQueryInputObjectTypes) {\n inputObjectTypes.push(mongoDbRawQueryInputType);\n }\n}\n\nfunction resolveMongoDbRawOperations(modelOperations: DMMF.ModelMapping[]) {\n const rawOpsMap: { [name: string]: string } = {};\n const rawOpsNames = [\n ...new Set(\n modelOperations.reduce<string[]>((result, current) => {\n const keys = Object.keys(current);\n keys?.forEach(key => {\n if (key.includes(\"Raw\")) {\n result.push(key);\n }\n });\n return result;\n }, [])\n )\n ];\n\n const modelNames = modelOperations.map(item => item.model);\n\n rawOpsNames.forEach(opName => {\n modelNames.forEach(modelName => {\n const isFind = opName === \"findRaw\";\n const opWithModel = `${opName.replace(\"Raw\", \"\")}${modelName}Raw`;\n rawOpsMap[opWithModel] = isFind\n ? `${modelName}FindRawArgs`\n : `${modelName}AggregateRawArgs`;\n });\n });\n\n return rawOpsMap;\n}\n\nfunction resolveMongoDbRawQueryInputObjectTypes(\n outputObjectTypes: DMMF.OutputType[]\n) {\n const mongoDbRawQueries = getMongoDbRawQueries(outputObjectTypes);\n const mongoDbRawQueryInputObjectTypes = mongoDbRawQueries.map(item => ({\n name: item.name,\n constraints: {\n maxNumFields: null,\n minNumFields: null\n },\n fields: item.args.map(arg => ({\n name: arg.name,\n isRequired: arg.isRequired,\n isNullable: arg.isNullable,\n inputTypes: arg.inputTypes\n }))\n }));\n\n return mongoDbRawQueryInputObjectTypes;\n}\n\nfunction getMongoDbRawQueries(outputObjectTypes: DMMF.OutputType[]) {\n const queryOutputTypes = outputObjectTypes.filter(\n item => item.name === \"Query\"\n );\n\n const mongodbRawQueries =\n queryOutputTypes?.[0]!.fields.filter(field => field.name.includes(\"Raw\")) ??\n [];\n\n return mongodbRawQueries;\n}\n\nexport const isMongodbRawOp = (name: string) =>\n /find[\\s\\S]*?Raw/.test(name) || /aggregate[\\s\\S]*?Raw/.test(name);\n"],"mappings":"iCAoBA,SAAgB,EACd,EACA,EACA,EACA,CAEA,EAAY,UADM,EAA4B,EAAgB,EACzB,EAAE,CAEvC,IAAM,EACJ,EAAuC,EAAkB,CAC3D,IAAK,IAAM,KAA4B,EACrC,EAAiB,KAAK,EAAyB,CAInD,SAAS,EAA4B,EAAsC,CACzE,IAAMA,EAAwC,EAAE,CAC1C,EAAc,CAClB,GAAG,IAAI,IACL,EAAgB,QAAkB,EAAQ,KAC3B,OAAO,KAAK,EAAQ,EAC3B,QAAQ,GAAO,CACf,EAAI,SAAS,MAAM,EACrB,EAAO,KAAK,EAAI,EAElB,CACK,GACN,EAAE,CAAC,CACP,CACF,CAEK,EAAa,EAAgB,IAAI,GAAQ,EAAK,MAAM,CAY1D,OAVA,EAAY,QAAQ,GAAU,CAC5B,EAAW,QAAQ,GAAa,CAC9B,IAAM,EAAS,IAAW,UACpB,EAAc,GAAG,EAAO,QAAQ,MAAO,GAAG,GAAG,EAAU,KAC7D,EAAU,GAAe,EACrB,GAAG,EAAU,aACb,GAAG,EAAU,mBACjB,EACF,CAEK,EAGT,SAAS,EACP,EACA,CAgBA,OAf0B,EAAqB,EAAkB,CACP,IAAI,IAAS,CACrE,KAAM,EAAK,KACX,YAAa,CACX,aAAc,KACd,aAAc,KACf,CACD,OAAQ,EAAK,KAAK,IAAI,IAAQ,CAC5B,KAAM,EAAI,KACV,WAAY,EAAI,WAChB,WAAY,EAAI,WAChB,WAAY,EAAI,WACjB,EAAE,CACJ,EAAE,CAKL,SAAS,EAAqB,EAAsC,CASlE,OARyB,EAAkB,OACzC,GAAQ,EAAK,OAAS,QACvB,GAGoB,GAAI,OAAO,OAAO,GAAS,EAAM,KAAK,SAAS,MAAM,CAAC,EACzE,EAAE,CAKN,MAAa,EAAkB,GAC7B,kBAAkB,KAAK,EAAK,EAAI,uBAAuB,KAAK,EAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./model-helpers.cjs`);function t(e,t,o){let s=n(t),c=[r(s),i(s),a(o)].flat();for(let t of c)e.push(t)}function n(e){return e.filter(({name:e})=>e.includes(`CountOutputType`))}function r(e){let t=[];for(let n of e){let{name:e,fields:r}=n,i={name:`${e}Select`,constraints:{maxNumFields:null,minNumFields:null},fields:r.map(({name:e})=>({name:e,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`}]}))};t.push(i)}return t}function i(e){let t=[];for(let n of e){let{name:e}=n,r={name:`${e}DefaultArgs`,constraints:{maxNumFields:null,minNumFields:null},fields:[{name:`select`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${e}Select`,location:`inputObjectTypes`,namespace:`prisma`}]}]};t.push(r)}return t}function a(t){let n=[];for(let r of t){let{name:t,fields:i}=r,a=[];for(let t of i){let{name:n,isList:r,type:i}=t,o=e.checkIsModelRelationField(t),s={name:n,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`}]};if(o){let e={isList:!1,type:r?`${i}FindManyArgs`:`${i}DefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`};s.inputTypes.push(e)}a.push(s)}if(e.checkModelHasManyModelRelation(r)){let e={name:`_count`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`},{isList:!1,type:`${t}CountOutputTypeDefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`}]};a.push(e)}let o={name:`${t}Select`,constraints:{maxNumFields:null,minNumFields:null},fields:a};n.push(o)}return n}exports.addMissingInputObjectTypesForSelect=t;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{checkIsModelRelationField as e,checkModelHasManyModelRelation as t}from"./model-helpers.mjs";function n(e,t,n){let s=r(t),c=[i(s),a(s),o(n)].flat();for(let t of c)e.push(t)}function r(e){return e.filter(({name:e})=>e.includes(`CountOutputType`))}function i(e){let t=[];for(let n of e){let{name:e,fields:r}=n,i={name:`${e}Select`,constraints:{maxNumFields:null,minNumFields:null},fields:r.map(({name:e})=>({name:e,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`}]}))};t.push(i)}return t}function a(e){let t=[];for(let n of e){let{name:e}=n,r={name:`${e}DefaultArgs`,constraints:{maxNumFields:null,minNumFields:null},fields:[{name:`select`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${e}Select`,location:`inputObjectTypes`,namespace:`prisma`}]}]};t.push(r)}return t}function o(n){let r=[];for(let i of n){let{name:n,fields:a}=i,o=[];for(let t of a){let{name:n,isList:r,type:i}=t,a=e(t),s={name:n,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`}]};if(a){let e={isList:!1,type:r?`${i}FindManyArgs`:`${i}DefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`};s.inputTypes.push(e)}o.push(s)}if(t(i)){let e={name:`_count`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`},{isList:!1,type:`${n}CountOutputTypeDefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`}]};o.push(e)}let s={name:`${n}Select`,constraints:{maxNumFields:null,minNumFields:null},fields:o};r.push(s)}return r}export{n as addMissingInputObjectTypesForSelect};
|
|
2
|
+
//# sourceMappingURL=select-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-helpers.mjs","names":["modelCountOutputTypeSelectInputObjectTypes: DMMF.InputType[]","modelCountOutputTypeSelectInputObjectType: DMMF.InputType","modelCountOutputTypeArgsInputObjectTypes: DMMF.InputType[]","modelCountOutputTypeArgsInputObjectType: DMMF.InputType","modelSelectInputObjectTypes: DMMF.InputType[]","fields: DMMF.SchemaArg[]","field: Writeable<DMMF.SchemaArg>","schemaArgInputType: ArrayValues<SchemaArgInputTypes>","_countField: DMMF.SchemaArg","modelSelectInputObjectType: DMMF.InputType"],"sources":["../../src/zod/select-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 { ArrayValues } from \"@stryke/types/array\";\nimport type { SchemaArgInputTypes, Writeable } from \"../types\";\nimport {\n checkIsModelRelationField,\n checkModelHasManyModelRelation\n} from \"./model-helpers\";\n\nexport function addMissingInputObjectTypesForSelect(\n inputObjectTypes: DMMF.InputType[],\n outputObjectTypes: DMMF.OutputType[],\n models: DMMF.Model[]\n) {\n // generate input object types necessary to support ModelSelect._count\n const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);\n const modelCountOutputTypeSelectInputObjectTypes =\n generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes);\n const modelCountOutputTypeArgsInputObjectTypes =\n generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes);\n\n const modelSelectInputObjectTypes =\n generateModelSelectInputObjectTypes(models);\n\n const generatedInputObjectTypes = [\n modelCountOutputTypeSelectInputObjectTypes,\n modelCountOutputTypeArgsInputObjectTypes,\n modelSelectInputObjectTypes\n ].flat();\n\n for (const inputObjectType of generatedInputObjectTypes) {\n inputObjectTypes.push(inputObjectType);\n }\n}\n\nfunction getModelCountOutputTypes(outputObjectTypes: DMMF.OutputType[]) {\n return outputObjectTypes.filter(({ name }) =>\n name.includes(\"CountOutputType\")\n );\n}\n\nfunction generateModelCountOutputTypeSelectInputObjectTypes(\n modelCountOutputTypes: DMMF.OutputType[]\n) {\n const modelCountOutputTypeSelectInputObjectTypes: DMMF.InputType[] = [];\n for (const modelCountOutputType of modelCountOutputTypes) {\n const {\n name: modelCountOutputTypeName,\n fields: modelCountOutputTypeFields\n } = modelCountOutputType;\n const modelCountOutputTypeSelectInputObjectType: DMMF.InputType = {\n name: `${modelCountOutputTypeName}Select`,\n constraints: {\n maxNumFields: null,\n minNumFields: null\n },\n fields: modelCountOutputTypeFields.map(({ name }) => ({\n name,\n isRequired: false,\n isNullable: false,\n inputTypes: [\n {\n isList: false,\n type: `Boolean`,\n location: \"scalar\"\n }\n ]\n }))\n };\n modelCountOutputTypeSelectInputObjectTypes.push(\n modelCountOutputTypeSelectInputObjectType\n );\n }\n\n return modelCountOutputTypeSelectInputObjectTypes;\n}\n\nfunction generateModelCountOutputTypeArgsInputObjectTypes(\n modelCountOutputTypes: DMMF.OutputType[]\n) {\n const modelCountOutputTypeArgsInputObjectTypes: DMMF.InputType[] = [];\n for (const modelCountOutputType of modelCountOutputTypes) {\n const { name: modelCountOutputTypeName } = modelCountOutputType;\n const modelCountOutputTypeArgsInputObjectType: DMMF.InputType = {\n name: `${modelCountOutputTypeName}DefaultArgs`,\n constraints: {\n maxNumFields: null,\n minNumFields: null\n },\n fields: [\n {\n name: \"select\",\n isRequired: false,\n isNullable: false,\n inputTypes: [\n {\n isList: false,\n type: `${modelCountOutputTypeName}Select`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n }\n ]\n }\n ]\n };\n modelCountOutputTypeArgsInputObjectTypes.push(\n modelCountOutputTypeArgsInputObjectType\n );\n }\n\n return modelCountOutputTypeArgsInputObjectTypes;\n}\n\nfunction generateModelSelectInputObjectTypes(models: DMMF.Model[]) {\n const modelSelectInputObjectTypes: 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 const field: Writeable<DMMF.SchemaArg> = {\n name: modelFieldName,\n isRequired: false,\n isNullable: false,\n inputTypes: [\n { isList: false, type: \"Boolean\", location: \"scalar\" }\n ] as Writeable<DMMF.SchemaArg[\"inputTypes\"]>\n };\n\n if (isRelationField) {\n const schemaArgInputType: ArrayValues<SchemaArgInputTypes> = {\n isList: false,\n type: isList ? `${type}FindManyArgs` : `${type}DefaultArgs`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n };\n field.inputTypes.push(schemaArgInputType);\n }\n\n fields.push(field);\n }\n\n const hasManyRelationToAnotherModel = checkModelHasManyModelRelation(model);\n\n const shouldAddCountField = hasManyRelationToAnotherModel;\n if (shouldAddCountField) {\n const _countField: DMMF.SchemaArg = {\n name: \"_count\",\n isRequired: false,\n isNullable: false,\n inputTypes: [\n { isList: false, type: \"Boolean\", location: \"scalar\" },\n {\n isList: false,\n type: `${modelName}CountOutputTypeDefaultArgs`,\n location: \"inputObjectTypes\",\n namespace: \"prisma\"\n }\n ]\n };\n fields.push(_countField);\n }\n\n const modelSelectInputObjectType: DMMF.InputType = {\n name: `${modelName}Select`,\n constraints: {\n maxNumFields: null,\n minNumFields: null\n },\n fields\n };\n modelSelectInputObjectTypes.push(modelSelectInputObjectType);\n }\n\n return modelSelectInputObjectTypes;\n}\n"],"mappings":"oGAyBA,SAAgB,EACd,EACA,EACA,EACA,CAEA,IAAM,EAAwB,EAAyB,EAAkB,CASnE,EAA4B,CAPhC,EAAmD,EAAsB,CAEzE,EAAiD,EAAsB,CAGvE,EAAoC,EAAO,CAM5C,CAAC,MAAM,CAER,IAAK,IAAM,KAAmB,EAC5B,EAAiB,KAAK,EAAgB,CAI1C,SAAS,EAAyB,EAAsC,CACtE,OAAO,EAAkB,QAAQ,CAAE,UACjC,EAAK,SAAS,kBAAkB,CACjC,CAGH,SAAS,EACP,EACA,CACA,IAAMA,EA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AAM,WAAW,KAAK,EAAmB,CAG3C,EAAO,KAAK,EAAM,CAMpB,GAHsC,EAA+B,EAAM,CAGlD,CACvB,IAAMC,EAA8B,CAClC,KAAM,SACN,WAAY,GACZ,WAAY,GACZ,WAAY,CACV,CAAE,OAAQ,GAAO,KAAM,UAAW,SAAU,SAAU,CACtD,CACE,OAAQ,GACR,KAAM,GAAG,EAAU,4BACnB,SAAU,mBACV,UAAW,SACZ,CACF,CACF,CACD,EAAO,KAAK,EAAY,CAG1B,IAAMC,EAA6C,CACjD,KAAM,GAAG,EAAU,QACnB,YAAa,CACX,aAAc,KACd,aAAc,KACf,CACD,SACD,CACD,EAA4B,KAAK,EAA2B,CAG9D,OAAO"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../packages/string-format/src/lower-case-first.cjs`),n=require(`../packages/string-format/src/upper-case-first.cjs`),r=require(`./model-helpers.cjs`),i=require(`../utils/write-file-safely.cjs`),a=require(`./aggregate-helpers.cjs`),o=require(`./mongodb-helpers.cjs`);let s=require(`node:path`);s=e.__toESM(s);var c=class e{name;fields;schemaImports=new Set;models;modelOperations;aggregateOperationSupport;enumTypes;static enumNames=[];static rawOpsMap={};static provider;static previewFeatures;static outputPath=`./generated`;hasJson=!1;static prismaClientOutputPath=`@prisma/client`;static isCustomPrismaClientOutputPath=!1;static isGenerateSelect=!0;static isGenerateInclude=!0;constructor(e){this.name=e.name??``,this.fields=e.fields??[],this.models=e.models??[],this.modelOperations=e.modelOperations??[],this.aggregateOperationSupport=e.aggregateOperationSupport??{},this.enumTypes=e.enumTypes??[]}static setOutputPath(e){this.outputPath=e}static setIsGenerateSelect(e){this.isGenerateSelect=e}static setIsGenerateInclude(e){this.isGenerateInclude=e}static getOutputPath(){return this.outputPath}static setPrismaClientOutputPath(e){this.prismaClientOutputPath=e,this.isCustomPrismaClientOutputPath=e!==`@prisma/client`}static async generateIndex(){await i.writeIndexFile(s.default.join(e.outputPath,`schemas/index.ts`))}async generateEnumSchemas(){for(let n of this.enumTypes){let{name:r,values:a}=n;await i.writeFileSafely(s.default.join(e.outputPath,`schemas/enums/${t.lowerCaseFirst(r)}.schema.ts`),`${this.generateImportZodStatement()}\n${this.generateExportSchemaStatement(`${t.lowerCaseFirst(r)}`,`z.enum(${JSON.stringify(a)})`)}`)}}generateImportZodStatement(){return`import { z } from 'zod';
|
|
2
|
+
`}generateExportSchemaStatement(e,n){return`export const ${t.lowerCaseFirst(e)}Schema = ${n}`}async generateObjectSchema(){let n=this.generateObjectSchemaFields(),r=this.prepareObjectSchema(n),a=this.resolveObjectSchemaName();await i.writeFileSafely(s.default.join(e.outputPath,`schemas/objects/${t.lowerCaseFirst(a)}.schema.ts`),r)}generateObjectSchemaFields(){return this.fields.map(e=>this.generateObjectSchemaField(e)).flatMap(e=>e).map(e=>{let[t,n,r]=e;return(r?t:this.generateFieldValidators(t,n)).trim()})}generateObjectSchemaField(e){let t=e.inputTypes;if(t.length===0)return[];let n=t.reduce((n,r)=>{if(r.type===`String`)n.push(this.wrapWithZodValidators(`z.string()`,e));else if(r.type===`Int`||r.type===`Float`||r.type===`Decimal`)n.push(this.wrapWithZodValidators(`z.number()`,e));else if(r.type===`BigInt`)n.push(this.wrapWithZodValidators(`z.bigint()`,e));else if(r.type===`Boolean`)n.push(this.wrapWithZodValidators(`z.boolean()`,e));else if(r.type===`DateTime`)n.push(this.wrapWithZodValidators(`z.coerce.date()`,e));else if(r.type===`Json`)this.hasJson=!0,n.push(this.wrapWithZodValidators(`jsonSchema`,e));else if(r.type===`True`)n.push(this.wrapWithZodValidators(`z.literal(true)`,e));else if(r.type===`Bytes`)n.push(this.wrapWithZodValidators(`z.instanceof(Buffer)`,e));else if(!r.type.endsWith(`FieldRefInput`)){let i=r.location===`enumTypes`;(r.namespace===`prisma`||i)&&(r.type!==this.name&&typeof r.type==`string`&&this.addSchemaImport(r.type),n.push(this.generatePrismaStringLine(e,r,t.length)))}return n},[]);if(n.length===0)return[];n.length>1&&(n=n.map(e=>e.replace(`.optional()`,``)));let r=n.some(e=>e.includes(`:`))?``:` ${e.name}:`,i=e.isRequired?``:`.optional()`,a=n.length===1?n.join(`,\r
|
|
3
|
+
`):`z.union([${n.join(`,\r
|
|
4
|
+
`)}])${i}`;return e.isNullable&&(a+=`.nullable()`),[[` ${r} ${a} `,e,!0]]}wrapWithZodValidators(e,t){let n=``;return n=e,t.inputTypes.some(e=>e.isList)&&(n+=`.array()`),t.isRequired||(n+=`.optional()`),n}addSchemaImport(e){this.schemaImports.add(e)}generatePrismaStringLine(e,n,r){let i=n.location===`enumTypes`,a=n.type,{isModelQueryType:o,modelName:s,queryName:c}=this.checkIsModelQueryType(a),l=o?this.resolveModelQuerySchemaName(s,c):`${a}ObjectSchema`,u=`${a}Schema`,d=n.type===this.name?l:i?u:l,f=n.isList?`.array()`:``,p=e.isRequired?``:`.optional()`;return r===1?` ${e.name}: z.lazy(() => ${t.lowerCaseFirst(d)})${f}${p}`:`z.lazy(() => ${t.lowerCaseFirst(d)})${f}${p}`}generateFieldValidators(e,t){let{isRequired:n,isNullable:r}=t;return n||(e+=`.optional()`),r&&(e+=`.nullable()`),e}prepareObjectSchema(e){let t=`${this.generateExportObjectSchemaStatement(this.addFinalWrappers({zodStringFields:e}))}\n`,n=this.generateImportPrismaStatement(),r=this.generateJsonSchemaImplementation();return`${this.generateObjectSchemaImportStatements()}${n}${r}${t}`}generateExportObjectSchemaStatement(n){let r=this.name,i=this.name;e.provider===`mongodb`&&o.isMongodbRawOp(r)&&(r=e.rawOpsMap[r],i=r.replace(`Args`,``)),a.isAggregateInputType(r)&&(r=`${r}Type`);let s=`export const ${t.lowerCaseFirst(i)}ObjectSchema = schema`;return`const schema: z.ZodType<Prisma.${r}> = ${n};\n\n ${s}`}addFinalWrappers({zodStringFields:e}){let t=[...e];return`${this.wrapWithZodObject(t)}.strict()`}generateImportPrismaStatement(){let t;if(e.isCustomPrismaClientOutputPath){let n=s.default.join(e.outputPath,`schemas`,`objects`),r=e.prismaClientOutputPath;t=s.default.relative(n,r).split(s.default.sep).join(s.default.posix.sep)}else t=e.prismaClientOutputPath;return`import type { Prisma } from '${t}';\n\n`}generateJsonSchemaImplementation(){let e=``;return this.hasJson&&(e+=`
|
|
5
|
+
`,e+=`const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
6
|
+
`,e+=`const jsonSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>
|
|
7
|
+
`,e+=` z.union([literalSchema, z.array(jsonSchema.nullable()), z.record(jsonSchema.nullable())])
|
|
8
|
+
`,e+=`);
|
|
9
|
+
|
|
10
|
+
`),e}generateObjectSchemaImportStatements(){let e=this.generateImportZodStatement();return e+=this.generateSchemaImports(),e+=`
|
|
11
|
+
|
|
12
|
+
`,e}generateSchemaImports(){return[...this.schemaImports].map(n=>{let{isModelQueryType:r,modelName:i,queryName:a}=this.checkIsModelQueryType(n);return r?`import { ${this.resolveModelQuerySchemaName(i,a)} } from '../${a}${i}.schema'`:e.enumNames.includes(n)?`import { ${t.lowerCaseFirst(n)}Schema } from '../enums/${t.lowerCaseFirst(n)}.schema'`:`import { ${t.lowerCaseFirst(n)}ObjectSchema } from './${t.lowerCaseFirst(n)}.schema'`}).join(`;\r
|
|
13
|
+
`)}checkIsModelQueryType(e){let t={FindManyArgs:`findMany`};for(let n of[`FindManyArgs`])if(e.includes(n)){let r=e.indexOf(n);return{isModelQueryType:!0,modelName:e.substring(0,r),queryName:t[n]}}return{isModelQueryType:!1}}resolveModelQuerySchemaName(e,r){return`${t.lowerCaseFirst(e)}${n.upperCaseFirst(r)}Schema`}wrapWithZodUnion(e){let t=``;return t+=`z.union([`,t+=`
|
|
14
|
+
`,t+=` ${e.join(`,`)}`,t+=`
|
|
15
|
+
`,t+=`])`,t}wrapWithZodObject(e){let t=``;return t+=`z.object({`,t+=`
|
|
16
|
+
`,t+=` ${typeof e==`string`?e:e.join(`,
|
|
17
|
+
`)}`,t+=`
|
|
18
|
+
`,t+=`})`,t}resolveObjectSchemaName(){let n=this.name,r=this.name;return o.isMongodbRawOp(n)&&(n=e.rawOpsMap[n],r=n.replace(`Args`,``)),t.lowerCaseFirst(r)}async generateModelSchemas(){for(let n of this.modelOperations){let{findUnique:a,findFirst:o,findMany:c,createOne:l,createMany:u,createManyAndReturn:d,deleteOne:f,updateOne:p,deleteMany:m,updateMany:h,updateManyAndReturn:g,upsertOne:_,aggregate:v,groupBy:y}=n,b=r.findModelByName(this.models,n.model),x=t.lowerCaseFirst(n.model),{selectImport:S,includeImport:C,selectZodSchemaLine:w,includeZodSchemaLine:T,selectZodSchemaLineLazy:E,includeZodSchemaLineLazy:D}=this.resolveSelectIncludeImportAndZodSchemaLine(b),{orderByImport:O,orderByZodSchemaLine:k}=this.resolveOrderByWithRelationImportAndZodSchemaLine(b);if(a){let t=[S,C,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${a}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}FindUnique`,`z.object({ ${w} ${T} where: ${x}WhereUniqueInputObjectSchema })`)}`)}if(o){let t=[S,C,O,`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`,`import { ${x}ScalarFieldEnumSchema } from './enums/${x}ScalarFieldEnum.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${o}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}FindFirst`,`z.object({ ${w} ${T} ${k} where: ${x}WhereInputObjectSchema.optional(), cursor: ${x}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${x}ScalarFieldEnumSchema).optional() })`)}`)}if(c){let t=[S,C,O,`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`,`import { ${x}ScalarFieldEnumSchema } from './enums/${x}ScalarFieldEnum.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${c}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}FindMany`,`z.object({ ${E} ${D} ${k} where: ${x}WhereInputObjectSchema.optional(), cursor: ${x}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${x}ScalarFieldEnumSchema).optional() })`)}`)}if(l){let t=[S,C,`import { ${x}CreateInputObjectSchema } from './objects/${x}CreateInput.schema'`,`import { ${x}UncheckedCreateInputObjectSchema } from './objects/${x}UncheckedCreateInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${l}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}CreateOne`,`z.object({ ${w} ${T} data: z.union([${x}CreateInputObjectSchema, ${x}UncheckedCreateInputObjectSchema]) })`)}`)}if(u){let t=[`import { ${x}CreateManyInputObjectSchema } from './objects/${x}CreateManyInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${u}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}CreateMany`,`z.object({ data: z.union([ ${x}CreateManyInputObjectSchema, z.array(${x}CreateManyInputObjectSchema) ]), ${e.provider===`mongodb`||e.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(d){let t=[`import { ${x}CreateManyAndReturnInputObjectSchema } from './objects/${x}CreateManyAndReturnInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${d}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}CreateManyAndReturn`,`z.object({ data: z.union([ ${x}CreateManyAndReturnInputObjectSchema, z.array(${x}CreateManyAndReturnInputObjectSchema) ]), ${e.provider===`mongodb`||e.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(f){let t=[S,C,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${f}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}DeleteOne`,`z.object({ ${w} ${T} where: ${x}WhereUniqueInputObjectSchema })`)}`)}if(m){let t=[`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${m}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}DeleteMany`,`z.object({ where: ${x}WhereInputObjectSchema.optional() })`)}`)}if(p){let t=[S,C,`import { ${x}UpdateInputObjectSchema } from './objects/${x}UpdateInput.schema'`,`import { ${x}UncheckedUpdateInputObjectSchema } from './objects/${x}UncheckedUpdateInput.schema'`,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${p}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}UpdateOne`,`z.object({ ${w} ${T} data: z.union([${x}UpdateInputObjectSchema, ${x}UncheckedUpdateInputObjectSchema]), where: ${x}WhereUniqueInputObjectSchema })`)}`)}if(h){let t=[`import { ${x}UpdateManyMutationInputObjectSchema } from './objects/${x}UpdateManyMutationInput.schema'`,`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${h}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}UpdateMany`,`z.object({ data: ${x}UpdateManyMutationInputObjectSchema, where: ${x}WhereInputObjectSchema.optional() })`)}`)}if(g){let t=[`import { ${x}UpdateManyAndReturnInputObjectSchema } from './objects/${x}UpdateManyAndReturnInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${g}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}UpdateManyAndReturn`,`z.object({ data: z.union([ ${x}UpdateManyAndReturnInputObjectSchema, z.array(${x}UpdateManyAndReturnInputObjectSchema) ]), ${e.provider===`mongodb`||e.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(_){let t=[S,C,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`,`import { ${x}CreateInputObjectSchema } from './objects/${x}CreateInput.schema'`,`import { ${x}UncheckedCreateInputObjectSchema } from './objects/${x}UncheckedCreateInput.schema'`,`import { ${x}UpdateInputObjectSchema } from './objects/${x}UpdateInput.schema'`,`import { ${x}UncheckedUpdateInputObjectSchema } from './objects/${x}UncheckedUpdateInput.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${_}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}Upsert`,`z.object({ ${w} ${T} where: ${x}WhereUniqueInputObjectSchema, create: z.union([ ${x}CreateInputObjectSchema, ${x}UncheckedCreateInputObjectSchema ]), update: z.union([ ${x}UpdateInputObjectSchema, ${x}UncheckedUpdateInputObjectSchema ]) })`)}`)}if(v){let t=[O,`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`],n=[];this.aggregateOperationSupport[x]&&(this.aggregateOperationSupport[x].count&&(t.push(`import { ${x}CountAggregateInputObjectSchema } from './objects/${x}CountAggregateInput.schema'`),n.push(`_count: z.union([ z.literal(true), ${x}CountAggregateInputObjectSchema ]).optional()`)),this.aggregateOperationSupport[x].min&&(t.push(`import { ${x}MinAggregateInputObjectSchema } from './objects/${x}MinAggregateInput.schema'`),n.push(`_min: ${x}MinAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[x].max&&(t.push(`import { ${x}MaxAggregateInputObjectSchema } from './objects/${x}MaxAggregateInput.schema'`),n.push(`_max: ${x}MaxAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[x].avg&&(t.push(`import { ${x}AvgAggregateInputObjectSchema } from './objects/${x}AvgAggregateInput.schema'`),n.push(`_avg: ${x}AvgAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[x].sum&&(t.push(`import { ${x}SumAggregateInputObjectSchema } from './objects/${x}SumAggregateInput.schema'`),n.push(`_sum: ${x}SumAggregateInputObjectSchema.optional()`))),await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${v}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}Aggregate`,`z.object({ ${k} where: ${x}WhereInputObjectSchema.optional(), cursor: ${x}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), ${n.join(`, `)} })`)}`)}if(y){let t=[`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`,`import { ${x}OrderByWithAggregationInputObjectSchema } from './objects/${x}OrderByWithAggregationInput.schema'`,`import { ${x}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${x}ScalarWhereWithAggregatesInput.schema'`,`import { ${x}ScalarFieldEnumSchema } from './enums/${x}ScalarFieldEnum.schema'`];await i.writeFileSafely(s.default.join(e.outputPath,`schemas/${y}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${x}GroupBy`,`z.object({ where: ${x}WhereInputObjectSchema.optional(), orderBy: z.union([${x}OrderByWithAggregationInputObjectSchema, ${x}OrderByWithAggregationInputObjectSchema.array()]).optional(), having: ${x}ScalarWhereWithAggregatesInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), by: z.array(${x}ScalarFieldEnumSchema) })`)}`)}}}generateImportStatements(e){let t=this.generateImportZodStatement();return t+=e?.filter(e=>!!e).join(`;\r
|
|
19
|
+
`)??``,t+=`
|
|
20
|
+
|
|
21
|
+
`,t}resolveSelectIncludeImportAndZodSchemaLine(n){let{name:i}=n,a=r.checkModelHasModelRelation(n),o=e.isGenerateSelect?`import { ${t.lowerCaseFirst(i)}SelectObjectSchema } from './objects/${t.lowerCaseFirst(i)}Select.schema'`:``,s=e.isGenerateInclude&&a?`import { ${t.lowerCaseFirst(i)}IncludeObjectSchema } from './objects/${t.lowerCaseFirst(i)}Include.schema'`:``,c=``,l=``,u=``,d=``;if(e.isGenerateSelect){let e=`${t.lowerCaseFirst(i)}SelectObjectSchema.optional()`;c=`select: ${e},`,u=`select: z.lazy(() => ${e}),`}if(e.isGenerateInclude&&a){let e=`${t.lowerCaseFirst(i)}IncludeObjectSchema.optional()`;l=`include: ${e},`,d=`include: z.lazy(() => ${e}),`}return{selectImport:o,includeImport:s,selectZodSchemaLine:c,includeZodSchemaLine:l,selectZodSchemaLineLazy:u,includeZodSchemaLineLazy:d}}resolveOrderByWithRelationImportAndZodSchemaLine(n){let{name:r}=n,i=``;return i=[`postgresql`,`mysql`].includes(e.provider)&&e.previewFeatures?.includes(`fullTextSearch`)?`${t.lowerCaseFirst(r)}OrderByWithRelationAndSearchRelevanceInput`:`${t.lowerCaseFirst(r)}OrderByWithRelationInput`,{orderByImport:`import { ${i}ObjectSchema } from './objects/${i}.schema'`,orderByZodSchemaLine:`orderBy: z.union([${i}ObjectSchema, ${i}ObjectSchema.array()]).optional(),`}}};exports.default=c;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{lowerCaseFirst as e}from"../packages/string-format/src/lower-case-first.mjs";import{upperCaseFirst as t}from"../packages/string-format/src/upper-case-first.mjs";import{checkModelHasModelRelation as n,findModelByName as r}from"./model-helpers.mjs";import{writeFileSafely as i,writeIndexFile as a}from"../utils/write-file-safely.mjs";import{isAggregateInputType as o}from"./aggregate-helpers.mjs";import{isMongodbRawOp as s}from"./mongodb-helpers.mjs";import c from"node:path";var l=class l{name;fields;schemaImports=new Set;models;modelOperations;aggregateOperationSupport;enumTypes;static enumNames=[];static rawOpsMap={};static provider;static previewFeatures;static outputPath=`./generated`;hasJson=!1;static prismaClientOutputPath=`@prisma/client`;static isCustomPrismaClientOutputPath=!1;static isGenerateSelect=!0;static isGenerateInclude=!0;constructor(e){this.name=e.name??``,this.fields=e.fields??[],this.models=e.models??[],this.modelOperations=e.modelOperations??[],this.aggregateOperationSupport=e.aggregateOperationSupport??{},this.enumTypes=e.enumTypes??[]}static setOutputPath(e){this.outputPath=e}static setIsGenerateSelect(e){this.isGenerateSelect=e}static setIsGenerateInclude(e){this.isGenerateInclude=e}static getOutputPath(){return this.outputPath}static setPrismaClientOutputPath(e){this.prismaClientOutputPath=e,this.isCustomPrismaClientOutputPath=e!==`@prisma/client`}static async generateIndex(){await a(c.join(l.outputPath,`schemas/index.ts`))}async generateEnumSchemas(){for(let t of this.enumTypes){let{name:n,values:r}=t;await i(c.join(l.outputPath,`schemas/enums/${e(n)}.schema.ts`),`${this.generateImportZodStatement()}\n${this.generateExportSchemaStatement(`${e(n)}`,`z.enum(${JSON.stringify(r)})`)}`)}}generateImportZodStatement(){return`import { z } from 'zod';
|
|
2
|
+
`}generateExportSchemaStatement(t,n){return`export const ${e(t)}Schema = ${n}`}async generateObjectSchema(){let t=this.generateObjectSchemaFields(),n=this.prepareObjectSchema(t),r=this.resolveObjectSchemaName();await i(c.join(l.outputPath,`schemas/objects/${e(r)}.schema.ts`),n)}generateObjectSchemaFields(){return this.fields.map(e=>this.generateObjectSchemaField(e)).flatMap(e=>e).map(e=>{let[t,n,r]=e;return(r?t:this.generateFieldValidators(t,n)).trim()})}generateObjectSchemaField(e){let t=e.inputTypes;if(t.length===0)return[];let n=t.reduce((n,r)=>{if(r.type===`String`)n.push(this.wrapWithZodValidators(`z.string()`,e));else if(r.type===`Int`||r.type===`Float`||r.type===`Decimal`)n.push(this.wrapWithZodValidators(`z.number()`,e));else if(r.type===`BigInt`)n.push(this.wrapWithZodValidators(`z.bigint()`,e));else if(r.type===`Boolean`)n.push(this.wrapWithZodValidators(`z.boolean()`,e));else if(r.type===`DateTime`)n.push(this.wrapWithZodValidators(`z.coerce.date()`,e));else if(r.type===`Json`)this.hasJson=!0,n.push(this.wrapWithZodValidators(`jsonSchema`,e));else if(r.type===`True`)n.push(this.wrapWithZodValidators(`z.literal(true)`,e));else if(r.type===`Bytes`)n.push(this.wrapWithZodValidators(`z.instanceof(Buffer)`,e));else if(!r.type.endsWith(`FieldRefInput`)){let i=r.location===`enumTypes`;(r.namespace===`prisma`||i)&&(r.type!==this.name&&typeof r.type==`string`&&this.addSchemaImport(r.type),n.push(this.generatePrismaStringLine(e,r,t.length)))}return n},[]);if(n.length===0)return[];n.length>1&&(n=n.map(e=>e.replace(`.optional()`,``)));let r=n.some(e=>e.includes(`:`))?``:` ${e.name}:`,i=e.isRequired?``:`.optional()`,a=n.length===1?n.join(`,\r
|
|
3
|
+
`):`z.union([${n.join(`,\r
|
|
4
|
+
`)}])${i}`;return e.isNullable&&(a+=`.nullable()`),[[` ${r} ${a} `,e,!0]]}wrapWithZodValidators(e,t){let n=``;return n=e,t.inputTypes.some(e=>e.isList)&&(n+=`.array()`),t.isRequired||(n+=`.optional()`),n}addSchemaImport(e){this.schemaImports.add(e)}generatePrismaStringLine(t,n,r){let i=n.location===`enumTypes`,a=n.type,{isModelQueryType:o,modelName:s,queryName:c}=this.checkIsModelQueryType(a),l=o?this.resolveModelQuerySchemaName(s,c):`${a}ObjectSchema`,u=`${a}Schema`,d=n.type===this.name?l:i?u:l,f=n.isList?`.array()`:``,p=t.isRequired?``:`.optional()`;return r===1?` ${t.name}: z.lazy(() => ${e(d)})${f}${p}`:`z.lazy(() => ${e(d)})${f}${p}`}generateFieldValidators(e,t){let{isRequired:n,isNullable:r}=t;return n||(e+=`.optional()`),r&&(e+=`.nullable()`),e}prepareObjectSchema(e){let t=`${this.generateExportObjectSchemaStatement(this.addFinalWrappers({zodStringFields:e}))}\n`,n=this.generateImportPrismaStatement(),r=this.generateJsonSchemaImplementation();return`${this.generateObjectSchemaImportStatements()}${n}${r}${t}`}generateExportObjectSchemaStatement(t){let n=this.name,r=this.name;l.provider===`mongodb`&&s(n)&&(n=l.rawOpsMap[n],r=n.replace(`Args`,``)),o(n)&&(n=`${n}Type`);let i=`export const ${e(r)}ObjectSchema = schema`;return`const schema: z.ZodType<Prisma.${n}> = ${t};\n\n ${i}`}addFinalWrappers({zodStringFields:e}){let t=[...e];return`${this.wrapWithZodObject(t)}.strict()`}generateImportPrismaStatement(){let e;if(l.isCustomPrismaClientOutputPath){let t=c.join(l.outputPath,`schemas`,`objects`),n=l.prismaClientOutputPath;e=c.relative(t,n).split(c.sep).join(c.posix.sep)}else e=l.prismaClientOutputPath;return`import type { Prisma } from '${e}';\n\n`}generateJsonSchemaImplementation(){let e=``;return this.hasJson&&(e+=`
|
|
5
|
+
`,e+=`const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
6
|
+
`,e+=`const jsonSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>
|
|
7
|
+
`,e+=` z.union([literalSchema, z.array(jsonSchema.nullable()), z.record(jsonSchema.nullable())])
|
|
8
|
+
`,e+=`);
|
|
9
|
+
|
|
10
|
+
`),e}generateObjectSchemaImportStatements(){let e=this.generateImportZodStatement();return e+=this.generateSchemaImports(),e+=`
|
|
11
|
+
|
|
12
|
+
`,e}generateSchemaImports(){return[...this.schemaImports].map(t=>{let{isModelQueryType:n,modelName:r,queryName:i}=this.checkIsModelQueryType(t);return n?`import { ${this.resolveModelQuerySchemaName(r,i)} } from '../${i}${r}.schema'`:l.enumNames.includes(t)?`import { ${e(t)}Schema } from '../enums/${e(t)}.schema'`:`import { ${e(t)}ObjectSchema } from './${e(t)}.schema'`}).join(`;\r
|
|
13
|
+
`)}checkIsModelQueryType(e){let t={FindManyArgs:`findMany`};for(let n of[`FindManyArgs`])if(e.includes(n)){let r=e.indexOf(n);return{isModelQueryType:!0,modelName:e.substring(0,r),queryName:t[n]}}return{isModelQueryType:!1}}resolveModelQuerySchemaName(n,r){return`${e(n)}${t(r)}Schema`}wrapWithZodUnion(e){let t=``;return t+=`z.union([`,t+=`
|
|
14
|
+
`,t+=` ${e.join(`,`)}`,t+=`
|
|
15
|
+
`,t+=`])`,t}wrapWithZodObject(e){let t=``;return t+=`z.object({`,t+=`
|
|
16
|
+
`,t+=` ${typeof e==`string`?e:e.join(`,
|
|
17
|
+
`)}`,t+=`
|
|
18
|
+
`,t+=`})`,t}resolveObjectSchemaName(){let t=this.name,n=this.name;return s(t)&&(t=l.rawOpsMap[t],n=t.replace(`Args`,``)),e(n)}async generateModelSchemas(){for(let t of this.modelOperations){let{findUnique:n,findFirst:a,findMany:o,createOne:s,createMany:u,createManyAndReturn:d,deleteOne:f,updateOne:p,deleteMany:m,updateMany:h,updateManyAndReturn:g,upsertOne:_,aggregate:v,groupBy:y}=t,b=r(this.models,t.model),x=e(t.model),{selectImport:S,includeImport:C,selectZodSchemaLine:w,includeZodSchemaLine:T,selectZodSchemaLineLazy:E,includeZodSchemaLineLazy:D}=this.resolveSelectIncludeImportAndZodSchemaLine(b),{orderByImport:O,orderByZodSchemaLine:k}=this.resolveOrderByWithRelationImportAndZodSchemaLine(b);if(n){let e=[S,C,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`];await i(c.join(l.outputPath,`schemas/${n}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}FindUnique`,`z.object({ ${w} ${T} where: ${x}WhereUniqueInputObjectSchema })`)}`)}if(a){let e=[S,C,O,`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`,`import { ${x}ScalarFieldEnumSchema } from './enums/${x}ScalarFieldEnum.schema'`];await i(c.join(l.outputPath,`schemas/${a}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}FindFirst`,`z.object({ ${w} ${T} ${k} where: ${x}WhereInputObjectSchema.optional(), cursor: ${x}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${x}ScalarFieldEnumSchema).optional() })`)}`)}if(o){let e=[S,C,O,`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`,`import { ${x}ScalarFieldEnumSchema } from './enums/${x}ScalarFieldEnum.schema'`];await i(c.join(l.outputPath,`schemas/${o}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}FindMany`,`z.object({ ${E} ${D} ${k} where: ${x}WhereInputObjectSchema.optional(), cursor: ${x}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${x}ScalarFieldEnumSchema).optional() })`)}`)}if(s){let e=[S,C,`import { ${x}CreateInputObjectSchema } from './objects/${x}CreateInput.schema'`,`import { ${x}UncheckedCreateInputObjectSchema } from './objects/${x}UncheckedCreateInput.schema'`];await i(c.join(l.outputPath,`schemas/${s}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}CreateOne`,`z.object({ ${w} ${T} data: z.union([${x}CreateInputObjectSchema, ${x}UncheckedCreateInputObjectSchema]) })`)}`)}if(u){let e=[`import { ${x}CreateManyInputObjectSchema } from './objects/${x}CreateManyInput.schema'`];await i(c.join(l.outputPath,`schemas/${u}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}CreateMany`,`z.object({ data: z.union([ ${x}CreateManyInputObjectSchema, z.array(${x}CreateManyInputObjectSchema) ]), ${l.provider===`mongodb`||l.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(d){let e=[`import { ${x}CreateManyAndReturnInputObjectSchema } from './objects/${x}CreateManyAndReturnInput.schema'`];await i(c.join(l.outputPath,`schemas/${d}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}CreateManyAndReturn`,`z.object({ data: z.union([ ${x}CreateManyAndReturnInputObjectSchema, z.array(${x}CreateManyAndReturnInputObjectSchema) ]), ${l.provider===`mongodb`||l.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(f){let e=[S,C,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`];await i(c.join(l.outputPath,`schemas/${f}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}DeleteOne`,`z.object({ ${w} ${T} where: ${x}WhereUniqueInputObjectSchema })`)}`)}if(m){let e=[`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`];await i(c.join(l.outputPath,`schemas/${m}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}DeleteMany`,`z.object({ where: ${x}WhereInputObjectSchema.optional() })`)}`)}if(p){let e=[S,C,`import { ${x}UpdateInputObjectSchema } from './objects/${x}UpdateInput.schema'`,`import { ${x}UncheckedUpdateInputObjectSchema } from './objects/${x}UncheckedUpdateInput.schema'`,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`];await i(c.join(l.outputPath,`schemas/${p}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}UpdateOne`,`z.object({ ${w} ${T} data: z.union([${x}UpdateInputObjectSchema, ${x}UncheckedUpdateInputObjectSchema]), where: ${x}WhereUniqueInputObjectSchema })`)}`)}if(h){let e=[`import { ${x}UpdateManyMutationInputObjectSchema } from './objects/${x}UpdateManyMutationInput.schema'`,`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`];await i(c.join(l.outputPath,`schemas/${h}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}UpdateMany`,`z.object({ data: ${x}UpdateManyMutationInputObjectSchema, where: ${x}WhereInputObjectSchema.optional() })`)}`)}if(g){let e=[`import { ${x}UpdateManyAndReturnInputObjectSchema } from './objects/${x}UpdateManyAndReturnInput.schema'`];await i(c.join(l.outputPath,`schemas/${g}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}UpdateManyAndReturn`,`z.object({ data: z.union([ ${x}UpdateManyAndReturnInputObjectSchema, z.array(${x}UpdateManyAndReturnInputObjectSchema) ]), ${l.provider===`mongodb`||l.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(_){let e=[S,C,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`,`import { ${x}CreateInputObjectSchema } from './objects/${x}CreateInput.schema'`,`import { ${x}UncheckedCreateInputObjectSchema } from './objects/${x}UncheckedCreateInput.schema'`,`import { ${x}UpdateInputObjectSchema } from './objects/${x}UpdateInput.schema'`,`import { ${x}UncheckedUpdateInputObjectSchema } from './objects/${x}UncheckedUpdateInput.schema'`];await i(c.join(l.outputPath,`schemas/${_}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}Upsert`,`z.object({ ${w} ${T} where: ${x}WhereUniqueInputObjectSchema, create: z.union([ ${x}CreateInputObjectSchema, ${x}UncheckedCreateInputObjectSchema ]), update: z.union([ ${x}UpdateInputObjectSchema, ${x}UncheckedUpdateInputObjectSchema ]) })`)}`)}if(v){let e=[O,`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`,`import { ${x}WhereUniqueInputObjectSchema } from './objects/${x}WhereUniqueInput.schema'`],t=[];this.aggregateOperationSupport[x]&&(this.aggregateOperationSupport[x].count&&(e.push(`import { ${x}CountAggregateInputObjectSchema } from './objects/${x}CountAggregateInput.schema'`),t.push(`_count: z.union([ z.literal(true), ${x}CountAggregateInputObjectSchema ]).optional()`)),this.aggregateOperationSupport[x].min&&(e.push(`import { ${x}MinAggregateInputObjectSchema } from './objects/${x}MinAggregateInput.schema'`),t.push(`_min: ${x}MinAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[x].max&&(e.push(`import { ${x}MaxAggregateInputObjectSchema } from './objects/${x}MaxAggregateInput.schema'`),t.push(`_max: ${x}MaxAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[x].avg&&(e.push(`import { ${x}AvgAggregateInputObjectSchema } from './objects/${x}AvgAggregateInput.schema'`),t.push(`_avg: ${x}AvgAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[x].sum&&(e.push(`import { ${x}SumAggregateInputObjectSchema } from './objects/${x}SumAggregateInput.schema'`),t.push(`_sum: ${x}SumAggregateInputObjectSchema.optional()`))),await i(c.join(l.outputPath,`schemas/${v}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}Aggregate`,`z.object({ ${k} where: ${x}WhereInputObjectSchema.optional(), cursor: ${x}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), ${t.join(`, `)} })`)}`)}if(y){let e=[`import { ${x}WhereInputObjectSchema } from './objects/${x}WhereInput.schema'`,`import { ${x}OrderByWithAggregationInputObjectSchema } from './objects/${x}OrderByWithAggregationInput.schema'`,`import { ${x}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${x}ScalarWhereWithAggregatesInput.schema'`,`import { ${x}ScalarFieldEnumSchema } from './enums/${x}ScalarFieldEnum.schema'`];await i(c.join(l.outputPath,`schemas/${y}.schema.ts`),`${this.generateImportStatements(e)}${this.generateExportSchemaStatement(`${x}GroupBy`,`z.object({ where: ${x}WhereInputObjectSchema.optional(), orderBy: z.union([${x}OrderByWithAggregationInputObjectSchema, ${x}OrderByWithAggregationInputObjectSchema.array()]).optional(), having: ${x}ScalarWhereWithAggregatesInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), by: z.array(${x}ScalarFieldEnumSchema) })`)}`)}}}generateImportStatements(e){let t=this.generateImportZodStatement();return t+=e?.filter(e=>!!e).join(`;\r
|
|
19
|
+
`)??``,t+=`
|
|
20
|
+
|
|
21
|
+
`,t}resolveSelectIncludeImportAndZodSchemaLine(t){let{name:r}=t,i=n(t),a=l.isGenerateSelect?`import { ${e(r)}SelectObjectSchema } from './objects/${e(r)}Select.schema'`:``,o=l.isGenerateInclude&&i?`import { ${e(r)}IncludeObjectSchema } from './objects/${e(r)}Include.schema'`:``,s=``,c=``,u=``,d=``;if(l.isGenerateSelect){let t=`${e(r)}SelectObjectSchema.optional()`;s=`select: ${t},`,u=`select: z.lazy(() => ${t}),`}if(l.isGenerateInclude&&i){let t=`${e(r)}IncludeObjectSchema.optional()`;c=`include: ${t},`,d=`include: z.lazy(() => ${t}),`}return{selectImport:a,includeImport:o,selectZodSchemaLine:s,includeZodSchemaLine:c,selectZodSchemaLineLazy:u,includeZodSchemaLineLazy:d}}resolveOrderByWithRelationImportAndZodSchemaLine(t){let{name:n}=t,r=``;return r=[`postgresql`,`mysql`].includes(l.provider)&&l.previewFeatures?.includes(`fullTextSearch`)?`${e(n)}OrderByWithRelationAndSearchRelevanceInput`:`${e(n)}OrderByWithRelationInput`,{orderByImport:`import { ${r}ObjectSchema } from './objects/${r}.schema'`,orderByZodSchemaLine:`orderBy: z.union([${r}ObjectSchema, ${r}ObjectSchema.array()]).optional(),`}}};export{l as default};
|
|
22
|
+
//# sourceMappingURL=transformer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer.mjs","names":["line: string","prismaClientImportPath: string","modelQueryTypeSuffixToQueryName: Record<string, string>"],"sources":["../../src/zod/transformer.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 {\n ConnectorType,\n DMMF as PrismaDMMF\n} from \"@prisma/generator-helper\";\nimport { lowerCaseFirst } from \"@stryke/string-format/lower-case-first\";\nimport { upperCaseFirst } from \"@stryke/string-format/upper-case-first\";\nimport path from \"node:path\";\nimport type {\n AggregateOperationSupport,\n TransformerParams,\n Writeable\n} from \"../types\";\nimport { writeFileSafely, writeIndexFile } from \"../utils/write-file-safely\";\nimport { isAggregateInputType } from \"./aggregate-helpers\";\nimport { checkModelHasModelRelation, findModelByName } from \"./model-helpers\";\nimport { isMongodbRawOp } from \"./mongodb-helpers\";\n\nexport default class Transformer {\n name: string;\n\n fields: Writeable<PrismaDMMF.SchemaArg[]>;\n\n schemaImports = new Set<string>();\n\n models: Writeable<PrismaDMMF.Model[]>;\n\n modelOperations: Writeable<PrismaDMMF.ModelMapping[]>;\n\n aggregateOperationSupport: AggregateOperationSupport;\n\n enumTypes: Writeable<PrismaDMMF.SchemaEnum[]>;\n\n static enumNames: string[] = [];\n\n static rawOpsMap: { [name: string]: string } = {};\n\n static provider: ConnectorType;\n\n static previewFeatures: string[] | undefined;\n\n private static outputPath: string = \"./generated\";\n\n private hasJson = false;\n\n private static prismaClientOutputPath: string = \"@prisma/client\";\n\n private static isCustomPrismaClientOutputPath: boolean = false;\n\n private static isGenerateSelect: boolean = true;\n\n private static isGenerateInclude: boolean = true;\n\n constructor(params: Writeable<TransformerParams>) {\n this.name = params.name ?? \"\";\n this.fields = params.fields ?? [];\n this.models = params.models ?? [];\n this.modelOperations = params.modelOperations ?? [];\n this.aggregateOperationSupport = params.aggregateOperationSupport ?? {};\n this.enumTypes = params.enumTypes ?? [];\n }\n\n static setOutputPath(outPath: string) {\n this.outputPath = outPath;\n }\n\n static setIsGenerateSelect(isGenerateSelect: boolean) {\n this.isGenerateSelect = isGenerateSelect;\n }\n\n static setIsGenerateInclude(isGenerateInclude: boolean) {\n this.isGenerateInclude = isGenerateInclude;\n }\n\n static getOutputPath() {\n return this.outputPath;\n }\n\n static setPrismaClientOutputPath(prismaClientCustomPath: string) {\n this.prismaClientOutputPath = prismaClientCustomPath;\n this.isCustomPrismaClientOutputPath =\n prismaClientCustomPath !== \"@prisma/client\";\n }\n\n static async generateIndex() {\n const indexPath = path.join(Transformer.outputPath, \"schemas/index.ts\");\n await writeIndexFile(indexPath);\n }\n\n async generateEnumSchemas() {\n for (const enumType of this.enumTypes) {\n const { name, values } = enumType;\n\n await writeFileSafely(\n path.join(\n Transformer.outputPath,\n `schemas/enums/${lowerCaseFirst(name)}.schema.ts`\n ),\n `${this.generateImportZodStatement()}\\n${this.generateExportSchemaStatement(\n `${lowerCaseFirst(name)}`,\n `z.enum(${JSON.stringify(values)})`\n )}`\n );\n }\n }\n\n generateImportZodStatement() {\n return \"import { z } from 'zod';\\n\";\n }\n\n generateExportSchemaStatement(name: string, schema: string) {\n return `export const ${lowerCaseFirst(name)}Schema = ${schema}`;\n }\n\n async generateObjectSchema() {\n const zodObjectSchemaFields = this.generateObjectSchemaFields();\n const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);\n const objectSchemaName = this.resolveObjectSchemaName();\n\n await writeFileSafely(\n path.join(\n Transformer.outputPath,\n `schemas/objects/${lowerCaseFirst(objectSchemaName)}.schema.ts`\n ),\n objectSchema\n );\n }\n\n generateObjectSchemaFields() {\n const zodObjectSchemaFields = this.fields\n .map(field => this.generateObjectSchemaField(field))\n .flatMap(item => item)\n .map(item => {\n const [zodStringWithMainType, field, skipValidators] = item;\n\n const value = skipValidators\n ? zodStringWithMainType\n : this.generateFieldValidators(zodStringWithMainType, field);\n\n return value.trim();\n });\n\n return zodObjectSchemaFields;\n }\n\n generateObjectSchemaField(\n field: PrismaDMMF.SchemaArg\n ): [string, PrismaDMMF.SchemaArg, boolean][] {\n const lines = field.inputTypes;\n\n if (lines.length === 0) {\n return [];\n }\n\n let alternatives = lines.reduce<string[]>((result, inputType) => {\n if (inputType.type === \"String\") {\n result.push(this.wrapWithZodValidators(\"z.string()\", field));\n } else if (\n inputType.type === \"Int\" ||\n inputType.type === \"Float\" ||\n inputType.type === \"Decimal\"\n ) {\n result.push(this.wrapWithZodValidators(\"z.number()\", field));\n } else if (inputType.type === \"BigInt\") {\n result.push(this.wrapWithZodValidators(\"z.bigint()\", field));\n } else if (inputType.type === \"Boolean\") {\n result.push(this.wrapWithZodValidators(\"z.boolean()\", field));\n } else if (inputType.type === \"DateTime\") {\n result.push(this.wrapWithZodValidators(\"z.coerce.date()\", field));\n } else if (inputType.type === \"Json\") {\n this.hasJson = true;\n\n result.push(this.wrapWithZodValidators(\"jsonSchema\", field));\n } else if (inputType.type === \"True\") {\n result.push(this.wrapWithZodValidators(\"z.literal(true)\", field));\n } else if (inputType.type === \"Bytes\") {\n result.push(this.wrapWithZodValidators(\"z.instanceof(Buffer)\", field));\n } else if (!inputType.type.endsWith(\"FieldRefInput\")) {\n const isEnum = inputType.location === \"enumTypes\";\n\n if (inputType.namespace === \"prisma\" || isEnum) {\n if (\n inputType.type !== this.name &&\n typeof inputType.type === \"string\"\n ) {\n this.addSchemaImport(inputType.type);\n }\n\n result.push(\n this.generatePrismaStringLine(field, inputType, lines.length)\n );\n }\n }\n\n return result;\n }, []);\n\n if (alternatives.length === 0) {\n return [];\n }\n\n if (alternatives.length > 1) {\n alternatives = alternatives.map(alter =>\n alter.replace(\".optional()\", \"\")\n );\n }\n\n const fieldName = alternatives.some(alt => alt.includes(\":\"))\n ? \"\"\n : ` ${field.name}:`;\n\n const opt = !field.isRequired ? \".optional()\" : \"\";\n\n let resString =\n alternatives.length === 1\n ? alternatives.join(\",\\r\\n\")\n : `z.union([${alternatives.join(\",\\r\\n\")}])${opt}`;\n\n if (field.isNullable) {\n resString += \".nullable()\";\n }\n\n return [[` ${fieldName} ${resString} `, field, true]];\n }\n\n wrapWithZodValidators(mainValidator: string, field: PrismaDMMF.SchemaArg) {\n let line: string = \"\";\n line = mainValidator;\n\n if (field.inputTypes.some(inputType => inputType.isList)) {\n line += \".array()\";\n }\n\n if (!field.isRequired) {\n line += \".optional()\";\n }\n\n return line;\n }\n\n addSchemaImport(name: string) {\n this.schemaImports.add(name);\n }\n\n generatePrismaStringLine(\n field: PrismaDMMF.SchemaArg,\n inputType: PrismaDMMF.InputTypeRef,\n inputsLength: number\n ) {\n // if (field.inputTypes.length === 0 || !field.inputTypes[0]) {\n // return \"\";\n // }\n\n // const inputType = field.inputTypes[0];\n\n const isEnum = inputType.location === \"enumTypes\";\n\n const inputTypeString = inputType.type;\n const { isModelQueryType, modelName, queryName } =\n this.checkIsModelQueryType(inputTypeString);\n\n const objectSchemaLine = isModelQueryType\n ? this.resolveModelQuerySchemaName(modelName!, queryName!)\n : `${inputTypeString}ObjectSchema`;\n const enumSchemaLine = `${inputTypeString}Schema`;\n\n const schema =\n inputType.type === this.name\n ? objectSchemaLine\n : isEnum\n ? enumSchemaLine\n : objectSchemaLine;\n const arr = inputType.isList ? \".array()\" : \"\";\n const opt = !field.isRequired ? \".optional()\" : \"\";\n\n return inputsLength === 1\n ? ` ${field.name}: z.lazy(() => ${lowerCaseFirst(schema)})${arr}${opt}`\n : `z.lazy(() => ${lowerCaseFirst(schema)})${arr}${opt}`;\n }\n\n generateFieldValidators(\n zodStringWithMainType: string,\n field: PrismaDMMF.SchemaArg\n ) {\n const { isRequired, isNullable } = field;\n\n if (!isRequired) {\n zodStringWithMainType += \".optional()\";\n }\n\n if (isNullable) {\n zodStringWithMainType += \".nullable()\";\n }\n\n return zodStringWithMainType;\n }\n\n prepareObjectSchema(zodObjectSchemaFields: string[]) {\n const objectSchema = `${this.generateExportObjectSchemaStatement(\n this.addFinalWrappers({ zodStringFields: zodObjectSchemaFields })\n )}\\n`;\n\n const prismaImportStatement = this.generateImportPrismaStatement();\n\n const json = this.generateJsonSchemaImplementation();\n\n return `${this.generateObjectSchemaImportStatements()}${prismaImportStatement}${json}${objectSchema}`;\n }\n\n generateExportObjectSchemaStatement(schema: string) {\n let name = this.name;\n let exportName = this.name;\n if (Transformer.provider === \"mongodb\") {\n if (isMongodbRawOp(name)) {\n name = Transformer.rawOpsMap[name]!;\n exportName = name.replace(\"Args\", \"\");\n }\n }\n\n if (isAggregateInputType(name)) {\n name = `${name}Type`;\n }\n const end = `export const ${lowerCaseFirst(exportName)}ObjectSchema = schema`;\n\n return `const schema: z.ZodType<Prisma.${name}> = ${schema};\\n\\n ${end}`;\n }\n\n addFinalWrappers({ zodStringFields }: { zodStringFields: string[] }) {\n const fields = [...zodStringFields];\n\n return `${this.wrapWithZodObject(fields)}.strict()`;\n }\n\n generateImportPrismaStatement() {\n let prismaClientImportPath: string;\n if (Transformer.isCustomPrismaClientOutputPath) {\n /**\n * If a custom location was designated for the prisma client, we need to figure out the\n * relative path from \\{outputPath\\}/schemas/objects to \\{prismaClientCustomPath\\}\n */\n const fromPath = path.join(Transformer.outputPath, \"schemas\", \"objects\");\n const toPath = Transformer.prismaClientOutputPath;\n const relativePathFromOutputToPrismaClient = path\n .relative(fromPath, toPath)\n .split(path.sep)\n .join(path.posix.sep);\n prismaClientImportPath = relativePathFromOutputToPrismaClient;\n } else {\n /**\n * If the default output path for prisma client (\\@prisma/client) is being used, we can import from it directly\n * without having to resolve a relative path\n */\n prismaClientImportPath = Transformer.prismaClientOutputPath;\n }\n return `import type { Prisma } from '${prismaClientImportPath}';\\n\\n`;\n }\n\n generateJsonSchemaImplementation() {\n let jsonSchemaImplementation = \"\";\n\n if (this.hasJson) {\n jsonSchemaImplementation += `\\n`;\n jsonSchemaImplementation += `const literalSchema = z.union([z.string(), z.number(), z.boolean()]);\\n`;\n jsonSchemaImplementation += `const jsonSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>\\n`;\n jsonSchemaImplementation += ` z.union([literalSchema, z.array(jsonSchema.nullable()), z.record(jsonSchema.nullable())])\\n`;\n jsonSchemaImplementation += `);\\n\\n`;\n }\n\n return jsonSchemaImplementation;\n }\n\n generateObjectSchemaImportStatements() {\n let generatedImports = this.generateImportZodStatement();\n generatedImports += this.generateSchemaImports();\n generatedImports += \"\\n\\n\";\n return generatedImports;\n }\n\n generateSchemaImports() {\n return [...this.schemaImports]\n .map(name => {\n const { isModelQueryType, modelName, queryName } =\n this.checkIsModelQueryType(name);\n if (isModelQueryType) {\n return `import { ${this.resolveModelQuerySchemaName(\n modelName!,\n queryName!\n )} } from '../${queryName}${modelName}.schema'`;\n } else if (Transformer.enumNames.includes(name)) {\n return `import { ${lowerCaseFirst(name)}Schema } from '../enums/${lowerCaseFirst(name)}.schema'`;\n } else {\n return `import { ${lowerCaseFirst(name)}ObjectSchema } from './${lowerCaseFirst(name)}.schema'`;\n }\n })\n .join(\";\\r\\n\");\n }\n\n checkIsModelQueryType(type: string) {\n const modelQueryTypeSuffixToQueryName: Record<string, string> = {\n FindManyArgs: \"findMany\"\n };\n for (const modelQueryType of [\"FindManyArgs\"]) {\n if (type.includes(modelQueryType)) {\n const modelQueryTypeSuffixIndex = type.indexOf(modelQueryType);\n\n return {\n isModelQueryType: true,\n modelName: type.substring(0, modelQueryTypeSuffixIndex),\n queryName: modelQueryTypeSuffixToQueryName[modelQueryType]\n };\n }\n }\n return { isModelQueryType: false };\n }\n\n resolveModelQuerySchemaName(modelName: string, queryName: string) {\n const modelNameUncapitalized = lowerCaseFirst(modelName);\n const queryNameCapitalized = upperCaseFirst(queryName);\n\n return `${modelNameUncapitalized}${queryNameCapitalized}Schema`;\n }\n\n wrapWithZodUnion(zodStringFields: string[]) {\n let wrapped = \"\";\n\n wrapped += \"z.union([\";\n wrapped += \"\\n\";\n wrapped += ` ${zodStringFields.join(\",\")}`;\n wrapped += \"\\n\";\n wrapped += \"])\";\n return wrapped;\n }\n\n wrapWithZodObject(zodStringFields: string | string[]) {\n let wrapped = \"\";\n\n wrapped += \"z.object({\";\n wrapped += \"\\n\";\n wrapped += ` ${typeof zodStringFields === \"string\" ? zodStringFields : zodStringFields.join(\",\\n \")}`;\n wrapped += \"\\n\";\n wrapped += \"})\";\n return wrapped;\n }\n\n resolveObjectSchemaName() {\n let name = this.name;\n let exportName = this.name;\n if (isMongodbRawOp(name)) {\n name = Transformer.rawOpsMap[name]!;\n exportName = name.replace(\"Args\", \"\");\n }\n\n return lowerCaseFirst(exportName);\n }\n\n async generateModelSchemas() {\n for (const modelOperation of this.modelOperations) {\n const {\n findUnique,\n findFirst,\n findMany,\n // @ts-ignore\n createOne,\n createMany,\n createManyAndReturn,\n // @ts-ignore\n deleteOne,\n // @ts-ignore\n updateOne,\n deleteMany,\n updateMany,\n updateManyAndReturn,\n // @ts-ignore\n upsertOne,\n aggregate,\n groupBy\n } = modelOperation;\n\n const model = findModelByName(this.models, modelOperation.model)!;\n const modelName = lowerCaseFirst(modelOperation.model)!;\n\n const {\n selectImport,\n includeImport,\n selectZodSchemaLine,\n includeZodSchemaLine,\n selectZodSchemaLineLazy,\n includeZodSchemaLineLazy\n } = this.resolveSelectIncludeImportAndZodSchemaLine(model);\n\n const { orderByImport, orderByZodSchemaLine } =\n this.resolveOrderByWithRelationImportAndZodSchemaLine(model);\n\n if (findUnique) {\n const imports = [\n selectImport,\n includeImport,\n `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${findUnique}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}FindUnique`,\n `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`\n )}`\n );\n }\n\n if (findFirst) {\n const imports = [\n selectImport,\n includeImport,\n orderByImport,\n `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,\n `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,\n `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${findFirst}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}FindFirst`,\n `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`\n )}`\n );\n }\n\n if (findMany) {\n const imports = [\n selectImport,\n includeImport,\n orderByImport,\n `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,\n `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,\n `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${findMany}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}FindMany`,\n `z.object({ ${selectZodSchemaLineLazy} ${includeZodSchemaLineLazy} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`\n )}`\n );\n }\n\n if (createOne) {\n const imports = [\n selectImport,\n includeImport,\n `import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,\n `import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${createOne}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}CreateOne`,\n `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema]) })`\n )}`\n );\n }\n\n if (createMany) {\n const imports = [\n `import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${createMany}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}CreateMany`,\n `z.object({ data: z.union([ ${modelName}CreateManyInputObjectSchema, z.array(${modelName}CreateManyInputObjectSchema) ]), ${\n Transformer.provider === \"mongodb\" ||\n Transformer.provider === \"sqlserver\"\n ? \"\"\n : \"skipDuplicates: z.boolean().optional()\"\n } })`\n )}`\n );\n }\n\n if (createManyAndReturn) {\n const imports = [\n `import { ${modelName}CreateManyAndReturnInputObjectSchema } from './objects/${modelName}CreateManyAndReturnInput.schema'`\n ];\n await writeFileSafely(\n path.join(\n Transformer.outputPath,\n `schemas/${createManyAndReturn}.schema.ts`\n ),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}CreateManyAndReturn`,\n `z.object({ data: z.union([ ${modelName}CreateManyAndReturnInputObjectSchema, z.array(${modelName}CreateManyAndReturnInputObjectSchema) ]), ${\n Transformer.provider === \"mongodb\" ||\n Transformer.provider === \"sqlserver\"\n ? \"\"\n : \"skipDuplicates: z.boolean().optional()\"\n } })`\n )}`\n );\n }\n\n if (deleteOne) {\n const imports = [\n selectImport,\n includeImport,\n `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${deleteOne}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}DeleteOne`,\n `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`\n )}`\n );\n }\n\n if (deleteMany) {\n const imports = [\n `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${deleteMany}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}DeleteMany`,\n `z.object({ where: ${modelName}WhereInputObjectSchema.optional() })`\n )}`\n );\n }\n\n if (updateOne) {\n const imports = [\n selectImport,\n includeImport,\n `import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,\n `import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,\n `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${updateOne}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}UpdateOne`,\n `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema]), where: ${modelName}WhereUniqueInputObjectSchema })`\n )}`\n );\n }\n\n if (updateMany) {\n const imports = [\n `import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,\n `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${updateMany}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}UpdateMany`,\n `z.object({ data: ${modelName}UpdateManyMutationInputObjectSchema, where: ${modelName}WhereInputObjectSchema.optional() })`\n )}`\n );\n }\n\n if (updateManyAndReturn) {\n const imports = [\n `import { ${modelName}UpdateManyAndReturnInputObjectSchema } from './objects/${modelName}UpdateManyAndReturnInput.schema'`\n ];\n await writeFileSafely(\n path.join(\n Transformer.outputPath,\n `schemas/${updateManyAndReturn}.schema.ts`\n ),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}UpdateManyAndReturn`,\n `z.object({ data: z.union([ ${modelName}UpdateManyAndReturnInputObjectSchema, z.array(${modelName}UpdateManyAndReturnInputObjectSchema) ]), ${\n Transformer.provider === \"mongodb\" ||\n Transformer.provider === \"sqlserver\"\n ? \"\"\n : \"skipDuplicates: z.boolean().optional()\"\n } })`\n )}`\n );\n }\n\n if (upsertOne) {\n const imports = [\n selectImport,\n includeImport,\n `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,\n `import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,\n `import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`,\n `import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,\n `import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${upsertOne}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}Upsert`,\n `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema, create: z.union([ ${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema ]), update: z.union([ ${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema ]) })`\n )}`\n );\n }\n\n if (aggregate) {\n const imports = [\n orderByImport,\n `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,\n `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`\n ];\n const aggregateOperations = [];\n if (this.aggregateOperationSupport[modelName]) {\n if (this.aggregateOperationSupport[modelName].count) {\n imports.push(\n `import { ${modelName}CountAggregateInputObjectSchema } from './objects/${modelName}CountAggregateInput.schema'`\n );\n aggregateOperations.push(\n `_count: z.union([ z.literal(true), ${modelName}CountAggregateInputObjectSchema ]).optional()`\n );\n }\n if (this.aggregateOperationSupport[modelName].min) {\n imports.push(\n `import { ${modelName}MinAggregateInputObjectSchema } from './objects/${modelName}MinAggregateInput.schema'`\n );\n aggregateOperations.push(\n `_min: ${modelName}MinAggregateInputObjectSchema.optional()`\n );\n }\n if (this.aggregateOperationSupport[modelName].max) {\n imports.push(\n `import { ${modelName}MaxAggregateInputObjectSchema } from './objects/${modelName}MaxAggregateInput.schema'`\n );\n aggregateOperations.push(\n `_max: ${modelName}MaxAggregateInputObjectSchema.optional()`\n );\n }\n if (this.aggregateOperationSupport[modelName].avg) {\n imports.push(\n `import { ${modelName}AvgAggregateInputObjectSchema } from './objects/${modelName}AvgAggregateInput.schema'`\n );\n aggregateOperations.push(\n `_avg: ${modelName}AvgAggregateInputObjectSchema.optional()`\n );\n }\n if (this.aggregateOperationSupport[modelName].sum) {\n imports.push(\n `import { ${modelName}SumAggregateInputObjectSchema } from './objects/${modelName}SumAggregateInput.schema'`\n );\n aggregateOperations.push(\n `_sum: ${modelName}SumAggregateInputObjectSchema.optional()`\n );\n }\n }\n\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${aggregate}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}Aggregate`,\n `z.object({ ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), ${aggregateOperations.join(\n \", \"\n )} })`\n )}`\n );\n }\n\n if (groupBy) {\n const imports = [\n `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,\n `import { ${modelName}OrderByWithAggregationInputObjectSchema } from './objects/${modelName}OrderByWithAggregationInput.schema'`,\n `import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,\n `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`\n ];\n await writeFileSafely(\n path.join(Transformer.outputPath, `schemas/${groupBy}.schema.ts`),\n `${this.generateImportStatements(\n imports\n )}${this.generateExportSchemaStatement(\n `${modelName}GroupBy`,\n `z.object({ where: ${modelName}WhereInputObjectSchema.optional(), orderBy: z.union([${modelName}OrderByWithAggregationInputObjectSchema, ${modelName}OrderByWithAggregationInputObjectSchema.array()]).optional(), having: ${modelName}ScalarWhereWithAggregatesInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), by: z.array(${modelName}ScalarFieldEnumSchema) })`\n )}`\n );\n }\n }\n }\n\n generateImportStatements(imports: (string | undefined)[]) {\n let generatedImports = this.generateImportZodStatement();\n generatedImports +=\n imports?.filter(importItem => !!importItem).join(\";\\r\\n\") ?? \"\";\n generatedImports += \"\\n\\n\";\n return generatedImports;\n }\n\n resolveSelectIncludeImportAndZodSchemaLine(model: PrismaDMMF.Model) {\n const { name: modelName } = model;\n\n const hasRelationToAnotherModel = checkModelHasModelRelation(model);\n\n const selectImport = Transformer.isGenerateSelect\n ? `import { ${lowerCaseFirst(modelName)}SelectObjectSchema } from './objects/${lowerCaseFirst(modelName)}Select.schema'`\n : \"\";\n\n const includeImport =\n Transformer.isGenerateInclude && hasRelationToAnotherModel\n ? `import { ${lowerCaseFirst(modelName)}IncludeObjectSchema } from './objects/${lowerCaseFirst(modelName)}Include.schema'`\n : \"\";\n\n let selectZodSchemaLine = \"\";\n let includeZodSchemaLine = \"\";\n let selectZodSchemaLineLazy = \"\";\n let includeZodSchemaLineLazy = \"\";\n\n if (Transformer.isGenerateSelect) {\n const zodSelectObjectSchema = `${lowerCaseFirst(modelName)}SelectObjectSchema.optional()`;\n selectZodSchemaLine = `select: ${zodSelectObjectSchema},`;\n selectZodSchemaLineLazy = `select: z.lazy(() => ${zodSelectObjectSchema}),`;\n }\n\n if (Transformer.isGenerateInclude && hasRelationToAnotherModel) {\n const zodIncludeObjectSchema = `${lowerCaseFirst(modelName)}IncludeObjectSchema.optional()`;\n includeZodSchemaLine = `include: ${zodIncludeObjectSchema},`;\n includeZodSchemaLineLazy = `include: z.lazy(() => ${zodIncludeObjectSchema}),`;\n }\n\n return {\n selectImport,\n includeImport,\n selectZodSchemaLine,\n includeZodSchemaLine,\n selectZodSchemaLineLazy,\n includeZodSchemaLineLazy\n };\n }\n\n resolveOrderByWithRelationImportAndZodSchemaLine(model: PrismaDMMF.Model) {\n const { name: modelName } = model;\n let modelOrderBy = \"\";\n\n if (\n [\"postgresql\", \"mysql\"].includes(Transformer.provider) &&\n Transformer.previewFeatures?.includes(\"fullTextSearch\")\n ) {\n modelOrderBy = `${lowerCaseFirst(modelName)}OrderByWithRelationAndSearchRelevanceInput`;\n } else {\n modelOrderBy = `${lowerCaseFirst(modelName)}OrderByWithRelationInput`;\n }\n\n const orderByImport = `import { ${modelOrderBy}ObjectSchema } from './objects/${modelOrderBy}.schema'`;\n const orderByZodSchemaLine = `orderBy: z.union([${modelOrderBy}ObjectSchema, ${modelOrderBy}ObjectSchema.array()]).optional(),`;\n\n return { orderByImport, orderByZodSchemaLine };\n }\n}\n"],"mappings":"keAkCA,IAAqB,EAArB,MAAqB,CAAY,CAC/B,KAEA,OAEA,cAAgB,IAAI,IAEpB,OAEA,gBAEA,0BAEA,UAEA,OAAO,UAAsB,EAAE,CAE/B,OAAO,UAAwC,EAAE,CAEjD,OAAO,SAEP,OAAO,gBAEP,OAAe,WAAqB,cAEpC,QAAkB,GAElB,OAAe,uBAAiC,iBAEhD,OAAe,+BAA0C,GAEzD,OAAe,iBAA4B,GAE3C,OAAe,kBAA6B,GAE5C,YAAY,EAAsC,CAChD,KAAK,KAAO,EAAO,MAAQ,GAC3B,KAAK,OAAS,EAAO,QAAU,EAAE,CACjC,KAAK,OAAS,EAAO,QAAU,EAAE,CACjC,KAAK,gBAAkB,EAAO,iBAAmB,EAAE,CACnD,KAAK,0BAA4B,EAAO,2BAA6B,EAAE,CACvE,KAAK,UAAY,EAAO,WAAa,EAAE,CAGzC,OAAO,cAAc,EAAiB,CACpC,KAAK,WAAa,EAGpB,OAAO,oBAAoB,EAA2B,CACpD,KAAK,iBAAmB,EAG1B,OAAO,qBAAqB,EAA4B,CACtD,KAAK,kBAAoB,EAG3B,OAAO,eAAgB,CACrB,OAAO,KAAK,WAGd,OAAO,0BAA0B,EAAgC,CAC/D,KAAK,uBAAyB,EAC9B,KAAK,+BACH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EACb,EAGT,2CAA2C,EAAyB,CAClE,GAAM,CAAE,KAAM,GAAc,EAEtB,EAA4B,EAA2B,EAAM,CAE7D,EAAe,EAAY,iBAC7B,YAAY,EAAe,EAAU,CAAC,uCAAuC,EAAe,EAAU,CAAC,gBACvG,GAEE,EACJ,EAAY,mBAAqB,EAC7B,YAAY,EAAe,EAAU,CAAC,wCAAwC,EAAe,EAAU,CAAC,iBACxG,GAEF,EAAsB,GACtB,EAAuB,GACvB,EAA0B,GAC1B,EAA2B,GAE/B,GAAI,EAAY,iBAAkB,CAChC,IAAM,EAAwB,GAAG,EAAe,EAAU,CAAC,+BAC3D,EAAsB,WAAW,EAAsB,GACvD,EAA0B,wBAAwB,EAAsB,IAG1E,GAAI,EAAY,mBAAqB,EAA2B,CAC9D,IAAM,EAAyB,GAAG,EAAe,EAAU,CAAC,gCAC5D,EAAuB,YAAY,EAAuB,GAC1D,EAA2B,yBAAyB,EAAuB,IAG7E,MAAO,CACL,eACA,gBACA,sBACA,uBACA,0BACA,2BACD,CAGH,iDAAiD,EAAyB,CACxE,GAAM,CAAE,KAAM,GAAc,EACxB,EAAe,GAcnB,MAZA,CAME,EALA,CAAC,aAAc,QAAQ,CAAC,SAAS,EAAY,SAAS,EACtD,EAAY,iBAAiB,SAAS,iBAAiB,CAExC,GAAG,EAAe,EAAU,CAAC,4CAE7B,GAAG,EAAe,EAAU,CAAC,0BAMvC,CAAE,cAHa,YAAY,EAAa,iCAAiC,EAAa,UAGrE,qBAFK,qBAAqB,EAAa,gBAAgB,EAAa,oCAE9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){e.map(e=>(e.name.includes(`WhereUniqueInput`)&&e.constraints.fields?.length>0&&(e.fields=e.fields.map(t=>(e.constraints.fields?.includes(t.name)&&(t.isRequired=!0),t))),e))}exports.changeOptionalToRequiredFields=e;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){e.map(e=>(e.name.includes(`WhereUniqueInput`)&&e.constraints.fields?.length>0&&(e.fields=e.fields.map(t=>(e.constraints.fields?.includes(t.name)&&(t.isRequired=!0),t))),e))}export{e as changeOptionalToRequiredFields};
|
|
2
|
+
//# sourceMappingURL=whereUniqueInput-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whereUniqueInput-helpers.mjs","names":[],"sources":["../../src/zod/whereUniqueInput-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 { ArrayValues } from \"@stryke/types/array\";\nimport type { Writeable } from \"../types\";\n\nexport function changeOptionalToRequiredFields(\n inputObjectTypes: Writeable<DMMF.InputType[]>\n) {\n inputObjectTypes.map((item: Writeable<DMMF.InputType>) => {\n if (\n item.name.includes(\"WhereUniqueInput\") &&\n // eslint-disable-next-line ts/no-non-null-asserted-optional-chain\n item.constraints.fields?.length! > 0\n ) {\n item.fields = item.fields.map(\n (subItem: Writeable<ArrayValues<DMMF.InputType[\"fields\"]>>) => {\n if (item.constraints.fields?.includes(subItem.name)) {\n subItem.isRequired = true;\n return subItem;\n }\n return subItem;\n }\n );\n }\n return item;\n });\n}\n"],"mappings":"AAqBA,SAAgB,EACd,EACA,CACA,EAAiB,IAAK,IAElB,EAAK,KAAK,SAAS,mBAAmB,EAEtC,EAAK,YAAY,QAAQ,OAAU,IAEnC,EAAK,OAAS,EAAK,OAAO,IACvB,IACK,EAAK,YAAY,QAAQ,SAAS,EAAQ,KAAK,GACjD,EAAQ,WAAa,IAGhB,GAEV,EAEI,GACP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/prisma-trpc-generator",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A fork of the prisma-trpc-generator code to work in ESM with Prisma v6.",
|
|
6
6
|
"repository": {
|
|
@@ -64,22 +64,22 @@
|
|
|
64
64
|
"sullivanpj"
|
|
65
65
|
],
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@prisma/generator-helper": "^6.19.
|
|
68
|
-
"@prisma/internals": "^6.19.
|
|
69
|
-
"@stryke/fs": "^0.33.
|
|
70
|
-
"@stryke/path": "^0.22.
|
|
67
|
+
"@prisma/generator-helper": "^6.19.1",
|
|
68
|
+
"@prisma/internals": "^6.19.1",
|
|
69
|
+
"@stryke/fs": "^0.33.21",
|
|
70
|
+
"@stryke/path": "^0.22.12",
|
|
71
71
|
"esbuild": "^0.25.12",
|
|
72
72
|
"jiti": "^2.6.1",
|
|
73
73
|
"parenthesis": "^3.1.8",
|
|
74
74
|
"prettier": "^3.7.4",
|
|
75
75
|
"ts-morph": "^25.0.1",
|
|
76
|
-
"zod": "^4.1
|
|
76
|
+
"zod": "^4.2.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@types/pluralize": "^0.0.33",
|
|
80
80
|
"pluralize": "^8.0.0",
|
|
81
|
-
"tsdown": "^0.17.
|
|
81
|
+
"tsdown": "^0.17.2"
|
|
82
82
|
},
|
|
83
83
|
"publishConfig": { "access": "public" },
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "8f2e484743eb3ce54929e99096ca2ea188b4730e"
|
|
85
85
|
}
|