cogsbox-shape 0.5.30 → 0.5.31

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 CHANGED
@@ -3203,11 +3203,12 @@ type BaseSchemaField<T extends SQLType = SQLType> = {
3203
3203
  toDb?: (clientValue: any) => any;
3204
3204
  };
3205
3205
  type AnyFieldDefinition = ReturnType<typeof shape.sql>;
3206
- type ReferenceField<TField extends AnyFieldDefinition, TTo extends SchemaField = any> = TField & {
3206
+ type ReferenceField<TField extends AnyFieldDefinition> = {
3207
+ field: TField;
3207
3208
  type: "reference";
3208
3209
  to: () => any;
3209
3210
  };
3210
- type SchemaField<T extends SQLType = SQLType> = BaseSchemaField<T> | ReferenceField<AnyFieldDefinition, any>;
3211
+ type SchemaField<T extends SQLType = SQLType> = BaseSchemaField<T> | ReferenceField<AnyFieldDefinition>;
3211
3212
  export type Schema<T extends Record<string, SchemaField | (() => Relation<any>)>> = {
3212
3213
  _tableName: string;
3213
3214
  __schemaId?: string;
@@ -3267,7 +3268,10 @@ type InferSqlSchema<T> = {
3267
3268
  config: {
3268
3269
  zodSqlSchema: infer S extends z.ZodTypeAny;
3269
3270
  };
3270
- } ? S : T[K] extends () => {
3271
+ } ? S : T[K] extends {
3272
+ type: "reference";
3273
+ field: infer F extends z.ZodTypeAny;
3274
+ } ? F : T[K] extends () => {
3271
3275
  type: "hasMany" | "manyToMany";
3272
3276
  schema: infer S extends SchemaDefinition;
3273
3277
  } ? z.ZodArray<z.ZodObject<Prettify<InferSqlSchema<S>>>> : T[K] extends () => {
package/dist/schema.js CHANGED
@@ -1,6 +1,4 @@
1
1
  import { z } from "zod";
2
- import { v4 as uuidv4 } from "uuid";
3
- import zodToJsonSchema, {} from "zod-to-json-schema";
4
2
  export const isFunction = (fn) => typeof fn === "function";
5
3
  // Function to create a properly typed current timestamp config
6
4
  export function currentTimeStamp() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.30",
3
+ "version": "0.5.31",
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",