cogsbox-shape 0.5.46 → 0.5.48

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 +4 -3
  2. package/package.json +1 -1
package/dist/schema.js CHANGED
@@ -340,7 +340,7 @@ function isRelation(value) {
340
340
  typeof value === "object" &&
341
341
  "type" in value &&
342
342
  "fromKey" in value &&
343
- typeof value.toKey === "function" && // More specific check
343
+ "toKey" in value &&
344
344
  "schema" in value);
345
345
  }
346
346
  export function createSchema(schema) {
@@ -352,16 +352,17 @@ export function createSchema(schema) {
352
352
  if (key === "_tableName" || key.startsWith("__"))
353
353
  continue;
354
354
  const field = schema[key];
355
+ console.log("FIELD", field);
356
+ console.log("is fucntion", isFunction(field));
355
357
  // Case 1: Handle relation functions (hasMany, hasOne, etc.)
356
358
  if (isFunction(field)) {
357
359
  const relation = field();
360
+ console.log("isRelation(relation)", isRelation(relation));
358
361
  if (!isRelation(relation)) {
359
362
  continue;
360
363
  }
361
364
  const childSchemaResult = createSchema(relation.schema());
362
365
  if (relation.type === "hasMany" || relation.type === "manyToMany") {
363
- // CORRECTLY ADD THE RELATION TO THE LIST OF VALIDATION FIELDS
364
- // Make it optional, as relations are often not included on create/update.
365
366
  validationFields[key] = z
366
367
  .array(childSchemaResult.validationSchema)
367
368
  .optional();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.46",
3
+ "version": "0.5.48",
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",