@labdigital/commercetools-mock 1.9.0 → 1.11.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.
package/dist/index.cjs CHANGED
@@ -2189,6 +2189,16 @@ var CartRepository = class extends AbstractResourceRepository {
2189
2189
  }
2190
2190
  resource.totalPrice.centAmount = calculateCartTotalPrice(resource);
2191
2191
  },
2192
+ addItemShippingAddress: (context, resource, { action, address }) => {
2193
+ const newAddress = createAddress(
2194
+ address,
2195
+ context.projectKey,
2196
+ this._storage
2197
+ );
2198
+ if (newAddress) {
2199
+ resource.itemShippingAddresses.push(newAddress);
2200
+ }
2201
+ },
2192
2202
  changeLineItemQuantity: (context, resource, { lineItemId, lineItemKey, quantity }) => {
2193
2203
  let lineItem;
2194
2204
  if (lineItemId) {
@@ -2312,6 +2322,26 @@ var CartRepository = class extends AbstractResourceRepository {
2312
2322
  setLocale: (context, resource, { locale }) => {
2313
2323
  resource.locale = locale;
2314
2324
  },
2325
+ setLineItemShippingDetails: (context, resource, {
2326
+ action,
2327
+ shippingDetails,
2328
+ lineItemId,
2329
+ lineItemKey
2330
+ }) => {
2331
+ const lineItem = resource.lineItems.find(
2332
+ (x) => lineItemId && x.id === lineItemId || lineItemKey && x.key === lineItemKey
2333
+ );
2334
+ if (!lineItem) {
2335
+ throw new CommercetoolsError({
2336
+ code: "General",
2337
+ message: lineItemKey ? `A line item with key '${lineItemKey}' not found.` : `A line item with ID '${lineItemId}' not found.`
2338
+ });
2339
+ }
2340
+ lineItem.shippingDetails = {
2341
+ ...shippingDetails,
2342
+ valid: true
2343
+ };
2344
+ },
2315
2345
  setShippingAddress: (context, resource, { address }) => {
2316
2346
  if (!address) {
2317
2347
  resource.shippingAddress = void 0;
@@ -2329,6 +2359,11 @@ var CartRepository = class extends AbstractResourceRepository {
2329
2359
  ...address,
2330
2360
  custom
2331
2361
  };
2362
+ },
2363
+ removeDiscountCode: (context, resource, { discountCode }) => {
2364
+ resource.discountCodes = resource.discountCodes.filter(
2365
+ (code) => code.discountCode.id !== discountCode.id
2366
+ );
2332
2367
  }
2333
2368
  };
2334
2369
  draftLineItemtoLineItem = (projectKey, draftLineItem, currency, country) => {
@@ -4674,6 +4709,7 @@ var ProductSelectionRepository = class extends AbstractResourceRepository {
4674
4709
  const resource = {
4675
4710
  ...getBaseResourceProperties(),
4676
4711
  productCount: 0,
4712
+ key: draft.key,
4677
4713
  name: draft.name,
4678
4714
  type: "individual",
4679
4715
  mode: "Individual"
@@ -4681,7 +4717,11 @@ var ProductSelectionRepository = class extends AbstractResourceRepository {
4681
4717
  this.saveNew(context, resource);
4682
4718
  return resource;
4683
4719
  }
4684
- actions = {};
4720
+ actions = {
4721
+ changeName: (context, resource, { name }) => {
4722
+ resource.name = name;
4723
+ }
4724
+ };
4685
4725
  };
4686
4726
 
4687
4727
  // src/repositories/product-type.ts
@@ -5681,6 +5721,18 @@ var AssociateRoleServices = class extends AbstractService {
5681
5721
  }
5682
5722
  };
5683
5723
 
5724
+ // src/services/attribute-group.ts
5725
+ var AttributeGroupService = class extends AbstractService {
5726
+ repository;
5727
+ constructor(parent, repository) {
5728
+ super(parent);
5729
+ this.repository = repository;
5730
+ }
5731
+ getBasePath() {
5732
+ return "attribute-groups";
5733
+ }
5734
+ };
5735
+
5684
5736
  // src/services/business-units.ts
5685
5737
  var BusinessUnitServices = class extends AbstractService {
5686
5738
  repository;
@@ -5693,6 +5745,18 @@ var BusinessUnitServices = class extends AbstractService {
5693
5745
  }
5694
5746
  };
5695
5747
 
5748
+ // src/services/cart-discount.ts
5749
+ var CartDiscountService = class extends AbstractService {
5750
+ repository;
5751
+ constructor(parent, repository) {
5752
+ super(parent);
5753
+ this.repository = repository;
5754
+ }
5755
+ getBasePath() {
5756
+ return "cart-discounts";
5757
+ }
5758
+ };
5759
+
5696
5760
  // src/services/cart.ts
5697
5761
  var CartService = class extends AbstractService {
5698
5762
  repository;
@@ -5731,18 +5795,6 @@ var CartService = class extends AbstractService {
5731
5795
  }
5732
5796
  };
5733
5797
 
5734
- // src/services/cart-discount.ts
5735
- var CartDiscountService = class extends AbstractService {
5736
- repository;
5737
- constructor(parent, repository) {
5738
- super(parent);
5739
- this.repository = repository;
5740
- }
5741
- getBasePath() {
5742
- return "cart-discounts";
5743
- }
5744
- };
5745
-
5746
5798
  // src/services/category.ts
5747
5799
  var CategoryServices = class extends AbstractService {
5748
5800
  repository;
@@ -5819,6 +5871,18 @@ var CustomObjectService = class extends AbstractService {
5819
5871
  }
5820
5872
  };
5821
5873
 
5874
+ // src/services/customer-group.ts
5875
+ var CustomerGroupService = class extends AbstractService {
5876
+ repository;
5877
+ constructor(parent, repository) {
5878
+ super(parent);
5879
+ this.repository = repository;
5880
+ }
5881
+ getBasePath() {
5882
+ return "customer-groups";
5883
+ }
5884
+ };
5885
+
5822
5886
  // src/services/customer.ts
5823
5887
  var import_uuid8 = require("uuid");
5824
5888
  var CustomerService = class extends AbstractService {
@@ -5850,18 +5914,6 @@ var CustomerService = class extends AbstractService {
5850
5914
  }
5851
5915
  };
5852
5916
 
5853
- // src/services/customer-group.ts
5854
- var CustomerGroupService = class extends AbstractService {
5855
- repository;
5856
- constructor(parent, repository) {
5857
- super(parent);
5858
- this.repository = repository;
5859
- }
5860
- getBasePath() {
5861
- return "customer-groups";
5862
- }
5863
- };
5864
-
5865
5917
  // src/services/discount-code.ts
5866
5918
  var DiscountCodeService = class extends AbstractService {
5867
5919
  repository;
@@ -6070,18 +6122,6 @@ var PaymentService = class extends AbstractService {
6070
6122
  }
6071
6123
  };
6072
6124
 
6073
- // src/services/product.ts
6074
- var ProductService = class extends AbstractService {
6075
- repository;
6076
- constructor(parent, repository) {
6077
- super(parent);
6078
- this.repository = repository;
6079
- }
6080
- getBasePath() {
6081
- return "products";
6082
- }
6083
- };
6084
-
6085
6125
  // src/services/product-discount.ts
6086
6126
  var ProductDiscountService = class extends AbstractService {
6087
6127
  repository;
@@ -6144,6 +6184,18 @@ var ProductProjectionService = class extends AbstractService {
6144
6184
  }
6145
6185
  };
6146
6186
 
6187
+ // src/services/product-selection.ts
6188
+ var ProductSelectionService = class extends AbstractService {
6189
+ repository;
6190
+ constructor(parent, repository) {
6191
+ super(parent);
6192
+ this.repository = repository;
6193
+ }
6194
+ getBasePath() {
6195
+ return "product-selections";
6196
+ }
6197
+ };
6198
+
6147
6199
  // src/services/product-type.ts
6148
6200
  var ProductTypeService = class extends AbstractService {
6149
6201
  repository;
@@ -6156,6 +6208,18 @@ var ProductTypeService = class extends AbstractService {
6156
6208
  }
6157
6209
  };
6158
6210
 
6211
+ // src/services/product.ts
6212
+ var ProductService = class extends AbstractService {
6213
+ repository;
6214
+ constructor(parent, repository) {
6215
+ super(parent);
6216
+ this.repository = repository;
6217
+ }
6218
+ getBasePath() {
6219
+ return "products";
6220
+ }
6221
+ };
6222
+
6159
6223
  // src/services/shipping-method.ts
6160
6224
  var ShippingMethodService = class extends AbstractService {
6161
6225
  repository;
@@ -6268,18 +6332,6 @@ var ZoneService = class extends AbstractService {
6268
6332
  }
6269
6333
  };
6270
6334
 
6271
- // src/services/attribute-group.ts
6272
- var AttributeGroupService = class extends AbstractService {
6273
- repository;
6274
- constructor(parent, repository) {
6275
- super(parent);
6276
- this.repository = repository;
6277
- }
6278
- getBasePath() {
6279
- return "attribute-groups";
6280
- }
6281
- };
6282
-
6283
6335
  // src/services/index.ts
6284
6336
  var createServices = (router, repos) => ({
6285
6337
  "associate-role": new AssociateRoleServices(router, repos["associate-role"]),
@@ -6324,6 +6376,10 @@ var createServices = (router, repos) => ({
6324
6376
  router,
6325
6377
  repos["product-projection"]
6326
6378
  ),
6379
+ "product-selection": new ProductSelectionService(
6380
+ router,
6381
+ repos["product-selection"]
6382
+ ),
6327
6383
  "shopping-list": new ShoppingListService(router, repos["shopping-list"]),
6328
6384
  state: new StateService(router, repos["state"]),
6329
6385
  store: new StoreService(router, repos["store"]),