@labdigital/commercetools-mock 2.28.1 → 2.29.1

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.js CHANGED
@@ -5103,6 +5103,67 @@ var ProductUpdateHandler = class extends AbstractUpdateHandler {
5103
5103
  checkForStagedChanges(resource);
5104
5104
  return resource;
5105
5105
  }
5106
+ setProductPriceCustomField(context, resource, { name, value, staged, priceId }) {
5107
+ const updatePriceCustomFields = (data) => {
5108
+ const price = [data.masterVariant, ...data.variants ?? []].flatMap((variant) => variant.prices ?? []).find((price2) => price2.id === priceId);
5109
+ if (!price) {
5110
+ throw new Error(
5111
+ `Price with id ${priceId} not found on product ${resource.id}`
5112
+ );
5113
+ }
5114
+ if (price.custom) {
5115
+ if (value === null) {
5116
+ delete price.custom.fields[name];
5117
+ } else {
5118
+ price.custom.fields[name] = value;
5119
+ }
5120
+ }
5121
+ return data;
5122
+ };
5123
+ resource.masterData.staged = updatePriceCustomFields(
5124
+ resource.masterData.staged
5125
+ );
5126
+ const onlyStaged = staged !== void 0 ? staged : true;
5127
+ if (!onlyStaged) {
5128
+ resource.masterData.current = updatePriceCustomFields(
5129
+ resource.masterData.current
5130
+ );
5131
+ }
5132
+ checkForStagedChanges(resource);
5133
+ return resource;
5134
+ }
5135
+ setProductPriceCustomType(context, resource, { type, fields, staged, priceId }) {
5136
+ const updatePriceCustomType = (data) => {
5137
+ const price = [data.masterVariant, ...data.variants ?? []].flatMap((variant) => variant.prices ?? []).find((price2) => price2.id === priceId);
5138
+ if (price) {
5139
+ if (type) {
5140
+ price.custom = createCustomFields(
5141
+ { type, fields },
5142
+ context.projectKey,
5143
+ this._storage
5144
+ );
5145
+ } else {
5146
+ price.custom = void 0;
5147
+ }
5148
+ } else {
5149
+ throw new Error(
5150
+ `Price with id ${priceId} not found on product ${resource.id}`
5151
+ );
5152
+ }
5153
+ return data;
5154
+ };
5155
+ resource.masterData.staged = updatePriceCustomType(
5156
+ resource.masterData.staged
5157
+ );
5158
+ const onlyStaged = staged !== void 0 ? staged : true;
5159
+ if (!onlyStaged) {
5160
+ resource.masterData.current = updatePriceCustomType(
5161
+ resource.masterData.current
5162
+ );
5163
+ }
5164
+ checkForStagedChanges(resource);
5165
+ return resource;
5166
+ }
5106
5167
  setTaxCategory(context, resource, { taxCategory }) {
5107
5168
  let taxCategoryReference = void 0;
5108
5169
  if (taxCategory) {
@@ -5150,8 +5211,6 @@ var ProductUpdateHandler = class extends AbstractUpdateHandler {
5150
5211
  checkForStagedChanges(resource);
5151
5212
  }
5152
5213
  // 'setPrices': () => {},
5153
- // 'setProductPriceCustomType': () => {},
5154
- // 'setProductPriceCustomField': () => {},
5155
5214
  // 'setDiscountedPrice': () => {},
5156
5215
  // 'setAttributeInAllVariants': () => {},
5157
5216
  // 'setCategoryOrderHint': () => {},
@@ -6100,6 +6159,14 @@ var ProjectUpdateHandler = class extends AbstractUpdateHandler {
6100
6159
  resource.messages.enabled = messagesConfiguration.enabled;
6101
6160
  resource.messages.deleteDaysAfterCreation = messagesConfiguration.deleteDaysAfterCreation;
6102
6161
  }
6162
+ changeMyBusinessUnitStatusOnCreation(context, resource, { status }) {
6163
+ if (resource.businessUnits === void 0) {
6164
+ resource.businessUnits = {
6165
+ myBusinessUnitStatusOnCreation: "Inactive"
6166
+ };
6167
+ }
6168
+ resource.businessUnits.myBusinessUnitStatusOnCreation = status;
6169
+ }
6103
6170
  changeName(context, resource, { name }) {
6104
6171
  resource.name = name;
6105
6172
  }
@@ -6120,6 +6187,18 @@ var ProjectUpdateHandler = class extends AbstractUpdateHandler {
6120
6187
  setExternalOAuth(context, resource, { externalOAuth }) {
6121
6188
  resource.externalOAuth = externalOAuth;
6122
6189
  }
6190
+ setMyBusinessUnitAssociateRoleOnCreation(context, resource, { associateRole }) {
6191
+ if (resource.businessUnits === void 0) {
6192
+ resource.businessUnits = {
6193
+ //Default status, so we set it here also
6194
+ myBusinessUnitStatusOnCreation: "Inactive"
6195
+ };
6196
+ }
6197
+ resource.businessUnits.myBusinessUnitAssociateRoleOnCreation = {
6198
+ typeId: associateRole.typeId,
6199
+ key: associateRole.key ?? "unknown"
6200
+ };
6201
+ }
6123
6202
  setShippingRateInputType(context, resource, { shippingRateInputType }) {
6124
6203
  resource.shippingRateInputType = shippingRateInputType;
6125
6204
  }