@labdigital/commercetools-mock 0.9.1 → 0.10.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/README.md +8 -0
- package/dist/index.d.ts +354 -188
- package/dist/index.global.js +2346 -2209
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1968 -1829
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2171 -2032
- package/dist/index.mjs.map +1 -1
- package/package.json +30 -21
- package/src/constants.ts +4 -2
- package/src/ctMock.ts +27 -86
- package/src/helpers.ts +10 -11
- package/src/index.test.ts +1 -1
- package/src/lib/haversine.ts +2 -2
- package/src/lib/masking.ts +3 -1
- package/src/lib/predicateParser.ts +93 -92
- package/src/lib/projectionSearchFilter.test.ts +28 -36
- package/src/lib/projectionSearchFilter.ts +88 -103
- package/src/oauth/store.ts +3 -3
- package/src/priceSelector.test.ts +16 -35
- package/src/priceSelector.ts +6 -9
- package/src/product-projection-search.ts +49 -57
- package/src/projectAPI.test.ts +7 -0
- package/src/projectAPI.ts +17 -22
- package/src/repositories/abstract.ts +102 -51
- package/src/repositories/cart-discount.ts +4 -5
- package/src/repositories/cart.ts +56 -46
- package/src/repositories/category.ts +23 -26
- package/src/repositories/channel.ts +5 -6
- package/src/repositories/custom-object.ts +41 -32
- package/src/repositories/customer-group.ts +4 -5
- package/src/repositories/customer.ts +42 -5
- package/src/repositories/discount-code.ts +5 -6
- package/src/repositories/errors.ts +10 -14
- package/src/repositories/extension.ts +16 -15
- package/src/repositories/helpers.ts +10 -15
- package/src/repositories/index.ts +75 -0
- package/src/repositories/inventory-entry.ts +5 -6
- package/src/repositories/my-order.ts +2 -2
- package/src/repositories/order-edit.ts +39 -0
- package/src/repositories/order.test.ts +16 -11
- package/src/repositories/order.ts +21 -14
- package/src/repositories/payment.ts +9 -10
- package/src/repositories/product-discount.ts +5 -25
- package/src/repositories/product-projection.ts +12 -5
- package/src/repositories/product-selection.ts +40 -0
- package/src/repositories/product-type.ts +38 -60
- package/src/repositories/product.ts +128 -85
- package/src/repositories/project.ts +16 -33
- package/src/repositories/quote-request.ts +28 -0
- package/src/repositories/quote.ts +28 -0
- package/src/repositories/review.ts +34 -0
- package/src/repositories/shipping-method.ts +25 -28
- package/src/repositories/shopping-list.ts +6 -6
- package/src/repositories/staged-quote.ts +29 -0
- package/src/repositories/standalone-price.ts +36 -0
- package/src/repositories/state.ts +16 -17
- package/src/repositories/store.ts +13 -29
- package/src/repositories/subscription.ts +4 -5
- package/src/repositories/tax-category.ts +9 -26
- package/src/repositories/type.ts +24 -27
- package/src/repositories/zone.ts +9 -11
- package/src/server.ts +5 -0
- package/src/services/abstract.ts +43 -12
- package/src/services/cart-discount.ts +3 -4
- package/src/services/cart.test.ts +9 -11
- package/src/services/cart.ts +42 -38
- package/src/services/category.test.ts +1 -2
- package/src/services/category.ts +3 -4
- package/src/services/channel.ts +3 -4
- package/src/services/custom-object.test.ts +6 -6
- package/src/services/custom-object.ts +4 -5
- package/src/services/customer-group.ts +3 -4
- package/src/services/customer.test.ts +136 -0
- package/src/services/customer.ts +5 -6
- package/src/services/discount-code.ts +3 -4
- package/src/services/extension.ts +3 -4
- package/src/services/index.ts +74 -0
- package/src/services/inventory-entry.test.ts +9 -13
- package/src/services/inventory-entry.ts +3 -4
- package/src/services/my-cart.test.ts +2 -0
- package/src/services/my-cart.ts +4 -5
- package/src/services/my-customer.ts +3 -4
- package/src/services/my-order.ts +4 -5
- package/src/services/my-payment.ts +3 -4
- package/src/services/order.test.ts +28 -26
- package/src/services/order.ts +4 -5
- package/src/services/payment.ts +3 -4
- package/src/services/product-discount.ts +3 -20
- package/src/services/product-projection.test.ts +76 -8
- package/src/services/product-projection.ts +4 -5
- package/src/services/product-type.ts +3 -20
- package/src/services/product.test.ts +200 -90
- package/src/services/product.ts +3 -4
- package/src/services/project.ts +5 -6
- package/src/services/shipping-method.ts +3 -4
- package/src/services/shopping-list.ts +3 -4
- package/src/services/state.ts +3 -4
- package/src/services/store.test.ts +11 -2
- package/src/services/store.ts +4 -21
- package/src/services/subscription.ts +3 -4
- package/src/services/tax-category.ts +3 -20
- package/src/services/type.ts +3 -4
- package/src/services/zone.ts +3 -4
- package/src/storage/abstract.ts +82 -0
- package/src/{storage.ts → storage/in-memory.ts} +79 -147
- package/src/storage/index.ts +2 -0
- package/src/types.ts +52 -83
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import express
|
|
1
|
+
import express from 'express';
|
|
2
2
|
import * as ctp from '@commercetools/platform-sdk';
|
|
3
|
-
import { Project,
|
|
3
|
+
import { Project, ResourceIdentifier, QueryParam, CartDraft, Cart, CartAddLineItemAction, 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, 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, StandalonePrice, StandalonePriceUpdateAction, 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
|
declare type GetParams$1 = {
|
|
@@ -17,109 +17,21 @@ declare type QueryParams$1 = {
|
|
|
17
17
|
};
|
|
18
18
|
declare abstract class AbstractStorage {
|
|
19
19
|
abstract clear(): void;
|
|
20
|
-
abstract
|
|
21
|
-
abstract
|
|
22
|
-
abstract
|
|
23
|
-
abstract
|
|
24
|
-
abstract getByKey<RT extends RepositoryTypes>(projectKey: string, typeId: RT, key: string, params: GetParams$1): ResourceMap[RT] | null;
|
|
20
|
+
abstract all<RT extends ResourceType>(projectKey: string, typeId: RT): Array<ResourceMap[RT]>;
|
|
21
|
+
abstract add<RT extends ResourceType>(projectKey: string, typeId: RT, obj: ResourceMap[RT]): void;
|
|
22
|
+
abstract get<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params?: GetParams$1): ResourceMap[RT] | null;
|
|
23
|
+
abstract getByKey<RT extends ResourceType>(projectKey: string, typeId: RT, key: string, params: GetParams$1): ResourceMap[RT] | null;
|
|
25
24
|
abstract addProject(projectKey: string): Project;
|
|
26
25
|
abstract getProject(projectKey: string): Project;
|
|
27
26
|
abstract saveProject(project: Project): Project;
|
|
28
|
-
abstract delete<RT extends
|
|
29
|
-
abstract query(projectKey: string, typeId:
|
|
30
|
-
abstract getByResourceIdentifier<RT extends
|
|
27
|
+
abstract delete<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params: GetParams$1): ResourceMap[RT] | null;
|
|
28
|
+
abstract query<RT extends ResourceType>(projectKey: string, typeId: RT, params: QueryParams$1): PagedQueryResponseMap[RT];
|
|
29
|
+
abstract getByResourceIdentifier<RT extends ResourceType>(projectKey: string, identifier: ResourceIdentifier): ResourceMap[RT] | null;
|
|
31
30
|
abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
49
|
-
declare type ProductProjectionSearchParams = {
|
|
50
|
-
fuzzy?: boolean;
|
|
51
|
-
fuzzyLevel?: number;
|
|
52
|
-
markMatchingVariants?: boolean;
|
|
53
|
-
staged?: boolean;
|
|
54
|
-
filter?: string[];
|
|
55
|
-
'filter.facets'?: string[];
|
|
56
|
-
'filter.query'?: string[];
|
|
57
|
-
facet?: string | string[];
|
|
58
|
-
sort?: string | string[];
|
|
59
|
-
limit?: number;
|
|
60
|
-
offset?: number;
|
|
61
|
-
withTotal?: boolean;
|
|
62
|
-
priceCurrency?: string;
|
|
63
|
-
priceCountry?: string;
|
|
64
|
-
priceCustomerGroup?: string;
|
|
65
|
-
priceChannel?: string;
|
|
66
|
-
localeProjection?: string;
|
|
67
|
-
storeProjection?: string;
|
|
68
|
-
expand?: string | string[];
|
|
69
|
-
[key: string]: QueryParam;
|
|
70
|
-
};
|
|
71
|
-
declare class ProductProjectionSearch {
|
|
72
|
-
protected _storage: AbstractStorage;
|
|
73
|
-
constructor(storage: AbstractStorage);
|
|
74
|
-
search(projectKey: string, params: ProductProjectionSearchParams): ProductProjectionPagedSearchResponse;
|
|
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;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
declare class ProductProjectionRepository extends AbstractResourceRepository {
|
|
88
|
-
protected _searchService: ProductProjectionSearch;
|
|
89
|
-
constructor(storage: AbstractStorage);
|
|
90
|
-
getTypeId(): RepositoryTypes;
|
|
91
|
-
create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
|
|
92
|
-
query(context: RepositoryContext, params?: QueryParams): ctp.PagedQueryResponse;
|
|
93
|
-
search(context: RepositoryContext, query: ParsedQs): ctp.ProductProjectionPagedSearchResponse;
|
|
94
|
-
actions: {};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
declare class ShoppingListRepository extends AbstractResourceRepository {
|
|
98
|
-
getTypeId(): ReferenceTypeId;
|
|
99
|
-
create(context: RepositoryContext, draft: ShoppingListDraft): ShoppingList;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
declare abstract class AbstractService {
|
|
103
|
-
protected abstract getBasePath(): string;
|
|
104
|
-
abstract repository: AbstractResourceRepository;
|
|
105
|
-
createStatusCode: number;
|
|
106
|
-
constructor(parent: Router);
|
|
107
|
-
extraRoutes(router: Router): void;
|
|
108
|
-
registerRoutes(parent: Router): void;
|
|
109
|
-
get(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
110
|
-
getWithId(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
111
|
-
getWithKey(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
112
|
-
deletewithId(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
113
|
-
deletewithKey(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
114
|
-
post(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
115
|
-
postWithId(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
116
|
-
postWithKey(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
117
|
-
protected _expandWithId(request: Request, resourceId: string): ctp.BaseResource | null;
|
|
118
|
-
private _parseParam;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
declare class CartRepository extends AbstractResourceRepository {
|
|
122
|
-
getTypeId(): ReferenceTypeId;
|
|
33
|
+
declare class CartRepository extends AbstractResourceRepository<'cart'> {
|
|
34
|
+
getTypeId(): "cart";
|
|
123
35
|
create(context: RepositoryContext, draft: CartDraft): Cart;
|
|
124
36
|
getActiveCart(projectKey: string): Cart | undefined;
|
|
125
37
|
actions: {
|
|
@@ -137,23 +49,79 @@ declare class CartRepository extends AbstractResourceRepository {
|
|
|
137
49
|
draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft, currency: string, country: string | undefined) => LineItem;
|
|
138
50
|
}
|
|
139
51
|
|
|
140
|
-
declare class
|
|
141
|
-
getTypeId():
|
|
52
|
+
declare class CartDiscountRepository extends AbstractResourceRepository<'cart-discount'> {
|
|
53
|
+
getTypeId(): "cart-discount";
|
|
54
|
+
create(context: RepositoryContext, draft: CartDiscountDraft): CartDiscount;
|
|
55
|
+
private transformValueDraft;
|
|
56
|
+
actions: Partial<Record<CartDiscountUpdateAction['action'], (context: RepositoryContext, resource: Writable<CartDiscount>, action: any) => void>>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare class CategoryRepository extends AbstractResourceRepository<'category'> {
|
|
60
|
+
getTypeId(): "category";
|
|
61
|
+
create(context: RepositoryContext, draft: CategoryDraft): Category;
|
|
62
|
+
actions: {
|
|
63
|
+
changeAssetName: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, name }: CategoryChangeAssetNameAction) => void;
|
|
64
|
+
changeSlug: (context: RepositoryContext, resource: Writable<Category>, { slug }: CategoryChangeSlugAction) => void;
|
|
65
|
+
setKey: (context: RepositoryContext, resource: Writable<Category>, { key }: CategorySetKeyAction) => void;
|
|
66
|
+
setAssetDescription: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, description }: CategorySetAssetDescriptionAction) => void;
|
|
67
|
+
setAssetSources: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, sources }: CategorySetAssetSourcesAction) => void;
|
|
68
|
+
setDescription: (context: RepositoryContext, resource: Writable<Category>, { description }: CategorySetDescriptionAction) => void;
|
|
69
|
+
setMetaDescription: (context: RepositoryContext, resource: Writable<Category>, { metaDescription }: CategorySetMetaDescriptionAction) => void;
|
|
70
|
+
setMetaKeywords: (context: RepositoryContext, resource: Writable<Category>, { metaKeywords }: CategorySetMetaKeywordsAction) => void;
|
|
71
|
+
setMetaTitle: (context: RepositoryContext, resource: Writable<Category>, { metaTitle }: CategorySetMetaTitleAction) => void;
|
|
72
|
+
setCustomType: (context: RepositoryContext, resource: Writable<Category>, { type, fields }: CategorySetCustomTypeAction) => void;
|
|
73
|
+
setCustomField: (context: RepositoryContext, resource: Writable<Category>, { name, value }: CategorySetCustomFieldAction) => void;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare class ChannelRepository extends AbstractResourceRepository<'channel'> {
|
|
78
|
+
getTypeId(): "channel";
|
|
79
|
+
create(context: RepositoryContext, draft: ChannelDraft): Channel;
|
|
80
|
+
actions: Partial<Record<ChannelUpdateAction['action'], (context: RepositoryContext, resource: Writable<Channel>, action: any) => void>>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare class CustomObjectRepository extends AbstractResourceRepository<'key-value-document'> {
|
|
84
|
+
getTypeId(): "key-value-document";
|
|
85
|
+
create(context: RepositoryContext, draft: Writable<CustomObjectDraft>): CustomObject;
|
|
86
|
+
getWithContainerAndKey(context: RepositoryContext, container: string, key: string): CustomObject | undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare class CustomerRepository extends AbstractResourceRepository<'customer'> {
|
|
90
|
+
getTypeId(): "customer";
|
|
142
91
|
create(context: RepositoryContext, draft: CustomerDraft): Customer;
|
|
143
92
|
getMe(context: RepositoryContext): Customer | undefined;
|
|
144
93
|
actions: {
|
|
145
94
|
changeEmail: (_context: RepositoryContext, resource: Writable<Customer>, { email }: CustomerChangeEmailAction) => void;
|
|
95
|
+
setAuthenticationMode: (_context: RepositoryContext, resource: Writable<Customer>, { authMode, password }: CustomerSetAuthenticationModeAction) => void;
|
|
146
96
|
};
|
|
147
97
|
}
|
|
148
98
|
|
|
149
|
-
declare class
|
|
150
|
-
getTypeId():
|
|
151
|
-
create(context: RepositoryContext, draft:
|
|
152
|
-
|
|
99
|
+
declare class CustomerGroupRepository extends AbstractResourceRepository<'customer-group'> {
|
|
100
|
+
getTypeId(): "customer-group";
|
|
101
|
+
create(context: RepositoryContext, draft: CustomerGroupDraft): CustomerGroup;
|
|
102
|
+
actions: {
|
|
103
|
+
setKey: (context: RepositoryContext, resource: Writable<CustomerGroup>, { key }: CustomerGroupSetKeyAction) => void;
|
|
104
|
+
changeName: (context: RepositoryContext, resource: Writable<CustomerGroup>, { name }: CustomerGroupChangeNameAction) => void;
|
|
105
|
+
setCustomType: (context: RepositoryContext, resource: Writable<CustomerGroup>, { type, fields }: CustomerGroupSetCustomTypeAction) => void;
|
|
106
|
+
setCustomField: (context: RepositoryContext, resource: Writable<CustomerGroup>, { name, value }: CustomerGroupSetCustomFieldAction) => void;
|
|
107
|
+
};
|
|
153
108
|
}
|
|
154
109
|
|
|
155
|
-
declare class
|
|
156
|
-
getTypeId():
|
|
110
|
+
declare class DiscountCodeRepository extends AbstractResourceRepository<'discount-code'> {
|
|
111
|
+
getTypeId(): "discount-code";
|
|
112
|
+
create(context: RepositoryContext, draft: DiscountCodeDraft): DiscountCode;
|
|
113
|
+
actions: Partial<Record<DiscountCodeUpdateAction['action'], (context: RepositoryContext, resource: Writable<DiscountCode>, action: any) => void>>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
declare class ExtensionRepository extends AbstractResourceRepository<'extension'> {
|
|
117
|
+
getTypeId(): "extension";
|
|
118
|
+
postProcessResource(resource: Extension): Extension;
|
|
119
|
+
create(context: RepositoryContext, draft: ExtensionDraft): Extension;
|
|
120
|
+
actions: Record<ExtensionUpdateAction['action'], (context: RepositoryContext, resource: Writable<Extension>, action: any) => void>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare class InventoryEntryRepository extends AbstractResourceRepository<'inventory-entry'> {
|
|
124
|
+
getTypeId(): "inventory-entry";
|
|
157
125
|
create(context: RepositoryContext, draft: InventoryEntryDraft): InventoryEntry;
|
|
158
126
|
actions: {
|
|
159
127
|
changeQuantity: (context: RepositoryContext, resource: Writable<InventoryEntry>, { quantity }: InventoryEntryChangeQuantityAction) => void;
|
|
@@ -164,8 +132,8 @@ declare class InventoryEntryRepository extends AbstractResourceRepository {
|
|
|
164
132
|
};
|
|
165
133
|
}
|
|
166
134
|
|
|
167
|
-
declare class OrderRepository extends AbstractResourceRepository {
|
|
168
|
-
getTypeId():
|
|
135
|
+
declare class OrderRepository extends AbstractResourceRepository<'order'> {
|
|
136
|
+
getTypeId(): "order";
|
|
169
137
|
create(context: RepositoryContext, draft: OrderFromCartDraft): Order;
|
|
170
138
|
createFromCart(context: RepositoryContext, cartReference: CartReference, orderNumber?: string): Order;
|
|
171
139
|
import(context: RepositoryContext, draft: OrderImportDraft): Order;
|
|
@@ -188,8 +156,18 @@ declare class OrderRepository extends AbstractResourceRepository {
|
|
|
188
156
|
};
|
|
189
157
|
}
|
|
190
158
|
|
|
191
|
-
declare class
|
|
192
|
-
|
|
159
|
+
declare class MyOrderRepository extends OrderRepository {
|
|
160
|
+
create(context: RepositoryContext, draft: MyOrderFromCartDraft): Order;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
declare class OrderEditRepository extends AbstractResourceRepository<'order-edit'> {
|
|
164
|
+
getTypeId(): "order-edit";
|
|
165
|
+
create(context: RepositoryContext, draft: OrderEditDraft): OrderEdit;
|
|
166
|
+
actions: Partial<Record<OrderEditUpdateAction['action'], (context: RepositoryContext, resource: Writable<OrderEdit>, action: any) => void>>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare class PaymentRepository extends AbstractResourceRepository<'payment'> {
|
|
170
|
+
getTypeId(): "payment";
|
|
193
171
|
create(context: RepositoryContext, draft: PaymentDraft): Payment;
|
|
194
172
|
transactionFromTransactionDraft: (draft: TransactionDraft, context: RepositoryContext) => {
|
|
195
173
|
id: string;
|
|
@@ -209,84 +187,264 @@ declare class PaymentRepository extends AbstractResourceRepository {
|
|
|
209
187
|
};
|
|
210
188
|
}
|
|
211
189
|
|
|
212
|
-
declare class ProductRepository extends AbstractResourceRepository {
|
|
213
|
-
getTypeId():
|
|
190
|
+
declare class ProductRepository extends AbstractResourceRepository<'product'> {
|
|
191
|
+
getTypeId(): "product";
|
|
214
192
|
create(context: RepositoryContext, draft: ProductDraft): Product;
|
|
215
|
-
actions:
|
|
216
|
-
|
|
217
|
-
|
|
193
|
+
actions: Partial<Record<ProductUpdateAction['action'], (context: RepositoryContext, resource: Writable<Product>, action: any) => void>>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
declare class ProductDiscountRepository extends AbstractResourceRepository<'product-discount'> {
|
|
197
|
+
getTypeId(): "product-discount";
|
|
198
|
+
create(context: RepositoryContext, draft: ProductDiscountDraft): ProductDiscount;
|
|
199
|
+
private transformValueDraft;
|
|
200
|
+
actions: Partial<Record<ProductDiscountUpdateAction['action'], (context: RepositoryContext, resource: Writable<ProductDiscount>, action: any) => void>>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* This module implements the commercetools product projection filter expression.
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
declare type RangeExpression = {
|
|
208
|
+
type: 'RangeExpression';
|
|
209
|
+
start?: number;
|
|
210
|
+
stop?: number;
|
|
211
|
+
match: (obj: any) => boolean;
|
|
212
|
+
};
|
|
213
|
+
declare type FilterExpression = {
|
|
214
|
+
type: 'FilterExpression';
|
|
215
|
+
match: (obj: any) => boolean;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
declare type ProductProjectionSearchParams = {
|
|
219
|
+
fuzzy?: boolean;
|
|
220
|
+
fuzzyLevel?: number;
|
|
221
|
+
markMatchingVariants?: boolean;
|
|
222
|
+
staged?: boolean;
|
|
223
|
+
filter?: string[];
|
|
224
|
+
'filter.facets'?: string[];
|
|
225
|
+
'filter.query'?: string[];
|
|
226
|
+
facet?: string | string[];
|
|
227
|
+
sort?: string | string[];
|
|
228
|
+
limit?: number;
|
|
229
|
+
offset?: number;
|
|
230
|
+
withTotal?: boolean;
|
|
231
|
+
priceCurrency?: string;
|
|
232
|
+
priceCountry?: string;
|
|
233
|
+
priceCustomerGroup?: string;
|
|
234
|
+
priceChannel?: string;
|
|
235
|
+
localeProjection?: string;
|
|
236
|
+
storeProjection?: string;
|
|
237
|
+
expand?: string | string[];
|
|
238
|
+
[key: string]: QueryParam;
|
|
239
|
+
};
|
|
240
|
+
declare class ProductProjectionSearch {
|
|
241
|
+
protected _storage: AbstractStorage;
|
|
242
|
+
constructor(storage: AbstractStorage);
|
|
243
|
+
search(projectKey: string, params: ProductProjectionSearchParams): ProductProjectionPagedSearchResponse;
|
|
244
|
+
transform(product: Product, staged: boolean): ProductProjection;
|
|
245
|
+
getFacets(params: ProductProjectionSearchParams, products: ProductProjection[]): FacetResults;
|
|
246
|
+
/**
|
|
247
|
+
* TODO: This implemention needs the following additional features:
|
|
248
|
+
* - counting products
|
|
249
|
+
* - correct dataType
|
|
250
|
+
*/
|
|
251
|
+
termFacet(facet: string, products: ProductProjection[]): TermFacetResult;
|
|
252
|
+
filterFacet(source: string, filters: FilterExpression[] | undefined, products: ProductProjection[]): FilteredFacetResult;
|
|
253
|
+
rangeFacet(source: string, ranges: RangeExpression[] | undefined, products: ProductProjection[]): RangeFacetResult;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare class ProductProjectionRepository extends AbstractResourceRepository<'product-projection'> {
|
|
257
|
+
protected _searchService: ProductProjectionSearch;
|
|
258
|
+
constructor(storage: AbstractStorage);
|
|
259
|
+
getTypeId(): "product-projection";
|
|
260
|
+
create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
|
|
261
|
+
query(context: RepositoryContext, params?: QueryParams): {
|
|
262
|
+
results: ProductProjection[];
|
|
263
|
+
limit: number;
|
|
264
|
+
offset: number;
|
|
265
|
+
count: number;
|
|
266
|
+
total?: number | undefined;
|
|
218
267
|
};
|
|
268
|
+
search(context: RepositoryContext, query: ParsedQs): ctp.ProductProjectionPagedSearchResponse;
|
|
269
|
+
actions: {};
|
|
219
270
|
}
|
|
220
271
|
|
|
221
|
-
declare class
|
|
222
|
-
getTypeId():
|
|
272
|
+
declare class ProductSelectionRepository extends AbstractResourceRepository<'product-selection'> {
|
|
273
|
+
getTypeId(): "product-selection";
|
|
274
|
+
create(context: RepositoryContext, draft: ProductSelectionDraft): ProductSelection;
|
|
275
|
+
actions: Partial<Record<ReviewUpdateAction['action'], (context: RepositoryContext, resource: Writable<Review>, action: any) => void>>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
declare class ProductTypeRepository extends AbstractResourceRepository<'product-type'> {
|
|
279
|
+
getTypeId(): "product-type";
|
|
223
280
|
create(context: RepositoryContext, draft: ProductTypeDraft): ProductType;
|
|
224
281
|
attributeDefinitionFromAttributeDefinitionDraft: (_context: RepositoryContext, draft: AttributeDefinitionDraft) => AttributeDefinition;
|
|
225
|
-
getWithKey(context: RepositoryContext, key: string): ProductType | undefined;
|
|
226
282
|
actions: Partial<Record<ProductTypeUpdateAction['action'], (context: RepositoryContext, resource: Writable<ProductType>, action: any) => void>>;
|
|
227
283
|
}
|
|
228
284
|
|
|
229
|
-
declare class
|
|
230
|
-
|
|
285
|
+
declare class ProjectRepository extends AbstractRepository<Project> {
|
|
286
|
+
get(context: RepositoryContext): Project | null;
|
|
287
|
+
postProcessResource(resource: Project): Project;
|
|
288
|
+
saveNew(context: RepositoryContext, resource: Writable<Project>): void;
|
|
289
|
+
saveUpdate(context: RepositoryContext, version: number, resource: Project): void;
|
|
290
|
+
actions: Partial<Record<ProjectUpdateAction['action'], (context: RepositoryContext, resource: Writable<Project>, action: any) => void>>;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare class QuoteRepository extends AbstractResourceRepository<'quote'> {
|
|
294
|
+
getTypeId(): "quote";
|
|
295
|
+
create(context: RepositoryContext, draft: QuoteDraft): Quote;
|
|
296
|
+
actions: Partial<Record<QuoteUpdateAction['action'], (context: RepositoryContext, resource: Writable<Quote>, action: any) => void>>;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
declare class QuoteRequestRepository extends AbstractResourceRepository<'quote-request'> {
|
|
300
|
+
getTypeId(): "quote-request";
|
|
301
|
+
create(context: RepositoryContext, draft: QuoteRequestDraft): QuoteRequest;
|
|
302
|
+
actions: Partial<Record<QuoteRequestUpdateAction['action'], (context: RepositoryContext, resource: Writable<QuoteRequest>, action: any) => void>>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
declare class ReviewRepository extends AbstractResourceRepository<'review'> {
|
|
306
|
+
getTypeId(): "review";
|
|
307
|
+
create(context: RepositoryContext, draft: ReviewDraft): Review;
|
|
308
|
+
actions: Partial<Record<ReviewUpdateAction['action'], (context: RepositoryContext, resource: Writable<Review>, action: any) => void>>;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
declare class ShippingMethodRepository extends AbstractResourceRepository<'shipping-method'> {
|
|
312
|
+
getTypeId(): "shipping-method";
|
|
231
313
|
create(context: RepositoryContext, draft: ShippingMethodDraft): ShippingMethod;
|
|
232
314
|
private _transformZoneRateDraft;
|
|
233
315
|
private _transformShippingRate;
|
|
234
316
|
actions: Partial<Record<ShippingMethodUpdateAction['action'], (context: RepositoryContext, resource: Writable<ShippingMethod>, action: any) => void>>;
|
|
235
317
|
}
|
|
236
318
|
|
|
237
|
-
declare class
|
|
238
|
-
getTypeId():
|
|
319
|
+
declare class ShoppingListRepository extends AbstractResourceRepository<'shopping-list'> {
|
|
320
|
+
getTypeId(): "shopping-list";
|
|
321
|
+
create(context: RepositoryContext, draft: ShoppingListDraft): ShoppingList;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
declare class StagedQuoteRepository extends AbstractResourceRepository<'staged-quote'> {
|
|
325
|
+
getTypeId(): "staged-quote";
|
|
326
|
+
create(context: RepositoryContext, draft: StagedQuoteDraft): StagedQuote;
|
|
327
|
+
actions: Partial<Record<StagedQuoteUpdateAction['action'], (context: RepositoryContext, resource: Writable<Quote>, action: any) => void>>;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
declare class StandAlonePriceRepository extends AbstractResourceRepository<'standalone-price'> {
|
|
331
|
+
getTypeId(): "standalone-price";
|
|
332
|
+
create(context: RepositoryContext, draft: StandalonePrice): StandalonePrice;
|
|
333
|
+
actions: Partial<Record<StandalonePriceUpdateAction['action'], (context: RepositoryContext, resource: Writable<Review>, action: any) => void>>;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
declare class StateRepository extends AbstractResourceRepository<'state'> {
|
|
337
|
+
getTypeId(): "state";
|
|
239
338
|
create(context: RepositoryContext, draft: StateDraft): State;
|
|
240
339
|
actions: Partial<Record<StateUpdateAction['action'], (context: RepositoryContext, resource: Writable<State>, action: any) => void>>;
|
|
241
340
|
}
|
|
242
341
|
|
|
243
|
-
declare class
|
|
244
|
-
getTypeId():
|
|
342
|
+
declare class StoreRepository extends AbstractResourceRepository<'store'> {
|
|
343
|
+
getTypeId(): "store";
|
|
344
|
+
create(context: RepositoryContext, draft: StoreDraft): Store;
|
|
345
|
+
private transformChannels;
|
|
346
|
+
actions: Partial<Record<StoreUpdateAction['action'], (context: RepositoryContext, resource: Writable<Store>, action: any) => void>>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
declare class SubscriptionRepository extends AbstractResourceRepository<'subscription'> {
|
|
350
|
+
getTypeId(): "subscription";
|
|
351
|
+
create(context: RepositoryContext, draft: SubscriptionDraft): Subscription;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
declare class TaxCategoryRepository extends AbstractResourceRepository<'tax-category'> {
|
|
355
|
+
getTypeId(): "tax-category";
|
|
245
356
|
create(context: RepositoryContext, draft: TaxCategoryDraft): TaxCategory;
|
|
246
357
|
private taxRateFromTaxRateDraft;
|
|
247
|
-
getWithKey(context: RepositoryContext, key: string): TaxCategory | undefined;
|
|
248
358
|
actions: Partial<Record<TaxCategoryUpdateAction['action'], (context: RepositoryContext, resource: Writable<TaxCategory>, action: any) => void>>;
|
|
249
359
|
}
|
|
250
360
|
|
|
251
|
-
declare class
|
|
252
|
-
getTypeId():
|
|
253
|
-
create(context: RepositoryContext, draft:
|
|
254
|
-
|
|
255
|
-
getWithKey(context: RepositoryContext, key: string): ProductDiscount | undefined;
|
|
256
|
-
actions: Partial<Record<ProductDiscountUpdateAction['action'], (context: RepositoryContext, resource: Writable<ProductDiscount>, action: any) => void>>;
|
|
361
|
+
declare class TypeRepository extends AbstractResourceRepository<'type'> {
|
|
362
|
+
getTypeId(): "type";
|
|
363
|
+
create(context: RepositoryContext, draft: TypeDraft): Type;
|
|
364
|
+
actions: Partial<Record<TypeUpdateAction['action'], (context: RepositoryContext, resource: Writable<Type>, action: any) => void>>;
|
|
257
365
|
}
|
|
258
366
|
|
|
367
|
+
declare class ZoneRepository extends AbstractResourceRepository<'zone'> {
|
|
368
|
+
getTypeId(): "zone";
|
|
369
|
+
create(context: RepositoryContext, draft: ZoneDraft): Zone;
|
|
370
|
+
actions: Partial<Record<ZoneUpdateAction['action'], (context: RepositoryContext, resource: Writable<Zone>, action: any) => void>>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
declare type RepositoryMap = ReturnType<typeof createRepositories>;
|
|
374
|
+
declare const createRepositories: (storage: AbstractStorage) => {
|
|
375
|
+
category: CategoryRepository;
|
|
376
|
+
cart: CartRepository;
|
|
377
|
+
'cart-discount': CartDiscountRepository;
|
|
378
|
+
customer: CustomerRepository;
|
|
379
|
+
channel: ChannelRepository;
|
|
380
|
+
'customer-group': CustomerGroupRepository;
|
|
381
|
+
'discount-code': DiscountCodeRepository;
|
|
382
|
+
extension: ExtensionRepository;
|
|
383
|
+
'inventory-entry': InventoryEntryRepository;
|
|
384
|
+
'key-value-document': CustomObjectRepository;
|
|
385
|
+
order: OrderRepository;
|
|
386
|
+
'order-edit': OrderEditRepository;
|
|
387
|
+
payment: PaymentRepository;
|
|
388
|
+
'my-cart': CartRepository;
|
|
389
|
+
'my-order': MyOrderRepository;
|
|
390
|
+
'my-customer': CustomerRepository;
|
|
391
|
+
'my-payment': PaymentRepository;
|
|
392
|
+
product: ProductRepository;
|
|
393
|
+
'product-type': ProductTypeRepository;
|
|
394
|
+
'product-discount': ProductDiscountRepository;
|
|
395
|
+
'product-projection': ProductProjectionRepository;
|
|
396
|
+
'product-selection': ProductSelectionRepository;
|
|
397
|
+
project: ProjectRepository;
|
|
398
|
+
review: ReviewRepository;
|
|
399
|
+
quote: QuoteRepository;
|
|
400
|
+
'quote-request': QuoteRequestRepository;
|
|
401
|
+
'shipping-method': ShippingMethodRepository;
|
|
402
|
+
'shopping-list': ShoppingListRepository;
|
|
403
|
+
'staged-quote': StagedQuoteRepository;
|
|
404
|
+
'standalone-price': StandAlonePriceRepository;
|
|
405
|
+
state: StateRepository;
|
|
406
|
+
store: StoreRepository;
|
|
407
|
+
subscription: SubscriptionRepository;
|
|
408
|
+
'tax-category': TaxCategoryRepository;
|
|
409
|
+
type: TypeRepository;
|
|
410
|
+
zone: ZoneRepository;
|
|
411
|
+
};
|
|
412
|
+
|
|
259
413
|
declare type Writable<T> = {
|
|
260
414
|
-readonly [P in keyof T]: Writable<T[P]>;
|
|
261
415
|
};
|
|
262
|
-
declare type
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}>;
|
|
416
|
+
declare type ShallowWritable<T> = {
|
|
417
|
+
-readonly [P in keyof T]: T[P];
|
|
418
|
+
};
|
|
419
|
+
declare type ResourceType = keyof ResourceMap & keyof RepositoryMap;
|
|
267
420
|
declare type ResourceMap = {
|
|
268
|
-
cart: ctp.Cart;
|
|
269
421
|
'cart-discount': ctp.CartDiscount;
|
|
422
|
+
cart: ctp.Cart;
|
|
270
423
|
category: ctp.Category;
|
|
271
424
|
channel: ctp.Channel;
|
|
272
|
-
customer:
|
|
425
|
+
'customer-email-token': never;
|
|
273
426
|
'customer-group': ctp.CustomerGroup;
|
|
427
|
+
'customer-password-token': never;
|
|
428
|
+
customer: ctp.Customer;
|
|
274
429
|
'discount-code': ctp.DiscountCode;
|
|
275
430
|
extension: ctp.Extension;
|
|
276
431
|
'inventory-entry': ctp.InventoryEntry;
|
|
277
432
|
'key-value-document': ctp.CustomObject;
|
|
278
|
-
order: ctp.Order;
|
|
279
433
|
'order-edit': ctp.OrderEdit;
|
|
434
|
+
order: ctp.Order;
|
|
280
435
|
payment: ctp.Payment;
|
|
281
|
-
product: ctp.Product;
|
|
282
436
|
'product-discount': ctp.ProductDiscount;
|
|
437
|
+
'product-price': ctp.StandalonePrice;
|
|
283
438
|
'product-projection': ctp.ProductProjection;
|
|
284
439
|
'product-selection': ctp.ProductSelection;
|
|
285
|
-
'product-price': ctp.StandalonePrice;
|
|
286
440
|
'product-type': ctp.ProductType;
|
|
441
|
+
product: ctp.Product;
|
|
442
|
+
'quote-request': ctp.QuoteRequest;
|
|
443
|
+
quote: ctp.Quote;
|
|
287
444
|
review: ctp.Review;
|
|
288
445
|
'shipping-method': ctp.ShippingMethod;
|
|
289
446
|
'shopping-list': ctp.ShoppingList;
|
|
447
|
+
'staged-quote': ctp.StagedQuote;
|
|
290
448
|
'standalone-price': ctp.StandalonePrice;
|
|
291
449
|
state: ctp.State;
|
|
292
450
|
store: ctp.Store;
|
|
@@ -294,38 +452,42 @@ declare type ResourceMap = {
|
|
|
294
452
|
'tax-category': ctp.TaxCategory;
|
|
295
453
|
type: ctp.Type;
|
|
296
454
|
zone: ctp.Zone;
|
|
297
|
-
'customer-email-token': never;
|
|
298
|
-
'customer-password-token': never;
|
|
299
455
|
};
|
|
300
|
-
declare type
|
|
301
|
-
cart:
|
|
302
|
-
|
|
303
|
-
category:
|
|
304
|
-
channel:
|
|
305
|
-
customer: CustomerRepository;
|
|
456
|
+
declare type PagedQueryResponseMap = {
|
|
457
|
+
'cart-discount': ctp.CartDiscountPagedQueryResponse;
|
|
458
|
+
cart: ctp.CartPagedQueryResponse;
|
|
459
|
+
category: ctp.CategoryPagedQueryResponse;
|
|
460
|
+
channel: ctp.ChannelPagedQueryResponse;
|
|
306
461
|
'customer-email-token': never;
|
|
307
|
-
'customer-group':
|
|
462
|
+
'customer-group': ctp.CustomerGroupPagedQueryResponse;
|
|
308
463
|
'customer-password-token': never;
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
'
|
|
313
|
-
|
|
314
|
-
'order-edit':
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
'product-
|
|
318
|
-
'product-
|
|
319
|
-
'product-
|
|
320
|
-
|
|
321
|
-
'
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
'
|
|
327
|
-
|
|
328
|
-
|
|
464
|
+
customer: ctp.CustomerPagedQueryResponse;
|
|
465
|
+
'discount-code': ctp.DiscountCodePagedQueryResponse;
|
|
466
|
+
extension: ctp.ExtensionPagedQueryResponse;
|
|
467
|
+
'inventory-entry': ctp.InventoryPagedQueryResponse;
|
|
468
|
+
'key-value-document': ctp.CustomObjectPagedQueryResponse;
|
|
469
|
+
'order-edit': ctp.OrderEditPagedQueryResponse;
|
|
470
|
+
order: ctp.OrderPagedQueryResponse;
|
|
471
|
+
payment: ctp.PaymentPagedQueryResponse;
|
|
472
|
+
'product-discount': ctp.ProductDiscountPagedQueryResponse;
|
|
473
|
+
'product-price': ctp.StandalonePricePagedQueryResponse;
|
|
474
|
+
'product-projection': ctp.ProductProjectionPagedQueryResponse;
|
|
475
|
+
'product-selection': ctp.ProductSelectionPagedQueryResponse;
|
|
476
|
+
'product-type': ctp.ProductTypePagedQueryResponse;
|
|
477
|
+
product: ctp.ProductPagedQueryResponse;
|
|
478
|
+
'quote-request': ctp.QuoteRequestPagedQueryResponse;
|
|
479
|
+
quote: ctp.QuotePagedQueryResponse;
|
|
480
|
+
review: ctp.ReviewPagedQueryResponse;
|
|
481
|
+
'shipping-method': ctp.ShippingMethodPagedQueryResponse;
|
|
482
|
+
'shopping-list': ctp.ShoppingListPagedQueryResponse;
|
|
483
|
+
'staged-quote': ctp.StagedQuotePagedQueryResponse;
|
|
484
|
+
'standalone-price': ctp.StandalonePricePagedQueryResponse;
|
|
485
|
+
state: ctp.StatePagedQueryResponse;
|
|
486
|
+
store: ctp.StorePagedQueryResponse;
|
|
487
|
+
subscription: ctp.SubscriptionPagedQueryResponse;
|
|
488
|
+
'tax-category': ctp.TaxCategoryPagedQueryResponse;
|
|
489
|
+
type: ctp.TypePagedQueryResponse;
|
|
490
|
+
zone: ctp.ZonePagedQueryResponse;
|
|
329
491
|
};
|
|
330
492
|
|
|
331
493
|
declare type QueryParams = {
|
|
@@ -341,33 +503,36 @@ declare type RepositoryContext = {
|
|
|
341
503
|
projectKey: string;
|
|
342
504
|
storeKey?: string;
|
|
343
505
|
};
|
|
344
|
-
declare abstract class AbstractRepository {
|
|
506
|
+
declare abstract class AbstractRepository<R extends BaseResource | Project> {
|
|
345
507
|
protected _storage: AbstractStorage;
|
|
346
508
|
protected actions: Partial<Record<any, (context: RepositoryContext, resource: any, action: any) => void>>;
|
|
347
509
|
constructor(storage: AbstractStorage);
|
|
348
|
-
abstract
|
|
349
|
-
|
|
350
|
-
|
|
510
|
+
abstract saveNew({ projectKey }: RepositoryContext, resource: R): void;
|
|
511
|
+
abstract saveUpdate({ projectKey }: RepositoryContext, version: number, resource: R): void;
|
|
512
|
+
processUpdateActions(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
|
|
513
|
+
abstract postProcessResource(resource: any): any;
|
|
351
514
|
}
|
|
352
|
-
declare abstract class AbstractResourceRepository extends AbstractRepository {
|
|
353
|
-
abstract create(context: RepositoryContext, draft: any):
|
|
354
|
-
abstract getTypeId():
|
|
515
|
+
declare abstract class AbstractResourceRepository<T extends ResourceType> extends AbstractRepository<ResourceMap[T]> {
|
|
516
|
+
abstract create(context: RepositoryContext, draft: any): ResourceMap[T];
|
|
517
|
+
abstract getTypeId(): T;
|
|
355
518
|
constructor(storage: AbstractStorage);
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
519
|
+
postProcessResource(resource: ResourceMap[T]): ResourceMap[T];
|
|
520
|
+
query(context: RepositoryContext, params?: QueryParams): PagedQueryResponseMap[T];
|
|
521
|
+
get(context: RepositoryContext, id: string, params?: GetParams): ResourceMap[T] | null;
|
|
522
|
+
getByKey(context: RepositoryContext, key: string, params?: GetParams): ResourceMap[T] | null;
|
|
523
|
+
delete(context: RepositoryContext, id: string, params?: GetParams): ResourceMap[T] | null;
|
|
524
|
+
saveNew(context: RepositoryContext, resource: ShallowWritable<ResourceMap[T]>): void;
|
|
525
|
+
saveUpdate(context: RepositoryContext, version: number, resource: ShallowWritable<ResourceMap[T]>): ShallowWritable<ResourceMap[T]>;
|
|
361
526
|
}
|
|
362
527
|
|
|
363
528
|
declare class ProjectAPI {
|
|
364
529
|
private projectKey;
|
|
365
530
|
private _storage;
|
|
366
|
-
private
|
|
367
|
-
constructor(projectKey: string,
|
|
368
|
-
add(typeId:
|
|
369
|
-
get<RT extends
|
|
370
|
-
getRepository<RT extends keyof RepositoryMap>(typeId:
|
|
531
|
+
private _repositories;
|
|
532
|
+
constructor(projectKey: string, repositories: RepositoryMap, storage: AbstractStorage);
|
|
533
|
+
add<T extends keyof RepositoryMap & keyof ResourceMap>(typeId: T, resource: ResourceMap[T]): void;
|
|
534
|
+
get<RT extends ResourceType>(typeId: RT, id: string, params?: GetParams): ResourceMap[RT];
|
|
535
|
+
getRepository<RT extends keyof RepositoryMap>(typeId: RT): RepositoryMap[RT];
|
|
371
536
|
}
|
|
372
537
|
|
|
373
538
|
declare type CommercetoolsMockOptions = {
|
|
@@ -388,6 +553,7 @@ declare class CommercetoolsMock {
|
|
|
388
553
|
private _oauth2;
|
|
389
554
|
private _nockScopes;
|
|
390
555
|
private _services;
|
|
556
|
+
private _repositories;
|
|
391
557
|
private _projectService?;
|
|
392
558
|
constructor(options?: Partial<CommercetoolsMockOptions>);
|
|
393
559
|
start(): void;
|