@versantonlinesolutions/prismabox 2.2.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Ade Yahya Prasetyo, 2024 m1212e
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # prismabox
2
+ Generate versatile [typebox](https://github.com/sinclairzx81/typebox) schemes from your [prisma](https://github.com/prisma) schema.
3
+
4
+ > Currently does not support [mongoDB composite types](https://www.prisma.io/docs/orm/prisma-schema/data-model/models#defining-composite-types)
5
+
6
+ > Development is currently on hold, please see [here](https://github.com/m1212e/prismabox/issues/59)
7
+
8
+ Install it in your project,
9
+ ```bash
10
+ npm i -D prismabox
11
+ pnpm i -D prismabox
12
+ bun add -D prismabox
13
+ ```
14
+
15
+ then add
16
+ ```prisma
17
+ generator prismabox {
18
+ provider = "prismabox"
19
+ // you can optionally specify the output location. Defaults to ./prismabox
20
+ output = "./myCoolPrismaboxDirectory"
21
+ // if you want, you can customize the imported variable name that is used for the schemes. Defaults to "Type" which is what the standard typebox package offers
22
+ typeboxImportVariableName = "t"
23
+ // you also can specify the dependency from which the above import should happen. This is useful if a package re-exports the typebox package and you would like to use that
24
+ typeboxImportDependencyName = "elysia"
25
+ // by default the generated schemes do not allow additional properties. You can allow them by setting this to true
26
+ additionalProperties = true
27
+ // optionally enable the data model generation. See the data model section below for more info
28
+ inputModel = true
29
+ }
30
+ ```
31
+ to your `prisma.schema`. You can modify the settings to your liking, please see the respective comments for info on what the option does.
32
+ > There are additional config options available which are mostly irrelevant to the average user. Please see [config.ts](src/config.ts) for all available options.
33
+
34
+ ## Annotations
35
+ Prismabox offers annotations to adjust the output of models and fields.
36
+
37
+ | Annotation | Example | Description |
38
+ ---|---|---
39
+ | @prismabox.hide | - | Hides the field or model from the output |
40
+ | @prismabox.hidden | - | Alias for @prismabox.hide |
41
+ | @prismabox.input.hide | - | Hides the field or model from the output only in the input model |
42
+ | @prismabox.create.input.hide | - | Hides the field or model from the outputs only in the input create model|
43
+ | @prismabox.update.input.hide | - | Hides the field or model from the outputs only in the input update model|
44
+ | @prismabox.options | @prismabox.options{ min: 10, max: 20 } | Uses the provided options for the field or model in the generated schema. Be careful to use valid JS/TS syntax! |
45
+ | @prismabox.typeOverwrite | @prismabox.typeOverwrite=Type.CustomName | Overwrite the type prismabox outputs for a field with a custom string. See [m1212e/prismabox#29](https://github.com/m1212e/prismabox/issues/29) for an extended usecase |
46
+
47
+ > For a more detailed list of available annotations, please see [annotations.ts](src/annotations/annotations.ts)
48
+
49
+ A schema using annotations could look like this:
50
+ ```prisma
51
+ /// The post model
52
+ model Post {
53
+ id Int @id @default(autoincrement())
54
+ /// @prismabox.hidden
55
+ createdAt DateTime @default(now())
56
+ title String @unique
57
+
58
+ User User? @relation(fields: [userId], references: [id])
59
+ /// @prismabox.options{max: 10}
60
+ /// this is the user id
61
+ userId Int?
62
+ }
63
+
64
+ /// @prismabox.hidden
65
+ enum Account {
66
+ PASSKEY
67
+ PASSWORD
68
+ }
69
+
70
+ ```
71
+ > Please note that you cannot use multiple annotations in one line! Each needs to be in its own!
72
+ ## Generated Schemes
73
+ The generator will output schema objects based on the models:
74
+ ```ts
75
+ // the plain object without any relations
76
+ export const PostPlain = ...
77
+
78
+ // only the relations of a model
79
+ export const PostRelations = ...
80
+
81
+ // a composite model of the two, providing the full type
82
+ export const Post = ...
83
+
84
+ // a schema for validating the prisma where input for this model
85
+ export const PostWhere = ...
86
+
87
+ // a schema for validating the prisma unique where input for this model
88
+ export const PostWhereUnique = ...
89
+
90
+ // a schema for validating the prisma order by input for this model
91
+ export const PostOrderBy = ...
92
+
93
+ // a schema for validating the prisma include input for this model
94
+ export const PostInclude = ...
95
+
96
+ // a schema for validating the prisma select input for this model
97
+ export const PostSelect = ...
98
+ ```
99
+
100
+ ### Input models
101
+ To simplify the validation of input data, prismabox is able to generate schemes specifically for input data.
102
+ These are called "InputModels" and need to be explicitly enabled in the generator settings (`inputModel = true`) because they expect some conventions/field naming patterns to work properly.
103
+ > If you want to see the specifics on how the model behaves, see [here](src/generators/relations.ts) and [here](src/generators/plain.ts).
104
+
105
+ 1. Foreign Ids need to end in Id (case is ignored, e.g. `userId` or `userid` will work)
106
+ 2. createdAt will be detected and ignored if it follows exactly this pattern: `createdAt DateTime @default(now())`
107
+ 3. updatedAt will be detected and ignored if it follows exactly this pattern: `updatedAt DateTime @updatedAt`
108
+ 4. Hide annotations marked for imports (`@prismabox.input.hide`) are respected.
109
+
110
+ If enabled, the generator will additonally output more schemes for each model which can be used for creating/updating entities. The model will only allow editing fields of the entity itself. For relations, only connecting/disconnecting is allowed, but changing/creating related entities is not possible.
111
+
112
+
113
+ ## Notes
114
+ ### `__nullable__` vs `Type.Optional`
115
+
116
+ Prismabox wraps nullable fields in a custom `__nullable__` method which allows `null` in addition to `undefined`. From the relevant [issue comment](https://github.com/m1212e/prismabox/issues/33#issuecomment-2708755442):
117
+ > prisma in some scenarios allows null OR undefined as types where optional only allows for undefined/is reflected as undefined in TS types
118
+
package/cli.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var D=require("node:fs/promises"),Pe=require("@prisma/generator-helper");var f=require("@sinclair/typebox"),N=require("@sinclair/typebox/value"),h=f.Type.Object({output:f.Type.String({default:"./prisma/prismabox"}),typeboxImportVariableName:f.Type.String({default:"Type"}),typeboxImportDependencyName:f.Type.String({default:"@sinclair/typebox"}),additionalProperties:f.Type.Boolean({default:!1}),inputModel:f.Type.Boolean({default:!1}),ignoreIdOnInputModel:f.Type.Boolean({default:!0}),ignoreCreatedAtOnInputModel:f.Type.Boolean({default:!0}),ignoreUpdatedAtOnInputModel:f.Type.Boolean({default:!0}),ignoreForeignOnInputModel:f.Type.Boolean({default:!0}),nullableName:f.Type.String({default:"__nullable__"}),allowRecursion:f.Type.Boolean({default:!0}),additionalFieldsPlain:f.Type.Optional(f.Type.Array(f.Type.String())),transformDateName:f.Type.String({default:"__transformDate__"}),useJsonTypes:f.Type.Union([f.Type.Boolean(),f.Type.Literal("transformer")],{default:!1}),importFileExtension:f.Type.String({default:""}),exportedTypePrefix:f.Type.String({default:""})},{additionalProperties:!1}),z={};function Z(e){try{N.Value.Clean(h,e),N.Value.Default(h,e),z=N.Value.Decode(h,N.Value.Convert(h,e)),Object.freeze(z)}catch(t){throw console.error(N.Value.Errors(h,e).First),t}}function n(){return z}function ee(e){return e.type==="OPTIONS"}function x(e){return e.type==="TYPE_OVERWRITE"}var Ne=[{type:"HIDDEN_INPUT_CREATE",keys:["@prismabox.create.input.hide","@prismabox.create.input.hidden"]},{type:"HIDDEN_INPUT_UPDATE",keys:["@prismabox.update.input.hide","@prismabox.update.input.hidden"]},{type:"HIDDEN_INPUT",keys:["@prismabox.input.hide","@prismabox.input.hidden"]},{type:"HIDDEN",keys:["@prismabox.hide","@prismabox.hidden"]},{type:"OPTIONS",keys:["@prismabox.options"]},{type:"TYPE_OVERWRITE",keys:["@prismabox.typeOverwrite"]}];function l(e){let t=[],r="",i=e??"";for(let s of i.split(`
3
+ `).map(o=>o.trim()).filter(o=>o.length>0)){let o=Ne.find(a=>a.keys.some(m=>s.startsWith(m)));if(o)if(o.type==="OPTIONS"){if(!s.startsWith(`${o.keys[0]}{`))throw new Error("Invalid syntax, expected opening { after prismabox.options");if(!s.endsWith("}"))throw new Error("Invalid syntax, expected closing } for prismabox.options");t.push({type:"OPTIONS",value:s.substring(o.keys[0].length+1,s.length-1)})}else if(o.type==="TYPE_OVERWRITE"){if(!s.startsWith(`${o.keys[0]}=`))throw new Error("Invalid syntax, expected = after prismabox.type");t.push({type:"TYPE_OVERWRITE",value:s.split("=")[1]})}else t.push({type:o.type});else r+=`${s}
4
+ `}return r=r.trim().replaceAll("`","\\`"),{annotations:t,description:r.length>0?r:void 0,isHidden:De(t),isHiddenInput:Te(t),isHiddenInputCreate:he(t),isHiddenInputUpdate:Oe(t)}}function De(e){return e.some(t=>t.type==="HIDDEN")}function Te(e){return e.some(t=>t.type==="HIDDEN_INPUT")}function he(e){return e.some(t=>t.type==="HIDDEN_INPUT_CREATE")}function Oe(e){return e.some(t=>t.type==="HIDDEN_INPUT_UPDATE")}function p({input:e,exludeAdditionalProperties:t}={}){t===void 0&&(t=!n().additionalProperties);let r=[];for(let i of e?.annotations??[])ee(i)&&r.push(i.value);return t&&r.push(`additionalProperties: ${n().additionalProperties}`),e?.description&&r.push(`description: \`${e.description}\``),r.length>0?`{${r.join(",")}}`:""}function I(e,t=p({exludeAdditionalProperties:!0})){return`${n().typeboxImportVariableName}.Union([${e.join(",")}], ${t})
5
+ `}var v=[],y=new Map;function te(e){for(let t of e){let r=Re(t);if(r){let i={name:t.name,stringRepresentation:r};v.push(i),y.set(t.name,i)}}Object.freeze(v)}function Re(e){let t=l(e.documentation);if(t.isHidden)return;let r=e.values.map(i=>`${n().typeboxImportVariableName}.Literal('${i.name}')`);return I(r,p({input:t}))}var Fe=["Int","BigInt","Float","Decimal","String","DateTime","Json","Boolean","Bytes"];function b(e){return Fe.includes(e)}function M({fieldType:e,options:t}){if(["Int","BigInt"].includes(e))return`${n().typeboxImportVariableName}.Integer(${t})`;if(["Float","Decimal"].includes(e))return`${n().typeboxImportVariableName}.Number(${t})`;if(e==="String")return`${n().typeboxImportVariableName}.String(${t})`;if(["DateTime"].includes(e)){let r=n();if(r.useJsonTypes==="transformer")return`${n().transformDateName}(${t})`;if(r.useJsonTypes){let i=t;return i.includes("{")&&i.includes("}")?i=i.replace("{","{ format: 'date-time', "):i="{ format: 'date-time' }",`${r.typeboxImportVariableName}.String(${i})`}return`${n().typeboxImportVariableName}.Date(${t})`}if(e==="Json")return`${n().typeboxImportVariableName}.Any(${t})`;if(e==="Boolean")return`${n().typeboxImportVariableName}.Boolean(${t})`;if(e==="Bytes")return`${n().typeboxImportVariableName}.Uint8Array(${t})`;throw new Error("Invalid type for primitive generation")}function c(e,t=!1){return`${n().typeboxImportVariableName}.Partial(${e}, ${p({exludeAdditionalProperties:t})})`}var A=[];function ne(e){for(let t of e){let r=Ve(t);r&&A.push({name:t.name,stringRepresentation:r})}Object.freeze(A)}function Ve(e){let t=l(e.documentation);if(t.isHidden)return;let r=e.fields.map(s=>{if(!l(s.documentation).isHidden&&!b(s.type))return`${s.name}: ${n().typeboxImportVariableName}.Boolean()`}).filter(s=>s);r.push(`_count: ${n().typeboxImportVariableName}.Boolean()`);let i=`${n().typeboxImportVariableName}.Object({${[...r].join(",")}},${p({input:t})})
6
+ `;return c(i)}var w=[];function oe(e){for(let t of e){let r=Ee(t);r&&w.push({name:t.name,stringRepresentation:r})}Object.freeze(w)}function Ee(e){let t=l(e.documentation);if(t.isHidden)return;let r=e.fields.map(s=>{if(!l(s.documentation).isHidden&&b(s.type))return`${s.name}: ${I([`${n().typeboxImportVariableName}.Literal('asc')`,`${n().typeboxImportVariableName}.Literal('desc')`])}`}).filter(s=>s),i=`${n().typeboxImportVariableName}.Object({${[...r].join(",")}},${p({input:t})})
7
+ `;return c(i)}function g(e){return`${n().typeboxImportVariableName}.Array(${e}, ${p({exludeAdditionalProperties:!0})})`}function re(){return`import { ${n().typeboxImportVariableName}, type TSchema } from "${n().typeboxImportDependencyName}"
8
+ export const ${n().nullableName} = <T extends TSchema>(schema: T) => ${n().typeboxImportVariableName}.Union([${n().typeboxImportVariableName}.Null(), schema])
9
+ `}function ie(){return`import { ${n().nullableName} } from "./${n().nullableName}${n().importFileExtension}"
10
+ `}function j(e){return`${n().nullableName}(${e})`}function Y(e){return`${n().typeboxImportVariableName}.Optional(${e})`}var C=[],O=new Map;function ae(e){for(let t of e){let r=R(t);if(r){let i={name:t.name,stringRepresentation:r};C.push(i),O.set(t.name,i)}}Object.freeze(C)}function R(e,t=!1,r=!1){let i=l(e.documentation);if(i.isHidden||(t||r)&&i.isHiddenInput||t&&i.isHiddenInputCreate||r&&i.isHiddenInputUpdate)return;let s=e.fields.map(o=>{let a=l(o.documentation);if(a.isHidden||(t||r)&&a.isHiddenInput||t&&a.isHiddenInputCreate||r&&a.isHiddenInputUpdate||n().ignoreIdOnInputModel&&(t||r)&&o.isId||n().ignoreCreatedAtOnInputModel&&(t||r)&&o.name==="createdAt"&&o.hasDefaultValue||n().ignoreUpdatedAtOnInputModel&&(t||r)&&o.isUpdatedAt||n().ignoreForeignOnInputModel&&(t||r)&&(o.name.toLowerCase().endsWith("id")||o.name.toLowerCase().endsWith("foreign")||o.name.toLowerCase().endsWith("foreignkey")))return;let m="";if(b(o.type)){let u=a.annotations.filter(x).at(0)?.value;u?m=u:m=M({fieldType:o.type,options:p({input:a,exludeAdditionalProperties:!1})})}else if(y.has(o.type))m=y.get(o.type).stringRepresentation;else return;o.isList&&(m=g(m));let d=!1;return o.isRequired||(m=j(m)),(r||t&&!o.isRequired&&!o.hasDefaultValue)&&(m=Y(m),d=!0),!d&&o.hasDefaultValue&&(t||r)&&(m=Y(m),d=!0),`${o.name}: ${m}`}).filter(o=>o);return`${n().typeboxImportVariableName}.Object({${[...s,t||r?[]:n().additionalFieldsPlain??[]].join(",")}},${p({input:i})})
11
+ `}var S=[];function se(e){for(let t of e){let r=R(t,!0,!1);r&&S.push({name:t.name,stringRepresentation:r})}Object.freeze(S)}var U=[];function pe(e){for(let t of e){let r=R(t,!1,!0);r&&U.push({name:t.name,stringRepresentation:r})}Object.freeze(U)}var F=[];function me(e){for(let t of e){let r=He(t);r&&F.push({name:t.name,stringRepresentation:r})}Object.freeze(F)}function He(e){let t=l(e.documentation);if(t.isHidden)return;let r=e.fields.map(i=>{if(l(i.documentation).isHidden||b(i.type)||y.has(i.type))return;let o=O.get(i.type)?.stringRepresentation;if(o)return i.isList&&(o=g(o)),i.isRequired||(o=j(o)),`${i.name}: ${o}`}).filter(i=>i);return`${n().typeboxImportVariableName}.Object({${r.join(",")}},${p({input:t})})
12
+ `}var V=[];function de(e){let t=new Map;for(let r of e)t.set(r.name,r);for(let r of e){let i=ve(r,t);i&&V.push({name:r.name,stringRepresentation:i})}Object.freeze(V)}function ve(e,t){let r=l(e.documentation);if(r.isHidden||r.isHiddenInput||r.isHiddenInputCreate)return;let i=e.fields.map(s=>{let o=l(s.documentation);if(o.isHidden||o.isHiddenInput||o.isHiddenInputCreate||b(s.type)||y.has(s.type))return;let a="String";switch(t.get(s.type)?.fields.find(L=>L.isId)?.type){case"String":a="String";break;case"Int":a="Integer";break;case"BigInt":a="Integer";break;default:return}let d=`${n().typeboxImportVariableName}.Object({
13
+ id: ${n().typeboxImportVariableName}.${a}(${p({input:o})}),
14
+ },${p({input:o})})`;s.isList&&(d=g(d));let u=`${n().typeboxImportVariableName}.Object({
15
+ connect: ${d},
16
+ }, ${p()})`;return(!s.isRequired||s.isList)&&(u=`${n().typeboxImportVariableName}.Optional(${u})`),`${s.name}: ${u}`}).filter(s=>s);return`${n().typeboxImportVariableName}.Object({${i.join(",")}},${p({input:r})})
17
+ `}var E=[];function le(e){let t=new Map;for(let r of e)t.set(r.name,r);for(let r of e){let i=Ae(r,t);i&&E.push({name:r.name,stringRepresentation:i})}Object.freeze(E)}function Ae(e,t){let r=l(e.documentation);if(r.isHidden||r.isHiddenInput||r.isHiddenInputUpdate)return;let i=e.fields.map(s=>{let o=l(s.documentation);if(o.isHidden||o.isHiddenInput||o.isHiddenInputUpdate||b(s.type)||y.has(s.type))return;let a="String";switch(t.get(s.type)?.fields.find(u=>u.isId)?.type){case"String":a="String";break;case"Int":a="Integer";break;case"BigInt":a="Integer";break;default:return}let d;return s.isList?d=c(`${n().typeboxImportVariableName}.Object({
18
+ connect: ${g(`${n().typeboxImportVariableName}.Object({
19
+ id: ${n().typeboxImportVariableName}.${a}(${p({input:o})})
20
+ }, ${p({input:o})})`)},
21
+ disconnect: ${g(`${n().typeboxImportVariableName}.Object({
22
+ id: ${n().typeboxImportVariableName}.${a}(${p({input:o})})
23
+ }, ${p({input:o})})`)}
24
+ }, ${p({input:o})})`):s.isRequired?d=`${n().typeboxImportVariableName}.Object({
25
+ connect: ${n().typeboxImportVariableName}.Object({
26
+ id: ${n().typeboxImportVariableName}.${a}(${p({input:o})})
27
+ }, ${p({input:o})})
28
+ }, ${p({input:o})})`:d=c(`${n().typeboxImportVariableName}.Object({
29
+ connect: ${n().typeboxImportVariableName}.Object({
30
+ id: ${n().typeboxImportVariableName}.${a}(${p({input:o})})
31
+ }, ${p({input:o})}),
32
+ disconnect: ${n().typeboxImportVariableName}.Boolean()
33
+ }, ${p({input:o})})`),`${s.name}: ${d}`}).filter(s=>s);return c(`${n().typeboxImportVariableName}.Object({${i.join(",")}},${p({input:r})})`)}var _=[];function ue(e){for(let t of e){let r=we(t);r&&_.push({name:t.name,stringRepresentation:r})}Object.freeze(_)}function we(e){let t=l(e.documentation);if(t.isHidden)return;let r=e.fields.map(s=>{if(!l(s.documentation).isHidden)return`${s.name}: ${n().typeboxImportVariableName}.Boolean()`}).filter(s=>s);r.push(`_count: ${n().typeboxImportVariableName}.Boolean()`);let i=`${n().typeboxImportVariableName}.Object({${[...r].join(",")}},${p({input:t})})
34
+ `;return c(i)}function J(e,t=p({exludeAdditionalProperties:!0})){return`${n().typeboxImportVariableName}.Intersect([${e.join(",")}], ${t})
35
+ `}var P="Self",W=[];function fe(e){for(let t of e){let r=je(t);r&&W.push({name:t.name,stringRepresentation:r})}Object.freeze(W)}function je(e){let t=l(e.documentation);if(t.isHidden)return;let r=e.fields.map(i=>{let s=l(i.documentation);if(s.isHidden)return;let o="";if(b(i.type)){let a=s.annotations.filter(x).at(0)?.value;a?o=a:o=M({fieldType:i.type,options:p({exludeAdditionalProperties:!1,input:s})})}else if(y.has(i.type))o=y.get(i.type).stringRepresentation;else return;return i.isList&&(o=g(o)),`${i.name}: ${o}`}).filter(i=>i);return n().allowRecursion?c(`${n().typeboxImportVariableName}.Recursive(${P} =>${n().typeboxImportVariableName}.Object({${ye()},${r.join(",")}},${p({exludeAdditionalProperties:!0,input:t})}), { $id: "${e.name}"})`):c(`${n().typeboxImportVariableName}.Object({${r.join(",")}},${p({exludeAdditionalProperties:!0,input:t})})`)}var k=[];function ce(e){for(let t of e){let r=Ce(t);r&&k.push({name:t.name,stringRepresentation:r})}Object.freeze(k)}function Ce(e){let t=l(e.documentation);if(t.isHidden)return;let r=e.uniqueFields.filter(a=>a.length>1).map(a=>{let m=a.join("_"),u=a.map($=>e.fields.find(T=>T.name===$)).map($=>{let T=l($.documentation);if(T.isHidden)return;let H="";if(b($.type)){let X=T.annotations.filter(x).at(0)?.value;X?H=X:H=M({fieldType:$.type,options:p({exludeAdditionalProperties:!1,input:T})})}else if(y.has($.type))H=y.get($.type).stringRepresentation;else throw new Error("Invalid type for unique composite generation");return`${$.name}: ${H}`}),L=`${n().typeboxImportVariableName}.Object({${u.join(",")}}, ${p({exludeAdditionalProperties:!0})})`;return`${m}: ${L}`}),i=e.fields.map(a=>{let m=l(a.documentation);if(m.isHidden)return;let d="";if(b(a.type)){let u=m.annotations.filter(x).at(0)?.value;u?d=u:d=M({fieldType:a.type,options:p({exludeAdditionalProperties:!1,input:m})})}else if(y.has(a.type))d=y.get(a.type).stringRepresentation;else return;return a.isList&&(d=g(d)),`${a.name}: ${d}`}).filter(a=>a),s=e.fields.map(a=>{let m=l(a.documentation);if(m.isHidden||!a.isUnique&&!a.isId)return;let d="";if(b(a.type)){let u=m.annotations.filter(x).at(0)?.value;u?d=u:d=M({fieldType:a.type,options:p({exludeAdditionalProperties:!1,input:m})})}else if(y.has(a.type))d=y.get(a.type).stringRepresentation;else return;return a.isList&&(d=g(d)),`${a.name}: ${d}`}).filter(a=>a),o=`${n().typeboxImportVariableName}.Object({${[...s,...r].join(",")}},${p({exludeAdditionalProperties:!0,input:t})})`;return n().allowRecursion?`${n().typeboxImportVariableName}.Recursive(${P} => ${J([c(o,!0),I([...s,...r].map(a=>`${n().typeboxImportVariableName}.Object({${a}})`)),c(`${n().typeboxImportVariableName}.Object({${ye()}})`,!0),c(`${n().typeboxImportVariableName}.Object({${i.join(",")}}, ${p()})`)])}, { $id: "${e.name}"})`:J([c(o,!0),I([...s,...r].map(a=>`${n().typeboxImportVariableName}.Object({${a}})`)),c(`${n().typeboxImportVariableName}.Object({${i.join(",")}})`)])}function ye(){return`AND: ${n().typeboxImportVariableName}.Union([${P}, ${g(P)}]),
36
+ NOT: ${n().typeboxImportVariableName}.Union([${P}, ${g(P)}]),
37
+ OR: ${g(P)}`}var G=require("node:fs/promises"),Q=require("node:path");function be(e){return e.map(t=>`export * from "./${t}${n().importFileExtension}";`).join(`
38
+ `)}var ge=require("prettier");async function K(e){try{return await(0,ge.format)(e,{parser:"typescript"})}catch(t){return console.error("Error formatting file",t),e}}function $e(){return`import { ${n().typeboxImportVariableName} } from "${n().typeboxImportDependencyName}";
39
+ export const ${n().transformDateName} = (options?: Parameters<typeof ${n().typeboxImportVariableName}.String>[0]) => ${n().typeboxImportVariableName}.Transform(${n().typeboxImportVariableName}.String({ format: 'date-time', ...options }))
40
+ .Decode((value) => new Date(value))
41
+ .Encode((value) => value.toISOString())
42
+ `}function xe(){return`import { ${n().transformDateName} } from "./${n().transformDateName}${n().importFileExtension}"
43
+ `}function B(e){return`${n().typeboxImportVariableName}.Composite([${e.map(t=>`${n().exportedTypePrefix}${t}`).join(",")}], ${p()})
44
+ `}function q(e){return`export const ${n().exportedTypePrefix}${e.name} = ${e.stringRepresentation}
45
+ `}function Se(){return`import { ${n().typeboxImportVariableName} } from "${n().typeboxImportDependencyName}"
46
+ `}function Ie(){let e=new Map,t=(o,a)=>{for(let m of o){let d=q({...m,name:`${m.name}${a}`}),u=e.get(m.name);u?e.set(m.name,`${u}
47
+ ${d}`):e.set(m.name,d)}};t(v,""),t(C,"Plain"),t(F,"Relations"),t(S,"PlainInputCreate"),t(U,"PlainInputUpdate"),t(V,"RelationsInputCreate"),t(E,"RelationsInputUpdate"),t(W,"Where"),t(k,"WhereUnique"),t(_,"Select"),t(A,"Include"),t(w,"OrderBy");let r=new Set(F.map(o=>o.name)),i=new Set(V.map(o=>o.name)),s=new Set(E.map(o=>o.name));for(let[o,a]of e){let m=O.has(o),d=r.has(o),u;if(m&&d)u=B([`${o}Plain`,`${o}Relations`]);else if(m)u=`${o}Plain`;else if(d)u=`${o}Relations`;else continue;e.set(o,`${a}
48
+ ${q({name:o,stringRepresentation:u})}`)}for(let[o,a]of e)if(i.has(o)){let m=B([`${o}PlainInputCreate`,`${o}RelationsInputCreate`]);e.set(o,`${a}
49
+ ${q({name:`${o}InputCreate`,stringRepresentation:m})}`)}for(let[o,a]of e)if(s.has(o)){let m=B([`${o}PlainInputUpdate`,`${o}RelationsInputUpdate`]);e.set(o,`${a}
50
+ ${q({name:`${o}InputUpdate`,stringRepresentation:m})}`)}for(let[o,a]of e)e.set(o,`${Se()}
51
+ ${xe()}
52
+ ${ie()}
53
+ ${a}`);return e.set(n().nullableName,re()),e.set(n().transformDateName,$e()),e}async function Me(){let e=Array.from(Ie().entries());return Promise.all([...e.map(async([t,r])=>(0,G.writeFile)((0,Q.join)(n().output,`${t}.ts`),await K(r))),(0,G.writeFile)((0,Q.join)(n().output,"barrel.ts"),await K(be(e.map(([t])=>t))))])}(0,Pe.generatorHandler)({onManifest(){return{defaultOutput:"./prismabox",prettyName:"prismabox"}},async onGenerate(e){Z({...e.generator.config,output:e.generator.output?.value});try{await(0,D.access)(n().output),await(0,D.rm)(n().output,{recursive:!0})}catch{}await(0,D.mkdir)(n().output,{recursive:!0}),te(e.dmmf.datamodel.enums),ae(e.dmmf.datamodel.models),me(e.dmmf.datamodel.models),fe(e.dmmf.datamodel.models),ce(e.dmmf.datamodel.models),n().inputModel&&(se(e.dmmf.datamodel.models),pe(e.dmmf.datamodel.models),de(e.dmmf.datamodel.models),le(e.dmmf.datamodel.models)),ue(e.dmmf.datamodel.models),ne(e.dmmf.datamodel.models),oe(e.dmmf.datamodel.models),await Me()}});
package/cli.js.map ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/config.ts", "../src/annotations/annotations.ts", "../src/annotations/options.ts", "../src/generators/wrappers/union.ts", "../src/generators/enum.ts", "../src/generators/primitiveField.ts", "../src/generators/wrappers/partial.ts", "../src/generators/include.ts", "../src/generators/orderBy.ts", "../src/generators/wrappers/array.ts", "../src/generators/wrappers/nullable.ts", "../src/generators/wrappers/optional.ts", "../src/generators/plain.ts", "../src/generators/plainInputCreate.ts", "../src/generators/plainInputUpdate.ts", "../src/generators/relations.ts", "../src/generators/select.ts", "../src/generators/wrappers/intersect.ts", "../src/generators/where.ts", "../src/writer.ts", "../src/barrel.ts", "../src/format.ts", "../src/generators/transformDate.ts", "../src/generators/wrappers/composite.ts", "../src/model.ts"],
4
+ "sourcesContent": ["import { access, mkdir, rm } from \"node:fs/promises\";\nimport { generatorHandler } from \"@prisma/generator-helper\";\nimport { getConfig, setConfig } from \"./config\";\nimport { processEnums } from \"./generators/enum\";\nimport { processInclude } from \"./generators/include\";\nimport { processOrderBy } from \"./generators/orderBy\";\nimport { processPlain } from \"./generators/plain\";\nimport { processPlainInputCreate } from \"./generators/plainInputCreate\";\nimport { processPlainInputUpdate } from \"./generators/plainInputUpdate\";\nimport {\n processRelations,\n processRelationsInputCreate,\n processRelationsInputUpdate,\n} from \"./generators/relations\";\nimport { processSelect } from \"./generators/select\";\nimport { processWhere, processWhereUnique } from \"./generators/where\";\nimport { write } from \"./writer\";\n\ngeneratorHandler({\n onManifest() {\n return {\n defaultOutput: \"./prismabox\",\n prettyName: \"prismabox\",\n };\n },\n async onGenerate(options) {\n setConfig({\n ...options.generator.config,\n // for some reason, the output is an object with a value key\n output: options.generator.output?.value,\n });\n\n try {\n await access(getConfig().output);\n await rm(getConfig().output, { recursive: true });\n } catch (_error) {}\n\n await mkdir(getConfig().output, { recursive: true });\n\n processEnums(options.dmmf.datamodel.enums);\n processPlain(options.dmmf.datamodel.models);\n processRelations(options.dmmf.datamodel.models);\n processWhere(options.dmmf.datamodel.models);\n processWhereUnique(options.dmmf.datamodel.models);\n if (getConfig().inputModel) {\n processPlainInputCreate(options.dmmf.datamodel.models);\n processPlainInputUpdate(options.dmmf.datamodel.models);\n processRelationsInputCreate(options.dmmf.datamodel.models);\n processRelationsInputUpdate(options.dmmf.datamodel.models);\n }\n processSelect(options.dmmf.datamodel.models);\n processInclude(options.dmmf.datamodel.models);\n processOrderBy(options.dmmf.datamodel.models);\n\n await write();\n },\n});\n", "import { type Static, Type } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nconst configSchema = Type.Object(\n {\n /**\n * Where to output the generated files\n */\n output: Type.String({ default: \"./prisma/prismabox\" }),\n /**\n * The name of the variable to import the Type from typebox\n */\n typeboxImportVariableName: Type.String({ default: \"Type\" }),\n /**\n * The name of the dependency to import the Type from typebox\n */\n typeboxImportDependencyName: Type.String({ default: \"@sinclair/typebox\" }),\n /**\n * Whether to allow additional properties in the generated schemes\n */\n additionalProperties: Type.Boolean({ default: false }),\n /**\n * Should the input schemes be generated\n */\n inputModel: Type.Boolean({ default: false }),\n /**\n * Prevents the ID field from being generated in the input model\n */\n ignoreIdOnInputModel: Type.Boolean({ default: true }),\n /**\n * Prevents the createdAt field from being generated in the input model\n */\n ignoreCreatedAtOnInputModel: Type.Boolean({ default: true }),\n /**\n * Prevents the updatedAt field from being generated in the input model\n */\n ignoreUpdatedAtOnInputModel: Type.Boolean({ default: true }),\n /**\n * Prevents the foreignId field from being generated in the input model\n */\n ignoreForeignOnInputModel: Type.Boolean({ default: true }),\n /**\n * How the nullable union should be named\n */\n nullableName: Type.String({ default: \"__nullable__\" }),\n /**\n * Whether to allow recursion in the generated schemes (enabling reduces code size)\n */\n allowRecursion: Type.Boolean({ default: true }),\n /**\n\t\t * Additional fields to add to the generated schemes (must be valid strings in the context of usage)\n\t * @example \n\t * ```prisma\n\t * generator prismabox {\n\t\t\tprovider = \"node ./dist/cli.js\"\n\t\t\t inputModel = true\n\t\t\t output = \"./generated/schema\"\n\t\t\t additionalFieldsPlain = [\"additional: Type.Optional(Type.String())\"]\n\t\t }\n\t ```\n\t\t */\n additionalFieldsPlain: Type.Optional(Type.Array(Type.String())),\n /**\n * How the transform date type should be named\n */\n transformDateName: Type.String({ default: \"__transformDate__\" }),\n /**\n * When enabled, this option ensures that only primitive types are generated as JSON types.\n * This ensures compatibility with tooling that only supports the serilization to JSON primitive types.\n *\n * This can be false (off), true (will result in formatted string type) or \"transformer\" which will use Tybepox transformers\n * to output native JS Date types but transforms those to strings on processing\n *\n * E.g. Date will be of Type String when enabled.\n */\n useJsonTypes: Type.Union([Type.Boolean(), Type.Literal(\"transformer\")], {\n default: false,\n }),\n /**\n * What file extension, if any, to add to src file imports. Set to \".js\" to support nodenext module resolution\n */\n importFileExtension: Type.String({ default: \"\" }),\n /**\n * The prefix to add to exported types\n */\n exportedTypePrefix: Type.String({ default: \"\" }),\n },\n { additionalProperties: false },\n);\n\n// biome-ignore lint/suspicious/noExplicitAny: we want to set the default value\nlet config: Static<typeof configSchema> = {} as unknown as any;\n\nexport function setConfig(input: unknown) {\n try {\n Value.Clean(configSchema, input);\n Value.Default(configSchema, input);\n config = Value.Decode(configSchema, Value.Convert(configSchema, input));\n Object.freeze(config);\n } catch (error) {\n console.error(Value.Errors(configSchema, input).First);\n throw error;\n }\n}\nexport function getConfig() {\n return config;\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\n\nexport type Annotation =\n | { type: \"HIDDEN\" }\n | { type: \"HIDDEN_INPUT\" }\n | { type: \"HIDDEN_INPUT_CREATE\" }\n | { type: \"HIDDEN_INPUT_UPDATE\" }\n | { type: \"OPTIONS\"; value: string }\n | { type: \"TYPE_OVERWRITE\"; value: string };\n\nexport function isHiddenVariant(\n annotation: Annotation,\n): annotation is { type: \"HIDDEN\"; value: number } {\n return annotation.type === \"HIDDEN\";\n}\n\nexport function isHiddenInputVariant(\n annotation: Annotation,\n): annotation is { type: \"HIDDEN_INPUT\"; value: number } {\n return annotation.type === \"HIDDEN_INPUT\";\n}\n\nexport function isHiddenInputCreateVariant(\n annotation: Annotation,\n): annotation is { type: \"HIDDEN_INPUT_CREATE\"; value: number } {\n return annotation.type === \"HIDDEN_INPUT_CREATE\";\n}\n\nexport function isHiddenInputUpdateVariant(\n annotation: Annotation,\n): annotation is { type: \"HIDDEN_INPUT_UPDATE\"; value: number } {\n return annotation.type === \"HIDDEN_INPUT_UPDATE\";\n}\n\nexport function isOptionsVariant(\n annotation: Annotation,\n): annotation is { type: \"OPTIONS\"; value: string } {\n return annotation.type === \"OPTIONS\";\n}\n\nexport function isTypeOverwriteVariant(\n annotation: Annotation,\n): annotation is { type: \"TYPE_OVERWRITE\"; value: string } {\n return annotation.type === \"TYPE_OVERWRITE\";\n}\n\nconst annotationKeys: { type: Annotation[\"type\"]; keys: string[] }[] = [\n {\n type: \"HIDDEN_INPUT_CREATE\",\n keys: [\"@prismabox.create.input.hide\", \"@prismabox.create.input.hidden\"],\n },\n {\n type: \"HIDDEN_INPUT_UPDATE\",\n keys: [\"@prismabox.update.input.hide\", \"@prismabox.update.input.hidden\"],\n },\n {\n type: \"HIDDEN_INPUT\",\n keys: [\n // we need to use input.hide instead of hide.input because the latter is a substring of input.hidden\n // and will falsely match\n \"@prismabox.input.hide\",\n \"@prismabox.input.hidden\",\n ],\n },\n {\n type: \"HIDDEN\",\n keys: [\"@prismabox.hide\", \"@prismabox.hidden\"],\n },\n {\n type: \"OPTIONS\",\n keys: [\"@prismabox.options\"],\n },\n {\n type: \"TYPE_OVERWRITE\",\n keys: [\"@prismabox.typeOverwrite\"],\n },\n];\n\nexport function extractAnnotations(\n input: DMMF.Model[\"fields\"][number][\"documentation\"],\n): {\n annotations: Annotation[];\n description: string | undefined;\n isHidden: boolean;\n isHiddenInput: boolean;\n isHiddenInputCreate: boolean;\n isHiddenInputUpdate: boolean;\n} {\n const annotations: Annotation[] = [];\n let description = \"\";\n\n const raw = input ?? \"\";\n\n for (const line of raw\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l.length > 0)) {\n const annotationKey = annotationKeys.find((key) =>\n key.keys.some((k) => line.startsWith(k)),\n );\n\n if (annotationKey) {\n if (annotationKey.type === \"OPTIONS\") {\n if (!line.startsWith(`${annotationKey.keys[0]}{`)) {\n throw new Error(\n \"Invalid syntax, expected opening { after prismabox.options\",\n );\n }\n if (!line.endsWith(\"}\")) {\n throw new Error(\n \"Invalid syntax, expected closing } for prismabox.options\",\n );\n }\n\n annotations.push({\n type: \"OPTIONS\",\n value: line.substring(\n annotationKey.keys[0].length + 1,\n line.length - 1,\n ),\n });\n } else if (annotationKey.type === \"TYPE_OVERWRITE\") {\n if (!line.startsWith(`${annotationKey.keys[0]}=`)) {\n throw new Error(\"Invalid syntax, expected = after prismabox.type\");\n }\n\n annotations.push({\n type: \"TYPE_OVERWRITE\",\n value: line.split(\"=\")[1],\n });\n } else {\n annotations.push({ type: annotationKey.type });\n }\n } else {\n description += `${line}\\n`;\n }\n }\n\n description = description.trim().replaceAll(\"`\", \"\\\\`\");\n return {\n annotations,\n description: description.length > 0 ? description : undefined,\n isHidden: isHidden(annotations),\n isHiddenInput: isHiddenInput(annotations),\n isHiddenInputCreate: isHiddenInputCreate(annotations),\n isHiddenInputUpdate: isHiddenInputUpdate(annotations),\n };\n}\n\nexport function isHidden(annotations: Annotation[]): boolean {\n return annotations.some((a) => a.type === \"HIDDEN\");\n}\n\nexport function isHiddenInput(annotations: Annotation[]): boolean {\n return annotations.some((a) => a.type === \"HIDDEN_INPUT\");\n}\n\nexport function isHiddenInputCreate(annotations: Annotation[]): boolean {\n return annotations.some((a) => a.type === \"HIDDEN_INPUT_CREATE\");\n}\n\nexport function isHiddenInputUpdate(annotations: Annotation[]): boolean {\n return annotations.some((a) => a.type === \"HIDDEN_INPUT_UPDATE\");\n}\n", "import { getConfig } from \"../config\";\nimport { type extractAnnotations, isOptionsVariant } from \"./annotations\";\n\nexport function generateTypeboxOptions({\n input,\n exludeAdditionalProperties,\n}: {\n input?: ReturnType<typeof extractAnnotations>;\n exludeAdditionalProperties?: boolean;\n} = {}): string {\n if (exludeAdditionalProperties === undefined) {\n exludeAdditionalProperties = !getConfig().additionalProperties;\n }\n\n const stringifiedOptions: string[] = [];\n for (const annotation of input?.annotations ?? []) {\n if (isOptionsVariant(annotation)) {\n stringifiedOptions.push(annotation.value);\n }\n }\n\n if (exludeAdditionalProperties) {\n stringifiedOptions.push(\n `additionalProperties: ${getConfig().additionalProperties}`,\n );\n }\n\n if (input?.description) {\n stringifiedOptions.push(`description: \\`${input.description}\\``);\n }\n\n return stringifiedOptions.length > 0\n ? `{${stringifiedOptions.join(\",\")}}`\n : \"\";\n}\n", "import { generateTypeboxOptions } from \"../../annotations/options\";\nimport { getConfig } from \"../../config\";\n\nexport function makeUnion(\n inputModels: string[],\n options = generateTypeboxOptions({ exludeAdditionalProperties: true }),\n) {\n return `${getConfig().typeboxImportVariableName}.Union([${inputModels.join(\n \",\",\n )}], ${options})\\n`;\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport { extractAnnotations } from \"../annotations/annotations\";\nimport { generateTypeboxOptions } from \"../annotations/options\";\nimport { getConfig } from \"../config\";\nimport type { ProcessedModel } from \"../model\";\nimport { makeUnion } from \"./wrappers/union\";\n\nexport const processedEnums: ProcessedModel[] = [];\nexport const processedEnumsMap = new Map<string, ProcessedModel>();\n\nexport function processEnums(\n enums: DMMF.DatamodelEnum[] | Readonly<DMMF.DatamodelEnum[]>,\n) {\n for (const e of enums) {\n const stringRepresentation = stringifyEnum(e);\n if (stringRepresentation) {\n const model = { name: e.name, stringRepresentation };\n processedEnums.push(model);\n processedEnumsMap.set(e.name, model);\n }\n }\n Object.freeze(processedEnums);\n}\n\nexport function stringifyEnum(data: DMMF.DatamodelEnum) {\n const annotations = extractAnnotations(data.documentation);\n if (annotations.isHidden) return undefined;\n\n const variantsString = data.values.map(\n (v) => `${getConfig().typeboxImportVariableName}.Literal('${v.name}')`,\n );\n\n return makeUnion(\n variantsString,\n generateTypeboxOptions({ input: annotations }),\n );\n}\n", "import { getConfig } from \"../config\";\n\nconst PrimitiveFields = [\n \"Int\",\n \"BigInt\",\n \"Float\",\n \"Decimal\",\n \"String\",\n \"DateTime\",\n \"Json\",\n \"Boolean\",\n \"Bytes\",\n] as const;\n\nexport type PrimitivePrismaFieldType = (typeof PrimitiveFields)[number];\n\nexport function isPrimitivePrismaFieldType(\n str: string,\n): str is PrimitivePrismaFieldType {\n // biome-ignore lint/suspicious/noExplicitAny: we want to check if the string is a valid primitive field\n return PrimitiveFields.includes(str as any);\n}\n\nexport function stringifyPrimitiveType({\n fieldType,\n options,\n}: {\n fieldType: PrimitivePrismaFieldType;\n options: string;\n}) {\n if ([\"Int\", \"BigInt\"].includes(fieldType)) {\n return `${getConfig().typeboxImportVariableName}.Integer(${options})`;\n }\n\n if ([\"Float\", \"Decimal\"].includes(fieldType)) {\n return `${getConfig().typeboxImportVariableName}.Number(${options})`;\n }\n\n if (fieldType === \"String\") {\n return `${getConfig().typeboxImportVariableName}.String(${options})`;\n }\n\n if ([\"DateTime\"].includes(fieldType)) {\n const config = getConfig();\n if (config.useJsonTypes === \"transformer\") {\n return `${getConfig().transformDateName}(${options})`;\n }\n\n if (config.useJsonTypes) {\n let opts = options;\n if (opts.includes(\"{\") && opts.includes(\"}\")) {\n opts = opts.replace(\"{\", \"{ format: 'date-time', \");\n } else {\n opts = `{ format: 'date-time' }`;\n }\n return `${config.typeboxImportVariableName}.String(${opts})`;\n }\n\n return `${getConfig().typeboxImportVariableName}.Date(${options})`;\n }\n\n if (fieldType === \"Json\") {\n return `${getConfig().typeboxImportVariableName}.Any(${options})`;\n }\n\n if (fieldType === \"Boolean\") {\n return `${getConfig().typeboxImportVariableName}.Boolean(${options})`;\n }\n\n if (fieldType === \"Bytes\") {\n return `${getConfig().typeboxImportVariableName}.Uint8Array(${options})`;\n }\n\n throw new Error(\"Invalid type for primitive generation\");\n}\n", "import { generateTypeboxOptions } from \"../../annotations/options\";\nimport { getConfig } from \"../../config\";\n\nexport function wrapWithPartial(\n input: string,\n exludeAdditionalPropertiesInOptions = false,\n) {\n return `${\n getConfig().typeboxImportVariableName\n }.Partial(${input}, ${generateTypeboxOptions({ exludeAdditionalProperties: exludeAdditionalPropertiesInOptions })})`;\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport { extractAnnotations } from \"../annotations/annotations\";\nimport { generateTypeboxOptions } from \"../annotations/options\";\nimport { getConfig } from \"../config\";\nimport type { ProcessedModel } from \"../model\";\nimport { isPrimitivePrismaFieldType } from \"./primitiveField\";\nimport { wrapWithPartial } from \"./wrappers/partial\";\n\nexport const processedInclude: ProcessedModel[] = [];\n\nexport function processInclude(models: DMMF.Model[] | Readonly<DMMF.Model[]>) {\n for (const m of models) {\n const o = stringifyInclude(m);\n if (o) {\n processedInclude.push({ name: m.name, stringRepresentation: o });\n }\n }\n Object.freeze(processedInclude);\n}\n\nexport function stringifyInclude(data: DMMF.Model) {\n const annotations = extractAnnotations(data.documentation);\n\n if (annotations.isHidden) return undefined;\n\n const fields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n if (annotations.isHidden) return undefined;\n\n if (isPrimitivePrismaFieldType(field.type)) return undefined;\n\n return `${field.name}: ${getConfig().typeboxImportVariableName}.Boolean()`;\n })\n .filter((x) => x) as string[];\n\n fields.push(`_count: ${getConfig().typeboxImportVariableName}.Boolean()`);\n\n const ret = `${getConfig().typeboxImportVariableName}.Object({${[\n ...fields,\n ].join(\",\")}},${generateTypeboxOptions({ input: annotations })})\\n`;\n\n return wrapWithPartial(ret);\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport { extractAnnotations } from \"../annotations/annotations\";\nimport { generateTypeboxOptions } from \"../annotations/options\";\nimport { getConfig } from \"../config\";\nimport type { ProcessedModel } from \"../model\";\nimport { isPrimitivePrismaFieldType } from \"./primitiveField\";\nimport { wrapWithPartial } from \"./wrappers/partial\";\nimport { makeUnion } from \"./wrappers/union\";\n\nexport const processedOrderBy: ProcessedModel[] = [];\n\nexport function processOrderBy(models: DMMF.Model[] | Readonly<DMMF.Model[]>) {\n for (const m of models) {\n const o = stringifyOrderBy(m);\n if (o) {\n processedOrderBy.push({ name: m.name, stringRepresentation: o });\n }\n }\n Object.freeze(processedOrderBy);\n}\n\nexport function stringifyOrderBy(data: DMMF.Model) {\n const annotations = extractAnnotations(data.documentation);\n\n if (annotations.isHidden) return undefined;\n\n const fields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n if (annotations.isHidden) return undefined;\n\n if (isPrimitivePrismaFieldType(field.type)) {\n return `${field.name}: ${makeUnion([\n `${getConfig().typeboxImportVariableName}.Literal('asc')`,\n `${getConfig().typeboxImportVariableName}.Literal('desc')`,\n ])}`;\n }\n\n //TODO if this is a many to one relation this is the wrong schema\n // return `${field.name}: ${getConfig().typeboxImportVariableName}.Object({_count: ${makeUnion(\n // [\n // `${getConfig().typeboxImportVariableName}.Literal('asc')`,\n // `${getConfig().typeboxImportVariableName}.Literal('desc')`,\n // ]\n // )}})`;\n })\n .filter((x) => x) as string[];\n\n const ret = `${getConfig().typeboxImportVariableName}.Object({${[\n ...fields,\n ].join(\",\")}},${generateTypeboxOptions({ input: annotations })})\\n`;\n\n return wrapWithPartial(ret);\n}\n", "import { generateTypeboxOptions } from \"../../annotations/options\";\nimport { getConfig } from \"../../config\";\n\nexport function wrapWithArray(input: string) {\n return `${\n getConfig().typeboxImportVariableName\n }.Array(${input}, ${generateTypeboxOptions({ exludeAdditionalProperties: true })})`;\n}\n", "import { getConfig } from \"../../config\";\n\nexport function nullableType() {\n return `import { ${\n getConfig().typeboxImportVariableName\n }, type TSchema } from \"${getConfig().typeboxImportDependencyName}\"\nexport const ${getConfig().nullableName} = <T extends TSchema>(schema: T) => ${\n getConfig().typeboxImportVariableName\n }.Union([${getConfig().typeboxImportVariableName}.Null(), schema])\\n`;\n}\n\nexport function nullableImport() {\n return `import { ${getConfig().nullableName} } from \"./${\n getConfig().nullableName\n }${getConfig().importFileExtension}\"\\n`;\n}\n\nexport function wrapWithNullable(input: string) {\n return `${getConfig().nullableName}(${input})`;\n}\n", "import { getConfig } from \"../../config\";\n\nexport function wrapWithOptional(input: string) {\n return `${getConfig().typeboxImportVariableName}.Optional(${input})`;\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport {\n extractAnnotations,\n isTypeOverwriteVariant,\n} from \"../annotations/annotations\";\nimport { generateTypeboxOptions } from \"../annotations/options\";\nimport { getConfig } from \"../config\";\nimport type { ProcessedModel } from \"../model\";\nimport { processedEnumsMap } from \"./enum\";\nimport {\n isPrimitivePrismaFieldType,\n type PrimitivePrismaFieldType,\n stringifyPrimitiveType,\n} from \"./primitiveField\";\nimport { wrapWithArray } from \"./wrappers/array\";\nimport { wrapWithNullable } from \"./wrappers/nullable\";\nimport { wrapWithOptional } from \"./wrappers/optional\";\n\nexport const processedPlain: ProcessedModel[] = [];\nexport const processedPlainMap = new Map<string, ProcessedModel>();\n\nexport function processPlain(models: DMMF.Model[] | Readonly<DMMF.Model[]>) {\n for (const m of models) {\n const o = stringifyPlain(m);\n if (o) {\n const model = { name: m.name, stringRepresentation: o };\n processedPlain.push(model);\n processedPlainMap.set(m.name, model);\n }\n }\n Object.freeze(processedPlain);\n}\n\nexport function stringifyPlain(\n data: DMMF.Model,\n isInputModelCreate = false,\n isInputModelUpdate = false,\n) {\n const annotations = extractAnnotations(data.documentation);\n\n if (\n annotations.isHidden ||\n ((isInputModelCreate || isInputModelUpdate) && annotations.isHiddenInput) ||\n (isInputModelCreate && annotations.isHiddenInputCreate) ||\n (isInputModelUpdate && annotations.isHiddenInputUpdate)\n )\n return undefined;\n\n const fields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n if (\n annotations.isHidden ||\n ((isInputModelCreate || isInputModelUpdate) &&\n annotations.isHiddenInput) ||\n (isInputModelCreate && annotations.isHiddenInputCreate) ||\n (isInputModelUpdate && annotations.isHiddenInputUpdate)\n )\n return undefined;\n\n // ===============================\n // INPUT MODEL FILTERS\n // ===============================\n // if we generate an input model we want to omit certain fields\n\n if (\n getConfig().ignoreIdOnInputModel &&\n (isInputModelCreate || isInputModelUpdate) &&\n field.isId\n )\n return undefined;\n if (\n getConfig().ignoreCreatedAtOnInputModel &&\n (isInputModelCreate || isInputModelUpdate) &&\n field.name === \"createdAt\" &&\n field.hasDefaultValue\n )\n return undefined;\n if (\n getConfig().ignoreUpdatedAtOnInputModel &&\n (isInputModelCreate || isInputModelUpdate) &&\n field.isUpdatedAt\n )\n return undefined;\n\n if (\n getConfig().ignoreForeignOnInputModel &&\n (isInputModelCreate || isInputModelUpdate) &&\n (field.name.toLowerCase().endsWith(\"id\") ||\n field.name.toLowerCase().endsWith(\"foreign\") ||\n field.name.toLowerCase().endsWith(\"foreignkey\"))\n ) {\n return undefined;\n }\n\n // ===============================\n // INPUT MODEL FILTERS END\n // ===============================\n\n let stringifiedType = \"\";\n\n if (isPrimitivePrismaFieldType(field.type)) {\n const overwrittenType = annotations.annotations\n .filter(isTypeOverwriteVariant)\n .at(0)?.value;\n\n if (overwrittenType) {\n stringifiedType = overwrittenType;\n } else {\n stringifiedType = stringifyPrimitiveType({\n fieldType: field.type as PrimitivePrismaFieldType,\n options: generateTypeboxOptions({\n input: annotations,\n exludeAdditionalProperties: false,\n }),\n });\n }\n } else if (processedEnumsMap.has(field.type)) {\n // biome-ignore lint/style/noNonNullAssertion: we checked this manually\n stringifiedType = processedEnumsMap.get(field.type)!.stringRepresentation;\n } else {\n return undefined;\n }\n\n if (field.isList) {\n stringifiedType = wrapWithArray(stringifiedType);\n }\n\n let madeOptional = false;\n\n if (!field.isRequired) {\n stringifiedType = wrapWithNullable(stringifiedType);\n }\n\n if (\n isInputModelUpdate ||\n (isInputModelCreate && !field.isRequired && !field.hasDefaultValue)\n ) {\n stringifiedType = wrapWithOptional(stringifiedType);\n madeOptional = true;\n }\n\n if (\n !madeOptional &&\n field.hasDefaultValue &&\n (isInputModelCreate || isInputModelUpdate)\n ) {\n stringifiedType = wrapWithOptional(stringifiedType);\n madeOptional = true;\n }\n\n return `${field.name}: ${stringifiedType}`;\n })\n .filter((x) => x) as string[];\n\n return `${getConfig().typeboxImportVariableName}.Object({${[\n ...fields,\n !(isInputModelCreate || isInputModelUpdate)\n ? (getConfig().additionalFieldsPlain ?? [])\n : [],\n ].join(\",\")}},${generateTypeboxOptions({ input: annotations })})\\n`;\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport type { ProcessedModel } from \"../model\";\nimport { stringifyPlain } from \"./plain\";\n\nexport const processedPlainInputCreate: ProcessedModel[] = [];\n\nexport function processPlainInputCreate(\n models: DMMF.Model[] | Readonly<DMMF.Model[]>,\n) {\n for (const m of models) {\n const o = stringifyPlain(m, true, false);\n if (o) {\n processedPlainInputCreate.push({ name: m.name, stringRepresentation: o });\n }\n }\n Object.freeze(processedPlainInputCreate);\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport type { ProcessedModel } from \"../model\";\nimport { stringifyPlain } from \"./plain\";\n\nexport const processedPlainInputUpdate: ProcessedModel[] = [];\n\nexport function processPlainInputUpdate(\n models: DMMF.Model[] | Readonly<DMMF.Model[]>,\n) {\n for (const m of models) {\n const o = stringifyPlain(m, false, true);\n if (o) {\n processedPlainInputUpdate.push({ name: m.name, stringRepresentation: o });\n }\n }\n Object.freeze(processedPlainInputUpdate);\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport { extractAnnotations } from \"../annotations/annotations\";\nimport { generateTypeboxOptions } from \"../annotations/options\";\nimport { getConfig } from \"../config\";\nimport type { ProcessedModel } from \"../model\";\nimport { processedEnumsMap } from \"./enum\";\nimport { processedPlainMap } from \"./plain\";\nimport { isPrimitivePrismaFieldType } from \"./primitiveField\";\nimport { wrapWithArray } from \"./wrappers/array\";\nimport { wrapWithNullable } from \"./wrappers/nullable\";\nimport { wrapWithPartial } from \"./wrappers/partial\";\n\nexport const processedRelations: ProcessedModel[] = [];\n\nexport function processRelations(\n models: DMMF.Model[] | Readonly<DMMF.Model[]>,\n) {\n for (const m of models) {\n const o = stringifyRelations(m);\n if (o) {\n processedRelations.push({ name: m.name, stringRepresentation: o });\n }\n }\n Object.freeze(processedRelations);\n}\n\nexport function stringifyRelations(data: DMMF.Model) {\n const annotations = extractAnnotations(data.documentation);\n if (annotations.isHidden) return undefined;\n\n const fields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n\n if (\n annotations.isHidden ||\n isPrimitivePrismaFieldType(field.type) ||\n processedEnumsMap.has(field.type)\n ) {\n return undefined;\n }\n\n let stringifiedType = processedPlainMap.get(\n field.type,\n )?.stringRepresentation;\n\n if (!stringifiedType) {\n return undefined;\n }\n\n if (field.isList) {\n stringifiedType = wrapWithArray(stringifiedType);\n }\n\n if (!field.isRequired) {\n stringifiedType = wrapWithNullable(stringifiedType);\n }\n\n return `${field.name}: ${stringifiedType}`;\n })\n .filter((x) => x) as string[];\n\n return `${getConfig().typeboxImportVariableName}.Object({${fields.join(\n \",\",\n )}},${generateTypeboxOptions({ input: annotations })})\\n`;\n}\n\nexport const processedRelationsInputCreate: ProcessedModel[] = [];\n\nexport function processRelationsInputCreate(\n models: DMMF.Model[] | Readonly<DMMF.Model[]>,\n) {\n const modelsMap = new Map<string, DMMF.Model>();\n for (const m of models) {\n modelsMap.set(m.name, m);\n }\n for (const m of models) {\n const o = stringifyRelationsInputCreate(m, modelsMap);\n if (o) {\n processedRelationsInputCreate.push({\n name: m.name,\n stringRepresentation: o,\n });\n }\n }\n Object.freeze(processedRelationsInputCreate);\n}\n\nexport function stringifyRelationsInputCreate(\n data: DMMF.Model,\n allModels: Map<string, DMMF.Model>,\n) {\n const annotations = extractAnnotations(data.documentation);\n if (\n annotations.isHidden ||\n annotations.isHiddenInput ||\n annotations.isHiddenInputCreate\n )\n return undefined;\n\n const fields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n\n if (\n annotations.isHidden ||\n annotations.isHiddenInput ||\n annotations.isHiddenInputCreate ||\n isPrimitivePrismaFieldType(field.type) ||\n processedEnumsMap.has(field.type)\n ) {\n return undefined;\n }\n\n let typeboxIdType = \"String\";\n\n const relatedIdType = allModels\n .get(field.type)\n ?.fields.find((f) => f.isId)?.type;\n\n switch (relatedIdType) {\n case \"String\":\n typeboxIdType = \"String\";\n break;\n case \"Int\":\n typeboxIdType = \"Integer\";\n break;\n case \"BigInt\":\n typeboxIdType = \"Integer\";\n break;\n default:\n // Skip relation fields pointing to models without a simple @id\n return undefined;\n }\n\n let connectString = `${getConfig().typeboxImportVariableName}.Object({\n\t\t\t\tid: ${\n getConfig().typeboxImportVariableName\n }.${typeboxIdType}(${generateTypeboxOptions({ input: annotations })}),\n\t\t\t},${generateTypeboxOptions({ input: annotations })})`;\n\n if (field.isList) {\n connectString = wrapWithArray(connectString);\n }\n\n let stringifiedType = `${getConfig().typeboxImportVariableName}.Object({\n\t\t\t\tconnect: ${connectString},\n\t\t\t}, ${generateTypeboxOptions()})`;\n\n if (!field.isRequired || field.isList) {\n stringifiedType = `${\n getConfig().typeboxImportVariableName\n }.Optional(${stringifiedType})`;\n }\n\n return `${field.name}: ${stringifiedType}`;\n })\n .filter((x) => x) as string[];\n\n return `${getConfig().typeboxImportVariableName}.Object({${fields.join(\n \",\",\n )}},${generateTypeboxOptions({ input: annotations })})\\n`;\n}\n\nexport const processedRelationsInputUpdate: ProcessedModel[] = [];\n\nexport function processRelationsInputUpdate(\n models: DMMF.Model[] | Readonly<DMMF.Model[]>,\n) {\n const modelsMap = new Map<string, DMMF.Model>();\n for (const m of models) {\n modelsMap.set(m.name, m);\n }\n for (const m of models) {\n const o = stringifyRelationsInputUpdate(m, modelsMap);\n if (o) {\n processedRelationsInputUpdate.push({\n name: m.name,\n stringRepresentation: o,\n });\n }\n }\n Object.freeze(processedRelationsInputUpdate);\n}\n\nexport function stringifyRelationsInputUpdate(\n data: DMMF.Model,\n allModels: Map<string, DMMF.Model>,\n) {\n const annotations = extractAnnotations(data.documentation);\n if (\n annotations.isHidden ||\n annotations.isHiddenInput ||\n annotations.isHiddenInputUpdate\n )\n return undefined;\n\n const fields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n\n if (\n annotations.isHidden ||\n annotations.isHiddenInput ||\n annotations.isHiddenInputUpdate ||\n isPrimitivePrismaFieldType(field.type) ||\n processedEnumsMap.has(field.type)\n ) {\n return undefined;\n }\n\n let typeboxIdType = \"String\";\n\n const relatedIdType = allModels\n .get(field.type)\n ?.fields.find((f) => f.isId)?.type;\n\n switch (relatedIdType) {\n case \"String\":\n typeboxIdType = \"String\";\n break;\n case \"Int\":\n typeboxIdType = \"Integer\";\n break;\n case \"BigInt\":\n typeboxIdType = \"Integer\";\n break;\n default:\n // Skip relation fields pointing to models without a simple @id\n return undefined;\n }\n\n let stringifiedType: string;\n\n if (field.isList) {\n stringifiedType = wrapWithPartial(`${\n getConfig().typeboxImportVariableName\n }.Object({\n\t\t\t\t\t\tconnect: ${wrapWithArray(`${getConfig().typeboxImportVariableName}.Object({\n\t\t\t\t\t\t\t\tid: ${\n getConfig().typeboxImportVariableName\n }.${typeboxIdType}(${generateTypeboxOptions({ input: annotations })})\n\t\t\t\t\t\t\t}, ${generateTypeboxOptions({ input: annotations })})`)},\n\t\t\t\t\t\tdisconnect: ${wrapWithArray(`${getConfig().typeboxImportVariableName}.Object({\n\t\t\t\t\t\t\t\tid: ${\n getConfig().typeboxImportVariableName\n }.${typeboxIdType}(${generateTypeboxOptions({ input: annotations })})\n\t\t\t\t\t\t\t}, ${generateTypeboxOptions({ input: annotations })})`)}\n\t\t\t\t\t}, ${generateTypeboxOptions({ input: annotations })})`);\n } else {\n if (field.isRequired) {\n stringifiedType = `${getConfig().typeboxImportVariableName}.Object({\n\t\t\t\t\t\tconnect: ${getConfig().typeboxImportVariableName}.Object({\n\t\t\t\t\t\t\tid: ${\n getConfig().typeboxImportVariableName\n }.${typeboxIdType}(${generateTypeboxOptions({ input: annotations })})\n\t\t\t\t\t\t}, ${generateTypeboxOptions({ input: annotations })})\n\t\t\t\t\t}, ${generateTypeboxOptions({ input: annotations })})`;\n } else {\n stringifiedType = wrapWithPartial(`${\n getConfig().typeboxImportVariableName\n }.Object({\n\t\t\t\t\t\tconnect: ${getConfig().typeboxImportVariableName}.Object({\n\t\t\t\t\t\t\tid: ${\n getConfig().typeboxImportVariableName\n }.${typeboxIdType}(${generateTypeboxOptions({ input: annotations })})\n\t\t\t\t\t\t}, ${generateTypeboxOptions({ input: annotations })}),\n\t\t\t\t\t\tdisconnect: ${getConfig().typeboxImportVariableName}.Boolean()\n\t\t\t\t\t}, ${generateTypeboxOptions({ input: annotations })})`);\n }\n }\n\n return `${field.name}: ${stringifiedType}`;\n })\n .filter((x) => x) as string[];\n\n return wrapWithPartial(\n `${getConfig().typeboxImportVariableName}.Object({${fields.join(\n \",\",\n )}},${generateTypeboxOptions({ input: annotations })})`,\n );\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport { extractAnnotations } from \"../annotations/annotations\";\nimport { generateTypeboxOptions } from \"../annotations/options\";\nimport { getConfig } from \"../config\";\nimport type { ProcessedModel } from \"../model\";\nimport { wrapWithPartial } from \"./wrappers/partial\";\n\nexport const processedSelect: ProcessedModel[] = [];\n\nexport function processSelect(models: DMMF.Model[] | Readonly<DMMF.Model[]>) {\n for (const m of models) {\n const o = stringifySelect(m);\n if (o) {\n processedSelect.push({ name: m.name, stringRepresentation: o });\n }\n }\n Object.freeze(processedSelect);\n}\n\nexport function stringifySelect(data: DMMF.Model) {\n const annotations = extractAnnotations(data.documentation);\n\n if (annotations.isHidden) return undefined;\n\n const fields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n if (annotations.isHidden) return undefined;\n\n return `${field.name}: ${getConfig().typeboxImportVariableName}.Boolean()`;\n })\n .filter((x) => x) as string[];\n\n fields.push(`_count: ${getConfig().typeboxImportVariableName}.Boolean()`);\n\n const ret = `${getConfig().typeboxImportVariableName}.Object({${[\n ...fields,\n ].join(\",\")}},${generateTypeboxOptions({ input: annotations })})\\n`;\n\n return wrapWithPartial(ret);\n}\n", "import { generateTypeboxOptions } from \"../../annotations/options\";\nimport { getConfig } from \"../../config\";\n\nexport function makeIntersection(\n inputModels: string[],\n options = generateTypeboxOptions({ exludeAdditionalProperties: true }),\n) {\n return `${getConfig().typeboxImportVariableName}.Intersect([${inputModels.join(\n \",\",\n )}], ${options})\\n`;\n}\n", "import type { DMMF } from \"@prisma/generator-helper\";\nimport {\n extractAnnotations,\n isTypeOverwriteVariant,\n} from \"../annotations/annotations\";\nimport { generateTypeboxOptions } from \"../annotations/options\";\nimport { getConfig } from \"../config\";\nimport type { ProcessedModel } from \"../model\";\nimport { processedEnumsMap } from \"./enum\";\nimport {\n isPrimitivePrismaFieldType,\n type PrimitivePrismaFieldType,\n stringifyPrimitiveType,\n} from \"./primitiveField\";\nimport { wrapWithArray } from \"./wrappers/array\";\nimport { makeIntersection } from \"./wrappers/intersect\";\nimport { wrapWithPartial } from \"./wrappers/partial\";\nimport { makeUnion } from \"./wrappers/union\";\n\nconst selfReferenceName = \"Self\";\n\nexport const processedWhere: ProcessedModel[] = [];\n\nexport function processWhere(models: DMMF.Model[] | Readonly<DMMF.Model[]>) {\n for (const m of models) {\n const o = stringifyWhere(m);\n if (o) {\n processedWhere.push({ name: m.name, stringRepresentation: o });\n }\n }\n Object.freeze(processedWhere);\n}\n\nexport function stringifyWhere(data: DMMF.Model) {\n const annotations = extractAnnotations(data.documentation);\n if (annotations.isHidden) return undefined;\n\n const fields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n if (annotations.isHidden) return undefined;\n\n let stringifiedType = \"\";\n\n if (isPrimitivePrismaFieldType(field.type)) {\n const overwrittenType = annotations.annotations\n .filter(isTypeOverwriteVariant)\n .at(0)?.value;\n\n if (overwrittenType) {\n stringifiedType = overwrittenType;\n } else {\n stringifiedType = stringifyPrimitiveType({\n fieldType: field.type as PrimitivePrismaFieldType,\n options: generateTypeboxOptions({\n exludeAdditionalProperties: false,\n input: annotations,\n }),\n });\n }\n } else if (processedEnumsMap.has(field.type)) {\n // biome-ignore lint/style/noNonNullAssertion: we checked this manually\n stringifiedType = processedEnumsMap.get(field.type)!.stringRepresentation;\n } else {\n return undefined;\n }\n\n if (field.isList) {\n stringifiedType = wrapWithArray(stringifiedType);\n }\n\n return `${field.name}: ${stringifiedType}`;\n })\n .filter((x) => x) as string[];\n\n if (getConfig().allowRecursion) {\n return wrapWithPartial(\n `${\n getConfig().typeboxImportVariableName\n }.Recursive(${selfReferenceName} =>${\n getConfig().typeboxImportVariableName\n }.Object({${AND_OR_NOT()},${fields.join(\",\")}},${generateTypeboxOptions({\n exludeAdditionalProperties: true,\n input: annotations,\n })}), { $id: \"${data.name}\"})`,\n );\n }\n\n return wrapWithPartial(\n `${getConfig().typeboxImportVariableName}.Object({${fields.join(\n \",\",\n )}},${generateTypeboxOptions({ exludeAdditionalProperties: true, input: annotations })})`,\n );\n}\n\nexport const processedWhereUnique: ProcessedModel[] = [];\n\nexport function processWhereUnique(\n models: DMMF.Model[] | Readonly<DMMF.Model[]>,\n) {\n for (const m of models) {\n const o = stringifyWhereUnique(m);\n if (o) {\n processedWhereUnique.push({ name: m.name, stringRepresentation: o });\n }\n }\n Object.freeze(processedWhereUnique);\n}\n\nexport function stringifyWhereUnique(data: DMMF.Model) {\n const annotations = extractAnnotations(data.documentation);\n if (annotations.isHidden) return undefined;\n\n const uniqueCompositeFields = data.uniqueFields\n .filter((fields) => fields.length > 1)\n .map((fields) => {\n const compositeName = fields.join(\"_\");\n const fieldObjects = fields.map(\n // biome-ignore lint/style/noNonNullAssertion: this must exist\n (f) => data.fields.find((field) => field.name === f)!,\n );\n\n const stringifiedFieldObjects = fieldObjects.map((f) => {\n const annotations = extractAnnotations(f.documentation);\n if (annotations.isHidden) return undefined;\n let stringifiedType = \"\";\n\n if (isPrimitivePrismaFieldType(f.type)) {\n const overwrittenType = annotations.annotations\n .filter(isTypeOverwriteVariant)\n .at(0)?.value;\n\n if (overwrittenType) {\n stringifiedType = overwrittenType;\n } else {\n stringifiedType = stringifyPrimitiveType({\n fieldType: f.type as PrimitivePrismaFieldType,\n options: generateTypeboxOptions({\n exludeAdditionalProperties: false,\n input: annotations,\n }),\n });\n }\n } else if (processedEnumsMap.has(f.type)) {\n // biome-ignore lint/style/noNonNullAssertion: we checked this manually\n stringifiedType = processedEnumsMap.get(f.type)!.stringRepresentation;\n } else {\n throw new Error(\"Invalid type for unique composite generation\");\n }\n\n return `${f.name}: ${stringifiedType}`;\n });\n\n const compositeObject = `${\n getConfig().typeboxImportVariableName\n }.Object({${stringifiedFieldObjects.join(\n \",\",\n )}}, ${generateTypeboxOptions({ exludeAdditionalProperties: true })})`;\n\n return `${compositeName}: ${compositeObject}`;\n });\n\n const allFields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n if (annotations.isHidden) return undefined;\n\n let stringifiedType = \"\";\n\n if (isPrimitivePrismaFieldType(field.type)) {\n const overwrittenType = annotations.annotations\n .filter(isTypeOverwriteVariant)\n .at(0)?.value;\n\n if (overwrittenType) {\n stringifiedType = overwrittenType;\n } else {\n stringifiedType = stringifyPrimitiveType({\n fieldType: field.type as PrimitivePrismaFieldType,\n options: generateTypeboxOptions({\n exludeAdditionalProperties: false,\n input: annotations,\n }),\n });\n }\n } else if (processedEnumsMap.has(field.type)) {\n // biome-ignore lint/style/noNonNullAssertion: we checked this manually\n stringifiedType = processedEnumsMap.get(field.type)!.stringRepresentation;\n } else {\n return undefined;\n }\n\n if (field.isList) {\n stringifiedType = wrapWithArray(stringifiedType);\n }\n\n return `${field.name}: ${stringifiedType}`;\n })\n .filter((x) => x) as string[];\n\n const uniqueFields = data.fields\n .map((field) => {\n const annotations = extractAnnotations(field.documentation);\n if (annotations.isHidden) return undefined;\n if (!field.isUnique && !field.isId) return undefined;\n\n let stringifiedType = \"\";\n\n if (isPrimitivePrismaFieldType(field.type)) {\n const overwrittenType = annotations.annotations\n .filter(isTypeOverwriteVariant)\n .at(0)?.value;\n\n if (overwrittenType) {\n stringifiedType = overwrittenType;\n } else {\n stringifiedType = stringifyPrimitiveType({\n fieldType: field.type as PrimitivePrismaFieldType,\n options: generateTypeboxOptions({\n exludeAdditionalProperties: false,\n input: annotations,\n }),\n });\n }\n } else if (processedEnumsMap.has(field.type)) {\n // biome-ignore lint/style/noNonNullAssertion: we checked this manually\n stringifiedType = processedEnumsMap.get(field.type)!.stringRepresentation;\n } else {\n return undefined;\n }\n\n if (field.isList) {\n stringifiedType = wrapWithArray(stringifiedType);\n }\n\n return `${field.name}: ${stringifiedType}`;\n })\n .filter((x) => x) as string[];\n\n const uniqueBaseObject = `${getConfig().typeboxImportVariableName}.Object({${[\n ...uniqueFields,\n ...uniqueCompositeFields,\n ].join(\n \",\",\n )}},${generateTypeboxOptions({ exludeAdditionalProperties: true, input: annotations })})`;\n\n if (getConfig().allowRecursion) {\n return `${\n getConfig().typeboxImportVariableName\n }.Recursive(${selfReferenceName} => ${makeIntersection([\n wrapWithPartial(uniqueBaseObject, true),\n makeUnion(\n [...uniqueFields, ...uniqueCompositeFields].map(\n (f) => `${getConfig().typeboxImportVariableName}.Object({${f}})`,\n ),\n ),\n wrapWithPartial(\n `${getConfig().typeboxImportVariableName}.Object({${AND_OR_NOT()}})`,\n true,\n ),\n wrapWithPartial(\n `${\n getConfig().typeboxImportVariableName\n }.Object({${allFields.join(\",\")}}, ${generateTypeboxOptions()})`,\n ),\n ])}, { $id: \"${data.name}\"})`;\n }\n\n return makeIntersection([\n wrapWithPartial(uniqueBaseObject, true),\n makeUnion(\n [...uniqueFields, ...uniqueCompositeFields].map(\n (f) => `${getConfig().typeboxImportVariableName}.Object({${f}})`,\n ),\n ),\n wrapWithPartial(\n `${getConfig().typeboxImportVariableName}.Object({${allFields.join(\n \",\",\n )}})`,\n ),\n ]);\n}\n\nfunction AND_OR_NOT() {\n return `AND: ${\n getConfig().typeboxImportVariableName\n }.Union([${selfReferenceName}, ${wrapWithArray(selfReferenceName)}]),\n\tNOT: ${\n getConfig().typeboxImportVariableName\n }.Union([${selfReferenceName}, ${wrapWithArray(selfReferenceName)}]),\n\tOR: ${wrapWithArray(selfReferenceName)}`;\n}\n", "import { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { generateBarrelFile } from \"./barrel\";\nimport { getConfig } from \"./config\";\nimport { format } from \"./format\";\nimport { mapAllModelsForWrite } from \"./model\";\n\nexport async function write() {\n const mappings = Array.from(mapAllModelsForWrite().entries());\n return Promise.all([\n ...mappings.map(async ([name, content]) => {\n return writeFile(\n join(getConfig().output, `${name}.ts`),\n await format(content),\n );\n }),\n writeFile(\n join(getConfig().output, \"barrel.ts\"),\n await format(generateBarrelFile(mappings.map(([key]) => key))),\n ),\n ]);\n}\n", "import { getConfig } from \"./config\";\n\nexport function generateBarrelFile(imports: string[]) {\n return imports\n .map((i) => `export * from \"./${i}${getConfig().importFileExtension}\";`)\n .join(\"\\n\");\n}\n", "import { format as prettierFormat } from \"prettier\";\n\nexport async function format(input: string) {\n try {\n return await prettierFormat(input, { parser: \"typescript\" });\n } catch (error) {\n console.error(\"Error formatting file\", error);\n return input;\n }\n}\n", "import { getConfig } from \"../config\";\n\nexport function transformDateType() {\n return `import { ${getConfig().typeboxImportVariableName} } from \"${getConfig().typeboxImportDependencyName}\";\n export const ${getConfig().transformDateName} = (options?: Parameters<typeof ${getConfig().typeboxImportVariableName}.String>[0]) => ${\n getConfig().typeboxImportVariableName\n }.Transform(${getConfig().typeboxImportVariableName}.String({ format: 'date-time', ...options }))\n .Decode((value) => new Date(value))\n .Encode((value) => value.toISOString())\\n`;\n}\n\nexport function transformDateImportStatement() {\n return `import { ${getConfig().transformDateName} } from \"./${\n getConfig().transformDateName\n }${getConfig().importFileExtension}\"\\n`;\n}\n", "import { generateTypeboxOptions } from \"../../annotations/options\";\nimport { getConfig } from \"../../config\";\n\nexport function makeComposite(inputModels: string[]) {\n return `${\n getConfig().typeboxImportVariableName\n }.Composite([${inputModels.map((i) => `${getConfig().exportedTypePrefix}${i}`).join(\",\")}], ${generateTypeboxOptions()})\\n`;\n}\n", "import { getConfig } from \"./config\";\nimport { processedEnums } from \"./generators/enum\";\nimport { processedInclude } from \"./generators/include\";\nimport { processedOrderBy } from \"./generators/orderBy\";\nimport { processedPlain, processedPlainMap } from \"./generators/plain\";\nimport { processedPlainInputCreate } from \"./generators/plainInputCreate\";\nimport { processedPlainInputUpdate } from \"./generators/plainInputUpdate\";\nimport {\n processedRelations,\n processedRelationsInputCreate,\n processedRelationsInputUpdate,\n} from \"./generators/relations\";\nimport { processedSelect } from \"./generators/select\";\nimport {\n transformDateImportStatement,\n transformDateType,\n} from \"./generators/transformDate\";\nimport { processedWhere, processedWhereUnique } from \"./generators/where\";\nimport { makeComposite } from \"./generators/wrappers/composite\";\nimport { nullableImport, nullableType } from \"./generators/wrappers/nullable\";\n\nexport type ProcessedModel = {\n name: string;\n stringRepresentation: string;\n};\n\nfunction convertModelToStandalone(\n input: Pick<ProcessedModel, \"name\" | \"stringRepresentation\">,\n) {\n return `export const ${getConfig().exportedTypePrefix}${input.name} = ${input.stringRepresentation}\\n`;\n}\n\nfunction typepoxImportStatement() {\n return `import { ${getConfig().typeboxImportVariableName} } from \"${\n getConfig().typeboxImportDependencyName\n }\"\\n`;\n}\n\nexport function mapAllModelsForWrite() {\n const modelsPerName = new Map<\n ProcessedModel[\"name\"],\n ProcessedModel[\"stringRepresentation\"]\n >();\n\n const process = (models: ProcessedModel[], suffix: string) => {\n for (const processedModel of models) {\n const standalone = convertModelToStandalone({\n ...processedModel,\n name: `${processedModel.name}${suffix}`,\n });\n const current = modelsPerName.get(processedModel.name);\n if (current) {\n modelsPerName.set(processedModel.name, `${current}\\n${standalone}`);\n } else {\n modelsPerName.set(processedModel.name, standalone);\n }\n }\n };\n\n process(processedEnums, \"\");\n process(processedPlain, \"Plain\");\n process(processedRelations, \"Relations\");\n process(processedPlainInputCreate, \"PlainInputCreate\");\n process(processedPlainInputUpdate, \"PlainInputUpdate\");\n process(processedRelationsInputCreate, \"RelationsInputCreate\");\n process(processedRelationsInputUpdate, \"RelationsInputUpdate\");\n process(processedWhere, \"Where\");\n process(processedWhereUnique, \"WhereUnique\");\n process(processedSelect, \"Select\");\n process(processedInclude, \"Include\");\n process(processedOrderBy, \"OrderBy\");\n\n const relationsSet = new Set(processedRelations.map((e) => e.name));\n const relationsInputCreateSet = new Set(\n processedRelationsInputCreate.map((e) => e.name),\n );\n const relationsInputUpdateSet = new Set(\n processedRelationsInputUpdate.map((e) => e.name),\n );\n\n for (const [key, value] of modelsPerName) {\n const hasPlain = processedPlainMap.has(key);\n const hasRelations = relationsSet.has(key);\n let composite: string;\n if (hasPlain && hasRelations) {\n composite = makeComposite([`${key}Plain`, `${key}Relations`]);\n } else if (hasPlain) {\n composite = `${key}Plain`;\n } else if (hasRelations) {\n composite = `${key}Relations`;\n } else {\n continue;\n }\n\n modelsPerName.set(\n key,\n `${value}\\n${convertModelToStandalone({\n name: key,\n stringRepresentation: composite,\n })}`,\n );\n }\n\n for (const [key, value] of modelsPerName) {\n if (relationsInputCreateSet.has(key)) {\n const composite = makeComposite([\n `${key}PlainInputCreate`,\n `${key}RelationsInputCreate`,\n ]);\n modelsPerName.set(\n key,\n `${value}\\n${convertModelToStandalone({\n name: `${key}InputCreate`,\n stringRepresentation: composite,\n })}`,\n );\n }\n }\n\n for (const [key, value] of modelsPerName) {\n if (relationsInputUpdateSet.has(key)) {\n const composite = makeComposite([\n `${key}PlainInputUpdate`,\n `${key}RelationsInputUpdate`,\n ]);\n modelsPerName.set(\n key,\n `${value}\\n${convertModelToStandalone({\n name: `${key}InputUpdate`,\n stringRepresentation: composite,\n })}`,\n );\n }\n }\n\n for (const [key, value] of modelsPerName) {\n modelsPerName.set(\n key,\n `${typepoxImportStatement()}\\n${transformDateImportStatement()}\\n${nullableImport()}\\n${value}`,\n );\n }\n\n modelsPerName.set(getConfig().nullableName, nullableType());\n modelsPerName.set(getConfig().transformDateName, transformDateType());\n\n return modelsPerName;\n}\n"],
5
+ "mappings": ";aAAA,IAAAA,EAAkC,4BAClCC,GAAiC,oCCDjC,IAAAC,EAAkC,6BAClCC,EAAsB,mCAEhBC,EAAe,OAAK,OACxB,CAIE,OAAQ,OAAK,OAAO,CAAE,QAAS,oBAAqB,CAAC,EAIrD,0BAA2B,OAAK,OAAO,CAAE,QAAS,MAAO,CAAC,EAI1D,4BAA6B,OAAK,OAAO,CAAE,QAAS,mBAAoB,CAAC,EAIzE,qBAAsB,OAAK,QAAQ,CAAE,QAAS,EAAM,CAAC,EAIrD,WAAY,OAAK,QAAQ,CAAE,QAAS,EAAM,CAAC,EAI3C,qBAAsB,OAAK,QAAQ,CAAE,QAAS,EAAK,CAAC,EAIpD,4BAA6B,OAAK,QAAQ,CAAE,QAAS,EAAK,CAAC,EAI3D,4BAA6B,OAAK,QAAQ,CAAE,QAAS,EAAK,CAAC,EAI3D,0BAA2B,OAAK,QAAQ,CAAE,QAAS,EAAK,CAAC,EAIzD,aAAc,OAAK,OAAO,CAAE,QAAS,cAAe,CAAC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AAQ,KAAK,UAAU,MAAM,EACrDS,GAAwBT,EAAQ,KAAK,UAAU,MAAM,EACrDU,GAA4BV,EAAQ,KAAK,UAAU,MAAM,EACzDW,GAA4BX,EAAQ,KAAK,UAAU,MAAM,GAE3DY,GAAcZ,EAAQ,KAAK,UAAU,MAAM,EAC3Ca,GAAeb,EAAQ,KAAK,UAAU,MAAM,EAC5Cc,GAAed,EAAQ,KAAK,UAAU,MAAM,EAE5C,MAAMe,GAAM,CACd,CACF,CAAC",
6
+ "names": ["import_promises", "import_generator_helper", "import_typebox", "import_value", "configSchema", "config", "setConfig", "input", "error", "getConfig", "isOptionsVariant", "annotation", "isTypeOverwriteVariant", "annotationKeys", "extractAnnotations", "input", "annotations", "description", "raw", "line", "l", "annotationKey", "key", "k", "isHidden", "isHiddenInput", "isHiddenInputCreate", "isHiddenInputUpdate", "a", "generateTypeboxOptions", "input", "exludeAdditionalProperties", "getConfig", "stringifiedOptions", "annotation", "isOptionsVariant", "makeUnion", "inputModels", "options", "generateTypeboxOptions", "getConfig", "processedEnums", "processedEnumsMap", "processEnums", "enums", "e", "stringRepresentation", "stringifyEnum", "model", "data", "annotations", "extractAnnotations", "variantsString", "v", "getConfig", "makeUnion", "generateTypeboxOptions", "PrimitiveFields", "isPrimitivePrismaFieldType", "str", "stringifyPrimitiveType", "fieldType", "options", "getConfig", "config", "opts", "wrapWithPartial", "input", "exludeAdditionalPropertiesInOptions", "getConfig", "generateTypeboxOptions", "processedInclude", "processInclude", "models", "m", "o", "stringifyInclude", "data", "annotations", "extractAnnotations", "fields", "field", "isPrimitivePrismaFieldType", "getConfig", "x", "ret", "generateTypeboxOptions", "wrapWithPartial", "processedOrderBy", "processOrderBy", "models", "m", "o", "stringifyOrderBy", "data", "annotations", "extractAnnotations", "fields", "field", "isPrimitivePrismaFieldType", "makeUnion", "getConfig", "x", "ret", "generateTypeboxOptions", "wrapWithPartial", "wrapWithArray", "input", "getConfig", "generateTypeboxOptions", "nullableType", "getConfig", "nullableImport", "wrapWithNullable", "input", "wrapWithOptional", "input", "getConfig", "processedPlain", "processedPlainMap", "processPlain", "models", "m", "o", "stringifyPlain", "model", "data", "isInputModelCreate", "isInputModelUpdate", "annotations", "extractAnnotations", "fields", "field", "getConfig", "stringifiedType", "isPrimitivePrismaFieldType", "overwrittenType", "isTypeOverwriteVariant", "stringifyPrimitiveType", "generateTypeboxOptions", "processedEnumsMap", "wrapWithArray", "madeOptional", "wrapWithNullable", "wrapWithOptional", "x", "processedPlainInputCreate", "processPlainInputCreate", "models", "m", "o", "stringifyPlain", "processedPlainInputUpdate", "processPlainInputUpdate", "models", "m", "o", "stringifyPlain", "processedRelations", "processRelations", "models", "m", "o", "stringifyRelations", "data", "annotations", "extractAnnotations", "fields", "field", "isPrimitivePrismaFieldType", "processedEnumsMap", "stringifiedType", "processedPlainMap", "wrapWithArray", "wrapWithNullable", "x", "getConfig", "generateTypeboxOptions", "processedRelationsInputCreate", "processRelationsInputCreate", "modelsMap", "stringifyRelationsInputCreate", "allModels", "typeboxIdType", "f", "connectString", "processedRelationsInputUpdate", "processRelationsInputUpdate", "stringifyRelationsInputUpdate", "wrapWithPartial", "processedSelect", "processSelect", "models", "m", "o", "stringifySelect", "data", "annotations", "extractAnnotations", "fields", "field", "getConfig", "x", "ret", "generateTypeboxOptions", "wrapWithPartial", "makeIntersection", "inputModels", "options", "generateTypeboxOptions", "getConfig", "selfReferenceName", "processedWhere", "processWhere", "models", "m", "o", "stringifyWhere", "data", "annotations", "extractAnnotations", "fields", "field", "stringifiedType", "isPrimitivePrismaFieldType", "overwrittenType", "isTypeOverwriteVariant", "stringifyPrimitiveType", "generateTypeboxOptions", "processedEnumsMap", "wrapWithArray", "x", "getConfig", "wrapWithPartial", "AND_OR_NOT", "processedWhereUnique", "processWhereUnique", "stringifyWhereUnique", "uniqueCompositeFields", "compositeName", "stringifiedFieldObjects", "f", "compositeObject", "allFields", "uniqueFields", "uniqueBaseObject", "makeIntersection", "makeUnion", "import_promises", "import_node_path", "generateBarrelFile", "imports", "i", "getConfig", "import_prettier", "format", "input", "prettierFormat", "error", "transformDateType", "getConfig", "transformDateImportStatement", "makeComposite", "inputModels", "getConfig", "i", "generateTypeboxOptions", "convertModelToStandalone", "input", "getConfig", "typepoxImportStatement", "mapAllModelsForWrite", "modelsPerName", "process", "models", "suffix", "processedModel", "standalone", "current", "processedEnums", "processedPlain", "processedRelations", "processedPlainInputCreate", "processedPlainInputUpdate", "processedRelationsInputCreate", "processedRelationsInputUpdate", "processedWhere", "processedWhereUnique", "processedSelect", "processedInclude", "processedOrderBy", "relationsSet", "e", "relationsInputCreateSet", "relationsInputUpdateSet", "key", "value", "hasPlain", "processedPlainMap", "hasRelations", "composite", "makeComposite", "transformDateImportStatement", "nullableImport", "nullableType", "transformDateType", "write", "mappings", "mapAllModelsForWrite", "name", "content", "getConfig", "format", "generateBarrelFile", "key", "options", "setConfig", "getConfig", "processEnums", "processPlain", "processRelations", "processWhere", "processWhereUnique", "processPlainInputCreate", "processPlainInputUpdate", "processRelationsInputCreate", "processRelationsInputUpdate", "processSelect", "processInclude", "processOrderBy", "write"]
7
+ }
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name":"@versantonlinesolutions/prismabox","version":"2.2.1","license":"MIT","description":"Typebox generator for prisma schema","author":{"name":"Ade Yahya Prasetyo, m1212e"},"keywords":["prisma2","prisma","prisma-generator","prisma-schema","code-generation","typebox","typebox-generator","prismabox"],"homepage":"https://github.com/m1212e/prismabox","repository":{"url":"https://github.com/m1212e/prismabox.git"},"scripts":{"dev":"bun run build && bunx prisma generate","build":"bun run typecheck && bun build.ts","lint":"biome check --write .","format":"bun run lint","typecheck":"tsc --noEmit"},"dependencies":{"@prisma/generator-helper":"^6.13.0","@sinclair/typebox":"^0.34.3","prettier":"^3.6.2"},"devDependencies":{"@biomejs/biome":"^2.1.3","@prisma/client":"6.13.0","@types/bun":"latest","esbuild":"^0.25.8","prisma":"6.13.0","typescript":"^5.9.2"},"bin":{"prismabox":"cli.js"}}