@labdigital/commercetools-mock 2.6.0 → 2.8.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 { SetupServer } from 'msw/node';
3
3
  import * as ctp from '@commercetools/platform-sdk';
4
- import { Project, ResourceIdentifier, QueryParam, AssociateRoleDraft, AssociateRole, AssociateRoleSetNameAction, AssociateRoleSetPermissionsAction, AssociateRoleChangeBuyerAssignableAction, AssociateRoleSetCustomFieldAction, AssociateRoleAddPermissionAction, AssociateRoleRemovePermissionAction, AttributeGroupDraft, AttributeGroup, AttributeGroupSetAttributesAction, AttributeGroupChangeNameAction, AttributeGroupSetDescriptionAction, AttributeGroupSetKeyAction, BusinessUnitDraft, BusinessUnit, BusinessUnitAddAddressAction, BusinessUnitAddAssociateAction, BusinessUnitSetAssociatesAction, BusinessUnitSetContactEmailAction, BusinessUnitSetStoreModeAction, BusinessUnitChangeNameAction, BusinessUnitChangeAddressAction, BusinessUnitAddStoreAction, BusinessUnitChangeParentUnitAction, BusinessUnitChangeStatusAction, CartDraft, Cart, CartAddLineItemAction, CartAddItemShippingAddressAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetLineItemShippingDetailsAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryChangeNameAction, CategoryChangeParentAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, CategoryRemoveAssetAction, CategoryAddAssetAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, CustomerSetCustomFieldAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, Transaction, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, ProductDraft, Product, ProductUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductSelectionUpdateAction, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, Review, ReviewUpdateAction, ShippingMethodDraft, ShippingMethod, ShippingMethodUpdateAction, ShoppingListDraft, ShoppingList, StagedQuoteDraft, StagedQuote, StagedQuoteUpdateAction, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, DiscountedPriceDraft, StandalonePriceChangeActiveAction, StandalonePriceChangeValueAction, StandalonePriceSetDiscountedPriceAction, StateDraft, State, StateUpdateAction, StoreDraft, Store, StoreUpdateAction, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TaxCategoryUpdateAction, TypeDraft, Type, TypeUpdateAction, ZoneDraft, Zone, ZoneUpdateAction, BaseResource, UpdateAction } from '@commercetools/platform-sdk';
4
+ import { Project, ResourceIdentifier, QueryParam, AssociateRoleDraft, AssociateRole, AssociateRoleSetNameAction, AssociateRoleSetPermissionsAction, AssociateRoleChangeBuyerAssignableAction, AssociateRoleSetCustomFieldAction, AssociateRoleAddPermissionAction, AssociateRoleRemovePermissionAction, AttributeGroupDraft, AttributeGroup, AttributeGroupSetAttributesAction, AttributeGroupChangeNameAction, AttributeGroupSetDescriptionAction, AttributeGroupSetKeyAction, BusinessUnitDraft, BusinessUnit, BusinessUnitAddAddressAction, BusinessUnitAddAssociateAction, BusinessUnitSetAssociatesAction, BusinessUnitSetContactEmailAction, BusinessUnitSetStoreModeAction, BusinessUnitChangeNameAction, BusinessUnitChangeAddressAction, BusinessUnitAddStoreAction, BusinessUnitChangeParentUnitAction, BusinessUnitChangeStatusAction, CartDraft, Cart, CartAddLineItemAction, CartAddItemShippingAddressAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetLineItemShippingDetailsAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryChangeNameAction, CategoryChangeParentAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, CategoryRemoveAssetAction, CategoryAddAssetAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, CustomerSetCustomFieldAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderAddReturnInfoAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, Transaction, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, ProductDraft, Product, ProductUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductSelectionUpdateAction, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, Review, ReviewUpdateAction, ShippingMethodDraft, ShippingMethod, ShippingMethodUpdateAction, ShoppingListDraft, ShoppingList, StagedQuoteDraft, StagedQuote, StagedQuoteUpdateAction, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, DiscountedPriceDraft, StandalonePriceChangeActiveAction, StandalonePriceChangeValueAction, StandalonePriceSetDiscountedPriceAction, StateDraft, State, StateUpdateAction, StoreDraft, Store, StoreUpdateAction, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TaxCategoryUpdateAction, TypeDraft, Type, TypeUpdateAction, ZoneDraft, Zone, ZoneUpdateAction, BaseResource, UpdateAction } from '@commercetools/platform-sdk';
5
5
 
6
6
  type GetParams$1 = {
7
7
  expand?: string[];
@@ -197,6 +197,7 @@ declare class OrderRepository extends AbstractResourceRepository<'order'> {
197
197
  getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams): Order | undefined;
198
198
  actions: {
199
199
  addPayment: (context: RepositoryContext, resource: Writable<Order>, { payment }: OrderAddPaymentAction) => void;
200
+ addReturnInfo: (context: RepositoryContext, resource: Writable<Order>, info: OrderAddReturnInfoAction) => void;
200
201
  changeOrderState: (context: RepositoryContext, resource: Writable<Order>, { orderState }: OrderChangeOrderStateAction) => void;
201
202
  changePaymentState: (context: RepositoryContext, resource: Writable<Order>, { paymentState }: OrderChangePaymentStateAction) => void;
202
203
  transitionState: (context: RepositoryContext, resource: Writable<Order>, { state }: OrderTransitionStateAction) => void;
@@ -237,6 +238,8 @@ declare class PaymentRepository extends AbstractResourceRepository<'payment'> {
237
238
  declare class ProductRepository extends AbstractResourceRepository<'product'> {
238
239
  getTypeId(): "product";
239
240
  create(context: RepositoryContext, draft: ProductDraft): Product;
241
+ private variantFromDraft;
242
+ private priceFromDraft;
240
243
  actions: Partial<Record<ProductUpdateAction['action'], (context: RepositoryContext, resource: Writable<Product>, action: any) => void>>;
241
244
  }
242
245
 
@@ -465,6 +468,7 @@ declare const createRepositories: (storage: AbstractStorage) => {
465
468
  'my-order': MyOrderRepository;
466
469
  'my-customer': CustomerRepository;
467
470
  'my-payment': PaymentRepository;
471
+ 'my-shopping-list': ShoppingListRepository;
468
472
  product: ProductRepository;
469
473
  'product-type': ProductTypeRepository;
470
474
  'product-discount': ProductDiscountRepository;
@@ -645,6 +649,7 @@ declare class CommercetoolsMock {
645
649
  runServer(port?: number, options?: AppOptions): void;
646
650
  private createApp;
647
651
  registerHandlers(server: SetupServer): void;
652
+ mswServer(): SetupServer | undefined;
648
653
  private startServer;
649
654
  }
650
655
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import express from 'express';
2
2
  import { SetupServer } from 'msw/node';
3
3
  import * as ctp from '@commercetools/platform-sdk';
4
- import { Project, ResourceIdentifier, QueryParam, AssociateRoleDraft, AssociateRole, AssociateRoleSetNameAction, AssociateRoleSetPermissionsAction, AssociateRoleChangeBuyerAssignableAction, AssociateRoleSetCustomFieldAction, AssociateRoleAddPermissionAction, AssociateRoleRemovePermissionAction, AttributeGroupDraft, AttributeGroup, AttributeGroupSetAttributesAction, AttributeGroupChangeNameAction, AttributeGroupSetDescriptionAction, AttributeGroupSetKeyAction, BusinessUnitDraft, BusinessUnit, BusinessUnitAddAddressAction, BusinessUnitAddAssociateAction, BusinessUnitSetAssociatesAction, BusinessUnitSetContactEmailAction, BusinessUnitSetStoreModeAction, BusinessUnitChangeNameAction, BusinessUnitChangeAddressAction, BusinessUnitAddStoreAction, BusinessUnitChangeParentUnitAction, BusinessUnitChangeStatusAction, CartDraft, Cart, CartAddLineItemAction, CartAddItemShippingAddressAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetLineItemShippingDetailsAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryChangeNameAction, CategoryChangeParentAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, CategoryRemoveAssetAction, CategoryAddAssetAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, CustomerSetCustomFieldAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, Transaction, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, ProductDraft, Product, ProductUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductSelectionUpdateAction, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, Review, ReviewUpdateAction, ShippingMethodDraft, ShippingMethod, ShippingMethodUpdateAction, ShoppingListDraft, ShoppingList, StagedQuoteDraft, StagedQuote, StagedQuoteUpdateAction, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, DiscountedPriceDraft, StandalonePriceChangeActiveAction, StandalonePriceChangeValueAction, StandalonePriceSetDiscountedPriceAction, StateDraft, State, StateUpdateAction, StoreDraft, Store, StoreUpdateAction, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TaxCategoryUpdateAction, TypeDraft, Type, TypeUpdateAction, ZoneDraft, Zone, ZoneUpdateAction, BaseResource, UpdateAction } from '@commercetools/platform-sdk';
4
+ import { Project, ResourceIdentifier, QueryParam, AssociateRoleDraft, AssociateRole, AssociateRoleSetNameAction, AssociateRoleSetPermissionsAction, AssociateRoleChangeBuyerAssignableAction, AssociateRoleSetCustomFieldAction, AssociateRoleAddPermissionAction, AssociateRoleRemovePermissionAction, AttributeGroupDraft, AttributeGroup, AttributeGroupSetAttributesAction, AttributeGroupChangeNameAction, AttributeGroupSetDescriptionAction, AttributeGroupSetKeyAction, BusinessUnitDraft, BusinessUnit, BusinessUnitAddAddressAction, BusinessUnitAddAssociateAction, BusinessUnitSetAssociatesAction, BusinessUnitSetContactEmailAction, BusinessUnitSetStoreModeAction, BusinessUnitChangeNameAction, BusinessUnitChangeAddressAction, BusinessUnitAddStoreAction, BusinessUnitChangeParentUnitAction, BusinessUnitChangeStatusAction, CartDraft, Cart, CartAddLineItemAction, CartAddItemShippingAddressAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetLineItemShippingDetailsAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryChangeNameAction, CategoryChangeParentAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, CategoryRemoveAssetAction, CategoryAddAssetAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, CustomerSetCustomFieldAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderAddReturnInfoAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, Transaction, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, ProductDraft, Product, ProductUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductSelectionUpdateAction, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, Review, ReviewUpdateAction, ShippingMethodDraft, ShippingMethod, ShippingMethodUpdateAction, ShoppingListDraft, ShoppingList, StagedQuoteDraft, StagedQuote, StagedQuoteUpdateAction, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, DiscountedPriceDraft, StandalonePriceChangeActiveAction, StandalonePriceChangeValueAction, StandalonePriceSetDiscountedPriceAction, StateDraft, State, StateUpdateAction, StoreDraft, Store, StoreUpdateAction, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TaxCategoryUpdateAction, TypeDraft, Type, TypeUpdateAction, ZoneDraft, Zone, ZoneUpdateAction, BaseResource, UpdateAction } from '@commercetools/platform-sdk';
5
5
 
6
6
  type GetParams$1 = {
7
7
  expand?: string[];
@@ -197,6 +197,7 @@ declare class OrderRepository extends AbstractResourceRepository<'order'> {
197
197
  getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams): Order | undefined;
198
198
  actions: {
199
199
  addPayment: (context: RepositoryContext, resource: Writable<Order>, { payment }: OrderAddPaymentAction) => void;
200
+ addReturnInfo: (context: RepositoryContext, resource: Writable<Order>, info: OrderAddReturnInfoAction) => void;
200
201
  changeOrderState: (context: RepositoryContext, resource: Writable<Order>, { orderState }: OrderChangeOrderStateAction) => void;
201
202
  changePaymentState: (context: RepositoryContext, resource: Writable<Order>, { paymentState }: OrderChangePaymentStateAction) => void;
202
203
  transitionState: (context: RepositoryContext, resource: Writable<Order>, { state }: OrderTransitionStateAction) => void;
@@ -237,6 +238,8 @@ declare class PaymentRepository extends AbstractResourceRepository<'payment'> {
237
238
  declare class ProductRepository extends AbstractResourceRepository<'product'> {
238
239
  getTypeId(): "product";
239
240
  create(context: RepositoryContext, draft: ProductDraft): Product;
241
+ private variantFromDraft;
242
+ private priceFromDraft;
240
243
  actions: Partial<Record<ProductUpdateAction['action'], (context: RepositoryContext, resource: Writable<Product>, action: any) => void>>;
241
244
  }
242
245
 
@@ -465,6 +468,7 @@ declare const createRepositories: (storage: AbstractStorage) => {
465
468
  'my-order': MyOrderRepository;
466
469
  'my-customer': CustomerRepository;
467
470
  'my-payment': PaymentRepository;
471
+ 'my-shopping-list': ShoppingListRepository;
468
472
  product: ProductRepository;
469
473
  'product-type': ProductTypeRepository;
470
474
  'product-discount': ProductDiscountRepository;
@@ -645,6 +649,7 @@ declare class CommercetoolsMock {
645
649
  runServer(port?: number, options?: AppOptions): void;
646
650
  private createApp;
647
651
  registerHandlers(server: SetupServer): void;
652
+ mswServer(): SetupServer | undefined;
648
653
  private startServer;
649
654
  }
650
655
 
package/dist/index.js CHANGED
@@ -1194,11 +1194,13 @@ var InMemoryStorage = class extends AbstractStorage {
1194
1194
  if (reference === void 0)
1195
1195
  return;
1196
1196
  if (reference.typeId !== void 0 && (reference.id !== void 0 || reference.key !== void 0)) {
1197
- reference.obj = this.getByResourceIdentifier(projectKey, {
1198
- typeId: reference.typeId,
1199
- id: reference.id,
1200
- key: reference.key
1201
- });
1197
+ if (!reference.obj) {
1198
+ reference.obj = this.getByResourceIdentifier(projectKey, {
1199
+ typeId: reference.typeId,
1200
+ id: reference.id,
1201
+ key: reference.key
1202
+ });
1203
+ }
1202
1204
  if (expand) {
1203
1205
  this._resolveResource(projectKey, reference.obj, expand);
1204
1206
  }
@@ -1633,7 +1635,7 @@ var getReferenceFromResourceIdentifier = (resourceIdentifier, projectKey, storag
1633
1635
  resourceIdentifier
1634
1636
  );
1635
1637
  if (!resource) {
1636
- const errIdentifier = resourceIdentifier.key ? `key '${resourceIdentifier.key}'` : `identifier '${resourceIdentifier.key}'`;
1638
+ const errIdentifier = resourceIdentifier.key ? `key '${resourceIdentifier.key}'` : `identifier '${resourceIdentifier.id}'`;
1637
1639
  throw new CommercetoolsError(
1638
1640
  {
1639
1641
  code: "ReferencedResourceNotFound",
@@ -2973,7 +2975,8 @@ var CustomerRepository = class extends AbstractResourceRepository {
2973
2975
  email: draft.email.toLowerCase(),
2974
2976
  password: draft.password ? hashPassword(draft.password) : void 0,
2975
2977
  isEmailVerified: draft.isEmailVerified || false,
2976
- addresses: []
2978
+ addresses: [],
2979
+ customerNumber: draft.customerNumber
2977
2980
  };
2978
2981
  this.saveNew(context, resource);
2979
2982
  return resource;
@@ -3479,10 +3482,11 @@ var OrderRepository = class extends AbstractResourceRepository {
3479
3482
  name: draft.name,
3480
3483
  quantity: draft.quantity ?? 0,
3481
3484
  perMethodTaxRate: [],
3482
- priceMode: draft.priceMode,
3485
+ priceMode: draft.priceMode ?? "Standard",
3483
3486
  slug: draft.slug,
3484
3487
  state: [],
3485
- totalPrice: createCentPrecisionMoney(draft.money)
3488
+ totalPrice: createCentPrecisionMoney(draft.money),
3489
+ taxedPricePortions: []
3486
3490
  };
3487
3491
  return lineItem;
3488
3492
  }
@@ -3518,6 +3522,37 @@ var OrderRepository = class extends AbstractResourceRepository {
3518
3522
  id: payment.id
3519
3523
  });
3520
3524
  },
3525
+ addReturnInfo: (context, resource, info) => {
3526
+ if (!resource.returnInfo) {
3527
+ resource.returnInfo = [];
3528
+ }
3529
+ const resolved = {
3530
+ items: info.items.map((item) => {
3531
+ const common = {
3532
+ ...getBaseResourceProperties(),
3533
+ quantity: item.quantity,
3534
+ paymentState: "Initial",
3535
+ shipmentState: "Initial",
3536
+ comment: item.comment
3537
+ };
3538
+ if (item.customLineItemId) {
3539
+ return {
3540
+ ...common,
3541
+ type: "CustomLineItemReturnItem",
3542
+ customLineItemId: item.customLineItemId
3543
+ };
3544
+ }
3545
+ return {
3546
+ ...common,
3547
+ type: "LineItemReturnItem",
3548
+ lineItemId: item.customLineItemId || item.lineItemId
3549
+ };
3550
+ }),
3551
+ returnTrackingId: info.returnTrackingId,
3552
+ returnDate: info.returnDate
3553
+ };
3554
+ resource.returnInfo.push(resolved);
3555
+ },
3521
3556
  changeOrderState: (context, resource, { orderState }) => {
3522
3557
  resource.orderState = orderState;
3523
3558
  },
@@ -3828,9 +3863,9 @@ var ProductRepository = class extends AbstractResourceRepository {
3828
3863
  slug: draft.slug,
3829
3864
  description: draft.description,
3830
3865
  categories: categoryReferences,
3831
- masterVariant: variantFromDraft(1, draft.masterVariant),
3866
+ masterVariant: this.variantFromDraft(context, 1, draft.masterVariant),
3832
3867
  variants: draft.variants?.map(
3833
- (variant, index) => variantFromDraft(index + 2, variant)
3868
+ (variant, index) => this.variantFromDraft(context, index + 2, variant)
3834
3869
  ) ?? [],
3835
3870
  metaTitle: draft.metaTitle,
3836
3871
  metaDescription: draft.metaDescription,
@@ -3853,6 +3888,30 @@ var ProductRepository = class extends AbstractResourceRepository {
3853
3888
  this.saveNew(context, resource);
3854
3889
  return resource;
3855
3890
  }
3891
+ variantFromDraft(context, variantId, variant) {
3892
+ return {
3893
+ id: variantId,
3894
+ sku: variant?.sku,
3895
+ key: variant?.key,
3896
+ attributes: variant?.attributes ?? [],
3897
+ prices: variant?.prices?.map((p) => this.priceFromDraft(context, p)),
3898
+ assets: [],
3899
+ images: []
3900
+ };
3901
+ }
3902
+ priceFromDraft(context, draft) {
3903
+ return {
3904
+ id: uuidv46(),
3905
+ key: draft.key,
3906
+ country: draft.country,
3907
+ value: createTypedMoney(draft.value),
3908
+ channel: draft.channel ? getReferenceFromResourceIdentifier(
3909
+ draft.channel,
3910
+ context.projectKey,
3911
+ this._storage
3912
+ ) : void 0
3913
+ };
3914
+ }
3856
3915
  actions = {
3857
3916
  publish: (context, resource, { scope }) => {
3858
3917
  resource.masterData.current = resource.masterData.staged;
@@ -4097,7 +4156,7 @@ var ProductRepository = class extends AbstractResourceRepository {
4097
4156
  data.variants[variantIndex] = variant;
4098
4157
  }
4099
4158
  };
4100
- const priceToAdd = priceFromDraft(price);
4159
+ const priceToAdd = this.priceFromDraft(context, price);
4101
4160
  const onlyStaged = staged !== void 0 ? staged : true;
4102
4161
  addVariantPrice(resource.masterData.staged, priceToAdd);
4103
4162
  if (!onlyStaged) {
@@ -4254,7 +4313,7 @@ var ProductRepository = class extends AbstractResourceRepository {
4254
4313
  (max, element) => element.id > max ? element.id : max,
4255
4314
  0
4256
4315
  );
4257
- const variant = variantFromDraft(maxId + 1, variantDraft);
4316
+ const variant = this.variantFromDraft(context, maxId + 1, variantDraft);
4258
4317
  dataStaged.variants.push(variant);
4259
4318
  const onlyStaged = staged !== void 0 ? staged : true;
4260
4319
  if (!onlyStaged) {
@@ -4492,21 +4551,6 @@ var getVariant = (productData, variantId, sku) => {
4492
4551
  variantIndex: !isMasterVariant && foundVariant ? productData.variants.indexOf(foundVariant) : -1
4493
4552
  };
4494
4553
  };
4495
- var variantFromDraft = (variantId, variant) => ({
4496
- id: variantId,
4497
- sku: variant?.sku,
4498
- key: variant?.key,
4499
- attributes: variant?.attributes ?? [],
4500
- prices: variant?.prices?.map(priceFromDraft),
4501
- assets: [],
4502
- images: []
4503
- });
4504
- var priceFromDraft = (draft) => ({
4505
- id: uuidv46(),
4506
- key: draft.key,
4507
- country: draft.country,
4508
- value: createTypedMoney(draft.value)
4509
- });
4510
4554
 
4511
4555
  // src/repositories/product-discount.ts
4512
4556
  var ProductDiscountRepository = class extends AbstractResourceRepository {
@@ -4778,7 +4822,7 @@ var getVariants = (p) => [
4778
4822
  ];
4779
4823
 
4780
4824
  // src/priceSelector.ts
4781
- var applyPriceSelector = (products, selector) => {
4825
+ var applyPriceSelector = (products, selector, noScopedPrice = false) => {
4782
4826
  validatePriceSelector(selector);
4783
4827
  for (const product of products) {
4784
4828
  const variants = [
@@ -4789,11 +4833,14 @@ var applyPriceSelector = (products, selector) => {
4789
4833
  const scopedPrices = variant.prices?.filter((p) => priceSelectorFilter(p, selector)) ?? [];
4790
4834
  if (scopedPrices.length > 0) {
4791
4835
  const price = scopedPrices[0];
4792
- variant.scopedPriceDiscounted = false;
4793
- variant.scopedPrice = {
4794
- ...price,
4795
- currentValue: price.value
4796
- };
4836
+ variant.price = scopedPrices[0];
4837
+ if (!noScopedPrice) {
4838
+ variant.scopedPriceDiscounted = false;
4839
+ variant.scopedPrice = {
4840
+ ...price,
4841
+ currentValue: price.value
4842
+ };
4843
+ }
4797
4844
  }
4798
4845
  }
4799
4846
  }
@@ -5128,6 +5175,16 @@ var ProductProjectionRepository = class extends AbstractResourceRepository {
5128
5175
  );
5129
5176
  }
5130
5177
  }
5178
+ applyPriceSelector(
5179
+ resources,
5180
+ {
5181
+ country: params.priceCountry,
5182
+ channel: params.priceChannel,
5183
+ customerGroup: params.priceCustomerGroup,
5184
+ currency: params.priceCurrency
5185
+ },
5186
+ true
5187
+ );
5131
5188
  if (params.expand !== void 0) {
5132
5189
  resources = resources.map(
5133
5190
  (resource) => this._storage.expand(context.projectKey, resource, params.expand)
@@ -5162,7 +5219,6 @@ var ProductSelectionRepository = class extends AbstractResourceRepository {
5162
5219
  productCount: 0,
5163
5220
  key: draft.key,
5164
5221
  name: draft.name,
5165
- type: "individual",
5166
5222
  mode: "Individual"
5167
5223
  };
5168
5224
  this.saveNew(context, resource);
@@ -5378,9 +5434,28 @@ var ReviewRepository = class extends AbstractResourceRepository {
5378
5434
  return "review";
5379
5435
  }
5380
5436
  create(context, draft) {
5437
+ if (!draft.target)
5438
+ throw new Error("Missing target");
5381
5439
  const resource = {
5382
5440
  ...getBaseResourceProperties(),
5383
- includedInStatistics: false
5441
+ locale: draft.locale,
5442
+ authorName: draft.authorName,
5443
+ title: draft.title,
5444
+ text: draft.text,
5445
+ rating: draft.rating,
5446
+ uniquenessValue: draft.uniquenessValue,
5447
+ state: draft.state ? getReferenceFromResourceIdentifier(
5448
+ draft.state,
5449
+ context.projectKey,
5450
+ this._storage
5451
+ ) : void 0,
5452
+ target: draft.target ? getReferenceFromResourceIdentifier(draft.target, context.projectKey, this._storage) : void 0,
5453
+ includedInStatistics: false,
5454
+ custom: createCustomFields(
5455
+ draft.custom,
5456
+ context.projectKey,
5457
+ this._storage
5458
+ )
5384
5459
  };
5385
5460
  this.saveNew(context, resource);
5386
5461
  return resource;
@@ -5994,6 +6069,7 @@ var createRepositories = (storage) => ({
5994
6069
  "my-order": new MyOrderRepository(storage),
5995
6070
  "my-customer": new CustomerRepository(storage),
5996
6071
  "my-payment": new PaymentRepository(storage),
6072
+ "my-shopping-list": new ShoppingListRepository(storage),
5997
6073
  product: new ProductRepository(storage),
5998
6074
  "product-type": new ProductTypeRepository(storage),
5999
6075
  "product-discount": new ProductDiscountRepository(storage),
@@ -6449,6 +6525,7 @@ var MyCustomerService = class extends AbstractService {
6449
6525
  const router = Router3({ mergeParams: true });
6450
6526
  this.extraRoutes(router);
6451
6527
  router.get("", this.getMe.bind(this));
6528
+ router.post("", this.updateMe.bind(this));
6452
6529
  router.post("/signup", this.signUp.bind(this));
6453
6530
  router.post("/login", this.signIn.bind(this));
6454
6531
  parent.use(`/${basePath}`, router);
@@ -6460,6 +6537,21 @@ var MyCustomerService = class extends AbstractService {
6460
6537
  }
6461
6538
  return response.status(200).send(resource);
6462
6539
  }
6540
+ updateMe(request, response) {
6541
+ const resource = this.repository.getMe(getRepositoryContext(request));
6542
+ if (!resource) {
6543
+ return response.status(404).send("Not found");
6544
+ }
6545
+ const updateRequest = request.body;
6546
+ const updatedResource = this.repository.processUpdateActions(
6547
+ getRepositoryContext(request),
6548
+ resource,
6549
+ updateRequest.version,
6550
+ updateRequest.actions
6551
+ );
6552
+ const result = this._expandWithId(request, updatedResource.id);
6553
+ return response.status(200).send(result);
6554
+ }
6463
6555
  signUp(request, response) {
6464
6556
  const draft = request.body;
6465
6557
  const resource = this.repository.create(
@@ -6526,6 +6618,18 @@ var MyPaymentService = class extends AbstractService {
6526
6618
  }
6527
6619
  };
6528
6620
 
6621
+ // src/services/my-shopping-list.ts
6622
+ var MyShoppingListService = class extends AbstractService {
6623
+ repository;
6624
+ constructor(parent, repository) {
6625
+ super(parent);
6626
+ this.repository = repository;
6627
+ }
6628
+ getBasePath() {
6629
+ return "me/shopping-lists";
6630
+ }
6631
+ };
6632
+
6529
6633
  // src/services/order.ts
6530
6634
  var OrderService = class extends AbstractService {
6531
6635
  repository;
@@ -6671,6 +6775,18 @@ var ProductService = class extends AbstractService {
6671
6775
  }
6672
6776
  };
6673
6777
 
6778
+ // src/services/reviews.ts
6779
+ var ReviewService = class extends AbstractService {
6780
+ repository;
6781
+ constructor(parent, repository) {
6782
+ super(parent);
6783
+ this.repository = repository;
6784
+ }
6785
+ getBasePath() {
6786
+ return "reviews";
6787
+ }
6788
+ };
6789
+
6674
6790
  // src/services/shipping-method.ts
6675
6791
  var ShippingMethodService = class extends AbstractService {
6676
6792
  repository;
@@ -6813,6 +6929,10 @@ var createServices = (router, repos) => ({
6813
6929
  "my-order": new MyOrderService(router, repos["my-order"]),
6814
6930
  "my-customer": new MyCustomerService(router, repos["my-customer"]),
6815
6931
  "my-payment": new MyPaymentService(router, repos["my-payment"]),
6932
+ "my-shopping-list": new MyShoppingListService(
6933
+ router,
6934
+ repos["my-shopping-list"]
6935
+ ),
6816
6936
  "shipping-method": new ShippingMethodService(
6817
6937
  router,
6818
6938
  repos["shipping-method"]
@@ -6831,6 +6951,7 @@ var createServices = (router, repos) => ({
6831
6951
  router,
6832
6952
  repos["product-selection"]
6833
6953
  ),
6954
+ reviews: new ReviewService(router, repos["review"]),
6834
6955
  "shopping-list": new ShoppingListService(router, repos["shopping-list"]),
6835
6956
  state: new StateService(router, repos["state"]),
6836
6957
  store: new StoreService(router, repos["store"]),
@@ -6884,7 +7005,6 @@ var CommercetoolsMock = class {
6884
7005
  this._mswServer = void 0;
6885
7006
  }
6886
7007
  clear() {
6887
- this._mswServer?.resetHandlers();
6888
7008
  this._storage.clear();
6889
7009
  }
6890
7010
  project(projectKey) {
@@ -7021,6 +7141,9 @@ var CommercetoolsMock = class {
7021
7141
  })
7022
7142
  );
7023
7143
  }
7144
+ mswServer() {
7145
+ return this._mswServer;
7146
+ }
7024
7147
  startServer() {
7025
7148
  if (_globalListeners.length > 0) {
7026
7149
  if (this._mswServer !== void 0) {