zenstack-trpc 0.1.9 → 0.1.16
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/zod-schemas.d.ts +2 -2
- package/dist/zod-schemas.d.ts.map +1 -1
- package/dist/zod-schemas.js +19 -2
- package/package.json +9 -12
package/dist/zod-schemas.d.ts
CHANGED
|
@@ -60,10 +60,10 @@ export declare function createModelSchemas<Schema extends SchemaDef>(schema: Sch
|
|
|
60
60
|
select: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
61
61
|
include: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
62
62
|
}, z.core.$loose>;
|
|
63
|
-
createMany: z.
|
|
63
|
+
createMany: z.ZodObject<{
|
|
64
64
|
data: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>]>;
|
|
65
65
|
skipDuplicates: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
-
}, z.core.$loose
|
|
66
|
+
}, z.core.$loose>;
|
|
67
67
|
update: z.ZodObject<{
|
|
68
68
|
where: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
69
69
|
data: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-schemas.d.ts","sourceRoot":"","sources":["../src/zod-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAsDxD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,SAAS,EACxD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,MAAM,CAAC,QAAQ,C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AC,MAAM,SAAS,SAAS,EAC9D,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,MAAM,CAAC,QAAQ,CAAC,GAChC,CAAC,CAAC,UAAU,CAsCd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,SAAS,SAAS,EACzD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,MAAM,CAAC,QAAQ,CAAC,GAChC,CAAC,CAAC,UAAU,CAcd;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,SAAS,EAC1D,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,MAAM,CAAC,QAAQ,CAAC,GAChC,CAAC,CAAC,UAAU,CAiBd;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,SAAS,EAC1D,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,MAAM,CAAC,QAAQ,CAAC,GAChC,CAAC,CAAC,UAAU,CAkBd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,SAAS,SAAS,EACzD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkIlC"}
|
package/dist/zod-schemas.js
CHANGED
|
@@ -182,8 +182,26 @@ export function createUniqueWhereSchema(schema, modelName) {
|
|
|
182
182
|
return z.object({}).passthrough();
|
|
183
183
|
}
|
|
184
184
|
const uniqueFields = model.uniqueFields;
|
|
185
|
+
const fields = model.fields;
|
|
185
186
|
const shape = {};
|
|
186
187
|
for (const [fieldName, fieldDef] of Object.entries(uniqueFields)) {
|
|
188
|
+
const compoundFields = Array.isArray(fieldDef.fields)
|
|
189
|
+
? fieldDef.fields
|
|
190
|
+
: null;
|
|
191
|
+
if (compoundFields) {
|
|
192
|
+
const compoundShape = {};
|
|
193
|
+
for (const compoundField of compoundFields) {
|
|
194
|
+
const fieldInfo = fields[compoundField];
|
|
195
|
+
if (fieldInfo) {
|
|
196
|
+
compoundShape[compoundField] = getZodTypeForField(fieldInfo.type, false, fieldInfo.array === true);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
compoundShape[compoundField] = z.any();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
shape[fieldName] = z.object(compoundShape).passthrough().optional();
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
187
205
|
const fieldType = fieldDef.type;
|
|
188
206
|
shape[fieldName] = getZodTypeForField(fieldType, true, false);
|
|
189
207
|
}
|
|
@@ -292,8 +310,7 @@ export function createModelSchemas(schema, modelName) {
|
|
|
292
310
|
data: z.union([createDataSchema, z.array(createDataSchema)]),
|
|
293
311
|
skipDuplicates: z.boolean().optional(),
|
|
294
312
|
})
|
|
295
|
-
.passthrough()
|
|
296
|
-
.optional(),
|
|
313
|
+
.passthrough(),
|
|
297
314
|
update: z.object({
|
|
298
315
|
where: uniqueWhereSchema,
|
|
299
316
|
data: updateDataSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zenstack-trpc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Auto-generate type-safe tRPC routers from ZenStack V3 schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
|
-
"require": "./dist/index.js",
|
|
14
13
|
"default": "./dist/index.js"
|
|
15
14
|
}
|
|
16
15
|
},
|
|
@@ -19,6 +18,13 @@
|
|
|
19
18
|
"README.md",
|
|
20
19
|
"LICENSE"
|
|
21
20
|
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.build.json",
|
|
23
|
+
"prepublishOnly": "pnpm run build",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"typecheck": "tsc --noEmit"
|
|
27
|
+
},
|
|
22
28
|
"keywords": [
|
|
23
29
|
"zenstack",
|
|
24
30
|
"trpc",
|
|
@@ -64,22 +70,13 @@
|
|
|
64
70
|
"@trpc/client": "^11.8.1",
|
|
65
71
|
"@trpc/react-query": "^11.8.1",
|
|
66
72
|
"@trpc/server": "^11.8.1",
|
|
67
|
-
"@types/better-sqlite3": "^7.6.13",
|
|
68
73
|
"@types/node": "^25.0.3",
|
|
69
|
-
"@zenstackhq/cli": "^3.1.0",
|
|
70
74
|
"@zenstackhq/orm": "^3.1.0",
|
|
71
75
|
"better-sqlite3": "^12.5.0",
|
|
72
76
|
"kysely": "^0.28.9",
|
|
73
|
-
"prisma": "^7.2.0",
|
|
74
77
|
"tsx": "^4.21.0",
|
|
75
78
|
"typescript": "^5.9.3",
|
|
76
79
|
"vitest": "^4.0.16",
|
|
77
80
|
"zod": "^4.3.5"
|
|
78
|
-
},
|
|
79
|
-
"scripts": {
|
|
80
|
-
"build": "tsc -p tsconfig.build.json",
|
|
81
|
-
"test": "vitest run",
|
|
82
|
-
"test:watch": "vitest",
|
|
83
|
-
"typecheck": "tsc --noEmit"
|
|
84
81
|
}
|
|
85
|
-
}
|
|
82
|
+
}
|