@labdigital/commercetools-mock 2.27.0 → 2.28.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.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import express from 'express';
2
2
  import { SetupServerApi, SetupServer } from 'msw/node';
3
3
  import * as ctp from '@commercetools/platform-sdk';
4
- import { QueryParam, BaseResource, Project, UpdateAction, ResourceIdentifier, AssociateRoleDraft, AssociateRole, AttributeGroupDraft, AttributeGroup, BusinessUnitDraft, BusinessUnit, CartDraft, Cart, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CategoryDraft, Category, ChannelDraft, Channel, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerCreatePasswordResetToken, CustomerToken, CustomerResetPassword, MyCustomerResetPassword, CustomerGroupDraft, CustomerGroup, DiscountCodeDraft, DiscountCode, ExtensionDraft, Extension, InventoryEntryDraft, InventoryEntry, MyCustomerChangePassword, MyCustomerEmailVerify, OrderFromCartDraft, Order, CartReference, OrderImportDraft, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, PaymentDraft, Payment, ProductDraft, Product, ProductDiscountDraft, ProductDiscount, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductTypeDraft, ProductType, QuoteDraft, Quote, QuoteRequestDraft, QuoteRequest, ReviewDraft, Review, ShippingMethodDraft, ShippingMethod, ZoneReference, ShoppingListDraft, ShoppingList, ShoppingListLineItem, StagedQuoteDraft, StagedQuote, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, StateDraft, State, StoreDraft, Store, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TypeDraft, Type, ZoneDraft, Zone } from '@commercetools/platform-sdk';
4
+ import { QueryParam, BaseResource, Project, UpdateAction, ResourceIdentifier, ProductTailoring, AssociateRoleDraft, AssociateRole, AttributeGroupDraft, AttributeGroup, BusinessUnitDraft, BusinessUnit, CartDraft, Cart, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CategoryDraft, Category, ChannelDraft, Channel, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerCreatePasswordResetToken, CustomerToken, CustomerResetPassword, MyCustomerResetPassword, CustomerGroupDraft, CustomerGroup, DiscountCodeDraft, DiscountCode, ExtensionDraft, Extension, InventoryEntryDraft, InventoryEntry, MyCustomerChangePassword, MyCustomerEmailVerify, OrderFromCartDraft, Order, CartReference, OrderImportDraft, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, PaymentDraft, Payment, ProductDraft, Product, ProductDiscountDraft, ProductDiscount, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductTypeDraft, ProductType, QuoteDraft, Quote, QuoteRequestDraft, QuoteRequest, ReviewDraft, Review, ShippingMethodDraft, ShippingMethod, ZoneReference, ShoppingListDraft, ShoppingList, ShoppingListLineItem, StagedQuoteDraft, StagedQuote, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, StateDraft, State, StoreDraft, Store, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TypeDraft, Type, ZoneDraft, Zone } from '@commercetools/platform-sdk';
5
5
 
6
6
  type Token = {
7
7
  access_token: string;
@@ -101,6 +101,7 @@ type ResourceMap = {
101
101
  "product-price": ctp.StandalonePrice;
102
102
  "product-projection": ctp.ProductProjection;
103
103
  "product-selection": ctp.ProductSelection;
104
+ "product-tailoring": ctp.ProductTailoring;
104
105
  "product-type": ctp.ProductType;
105
106
  "product": ctp.Product;
106
107
  "quote-request": ctp.QuoteRequest;
@@ -140,6 +141,7 @@ type PagedQueryResponseMap = {
140
141
  "product-price": ctp.StandalonePricePagedQueryResponse;
141
142
  "product-projection": ctp.ProductProjectionPagedQueryResponse;
142
143
  "product-selection": ctp.ProductSelectionPagedQueryResponse;
144
+ "product-tailoring": ctp.ProductTailoringPagedQueryResponse;
143
145
  "product-type": ctp.ProductTypePagedQueryResponse;
144
146
  "product": ctp.ProductPagedQueryResponse;
145
147
  "quote-request": ctp.QuoteRequestPagedQueryResponse;
@@ -184,6 +186,11 @@ declare abstract class AbstractStorage {
184
186
  abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
185
187
  }
186
188
 
189
+ declare class ProductTailoringRepository extends AbstractResourceRepository<"product-tailoring"> {
190
+ constructor(storage: AbstractStorage);
191
+ create(context: RepositoryContext, draft: any): ProductTailoring;
192
+ }
193
+
187
194
  declare class AssociateRoleRepository extends AbstractResourceRepository<"associate-role"> {
188
195
  constructor(storage: AbstractStorage);
189
196
  create(context: RepositoryContext, draft: AssociateRoleDraft): AssociateRole;
@@ -440,6 +447,7 @@ declare class ShippingMethodRepository extends AbstractResourceRepository<"shipp
440
447
  description?: string | undefined;
441
448
  localizedDescription?: ctp.LocalizedString | undefined;
442
449
  taxCategory: ctp.TaxCategoryReference;
450
+ active: boolean;
443
451
  isDefault: boolean;
444
452
  predicate?: string | undefined;
445
453
  custom?: ctp.CustomFields | undefined;
@@ -527,6 +535,7 @@ declare const createRepositories: (storage: AbstractStorage) => {
527
535
  "product-discount": ProductDiscountRepository;
528
536
  "product-projection": ProductProjectionRepository;
529
537
  "product-selection": ProductSelectionRepository;
538
+ "product-tailoring": ProductTailoringRepository;
530
539
  project: ProjectRepository;
531
540
  review: ReviewRepository;
532
541
  quote: QuoteRepository;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import express from 'express';
2
2
  import { SetupServerApi, SetupServer } from 'msw/node';
3
3
  import * as ctp from '@commercetools/platform-sdk';
4
- import { QueryParam, BaseResource, Project, UpdateAction, ResourceIdentifier, AssociateRoleDraft, AssociateRole, AttributeGroupDraft, AttributeGroup, BusinessUnitDraft, BusinessUnit, CartDraft, Cart, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CategoryDraft, Category, ChannelDraft, Channel, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerCreatePasswordResetToken, CustomerToken, CustomerResetPassword, MyCustomerResetPassword, CustomerGroupDraft, CustomerGroup, DiscountCodeDraft, DiscountCode, ExtensionDraft, Extension, InventoryEntryDraft, InventoryEntry, MyCustomerChangePassword, MyCustomerEmailVerify, OrderFromCartDraft, Order, CartReference, OrderImportDraft, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, PaymentDraft, Payment, ProductDraft, Product, ProductDiscountDraft, ProductDiscount, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductTypeDraft, ProductType, QuoteDraft, Quote, QuoteRequestDraft, QuoteRequest, ReviewDraft, Review, ShippingMethodDraft, ShippingMethod, ZoneReference, ShoppingListDraft, ShoppingList, ShoppingListLineItem, StagedQuoteDraft, StagedQuote, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, StateDraft, State, StoreDraft, Store, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TypeDraft, Type, ZoneDraft, Zone } from '@commercetools/platform-sdk';
4
+ import { QueryParam, BaseResource, Project, UpdateAction, ResourceIdentifier, ProductTailoring, AssociateRoleDraft, AssociateRole, AttributeGroupDraft, AttributeGroup, BusinessUnitDraft, BusinessUnit, CartDraft, Cart, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CategoryDraft, Category, ChannelDraft, Channel, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerCreatePasswordResetToken, CustomerToken, CustomerResetPassword, MyCustomerResetPassword, CustomerGroupDraft, CustomerGroup, DiscountCodeDraft, DiscountCode, ExtensionDraft, Extension, InventoryEntryDraft, InventoryEntry, MyCustomerChangePassword, MyCustomerEmailVerify, OrderFromCartDraft, Order, CartReference, OrderImportDraft, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, PaymentDraft, Payment, ProductDraft, Product, ProductDiscountDraft, ProductDiscount, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductTypeDraft, ProductType, QuoteDraft, Quote, QuoteRequestDraft, QuoteRequest, ReviewDraft, Review, ShippingMethodDraft, ShippingMethod, ZoneReference, ShoppingListDraft, ShoppingList, ShoppingListLineItem, StagedQuoteDraft, StagedQuote, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, StateDraft, State, StoreDraft, Store, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TypeDraft, Type, ZoneDraft, Zone } from '@commercetools/platform-sdk';
5
5
 
6
6
  type Token = {
7
7
  access_token: string;
@@ -101,6 +101,7 @@ type ResourceMap = {
101
101
  "product-price": ctp.StandalonePrice;
102
102
  "product-projection": ctp.ProductProjection;
103
103
  "product-selection": ctp.ProductSelection;
104
+ "product-tailoring": ctp.ProductTailoring;
104
105
  "product-type": ctp.ProductType;
105
106
  "product": ctp.Product;
106
107
  "quote-request": ctp.QuoteRequest;
@@ -140,6 +141,7 @@ type PagedQueryResponseMap = {
140
141
  "product-price": ctp.StandalonePricePagedQueryResponse;
141
142
  "product-projection": ctp.ProductProjectionPagedQueryResponse;
142
143
  "product-selection": ctp.ProductSelectionPagedQueryResponse;
144
+ "product-tailoring": ctp.ProductTailoringPagedQueryResponse;
143
145
  "product-type": ctp.ProductTypePagedQueryResponse;
144
146
  "product": ctp.ProductPagedQueryResponse;
145
147
  "quote-request": ctp.QuoteRequestPagedQueryResponse;
@@ -184,6 +186,11 @@ declare abstract class AbstractStorage {
184
186
  abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
185
187
  }
186
188
 
189
+ declare class ProductTailoringRepository extends AbstractResourceRepository<"product-tailoring"> {
190
+ constructor(storage: AbstractStorage);
191
+ create(context: RepositoryContext, draft: any): ProductTailoring;
192
+ }
193
+
187
194
  declare class AssociateRoleRepository extends AbstractResourceRepository<"associate-role"> {
188
195
  constructor(storage: AbstractStorage);
189
196
  create(context: RepositoryContext, draft: AssociateRoleDraft): AssociateRole;
@@ -440,6 +447,7 @@ declare class ShippingMethodRepository extends AbstractResourceRepository<"shipp
440
447
  description?: string | undefined;
441
448
  localizedDescription?: ctp.LocalizedString | undefined;
442
449
  taxCategory: ctp.TaxCategoryReference;
450
+ active: boolean;
443
451
  isDefault: boolean;
444
452
  predicate?: string | undefined;
445
453
  custom?: ctp.CustomFields | undefined;
@@ -527,6 +535,7 @@ declare const createRepositories: (storage: AbstractStorage) => {
527
535
  "product-discount": ProductDiscountRepository;
528
536
  "product-projection": ProductProjectionRepository;
529
537
  "product-selection": ProductSelectionRepository;
538
+ "product-tailoring": ProductTailoringRepository;
530
539
  project: ProjectRepository;
531
540
  review: ReviewRepository;
532
541
  quote: QuoteRepository;
package/dist/index.js CHANGED
@@ -1503,6 +1503,7 @@ var InMemoryStorage = class extends AbstractStorage {
1503
1503
  "product-selection": /* @__PURE__ */ new Map(),
1504
1504
  "product-type": /* @__PURE__ */ new Map(),
1505
1505
  "product-projection": /* @__PURE__ */ new Map(),
1506
+ "product-tailoring": /* @__PURE__ */ new Map(),
1506
1507
  "review": /* @__PURE__ */ new Map(),
1507
1508
  "shipping-method": /* @__PURE__ */ new Map(),
1508
1509
  "staged-quote": /* @__PURE__ */ new Map(),
@@ -1887,6 +1888,22 @@ var AbstractUpdateHandler = class {
1887
1888
  }
1888
1889
  };
1889
1890
 
1891
+ // src/repositories/product-tailoring.ts
1892
+ var ProductTailoringRepository = class extends AbstractResourceRepository {
1893
+ constructor(storage) {
1894
+ super("product-tailoring", storage);
1895
+ this.actions = new ProductTailoringUpdateHandler(this._storage);
1896
+ }
1897
+ create(context, draft) {
1898
+ throw new Error("Create method for product-tailoring not implemented.");
1899
+ }
1900
+ };
1901
+ var ProductTailoringUpdateHandler = class extends AbstractUpdateHandler {
1902
+ setSlug() {
1903
+ throw new Error("SetSlug method for product-tailoring not implemented.");
1904
+ }
1905
+ };
1906
+
1890
1907
  // src/repositories/helpers.ts
1891
1908
  import { v4 as uuidv44 } from "uuid";
1892
1909
  var createAddress = (base, projectKey, storage) => {
@@ -2210,6 +2227,18 @@ var BusinessUnitRepository = class extends AbstractResourceRepository {
2210
2227
  this.actions = new BusinessUnitUpdateHandler(this._storage);
2211
2228
  }
2212
2229
  create(context, draft) {
2230
+ const addresses = draft.addresses?.map((address) => ({
2231
+ ...address,
2232
+ id: generateRandomString(5)
2233
+ })) ?? [];
2234
+ const defaultBillingAddressId = addresses.length > 0 && draft.defaultBillingAddress !== void 0 ? addresses[draft.defaultBillingAddress].id : void 0;
2235
+ const defaultShippingAddressId = addresses.length > 0 && draft.defaultShippingAddress !== void 0 ? addresses[draft.defaultShippingAddress].id : void 0;
2236
+ const shippingAddressIds = draft.shippingAddresses?.map(
2237
+ (i) => addresses[i].id
2238
+ );
2239
+ const billingAddressIds = draft.billingAddresses?.map(
2240
+ (i) => addresses[i].id
2241
+ );
2213
2242
  const resource = {
2214
2243
  ...getBaseResourceProperties(),
2215
2244
  key: draft.key,
@@ -2220,18 +2249,18 @@ var BusinessUnitRepository = class extends AbstractResourceRepository {
2220
2249
  storeMode: draft.storeMode,
2221
2250
  name: draft.name,
2222
2251
  contactEmail: draft.contactEmail,
2223
- addresses: draft.addresses?.map(
2224
- (a) => createAddress(a, context.projectKey, this._storage)
2225
- ),
2252
+ addresses,
2226
2253
  custom: createCustomFields(
2227
2254
  draft.custom,
2228
2255
  context.projectKey,
2229
2256
  this._storage
2230
2257
  ),
2231
- shippingAddressIds: draft.shippingAddresses,
2232
- defaultShippingAddressId: draft.defaultShippingAddress,
2233
- billingAddressIds: draft.billingAddresses,
2258
+ shippingAddressIds,
2259
+ billingAddressIds,
2260
+ defaultShippingAddressId,
2261
+ defaultBillingAddressId,
2234
2262
  associateMode: draft.associateMode,
2263
+ approvalRuleMode: draft.approvalRuleMode,
2235
2264
  associates: draft.associates?.map(
2236
2265
  (a) => createAssociate(a, context.projectKey, this._storage)
2237
2266
  )
@@ -2305,6 +2334,9 @@ var BusinessUnitUpdateHandler = class extends AbstractUpdateHandler {
2305
2334
  resource.addresses.push(newAddress);
2306
2335
  }
2307
2336
  }
2337
+ changeApprovalRuleMode(context, resource, { approvalRuleMode }) {
2338
+ resource.approvalRuleMode = approvalRuleMode;
2339
+ }
2308
2340
  changeAssociateMode(context, resource, { associateMode }) {
2309
2341
  resource.associateMode = associateMode;
2310
2342
  }
@@ -2604,10 +2636,12 @@ var CartUpdateHandler = class extends AbstractUpdateHandler {
2604
2636
  }
2605
2637
  }
2606
2638
  setDirectDiscounts(context, resource, { discounts }) {
2607
- resource.directDiscounts = discounts.map((discount) => ({
2608
- ...discount,
2609
- id: uuidv45()
2610
- }));
2639
+ resource.directDiscounts = discounts.map(
2640
+ (discount) => ({
2641
+ ...discount,
2642
+ id: uuidv45()
2643
+ })
2644
+ );
2611
2645
  }
2612
2646
  setLineItemShippingDetails(context, resource, {
2613
2647
  action,
@@ -3417,7 +3451,8 @@ var CustomerRepository = class extends AbstractResourceRepository {
3417
3451
  draft.custom,
3418
3452
  context.projectKey,
3419
3453
  this._storage
3420
- )
3454
+ ),
3455
+ stores: []
3421
3456
  };
3422
3457
  return this.saveNew(context, resource);
3423
3458
  }
@@ -6212,6 +6247,9 @@ var ShippingMethodUpdateHandler = class extends AbstractUpdateHandler {
6212
6247
  shippingRates: []
6213
6248
  });
6214
6249
  }
6250
+ changeActive(_context, resource, { active }) {
6251
+ resource.active = active;
6252
+ }
6215
6253
  changeIsDefault(_context, resource, { isDefault }) {
6216
6254
  resource.isDefault = isDefault;
6217
6255
  }
@@ -6281,6 +6319,7 @@ var ShippingMethodRepository = class extends AbstractResourceRepository {
6281
6319
  const resource = {
6282
6320
  ...getBaseResourceProperties(),
6283
6321
  ...draft,
6322
+ active: draft.active ?? true,
6284
6323
  taxCategory: getReferenceFromResourceIdentifier(
6285
6324
  draft.taxCategory,
6286
6325
  context.projectKey,
@@ -7097,6 +7136,7 @@ var createRepositories = (storage) => ({
7097
7136
  "product-discount": new ProductDiscountRepository(storage),
7098
7137
  "product-projection": new ProductProjectionRepository(storage),
7099
7138
  "product-selection": new ProductSelectionRepository(storage),
7139
+ "product-tailoring": new ProductTailoringRepository(storage),
7100
7140
  "project": new ProjectRepository(storage),
7101
7141
  "review": new ReviewRepository(storage),
7102
7142
  "quote": new QuoteRepository(storage),