cogsbox-shape 0.5.32 → 0.5.34
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/example/schema.d.ts +1638 -598
- package/dist/example/user.d.ts +2494 -1454
- package/dist/example/user.js +22 -21
- package/dist/schema.d.ts +2235 -729
- package/dist/schema.js +10 -3
- package/package.json +1 -1
package/dist/schema.js
CHANGED
|
@@ -267,9 +267,8 @@ function inferDefaultFromZod(zodType, sqlConfig) {
|
|
|
267
267
|
}
|
|
268
268
|
export function reference(config) {
|
|
269
269
|
return {
|
|
270
|
-
field: config.field,
|
|
271
270
|
type: "reference",
|
|
272
|
-
to:
|
|
271
|
+
to: config,
|
|
273
272
|
};
|
|
274
273
|
}
|
|
275
274
|
export function createMixedValidationSchema(schema, clientSchema, dbSchema) {
|
|
@@ -377,7 +376,15 @@ export function createSchema(schema) {
|
|
|
377
376
|
defaultValues[key] = childSchemaResult.defaultValues;
|
|
378
377
|
}
|
|
379
378
|
}
|
|
380
|
-
|
|
379
|
+
else if (field &&
|
|
380
|
+
typeof field === "object" &&
|
|
381
|
+
field.type === "reference") {
|
|
382
|
+
const referencedField = field.to();
|
|
383
|
+
sqlFields[key] = referencedField.config.zodSqlSchema;
|
|
384
|
+
clientFields[key] = referencedField.config.zodClientSchema;
|
|
385
|
+
validationFields[key] = referencedField.config.zodValidationSchema;
|
|
386
|
+
defaultValues[key] = referencedField.config.initialValue;
|
|
387
|
+
}
|
|
381
388
|
else if (field && typeof field === "object" && "config" in field) {
|
|
382
389
|
sqlFields[key] = field.config.zodSqlSchema;
|
|
383
390
|
clientFields[key] = field.config.zodClientSchema;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cogsbox-shape",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.34",
|
|
4
4
|
"description": "A TypeScript library for creating type-safe database schemas with Zod validation, SQL type definitions, and automatic client/server transformations. Unifies client, server, and database types through a single schema definition, with built-in support for relationships and serialization.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|