cogsbox-shape 0.5.156 → 0.5.157

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
@@ -453,6 +453,11 @@ type DeriveDefaults<T, Depth extends any[] = []> = Prettify<Depth["length"] exte
453
453
  initialValue: infer D;
454
454
  };
455
455
  } ? D extends () => infer R ? R : D : never : T[K] extends {
456
+ config: {
457
+ transforms: any;
458
+ zodClientSchema: infer TClient extends z.ZodTypeAny;
459
+ };
460
+ } ? z.infer<TClient> : T[K] extends {
456
461
  config: {
457
462
  initialValue: infer D;
458
463
  };
package/dist/schema.js CHANGED
@@ -521,6 +521,11 @@ export function createSchema(schema, relations) {
521
521
  : initialValueOrFn;
522
522
  }
523
523
  }
524
+ } // Apply transforms to default values so they match client schema
525
+ for (const key in fieldTransforms) {
526
+ if (key in defaultValues && defaultValues[key] !== undefined) {
527
+ defaultValues[key] = fieldTransforms[key].toClient(defaultValues[key]);
528
+ }
524
529
  }
525
530
  const generateDefaults = () => {
526
531
  const freshDefaults = {};
@@ -530,6 +535,11 @@ export function createSchema(schema, relations) {
530
535
  ? generatorOrValue() // Call the function to get a fresh value
531
536
  : generatorOrValue; // Use the static value
532
537
  }
538
+ for (const key in fieldTransforms) {
539
+ if (key in freshDefaults && freshDefaults[key] !== undefined) {
540
+ freshDefaults[key] = fieldTransforms[key].toClient(freshDefaults[key]);
541
+ }
542
+ }
533
543
  return freshDefaults;
534
544
  };
535
545
  const toClient = (dbObject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.156",
3
+ "version": "0.5.157",
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",