@labdigital/commercetools-mock 2.7.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
 
@@ -646,6 +649,7 @@ declare class CommercetoolsMock {
646
649
  runServer(port?: number, options?: AppOptions): void;
647
650
  private createApp;
648
651
  registerHandlers(server: SetupServer): void;
652
+ mswServer(): SetupServer | undefined;
649
653
  private startServer;
650
654
  }
651
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
 
@@ -646,6 +649,7 @@ declare class CommercetoolsMock {
646
649
  runServer(port?: number, options?: AppOptions): void;
647
650
  private createApp;
648
651
  registerHandlers(server: SetupServer): void;
652
+ mswServer(): SetupServer | undefined;
649
653
  private startServer;
650
654
  }
651
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;
@@ -6700,6 +6775,18 @@ var ProductService = class extends AbstractService {
6700
6775
  }
6701
6776
  };
6702
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
+
6703
6790
  // src/services/shipping-method.ts
6704
6791
  var ShippingMethodService = class extends AbstractService {
6705
6792
  repository;
@@ -6864,6 +6951,7 @@ var createServices = (router, repos) => ({
6864
6951
  router,
6865
6952
  repos["product-selection"]
6866
6953
  ),
6954
+ reviews: new ReviewService(router, repos["review"]),
6867
6955
  "shopping-list": new ShoppingListService(router, repos["shopping-list"]),
6868
6956
  state: new StateService(router, repos["state"]),
6869
6957
  store: new StoreService(router, repos["store"]),
@@ -7053,6 +7141,9 @@ var CommercetoolsMock = class {
7053
7141
  })
7054
7142
  );
7055
7143
  }
7144
+ mswServer() {
7145
+ return this._mswServer;
7146
+ }
7056
7147
  startServer() {
7057
7148
  if (_globalListeners.length > 0) {
7058
7149
  if (this._mswServer !== void 0) {