cogsbox-shape 0.5.164 → 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.
package/dist/schema.d.ts CHANGED
@@ -324,7 +324,7 @@ type _DeriveViewShape<TTableName extends keyof TRegistry, TSelection, TRegistry
324
324
  } ? RelType extends "hasMany" | "manyToMany" ? z.ZodArray<z.ZodObject<_DeriveViewShape<TargetKey, TSelection[K], TRegistry, TKey, [
325
325
  ...Depth,
326
326
  1
327
- ]>>> : z.ZodOptional<z.ZodObject<_DeriveViewShape<TargetKey, TSelection[K], TRegistry, TKey, [
327
+ ]>>> : z.ZodNullable<z.ZodObject<_DeriveViewShape<TargetKey, TSelection[K], TRegistry, TKey, [
328
328
  ...Depth,
329
329
  1
330
330
  ]>>> : never : never : never;
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),
@@ -652,7 +651,7 @@ function createViewObject(initialRegistryKey, selection, registry, tableNameToRe
652
651
  selectedRelationShapes[relationKey] = z.array(relationSchema);
653
652
  }
654
653
  else {
655
- selectedRelationShapes[relationKey] = relationSchema.optional();
654
+ selectedRelationShapes[relationKey] = relationSchema.nullable();
656
655
  }
657
656
  }
658
657
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.164",
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",