@labdigital/commercetools-mock 1.8.1 → 1.9.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 +218 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +218 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/business-unit.ts +204 -3
- package/src/repositories/cart-discount.ts +26 -1
- package/src/repositories/helpers.ts +118 -21
- package/src/services/business-units.test.ts +42 -0
- package/src/services/business-units.ts +17 -0
- package/src/services/cart-discount.test.ts +18 -0
- package/src/services/index.ts +3 -1
- package/src/services/project.test.ts +52 -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, BusinessUnit, CartDraft, Cart, CartAddLineItemAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, 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, ReviewUpdateAction, Review, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, 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, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, 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, ReviewUpdateAction, Review, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, 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[];
|
|
@@ -56,7 +56,22 @@ declare class AttributeGroupRepository extends AbstractResourceRepository<'attri
|
|
|
56
56
|
|
|
57
57
|
declare class BusinessUnitRepository extends AbstractResourceRepository<'business-unit'> {
|
|
58
58
|
getTypeId(): "business-unit";
|
|
59
|
-
|
|
59
|
+
private _isCompanyDraft;
|
|
60
|
+
private _isDivisionDraft;
|
|
61
|
+
create(context: RepositoryContext, draft: BusinessUnitDraft): BusinessUnit;
|
|
62
|
+
actions: {
|
|
63
|
+
addAddress: (context: RepositoryContext, resource: Writable<BusinessUnit>, { address }: BusinessUnitAddAddressAction) => void;
|
|
64
|
+
addAssociate: (context: RepositoryContext, resource: Writable<BusinessUnit>, { associate }: BusinessUnitAddAssociateAction) => void;
|
|
65
|
+
setAssociates: (context: RepositoryContext, resource: Writable<BusinessUnit>, { associates }: BusinessUnitSetAssociatesAction) => void;
|
|
66
|
+
setContactEmail: (context: RepositoryContext, resource: Writable<BusinessUnit>, { contactEmail }: BusinessUnitSetContactEmailAction) => void;
|
|
67
|
+
setStoreMode: (context: RepositoryContext, resource: Writable<BusinessUnit>, { storeMode }: BusinessUnitSetStoreModeAction) => void;
|
|
68
|
+
changeAssociateMode: (context: RepositoryContext, resource: Writable<BusinessUnit>, { storeMode }: BusinessUnitSetStoreModeAction) => void;
|
|
69
|
+
changeName: (context: RepositoryContext, resource: Writable<BusinessUnit>, { name }: BusinessUnitChangeNameAction) => void;
|
|
70
|
+
changeAddress: (context: RepositoryContext, resource: Writable<BusinessUnit>, { address }: BusinessUnitChangeAddressAction) => void;
|
|
71
|
+
addStore: (context: RepositoryContext, resource: Writable<BusinessUnit>, { store }: BusinessUnitAddStoreAction) => void;
|
|
72
|
+
changeParentUnit: (context: RepositoryContext, resource: Writable<BusinessUnit>, { parentUnit }: BusinessUnitChangeParentUnitAction) => void;
|
|
73
|
+
changeStatus: (context: RepositoryContext, resource: Writable<BusinessUnit>, { status }: BusinessUnitChangeStatusAction) => void;
|
|
74
|
+
};
|
|
60
75
|
}
|
|
61
76
|
|
|
62
77
|
declare class CartRepository extends AbstractResourceRepository<'cart'> {
|
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, BusinessUnit, CartDraft, Cart, CartAddLineItemAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, 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, ReviewUpdateAction, Review, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, 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, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, 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, ReviewUpdateAction, Review, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, 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[];
|
|
@@ -56,7 +56,22 @@ declare class AttributeGroupRepository extends AbstractResourceRepository<'attri
|
|
|
56
56
|
|
|
57
57
|
declare class BusinessUnitRepository extends AbstractResourceRepository<'business-unit'> {
|
|
58
58
|
getTypeId(): "business-unit";
|
|
59
|
-
|
|
59
|
+
private _isCompanyDraft;
|
|
60
|
+
private _isDivisionDraft;
|
|
61
|
+
create(context: RepositoryContext, draft: BusinessUnitDraft): BusinessUnit;
|
|
62
|
+
actions: {
|
|
63
|
+
addAddress: (context: RepositoryContext, resource: Writable<BusinessUnit>, { address }: BusinessUnitAddAddressAction) => void;
|
|
64
|
+
addAssociate: (context: RepositoryContext, resource: Writable<BusinessUnit>, { associate }: BusinessUnitAddAssociateAction) => void;
|
|
65
|
+
setAssociates: (context: RepositoryContext, resource: Writable<BusinessUnit>, { associates }: BusinessUnitSetAssociatesAction) => void;
|
|
66
|
+
setContactEmail: (context: RepositoryContext, resource: Writable<BusinessUnit>, { contactEmail }: BusinessUnitSetContactEmailAction) => void;
|
|
67
|
+
setStoreMode: (context: RepositoryContext, resource: Writable<BusinessUnit>, { storeMode }: BusinessUnitSetStoreModeAction) => void;
|
|
68
|
+
changeAssociateMode: (context: RepositoryContext, resource: Writable<BusinessUnit>, { storeMode }: BusinessUnitSetStoreModeAction) => void;
|
|
69
|
+
changeName: (context: RepositoryContext, resource: Writable<BusinessUnit>, { name }: BusinessUnitChangeNameAction) => void;
|
|
70
|
+
changeAddress: (context: RepositoryContext, resource: Writable<BusinessUnit>, { address }: BusinessUnitChangeAddressAction) => void;
|
|
71
|
+
addStore: (context: RepositoryContext, resource: Writable<BusinessUnit>, { store }: BusinessUnitAddStoreAction) => void;
|
|
72
|
+
changeParentUnit: (context: RepositoryContext, resource: Writable<BusinessUnit>, { parentUnit }: BusinessUnitChangeParentUnitAction) => void;
|
|
73
|
+
changeStatus: (context: RepositoryContext, resource: Writable<BusinessUnit>, { status }: BusinessUnitChangeStatusAction) => void;
|
|
74
|
+
};
|
|
60
75
|
}
|
|
61
76
|
|
|
62
77
|
declare class CartRepository extends AbstractResourceRepository<'cart'> {
|
package/dist/index.js
CHANGED
|
@@ -1551,6 +1551,71 @@ var getRepositoryContext = (request) => ({
|
|
|
1551
1551
|
projectKey: request.params.projectKey,
|
|
1552
1552
|
storeKey: request.params.storeKey
|
|
1553
1553
|
});
|
|
1554
|
+
var createAssociate = (a, projectKey, storage) => {
|
|
1555
|
+
if (!a)
|
|
1556
|
+
return void 0;
|
|
1557
|
+
if (!a.associateRoleAssignments) {
|
|
1558
|
+
throw new Error("AssociateRoleAssignments is required");
|
|
1559
|
+
}
|
|
1560
|
+
return {
|
|
1561
|
+
customer: getReferenceFromResourceIdentifier(
|
|
1562
|
+
a.customer,
|
|
1563
|
+
projectKey,
|
|
1564
|
+
storage
|
|
1565
|
+
),
|
|
1566
|
+
associateRoleAssignments: a.associateRoleAssignments?.map(
|
|
1567
|
+
(a2) => ({
|
|
1568
|
+
associateRole: getAssociateRoleKeyReference(
|
|
1569
|
+
a2.associateRole,
|
|
1570
|
+
projectKey,
|
|
1571
|
+
storage
|
|
1572
|
+
),
|
|
1573
|
+
inheritance: a2.inheritance
|
|
1574
|
+
})
|
|
1575
|
+
),
|
|
1576
|
+
roles: a.roles
|
|
1577
|
+
};
|
|
1578
|
+
};
|
|
1579
|
+
var getAssociateRoleKeyReference = (id, projectKey, storage) => {
|
|
1580
|
+
if (id.key) {
|
|
1581
|
+
return {
|
|
1582
|
+
typeId: "associate-role",
|
|
1583
|
+
key: id.key
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
const value = getReferenceFromResourceIdentifier(
|
|
1587
|
+
id,
|
|
1588
|
+
projectKey,
|
|
1589
|
+
storage
|
|
1590
|
+
);
|
|
1591
|
+
if (!value.obj?.key) {
|
|
1592
|
+
throw new Error("No associate-role found for reference");
|
|
1593
|
+
}
|
|
1594
|
+
return {
|
|
1595
|
+
typeId: "associate-role",
|
|
1596
|
+
key: value.obj?.key
|
|
1597
|
+
};
|
|
1598
|
+
};
|
|
1599
|
+
var getBusinessUnitKeyReference = (id, projectKey, storage) => {
|
|
1600
|
+
if (id.key) {
|
|
1601
|
+
return {
|
|
1602
|
+
typeId: "business-unit",
|
|
1603
|
+
key: id.key
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
const value = getReferenceFromResourceIdentifier(
|
|
1607
|
+
id,
|
|
1608
|
+
projectKey,
|
|
1609
|
+
storage
|
|
1610
|
+
);
|
|
1611
|
+
if (!value.obj?.key) {
|
|
1612
|
+
throw new Error("No business-unit found for reference");
|
|
1613
|
+
}
|
|
1614
|
+
return {
|
|
1615
|
+
typeId: "business-unit",
|
|
1616
|
+
key: value.obj?.key
|
|
1617
|
+
};
|
|
1618
|
+
};
|
|
1554
1619
|
|
|
1555
1620
|
// src/services/project.ts
|
|
1556
1621
|
var ProjectService = class {
|
|
@@ -1810,9 +1875,128 @@ var BusinessUnitRepository = class extends AbstractResourceRepository {
|
|
|
1810
1875
|
getTypeId() {
|
|
1811
1876
|
return "business-unit";
|
|
1812
1877
|
}
|
|
1878
|
+
_isCompanyDraft(draft) {
|
|
1879
|
+
return draft.unitType === "Company";
|
|
1880
|
+
}
|
|
1881
|
+
_isDivisionDraft(draft) {
|
|
1882
|
+
return draft.unitType === "Division";
|
|
1883
|
+
}
|
|
1813
1884
|
create(context, draft) {
|
|
1814
|
-
|
|
1885
|
+
const resource = {
|
|
1886
|
+
...getBaseResourceProperties(),
|
|
1887
|
+
key: draft.key,
|
|
1888
|
+
status: draft.status,
|
|
1889
|
+
stores: draft.stores?.map(
|
|
1890
|
+
(s) => getStoreKeyReference(s, context.projectKey, this._storage)
|
|
1891
|
+
),
|
|
1892
|
+
storeMode: draft.storeMode,
|
|
1893
|
+
name: draft.name,
|
|
1894
|
+
contactEmail: draft.contactEmail,
|
|
1895
|
+
addresses: draft.addresses?.map(
|
|
1896
|
+
(a) => createAddress(a, context.projectKey, this._storage)
|
|
1897
|
+
),
|
|
1898
|
+
custom: createCustomFields(
|
|
1899
|
+
draft.custom,
|
|
1900
|
+
context.projectKey,
|
|
1901
|
+
this._storage
|
|
1902
|
+
),
|
|
1903
|
+
shippingAddressIds: draft.shippingAddresses,
|
|
1904
|
+
defaultShippingAddressId: draft.defaultShippingAddress,
|
|
1905
|
+
billingAddressIds: draft.billingAddresses,
|
|
1906
|
+
associateMode: draft.associateMode,
|
|
1907
|
+
associates: draft.associates?.map(
|
|
1908
|
+
(a) => createAssociate(a, context.projectKey, this._storage)
|
|
1909
|
+
)
|
|
1910
|
+
};
|
|
1911
|
+
if (this._isDivisionDraft(draft)) {
|
|
1912
|
+
const division = {
|
|
1913
|
+
...resource,
|
|
1914
|
+
parentUnit: getBusinessUnitKeyReference(
|
|
1915
|
+
draft.parentUnit,
|
|
1916
|
+
context.projectKey,
|
|
1917
|
+
this._storage
|
|
1918
|
+
)
|
|
1919
|
+
};
|
|
1920
|
+
this.saveNew(context, division);
|
|
1921
|
+
return division;
|
|
1922
|
+
} else if (this._isCompanyDraft(draft)) {
|
|
1923
|
+
const company = resource;
|
|
1924
|
+
this.saveNew(context, company);
|
|
1925
|
+
return company;
|
|
1926
|
+
}
|
|
1927
|
+
throw new Error("Invalid business unit type");
|
|
1815
1928
|
}
|
|
1929
|
+
actions = {
|
|
1930
|
+
addAddress: (context, resource, { address }) => {
|
|
1931
|
+
const newAddress = createAddress(
|
|
1932
|
+
address,
|
|
1933
|
+
context.projectKey,
|
|
1934
|
+
this._storage
|
|
1935
|
+
);
|
|
1936
|
+
if (newAddress) {
|
|
1937
|
+
resource.addresses.push(newAddress);
|
|
1938
|
+
}
|
|
1939
|
+
},
|
|
1940
|
+
addAssociate: (context, resource, { associate }) => {
|
|
1941
|
+
const newAssociate = createAssociate(
|
|
1942
|
+
associate,
|
|
1943
|
+
context.projectKey,
|
|
1944
|
+
this._storage
|
|
1945
|
+
);
|
|
1946
|
+
if (newAssociate) {
|
|
1947
|
+
resource.associates.push(newAssociate);
|
|
1948
|
+
}
|
|
1949
|
+
},
|
|
1950
|
+
setAssociates: (context, resource, { associates }) => {
|
|
1951
|
+
const newAssociates = associates.map((a) => createAssociate(a, context.projectKey, this._storage)).filter((a) => a !== void 0);
|
|
1952
|
+
resource.associates = newAssociates || void 0;
|
|
1953
|
+
},
|
|
1954
|
+
setContactEmail: (context, resource, { contactEmail }) => {
|
|
1955
|
+
resource.contactEmail = contactEmail;
|
|
1956
|
+
},
|
|
1957
|
+
setStoreMode: (context, resource, { storeMode }) => {
|
|
1958
|
+
resource.storeMode = storeMode;
|
|
1959
|
+
},
|
|
1960
|
+
changeAssociateMode: (context, resource, { storeMode }) => {
|
|
1961
|
+
resource.associateMode = storeMode;
|
|
1962
|
+
},
|
|
1963
|
+
changeName: (context, resource, { name }) => {
|
|
1964
|
+
resource.name = name;
|
|
1965
|
+
},
|
|
1966
|
+
changeAddress: (context, resource, { address }) => {
|
|
1967
|
+
const newAddress = createAddress(
|
|
1968
|
+
address,
|
|
1969
|
+
context.projectKey,
|
|
1970
|
+
this._storage
|
|
1971
|
+
);
|
|
1972
|
+
if (newAddress) {
|
|
1973
|
+
resource.addresses.push(newAddress);
|
|
1974
|
+
}
|
|
1975
|
+
},
|
|
1976
|
+
addStore: (context, resource, { store }) => {
|
|
1977
|
+
const newStore = getStoreKeyReference(
|
|
1978
|
+
store,
|
|
1979
|
+
context.projectKey,
|
|
1980
|
+
this._storage
|
|
1981
|
+
);
|
|
1982
|
+
if (newStore) {
|
|
1983
|
+
if (!resource.stores) {
|
|
1984
|
+
resource.stores = [];
|
|
1985
|
+
}
|
|
1986
|
+
resource.stores.push(newStore);
|
|
1987
|
+
}
|
|
1988
|
+
},
|
|
1989
|
+
changeParentUnit: (context, resource, { parentUnit }) => {
|
|
1990
|
+
resource.parentUnit = getBusinessUnitKeyReference(
|
|
1991
|
+
parentUnit,
|
|
1992
|
+
context.projectKey,
|
|
1993
|
+
this._storage
|
|
1994
|
+
);
|
|
1995
|
+
},
|
|
1996
|
+
changeStatus: (context, resource, { status }) => {
|
|
1997
|
+
resource.status = status;
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
1816
2000
|
};
|
|
1817
2001
|
|
|
1818
2002
|
// src/repositories/cart.ts
|
|
@@ -2300,6 +2484,26 @@ var CartDiscountRepository = class extends AbstractResourceRepository {
|
|
|
2300
2484
|
} else {
|
|
2301
2485
|
resource.custom.fields[name] = value;
|
|
2302
2486
|
}
|
|
2487
|
+
},
|
|
2488
|
+
setCustomType: (context, resource, { type, fields }) => {
|
|
2489
|
+
if (!type) {
|
|
2490
|
+
resource.custom = void 0;
|
|
2491
|
+
} else {
|
|
2492
|
+
const resolvedType = this._storage.getByResourceIdentifier(
|
|
2493
|
+
context.projectKey,
|
|
2494
|
+
type
|
|
2495
|
+
);
|
|
2496
|
+
if (!resolvedType) {
|
|
2497
|
+
throw new Error(`Type ${type} not found`);
|
|
2498
|
+
}
|
|
2499
|
+
resource.custom = {
|
|
2500
|
+
type: {
|
|
2501
|
+
typeId: "type",
|
|
2502
|
+
id: resolvedType.id
|
|
2503
|
+
},
|
|
2504
|
+
fields: fields || {}
|
|
2505
|
+
};
|
|
2506
|
+
}
|
|
2303
2507
|
}
|
|
2304
2508
|
};
|
|
2305
2509
|
};
|
|
@@ -5440,6 +5644,18 @@ var AssociateRoleServices = class extends AbstractService {
|
|
|
5440
5644
|
}
|
|
5441
5645
|
};
|
|
5442
5646
|
|
|
5647
|
+
// src/services/business-units.ts
|
|
5648
|
+
var BusinessUnitServices = class extends AbstractService {
|
|
5649
|
+
repository;
|
|
5650
|
+
constructor(parent, repository) {
|
|
5651
|
+
super(parent);
|
|
5652
|
+
this.repository = repository;
|
|
5653
|
+
}
|
|
5654
|
+
getBasePath() {
|
|
5655
|
+
return "business-units";
|
|
5656
|
+
}
|
|
5657
|
+
};
|
|
5658
|
+
|
|
5443
5659
|
// src/services/cart.ts
|
|
5444
5660
|
var CartService = class extends AbstractService {
|
|
5445
5661
|
repository;
|
|
@@ -6030,6 +6246,7 @@ var AttributeGroupService = class extends AbstractService {
|
|
|
6030
6246
|
// src/services/index.ts
|
|
6031
6247
|
var createServices = (router, repos) => ({
|
|
6032
6248
|
"associate-role": new AssociateRoleServices(router, repos["associate-role"]),
|
|
6249
|
+
"business-unit": new BusinessUnitServices(router, repos["business-unit"]),
|
|
6033
6250
|
category: new CategoryServices(router, repos["category"]),
|
|
6034
6251
|
cart: new CartService(router, repos["cart"], repos["order"]),
|
|
6035
6252
|
"cart-discount": new CartDiscountService(router, repos["cart-discount"]),
|