@labdigital/commercetools-mock 2.2.0 → 2.4.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 +366 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +366 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/category.ts +26 -0
- package/src/repositories/product.ts +484 -20
- package/src/services/category.test.ts +99 -0
- package/src/services/product.test.ts +898 -7
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, 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';
|
|
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, 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
4
|
|
|
5
5
|
type GetParams$1 = {
|
|
6
6
|
expand?: string[];
|
|
@@ -111,6 +111,8 @@ declare class CategoryRepository extends AbstractResourceRepository<'category'>
|
|
|
111
111
|
actions: {
|
|
112
112
|
changeAssetName: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, name }: CategoryChangeAssetNameAction) => void;
|
|
113
113
|
changeSlug: (context: RepositoryContext, resource: Writable<Category>, { slug }: CategoryChangeSlugAction) => void;
|
|
114
|
+
changeName: (context: RepositoryContext, resource: Writable<Category>, { name }: CategoryChangeNameAction) => void;
|
|
115
|
+
changeParent: (context: RepositoryContext, resource: Writable<Category>, { parent }: CategoryChangeParentAction) => void;
|
|
114
116
|
setKey: (context: RepositoryContext, resource: Writable<Category>, { key }: CategorySetKeyAction) => void;
|
|
115
117
|
setAssetDescription: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, description }: CategorySetAssetDescriptionAction) => void;
|
|
116
118
|
setAssetSources: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, sources }: CategorySetAssetSourcesAction) => void;
|
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, 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';
|
|
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, 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
4
|
|
|
5
5
|
type GetParams$1 = {
|
|
6
6
|
expand?: string[];
|
|
@@ -111,6 +111,8 @@ declare class CategoryRepository extends AbstractResourceRepository<'category'>
|
|
|
111
111
|
actions: {
|
|
112
112
|
changeAssetName: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, name }: CategoryChangeAssetNameAction) => void;
|
|
113
113
|
changeSlug: (context: RepositoryContext, resource: Writable<Category>, { slug }: CategoryChangeSlugAction) => void;
|
|
114
|
+
changeName: (context: RepositoryContext, resource: Writable<Category>, { name }: CategoryChangeNameAction) => void;
|
|
115
|
+
changeParent: (context: RepositoryContext, resource: Writable<Category>, { parent }: CategoryChangeParentAction) => void;
|
|
114
116
|
setKey: (context: RepositoryContext, resource: Writable<Category>, { key }: CategorySetKeyAction) => void;
|
|
115
117
|
setAssetDescription: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, description }: CategorySetAssetDescriptionAction) => void;
|
|
116
118
|
setAssetSources: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, sources }: CategorySetAssetSourcesAction) => void;
|
package/dist/index.js
CHANGED
|
@@ -2723,6 +2723,22 @@ var CategoryRepository = class extends AbstractResourceRepository {
|
|
|
2723
2723
|
changeSlug: (context, resource, { slug }) => {
|
|
2724
2724
|
resource.slug = slug;
|
|
2725
2725
|
},
|
|
2726
|
+
changeName: (context, resource, { name }) => {
|
|
2727
|
+
resource.name = name;
|
|
2728
|
+
},
|
|
2729
|
+
changeParent: (context, resource, { parent }) => {
|
|
2730
|
+
const category = this._storage.getByResourceIdentifier(
|
|
2731
|
+
context.projectKey,
|
|
2732
|
+
parent
|
|
2733
|
+
);
|
|
2734
|
+
if (!category) {
|
|
2735
|
+
throw new Error("No category found for reference");
|
|
2736
|
+
}
|
|
2737
|
+
resource.parent = {
|
|
2738
|
+
typeId: "category",
|
|
2739
|
+
id: category.id
|
|
2740
|
+
};
|
|
2741
|
+
},
|
|
2726
2742
|
setKey: (context, resource, { key }) => {
|
|
2727
2743
|
resource.key = key;
|
|
2728
2744
|
},
|
|
@@ -3770,20 +3786,63 @@ var ProductRepository = class extends AbstractResourceRepository {
|
|
|
3770
3786
|
id: draft.productType.id || ""
|
|
3771
3787
|
};
|
|
3772
3788
|
}
|
|
3789
|
+
const categoryReferences = [];
|
|
3790
|
+
draft.categories?.forEach((category) => {
|
|
3791
|
+
if (category) {
|
|
3792
|
+
categoryReferences.push(
|
|
3793
|
+
getReferenceFromResourceIdentifier(
|
|
3794
|
+
category,
|
|
3795
|
+
context.projectKey,
|
|
3796
|
+
this._storage
|
|
3797
|
+
)
|
|
3798
|
+
);
|
|
3799
|
+
} else {
|
|
3800
|
+
throw new CommercetoolsError(
|
|
3801
|
+
{
|
|
3802
|
+
code: "InvalidJsonInput",
|
|
3803
|
+
message: "Request body does not contain valid JSON.",
|
|
3804
|
+
detailedErrorMessage: "categories: JSON object expected."
|
|
3805
|
+
},
|
|
3806
|
+
400
|
|
3807
|
+
);
|
|
3808
|
+
}
|
|
3809
|
+
});
|
|
3810
|
+
let taxCategoryReference = void 0;
|
|
3811
|
+
if (draft.taxCategory) {
|
|
3812
|
+
taxCategoryReference = getReferenceFromResourceIdentifier(
|
|
3813
|
+
draft.taxCategory,
|
|
3814
|
+
context.projectKey,
|
|
3815
|
+
this._storage
|
|
3816
|
+
);
|
|
3817
|
+
}
|
|
3818
|
+
let productStateReference = void 0;
|
|
3819
|
+
if (draft.state) {
|
|
3820
|
+
productStateReference = getReferenceFromResourceIdentifier(
|
|
3821
|
+
draft.state,
|
|
3822
|
+
context.projectKey,
|
|
3823
|
+
this._storage
|
|
3824
|
+
);
|
|
3825
|
+
}
|
|
3773
3826
|
const productData = {
|
|
3774
3827
|
name: draft.name,
|
|
3775
3828
|
slug: draft.slug,
|
|
3776
|
-
|
|
3829
|
+
description: draft.description,
|
|
3830
|
+
categories: categoryReferences,
|
|
3777
3831
|
masterVariant: variantFromDraft(1, draft.masterVariant),
|
|
3778
3832
|
variants: draft.variants?.map(
|
|
3779
3833
|
(variant, index) => variantFromDraft(index + 2, variant)
|
|
3780
3834
|
) ?? [],
|
|
3835
|
+
metaTitle: draft.metaTitle,
|
|
3836
|
+
metaDescription: draft.metaDescription,
|
|
3837
|
+
metaKeywords: draft.metaKeywords,
|
|
3781
3838
|
searchKeywords: draft.searchKeywords ?? {}
|
|
3782
3839
|
};
|
|
3783
3840
|
const resource = {
|
|
3784
3841
|
...getBaseResourceProperties(),
|
|
3785
3842
|
key: draft.key,
|
|
3786
3843
|
productType,
|
|
3844
|
+
taxCategory: taxCategoryReference,
|
|
3845
|
+
state: productStateReference,
|
|
3787
3846
|
masterData: {
|
|
3788
3847
|
current: productData,
|
|
3789
3848
|
staged: productData,
|
|
@@ -3844,6 +3903,47 @@ var ProductRepository = class extends AbstractResourceRepository {
|
|
|
3844
3903
|
checkForStagedChanges(resource);
|
|
3845
3904
|
return resource;
|
|
3846
3905
|
},
|
|
3906
|
+
setAttributeInAllVariants: (context, resource, { name, value, staged }) => {
|
|
3907
|
+
const setAttrInAllVariants = (data) => {
|
|
3908
|
+
if (!data.masterVariant.attributes) {
|
|
3909
|
+
data.masterVariant.attributes = [];
|
|
3910
|
+
}
|
|
3911
|
+
const existingAttr = data.masterVariant.attributes?.find(
|
|
3912
|
+
(attr) => attr.name === name
|
|
3913
|
+
);
|
|
3914
|
+
if (existingAttr) {
|
|
3915
|
+
existingAttr.value = value;
|
|
3916
|
+
} else {
|
|
3917
|
+
data.masterVariant.attributes.push({
|
|
3918
|
+
name,
|
|
3919
|
+
value
|
|
3920
|
+
});
|
|
3921
|
+
}
|
|
3922
|
+
data.variants.forEach((variant) => {
|
|
3923
|
+
if (!variant.attributes) {
|
|
3924
|
+
variant.attributes = [];
|
|
3925
|
+
}
|
|
3926
|
+
const existingAttr2 = variant.attributes.find(
|
|
3927
|
+
(attr) => attr.name === name
|
|
3928
|
+
);
|
|
3929
|
+
if (existingAttr2) {
|
|
3930
|
+
existingAttr2.value = value;
|
|
3931
|
+
} else {
|
|
3932
|
+
variant.attributes.push({
|
|
3933
|
+
name,
|
|
3934
|
+
value
|
|
3935
|
+
});
|
|
3936
|
+
}
|
|
3937
|
+
});
|
|
3938
|
+
};
|
|
3939
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
3940
|
+
setAttrInAllVariants(resource.masterData.staged);
|
|
3941
|
+
if (!onlyStaged) {
|
|
3942
|
+
setAttrInAllVariants(resource.masterData.current);
|
|
3943
|
+
}
|
|
3944
|
+
checkForStagedChanges(resource);
|
|
3945
|
+
return resource;
|
|
3946
|
+
},
|
|
3847
3947
|
setDescription: (context, resource, { description, staged }) => {
|
|
3848
3948
|
const onlyStaged = staged !== void 0 ? staged : true;
|
|
3849
3949
|
resource.masterData.staged.description = description;
|
|
@@ -3975,7 +4075,7 @@ var ProductRepository = class extends AbstractResourceRepository {
|
|
|
3975
4075
|
return resource;
|
|
3976
4076
|
},
|
|
3977
4077
|
addPrice: (context, resource, { variantId, sku, price, staged }) => {
|
|
3978
|
-
const addVariantPrice = (data) => {
|
|
4078
|
+
const addVariantPrice = (data, priceToAdd2) => {
|
|
3979
4079
|
const { variant, isMasterVariant, variantIndex } = getVariant(
|
|
3980
4080
|
data,
|
|
3981
4081
|
variantId,
|
|
@@ -3987,9 +4087,9 @@ var ProductRepository = class extends AbstractResourceRepository {
|
|
|
3987
4087
|
);
|
|
3988
4088
|
}
|
|
3989
4089
|
if (variant.prices === void 0) {
|
|
3990
|
-
variant.prices = [
|
|
4090
|
+
variant.prices = [priceToAdd2];
|
|
3991
4091
|
} else {
|
|
3992
|
-
variant.prices.push(
|
|
4092
|
+
variant.prices.push(priceToAdd2);
|
|
3993
4093
|
}
|
|
3994
4094
|
if (isMasterVariant) {
|
|
3995
4095
|
data.masterVariant = variant;
|
|
@@ -3997,10 +4097,11 @@ var ProductRepository = class extends AbstractResourceRepository {
|
|
|
3997
4097
|
data.variants[variantIndex] = variant;
|
|
3998
4098
|
}
|
|
3999
4099
|
};
|
|
4100
|
+
const priceToAdd = priceFromDraft(price);
|
|
4000
4101
|
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4001
|
-
addVariantPrice(resource.masterData.staged);
|
|
4102
|
+
addVariantPrice(resource.masterData.staged, priceToAdd);
|
|
4002
4103
|
if (!onlyStaged) {
|
|
4003
|
-
addVariantPrice(resource.masterData.current);
|
|
4104
|
+
addVariantPrice(resource.masterData.current, priceToAdd);
|
|
4004
4105
|
}
|
|
4005
4106
|
checkForStagedChanges(resource);
|
|
4006
4107
|
return resource;
|
|
@@ -4081,21 +4182,270 @@ var ProductRepository = class extends AbstractResourceRepository {
|
|
|
4081
4182
|
}
|
|
4082
4183
|
checkForStagedChanges(resource);
|
|
4083
4184
|
return resource;
|
|
4185
|
+
},
|
|
4186
|
+
changeName: (context, resource, { name, staged }) => {
|
|
4187
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4188
|
+
resource.masterData.staged.name = name;
|
|
4189
|
+
if (!onlyStaged) {
|
|
4190
|
+
resource.masterData.current.name = name;
|
|
4191
|
+
}
|
|
4192
|
+
checkForStagedChanges(resource);
|
|
4193
|
+
return resource;
|
|
4194
|
+
},
|
|
4195
|
+
changeSlug: (context, resource, { slug, staged }) => {
|
|
4196
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4197
|
+
resource.masterData.staged.slug = slug;
|
|
4198
|
+
if (!onlyStaged) {
|
|
4199
|
+
resource.masterData.current.slug = slug;
|
|
4200
|
+
}
|
|
4201
|
+
checkForStagedChanges(resource);
|
|
4202
|
+
return resource;
|
|
4203
|
+
},
|
|
4204
|
+
setMetaTitle: (context, resource, { metaTitle, staged }) => {
|
|
4205
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4206
|
+
resource.masterData.staged.metaTitle = metaTitle;
|
|
4207
|
+
if (!onlyStaged) {
|
|
4208
|
+
resource.masterData.current.metaTitle = metaTitle;
|
|
4209
|
+
}
|
|
4210
|
+
checkForStagedChanges(resource);
|
|
4211
|
+
return resource;
|
|
4212
|
+
},
|
|
4213
|
+
setMetaDescription: (context, resource, { metaDescription, staged }) => {
|
|
4214
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4215
|
+
resource.masterData.staged.metaDescription = metaDescription;
|
|
4216
|
+
if (!onlyStaged) {
|
|
4217
|
+
resource.masterData.current.metaDescription = metaDescription;
|
|
4218
|
+
}
|
|
4219
|
+
checkForStagedChanges(resource);
|
|
4220
|
+
return resource;
|
|
4221
|
+
},
|
|
4222
|
+
setMetaKeywords: (context, resource, { metaKeywords, staged }) => {
|
|
4223
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4224
|
+
resource.masterData.staged.metaKeywords = metaKeywords;
|
|
4225
|
+
if (!onlyStaged) {
|
|
4226
|
+
resource.masterData.current.metaKeywords = metaKeywords;
|
|
4227
|
+
}
|
|
4228
|
+
checkForStagedChanges(resource);
|
|
4229
|
+
return resource;
|
|
4230
|
+
},
|
|
4231
|
+
addVariant: (context, resource, {
|
|
4232
|
+
sku,
|
|
4233
|
+
key,
|
|
4234
|
+
prices,
|
|
4235
|
+
images,
|
|
4236
|
+
attributes,
|
|
4237
|
+
staged,
|
|
4238
|
+
assets
|
|
4239
|
+
}) => {
|
|
4240
|
+
const variantDraft = {
|
|
4241
|
+
sku,
|
|
4242
|
+
key,
|
|
4243
|
+
prices,
|
|
4244
|
+
images,
|
|
4245
|
+
attributes,
|
|
4246
|
+
assets
|
|
4247
|
+
};
|
|
4248
|
+
const dataStaged = resource.masterData.staged;
|
|
4249
|
+
const allVariants = [
|
|
4250
|
+
dataStaged.masterVariant,
|
|
4251
|
+
...dataStaged.variants ?? []
|
|
4252
|
+
];
|
|
4253
|
+
const maxId = allVariants.reduce(
|
|
4254
|
+
(max, element) => element.id > max ? element.id : max,
|
|
4255
|
+
0
|
|
4256
|
+
);
|
|
4257
|
+
const variant = variantFromDraft(maxId + 1, variantDraft);
|
|
4258
|
+
dataStaged.variants.push(variant);
|
|
4259
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4260
|
+
if (!onlyStaged) {
|
|
4261
|
+
resource.masterData.current.variants.push(variant);
|
|
4262
|
+
}
|
|
4263
|
+
checkForStagedChanges(resource);
|
|
4264
|
+
return resource;
|
|
4265
|
+
},
|
|
4266
|
+
removeVariant: (context, resource, { id, sku, staged }) => {
|
|
4267
|
+
const removeVariant = (data) => {
|
|
4268
|
+
const { variant, isMasterVariant, variantIndex } = getVariant(
|
|
4269
|
+
data,
|
|
4270
|
+
id,
|
|
4271
|
+
sku
|
|
4272
|
+
);
|
|
4273
|
+
if (!variant) {
|
|
4274
|
+
throw new Error(
|
|
4275
|
+
`Variant with id ${id} or sku ${sku} not found on product ${resource.id}`
|
|
4276
|
+
);
|
|
4277
|
+
}
|
|
4278
|
+
if (isMasterVariant) {
|
|
4279
|
+
throw new Error(
|
|
4280
|
+
`Can not remove the variant [ID:${id}] for [Product:${resource.id}] since it's the master variant`
|
|
4281
|
+
);
|
|
4282
|
+
}
|
|
4283
|
+
data.variants.splice(variantIndex, 1);
|
|
4284
|
+
};
|
|
4285
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4286
|
+
removeVariant(resource.masterData.staged);
|
|
4287
|
+
if (!onlyStaged) {
|
|
4288
|
+
removeVariant(resource.masterData.current);
|
|
4289
|
+
}
|
|
4290
|
+
checkForStagedChanges(resource);
|
|
4291
|
+
return resource;
|
|
4292
|
+
},
|
|
4293
|
+
changeMasterVariant: (context, resource, { variantId, sku, staged }) => {
|
|
4294
|
+
const setMaster = (data) => {
|
|
4295
|
+
const { variant, isMasterVariant, variantIndex } = getVariant(
|
|
4296
|
+
data,
|
|
4297
|
+
variantId,
|
|
4298
|
+
sku
|
|
4299
|
+
);
|
|
4300
|
+
if (!variant) {
|
|
4301
|
+
throw new Error(
|
|
4302
|
+
`Variant with id ${variantId} or sku ${sku} not found on product ${resource.id}`
|
|
4303
|
+
);
|
|
4304
|
+
}
|
|
4305
|
+
if (!isMasterVariant) {
|
|
4306
|
+
const masterVariantPrev = data.masterVariant;
|
|
4307
|
+
data.masterVariant = variant;
|
|
4308
|
+
data.variants.splice(variantIndex, 1);
|
|
4309
|
+
data.variants.push(masterVariantPrev);
|
|
4310
|
+
}
|
|
4311
|
+
};
|
|
4312
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4313
|
+
setMaster(resource.masterData.staged);
|
|
4314
|
+
if (!onlyStaged) {
|
|
4315
|
+
setMaster(resource.masterData.current);
|
|
4316
|
+
}
|
|
4317
|
+
checkForStagedChanges(resource);
|
|
4318
|
+
return resource;
|
|
4319
|
+
},
|
|
4320
|
+
setTaxCategory: (context, resource, { taxCategory }) => {
|
|
4321
|
+
let taxCategoryReference = void 0;
|
|
4322
|
+
if (taxCategory) {
|
|
4323
|
+
taxCategoryReference = getReferenceFromResourceIdentifier(
|
|
4324
|
+
taxCategory,
|
|
4325
|
+
context.projectKey,
|
|
4326
|
+
this._storage
|
|
4327
|
+
);
|
|
4328
|
+
} else {
|
|
4329
|
+
throw new CommercetoolsError(
|
|
4330
|
+
{
|
|
4331
|
+
code: "InvalidJsonInput",
|
|
4332
|
+
message: "Request body does not contain valid JSON.",
|
|
4333
|
+
detailedErrorMessage: "actions -> taxCategory: Missing required value"
|
|
4334
|
+
},
|
|
4335
|
+
400
|
|
4336
|
+
);
|
|
4337
|
+
}
|
|
4338
|
+
resource.taxCategory = taxCategoryReference;
|
|
4339
|
+
return resource;
|
|
4340
|
+
},
|
|
4341
|
+
addToCategory: (context, resource, { category, staged, orderHint }) => {
|
|
4342
|
+
const addCategory = (data) => {
|
|
4343
|
+
if (category) {
|
|
4344
|
+
data.categories.push(
|
|
4345
|
+
getReferenceFromResourceIdentifier(
|
|
4346
|
+
category,
|
|
4347
|
+
context.projectKey,
|
|
4348
|
+
this._storage
|
|
4349
|
+
)
|
|
4350
|
+
);
|
|
4351
|
+
} else {
|
|
4352
|
+
throw new CommercetoolsError(
|
|
4353
|
+
{
|
|
4354
|
+
code: "InvalidJsonInput",
|
|
4355
|
+
message: "Request body does not contain valid JSON.",
|
|
4356
|
+
detailedErrorMessage: "actions -> category: Missing required value"
|
|
4357
|
+
},
|
|
4358
|
+
400
|
|
4359
|
+
);
|
|
4360
|
+
}
|
|
4361
|
+
};
|
|
4362
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4363
|
+
addCategory(resource.masterData.staged);
|
|
4364
|
+
if (!onlyStaged) {
|
|
4365
|
+
addCategory(resource.masterData.current);
|
|
4366
|
+
}
|
|
4367
|
+
checkForStagedChanges(resource);
|
|
4368
|
+
return resource;
|
|
4369
|
+
},
|
|
4370
|
+
removeFromCategory: (context, resource, { category, staged }) => {
|
|
4371
|
+
const removeCategory = (data) => {
|
|
4372
|
+
if (category) {
|
|
4373
|
+
const resolvedCategory = getReferenceFromResourceIdentifier(
|
|
4374
|
+
category,
|
|
4375
|
+
context.projectKey,
|
|
4376
|
+
this._storage
|
|
4377
|
+
);
|
|
4378
|
+
const foundCategory = data.categories.find(
|
|
4379
|
+
(productCategory) => {
|
|
4380
|
+
if (productCategory.id == resolvedCategory.id) {
|
|
4381
|
+
return productCategory;
|
|
4382
|
+
}
|
|
4383
|
+
return false;
|
|
4384
|
+
}
|
|
4385
|
+
);
|
|
4386
|
+
if (!foundCategory) {
|
|
4387
|
+
throw new CommercetoolsError(
|
|
4388
|
+
{
|
|
4389
|
+
code: "InvalidOperation",
|
|
4390
|
+
message: `Cannot remove from category '${resolvedCategory.id}' because product '${resource.masterData.current.name}' is not in that category.`
|
|
4391
|
+
},
|
|
4392
|
+
400
|
|
4393
|
+
);
|
|
4394
|
+
}
|
|
4395
|
+
data.categories = data.categories.filter(
|
|
4396
|
+
(productCategory) => {
|
|
4397
|
+
if (productCategory.id == resolvedCategory.id) {
|
|
4398
|
+
return false;
|
|
4399
|
+
}
|
|
4400
|
+
return true;
|
|
4401
|
+
}
|
|
4402
|
+
);
|
|
4403
|
+
} else {
|
|
4404
|
+
throw new CommercetoolsError(
|
|
4405
|
+
{
|
|
4406
|
+
code: "InvalidJsonInput",
|
|
4407
|
+
message: "Request body does not contain valid JSON.",
|
|
4408
|
+
detailedErrorMessage: "actions -> category: Missing required value"
|
|
4409
|
+
},
|
|
4410
|
+
400
|
|
4411
|
+
);
|
|
4412
|
+
}
|
|
4413
|
+
};
|
|
4414
|
+
const onlyStaged = staged !== void 0 ? staged : true;
|
|
4415
|
+
removeCategory(resource.masterData.staged);
|
|
4416
|
+
if (!onlyStaged) {
|
|
4417
|
+
removeCategory(resource.masterData.current);
|
|
4418
|
+
}
|
|
4419
|
+
checkForStagedChanges(resource);
|
|
4420
|
+
return resource;
|
|
4421
|
+
},
|
|
4422
|
+
transitionState: (context, resource, { state, force }) => {
|
|
4423
|
+
let productStateReference = void 0;
|
|
4424
|
+
if (state) {
|
|
4425
|
+
productStateReference = getReferenceFromResourceIdentifier(
|
|
4426
|
+
state,
|
|
4427
|
+
context.projectKey,
|
|
4428
|
+
this._storage
|
|
4429
|
+
);
|
|
4430
|
+
resource.state = productStateReference;
|
|
4431
|
+
} else {
|
|
4432
|
+
throw new CommercetoolsError(
|
|
4433
|
+
{
|
|
4434
|
+
code: "InvalidJsonInput",
|
|
4435
|
+
message: "Request body does not contain valid JSON.",
|
|
4436
|
+
detailedErrorMessage: "actions -> state: Missing required value"
|
|
4437
|
+
},
|
|
4438
|
+
400
|
|
4439
|
+
);
|
|
4440
|
+
}
|
|
4441
|
+
return resource;
|
|
4084
4442
|
}
|
|
4085
|
-
// 'changeName': () => {},
|
|
4086
|
-
// 'changeSlug': () => {},
|
|
4087
|
-
// 'addVariant': () => {},
|
|
4088
|
-
// 'removeVariant': () => {},
|
|
4089
|
-
// 'changeMasterVariant': () => {},
|
|
4090
4443
|
// 'setPrices': () => {},
|
|
4091
4444
|
// 'setProductPriceCustomType': () => {},
|
|
4092
4445
|
// 'setProductPriceCustomField': () => {},
|
|
4093
4446
|
// 'setDiscountedPrice': () => {},
|
|
4094
4447
|
// 'setAttributeInAllVariants': () => {},
|
|
4095
|
-
// 'addToCategory': () => {},
|
|
4096
4448
|
// 'setCategoryOrderHint': () => {},
|
|
4097
|
-
// 'removeFromCategory': () => {},
|
|
4098
|
-
// 'setTaxCategory': () => {},
|
|
4099
4449
|
// 'setSku': () => {},
|
|
4100
4450
|
// 'setProductVariantKey': () => {},
|
|
4101
4451
|
// 'setImageLabel': () => {},
|
|
@@ -4110,12 +4460,8 @@ var ProductRepository = class extends AbstractResourceRepository {
|
|
|
4110
4460
|
// 'setAssetCustomType': () => {},
|
|
4111
4461
|
// 'setAssetCustomField': () => {},
|
|
4112
4462
|
// 'setSearchKeywords': () => {},
|
|
4113
|
-
// 'setMetaTitle': () => {},
|
|
4114
|
-
// 'setMetaDescription': () => {},
|
|
4115
|
-
// 'setMetaKeywords': () => {},
|
|
4116
4463
|
// 'revertStagedChanges': () => {},
|
|
4117
4464
|
// 'revertStagedVariantChanges': () => {},
|
|
4118
|
-
// 'transitionState': () => {},
|
|
4119
4465
|
};
|
|
4120
4466
|
};
|
|
4121
4467
|
var checkForStagedChanges = (product) => {
|
|
@@ -4149,6 +4495,7 @@ var getVariant = (productData, variantId, sku) => {
|
|
|
4149
4495
|
var variantFromDraft = (variantId, variant) => ({
|
|
4150
4496
|
id: variantId,
|
|
4151
4497
|
sku: variant?.sku,
|
|
4498
|
+
key: variant?.key,
|
|
4152
4499
|
attributes: variant?.attributes ?? [],
|
|
4153
4500
|
prices: variant?.prices?.map(priceFromDraft),
|
|
4154
4501
|
assets: [],
|
|
@@ -4156,6 +4503,7 @@ var variantFromDraft = (variantId, variant) => ({
|
|
|
4156
4503
|
});
|
|
4157
4504
|
var priceFromDraft = (draft) => ({
|
|
4158
4505
|
id: uuidv46(),
|
|
4506
|
+
key: draft.key,
|
|
4159
4507
|
country: draft.country,
|
|
4160
4508
|
value: createTypedMoney(draft.value)
|
|
4161
4509
|
});
|