@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.7 → 1.3.1-dev.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shisyamo4131/air-guard-v2-schemas",
3
- "version": "1.3.1-dev.7",
3
+ "version": "1.3.1-dev.8",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -234,6 +234,7 @@ export default class OperationResult extends Operation {
234
234
  super.afterInitialize();
235
235
 
236
236
  /** Computed properties */
237
+ let _agreement = this.agreement;
237
238
  Object.defineProperties(this, {
238
239
  statistics: {
239
240
  configurable: true,
@@ -419,7 +420,17 @@ export default class OperationResult extends Operation {
419
420
  set(v) {},
420
421
  },
421
422
 
422
- /** add */
423
+ agreement: {
424
+ configurable: true,
425
+ enumerable: true,
426
+ get() {
427
+ return _agreement;
428
+ },
429
+ set(v) {
430
+ _agreement = v;
431
+ this.refreshBillingDateAt();
432
+ },
433
+ },
423
434
  hasAgreement: {
424
435
  configurable: true,
425
436
  enumerable: true,
@@ -472,8 +483,23 @@ export default class OperationResult extends Operation {
472
483
  this.refreshBillingDateAt();
473
484
  }
474
485
 
486
+ /**
487
+ * Override create method to validate billingDateAt when ignoreEmptyAgreement is true
488
+ * @param {*} options
489
+ * @returns {Promise<DocumentReference>}
490
+ */
491
+ async create(options = {}) {
492
+ if (this.ignoreEmptyAgreement && !this.billingDateAt) {
493
+ throw new Error(
494
+ "[OperationResult] Billing date is required when 'ignoreEmptyAgreement' is true."
495
+ );
496
+ }
497
+ return await super.create(options);
498
+ }
499
+
475
500
  /**
476
501
  * Override update method to prevent editing if isLocked is true
502
+ * - Also validate billingDateAt when ignoreEmptyAgreement is true
477
503
  * @param {*} options
478
504
  * @returns {Promise<void>}
479
505
  */
@@ -483,7 +509,12 @@ export default class OperationResult extends Operation {
483
509
  "[OperationResult] This OperationResult is locked and cannot be edited."
484
510
  );
485
511
  }
486
- return super.update(options);
512
+ if (this.ignoreEmptyAgreement && !this.billingDateAt) {
513
+ throw new Error(
514
+ "[OperationResult] Billing date is required when 'ignoreEmptyAgreement' is true."
515
+ );
516
+ }
517
+ return await super.update(options);
487
518
  }
488
519
 
489
520
  /**
@@ -497,6 +528,6 @@ export default class OperationResult extends Operation {
497
528
  "[OperationResult] This OperationResult is locked and cannot be deleted."
498
529
  );
499
530
  }
500
- return super.delete(options);
531
+ return await super.delete(options);
501
532
  }
502
533
  }