cogsbox-shape 0.5.166 → 0.5.167

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
@@ -412,6 +412,7 @@ type CreateSchemaBoxReturn<S extends Record<string, SchemaWithPlaceholders>, R e
412
412
  };
413
413
  defaults: Resolved[K]["zodSchemas"]["defaultValues"];
414
414
  stateType: Resolved[K]["zodSchemas"]["stateType"];
415
+ generateDefaults: () => Resolved[K]["zodSchemas"]["defaultValues"];
415
416
  nav: NavigationProxy<K & string, Resolved>;
416
417
  RelationSelection: NavigationToSelection<NavigationProxy<K & string, Resolved>>;
417
418
  createView: <const TSelection extends NavigationToSelection<NavigationProxy<K & string, Resolved>>>(selection: TSelection) => DeriveViewResult<K & string, TSelection, Resolved>;
package/dist/schema.js CHANGED
@@ -489,10 +489,11 @@ export function createSchema(schema, relations) {
489
489
  serverFields[key] = config.zodValidationSchema;
490
490
  const initialValueOrFn = config.initialValue;
491
491
  defaultGenerators[key] = initialValueOrFn;
492
- defaultValues[key] = inferDefaultFromZod(config.zodClientSchema, {
493
- ...config.sql,
494
- default: undefined,
495
- });
492
+ // FIX: Call the function with { uuid } if it's a function
493
+ let rawDefault = isFunction(initialValueOrFn)
494
+ ? initialValueOrFn({ uuid })
495
+ : initialValueOrFn;
496
+ defaultValues[key] = rawDefault;
496
497
  if (config.transforms) {
497
498
  fieldTransforms[key] = config.transforms;
498
499
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.166",
3
+ "version": "0.5.167",
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",