@vibeorm/generator 1.1.8 → 1.2.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeorm/generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "TypeScript client generator for VibeORM — produces typed delegates, inputs, and Zod schemas from a Prisma schema",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"bun": ">=1.1.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@vibeorm/parser": "1.
|
|
40
|
+
"@vibeorm/parser": "1.2.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -197,7 +197,9 @@ function generateCreateInput(params: {
|
|
|
197
197
|
entries.push(` ${field.name}${isOptional ? "?" : ""}: ${tsType};`);
|
|
198
198
|
} else if (field.kind === "enum") {
|
|
199
199
|
const isOptional = !field.isRequired || field.default !== undefined;
|
|
200
|
-
|
|
200
|
+
const nullable = !field.isRequired && !field.isList ? " | null" : "";
|
|
201
|
+
const listSuffix = field.isList ? "[]" : "";
|
|
202
|
+
entries.push(` ${field.name}${isOptional ? "?" : ""}: ${field.enumName}${nullable}${listSuffix};`);
|
|
201
203
|
} else if (field.kind === "relation") {
|
|
202
204
|
// Relation fields in create — nested create/connect
|
|
203
205
|
if (field.isList) {
|
|
@@ -248,7 +250,9 @@ function generateUpdateInput(params: {
|
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
252
|
} else if (field.kind === "enum") {
|
|
251
|
-
|
|
253
|
+
const nullable = !field.isRequired && !field.isList ? " | null" : "";
|
|
254
|
+
const listSuffix = field.isList ? "[]" : "";
|
|
255
|
+
entries.push(` ${field.name}?: ${field.enumName}${nullable}${listSuffix};`);
|
|
252
256
|
} else if (field.kind === "relation") {
|
|
253
257
|
if (field.isList) {
|
|
254
258
|
entries.push(` ${field.name}?: {
|
|
@@ -16,8 +16,14 @@ export function generateModels(params: { schema: Schema }): string {
|
|
|
16
16
|
parts.push(`import type { ${enumImports} } from "./enums.ts";\n`);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// Generate JsonValue type
|
|
20
|
-
|
|
19
|
+
// Generate JsonValue type.
|
|
20
|
+
//
|
|
21
|
+
// Arrays and object index signatures are `readonly` so that `readonly T[]` /
|
|
22
|
+
// `ReadonlyArray<T>` (common in typed catalogues, factories, seed scripts) can
|
|
23
|
+
// be assigned into Json columns without forcing a spread/cast at every call
|
|
24
|
+
// site. Postgres doesn't care about JS array mutability — this is a purely
|
|
25
|
+
// type-level relaxation that's strictly more permissive in argument position.
|
|
26
|
+
parts.push(`export type JsonValue = string | number | boolean | null | readonly JsonValue[] | { readonly [key: string]: JsonValue };\n`);
|
|
21
27
|
|
|
22
28
|
// Generate the base OperationPayload interface
|
|
23
29
|
parts.push(`export type OperationPayload = {
|