s3db.js 4.1.3 → 4.1.4

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/s3db.iife.js CHANGED
@@ -3474,6 +3474,7 @@ ${JSON.stringify(validation, null, 2)}`
3474
3474
  this.attributes = attributes || {};
3475
3475
  this.passphrase = passphrase ?? "secret";
3476
3476
  this.options = lodashEs.merge({}, this.defaultOptions(), options);
3477
+ this.allNestedObjectsOptional = this.options.allNestedObjectsOptional ?? false;
3477
3478
  const processedAttributes = this.preprocessAttributesForValidation(this.attributes);
3478
3479
  this.validator = new ValidatorManager({ autoEncrypt: false }).compile(lodashEs.merge(
3479
3480
  { $$async: true },
@@ -3671,11 +3672,17 @@ ${JSON.stringify(validation, null, 2)}`
3671
3672
  const processed = {};
3672
3673
  for (const [key, value] of Object.entries(attributes)) {
3673
3674
  if (typeof value === "object" && value !== null && !Array.isArray(value)) {
3674
- processed[key] = {
3675
+ const isExplicitRequired = value.$$type && value.$$type.includes("required");
3676
+ const isExplicitOptional = value.$$type && value.$$type.includes("optional");
3677
+ const objectConfig = {
3675
3678
  type: "object",
3676
3679
  properties: this.preprocessAttributesForValidation(value),
3677
3680
  strict: false
3678
3681
  };
3682
+ if (isExplicitRequired) ; else if (isExplicitOptional || this.allNestedObjectsOptional) {
3683
+ objectConfig.optional = true;
3684
+ }
3685
+ processed[key] = objectConfig;
3679
3686
  } else {
3680
3687
  processed[key] = value;
3681
3688
  }
@@ -8837,6 +8844,7 @@ ${JSON.stringify(validation, null, 2)}`
8837
8844
  partitions: {},
8838
8845
  paranoid: true,
8839
8846
  // Security flag for dangerous operations
8847
+ allNestedObjectsOptional: options.allNestedObjectsOptional ?? false,
8840
8848
  ...options
8841
8849
  };
8842
8850
  this.hooks = {
@@ -8871,7 +8879,10 @@ ${JSON.stringify(validation, null, 2)}`
8871
8879
  attributes: this.attributes,
8872
8880
  passphrase,
8873
8881
  version: this.version,
8874
- options: this.options
8882
+ options: {
8883
+ ...this.options,
8884
+ allNestedObjectsOptional: this.options.allNestedObjectsOptional ?? false
8885
+ }
8875
8886
  });
8876
8887
  this.validatePartitions();
8877
8888
  this.setupPartitionHooks();
@@ -9798,7 +9809,7 @@ ${JSON.stringify(validation, null, 2)}`
9798
9809
  this.version = "1";
9799
9810
  this.s3dbVersion = (() => {
9800
9811
  try {
9801
- return true ? "4.1.2" : "latest";
9812
+ return true ? "4.1.3" : "latest";
9802
9813
  } catch (e) {
9803
9814
  return "latest";
9804
9815
  }