cogsbox-shape 0.5.151 → 0.5.153

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 +12 -15
  2. package/package.json +1 -1
package/dist/schema.js CHANGED
@@ -569,17 +569,17 @@ function createViewObject(initialRegistryKey, selection, registry, tableNameToRe
569
569
  if (!registryEntry) {
570
570
  throw new Error(`Schema with key "${currentRegistryKey}" not found in the registry.`);
571
571
  }
572
- // Check if this table has pk and clientPk (only check once per table)
572
+ // FIX: Check at the correct path - registryEntry.zodSchemas
573
573
  if (!(currentRegistryKey in checkedTables)) {
574
- const hasPks = !!(registryEntry.pk &&
575
- registryEntry.pk.length > 0 &&
576
- registryEntry.clientPk &&
577
- registryEntry.clientPk.length > 0);
574
+ const hasPks = !!(registryEntry.zodSchemas?.pk &&
575
+ registryEntry.zodSchemas.pk.length > 0 &&
576
+ registryEntry.zodSchemas?.clientPk &&
577
+ registryEntry.zodSchemas.clientPk.length > 0);
578
578
  checkedTables[currentRegistryKey] = hasPks;
579
579
  if (!hasPks) {
580
580
  console.log(`Table ${currentRegistryKey} missing pk/clientPk:`, {
581
- pk: registryEntry.pk,
582
- clientPk: registryEntry.clientPk,
581
+ pk: registryEntry.zodSchemas?.pk,
582
+ clientPk: registryEntry.zodSchemas?.clientPk,
583
583
  });
584
584
  allTablesSupportsReconciliation = false;
585
585
  }
@@ -617,16 +617,11 @@ function createViewObject(initialRegistryKey, selection, registry, tableNameToRe
617
617
  const finalShape = { ...primitiveShape, ...selectedRelationShapes };
618
618
  return z.object(finalShape);
619
619
  }
620
- // For array schemas, handle the initial registry key check
621
- const isArray = Array.isArray(selection);
622
- const actualSelection = isArray ? true : selection;
623
620
  return {
624
621
  sql: registry[initialRegistryKey].zodSchemas.sqlSchema,
625
- client: buildView(initialRegistryKey, actualSelection, "client"),
626
- server: buildView(initialRegistryKey, actualSelection, "server"),
622
+ client: buildView(initialRegistryKey, selection, "client"),
623
+ server: buildView(initialRegistryKey, selection, "server"),
627
624
  supportsReconciliation: allTablesSupportsReconciliation,
628
- // Debug info
629
- checkedTables,
630
625
  };
631
626
  }
632
627
  export function createSchemaBox(schemas, resolver) {
@@ -786,9 +781,11 @@ export function createSchemaBox(schemas, resolver) {
786
781
  toDb: entry.zodSchemas.toDb,
787
782
  },
788
783
  defaults: defaults,
789
- // ADD THESE BACK - views need the pk/clientPk arrays from base table
784
+ // Include the pk and clientPk arrays
790
785
  pk: entry.zodSchemas.pk,
791
786
  clientPk: entry.zodSchemas.clientPk,
787
+ // ADD THIS - the boolean from createViewObject
788
+ supportsReconciliation: view.supportsReconciliation,
792
789
  isView: true,
793
790
  viewSelection: selection,
794
791
  baseTable: tableName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.151",
3
+ "version": "0.5.153",
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",