@labdigital/commercetools-mock 2.42.1 → 2.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2514 -2501
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +179 -170
- package/dist/index.d.ts +179 -170
- package/dist/index.js +2523 -2510
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/config.ts +6 -0
- package/src/ctMock.ts +25 -14
- package/src/index.test.ts +20 -16
- package/src/oauth/server.test.ts +3 -1
- package/src/product-projection-search.ts +3 -2
- package/src/product-search.ts +3 -2
- package/src/projectAPI.ts +18 -6
- package/src/repositories/abstract.ts +8 -4
- package/src/repositories/associate-role.ts +3 -3
- package/src/repositories/attribute-group.ts +3 -3
- package/src/repositories/business-unit.ts +3 -3
- package/src/repositories/cart/index.test.ts +3 -1
- package/src/repositories/cart/index.ts +3 -3
- package/src/repositories/cart-discount/index.ts +4 -6
- package/src/repositories/category/index.test.ts +3 -1
- package/src/repositories/category/index.ts +3 -3
- package/src/repositories/channel.ts +3 -3
- package/src/repositories/custom-object.ts +3 -3
- package/src/repositories/customer/index.test.ts +3 -1
- package/src/repositories/customer/index.ts +4 -4
- package/src/repositories/customer-group.ts +4 -4
- package/src/repositories/discount-code/index.ts +4 -4
- package/src/repositories/extension.ts +4 -4
- package/src/repositories/index.ts +45 -45
- package/src/repositories/inventory-entry/index.ts +4 -4
- package/src/repositories/order/index.test.ts +6 -1
- package/src/repositories/order/index.ts +4 -4
- package/src/repositories/order-edit.ts +3 -3
- package/src/repositories/payment/index.ts +3 -3
- package/src/repositories/product/index.ts +10 -6
- package/src/repositories/product-discount.ts +3 -3
- package/src/repositories/product-projection.ts +4 -4
- package/src/repositories/product-selection.ts +3 -3
- package/src/repositories/product-tailoring.ts +3 -3
- package/src/repositories/product-type.ts +4 -4
- package/src/repositories/project.ts +4 -4
- package/src/repositories/quote-request.ts +3 -3
- package/src/repositories/quote.ts +3 -3
- package/src/repositories/review.ts +3 -3
- package/src/repositories/shipping-method/index.ts +4 -4
- package/src/repositories/shopping-list/index.ts +4 -4
- package/src/repositories/staged-quote.ts +3 -3
- package/src/repositories/standalone-price.ts +3 -3
- package/src/repositories/state.ts +4 -4
- package/src/repositories/store.ts +3 -2
- package/src/repositories/subscription.ts +4 -4
- package/src/repositories/tax-category/index.ts +3 -3
- package/src/repositories/type/index.ts +4 -4
- package/src/repositories/zone.ts +4 -4
- package/src/services/project.test.ts +1 -13
- package/src/services/store.test.ts +1 -13
- package/src/deprecation.ts +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { SetupServerApi, SetupServer } from 'msw/node';
|
|
3
3
|
import * as ctp from '@commercetools/platform-sdk';
|
|
4
|
-
import {
|
|
4
|
+
import { QueryParam, BaseResource, Project, UpdateAction, ProductTailoring, CartDraft, Cart, LineItemDraft, LineItem, OrderFromCartDraft, Order, CartReference, OrderImportDraft, AssociateRoleDraft, AssociateRole, AttributeGroupDraft, AttributeGroup, BusinessUnitDraft, BusinessUnit, CartDiscountDraft, CartDiscount, CategoryDraft, Category, ChannelDraft, Channel, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerCreatePasswordResetToken, CustomerToken, CustomerResetPassword, MyCustomerResetPassword, CustomerGroupDraft, CustomerGroup, DiscountCodeDraft, DiscountCode, ExtensionDraft, Extension, InventoryEntryDraft, InventoryEntry, MyCustomerChangePassword, MyCustomerEmailVerify, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, PaymentDraft, Payment, ProductSearchRequest, ProductPagedSearchResponse, Product, ProductProjection, ProductDraft, ProductDiscountDraft, ProductDiscount, ProductProjectionPagedSearchResponse, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductTypeDraft, ProductType, QuoteDraft, Quote, QuoteRequestDraft, QuoteRequest, ReviewDraft, Review, ShippingMethodDraft, ShippingMethod, ZoneReference, ShoppingListDraft, ShoppingList, ShoppingListLineItem, StagedQuoteDraft, StagedQuote, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, StateDraft, State, StoreDraft, Store, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TypeDraft, Type, ZoneDraft, Zone, ResourceIdentifier } from '@commercetools/platform-sdk';
|
|
5
5
|
|
|
6
6
|
type Token = {
|
|
7
7
|
access_token: string;
|
|
@@ -27,129 +27,14 @@ declare class OAuth2Store {
|
|
|
27
27
|
validateToken(token: string): boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
type Writable<T> = {
|
|
31
|
-
-readonly [P in keyof T]: Writable<T[P]>;
|
|
32
|
-
};
|
|
33
|
-
type ShallowWritable<T> = {
|
|
34
|
-
-readonly [P in keyof T]: T[P];
|
|
35
|
-
};
|
|
36
|
-
type ResourceType = keyof ResourceMap & keyof RepositoryMap;
|
|
37
|
-
type ResourceMap = {
|
|
38
|
-
"attribute-group": ctp.AttributeGroup;
|
|
39
|
-
"associate-role": ctp.AssociateRole;
|
|
40
|
-
"business-unit": ctp.BusinessUnit;
|
|
41
|
-
"cart-discount": ctp.CartDiscount;
|
|
42
|
-
"cart": ctp.Cart;
|
|
43
|
-
"category": ctp.Category;
|
|
44
|
-
"channel": ctp.Channel;
|
|
45
|
-
"customer-email-token": never;
|
|
46
|
-
"customer-group": ctp.CustomerGroup;
|
|
47
|
-
"customer-password-token": never;
|
|
48
|
-
"customer": ctp.Customer;
|
|
49
|
-
"discount-code": ctp.DiscountCode;
|
|
50
|
-
"extension": ctp.Extension;
|
|
51
|
-
"inventory-entry": ctp.InventoryEntry;
|
|
52
|
-
"key-value-document": ctp.CustomObject;
|
|
53
|
-
"order-edit": ctp.OrderEdit;
|
|
54
|
-
"order": ctp.Order;
|
|
55
|
-
"payment": ctp.Payment;
|
|
56
|
-
"product-discount": ctp.ProductDiscount;
|
|
57
|
-
"product-price": ctp.StandalonePrice;
|
|
58
|
-
"product-projection": ctp.ProductProjection;
|
|
59
|
-
"product-selection": ctp.ProductSelection;
|
|
60
|
-
"product-tailoring": ctp.ProductTailoring;
|
|
61
|
-
"product-type": ctp.ProductType;
|
|
62
|
-
"product": ctp.Product;
|
|
63
|
-
"quote-request": ctp.QuoteRequest;
|
|
64
|
-
"quote": ctp.Quote;
|
|
65
|
-
"review": ctp.Review;
|
|
66
|
-
"shipping-method": ctp.ShippingMethod;
|
|
67
|
-
"shopping-list": ctp.ShoppingList;
|
|
68
|
-
"staged-quote": ctp.StagedQuote;
|
|
69
|
-
"standalone-price": ctp.StandalonePrice;
|
|
70
|
-
"state": ctp.State;
|
|
71
|
-
"store": ctp.Store;
|
|
72
|
-
"subscription": ctp.Subscription;
|
|
73
|
-
"tax-category": ctp.TaxCategory;
|
|
74
|
-
"type": ctp.Type;
|
|
75
|
-
"zone": ctp.Zone;
|
|
76
|
-
};
|
|
77
|
-
type PagedQueryResponseMap = {
|
|
78
|
-
"attribute-group": ctp.AttributeGroupPagedQueryResponse;
|
|
79
|
-
"associate-role": ctp.AssociateRolePagedQueryResponse;
|
|
80
|
-
"business-unit": ctp.BusinessUnitPagedQueryResponse;
|
|
81
|
-
"cart-discount": ctp.CartDiscountPagedQueryResponse;
|
|
82
|
-
"cart": ctp.CartPagedQueryResponse;
|
|
83
|
-
"category": ctp.CategoryPagedQueryResponse;
|
|
84
|
-
"channel": ctp.ChannelPagedQueryResponse;
|
|
85
|
-
"customer-email-token": never;
|
|
86
|
-
"customer-group": ctp.CustomerGroupPagedQueryResponse;
|
|
87
|
-
"customer-password-token": never;
|
|
88
|
-
"customer": ctp.CustomerPagedQueryResponse;
|
|
89
|
-
"discount-code": ctp.DiscountCodePagedQueryResponse;
|
|
90
|
-
"extension": ctp.ExtensionPagedQueryResponse;
|
|
91
|
-
"inventory-entry": ctp.InventoryPagedQueryResponse;
|
|
92
|
-
"key-value-document": ctp.CustomObjectPagedQueryResponse;
|
|
93
|
-
"order-edit": ctp.OrderEditPagedQueryResponse;
|
|
94
|
-
"order": ctp.OrderPagedQueryResponse;
|
|
95
|
-
"payment": ctp.PaymentPagedQueryResponse;
|
|
96
|
-
"product-discount": ctp.ProductDiscountPagedQueryResponse;
|
|
97
|
-
"product-price": ctp.StandalonePricePagedQueryResponse;
|
|
98
|
-
"product-projection": ctp.ProductProjectionPagedQueryResponse;
|
|
99
|
-
"product-selection": ctp.ProductSelectionPagedQueryResponse;
|
|
100
|
-
"product-tailoring": ctp.ProductTailoringPagedQueryResponse;
|
|
101
|
-
"product-type": ctp.ProductTypePagedQueryResponse;
|
|
102
|
-
"product": ctp.ProductPagedQueryResponse;
|
|
103
|
-
"quote-request": ctp.QuoteRequestPagedQueryResponse;
|
|
104
|
-
"quote": ctp.QuotePagedQueryResponse;
|
|
105
|
-
"review": ctp.ReviewPagedQueryResponse;
|
|
106
|
-
"shipping-method": ctp.ShippingMethodPagedQueryResponse;
|
|
107
|
-
"shopping-list": ctp.ShoppingListPagedQueryResponse;
|
|
108
|
-
"staged-quote": ctp.StagedQuotePagedQueryResponse;
|
|
109
|
-
"standalone-price": ctp.StandalonePricePagedQueryResponse;
|
|
110
|
-
"state": ctp.StatePagedQueryResponse;
|
|
111
|
-
"store": ctp.StorePagedQueryResponse;
|
|
112
|
-
"subscription": ctp.SubscriptionPagedQueryResponse;
|
|
113
|
-
"tax-category": ctp.TaxCategoryPagedQueryResponse;
|
|
114
|
-
"type": ctp.TypePagedQueryResponse;
|
|
115
|
-
"zone": ctp.ZonePagedQueryResponse;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
type GetParams$1 = {
|
|
119
|
-
expand?: string[];
|
|
120
|
-
};
|
|
121
30
|
type QueryParams$1 = {
|
|
122
|
-
expand?: string | string[];
|
|
123
|
-
sort?: string | string[];
|
|
124
|
-
limit?: number;
|
|
125
|
-
offset?: number;
|
|
126
|
-
withTotal?: boolean;
|
|
127
|
-
where?: string | string[];
|
|
128
|
-
[key: string]: QueryParam;
|
|
129
|
-
};
|
|
130
|
-
declare abstract class AbstractStorage {
|
|
131
|
-
abstract clear(): void;
|
|
132
|
-
abstract all<RT extends ResourceType>(projectKey: string, typeId: RT): Array<ResourceMap[RT]>;
|
|
133
|
-
abstract add<RT extends ResourceType>(projectKey: string, typeId: RT, obj: ResourceMap[RT]): ResourceMap[RT];
|
|
134
|
-
abstract get<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params?: GetParams$1): ResourceMap[RT] | null;
|
|
135
|
-
abstract getByKey<RT extends ResourceType>(projectKey: string, typeId: RT, key: string, params: GetParams$1): ResourceMap[RT] | null;
|
|
136
|
-
abstract addProject(projectKey: string): Project;
|
|
137
|
-
abstract getProject(projectKey: string): Project;
|
|
138
|
-
abstract saveProject(project: Project): Project;
|
|
139
|
-
abstract delete<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params: GetParams$1): ResourceMap[RT] | null;
|
|
140
|
-
abstract query<RT extends ResourceType>(projectKey: string, typeId: RT, params: QueryParams$1): PagedQueryResponseMap[RT];
|
|
141
|
-
abstract getByResourceIdentifier<RT extends ResourceType>(projectKey: string, identifier: ResourceIdentifier): ResourceMap[RT];
|
|
142
|
-
abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
type QueryParams = {
|
|
146
31
|
expand?: string[];
|
|
147
32
|
where?: string[];
|
|
148
33
|
offset?: number;
|
|
149
34
|
limit?: number;
|
|
150
35
|
[key: string]: QueryParam;
|
|
151
36
|
};
|
|
152
|
-
type GetParams = {
|
|
37
|
+
type GetParams$1 = {
|
|
153
38
|
expand?: string[];
|
|
154
39
|
};
|
|
155
40
|
type RepositoryContext = {
|
|
@@ -158,8 +43,9 @@ type RepositoryContext = {
|
|
|
158
43
|
};
|
|
159
44
|
declare abstract class AbstractRepository<R extends BaseResource | Project> {
|
|
160
45
|
protected _storage: AbstractStorage;
|
|
46
|
+
protected config: Config;
|
|
161
47
|
protected actions: AbstractUpdateHandler | undefined;
|
|
162
|
-
constructor(
|
|
48
|
+
constructor(config: Config);
|
|
163
49
|
abstract saveNew({ projectKey }: RepositoryContext, resource: R): void;
|
|
164
50
|
abstract saveUpdate({ projectKey }: RepositoryContext, version: number, resource: R): void;
|
|
165
51
|
abstract postProcessResource(context: RepositoryContext, resource: any): any;
|
|
@@ -167,14 +53,14 @@ declare abstract class AbstractRepository<R extends BaseResource | Project> {
|
|
|
167
53
|
}
|
|
168
54
|
declare abstract class AbstractResourceRepository<T extends ResourceType> extends AbstractRepository<ResourceMap[T]> {
|
|
169
55
|
protected _typeId: T;
|
|
170
|
-
constructor(typeId: T,
|
|
56
|
+
constructor(typeId: T, config: Config);
|
|
171
57
|
abstract create(context: RepositoryContext, draft: any): ResourceMap[T];
|
|
172
58
|
protected getTypeId(): T;
|
|
173
|
-
delete(context: RepositoryContext, id: string, params?: GetParams): ResourceMap[T] | null;
|
|
174
|
-
get(context: RepositoryContext, id: string, params?: GetParams): ResourceMap[T] | null;
|
|
175
|
-
getByKey(context: RepositoryContext, key: string, params?: GetParams): ResourceMap[T] | null;
|
|
176
|
-
postProcessResource(context: RepositoryContext, resource: ResourceMap[T], params?: GetParams): ResourceMap[T];
|
|
177
|
-
query(context: RepositoryContext, params?: QueryParams): PagedQueryResponseMap[T] & {
|
|
59
|
+
delete(context: RepositoryContext, id: string, params?: GetParams$1): ResourceMap[T] | null;
|
|
60
|
+
get(context: RepositoryContext, id: string, params?: GetParams$1): ResourceMap[T] | null;
|
|
61
|
+
getByKey(context: RepositoryContext, key: string, params?: GetParams$1): ResourceMap[T] | null;
|
|
62
|
+
postProcessResource(context: RepositoryContext, resource: ResourceMap[T], params?: GetParams$1): ResourceMap[T];
|
|
63
|
+
query(context: RepositoryContext, params?: QueryParams$1): PagedQueryResponseMap[T] & {
|
|
178
64
|
results: ResourceMap[T][];
|
|
179
65
|
};
|
|
180
66
|
saveNew(context: RepositoryContext, resource: ShallowWritable<ResourceMap[T]>): ResourceMap[T];
|
|
@@ -187,25 +73,25 @@ declare class AbstractUpdateHandler {
|
|
|
187
73
|
}
|
|
188
74
|
|
|
189
75
|
declare class ProductTailoringRepository extends AbstractResourceRepository<"product-tailoring"> {
|
|
190
|
-
constructor(
|
|
76
|
+
constructor(config: Config);
|
|
191
77
|
create(context: RepositoryContext, draft: any): ProductTailoring;
|
|
192
78
|
}
|
|
193
79
|
|
|
194
80
|
declare class CartRepository extends AbstractResourceRepository<"cart"> {
|
|
195
|
-
constructor(
|
|
81
|
+
constructor(config: Config);
|
|
196
82
|
create(context: RepositoryContext, draft: CartDraft): Cart;
|
|
197
83
|
getActiveCart(projectKey: string): Cart | undefined;
|
|
198
84
|
draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft, currency: string, country: string | undefined) => LineItem;
|
|
199
85
|
}
|
|
200
86
|
|
|
201
87
|
declare class OrderRepository extends AbstractResourceRepository<"order"> {
|
|
202
|
-
constructor(
|
|
88
|
+
constructor(config: Config);
|
|
203
89
|
create(context: RepositoryContext, draft: OrderFromCartDraft): Order;
|
|
204
90
|
createFromCart(context: RepositoryContext, cartReference: CartReference, orderNumber?: string): Order;
|
|
205
91
|
import(context: RepositoryContext, draft: OrderImportDraft): Order;
|
|
206
92
|
private lineItemFromImportDraft;
|
|
207
93
|
private customLineItemFromImportDraft;
|
|
208
|
-
getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams): Order | undefined;
|
|
94
|
+
getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams$1): Order | undefined;
|
|
209
95
|
}
|
|
210
96
|
|
|
211
97
|
declare class AsAssociateOrderRepository extends OrderRepository {
|
|
@@ -214,48 +100,48 @@ declare class AsAssociateCartRepository extends CartRepository {
|
|
|
214
100
|
}
|
|
215
101
|
|
|
216
102
|
declare class AssociateRoleRepository extends AbstractResourceRepository<"associate-role"> {
|
|
217
|
-
constructor(
|
|
103
|
+
constructor(config: Config);
|
|
218
104
|
create(context: RepositoryContext, draft: AssociateRoleDraft): AssociateRole;
|
|
219
105
|
}
|
|
220
106
|
|
|
221
107
|
declare class AttributeGroupRepository extends AbstractResourceRepository<"attribute-group"> {
|
|
222
|
-
constructor(
|
|
108
|
+
constructor(config: Config);
|
|
223
109
|
create(context: RepositoryContext, draft: AttributeGroupDraft): AttributeGroup;
|
|
224
110
|
}
|
|
225
111
|
|
|
226
112
|
declare class BusinessUnitRepository extends AbstractResourceRepository<"business-unit"> {
|
|
227
|
-
constructor(
|
|
113
|
+
constructor(config: Config);
|
|
228
114
|
create(context: RepositoryContext, draft: BusinessUnitDraft): BusinessUnit;
|
|
229
115
|
private _isCompanyDraft;
|
|
230
116
|
private _isDivisionDraft;
|
|
231
117
|
}
|
|
232
118
|
|
|
233
119
|
declare class CartDiscountRepository extends AbstractResourceRepository<"cart-discount"> {
|
|
234
|
-
constructor(
|
|
120
|
+
constructor(config: Config);
|
|
235
121
|
create(context: RepositoryContext, draft: CartDiscountDraft): CartDiscount;
|
|
236
122
|
private transformValueDraft;
|
|
237
123
|
}
|
|
238
124
|
|
|
239
125
|
declare class CategoryRepository extends AbstractResourceRepository<"category"> {
|
|
240
|
-
constructor(
|
|
126
|
+
constructor(config: Config);
|
|
241
127
|
create(context: RepositoryContext, draft: CategoryDraft): Category;
|
|
242
|
-
postProcessResource(context: RepositoryContext, resource: Writable<Category>, params?: GetParams): Category;
|
|
128
|
+
postProcessResource(context: RepositoryContext, resource: Writable<Category>, params?: GetParams$1): Category;
|
|
243
129
|
}
|
|
244
130
|
|
|
245
131
|
declare class ChannelRepository extends AbstractResourceRepository<"channel"> {
|
|
246
|
-
constructor(
|
|
132
|
+
constructor(config: Config);
|
|
247
133
|
create(context: RepositoryContext, draft: ChannelDraft): Channel;
|
|
248
134
|
}
|
|
249
135
|
|
|
250
136
|
declare class CustomObjectRepository extends AbstractResourceRepository<"key-value-document"> {
|
|
251
|
-
constructor(
|
|
137
|
+
constructor(config: Config);
|
|
252
138
|
create(context: RepositoryContext, draft: Writable<CustomObjectDraft>): CustomObject;
|
|
253
139
|
getWithContainerAndKey(context: RepositoryContext, container: string, key: string): CustomObject | undefined;
|
|
254
|
-
queryWithContainer(context: RepositoryContext, container: string, params?: QueryParams): ctp.CustomObjectPagedQueryResponse;
|
|
140
|
+
queryWithContainer(context: RepositoryContext, container: string, params?: QueryParams$1): ctp.CustomObjectPagedQueryResponse;
|
|
255
141
|
}
|
|
256
142
|
|
|
257
143
|
declare class CustomerRepository extends AbstractResourceRepository<"customer"> {
|
|
258
|
-
constructor(
|
|
144
|
+
constructor(config: Config);
|
|
259
145
|
create(context: RepositoryContext, draft: CustomerDraft): Customer;
|
|
260
146
|
saveUpdate(context: RepositoryContext, version: number, resource: ShallowWritable<ResourceMap["customer"]>): ShallowWritable<ResourceMap["customer"]>;
|
|
261
147
|
passwordResetToken(context: RepositoryContext, request: CustomerCreatePasswordResetToken): CustomerToken;
|
|
@@ -265,23 +151,23 @@ declare class CustomerRepository extends AbstractResourceRepository<"customer">
|
|
|
265
151
|
}
|
|
266
152
|
|
|
267
153
|
declare class CustomerGroupRepository extends AbstractResourceRepository<"customer-group"> {
|
|
268
|
-
constructor(
|
|
154
|
+
constructor(config: Config);
|
|
269
155
|
create(context: RepositoryContext, draft: CustomerGroupDraft): CustomerGroup;
|
|
270
156
|
}
|
|
271
157
|
|
|
272
158
|
declare class DiscountCodeRepository extends AbstractResourceRepository<"discount-code"> {
|
|
273
|
-
constructor(
|
|
159
|
+
constructor(config: Config);
|
|
274
160
|
create(context: RepositoryContext, draft: DiscountCodeDraft): DiscountCode;
|
|
275
161
|
}
|
|
276
162
|
|
|
277
163
|
declare class ExtensionRepository extends AbstractResourceRepository<"extension"> {
|
|
278
|
-
constructor(
|
|
164
|
+
constructor(config: Config);
|
|
279
165
|
create(context: RepositoryContext, draft: ExtensionDraft): Extension;
|
|
280
166
|
postProcessResource(context: RepositoryContext, resource: Extension): Extension;
|
|
281
167
|
}
|
|
282
168
|
|
|
283
169
|
declare class InventoryEntryRepository extends AbstractResourceRepository<"inventory-entry"> {
|
|
284
|
-
constructor(
|
|
170
|
+
constructor(config: Config);
|
|
285
171
|
create(context: RepositoryContext, draft: InventoryEntryDraft): InventoryEntry;
|
|
286
172
|
}
|
|
287
173
|
|
|
@@ -297,31 +183,31 @@ declare class MyOrderRepository extends OrderRepository {
|
|
|
297
183
|
}
|
|
298
184
|
|
|
299
185
|
declare class OrderEditRepository extends AbstractResourceRepository<"order-edit"> {
|
|
300
|
-
constructor(
|
|
186
|
+
constructor(config: Config);
|
|
301
187
|
create(context: RepositoryContext, draft: OrderEditDraft): OrderEdit;
|
|
302
188
|
}
|
|
303
189
|
|
|
304
190
|
declare class PaymentRepository extends AbstractResourceRepository<"payment"> {
|
|
305
|
-
constructor(
|
|
191
|
+
constructor(config: Config);
|
|
306
192
|
create(context: RepositoryContext, draft: PaymentDraft): Payment;
|
|
307
193
|
}
|
|
308
194
|
|
|
309
195
|
declare class ProductSearch {
|
|
310
196
|
protected _storage: AbstractStorage;
|
|
311
|
-
constructor(
|
|
197
|
+
constructor(config: Config);
|
|
312
198
|
search(projectKey: string, params: ProductSearchRequest): ProductPagedSearchResponse;
|
|
313
199
|
transform(product: Product, staged: boolean): ProductProjection;
|
|
314
200
|
}
|
|
315
201
|
|
|
316
202
|
declare class ProductRepository extends AbstractResourceRepository<"product"> {
|
|
317
203
|
protected _searchService: ProductSearch;
|
|
318
|
-
constructor(
|
|
204
|
+
constructor(config: Config);
|
|
319
205
|
create(context: RepositoryContext, draft: ProductDraft): Product;
|
|
320
206
|
search(context: RepositoryContext, searchRequest: ProductSearchRequest): ProductPagedSearchResponse;
|
|
321
207
|
}
|
|
322
208
|
|
|
323
209
|
declare class ProductDiscountRepository extends AbstractResourceRepository<"product-discount"> {
|
|
324
|
-
constructor(
|
|
210
|
+
constructor(config: Config);
|
|
325
211
|
create(context: RepositoryContext, draft: ProductDiscountDraft): ProductDiscount;
|
|
326
212
|
}
|
|
327
213
|
|
|
@@ -364,7 +250,7 @@ type ProductProjectionSearchParams = {
|
|
|
364
250
|
};
|
|
365
251
|
declare class ProductProjectionSearch {
|
|
366
252
|
protected _storage: AbstractStorage;
|
|
367
|
-
constructor(
|
|
253
|
+
constructor(config: Config);
|
|
368
254
|
search(projectKey: string, params: ProductProjectionSearchParams): ProductProjectionPagedSearchResponse;
|
|
369
255
|
transform(product: Product, staged: boolean): ProductProjection;
|
|
370
256
|
getFacets(params: ProductProjectionSearchParams, products: ProductProjection[]): FacetResults;
|
|
@@ -396,9 +282,9 @@ type ProductProjectionQueryParams = {
|
|
|
396
282
|
};
|
|
397
283
|
declare class ProductProjectionRepository extends AbstractResourceRepository<"product-projection"> {
|
|
398
284
|
protected _searchService: ProductProjectionSearch;
|
|
399
|
-
constructor(
|
|
285
|
+
constructor(config: Config);
|
|
400
286
|
create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
|
|
401
|
-
get(context: RepositoryContext, id: string, params?: GetParams): ProductProjection | null;
|
|
287
|
+
get(context: RepositoryContext, id: string, params?: GetParams$1): ProductProjection | null;
|
|
402
288
|
query(context: RepositoryContext, params?: ProductProjectionQueryParams): {
|
|
403
289
|
count: number;
|
|
404
290
|
total: number;
|
|
@@ -410,17 +296,17 @@ declare class ProductProjectionRepository extends AbstractResourceRepository<"pr
|
|
|
410
296
|
}
|
|
411
297
|
|
|
412
298
|
declare class ProductSelectionRepository extends AbstractResourceRepository<"product-selection"> {
|
|
413
|
-
constructor(
|
|
299
|
+
constructor(config: Config);
|
|
414
300
|
create(context: RepositoryContext, draft: ProductSelectionDraft): ProductSelection;
|
|
415
301
|
}
|
|
416
302
|
|
|
417
303
|
declare class ProductTypeRepository extends AbstractResourceRepository<"product-type"> {
|
|
418
|
-
constructor(
|
|
304
|
+
constructor(config: Config);
|
|
419
305
|
create(context: RepositoryContext, draft: ProductTypeDraft): ProductType;
|
|
420
306
|
}
|
|
421
307
|
|
|
422
308
|
declare class ProjectRepository extends AbstractRepository<Project> {
|
|
423
|
-
constructor(
|
|
309
|
+
constructor(config: Config);
|
|
424
310
|
get(context: RepositoryContext): Project | null;
|
|
425
311
|
postProcessResource(context: RepositoryContext, resource: Project): Project;
|
|
426
312
|
saveNew(context: RepositoryContext, resource: Writable<Project>): void;
|
|
@@ -428,24 +314,24 @@ declare class ProjectRepository extends AbstractRepository<Project> {
|
|
|
428
314
|
}
|
|
429
315
|
|
|
430
316
|
declare class QuoteRepository extends AbstractResourceRepository<"quote"> {
|
|
431
|
-
constructor(
|
|
317
|
+
constructor(config: Config);
|
|
432
318
|
create(context: RepositoryContext, draft: QuoteDraft): Quote;
|
|
433
319
|
}
|
|
434
320
|
|
|
435
321
|
declare class QuoteRequestRepository extends AbstractResourceRepository<"quote-request"> {
|
|
436
|
-
constructor(
|
|
322
|
+
constructor(config: Config);
|
|
437
323
|
create(context: RepositoryContext, draft: QuoteRequestDraft): QuoteRequest;
|
|
438
324
|
}
|
|
439
325
|
|
|
440
326
|
declare class ReviewRepository extends AbstractResourceRepository<"review"> {
|
|
441
|
-
constructor(
|
|
327
|
+
constructor(config: Config);
|
|
442
328
|
create(context: RepositoryContext, draft: ReviewDraft): Review;
|
|
443
329
|
}
|
|
444
330
|
|
|
445
331
|
declare class ShippingMethodRepository extends AbstractResourceRepository<"shipping-method"> {
|
|
446
|
-
constructor(
|
|
332
|
+
constructor(config: Config);
|
|
447
333
|
create(context: RepositoryContext, draft: ShippingMethodDraft): ShippingMethod;
|
|
448
|
-
matchingCart(context: RepositoryContext, cartId: string, params?: GetParams): {
|
|
334
|
+
matchingCart(context: RepositoryContext, cartId: string, params?: GetParams$1): {
|
|
449
335
|
results: {
|
|
450
336
|
zoneRates: {
|
|
451
337
|
zone: ZoneReference;
|
|
@@ -477,54 +363,54 @@ declare class ShippingMethodRepository extends AbstractResourceRepository<"shipp
|
|
|
477
363
|
}
|
|
478
364
|
|
|
479
365
|
declare class ShoppingListRepository extends AbstractResourceRepository<"shopping-list"> {
|
|
480
|
-
constructor(
|
|
366
|
+
constructor(config: Config);
|
|
481
367
|
create(context: RepositoryContext, draft: ShoppingListDraft): ShoppingList;
|
|
482
368
|
draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft) => ShoppingListLineItem;
|
|
483
369
|
}
|
|
484
370
|
|
|
485
371
|
declare class StagedQuoteRepository extends AbstractResourceRepository<"staged-quote"> {
|
|
486
|
-
constructor(
|
|
372
|
+
constructor(config: Config);
|
|
487
373
|
create(context: RepositoryContext, draft: StagedQuoteDraft): StagedQuote;
|
|
488
374
|
}
|
|
489
375
|
|
|
490
376
|
declare class StandAlonePriceRepository extends AbstractResourceRepository<"standalone-price"> {
|
|
491
|
-
constructor(
|
|
377
|
+
constructor(config: Config);
|
|
492
378
|
create(context: RepositoryContext, draft: StandalonePriceDraft): StandalonePrice;
|
|
493
379
|
transformChannelReferenceDraft(channel: ChannelResourceIdentifier): ChannelReference;
|
|
494
380
|
}
|
|
495
381
|
|
|
496
382
|
declare class StateRepository extends AbstractResourceRepository<"state"> {
|
|
497
|
-
constructor(
|
|
383
|
+
constructor(config: Config);
|
|
498
384
|
create(context: RepositoryContext, draft: StateDraft): State;
|
|
499
385
|
}
|
|
500
386
|
|
|
501
387
|
declare class StoreRepository extends AbstractResourceRepository<"store"> {
|
|
502
|
-
constructor(
|
|
388
|
+
constructor(config: Config);
|
|
503
389
|
create(context: RepositoryContext, draft: StoreDraft): Store;
|
|
504
390
|
}
|
|
505
391
|
|
|
506
392
|
declare class SubscriptionRepository extends AbstractResourceRepository<"subscription"> {
|
|
507
|
-
constructor(
|
|
393
|
+
constructor(config: Config);
|
|
508
394
|
create(context: RepositoryContext, draft: SubscriptionDraft): Subscription;
|
|
509
395
|
}
|
|
510
396
|
|
|
511
397
|
declare class TaxCategoryRepository extends AbstractResourceRepository<"tax-category"> {
|
|
512
|
-
constructor(
|
|
398
|
+
constructor(config: Config);
|
|
513
399
|
create(context: RepositoryContext, draft: TaxCategoryDraft): TaxCategory;
|
|
514
400
|
}
|
|
515
401
|
|
|
516
402
|
declare class TypeRepository extends AbstractResourceRepository<"type"> {
|
|
517
|
-
constructor(
|
|
403
|
+
constructor(config: Config);
|
|
518
404
|
create(context: RepositoryContext, draft: TypeDraft): Type;
|
|
519
405
|
}
|
|
520
406
|
|
|
521
407
|
declare class ZoneRepository extends AbstractResourceRepository<"zone"> {
|
|
522
|
-
constructor(
|
|
408
|
+
constructor(config: Config);
|
|
523
409
|
create(context: RepositoryContext, draft: ZoneDraft): Zone;
|
|
524
410
|
}
|
|
525
411
|
|
|
526
412
|
type RepositoryMap = ReturnType<typeof createRepositories>;
|
|
527
|
-
declare const createRepositories: (
|
|
413
|
+
declare const createRepositories: (config: Config) => {
|
|
528
414
|
"as-associate": {
|
|
529
415
|
cart: AsAssociateCartRepository;
|
|
530
416
|
order: AsAssociateOrderRepository;
|
|
@@ -572,13 +458,135 @@ declare const createRepositories: (storage: AbstractStorage) => {
|
|
|
572
458
|
zone: ZoneRepository;
|
|
573
459
|
};
|
|
574
460
|
|
|
461
|
+
type Writable<T> = {
|
|
462
|
+
-readonly [P in keyof T]: Writable<T[P]>;
|
|
463
|
+
};
|
|
464
|
+
type ShallowWritable<T> = {
|
|
465
|
+
-readonly [P in keyof T]: T[P];
|
|
466
|
+
};
|
|
467
|
+
type ResourceType = keyof ResourceMap & keyof RepositoryMap;
|
|
468
|
+
type ResourceMap = {
|
|
469
|
+
"attribute-group": ctp.AttributeGroup;
|
|
470
|
+
"associate-role": ctp.AssociateRole;
|
|
471
|
+
"business-unit": ctp.BusinessUnit;
|
|
472
|
+
"cart-discount": ctp.CartDiscount;
|
|
473
|
+
"cart": ctp.Cart;
|
|
474
|
+
"category": ctp.Category;
|
|
475
|
+
"channel": ctp.Channel;
|
|
476
|
+
"customer-email-token": never;
|
|
477
|
+
"customer-group": ctp.CustomerGroup;
|
|
478
|
+
"customer-password-token": never;
|
|
479
|
+
"customer": ctp.Customer;
|
|
480
|
+
"discount-code": ctp.DiscountCode;
|
|
481
|
+
"extension": ctp.Extension;
|
|
482
|
+
"inventory-entry": ctp.InventoryEntry;
|
|
483
|
+
"key-value-document": ctp.CustomObject;
|
|
484
|
+
"order-edit": ctp.OrderEdit;
|
|
485
|
+
"order": ctp.Order;
|
|
486
|
+
"payment": ctp.Payment;
|
|
487
|
+
"product-discount": ctp.ProductDiscount;
|
|
488
|
+
"product-price": ctp.StandalonePrice;
|
|
489
|
+
"product-projection": ctp.ProductProjection;
|
|
490
|
+
"product-selection": ctp.ProductSelection;
|
|
491
|
+
"product-tailoring": ctp.ProductTailoring;
|
|
492
|
+
"product-type": ctp.ProductType;
|
|
493
|
+
"product": ctp.Product;
|
|
494
|
+
"quote-request": ctp.QuoteRequest;
|
|
495
|
+
"quote": ctp.Quote;
|
|
496
|
+
"review": ctp.Review;
|
|
497
|
+
"shipping-method": ctp.ShippingMethod;
|
|
498
|
+
"shopping-list": ctp.ShoppingList;
|
|
499
|
+
"staged-quote": ctp.StagedQuote;
|
|
500
|
+
"standalone-price": ctp.StandalonePrice;
|
|
501
|
+
"state": ctp.State;
|
|
502
|
+
"store": ctp.Store;
|
|
503
|
+
"subscription": ctp.Subscription;
|
|
504
|
+
"tax-category": ctp.TaxCategory;
|
|
505
|
+
"type": ctp.Type;
|
|
506
|
+
"zone": ctp.Zone;
|
|
507
|
+
};
|
|
508
|
+
type PagedQueryResponseMap = {
|
|
509
|
+
"attribute-group": ctp.AttributeGroupPagedQueryResponse;
|
|
510
|
+
"associate-role": ctp.AssociateRolePagedQueryResponse;
|
|
511
|
+
"business-unit": ctp.BusinessUnitPagedQueryResponse;
|
|
512
|
+
"cart-discount": ctp.CartDiscountPagedQueryResponse;
|
|
513
|
+
"cart": ctp.CartPagedQueryResponse;
|
|
514
|
+
"category": ctp.CategoryPagedQueryResponse;
|
|
515
|
+
"channel": ctp.ChannelPagedQueryResponse;
|
|
516
|
+
"customer-email-token": never;
|
|
517
|
+
"customer-group": ctp.CustomerGroupPagedQueryResponse;
|
|
518
|
+
"customer-password-token": never;
|
|
519
|
+
"customer": ctp.CustomerPagedQueryResponse;
|
|
520
|
+
"discount-code": ctp.DiscountCodePagedQueryResponse;
|
|
521
|
+
"extension": ctp.ExtensionPagedQueryResponse;
|
|
522
|
+
"inventory-entry": ctp.InventoryPagedQueryResponse;
|
|
523
|
+
"key-value-document": ctp.CustomObjectPagedQueryResponse;
|
|
524
|
+
"order-edit": ctp.OrderEditPagedQueryResponse;
|
|
525
|
+
"order": ctp.OrderPagedQueryResponse;
|
|
526
|
+
"payment": ctp.PaymentPagedQueryResponse;
|
|
527
|
+
"product-discount": ctp.ProductDiscountPagedQueryResponse;
|
|
528
|
+
"product-price": ctp.StandalonePricePagedQueryResponse;
|
|
529
|
+
"product-projection": ctp.ProductProjectionPagedQueryResponse;
|
|
530
|
+
"product-selection": ctp.ProductSelectionPagedQueryResponse;
|
|
531
|
+
"product-tailoring": ctp.ProductTailoringPagedQueryResponse;
|
|
532
|
+
"product-type": ctp.ProductTypePagedQueryResponse;
|
|
533
|
+
"product": ctp.ProductPagedQueryResponse;
|
|
534
|
+
"quote-request": ctp.QuoteRequestPagedQueryResponse;
|
|
535
|
+
"quote": ctp.QuotePagedQueryResponse;
|
|
536
|
+
"review": ctp.ReviewPagedQueryResponse;
|
|
537
|
+
"shipping-method": ctp.ShippingMethodPagedQueryResponse;
|
|
538
|
+
"shopping-list": ctp.ShoppingListPagedQueryResponse;
|
|
539
|
+
"staged-quote": ctp.StagedQuotePagedQueryResponse;
|
|
540
|
+
"standalone-price": ctp.StandalonePricePagedQueryResponse;
|
|
541
|
+
"state": ctp.StatePagedQueryResponse;
|
|
542
|
+
"store": ctp.StorePagedQueryResponse;
|
|
543
|
+
"subscription": ctp.SubscriptionPagedQueryResponse;
|
|
544
|
+
"tax-category": ctp.TaxCategoryPagedQueryResponse;
|
|
545
|
+
"type": ctp.TypePagedQueryResponse;
|
|
546
|
+
"zone": ctp.ZonePagedQueryResponse;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
type GetParams = {
|
|
550
|
+
expand?: string[];
|
|
551
|
+
};
|
|
552
|
+
type QueryParams = {
|
|
553
|
+
expand?: string | string[];
|
|
554
|
+
sort?: string | string[];
|
|
555
|
+
limit?: number;
|
|
556
|
+
offset?: number;
|
|
557
|
+
withTotal?: boolean;
|
|
558
|
+
where?: string | string[];
|
|
559
|
+
[key: string]: QueryParam;
|
|
560
|
+
};
|
|
561
|
+
declare abstract class AbstractStorage {
|
|
562
|
+
abstract clear(): void;
|
|
563
|
+
abstract all<RT extends ResourceType>(projectKey: string, typeId: RT): Array<ResourceMap[RT]>;
|
|
564
|
+
abstract add<RT extends ResourceType>(projectKey: string, typeId: RT, obj: ResourceMap[RT]): ResourceMap[RT];
|
|
565
|
+
abstract get<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params?: GetParams): ResourceMap[RT] | null;
|
|
566
|
+
abstract getByKey<RT extends ResourceType>(projectKey: string, typeId: RT, key: string, params: GetParams): ResourceMap[RT] | null;
|
|
567
|
+
abstract addProject(projectKey: string): Project;
|
|
568
|
+
abstract getProject(projectKey: string): Project;
|
|
569
|
+
abstract saveProject(project: Project): Project;
|
|
570
|
+
abstract delete<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params: GetParams): ResourceMap[RT] | null;
|
|
571
|
+
abstract query<RT extends ResourceType>(projectKey: string, typeId: RT, params: QueryParams): PagedQueryResponseMap[RT];
|
|
572
|
+
abstract getByResourceIdentifier<RT extends ResourceType>(projectKey: string, identifier: ResourceIdentifier): ResourceMap[RT];
|
|
573
|
+
abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
type Config = {
|
|
577
|
+
strict: boolean;
|
|
578
|
+
storage: AbstractStorage;
|
|
579
|
+
};
|
|
580
|
+
|
|
575
581
|
declare class ProjectAPI {
|
|
576
582
|
private projectKey;
|
|
577
583
|
private _storage;
|
|
578
584
|
private _repositories;
|
|
579
|
-
|
|
585
|
+
private config;
|
|
586
|
+
constructor(projectKey: string, repositories: RepositoryMap, config: Config);
|
|
580
587
|
add<T extends keyof RepositoryMap & keyof ResourceMap>(typeId: T, resource: ResourceMap[T]): void;
|
|
581
|
-
|
|
588
|
+
unsafeAdd<T extends keyof RepositoryMap & keyof ResourceMap>(typeId: T, resource: ResourceMap[T]): void;
|
|
589
|
+
get<RT extends ResourceType>(typeId: RT, id: string, params?: GetParams$1): ResourceMap[RT];
|
|
582
590
|
getRepository<RT extends keyof RepositoryMap>(typeId: RT): RepositoryMap[RT];
|
|
583
591
|
}
|
|
584
592
|
|
|
@@ -589,6 +597,7 @@ type CommercetoolsMockOptions = {
|
|
|
589
597
|
apiHost: RegExp | string;
|
|
590
598
|
authHost: RegExp | string;
|
|
591
599
|
silent: boolean;
|
|
600
|
+
strict: boolean;
|
|
592
601
|
};
|
|
593
602
|
type AppOptions = {
|
|
594
603
|
silent?: boolean;
|