cogsbox-shape 0.5.165 → 0.5.166

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.
Files changed (2) hide show
  1. package/dist/schema.js +3 -4
  2. package/package.json +1 -1
package/dist/schema.js CHANGED
@@ -519,7 +519,7 @@ export function createSchema(schema, relations) {
519
519
  defaultGenerators[key] = initialValueOrFn;
520
520
  // Get the raw default value
521
521
  let rawDefault = isFunction(initialValueOrFn)
522
- ? initialValueOrFn()
522
+ ? initialValueOrFn({ uuid })
523
523
  : initialValueOrFn;
524
524
  // Apply toClient transform if it exists
525
525
  if (config.transforms?.toClient && rawDefault !== undefined) {
@@ -558,9 +558,8 @@ export function createSchema(schema, relations) {
558
558
  for (const key in defaultGenerators) {
559
559
  const generatorOrValue = defaultGenerators[key];
560
560
  let rawValue = isFunction(generatorOrValue)
561
- ? generatorOrValue()
561
+ ? generatorOrValue({ uuid }) // Pass the tools
562
562
  : generatorOrValue;
563
- // Apply toClient transform if it exists
564
563
  if (fieldTransforms[key]?.toClient && rawValue !== undefined) {
565
564
  freshDefaults[key] = fieldTransforms[key].toClient(rawValue);
566
565
  }
@@ -591,7 +590,7 @@ export function createSchema(schema, relations) {
591
590
  return {
592
591
  pk: pkKeys.length ? pkKeys : null,
593
592
  clientPk: clientPkKeys.length ? clientPkKeys : null,
594
- isClientRecord, // NOW IT'S IN SCOPE
593
+ isClientRecord,
595
594
  sqlSchema: z.object(sqlFields),
596
595
  clientSchema: z.object(clientFields),
597
596
  validationSchema: z.object(serverFields),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.165",
3
+ "version": "0.5.166",
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",