@labdigital/commercetools-mock 1.10.0 → 1.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.
- package/dist/index.cjs +100 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +100 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/cart.ts +48 -0
- package/src/repositories/product-selection.ts +14 -5
- package/src/services/cart.test.ts +87 -0
- package/src/services/index.ts +9 -4
- package/src/services/product-selection.test.ts +36 -0
- package/src/services/product-selection.ts +16 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import * as ctp from '@commercetools/platform-sdk';
|
|
3
|
-
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, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, 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,
|
|
3
|
+
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, 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
4
|
|
|
5
5
|
type GetParams$1 = {
|
|
6
6
|
expand?: string[];
|
|
@@ -80,6 +80,7 @@ declare class CartRepository extends AbstractResourceRepository<'cart'> {
|
|
|
80
80
|
getActiveCart(projectKey: string): Cart | undefined;
|
|
81
81
|
actions: {
|
|
82
82
|
addLineItem: (context: RepositoryContext, resource: Writable<Cart>, { productId, variantId, sku, quantity }: CartAddLineItemAction) => void;
|
|
83
|
+
addItemShippingAddress: (context: RepositoryContext, resource: Writable<Cart>, { action, address }: CartAddItemShippingAddressAction) => void;
|
|
83
84
|
changeLineItemQuantity: (context: RepositoryContext, resource: Writable<Cart>, { lineItemId, lineItemKey, quantity }: CartChangeLineItemQuantityAction) => void;
|
|
84
85
|
removeLineItem: (context: RepositoryContext, resource: Writable<Cart>, { lineItemId, quantity }: CartRemoveLineItemAction) => void;
|
|
85
86
|
setBillingAddress: (context: RepositoryContext, resource: Writable<Cart>, { address }: CartSetBillingAddressAction) => void;
|
|
@@ -89,6 +90,7 @@ declare class CartRepository extends AbstractResourceRepository<'cart'> {
|
|
|
89
90
|
setCustomField: (context: RepositoryContext, resource: Cart, { name, value }: CartSetCustomFieldAction) => void;
|
|
90
91
|
setCustomType: (context: RepositoryContext, resource: Writable<Cart>, { type, fields }: CartSetCustomTypeAction) => void;
|
|
91
92
|
setLocale: (context: RepositoryContext, resource: Writable<Cart>, { locale }: CartSetLocaleAction) => void;
|
|
93
|
+
setLineItemShippingDetails: (context: RepositoryContext, resource: Writable<Cart>, { action, shippingDetails, lineItemId, lineItemKey, }: CartSetLineItemShippingDetailsAction) => void;
|
|
92
94
|
setShippingAddress: (context: RepositoryContext, resource: Writable<Cart>, { address }: CartSetShippingAddressAction) => void;
|
|
93
95
|
removeDiscountCode: (context: RepositoryContext, resource: Writable<Cart>, { discountCode }: CartRemoveDiscountCodeAction) => void;
|
|
94
96
|
};
|
|
@@ -331,7 +333,7 @@ declare class ProductProjectionRepository extends AbstractResourceRepository<'pr
|
|
|
331
333
|
declare class ProductSelectionRepository extends AbstractResourceRepository<'product-selection'> {
|
|
332
334
|
getTypeId(): "product-selection";
|
|
333
335
|
create(context: RepositoryContext, draft: ProductSelectionDraft): ProductSelection;
|
|
334
|
-
actions: Partial<Record<
|
|
336
|
+
actions: Partial<Record<ProductSelectionUpdateAction['action'], (context: RepositoryContext, resource: Writable<ProductSelection>, action: any) => void>>;
|
|
335
337
|
}
|
|
336
338
|
|
|
337
339
|
declare class ProductTypeRepository extends AbstractResourceRepository<'product-type'> {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import * as ctp from '@commercetools/platform-sdk';
|
|
3
|
-
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, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, 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,
|
|
3
|
+
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, 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
4
|
|
|
5
5
|
type GetParams$1 = {
|
|
6
6
|
expand?: string[];
|
|
@@ -80,6 +80,7 @@ declare class CartRepository extends AbstractResourceRepository<'cart'> {
|
|
|
80
80
|
getActiveCart(projectKey: string): Cart | undefined;
|
|
81
81
|
actions: {
|
|
82
82
|
addLineItem: (context: RepositoryContext, resource: Writable<Cart>, { productId, variantId, sku, quantity }: CartAddLineItemAction) => void;
|
|
83
|
+
addItemShippingAddress: (context: RepositoryContext, resource: Writable<Cart>, { action, address }: CartAddItemShippingAddressAction) => void;
|
|
83
84
|
changeLineItemQuantity: (context: RepositoryContext, resource: Writable<Cart>, { lineItemId, lineItemKey, quantity }: CartChangeLineItemQuantityAction) => void;
|
|
84
85
|
removeLineItem: (context: RepositoryContext, resource: Writable<Cart>, { lineItemId, quantity }: CartRemoveLineItemAction) => void;
|
|
85
86
|
setBillingAddress: (context: RepositoryContext, resource: Writable<Cart>, { address }: CartSetBillingAddressAction) => void;
|
|
@@ -89,6 +90,7 @@ declare class CartRepository extends AbstractResourceRepository<'cart'> {
|
|
|
89
90
|
setCustomField: (context: RepositoryContext, resource: Cart, { name, value }: CartSetCustomFieldAction) => void;
|
|
90
91
|
setCustomType: (context: RepositoryContext, resource: Writable<Cart>, { type, fields }: CartSetCustomTypeAction) => void;
|
|
91
92
|
setLocale: (context: RepositoryContext, resource: Writable<Cart>, { locale }: CartSetLocaleAction) => void;
|
|
93
|
+
setLineItemShippingDetails: (context: RepositoryContext, resource: Writable<Cart>, { action, shippingDetails, lineItemId, lineItemKey, }: CartSetLineItemShippingDetailsAction) => void;
|
|
92
94
|
setShippingAddress: (context: RepositoryContext, resource: Writable<Cart>, { address }: CartSetShippingAddressAction) => void;
|
|
93
95
|
removeDiscountCode: (context: RepositoryContext, resource: Writable<Cart>, { discountCode }: CartRemoveDiscountCodeAction) => void;
|
|
94
96
|
};
|
|
@@ -331,7 +333,7 @@ declare class ProductProjectionRepository extends AbstractResourceRepository<'pr
|
|
|
331
333
|
declare class ProductSelectionRepository extends AbstractResourceRepository<'product-selection'> {
|
|
332
334
|
getTypeId(): "product-selection";
|
|
333
335
|
create(context: RepositoryContext, draft: ProductSelectionDraft): ProductSelection;
|
|
334
|
-
actions: Partial<Record<
|
|
336
|
+
actions: Partial<Record<ProductSelectionUpdateAction['action'], (context: RepositoryContext, resource: Writable<ProductSelection>, action: any) => void>>;
|
|
335
337
|
}
|
|
336
338
|
|
|
337
339
|
declare class ProductTypeRepository extends AbstractResourceRepository<'product-type'> {
|
package/dist/index.js
CHANGED
|
@@ -2152,6 +2152,16 @@ var CartRepository = class extends AbstractResourceRepository {
|
|
|
2152
2152
|
}
|
|
2153
2153
|
resource.totalPrice.centAmount = calculateCartTotalPrice(resource);
|
|
2154
2154
|
},
|
|
2155
|
+
addItemShippingAddress: (context, resource, { action, address }) => {
|
|
2156
|
+
const newAddress = createAddress(
|
|
2157
|
+
address,
|
|
2158
|
+
context.projectKey,
|
|
2159
|
+
this._storage
|
|
2160
|
+
);
|
|
2161
|
+
if (newAddress) {
|
|
2162
|
+
resource.itemShippingAddresses.push(newAddress);
|
|
2163
|
+
}
|
|
2164
|
+
},
|
|
2155
2165
|
changeLineItemQuantity: (context, resource, { lineItemId, lineItemKey, quantity }) => {
|
|
2156
2166
|
let lineItem;
|
|
2157
2167
|
if (lineItemId) {
|
|
@@ -2275,6 +2285,26 @@ var CartRepository = class extends AbstractResourceRepository {
|
|
|
2275
2285
|
setLocale: (context, resource, { locale }) => {
|
|
2276
2286
|
resource.locale = locale;
|
|
2277
2287
|
},
|
|
2288
|
+
setLineItemShippingDetails: (context, resource, {
|
|
2289
|
+
action,
|
|
2290
|
+
shippingDetails,
|
|
2291
|
+
lineItemId,
|
|
2292
|
+
lineItemKey
|
|
2293
|
+
}) => {
|
|
2294
|
+
const lineItem = resource.lineItems.find(
|
|
2295
|
+
(x) => lineItemId && x.id === lineItemId || lineItemKey && x.key === lineItemKey
|
|
2296
|
+
);
|
|
2297
|
+
if (!lineItem) {
|
|
2298
|
+
throw new CommercetoolsError({
|
|
2299
|
+
code: "General",
|
|
2300
|
+
message: lineItemKey ? `A line item with key '${lineItemKey}' not found.` : `A line item with ID '${lineItemId}' not found.`
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
lineItem.shippingDetails = {
|
|
2304
|
+
...shippingDetails,
|
|
2305
|
+
valid: true
|
|
2306
|
+
};
|
|
2307
|
+
},
|
|
2278
2308
|
setShippingAddress: (context, resource, { address }) => {
|
|
2279
2309
|
if (!address) {
|
|
2280
2310
|
resource.shippingAddress = void 0;
|
|
@@ -4642,6 +4672,7 @@ var ProductSelectionRepository = class extends AbstractResourceRepository {
|
|
|
4642
4672
|
const resource = {
|
|
4643
4673
|
...getBaseResourceProperties(),
|
|
4644
4674
|
productCount: 0,
|
|
4675
|
+
key: draft.key,
|
|
4645
4676
|
name: draft.name,
|
|
4646
4677
|
type: "individual",
|
|
4647
4678
|
mode: "Individual"
|
|
@@ -4649,7 +4680,11 @@ var ProductSelectionRepository = class extends AbstractResourceRepository {
|
|
|
4649
4680
|
this.saveNew(context, resource);
|
|
4650
4681
|
return resource;
|
|
4651
4682
|
}
|
|
4652
|
-
actions = {
|
|
4683
|
+
actions = {
|
|
4684
|
+
changeName: (context, resource, { name }) => {
|
|
4685
|
+
resource.name = name;
|
|
4686
|
+
}
|
|
4687
|
+
};
|
|
4653
4688
|
};
|
|
4654
4689
|
|
|
4655
4690
|
// src/repositories/product-type.ts
|
|
@@ -5649,6 +5684,18 @@ var AssociateRoleServices = class extends AbstractService {
|
|
|
5649
5684
|
}
|
|
5650
5685
|
};
|
|
5651
5686
|
|
|
5687
|
+
// src/services/attribute-group.ts
|
|
5688
|
+
var AttributeGroupService = class extends AbstractService {
|
|
5689
|
+
repository;
|
|
5690
|
+
constructor(parent, repository) {
|
|
5691
|
+
super(parent);
|
|
5692
|
+
this.repository = repository;
|
|
5693
|
+
}
|
|
5694
|
+
getBasePath() {
|
|
5695
|
+
return "attribute-groups";
|
|
5696
|
+
}
|
|
5697
|
+
};
|
|
5698
|
+
|
|
5652
5699
|
// src/services/business-units.ts
|
|
5653
5700
|
var BusinessUnitServices = class extends AbstractService {
|
|
5654
5701
|
repository;
|
|
@@ -5661,6 +5708,18 @@ var BusinessUnitServices = class extends AbstractService {
|
|
|
5661
5708
|
}
|
|
5662
5709
|
};
|
|
5663
5710
|
|
|
5711
|
+
// src/services/cart-discount.ts
|
|
5712
|
+
var CartDiscountService = class extends AbstractService {
|
|
5713
|
+
repository;
|
|
5714
|
+
constructor(parent, repository) {
|
|
5715
|
+
super(parent);
|
|
5716
|
+
this.repository = repository;
|
|
5717
|
+
}
|
|
5718
|
+
getBasePath() {
|
|
5719
|
+
return "cart-discounts";
|
|
5720
|
+
}
|
|
5721
|
+
};
|
|
5722
|
+
|
|
5664
5723
|
// src/services/cart.ts
|
|
5665
5724
|
var CartService = class extends AbstractService {
|
|
5666
5725
|
repository;
|
|
@@ -5699,18 +5758,6 @@ var CartService = class extends AbstractService {
|
|
|
5699
5758
|
}
|
|
5700
5759
|
};
|
|
5701
5760
|
|
|
5702
|
-
// src/services/cart-discount.ts
|
|
5703
|
-
var CartDiscountService = class extends AbstractService {
|
|
5704
|
-
repository;
|
|
5705
|
-
constructor(parent, repository) {
|
|
5706
|
-
super(parent);
|
|
5707
|
-
this.repository = repository;
|
|
5708
|
-
}
|
|
5709
|
-
getBasePath() {
|
|
5710
|
-
return "cart-discounts";
|
|
5711
|
-
}
|
|
5712
|
-
};
|
|
5713
|
-
|
|
5714
5761
|
// src/services/category.ts
|
|
5715
5762
|
var CategoryServices = class extends AbstractService {
|
|
5716
5763
|
repository;
|
|
@@ -5787,6 +5834,18 @@ var CustomObjectService = class extends AbstractService {
|
|
|
5787
5834
|
}
|
|
5788
5835
|
};
|
|
5789
5836
|
|
|
5837
|
+
// src/services/customer-group.ts
|
|
5838
|
+
var CustomerGroupService = class extends AbstractService {
|
|
5839
|
+
repository;
|
|
5840
|
+
constructor(parent, repository) {
|
|
5841
|
+
super(parent);
|
|
5842
|
+
this.repository = repository;
|
|
5843
|
+
}
|
|
5844
|
+
getBasePath() {
|
|
5845
|
+
return "customer-groups";
|
|
5846
|
+
}
|
|
5847
|
+
};
|
|
5848
|
+
|
|
5790
5849
|
// src/services/customer.ts
|
|
5791
5850
|
import { v4 as uuidv48 } from "uuid";
|
|
5792
5851
|
var CustomerService = class extends AbstractService {
|
|
@@ -5818,18 +5877,6 @@ var CustomerService = class extends AbstractService {
|
|
|
5818
5877
|
}
|
|
5819
5878
|
};
|
|
5820
5879
|
|
|
5821
|
-
// src/services/customer-group.ts
|
|
5822
|
-
var CustomerGroupService = class extends AbstractService {
|
|
5823
|
-
repository;
|
|
5824
|
-
constructor(parent, repository) {
|
|
5825
|
-
super(parent);
|
|
5826
|
-
this.repository = repository;
|
|
5827
|
-
}
|
|
5828
|
-
getBasePath() {
|
|
5829
|
-
return "customer-groups";
|
|
5830
|
-
}
|
|
5831
|
-
};
|
|
5832
|
-
|
|
5833
5880
|
// src/services/discount-code.ts
|
|
5834
5881
|
var DiscountCodeService = class extends AbstractService {
|
|
5835
5882
|
repository;
|
|
@@ -6038,18 +6085,6 @@ var PaymentService = class extends AbstractService {
|
|
|
6038
6085
|
}
|
|
6039
6086
|
};
|
|
6040
6087
|
|
|
6041
|
-
// src/services/product.ts
|
|
6042
|
-
var ProductService = class extends AbstractService {
|
|
6043
|
-
repository;
|
|
6044
|
-
constructor(parent, repository) {
|
|
6045
|
-
super(parent);
|
|
6046
|
-
this.repository = repository;
|
|
6047
|
-
}
|
|
6048
|
-
getBasePath() {
|
|
6049
|
-
return "products";
|
|
6050
|
-
}
|
|
6051
|
-
};
|
|
6052
|
-
|
|
6053
6088
|
// src/services/product-discount.ts
|
|
6054
6089
|
var ProductDiscountService = class extends AbstractService {
|
|
6055
6090
|
repository;
|
|
@@ -6112,6 +6147,18 @@ var ProductProjectionService = class extends AbstractService {
|
|
|
6112
6147
|
}
|
|
6113
6148
|
};
|
|
6114
6149
|
|
|
6150
|
+
// src/services/product-selection.ts
|
|
6151
|
+
var ProductSelectionService = class extends AbstractService {
|
|
6152
|
+
repository;
|
|
6153
|
+
constructor(parent, repository) {
|
|
6154
|
+
super(parent);
|
|
6155
|
+
this.repository = repository;
|
|
6156
|
+
}
|
|
6157
|
+
getBasePath() {
|
|
6158
|
+
return "product-selections";
|
|
6159
|
+
}
|
|
6160
|
+
};
|
|
6161
|
+
|
|
6115
6162
|
// src/services/product-type.ts
|
|
6116
6163
|
var ProductTypeService = class extends AbstractService {
|
|
6117
6164
|
repository;
|
|
@@ -6124,6 +6171,18 @@ var ProductTypeService = class extends AbstractService {
|
|
|
6124
6171
|
}
|
|
6125
6172
|
};
|
|
6126
6173
|
|
|
6174
|
+
// src/services/product.ts
|
|
6175
|
+
var ProductService = class extends AbstractService {
|
|
6176
|
+
repository;
|
|
6177
|
+
constructor(parent, repository) {
|
|
6178
|
+
super(parent);
|
|
6179
|
+
this.repository = repository;
|
|
6180
|
+
}
|
|
6181
|
+
getBasePath() {
|
|
6182
|
+
return "products";
|
|
6183
|
+
}
|
|
6184
|
+
};
|
|
6185
|
+
|
|
6127
6186
|
// src/services/shipping-method.ts
|
|
6128
6187
|
var ShippingMethodService = class extends AbstractService {
|
|
6129
6188
|
repository;
|
|
@@ -6236,18 +6295,6 @@ var ZoneService = class extends AbstractService {
|
|
|
6236
6295
|
}
|
|
6237
6296
|
};
|
|
6238
6297
|
|
|
6239
|
-
// src/services/attribute-group.ts
|
|
6240
|
-
var AttributeGroupService = class extends AbstractService {
|
|
6241
|
-
repository;
|
|
6242
|
-
constructor(parent, repository) {
|
|
6243
|
-
super(parent);
|
|
6244
|
-
this.repository = repository;
|
|
6245
|
-
}
|
|
6246
|
-
getBasePath() {
|
|
6247
|
-
return "attribute-groups";
|
|
6248
|
-
}
|
|
6249
|
-
};
|
|
6250
|
-
|
|
6251
6298
|
// src/services/index.ts
|
|
6252
6299
|
var createServices = (router, repos) => ({
|
|
6253
6300
|
"associate-role": new AssociateRoleServices(router, repos["associate-role"]),
|
|
@@ -6292,6 +6339,10 @@ var createServices = (router, repos) => ({
|
|
|
6292
6339
|
router,
|
|
6293
6340
|
repos["product-projection"]
|
|
6294
6341
|
),
|
|
6342
|
+
"product-selection": new ProductSelectionService(
|
|
6343
|
+
router,
|
|
6344
|
+
repos["product-selection"]
|
|
6345
|
+
),
|
|
6295
6346
|
"shopping-list": new ShoppingListService(router, repos["shopping-list"]),
|
|
6296
6347
|
state: new StateService(router, repos["state"]),
|
|
6297
6348
|
store: new StoreService(router, repos["store"]),
|