@labdigital/commercetools-mock 0.7.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +26 -1
- package/dist/index.global.js +387 -92
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +384 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +384 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
- package/src/helpers.ts +24 -0
- package/src/lib/predicateParser.test.ts +16 -0
- package/src/lib/predicateParser.ts +8 -1
- package/src/lib/projectionSearchFilter.test.ts +6 -0
- package/src/lib/projectionSearchFilter.ts +173 -74
- package/src/product-projection-search.ts +210 -10
- package/src/repositories/abstract.ts +23 -5
- package/src/repositories/extension.ts +18 -1
- package/src/repositories/helpers.ts +37 -3
- package/src/repositories/product-projection.ts +1 -0
- package/src/repositories/project.ts +10 -5
- package/src/repositories/state.ts +14 -0
- package/src/services/product-projection.test.ts +170 -3
- package/src/validate.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express, { Router, Request, Response } from 'express';
|
|
2
2
|
import * as ctp from '@commercetools/platform-sdk';
|
|
3
|
-
import { Project, BaseResource, PagedQueryResponse, ResourceIdentifier, QueryParam, ProductProjectionPagedSearchResponse, Product, ProductProjection, ProductDraft, ReferenceTypeId, ShoppingListDraft, ShoppingList, CartDraft, Cart, CartAddLineItemAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, LineItemDraft, LineItem, CustomerDraft, Customer, CustomerChangeEmailAction, CustomObjectDraft, CustomObject, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, PaymentDraft, Payment, TransactionDraft, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, ProductPublishAction, ProductSetAttributeAction, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ShippingMethodDraft, ShippingMethod, ShippingMethodUpdateAction, StateDraft, State, StateUpdateAction, TaxCategoryDraft, TaxCategory, TaxCategoryUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, UpdateAction } from '@commercetools/platform-sdk';
|
|
3
|
+
import { Project, BaseResource, PagedQueryResponse, ResourceIdentifier, QueryParam, ProductProjectionPagedSearchResponse, Product, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductDraft, ReferenceTypeId, ShoppingListDraft, ShoppingList, CartDraft, Cart, CartAddLineItemAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, LineItemDraft, LineItem, CustomerDraft, Customer, CustomerChangeEmailAction, CustomObjectDraft, CustomObject, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, PaymentDraft, Payment, TransactionDraft, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, ProductPublishAction, ProductSetAttributeAction, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ShippingMethodDraft, ShippingMethod, ShippingMethodUpdateAction, StateDraft, State, StateUpdateAction, TaxCategoryDraft, TaxCategory, TaxCategoryUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, UpdateAction } from '@commercetools/platform-sdk';
|
|
4
4
|
import { ParsedQs } from 'qs';
|
|
5
5
|
|
|
6
6
|
declare type GetParams$1 = {
|
|
@@ -31,6 +31,21 @@ declare abstract class AbstractStorage {
|
|
|
31
31
|
abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* This module implements the commercetools product projection filter expression.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
declare type RangeExpression = {
|
|
39
|
+
type: 'RangeExpression';
|
|
40
|
+
start?: number;
|
|
41
|
+
stop?: number;
|
|
42
|
+
match: (obj: any) => boolean;
|
|
43
|
+
};
|
|
44
|
+
declare type FilterExpression = {
|
|
45
|
+
type: 'FilterExpression';
|
|
46
|
+
match: (obj: any) => boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
34
49
|
declare type ProductProjectionSearchParams = {
|
|
35
50
|
fuzzy?: boolean;
|
|
36
51
|
fuzzyLevel?: number;
|
|
@@ -58,6 +73,15 @@ declare class ProductProjectionSearch {
|
|
|
58
73
|
constructor(storage: AbstractStorage);
|
|
59
74
|
search(projectKey: string, params: ProductProjectionSearchParams): ProductProjectionPagedSearchResponse;
|
|
60
75
|
transform(product: Product): ProductProjection;
|
|
76
|
+
getFacets(params: ProductProjectionSearchParams, products: Product[]): FacetResults;
|
|
77
|
+
/**
|
|
78
|
+
* TODO: This implemention needs the following additional features:
|
|
79
|
+
* - counting products
|
|
80
|
+
* - correct dataType
|
|
81
|
+
*/
|
|
82
|
+
termFacet(facet: string, products: Product[], staged: boolean): TermFacetResult;
|
|
83
|
+
filterFacet(source: string, filters: FilterExpression[] | undefined, products: Product[], staged: boolean): FilteredFacetResult;
|
|
84
|
+
rangeFacet(source: string, ranges: RangeExpression[] | undefined, products: Product[], staged: boolean): RangeFacetResult;
|
|
61
85
|
}
|
|
62
86
|
|
|
63
87
|
declare class ProductProjectionRepository extends AbstractResourceRepository {
|
|
@@ -323,6 +347,7 @@ declare abstract class AbstractRepository {
|
|
|
323
347
|
constructor(storage: AbstractStorage);
|
|
324
348
|
abstract save({ projectKey }: RepositoryContext, resource: BaseResource | Project): void;
|
|
325
349
|
processUpdateActions(context: RepositoryContext, resource: BaseResource | Project, actions: UpdateAction[]): BaseResource;
|
|
350
|
+
postProcessResource(resource: BaseResource | null): BaseResource | null;
|
|
326
351
|
}
|
|
327
352
|
declare abstract class AbstractResourceRepository extends AbstractRepository {
|
|
328
353
|
abstract create(context: RepositoryContext, draft: any): BaseResource;
|