@stryke/prisma-trpc-generator
Version:
A fork of the prisma-trpc-generator code to work in ESM with Prisma v6.
1 lines • 2.06 kB
Source Map (JSON)
{"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 at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\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":";AAsBA,SAAgB,+BACd,kBACA;AACA,kBAAiB,KAAK,SAAoC;AACxD,MACE,KAAK,KAAK,SAAS,mBAAmB,IAEtC,KAAK,YAAY,QAAQ,SAAU,EAEnC,MAAK,SAAS,KAAK,OAAO,KACvB,YAA8D;AAC7D,OAAI,KAAK,YAAY,QAAQ,SAAS,QAAQ,KAAK,EAAE;AACnD,YAAQ,aAAa;AACrB,WAAO;;AAET,UAAO;IAEV;AAEH,SAAO;GACP"}