@labdigital/commercetools-mock 0.10.1 → 0.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.
@@ -45950,13 +45950,13 @@ ${this.pendingMocks().join("\n")}`
45950
45950
  if (!project) {
45951
45951
  return response.status(404).send({});
45952
45952
  }
45953
- this.repository.processUpdateActions(
45953
+ const updatedResource = this.repository.processUpdateActions(
45954
45954
  getRepositoryContext(request),
45955
45955
  project,
45956
45956
  updateRequest.version,
45957
45957
  updateRequest.actions
45958
45958
  );
45959
- return response.status(200).send({});
45959
+ return response.status(200).send(updatedResource);
45960
45960
  }
45961
45961
  };
45962
45962
 
@@ -47579,6 +47579,77 @@ ${this.pendingMocks().join("\n")}`
47579
47579
  setKey: (context, resource, { key }) => {
47580
47580
  resource.key = key;
47581
47581
  return resource;
47582
+ },
47583
+ addExternalImage: (context, resource, { variantId, sku, image, staged }) => {
47584
+ const addImg = (data) => {
47585
+ const { variant, isMasterVariant, variantIndex } = getVariant(
47586
+ data,
47587
+ variantId,
47588
+ sku
47589
+ );
47590
+ if (!variant) {
47591
+ throw new Error(
47592
+ `Variant with id ${variantId} or sku ${sku} not found on product ${resource.id}`
47593
+ );
47594
+ }
47595
+ if (!variant.images) {
47596
+ variant.images = [];
47597
+ } else {
47598
+ const existingImage = variant.images.find((x) => x.url === image.url);
47599
+ if (existingImage) {
47600
+ throw new Error(
47601
+ `Cannot add image '${image.url}' because product '${resource.id}' already has that image.`
47602
+ );
47603
+ }
47604
+ }
47605
+ variant.images.push(image);
47606
+ if (isMasterVariant) {
47607
+ data.masterVariant = variant;
47608
+ } else {
47609
+ data.variants[variantIndex] = variant;
47610
+ }
47611
+ };
47612
+ const onlyStaged = staged !== void 0 ? staged : true;
47613
+ addImg(resource.masterData.staged);
47614
+ if (!onlyStaged) {
47615
+ addImg(resource.masterData.current);
47616
+ }
47617
+ checkForStagedChanges(resource);
47618
+ return resource;
47619
+ },
47620
+ removeImage: (context, resource, { variantId, sku, imageUrl, staged }) => {
47621
+ const removeImg = (data) => {
47622
+ const { variant, isMasterVariant, variantIndex } = getVariant(
47623
+ data,
47624
+ variantId,
47625
+ sku
47626
+ );
47627
+ if (!variant) {
47628
+ throw new Error(
47629
+ `Variant with id ${variantId} or sku ${sku} not found on product ${resource.id}`
47630
+ );
47631
+ }
47632
+ const variantImages = variant.images ?? [];
47633
+ const existingImage = variantImages.find((x) => x.url === imageUrl);
47634
+ if (!existingImage) {
47635
+ throw new Error(
47636
+ `Cannot remove image '${imageUrl}' because product '${resource.id}' does not have that image.`
47637
+ );
47638
+ }
47639
+ variant.images = variantImages.filter((image) => image.url !== imageUrl);
47640
+ if (isMasterVariant) {
47641
+ data.masterVariant = variant;
47642
+ } else {
47643
+ data.variants[variantIndex] = variant;
47644
+ }
47645
+ };
47646
+ const onlyStaged = staged !== void 0 ? staged : true;
47647
+ removeImg(resource.masterData.staged);
47648
+ if (!onlyStaged) {
47649
+ removeImg(resource.masterData.current);
47650
+ }
47651
+ checkForStagedChanges(resource);
47652
+ return resource;
47582
47653
  }
47583
47654
  };
47584
47655
  }
@@ -48428,6 +48499,7 @@ ${this.pendingMocks().join("\n")}`
48428
48499
  },
48429
48500
  changeMessagesConfiguration: (context, resource, { messagesConfiguration }) => {
48430
48501
  resource.messages.enabled = messagesConfiguration.enabled;
48502
+ resource.messages.deleteDaysAfterCreation = messagesConfiguration.deleteDaysAfterCreation;
48431
48503
  },
48432
48504
  changeProductSearchIndexingEnabled: (context, resource, { enabled }) => {
48433
48505
  var _a;
@@ -48747,6 +48819,9 @@ ${this.pendingMocks().join("\n")}`
48747
48819
  changeKey: (context, resource, { key }) => {
48748
48820
  resource.key = key;
48749
48821
  },
48822
+ changeInitial: (context, resource, { initial }) => {
48823
+ resource.initial = initial;
48824
+ },
48750
48825
  setDescription: (context, resource, { description }) => {
48751
48826
  resource.description = description;
48752
48827
  },