@composio/json-schema-to-zod 0.1.10-next.0 → 0.1.10-next.2

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/index.cjs CHANGED
@@ -406,10 +406,12 @@ function parseObjectProperties(objectSchema, refs) {
406
406
  ...refs,
407
407
  path: [...refs.path, "properties", key]
408
408
  });
409
- const hasDefault = typeof propJsonSchema === "object" && propJsonSchema.default !== void 0;
410
- const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : typeof propJsonSchema === "object" && propJsonSchema.required === true;
411
- const isOptional = !hasDefault && !required;
412
- properties[key] = isOptional ? propZodSchema.optional() : propZodSchema;
409
+ const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : false;
410
+ if (!required && propJsonSchema && typeof propJsonSchema === "object" && "default" in propJsonSchema) {
411
+ properties[key] = propZodSchema.optional().default(propJsonSchema.default);
412
+ } else {
413
+ properties[key] = required ? propZodSchema : propZodSchema.optional();
414
+ }
413
415
  }
414
416
  return z14.object(properties);
415
417
  }
package/dist/index.js CHANGED
@@ -370,10 +370,12 @@ function parseObjectProperties(objectSchema, refs) {
370
370
  ...refs,
371
371
  path: [...refs.path, "properties", key]
372
372
  });
373
- const hasDefault = typeof propJsonSchema === "object" && propJsonSchema.default !== void 0;
374
- const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : typeof propJsonSchema === "object" && propJsonSchema.required === true;
375
- const isOptional = !hasDefault && !required;
376
- properties[key] = isOptional ? propZodSchema.optional() : propZodSchema;
373
+ const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : false;
374
+ if (!required && propJsonSchema && typeof propJsonSchema === "object" && "default" in propJsonSchema) {
375
+ properties[key] = propZodSchema.optional().default(propJsonSchema.default);
376
+ } else {
377
+ properties[key] = required ? propZodSchema : propZodSchema.optional();
378
+ }
377
379
  }
378
380
  return z14.object(properties);
379
381
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/json-schema-to-zod",
3
- "version": "0.1.10-next.0",
3
+ "version": "0.1.10-next.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",