cogsbox-shape 0.5.6 → 0.5.7
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/schema.d.ts +9 -2
- package/dist/schema.js +0 -1
- package/package.json +1 -1
package/dist/schema.d.ts
CHANGED
|
@@ -1218,7 +1218,13 @@ type BaseSchemaField<T extends SQLType = SQLType> = {
|
|
|
1218
1218
|
};
|
|
1219
1219
|
type ReferenceField = {
|
|
1220
1220
|
type: "reference";
|
|
1221
|
-
to: () =>
|
|
1221
|
+
to: () => any;
|
|
1222
|
+
sql: SQLType;
|
|
1223
|
+
zodDbSchema: z.ZodType<any>;
|
|
1224
|
+
zodClientSchema: z.ZodType<any>;
|
|
1225
|
+
defaultValue?: any;
|
|
1226
|
+
toClient?: (dbValue: any) => any;
|
|
1227
|
+
toDb?: (clientValue: any) => any;
|
|
1222
1228
|
};
|
|
1223
1229
|
type SchemaField<T extends SQLType = SQLType> = BaseSchemaField<T> | ReferenceField;
|
|
1224
1230
|
export type Schema<T extends Record<string, SchemaField | (() => Relation<any>)>> = {
|
|
@@ -1408,9 +1414,10 @@ type InferSerializedSchema<T> = {
|
|
|
1408
1414
|
};
|
|
1409
1415
|
} : never;
|
|
1410
1416
|
};
|
|
1417
|
+
type ShapeFieldReturn = ReturnType<typeof shape.sql>;
|
|
1411
1418
|
export declare function reference<T = any>(config: {
|
|
1412
1419
|
to: () => T;
|
|
1413
|
-
field:
|
|
1420
|
+
field: ShapeFieldReturn;
|
|
1414
1421
|
}): ReferenceField;
|
|
1415
1422
|
export declare function createSchema<T extends Schema<any>>(schema: T): {
|
|
1416
1423
|
dbSchema: z.ZodObject<Prettify<InferDBSchema<T>>>;
|
package/dist/schema.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cogsbox-shape",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
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",
|