@labdigital/commercetools-mock 2.37.0 → 2.38.0

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 (130) hide show
  1. package/dist/index.cjs +211 -80
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +211 -80
  4. package/dist/index.js.map +1 -1
  5. package/package.json +10 -9
  6. package/src/ctMock.ts +10 -6
  7. package/src/helpers.ts +4 -4
  8. package/src/index.ts +2 -1
  9. package/src/lib/expandParser.ts +1 -1
  10. package/src/lib/haversine.test.ts +2 -1
  11. package/src/lib/password.ts +2 -2
  12. package/src/lib/predicateParser.ts +1 -1
  13. package/src/lib/productSearchFilter.test.ts +4 -1
  14. package/src/lib/projectionSearchFilter.ts +3 -3
  15. package/src/oauth/helpers.ts +1 -1
  16. package/src/oauth/server.test.ts +2 -1
  17. package/src/oauth/server.ts +5 -8
  18. package/src/oauth/store.ts +1 -1
  19. package/src/priceSelector.ts +1 -1
  20. package/src/product-projection-search.ts +4 -2
  21. package/src/product-search.ts +2 -2
  22. package/src/projectAPI.ts +4 -4
  23. package/src/repositories/abstract.ts +20 -3
  24. package/src/repositories/associate-role.ts +3 -3
  25. package/src/repositories/attribute-group.ts +3 -3
  26. package/src/repositories/business-unit.ts +6 -4
  27. package/src/repositories/cart/actions.ts +6 -7
  28. package/src/repositories/cart/helpers.ts +1 -1
  29. package/src/repositories/cart/index.ts +1 -1
  30. package/src/repositories/cart-discount/actions.ts +2 -5
  31. package/src/repositories/cart-discount/index.ts +1 -1
  32. package/src/repositories/category/actions.ts +4 -7
  33. package/src/repositories/category/index.ts +3 -3
  34. package/src/repositories/channel.ts +2 -2
  35. package/src/repositories/custom-object.ts +3 -6
  36. package/src/repositories/customer/actions.ts +272 -68
  37. package/src/repositories/customer/index.ts +10 -8
  38. package/src/repositories/customer-group.ts +2 -2
  39. package/src/repositories/discount-code/actions.ts +2 -5
  40. package/src/repositories/discount-code/index.ts +1 -1
  41. package/src/repositories/extension.ts +3 -3
  42. package/src/repositories/helpers.ts +4 -2
  43. package/src/repositories/index.ts +1 -1
  44. package/src/repositories/inventory-entry/actions.ts +2 -5
  45. package/src/repositories/inventory-entry/index.ts +1 -1
  46. package/src/repositories/my-customer.ts +2 -2
  47. package/src/repositories/order/actions.ts +2 -5
  48. package/src/repositories/order/index.ts +3 -6
  49. package/src/repositories/order-edit.ts +3 -2
  50. package/src/repositories/payment/actions.ts +2 -5
  51. package/src/repositories/payment/helpers.ts +6 -3
  52. package/src/repositories/payment/index.ts +3 -2
  53. package/src/repositories/product/actions.ts +2 -2
  54. package/src/repositories/product/helpers.ts +4 -4
  55. package/src/repositories/product/index.ts +3 -2
  56. package/src/repositories/product-discount.ts +3 -7
  57. package/src/repositories/product-projection.ts +2 -5
  58. package/src/repositories/product-selection.ts +3 -7
  59. package/src/repositories/product-tailoring.ts +3 -7
  60. package/src/repositories/product-type.ts +7 -11
  61. package/src/repositories/project.ts +4 -8
  62. package/src/repositories/quote-request.ts +3 -2
  63. package/src/repositories/quote.ts +3 -2
  64. package/src/repositories/review.ts +6 -3
  65. package/src/repositories/shipping-method/actions.ts +5 -6
  66. package/src/repositories/shipping-method/helpers.ts +4 -1
  67. package/src/repositories/shipping-method/index.ts +3 -6
  68. package/src/repositories/shopping-list/actions.ts +3 -6
  69. package/src/repositories/shopping-list/index.ts +4 -3
  70. package/src/repositories/staged-quote.ts +3 -2
  71. package/src/repositories/standalone-price.ts +3 -7
  72. package/src/repositories/state.ts +3 -7
  73. package/src/repositories/store.ts +3 -7
  74. package/src/repositories/subscription.ts +4 -8
  75. package/src/repositories/tax-category/actions.ts +2 -1
  76. package/src/repositories/tax-category/helpers.ts +1 -1
  77. package/src/repositories/tax-category/index.ts +3 -2
  78. package/src/repositories/type/actions.ts +2 -1
  79. package/src/repositories/type/index.ts +3 -2
  80. package/src/repositories/zone.ts +3 -7
  81. package/src/services/abstract.ts +2 -2
  82. package/src/services/associate-roles.test.ts +1 -1
  83. package/src/services/associate-roles.ts +2 -2
  84. package/src/services/attribute-group.ts +2 -2
  85. package/src/services/business-units.test.ts +1 -1
  86. package/src/services/business-units.ts +2 -2
  87. package/src/services/cart-discount.test.ts +1 -1
  88. package/src/services/cart-discount.ts +2 -2
  89. package/src/services/category.ts +2 -2
  90. package/src/services/channel.ts +2 -2
  91. package/src/services/customer-group.ts +2 -2
  92. package/src/services/customer.test.ts +422 -132
  93. package/src/services/customer.ts +4 -3
  94. package/src/services/discount-code.ts +2 -2
  95. package/src/services/extension.ts +2 -2
  96. package/src/services/index.ts +1 -1
  97. package/src/services/inventory-entry.ts +2 -2
  98. package/src/services/my-business-unit.ts +1 -1
  99. package/src/services/my-cart.ts +3 -2
  100. package/src/services/my-customer.ts +4 -3
  101. package/src/services/my-order.ts +1 -1
  102. package/src/services/my-payment.ts +2 -2
  103. package/src/services/my-shopping-list.ts +2 -2
  104. package/src/services/order.ts +2 -2
  105. package/src/services/payment.ts +2 -2
  106. package/src/services/product-discount.ts +2 -2
  107. package/src/services/product-projection.test.ts +1 -1
  108. package/src/services/product-projection.ts +2 -2
  109. package/src/services/product-selection.ts +2 -2
  110. package/src/services/product-type.ts +2 -2
  111. package/src/services/product.test.ts +1 -1
  112. package/src/services/product.ts +2 -2
  113. package/src/services/project.ts +3 -3
  114. package/src/services/reviews.ts +2 -2
  115. package/src/services/shipping-method.ts +2 -2
  116. package/src/services/shopping-list.test.ts +1 -1
  117. package/src/services/shopping-list.ts +2 -2
  118. package/src/services/standalone-price.ts +2 -2
  119. package/src/services/state.ts +2 -2
  120. package/src/services/store.ts +2 -2
  121. package/src/services/subscription.ts +2 -2
  122. package/src/services/tax-category.ts +2 -2
  123. package/src/services/type.ts +2 -2
  124. package/src/services/zone.ts +2 -2
  125. package/src/shipping.test.ts +1 -1
  126. package/src/shipping.ts +3 -3
  127. package/src/storage/abstract.ts +5 -1
  128. package/src/storage/in-memory.ts +6 -8
  129. package/src/types.ts +2 -2
  130. package/src/validate.ts +2 -2
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ var validatePasswordResetToken = (token) => {
56
56
  if (secret !== PWRESET_SECRET) {
57
57
  return void 0;
58
58
  }
59
- if (parseInt(time) < (/* @__PURE__ */ new Date()).getTime()) {
59
+ if (Number.parseInt(time) < (/* @__PURE__ */ new Date()).getTime()) {
60
60
  return void 0;
61
61
  }
62
62
  return customerId;
@@ -81,7 +81,7 @@ var getBearerToken = (request) => {
81
81
  };
82
82
 
83
83
  // src/oauth/store.ts
84
- import { randomBytes } from "crypto";
84
+ import { randomBytes } from "node:crypto";
85
85
  import { v4 as uuidv42 } from "uuid";
86
86
  var OAuth2Store = class {
87
87
  tokens = [];
@@ -452,7 +452,7 @@ var nestedLookup = (obj, path) => {
452
452
  let val = obj;
453
453
  for (let i = 0; i < parts.length; i++) {
454
454
  const part = parts[i];
455
- if (val == void 0) {
455
+ if (val === void 0) {
456
456
  return void 0;
457
457
  }
458
458
  val = val[part];
@@ -460,7 +460,7 @@ var nestedLookup = (obj, path) => {
460
460
  return val;
461
461
  };
462
462
  var queryParamsArray = (input) => {
463
- if (input == void 0) {
463
+ if (input === void 0) {
464
464
  return void 0;
465
465
  }
466
466
  const values = Array.isArray(input) ? input : [input];
@@ -559,7 +559,7 @@ var parseExpandClause = (clause) => {
559
559
  }
560
560
  const match = result.element.match(/\[([^\]+])]/);
561
561
  if (match) {
562
- result.index = match[1] === "*" ? "*" : parseInt(match[1], 10);
562
+ result.index = match[1] === "*" ? "*" : Number.parseInt(match[1], 10);
563
563
  result.element = result.element.substring(0, match.index);
564
564
  }
565
565
  return result;
@@ -1343,7 +1343,7 @@ var generateMatchFunc = (predicate) => {
1343
1343
  return (obj, vars) => {
1344
1344
  const value = resolveValue(obj, left);
1345
1345
  const other = resolveSymbol(expr, vars);
1346
- if (typeof value != "string") {
1346
+ if (typeof value !== "string") {
1347
1347
  throw new PredicateError(
1348
1348
  `The field '${left.value}' does not support this expression.`
1349
1349
  );
@@ -1781,7 +1781,7 @@ var AbstractRepository = class {
1781
1781
  version,
1782
1782
  actions
1783
1783
  );
1784
- if (resource.version != updatedResource.version) {
1784
+ if (resource.version !== updatedResource.version) {
1785
1785
  this.saveUpdate(context, version, updatedResource);
1786
1786
  }
1787
1787
  const result = this.postProcessResource(context, updatedResource);
@@ -1888,6 +1888,19 @@ var AbstractUpdateHandler = class {
1888
1888
  const updatedResource = cloneObject(resource);
1889
1889
  const identifier = resource.id ? resource.id : resource.key;
1890
1890
  for (const action of actions) {
1891
+ if (this[action.action] === void 0) {
1892
+ console.info(`No handler for action ${action.action}`);
1893
+ throw new CommercetoolsError({
1894
+ code: "InvalidInput",
1895
+ message: `Invalid action ${action.action}`,
1896
+ errors: [
1897
+ {
1898
+ code: "InvalidInput",
1899
+ message: `Invalid action ${action.action}`
1900
+ }
1901
+ ]
1902
+ });
1903
+ }
1891
1904
  const updateFunc = this[action.action].bind(this);
1892
1905
  if (!updateFunc) {
1893
1906
  console.error(`No mock implemented for update action ${action.action}`);
@@ -3554,6 +3567,7 @@ var CustomObjectRepository = class extends AbstractResourceRepository {
3554
3567
  };
3555
3568
 
3556
3569
  // src/repositories/customer/actions.ts
3570
+ import assert2 from "node:assert";
3557
3571
  var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3558
3572
  addAddress(_context, resource, { address }) {
3559
3573
  resource.addresses.push({
@@ -3562,67 +3576,35 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3562
3576
  });
3563
3577
  }
3564
3578
  addBillingAddressId(_context, resource, { addressId, addressKey }) {
3565
- const address = resource.addresses.find((a) => {
3566
- if (a.id != void 0 && addressId != void 0 && a.id === addressId) {
3567
- return true;
3568
- }
3569
- return a.key != void 0 && addressKey != void 0 && a.key === addressKey;
3570
- });
3571
- if (!address) {
3572
- throw new CommercetoolsError(
3573
- {
3574
- code: "InvalidInput",
3575
- message: `Address with id '${addressId}' or key '${addressKey}' not found.`
3576
- },
3577
- 400
3578
- );
3579
+ const address = this._findAddress(resource, addressId, addressKey, true);
3580
+ assert2(address?.id);
3581
+ if (resource.billingAddressIds === void 0) {
3582
+ resource.billingAddressIds = [];
3579
3583
  }
3580
- const billingAddressId = String(address.id);
3581
- if (resource.billingAddressIds?.length) {
3582
- resource.billingAddressIds.push(billingAddressId);
3583
- } else if (address) {
3584
- resource.billingAddressIds = [billingAddressId];
3584
+ if (!resource.billingAddressIds.includes(address.id)) {
3585
+ resource.billingAddressIds.push(address.id);
3585
3586
  }
3586
3587
  }
3587
3588
  addShippingAddressId(_context, resource, { addressId, addressKey }) {
3588
- const address = resource.addresses.find((a) => {
3589
- if (a.id != void 0 && addressId != void 0 && a.id === addressId) {
3590
- return true;
3591
- }
3592
- return a.key != void 0 && addressKey != void 0 && a.key === addressKey;
3593
- });
3594
- if (!address) {
3595
- throw new CommercetoolsError(
3596
- {
3597
- code: "InvalidInput",
3598
- message: `Address with id '${addressId}' or key '${addressKey}' not found.`
3599
- },
3600
- 400
3601
- );
3589
+ const address = this._findAddress(resource, addressId, addressKey, true);
3590
+ assert2(address?.id);
3591
+ if (resource.shippingAddressIds === void 0) {
3592
+ resource.shippingAddressIds = [];
3602
3593
  }
3603
- const shippingAddressId = String(address.id);
3604
- if (resource.shippingAddressIds?.length) {
3605
- resource.shippingAddressIds.push(shippingAddressId);
3606
- } else if (address) {
3607
- resource.shippingAddressIds = [shippingAddressId];
3594
+ if (!resource.shippingAddressIds.includes(address.id)) {
3595
+ resource.shippingAddressIds.push(address.id);
3608
3596
  }
3597
+ return resource;
3598
+ }
3599
+ addStore(context, resource, action) {
3600
+ throw new Error("Method not implemented.");
3609
3601
  }
3610
3602
  changeAddress(context, resource, { addressId, addressKey, address }) {
3611
- const oldAddressIndex = resource.addresses.findIndex((a) => {
3612
- if (a.id != void 0 && addressId != void 0 && a.id === addressId) {
3613
- return true;
3614
- }
3615
- return a.key != void 0 && addressKey != void 0 && a.key === addressKey;
3616
- });
3617
- if (oldAddressIndex === -1) {
3618
- throw new CommercetoolsError(
3619
- {
3620
- code: "InvalidInput",
3621
- message: `Address with id '${addressId}' or key '${addressKey}' not found.`
3622
- },
3623
- 400
3624
- );
3625
- }
3603
+ const current = this._findAddress(resource, addressId, addressKey, true);
3604
+ assert2(current?.id);
3605
+ const oldAddressIndex = resource.addresses.findIndex(
3606
+ (a) => a.id === current.id
3607
+ );
3626
3608
  const newAddress = createAddress(
3627
3609
  address,
3628
3610
  context.projectKey,
@@ -3638,6 +3620,55 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3638
3620
  changeEmail(_context, resource, { email }) {
3639
3621
  resource.email = email;
3640
3622
  }
3623
+ removeAddress(context, resource, action) {
3624
+ const address = this._findAddress(
3625
+ resource,
3626
+ action.addressId,
3627
+ action.addressKey,
3628
+ true
3629
+ );
3630
+ assert2(address?.id);
3631
+ resource.addresses = resource.addresses.filter((a) => a.id !== address.id);
3632
+ }
3633
+ removeBillingAddressId(context, resource, action) {
3634
+ const address = this._findAddress(
3635
+ resource,
3636
+ action.addressId,
3637
+ action.addressKey,
3638
+ true
3639
+ );
3640
+ assert2(address?.id);
3641
+ resource.billingAddressIds = resource.billingAddressIds?.filter(
3642
+ (id) => id !== address.id
3643
+ );
3644
+ if (resource.defaultBillingAddressId === address.id) {
3645
+ resource.defaultBillingAddressId = void 0;
3646
+ }
3647
+ }
3648
+ removeShippingAddressId(context, resource, action) {
3649
+ const address = this._findAddress(
3650
+ resource,
3651
+ action.addressId,
3652
+ action.addressKey,
3653
+ true
3654
+ );
3655
+ assert2(address?.id);
3656
+ resource.shippingAddressIds = resource.shippingAddressIds?.filter(
3657
+ (id) => id !== address.id
3658
+ );
3659
+ if (resource.defaultShippingAddressId === address.id) {
3660
+ resource.defaultShippingAddressId = void 0;
3661
+ }
3662
+ }
3663
+ removeStore(context, resource, action) {
3664
+ throw new Error("Method not implemented.");
3665
+ }
3666
+ setAddressCustomField(context, resource, action) {
3667
+ throw new Error("Method not implemented.");
3668
+ }
3669
+ setAddressCustomType(context, resource, action) {
3670
+ throw new Error("Method not implemented.");
3671
+ }
3641
3672
  setAuthenticationMode(_context, resource, { authMode, password }) {
3642
3673
  if (resource.authenticationMode === authMode) {
3643
3674
  throw new CommercetoolsError(
@@ -3669,6 +3700,25 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3669
3700
  setCompanyName(_context, resource, { companyName }) {
3670
3701
  resource.companyName = companyName;
3671
3702
  }
3703
+ setCustomerGroup(context, resource, action) {
3704
+ if (!action.customerGroup) {
3705
+ throw new CommercetoolsError(
3706
+ {
3707
+ code: "InvalidOperation",
3708
+ message: "CustomerGroup is required."
3709
+ },
3710
+ 400
3711
+ );
3712
+ }
3713
+ const group = this._storage.getByResourceIdentifier(
3714
+ context.projectKey,
3715
+ action.customerGroup
3716
+ );
3717
+ resource.customerGroup = {
3718
+ typeId: "customer-group",
3719
+ id: group.id
3720
+ };
3721
+ }
3672
3722
  setCustomerNumber(_context, resource, { customerNumber }) {
3673
3723
  if (resource.customerNumber) {
3674
3724
  throw new Error(
@@ -3694,6 +3744,41 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3694
3744
  resource.custom = void 0;
3695
3745
  }
3696
3746
  }
3747
+ setDateOfBirth(context, resource, action) {
3748
+ resource.dateOfBirth = action.dateOfBirth;
3749
+ }
3750
+ setDefaultBillingAddress(context, resource, action) {
3751
+ const address = this._findAddress(
3752
+ resource,
3753
+ action.addressId,
3754
+ action.addressKey,
3755
+ true
3756
+ );
3757
+ assert2(address?.id);
3758
+ resource.defaultBillingAddressId = address.id;
3759
+ if (resource.billingAddressIds === void 0) {
3760
+ resource.billingAddressIds = [];
3761
+ }
3762
+ if (!resource.billingAddressIds.includes(address.id)) {
3763
+ resource.billingAddressIds.push(address.id);
3764
+ }
3765
+ }
3766
+ setDefaultShippingAddress(context, resource, action) {
3767
+ const address = this._findAddress(
3768
+ resource,
3769
+ action.addressId,
3770
+ action.addressKey,
3771
+ true
3772
+ );
3773
+ assert2(address?.id);
3774
+ resource.defaultShippingAddressId = address.id;
3775
+ if (resource.shippingAddressIds === void 0) {
3776
+ resource.shippingAddressIds = [];
3777
+ }
3778
+ if (!resource.shippingAddressIds.includes(address.id)) {
3779
+ resource.shippingAddressIds.push(address.id);
3780
+ }
3781
+ }
3697
3782
  setExternalId(_context, resource, { externalId }) {
3698
3783
  resource.externalId = externalId;
3699
3784
  }
@@ -3709,12 +3794,58 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3709
3794
  setLocale(_context, resource, { locale }) {
3710
3795
  resource.locale = locale;
3711
3796
  }
3797
+ setMiddleName(context, resource, action) {
3798
+ resource.middleName = action.middleName;
3799
+ }
3712
3800
  setSalutation(_context, resource, { salutation }) {
3713
3801
  resource.salutation = salutation;
3714
3802
  }
3803
+ setStores(context, resource, action) {
3804
+ throw new Error("Method not implemented.");
3805
+ }
3806
+ setTitle(context, resource, action) {
3807
+ resource.title = action.title;
3808
+ }
3715
3809
  setVatId(_context, resource, { vatId }) {
3716
3810
  resource.vatId = vatId;
3717
3811
  }
3812
+ _findAddress(resource, addressId, addressKey, required = false) {
3813
+ if (addressKey) {
3814
+ const address = resource.addresses.find((a) => a.key === addressKey);
3815
+ if (!address) {
3816
+ throw new CommercetoolsError(
3817
+ {
3818
+ code: "InvalidOperation",
3819
+ message: `Customer does not contain an address with the key ${addressKey}.`
3820
+ },
3821
+ 400
3822
+ );
3823
+ }
3824
+ return address;
3825
+ }
3826
+ if (addressId) {
3827
+ const address = resource.addresses.find((a) => a.id === addressId);
3828
+ if (!address) {
3829
+ throw new CommercetoolsError(
3830
+ {
3831
+ code: "InvalidOperation",
3832
+ message: `Customer does not contain an address with the id ${addressId}.`
3833
+ },
3834
+ 400
3835
+ );
3836
+ }
3837
+ return address;
3838
+ }
3839
+ if (required) {
3840
+ throw new CommercetoolsError(
3841
+ {
3842
+ code: "InvalidOperation",
3843
+ message: "One of address 'addressId' or 'addressKey' is required."
3844
+ },
3845
+ 400
3846
+ );
3847
+ }
3848
+ }
3718
3849
  };
3719
3850
 
3720
3851
  // src/repositories/customer/index.ts
@@ -3766,8 +3897,8 @@ var CustomerRepository = class extends AbstractResourceRepository {
3766
3897
  ]
3767
3898
  });
3768
3899
  };
3769
- const defaultBillingAddressId = draft.defaultBillingAddress ? lookupAdressId(addresses, draft.defaultBillingAddress) : void 0;
3770
- const defaultShippingAddressId = draft.defaultShippingAddress ? lookupAdressId(addresses, draft.defaultShippingAddress) : void 0;
3900
+ const defaultBillingAddressId = draft.defaultBillingAddress !== void 0 ? lookupAdressId(addresses, draft.defaultBillingAddress) : void 0;
3901
+ const defaultShippingAddressId = draft.defaultShippingAddress !== void 0 ? lookupAdressId(addresses, draft.defaultShippingAddress) : void 0;
3771
3902
  const shippingAddressIds = draft.shippingAddresses?.map(
3772
3903
  (addressId) => lookupAdressId(addresses, addressId)
3773
3904
  ) ?? [];
@@ -4070,7 +4201,7 @@ var ExtensionRepository = class extends AbstractResourceRepository {
4070
4201
  extension,
4071
4202
  "destination.authentication.headerValue"
4072
4203
  );
4073
- } else if (extension.destination.type == "AWSLambda") {
4204
+ } else if (extension.destination.type === "AWSLambda") {
4074
4205
  return maskSecretValue(resource, "destination.accessSecret");
4075
4206
  }
4076
4207
  }
@@ -4237,13 +4368,13 @@ var MyCustomerRepository = class extends CustomerRepository {
4237
4368
  };
4238
4369
 
4239
4370
  // src/repositories/my-order.ts
4240
- import assert4 from "assert";
4371
+ import assert5 from "assert";
4241
4372
 
4242
4373
  // src/repositories/order/index.ts
4243
- import assert3 from "assert";
4374
+ import assert4 from "assert";
4244
4375
 
4245
4376
  // src/repositories/order/actions.ts
4246
- import assert2 from "assert";
4377
+ import assert3 from "assert";
4247
4378
  var OrderUpdateHandler = class extends AbstractUpdateHandler {
4248
4379
  addPayment(context, resource, { payment }) {
4249
4380
  const resolvedPayment = this._storage.getByResourceIdentifier(
@@ -4343,7 +4474,7 @@ var OrderUpdateHandler = class extends AbstractUpdateHandler {
4343
4474
  }
4344
4475
  }
4345
4476
  setDeliveryCustomField(context, resource, { deliveryId, name, value }) {
4346
- assert2(resource.shippingInfo, "shippingInfo is not defined");
4477
+ assert3(resource.shippingInfo, "shippingInfo is not defined");
4347
4478
  if (Array.isArray(resource.shippingInfo.deliveries)) {
4348
4479
  resource.shippingInfo.deliveries.map((delivery) => {
4349
4480
  if (delivery.id !== deliveryId) throw "No matching delivery id found";
@@ -4438,7 +4569,7 @@ var OrderRepository = class extends AbstractResourceRepository {
4438
4569
  this.actions = new OrderUpdateHandler(storage);
4439
4570
  }
4440
4571
  create(context, draft) {
4441
- assert3(draft.cart, "draft.cart is missing");
4572
+ assert4(draft.cart, "draft.cart is missing");
4442
4573
  return this.createFromCart(
4443
4574
  context,
4444
4575
  {
@@ -4493,7 +4624,7 @@ var OrderRepository = class extends AbstractResourceRepository {
4493
4624
  return this.saveNew(context, resource);
4494
4625
  }
4495
4626
  import(context, draft) {
4496
- assert3(this, "OrderRepository not valid");
4627
+ assert4(this, "OrderRepository not valid");
4497
4628
  const resource = {
4498
4629
  ...getBaseResourceProperties(),
4499
4630
  billingAddress: createAddress(
@@ -4636,7 +4767,7 @@ var OrderRepository = class extends AbstractResourceRepository {
4636
4767
  // src/repositories/my-order.ts
4637
4768
  var MyOrderRepository = class extends OrderRepository {
4638
4769
  create(context, draft) {
4639
- assert4(draft.id, "draft.id is missing");
4770
+ assert5(draft.id, "draft.id is missing");
4640
4771
  const cartIdentifier = {
4641
4772
  id: draft.id,
4642
4773
  typeId: "cart"
@@ -4887,12 +5018,12 @@ var parseFilter = (filter) => {
4887
5018
  if (unique.size > 1) {
4888
5019
  throw new Error("Invalid expression");
4889
5020
  }
4890
- if (expressions.some((expr) => expr.type == "Symbol")) {
5021
+ if (expressions.some((expr) => expr.type === "Symbol")) {
4891
5022
  return {
4892
5023
  source: left,
4893
5024
  type: "FilterExpression",
4894
5025
  children: expressions.map((e) => {
4895
- if (e.type != "Symbol") {
5026
+ if (e.type !== "Symbol") {
4896
5027
  throw new Error("Invalid expression");
4897
5028
  }
4898
5029
  return {
@@ -4990,7 +5121,7 @@ var generateMatchFunc2 = (filter) => {
4990
5121
  if (!result) {
4991
5122
  throw new Error(`Syntax error while parsing '${filter}'.`);
4992
5123
  }
4993
- if (result.type == "TermExpression") {
5124
+ if (result.type === "TermExpression") {
4994
5125
  throw new Error(`Syntax error while parsing '${filter}'.`);
4995
5126
  }
4996
5127
  return (obj) => {
@@ -5254,7 +5385,7 @@ var applyPriceSelector = (products, selector, noScopedPrice = false) => {
5254
5385
  const variants = [
5255
5386
  product.masterVariant,
5256
5387
  ...product.variants ?? []
5257
- ].filter((x) => x != void 0);
5388
+ ].filter((x) => x !== void 0);
5258
5389
  for (const variant of variants) {
5259
5390
  const scopedPrices = variant.prices?.filter((p) => priceSelectorFilter(p, selector)) ?? [];
5260
5391
  if (scopedPrices.length > 0) {
@@ -5723,7 +5854,7 @@ var ProductUpdateHandler = class extends AbstractUpdateHandler {
5723
5854
  );
5724
5855
  const foundCategory = data.categories.find(
5725
5856
  (productCategory) => {
5726
- if (productCategory.id == resolvedCategory.id) {
5857
+ if (productCategory.id === resolvedCategory.id) {
5727
5858
  return productCategory;
5728
5859
  }
5729
5860
  return false;
@@ -5740,7 +5871,7 @@ var ProductUpdateHandler = class extends AbstractUpdateHandler {
5740
5871
  }
5741
5872
  data.categories = data.categories.filter(
5742
5873
  (productCategory) => {
5743
- if (productCategory.id == resolvedCategory.id) {
5874
+ if (productCategory.id === resolvedCategory.id) {
5744
5875
  return false;
5745
5876
  }
5746
5877
  return true;
@@ -6735,14 +6866,14 @@ var ProductTypeUpdateHandler = class extends AbstractUpdateHandler {
6735
6866
  }
6736
6867
  removeEnumValues(context, resource, { attributeName, keys }) {
6737
6868
  resource.attributes?.forEach((attr) => {
6738
- if (attr.name == attributeName) {
6739
- if (attr.type.name == "enum") {
6869
+ if (attr.name === attributeName) {
6870
+ if (attr.type.name === "enum") {
6740
6871
  attr.type.values = attr.type.values.filter(
6741
6872
  (v) => !keys.includes(v.key)
6742
6873
  );
6743
6874
  }
6744
- if (attr.type.name == "set") {
6745
- if (attr.type.elementType.name == "enum") {
6875
+ if (attr.type.name === "set") {
6876
+ if (attr.type.elementType.name === "enum") {
6746
6877
  attr.type.elementType.values = attr.type.elementType.values.filter(
6747
6878
  (v) => !keys.includes(v.key)
6748
6879
  );