@labdigital/commercetools-mock 0.10.0 → 0.11.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.d.ts +353 -188
- package/dist/index.global.js +1007 -876
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +348 -217
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +348 -217
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/ctMock.ts +15 -9
- package/src/helpers.ts +1 -1
- package/src/lib/projectionSearchFilter.ts +3 -2
- package/src/priceSelector.test.ts +1 -3
- package/src/product-projection-search.ts +1 -3
- package/src/projectAPI.test.ts +7 -0
- package/src/projectAPI.ts +17 -22
- package/src/repositories/abstract.ts +31 -24
- package/src/repositories/cart-discount.ts +3 -4
- package/src/repositories/cart.ts +20 -15
- package/src/repositories/category.ts +6 -7
- package/src/repositories/channel.ts +4 -5
- package/src/repositories/custom-object.ts +9 -13
- package/src/repositories/customer-group.ts +3 -4
- package/src/repositories/customer.ts +4 -5
- package/src/repositories/discount-code.ts +4 -5
- package/src/repositories/errors.ts +1 -3
- package/src/repositories/extension.ts +7 -8
- package/src/repositories/helpers.ts +2 -2
- package/src/repositories/index.ts +19 -3
- package/src/repositories/inventory-entry.ts +4 -5
- 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 +15 -8
- package/src/repositories/payment.ts +6 -7
- package/src/repositories/product-discount.ts +4 -24
- package/src/repositories/product-projection.ts +11 -5
- package/src/repositories/product-selection.ts +40 -0
- package/src/repositories/product-type.ts +11 -28
- package/src/repositories/product.ts +117 -10
- package/src/repositories/project.ts +9 -8
- 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 +10 -11
- package/src/repositories/shopping-list.ts +4 -4
- package/src/repositories/staged-quote.ts +29 -0
- package/src/repositories/standalone-price.ts +36 -0
- package/src/repositories/state.ts +15 -8
- package/src/repositories/store.ts +11 -27
- package/src/repositories/subscription.ts +3 -4
- package/src/repositories/tax-category.ts +5 -22
- package/src/repositories/type.ts +12 -13
- package/src/repositories/zone.ts +4 -5
- package/src/server.ts +4 -4
- package/src/services/abstract.ts +3 -5
- package/src/services/cart-discount.ts +1 -1
- package/src/services/cart.test.ts +1 -1
- package/src/services/cart.ts +40 -33
- package/src/services/category.ts +1 -1
- package/src/services/channel.ts +1 -1
- package/src/services/custom-object.test.ts +1 -1
- package/src/services/custom-object.ts +2 -2
- package/src/services/customer-group.ts +1 -1
- package/src/services/customer.test.ts +1 -1
- package/src/services/customer.ts +3 -3
- package/src/services/discount-code.ts +1 -1
- package/src/services/extension.ts +1 -1
- package/src/services/inventory-entry.test.ts +1 -1
- package/src/services/inventory-entry.ts +1 -1
- package/src/services/my-cart.test.ts +2 -0
- package/src/services/my-cart.ts +1 -1
- package/src/services/my-customer.ts +1 -1
- package/src/services/my-order.ts +1 -1
- package/src/services/my-payment.ts +1 -1
- package/src/services/order.test.ts +24 -20
- package/src/services/order.ts +2 -2
- package/src/services/payment.ts +1 -1
- package/src/services/product-discount.ts +1 -17
- package/src/services/product-projection.test.ts +1 -1
- package/src/services/product-projection.ts +2 -2
- package/src/services/product-type.ts +1 -17
- package/src/services/product.test.ts +63 -2
- package/src/services/product.ts +1 -1
- package/src/services/project.ts +4 -5
- package/src/services/shipping-method.ts +1 -1
- package/src/services/shopping-list.ts +1 -1
- package/src/services/state.ts +1 -1
- package/src/services/store.ts +2 -18
- package/src/services/subscription.ts +1 -1
- package/src/services/tax-category.ts +1 -17
- package/src/services/type.ts +1 -1
- package/src/services/zone.ts +1 -1
- package/src/storage/abstract.ts +82 -0
- package/src/{storage.ts → storage/in-memory.ts} +57 -118
- package/src/storage/index.ts +2 -0
- package/src/types.ts +48 -119
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,108 +17,21 @@ declare type QueryParams$1 = {
|
|
|
17
17
|
};
|
|
18
18
|
declare abstract class AbstractStorage {
|
|
19
19
|
abstract clear(): void;
|
|
20
|
-
abstract all<RT extends
|
|
21
|
-
abstract add<RT extends
|
|
22
|
-
abstract get<RT extends
|
|
23
|
-
abstract getByKey<RT extends
|
|
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;
|
|
24
24
|
abstract addProject(projectKey: string): Project;
|
|
25
25
|
abstract getProject(projectKey: string): Project;
|
|
26
26
|
abstract saveProject(project: Project): Project;
|
|
27
|
-
abstract delete<RT extends
|
|
28
|
-
abstract query(projectKey: string, typeId:
|
|
29
|
-
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;
|
|
30
30
|
abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
declare type RangeExpression = {
|
|
38
|
-
type: 'RangeExpression';
|
|
39
|
-
start?: number;
|
|
40
|
-
stop?: number;
|
|
41
|
-
match: (obj: any) => boolean;
|
|
42
|
-
};
|
|
43
|
-
declare type FilterExpression = {
|
|
44
|
-
type: 'FilterExpression';
|
|
45
|
-
match: (obj: any) => boolean;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
declare type ProductProjectionSearchParams = {
|
|
49
|
-
fuzzy?: boolean;
|
|
50
|
-
fuzzyLevel?: number;
|
|
51
|
-
markMatchingVariants?: boolean;
|
|
52
|
-
staged?: boolean;
|
|
53
|
-
filter?: string[];
|
|
54
|
-
'filter.facets'?: string[];
|
|
55
|
-
'filter.query'?: string[];
|
|
56
|
-
facet?: string | string[];
|
|
57
|
-
sort?: string | string[];
|
|
58
|
-
limit?: number;
|
|
59
|
-
offset?: number;
|
|
60
|
-
withTotal?: boolean;
|
|
61
|
-
priceCurrency?: string;
|
|
62
|
-
priceCountry?: string;
|
|
63
|
-
priceCustomerGroup?: string;
|
|
64
|
-
priceChannel?: string;
|
|
65
|
-
localeProjection?: string;
|
|
66
|
-
storeProjection?: string;
|
|
67
|
-
expand?: string | string[];
|
|
68
|
-
[key: string]: QueryParam;
|
|
69
|
-
};
|
|
70
|
-
declare class ProductProjectionSearch {
|
|
71
|
-
protected _storage: AbstractStorage;
|
|
72
|
-
constructor(storage: AbstractStorage);
|
|
73
|
-
search(projectKey: string, params: ProductProjectionSearchParams): ProductProjectionPagedSearchResponse;
|
|
74
|
-
transform(product: Product, staged: boolean): ProductProjection | null;
|
|
75
|
-
getFacets(params: ProductProjectionSearchParams, products: ProductProjection[]): FacetResults;
|
|
76
|
-
/**
|
|
77
|
-
* TODO: This implemention needs the following additional features:
|
|
78
|
-
* - counting products
|
|
79
|
-
* - correct dataType
|
|
80
|
-
*/
|
|
81
|
-
termFacet(facet: string, products: ProductProjection[]): TermFacetResult;
|
|
82
|
-
filterFacet(source: string, filters: FilterExpression[] | undefined, products: ProductProjection[]): FilteredFacetResult;
|
|
83
|
-
rangeFacet(source: string, ranges: RangeExpression[] | undefined, products: ProductProjection[]): RangeFacetResult;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
declare class ProductProjectionRepository extends AbstractResourceRepository {
|
|
87
|
-
protected _searchService: ProductProjectionSearch;
|
|
88
|
-
constructor(storage: AbstractStorage);
|
|
89
|
-
getTypeId(): RepositoryTypes;
|
|
90
|
-
create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
|
|
91
|
-
query(context: RepositoryContext, params?: QueryParams): ctp.PagedQueryResponse;
|
|
92
|
-
search(context: RepositoryContext, query: ParsedQs): ctp.ProductProjectionPagedSearchResponse;
|
|
93
|
-
actions: {};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
declare class ShoppingListRepository extends AbstractResourceRepository {
|
|
97
|
-
getTypeId(): ReferenceTypeId;
|
|
98
|
-
create(context: RepositoryContext, draft: ShoppingListDraft): ShoppingList;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
declare abstract class AbstractService {
|
|
102
|
-
protected abstract getBasePath(): string;
|
|
103
|
-
abstract repository: AbstractResourceRepository;
|
|
104
|
-
createStatusCode: number;
|
|
105
|
-
constructor(parent: Router);
|
|
106
|
-
extraRoutes(router: Router): void;
|
|
107
|
-
registerRoutes(parent: Router): void;
|
|
108
|
-
get(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
109
|
-
getWithId(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
110
|
-
getWithKey(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
111
|
-
deleteWithId(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
112
|
-
deleteWithKey(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
113
|
-
post(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
114
|
-
postWithId(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
115
|
-
postWithKey(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
116
|
-
protected _expandWithId(request: Request, resourceId: string): ctp.BaseResource | null;
|
|
117
|
-
private _parseParam;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
declare class CartRepository extends AbstractResourceRepository {
|
|
121
|
-
getTypeId(): ReferenceTypeId;
|
|
33
|
+
declare class CartRepository extends AbstractResourceRepository<'cart'> {
|
|
34
|
+
getTypeId(): "cart";
|
|
122
35
|
create(context: RepositoryContext, draft: CartDraft): Cart;
|
|
123
36
|
getActiveCart(projectKey: string): Cart | undefined;
|
|
124
37
|
actions: {
|
|
@@ -136,8 +49,45 @@ declare class CartRepository extends AbstractResourceRepository {
|
|
|
136
49
|
draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft, currency: string, country: string | undefined) => LineItem;
|
|
137
50
|
}
|
|
138
51
|
|
|
139
|
-
declare class
|
|
140
|
-
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";
|
|
141
91
|
create(context: RepositoryContext, draft: CustomerDraft): Customer;
|
|
142
92
|
getMe(context: RepositoryContext): Customer | undefined;
|
|
143
93
|
actions: {
|
|
@@ -146,14 +96,32 @@ declare class CustomerRepository extends AbstractResourceRepository {
|
|
|
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,82 +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
193
|
actions: Partial<Record<ProductUpdateAction['action'], (context: RepositoryContext, resource: Writable<Product>, action: any) => void>>;
|
|
216
194
|
}
|
|
217
195
|
|
|
218
|
-
declare class
|
|
219
|
-
getTypeId():
|
|
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;
|
|
267
|
+
};
|
|
268
|
+
search(context: RepositoryContext, query: ParsedQs): ctp.ProductProjectionPagedSearchResponse;
|
|
269
|
+
actions: {};
|
|
270
|
+
}
|
|
271
|
+
|
|
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";
|
|
220
280
|
create(context: RepositoryContext, draft: ProductTypeDraft): ProductType;
|
|
221
281
|
attributeDefinitionFromAttributeDefinitionDraft: (_context: RepositoryContext, draft: AttributeDefinitionDraft) => AttributeDefinition;
|
|
222
|
-
getWithKey(context: RepositoryContext, key: string): ProductType | undefined;
|
|
223
282
|
actions: Partial<Record<ProductTypeUpdateAction['action'], (context: RepositoryContext, resource: Writable<ProductType>, action: any) => void>>;
|
|
224
283
|
}
|
|
225
284
|
|
|
226
|
-
declare class
|
|
227
|
-
|
|
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";
|
|
228
313
|
create(context: RepositoryContext, draft: ShippingMethodDraft): ShippingMethod;
|
|
229
314
|
private _transformZoneRateDraft;
|
|
230
315
|
private _transformShippingRate;
|
|
231
316
|
actions: Partial<Record<ShippingMethodUpdateAction['action'], (context: RepositoryContext, resource: Writable<ShippingMethod>, action: any) => void>>;
|
|
232
317
|
}
|
|
233
318
|
|
|
234
|
-
declare class
|
|
235
|
-
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";
|
|
236
338
|
create(context: RepositoryContext, draft: StateDraft): State;
|
|
237
339
|
actions: Partial<Record<StateUpdateAction['action'], (context: RepositoryContext, resource: Writable<State>, action: any) => void>>;
|
|
238
340
|
}
|
|
239
341
|
|
|
240
|
-
declare class
|
|
241
|
-
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";
|
|
242
356
|
create(context: RepositoryContext, draft: TaxCategoryDraft): TaxCategory;
|
|
243
357
|
private taxRateFromTaxRateDraft;
|
|
244
|
-
getWithKey(context: RepositoryContext, key: string): TaxCategory | undefined;
|
|
245
358
|
actions: Partial<Record<TaxCategoryUpdateAction['action'], (context: RepositoryContext, resource: Writable<TaxCategory>, action: any) => void>>;
|
|
246
359
|
}
|
|
247
360
|
|
|
248
|
-
declare class
|
|
249
|
-
getTypeId():
|
|
250
|
-
create(context: RepositoryContext, draft:
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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>>;
|
|
365
|
+
}
|
|
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>>;
|
|
254
371
|
}
|
|
255
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
|
+
|
|
256
413
|
declare type Writable<T> = {
|
|
257
414
|
-readonly [P in keyof T]: Writable<T[P]>;
|
|
258
415
|
};
|
|
259
|
-
declare type
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}>;
|
|
264
|
-
declare type Resource = ctp.BaseResource | ctp.Cart | ctp.CartDiscount | ctp.Category | ctp.Channel | ctp.Customer | ctp.CustomerGroup | ctp.DiscountCode | ctp.Extension | ctp.InventoryEntry | ctp.CustomObject | ctp.Order | ctp.OrderEdit | ctp.Payment | ctp.Product | ctp.Project | ctp.ProductDiscount | ctp.ProductProjection | ctp.ProductSelection | ctp.StandalonePrice | ctp.ProductType | ctp.Review | ctp.ShippingMethod | ctp.ShoppingList | ctp.StandalonePrice | ctp.State | ctp.Store | ctp.Subscription | ctp.TaxCategory | ctp.Type | ctp.Zone;
|
|
416
|
+
declare type ShallowWritable<T> = {
|
|
417
|
+
-readonly [P in keyof T]: T[P];
|
|
418
|
+
};
|
|
419
|
+
declare type ResourceType = keyof ResourceMap & keyof RepositoryMap;
|
|
265
420
|
declare type ResourceMap = {
|
|
266
|
-
cart: ctp.Cart;
|
|
267
421
|
'cart-discount': ctp.CartDiscount;
|
|
422
|
+
cart: ctp.Cart;
|
|
268
423
|
category: ctp.Category;
|
|
269
424
|
channel: ctp.Channel;
|
|
270
|
-
customer:
|
|
425
|
+
'customer-email-token': never;
|
|
271
426
|
'customer-group': ctp.CustomerGroup;
|
|
427
|
+
'customer-password-token': never;
|
|
428
|
+
customer: ctp.Customer;
|
|
272
429
|
'discount-code': ctp.DiscountCode;
|
|
273
430
|
extension: ctp.Extension;
|
|
274
431
|
'inventory-entry': ctp.InventoryEntry;
|
|
275
432
|
'key-value-document': ctp.CustomObject;
|
|
276
|
-
order: ctp.Order;
|
|
277
433
|
'order-edit': ctp.OrderEdit;
|
|
434
|
+
order: ctp.Order;
|
|
278
435
|
payment: ctp.Payment;
|
|
279
|
-
product: ctp.Product;
|
|
280
436
|
'product-discount': ctp.ProductDiscount;
|
|
437
|
+
'product-price': ctp.StandalonePrice;
|
|
281
438
|
'product-projection': ctp.ProductProjection;
|
|
282
439
|
'product-selection': ctp.ProductSelection;
|
|
283
|
-
'product-price': ctp.StandalonePrice;
|
|
284
440
|
'product-type': ctp.ProductType;
|
|
441
|
+
product: ctp.Product;
|
|
442
|
+
'quote-request': ctp.QuoteRequest;
|
|
443
|
+
quote: ctp.Quote;
|
|
285
444
|
review: ctp.Review;
|
|
286
445
|
'shipping-method': ctp.ShippingMethod;
|
|
287
446
|
'shopping-list': ctp.ShoppingList;
|
|
447
|
+
'staged-quote': ctp.StagedQuote;
|
|
288
448
|
'standalone-price': ctp.StandalonePrice;
|
|
289
449
|
state: ctp.State;
|
|
290
450
|
store: ctp.Store;
|
|
@@ -292,38 +452,42 @@ declare type ResourceMap = {
|
|
|
292
452
|
'tax-category': ctp.TaxCategory;
|
|
293
453
|
type: ctp.Type;
|
|
294
454
|
zone: ctp.Zone;
|
|
295
|
-
'customer-email-token': never;
|
|
296
|
-
'customer-password-token': never;
|
|
297
455
|
};
|
|
298
|
-
declare type
|
|
299
|
-
cart:
|
|
300
|
-
|
|
301
|
-
category:
|
|
302
|
-
channel:
|
|
303
|
-
customer: CustomerRepository;
|
|
456
|
+
declare type PagedQueryResponseMap = {
|
|
457
|
+
'cart-discount': ctp.CartDiscountPagedQueryResponse;
|
|
458
|
+
cart: ctp.CartPagedQueryResponse;
|
|
459
|
+
category: ctp.CategoryPagedQueryResponse;
|
|
460
|
+
channel: ctp.ChannelPagedQueryResponse;
|
|
304
461
|
'customer-email-token': never;
|
|
305
|
-
'customer-group':
|
|
462
|
+
'customer-group': ctp.CustomerGroupPagedQueryResponse;
|
|
306
463
|
'customer-password-token': never;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
'
|
|
311
|
-
|
|
312
|
-
'order-edit':
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
'product-
|
|
316
|
-
'product-
|
|
317
|
-
'product-
|
|
318
|
-
|
|
319
|
-
'
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
'
|
|
325
|
-
|
|
326
|
-
|
|
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;
|
|
327
491
|
};
|
|
328
492
|
|
|
329
493
|
declare type QueryParams = {
|
|
@@ -339,35 +503,36 @@ declare type RepositoryContext = {
|
|
|
339
503
|
projectKey: string;
|
|
340
504
|
storeKey?: string;
|
|
341
505
|
};
|
|
342
|
-
declare abstract class AbstractRepository {
|
|
506
|
+
declare abstract class AbstractRepository<R extends BaseResource | Project> {
|
|
343
507
|
protected _storage: AbstractStorage;
|
|
344
508
|
protected actions: Partial<Record<any, (context: RepositoryContext, resource: any, action: any) => void>>;
|
|
345
509
|
constructor(storage: AbstractStorage);
|
|
346
|
-
abstract saveNew({ projectKey }: RepositoryContext, resource:
|
|
347
|
-
abstract saveUpdate({ projectKey }: RepositoryContext, version: number, resource:
|
|
348
|
-
processUpdateActions
|
|
349
|
-
postProcessResource
|
|
350
|
-
}
|
|
351
|
-
declare abstract class AbstractResourceRepository extends AbstractRepository {
|
|
352
|
-
abstract create(context: RepositoryContext, draft: any):
|
|
353
|
-
abstract getTypeId():
|
|
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;
|
|
514
|
+
}
|
|
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;
|
|
354
518
|
constructor(storage: AbstractStorage);
|
|
355
|
-
|
|
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 = {
|