@labdigital/commercetools-mock 1.4.0 → 1.6.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/README.md +5 -4
- package/dist/index.cjs +116 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -7
- package/dist/index.d.ts +30 -7
- package/dist/index.js +116 -18
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/constants.ts +2 -2
- package/src/ctMock.ts +176 -176
- package/src/exceptions.ts +10 -10
- package/src/helpers.ts +26 -26
- package/src/index.test.ts +173 -173
- package/src/index.ts +3 -3
- package/src/lib/expandParser.ts +19 -19
- package/src/lib/haversine.test.ts +13 -13
- package/src/lib/haversine.ts +14 -14
- package/src/lib/masking.ts +15 -15
- package/src/lib/parser.ts +2 -2
- package/src/lib/predicateParser.test.ts +204 -204
- package/src/lib/predicateParser.ts +398 -398
- package/src/lib/projectionSearchFilter.test.ts +168 -168
- package/src/lib/projectionSearchFilter.ts +272 -269
- package/src/lib/proxy.ts +8 -8
- package/src/oauth/errors.ts +4 -4
- package/src/oauth/helpers.ts +6 -6
- package/src/oauth/server.ts +103 -101
- package/src/oauth/store.ts +27 -27
- package/src/priceSelector.test.ts +68 -68
- package/src/priceSelector.ts +70 -70
- package/src/product-projection-search.ts +296 -296
- package/src/projectAPI.test.ts +3 -3
- package/src/projectAPI.ts +46 -46
- package/src/repositories/abstract.ts +190 -190
- package/src/repositories/associate-role.ts +10 -7
- package/src/repositories/attribute-group.ts +63 -8
- package/src/repositories/business-unit.ts +10 -7
- package/src/repositories/cart-discount.ts +134 -134
- package/src/repositories/cart.ts +517 -514
- package/src/repositories/category.ts +170 -167
- package/src/repositories/channel.ts +114 -111
- package/src/repositories/custom-object.ts +66 -63
- package/src/repositories/customer-group.ts +72 -69
- package/src/repositories/customer.ts +93 -79
- package/src/repositories/discount-code.ts +171 -168
- package/src/repositories/errors.ts +15 -15
- package/src/repositories/extension.ts +79 -76
- package/src/repositories/helpers.ts +180 -180
- package/src/repositories/index.ts +39 -39
- package/src/repositories/inventory-entry.ts +98 -95
- package/src/repositories/my-order.ts +11 -11
- package/src/repositories/order-edit.ts +29 -29
- package/src/repositories/order.test.ts +191 -191
- package/src/repositories/order.ts +393 -389
- package/src/repositories/payment.ts +155 -155
- package/src/repositories/product-discount.ts +149 -149
- package/src/repositories/product-projection.ts +116 -52
- package/src/repositories/product-selection.ts +31 -31
- package/src/repositories/product-type.ts +156 -156
- package/src/repositories/product.ts +600 -597
- package/src/repositories/project.ts +136 -135
- package/src/repositories/quote-request.ts +19 -19
- package/src/repositories/quote.ts +19 -19
- package/src/repositories/review.ts +24 -24
- package/src/repositories/shipping-method.ts +217 -217
- package/src/repositories/shopping-list.ts +49 -49
- package/src/repositories/staged-quote.ts +20 -20
- package/src/repositories/standalone-price.ts +72 -61
- package/src/repositories/state.ts +84 -84
- package/src/repositories/store.ts +114 -114
- package/src/repositories/subscription.ts +40 -40
- package/src/repositories/tax-category.ts +98 -98
- package/src/repositories/type.ts +157 -157
- package/src/repositories/zone.ts +71 -71
- package/src/server.ts +2 -2
- package/src/services/abstract.ts +173 -173
- package/src/services/attribute-group.ts +16 -0
- package/src/services/cart-discount.ts +8 -8
- package/src/services/cart.test.ts +409 -409
- package/src/services/cart.ts +50 -50
- package/src/services/category.test.ts +25 -25
- package/src/services/category.ts +8 -8
- package/src/services/channel.ts +8 -8
- package/src/services/custom-object.test.ts +184 -184
- package/src/services/custom-object.ts +48 -48
- package/src/services/customer-group.ts +8 -8
- package/src/services/customer.test.ts +151 -129
- package/src/services/customer.ts +27 -27
- package/src/services/discount-code.ts +8 -8
- package/src/services/extension.ts +8 -8
- package/src/services/index.ts +52 -44
- package/src/services/inventory-entry.test.ts +162 -162
- package/src/services/inventory-entry.ts +8 -8
- package/src/services/my-cart.test.ts +78 -78
- package/src/services/my-cart.ts +28 -28
- package/src/services/my-customer.test.ts +44 -44
- package/src/services/my-customer.ts +53 -53
- package/src/services/my-order.ts +20 -20
- package/src/services/my-payment.test.ts +65 -65
- package/src/services/my-payment.ts +8 -8
- package/src/services/order.test.ts +527 -527
- package/src/services/order.ts +31 -31
- package/src/services/payment.test.ts +65 -65
- package/src/services/payment.ts +8 -8
- package/src/services/product-discount.ts +8 -8
- package/src/services/product-projection.test.ts +492 -428
- package/src/services/product-projection.ts +32 -18
- package/src/services/product-type.test.ts +56 -56
- package/src/services/product-type.ts +8 -8
- package/src/services/product.test.ts +510 -510
- package/src/services/product.ts +8 -8
- package/src/services/project.ts +34 -34
- package/src/services/shipping-method.test.ts +81 -81
- package/src/services/shipping-method.ts +12 -12
- package/src/services/shopping-list.ts +8 -8
- package/src/services/standalone-price.test.ts +256 -256
- package/src/services/standalone-price.ts +8 -8
- package/src/services/state.test.ts +42 -42
- package/src/services/state.ts +8 -8
- package/src/services/store.test.ts +57 -57
- package/src/services/store.ts +8 -8
- package/src/services/subscription.ts +8 -8
- package/src/services/tax-category.test.ts +61 -61
- package/src/services/tax-category.ts +8 -8
- package/src/services/type.ts +8 -8
- package/src/services/zone.ts +8 -8
- package/src/storage/abstract.ts +58 -58
- package/src/storage/in-memory.ts +419 -419
- package/src/types.ts +82 -82
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, AssociateRole, AttributeGroup, BusinessUnit, CartDraft, Cart, CartAddLineItemAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, 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, AssociateRole, 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, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, 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
|
import { ParsedQs } from 'qs';
|
|
5
5
|
|
|
6
6
|
type GetParams$1 = {
|
|
@@ -37,7 +37,13 @@ declare class AssociateRoleRepository extends AbstractResourceRepository<'associ
|
|
|
37
37
|
|
|
38
38
|
declare class AttributeGroupRepository extends AbstractResourceRepository<'attribute-group'> {
|
|
39
39
|
getTypeId(): "attribute-group";
|
|
40
|
-
create(context: RepositoryContext, draft:
|
|
40
|
+
create(context: RepositoryContext, draft: AttributeGroupDraft): AttributeGroup;
|
|
41
|
+
actions: {
|
|
42
|
+
setAttributes: (_context: RepositoryContext, resource: Writable<AttributeGroup>, { attributes }: AttributeGroupSetAttributesAction) => void;
|
|
43
|
+
changeName: (_context: RepositoryContext, resource: Writable<AttributeGroup>, { name }: AttributeGroupChangeNameAction) => void;
|
|
44
|
+
setDescription: (_context: RepositoryContext, resource: Writable<AttributeGroup>, { description }: AttributeGroupSetDescriptionAction) => void;
|
|
45
|
+
setKey: (_context: RepositoryContext, resource: Writable<AttributeGroup>, { key }: AttributeGroupSetKeyAction) => void;
|
|
46
|
+
};
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
declare class BusinessUnitRepository extends AbstractResourceRepository<'business-unit'> {
|
|
@@ -109,6 +115,7 @@ declare class CustomerRepository extends AbstractResourceRepository<'customer'>
|
|
|
109
115
|
actions: {
|
|
110
116
|
changeEmail: (_context: RepositoryContext, resource: Writable<Customer>, { email }: CustomerChangeEmailAction) => void;
|
|
111
117
|
setAuthenticationMode: (_context: RepositoryContext, resource: Writable<Customer>, { authMode, password }: CustomerSetAuthenticationModeAction) => void;
|
|
118
|
+
setCustomField: (_context: RepositoryContext, resource: Writable<Customer>, { name, value }: CustomerSetCustomFieldAction) => void;
|
|
112
119
|
};
|
|
113
120
|
}
|
|
114
121
|
|
|
@@ -261,17 +268,33 @@ declare class ProductProjectionSearch {
|
|
|
261
268
|
rangeFacet(source: string, ranges: RangeExpression[] | undefined, products: ProductProjection[]): RangeFacetResult;
|
|
262
269
|
}
|
|
263
270
|
|
|
271
|
+
type ProductProjectionQueryParams = {
|
|
272
|
+
staged?: boolean;
|
|
273
|
+
priceCurrency?: string;
|
|
274
|
+
priceCountry?: string;
|
|
275
|
+
priceCustomerGroup?: string;
|
|
276
|
+
priceChannel?: string;
|
|
277
|
+
localeProjection?: string | string[];
|
|
278
|
+
storeProjection?: string;
|
|
279
|
+
expand?: string | string[];
|
|
280
|
+
sort?: string | string[];
|
|
281
|
+
limit?: number;
|
|
282
|
+
offset?: number;
|
|
283
|
+
withTotal?: boolean;
|
|
284
|
+
where?: string | string[];
|
|
285
|
+
[key: string]: QueryParam;
|
|
286
|
+
};
|
|
264
287
|
declare class ProductProjectionRepository extends AbstractResourceRepository<'product-projection'> {
|
|
265
288
|
protected _searchService: ProductProjectionSearch;
|
|
266
289
|
constructor(storage: AbstractStorage);
|
|
267
290
|
getTypeId(): "product-projection";
|
|
268
291
|
create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
|
|
269
|
-
query(context: RepositoryContext, params?:
|
|
270
|
-
results: ProductProjection[];
|
|
271
|
-
limit: number;
|
|
272
|
-
offset: number;
|
|
292
|
+
query(context: RepositoryContext, params?: ProductProjectionQueryParams): {
|
|
273
293
|
count: number;
|
|
274
|
-
total
|
|
294
|
+
total: number;
|
|
295
|
+
offset: number;
|
|
296
|
+
limit: number;
|
|
297
|
+
results: ProductProjection[];
|
|
275
298
|
};
|
|
276
299
|
search(context: RepositoryContext, query: ParsedQs): ctp.ProductProjectionPagedSearchResponse;
|
|
277
300
|
actions: {};
|
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, AssociateRole, AttributeGroup, BusinessUnit, CartDraft, Cart, CartAddLineItemAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, 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, AssociateRole, 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, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, 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
|
import { ParsedQs } from 'qs';
|
|
5
5
|
|
|
6
6
|
type GetParams$1 = {
|
|
@@ -37,7 +37,13 @@ declare class AssociateRoleRepository extends AbstractResourceRepository<'associ
|
|
|
37
37
|
|
|
38
38
|
declare class AttributeGroupRepository extends AbstractResourceRepository<'attribute-group'> {
|
|
39
39
|
getTypeId(): "attribute-group";
|
|
40
|
-
create(context: RepositoryContext, draft:
|
|
40
|
+
create(context: RepositoryContext, draft: AttributeGroupDraft): AttributeGroup;
|
|
41
|
+
actions: {
|
|
42
|
+
setAttributes: (_context: RepositoryContext, resource: Writable<AttributeGroup>, { attributes }: AttributeGroupSetAttributesAction) => void;
|
|
43
|
+
changeName: (_context: RepositoryContext, resource: Writable<AttributeGroup>, { name }: AttributeGroupChangeNameAction) => void;
|
|
44
|
+
setDescription: (_context: RepositoryContext, resource: Writable<AttributeGroup>, { description }: AttributeGroupSetDescriptionAction) => void;
|
|
45
|
+
setKey: (_context: RepositoryContext, resource: Writable<AttributeGroup>, { key }: AttributeGroupSetKeyAction) => void;
|
|
46
|
+
};
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
declare class BusinessUnitRepository extends AbstractResourceRepository<'business-unit'> {
|
|
@@ -109,6 +115,7 @@ declare class CustomerRepository extends AbstractResourceRepository<'customer'>
|
|
|
109
115
|
actions: {
|
|
110
116
|
changeEmail: (_context: RepositoryContext, resource: Writable<Customer>, { email }: CustomerChangeEmailAction) => void;
|
|
111
117
|
setAuthenticationMode: (_context: RepositoryContext, resource: Writable<Customer>, { authMode, password }: CustomerSetAuthenticationModeAction) => void;
|
|
118
|
+
setCustomField: (_context: RepositoryContext, resource: Writable<Customer>, { name, value }: CustomerSetCustomFieldAction) => void;
|
|
112
119
|
};
|
|
113
120
|
}
|
|
114
121
|
|
|
@@ -261,17 +268,33 @@ declare class ProductProjectionSearch {
|
|
|
261
268
|
rangeFacet(source: string, ranges: RangeExpression[] | undefined, products: ProductProjection[]): RangeFacetResult;
|
|
262
269
|
}
|
|
263
270
|
|
|
271
|
+
type ProductProjectionQueryParams = {
|
|
272
|
+
staged?: boolean;
|
|
273
|
+
priceCurrency?: string;
|
|
274
|
+
priceCountry?: string;
|
|
275
|
+
priceCustomerGroup?: string;
|
|
276
|
+
priceChannel?: string;
|
|
277
|
+
localeProjection?: string | string[];
|
|
278
|
+
storeProjection?: string;
|
|
279
|
+
expand?: string | string[];
|
|
280
|
+
sort?: string | string[];
|
|
281
|
+
limit?: number;
|
|
282
|
+
offset?: number;
|
|
283
|
+
withTotal?: boolean;
|
|
284
|
+
where?: string | string[];
|
|
285
|
+
[key: string]: QueryParam;
|
|
286
|
+
};
|
|
264
287
|
declare class ProductProjectionRepository extends AbstractResourceRepository<'product-projection'> {
|
|
265
288
|
protected _searchService: ProductProjectionSearch;
|
|
266
289
|
constructor(storage: AbstractStorage);
|
|
267
290
|
getTypeId(): "product-projection";
|
|
268
291
|
create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
|
|
269
|
-
query(context: RepositoryContext, params?:
|
|
270
|
-
results: ProductProjection[];
|
|
271
|
-
limit: number;
|
|
272
|
-
offset: number;
|
|
292
|
+
query(context: RepositoryContext, params?: ProductProjectionQueryParams): {
|
|
273
293
|
count: number;
|
|
274
|
-
total
|
|
294
|
+
total: number;
|
|
295
|
+
offset: number;
|
|
296
|
+
limit: number;
|
|
297
|
+
results: ProductProjection[];
|
|
275
298
|
};
|
|
276
299
|
search(context: RepositoryContext, query: ParsedQs): ctp.ProductProjectionPagedSearchResponse;
|
|
277
300
|
actions: {};
|
package/dist/index.js
CHANGED
|
@@ -194,10 +194,13 @@ var TokenTypes = class {
|
|
|
194
194
|
}
|
|
195
195
|
peek(source, position) {
|
|
196
196
|
const s = source.substr(position);
|
|
197
|
-
return first(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
return first(
|
|
198
|
+
this.tokenTypes.filter((tt) => tt.enabled),
|
|
199
|
+
(tt) => {
|
|
200
|
+
tt.regex.lastIndex = 0;
|
|
201
|
+
return tt.regex.exec(s);
|
|
202
|
+
}
|
|
203
|
+
);
|
|
201
204
|
}
|
|
202
205
|
token(type, pattern, skip = false) {
|
|
203
206
|
this.tokenTypes.push({
|
|
@@ -642,7 +645,7 @@ var validateSymbol = (val) => {
|
|
|
642
645
|
};
|
|
643
646
|
var resolveSymbol = (val, vars) => {
|
|
644
647
|
if (val.type === "var") {
|
|
645
|
-
if (!(val.value in vars)) {
|
|
648
|
+
if (!(val.value in (vars ?? {}))) {
|
|
646
649
|
throw new PredicateError(`Missing parameter value for ${val.value}`);
|
|
647
650
|
}
|
|
648
651
|
return vars[val.value];
|
|
@@ -739,7 +742,7 @@ var generateMatchFunc = (predicate) => {
|
|
|
739
742
|
return (obj, vars) => {
|
|
740
743
|
const value = resolveValue(obj, left);
|
|
741
744
|
if (value) {
|
|
742
|
-
return expr(value);
|
|
745
|
+
return expr(value, vars);
|
|
743
746
|
}
|
|
744
747
|
return false;
|
|
745
748
|
};
|
|
@@ -1716,8 +1719,30 @@ var AttributeGroupRepository = class extends AbstractResourceRepository {
|
|
|
1716
1719
|
return "attribute-group";
|
|
1717
1720
|
}
|
|
1718
1721
|
create(context, draft) {
|
|
1719
|
-
|
|
1722
|
+
const resource = {
|
|
1723
|
+
...getBaseResourceProperties(),
|
|
1724
|
+
name: draft.name,
|
|
1725
|
+
description: draft.description,
|
|
1726
|
+
key: draft.key,
|
|
1727
|
+
attributes: draft.attributes
|
|
1728
|
+
};
|
|
1729
|
+
this.saveNew(context, resource);
|
|
1730
|
+
return resource;
|
|
1720
1731
|
}
|
|
1732
|
+
actions = {
|
|
1733
|
+
setAttributes: (_context, resource, { attributes }) => {
|
|
1734
|
+
resource.attributes = attributes;
|
|
1735
|
+
},
|
|
1736
|
+
changeName: (_context, resource, { name }) => {
|
|
1737
|
+
resource.name = name;
|
|
1738
|
+
},
|
|
1739
|
+
setDescription: (_context, resource, { description }) => {
|
|
1740
|
+
resource.description = description;
|
|
1741
|
+
},
|
|
1742
|
+
setKey: (_context, resource, { key }) => {
|
|
1743
|
+
resource.key = key;
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1721
1746
|
};
|
|
1722
1747
|
|
|
1723
1748
|
// src/repositories/business-unit.ts
|
|
@@ -2483,6 +2508,12 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
2483
2508
|
},
|
|
2484
2509
|
400
|
|
2485
2510
|
);
|
|
2511
|
+
},
|
|
2512
|
+
setCustomField: (_context, resource, { name, value }) => {
|
|
2513
|
+
if (!resource.custom) {
|
|
2514
|
+
throw new Error("Resource has no custom field");
|
|
2515
|
+
}
|
|
2516
|
+
resource.custom.fields[name] = value;
|
|
2486
2517
|
}
|
|
2487
2518
|
};
|
|
2488
2519
|
};
|
|
@@ -2991,7 +3022,11 @@ var OrderRepository = class extends AbstractResourceRepository {
|
|
|
2991
3022
|
`No state found with key=${state.key} or id=${state.key}`
|
|
2992
3023
|
);
|
|
2993
3024
|
}
|
|
2994
|
-
resource.state = {
|
|
3025
|
+
resource.state = {
|
|
3026
|
+
typeId: "state",
|
|
3027
|
+
id: resolvedType.id,
|
|
3028
|
+
obj: { ...resolvedType, key: state.key ?? "" }
|
|
3029
|
+
};
|
|
2995
3030
|
},
|
|
2996
3031
|
setBillingAddress: (context, resource, { address }) => {
|
|
2997
3032
|
resource.billingAddress = createAddress(
|
|
@@ -4198,17 +4233,49 @@ var ProductProjectionRepository = class extends AbstractResourceRepository {
|
|
|
4198
4233
|
throw new Error("No valid action");
|
|
4199
4234
|
}
|
|
4200
4235
|
query(context, params = {}) {
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4236
|
+
let resources = this._storage.all(context.projectKey, "product").map((r) => this._searchService.transform(r, params.staged ?? false)).filter((p) => {
|
|
4237
|
+
if (!params.staged) {
|
|
4238
|
+
return p.published;
|
|
4239
|
+
}
|
|
4240
|
+
return true;
|
|
4206
4241
|
});
|
|
4242
|
+
if (params.where) {
|
|
4243
|
+
const variableMap = {};
|
|
4244
|
+
for (const [k, v] of Object.entries(params)) {
|
|
4245
|
+
if (k.startsWith("var.")) {
|
|
4246
|
+
variableMap[k.substring(4)] = v;
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
try {
|
|
4250
|
+
const filterFunc = parseQueryExpression(params.where);
|
|
4251
|
+
resources = resources.filter(
|
|
4252
|
+
(resource) => filterFunc(resource, variableMap)
|
|
4253
|
+
);
|
|
4254
|
+
} catch (err) {
|
|
4255
|
+
throw new CommercetoolsError(
|
|
4256
|
+
{
|
|
4257
|
+
code: "InvalidInput",
|
|
4258
|
+
message: err.message
|
|
4259
|
+
},
|
|
4260
|
+
400
|
|
4261
|
+
);
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
if (params.expand !== void 0) {
|
|
4265
|
+
resources = resources.map(
|
|
4266
|
+
(resource) => this._storage.expand(context.projectKey, resource, params.expand)
|
|
4267
|
+
);
|
|
4268
|
+
}
|
|
4269
|
+
const totalResults = resources.length;
|
|
4270
|
+
const offset = params.offset || 0;
|
|
4271
|
+
const limit = params.limit || 20;
|
|
4272
|
+
const results = resources.slice(offset, offset + limit);
|
|
4207
4273
|
return {
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4274
|
+
count: totalResults,
|
|
4275
|
+
total: results.length,
|
|
4276
|
+
offset,
|
|
4277
|
+
limit,
|
|
4278
|
+
results
|
|
4212
4279
|
};
|
|
4213
4280
|
}
|
|
4214
4281
|
search(context, query) {
|
|
@@ -5646,6 +5713,18 @@ var ProductProjectionService = class extends AbstractService {
|
|
|
5646
5713
|
extraRoutes(router) {
|
|
5647
5714
|
router.get("/search", this.search.bind(this));
|
|
5648
5715
|
}
|
|
5716
|
+
get(request, response) {
|
|
5717
|
+
const limit = this._parseParam(request.query.limit);
|
|
5718
|
+
const offset = this._parseParam(request.query.offset);
|
|
5719
|
+
const result = this.repository.query(getRepositoryContext(request), {
|
|
5720
|
+
...request.query,
|
|
5721
|
+
expand: this._parseParam(request.query.expand),
|
|
5722
|
+
where: this._parseParam(request.query.where),
|
|
5723
|
+
limit: limit !== void 0 ? Number(limit) : void 0,
|
|
5724
|
+
offset: offset !== void 0 ? Number(offset) : void 0
|
|
5725
|
+
});
|
|
5726
|
+
return response.status(200).send(result);
|
|
5727
|
+
}
|
|
5649
5728
|
search(request, response) {
|
|
5650
5729
|
const resource = this.repository.search(
|
|
5651
5730
|
getRepositoryContext(request),
|
|
@@ -5779,6 +5858,18 @@ var ZoneService = class extends AbstractService {
|
|
|
5779
5858
|
}
|
|
5780
5859
|
};
|
|
5781
5860
|
|
|
5861
|
+
// src/services/attribute-group.ts
|
|
5862
|
+
var AttributeGroupService = class extends AbstractService {
|
|
5863
|
+
repository;
|
|
5864
|
+
constructor(parent, repository) {
|
|
5865
|
+
super(parent);
|
|
5866
|
+
this.repository = repository;
|
|
5867
|
+
}
|
|
5868
|
+
getBasePath() {
|
|
5869
|
+
return "attribute-groups";
|
|
5870
|
+
}
|
|
5871
|
+
};
|
|
5872
|
+
|
|
5782
5873
|
// src/services/index.ts
|
|
5783
5874
|
var createServices = (router, repos) => ({
|
|
5784
5875
|
category: new CategoryServices(router, repos["category"]),
|
|
@@ -5799,7 +5890,10 @@ var createServices = (router, repos) => ({
|
|
|
5799
5890
|
),
|
|
5800
5891
|
order: new OrderService(router, repos["order"]),
|
|
5801
5892
|
payment: new PaymentService(router, repos["payment"]),
|
|
5802
|
-
"standalone-price": new StandAlonePriceService(
|
|
5893
|
+
"standalone-price": new StandAlonePriceService(
|
|
5894
|
+
router,
|
|
5895
|
+
repos["standalone-price"]
|
|
5896
|
+
),
|
|
5803
5897
|
"my-cart": new MyCartService(router, repos["my-cart"]),
|
|
5804
5898
|
"my-order": new MyOrderService(router, repos["my-order"]),
|
|
5805
5899
|
"my-customer": new MyCustomerService(router, repos["my-customer"]),
|
|
@@ -5823,6 +5917,10 @@ var createServices = (router, repos) => ({
|
|
|
5823
5917
|
store: new StoreService(router, repos["store"]),
|
|
5824
5918
|
subscription: new SubscriptionService(router, repos["subscription"]),
|
|
5825
5919
|
"tax-category": new TaxCategoryService(router, repos["tax-category"]),
|
|
5920
|
+
"attribute-group": new AttributeGroupService(
|
|
5921
|
+
router,
|
|
5922
|
+
repos["attribute-group"]
|
|
5923
|
+
),
|
|
5826
5924
|
type: new TypeService(router, repos["type"]),
|
|
5827
5925
|
zone: new ZoneService(router, repos["zone"])
|
|
5828
5926
|
});
|