@labdigital/commercetools-mock 2.41.0 → 2.42.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.cts 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 { QueryParam, BaseResource, Project, UpdateAction, ResourceIdentifier, ProductTailoring, AssociateRoleDraft, AssociateRole, AttributeGroupDraft, AttributeGroup, BusinessUnitDraft, BusinessUnit, CartDraft, Cart, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CategoryDraft, Category, ChannelDraft, Channel, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerCreatePasswordResetToken, CustomerToken, CustomerResetPassword, MyCustomerResetPassword, CustomerGroupDraft, CustomerGroup, DiscountCodeDraft, DiscountCode, ExtensionDraft, Extension, InventoryEntryDraft, InventoryEntry, MyCustomerChangePassword, MyCustomerEmailVerify, OrderFromCartDraft, Order, CartReference, OrderImportDraft, 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 } from '@commercetools/platform-sdk';
4
+ import { Project, ResourceIdentifier, QueryParam, BaseResource, 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 } from '@commercetools/platform-sdk';
5
5
 
6
6
  type Token = {
7
7
  access_token: string;
@@ -27,50 +27,6 @@ declare class OAuth2Store {
27
27
  validateToken(token: string): boolean;
28
28
  }
29
29
 
30
- type QueryParams$1 = {
31
- expand?: string[];
32
- where?: string[];
33
- offset?: number;
34
- limit?: number;
35
- [key: string]: QueryParam;
36
- };
37
- type GetParams$1 = {
38
- expand?: string[];
39
- };
40
- type RepositoryContext = {
41
- projectKey: string;
42
- storeKey?: string;
43
- };
44
- declare abstract class AbstractRepository<R extends BaseResource | Project> {
45
- protected _storage: AbstractStorage;
46
- protected actions: AbstractUpdateHandler | undefined;
47
- constructor(storage: AbstractStorage);
48
- abstract saveNew({ projectKey }: RepositoryContext, resource: R): void;
49
- abstract saveUpdate({ projectKey }: RepositoryContext, version: number, resource: R): void;
50
- abstract postProcessResource(context: RepositoryContext, resource: any): any;
51
- processUpdateActions(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
52
- }
53
- declare abstract class AbstractResourceRepository<T extends ResourceType> extends AbstractRepository<ResourceMap[T]> {
54
- protected _typeId: T;
55
- constructor(typeId: T, storage: AbstractStorage);
56
- abstract create(context: RepositoryContext, draft: any): ResourceMap[T];
57
- protected getTypeId(): T;
58
- delete(context: RepositoryContext, id: string, params?: GetParams$1): ResourceMap[T] | null;
59
- get(context: RepositoryContext, id: string, params?: GetParams$1): ResourceMap[T] | null;
60
- getByKey(context: RepositoryContext, key: string, params?: GetParams$1): ResourceMap[T] | null;
61
- postProcessResource(context: RepositoryContext, resource: ResourceMap[T], params?: GetParams$1): ResourceMap[T];
62
- query(context: RepositoryContext, params?: QueryParams$1): PagedQueryResponseMap[T] & {
63
- results: ResourceMap[T][];
64
- };
65
- saveNew(context: RepositoryContext, resource: ShallowWritable<ResourceMap[T]>): ResourceMap[T];
66
- saveUpdate(context: RepositoryContext, version: number, resource: ShallowWritable<ResourceMap[T]>): ShallowWritable<ResourceMap[T]>;
67
- }
68
- declare class AbstractUpdateHandler {
69
- protected _storage: AbstractStorage;
70
- constructor(_storage: AbstractStorage);
71
- apply<R extends BaseResource | Project>(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
72
- }
73
-
74
30
  type Writable<T> = {
75
31
  -readonly [P in keyof T]: Writable<T[P]>;
76
32
  };
@@ -159,10 +115,10 @@ type PagedQueryResponseMap = {
159
115
  "zone": ctp.ZonePagedQueryResponse;
160
116
  };
161
117
 
162
- type GetParams = {
118
+ type GetParams$1 = {
163
119
  expand?: string[];
164
120
  };
165
- type QueryParams = {
121
+ type QueryParams$1 = {
166
122
  expand?: string | string[];
167
123
  sort?: string | string[];
168
124
  limit?: number;
@@ -175,22 +131,88 @@ declare abstract class AbstractStorage {
175
131
  abstract clear(): void;
176
132
  abstract all<RT extends ResourceType>(projectKey: string, typeId: RT): Array<ResourceMap[RT]>;
177
133
  abstract add<RT extends ResourceType>(projectKey: string, typeId: RT, obj: ResourceMap[RT]): ResourceMap[RT];
178
- abstract get<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params?: GetParams): ResourceMap[RT] | null;
179
- abstract getByKey<RT extends ResourceType>(projectKey: string, typeId: RT, key: string, params: GetParams): ResourceMap[RT] | null;
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;
180
136
  abstract addProject(projectKey: string): Project;
181
137
  abstract getProject(projectKey: string): Project;
182
138
  abstract saveProject(project: Project): Project;
183
- abstract delete<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params: GetParams): ResourceMap[RT] | null;
184
- abstract query<RT extends ResourceType>(projectKey: string, typeId: RT, params: QueryParams): PagedQueryResponseMap[RT];
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];
185
141
  abstract getByResourceIdentifier<RT extends ResourceType>(projectKey: string, identifier: ResourceIdentifier): ResourceMap[RT];
186
142
  abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
187
143
  }
188
144
 
145
+ type QueryParams = {
146
+ expand?: string[];
147
+ where?: string[];
148
+ offset?: number;
149
+ limit?: number;
150
+ [key: string]: QueryParam;
151
+ };
152
+ type GetParams = {
153
+ expand?: string[];
154
+ };
155
+ type RepositoryContext = {
156
+ projectKey: string;
157
+ storeKey?: string;
158
+ };
159
+ declare abstract class AbstractRepository<R extends BaseResource | Project> {
160
+ protected _storage: AbstractStorage;
161
+ protected actions: AbstractUpdateHandler | undefined;
162
+ constructor(storage: AbstractStorage);
163
+ abstract saveNew({ projectKey }: RepositoryContext, resource: R): void;
164
+ abstract saveUpdate({ projectKey }: RepositoryContext, version: number, resource: R): void;
165
+ abstract postProcessResource(context: RepositoryContext, resource: any): any;
166
+ processUpdateActions(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
167
+ }
168
+ declare abstract class AbstractResourceRepository<T extends ResourceType> extends AbstractRepository<ResourceMap[T]> {
169
+ protected _typeId: T;
170
+ constructor(typeId: T, storage: AbstractStorage);
171
+ abstract create(context: RepositoryContext, draft: any): ResourceMap[T];
172
+ 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] & {
178
+ results: ResourceMap[T][];
179
+ };
180
+ saveNew(context: RepositoryContext, resource: ShallowWritable<ResourceMap[T]>): ResourceMap[T];
181
+ saveUpdate(context: RepositoryContext, version: number, resource: ShallowWritable<ResourceMap[T]>): ShallowWritable<ResourceMap[T]>;
182
+ }
183
+ declare class AbstractUpdateHandler {
184
+ protected _storage: AbstractStorage;
185
+ constructor(_storage: AbstractStorage);
186
+ apply<R extends BaseResource | Project>(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
187
+ }
188
+
189
189
  declare class ProductTailoringRepository extends AbstractResourceRepository<"product-tailoring"> {
190
190
  constructor(storage: AbstractStorage);
191
191
  create(context: RepositoryContext, draft: any): ProductTailoring;
192
192
  }
193
193
 
194
+ declare class CartRepository extends AbstractResourceRepository<"cart"> {
195
+ constructor(storage: AbstractStorage);
196
+ create(context: RepositoryContext, draft: CartDraft): Cart;
197
+ getActiveCart(projectKey: string): Cart | undefined;
198
+ draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft, currency: string, country: string | undefined) => LineItem;
199
+ }
200
+
201
+ declare class OrderRepository extends AbstractResourceRepository<"order"> {
202
+ constructor(storage: AbstractStorage);
203
+ create(context: RepositoryContext, draft: OrderFromCartDraft): Order;
204
+ createFromCart(context: RepositoryContext, cartReference: CartReference, orderNumber?: string): Order;
205
+ import(context: RepositoryContext, draft: OrderImportDraft): Order;
206
+ private lineItemFromImportDraft;
207
+ private customLineItemFromImportDraft;
208
+ getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams): Order | undefined;
209
+ }
210
+
211
+ declare class AsAssociateOrderRepository extends OrderRepository {
212
+ }
213
+ declare class AsAssociateCartRepository extends CartRepository {
214
+ }
215
+
194
216
  declare class AssociateRoleRepository extends AbstractResourceRepository<"associate-role"> {
195
217
  constructor(storage: AbstractStorage);
196
218
  create(context: RepositoryContext, draft: AssociateRoleDraft): AssociateRole;
@@ -208,13 +230,6 @@ declare class BusinessUnitRepository extends AbstractResourceRepository<"busines
208
230
  private _isDivisionDraft;
209
231
  }
210
232
 
211
- declare class CartRepository extends AbstractResourceRepository<"cart"> {
212
- constructor(storage: AbstractStorage);
213
- create(context: RepositoryContext, draft: CartDraft): Cart;
214
- getActiveCart(projectKey: string): Cart | undefined;
215
- draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft, currency: string, country: string | undefined) => LineItem;
216
- }
217
-
218
233
  declare class CartDiscountRepository extends AbstractResourceRepository<"cart-discount"> {
219
234
  constructor(storage: AbstractStorage);
220
235
  create(context: RepositoryContext, draft: CartDiscountDraft): CartDiscount;
@@ -224,7 +239,7 @@ declare class CartDiscountRepository extends AbstractResourceRepository<"cart-di
224
239
  declare class CategoryRepository extends AbstractResourceRepository<"category"> {
225
240
  constructor(storage: AbstractStorage);
226
241
  create(context: RepositoryContext, draft: CategoryDraft): Category;
227
- postProcessResource(context: RepositoryContext, resource: Writable<Category>, params?: GetParams$1): Category;
242
+ postProcessResource(context: RepositoryContext, resource: Writable<Category>, params?: GetParams): Category;
228
243
  }
229
244
 
230
245
  declare class ChannelRepository extends AbstractResourceRepository<"channel"> {
@@ -236,7 +251,7 @@ declare class CustomObjectRepository extends AbstractResourceRepository<"key-val
236
251
  constructor(storage: AbstractStorage);
237
252
  create(context: RepositoryContext, draft: Writable<CustomObjectDraft>): CustomObject;
238
253
  getWithContainerAndKey(context: RepositoryContext, container: string, key: string): CustomObject | undefined;
239
- queryWithContainer(context: RepositoryContext, container: string, params?: QueryParams$1): ctp.CustomObjectPagedQueryResponse;
254
+ queryWithContainer(context: RepositoryContext, container: string, params?: QueryParams): ctp.CustomObjectPagedQueryResponse;
240
255
  }
241
256
 
242
257
  declare class CustomerRepository extends AbstractResourceRepository<"customer"> {
@@ -246,6 +261,7 @@ declare class CustomerRepository extends AbstractResourceRepository<"customer">
246
261
  passwordResetToken(context: RepositoryContext, request: CustomerCreatePasswordResetToken): CustomerToken;
247
262
  passwordReset(context: RepositoryContext, resetPassword: CustomerResetPassword | MyCustomerResetPassword): Writable<Customer>;
248
263
  verifyEmailToken(context: RepositoryContext, id: string): CustomerToken;
264
+ private storeReferenceToStoreKeyReference;
249
265
  }
250
266
 
251
267
  declare class CustomerGroupRepository extends AbstractResourceRepository<"customer-group"> {
@@ -276,16 +292,6 @@ declare class MyCustomerRepository extends CustomerRepository {
276
292
  getMe(context: RepositoryContext): Customer | undefined;
277
293
  }
278
294
 
279
- declare class OrderRepository extends AbstractResourceRepository<"order"> {
280
- constructor(storage: AbstractStorage);
281
- create(context: RepositoryContext, draft: OrderFromCartDraft): Order;
282
- createFromCart(context: RepositoryContext, cartReference: CartReference, orderNumber?: string): Order;
283
- import(context: RepositoryContext, draft: OrderImportDraft): Order;
284
- private lineItemFromImportDraft;
285
- private customLineItemFromImportDraft;
286
- getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams$1): Order | undefined;
287
- }
288
-
289
295
  declare class MyOrderRepository extends OrderRepository {
290
296
  create(context: RepositoryContext, draft: MyOrderFromCartDraft): Order;
291
297
  }
@@ -392,7 +398,7 @@ declare class ProductProjectionRepository extends AbstractResourceRepository<"pr
392
398
  protected _searchService: ProductProjectionSearch;
393
399
  constructor(storage: AbstractStorage);
394
400
  create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
395
- get(context: RepositoryContext, id: string, params?: GetParams$1): ProductProjection | null;
401
+ get(context: RepositoryContext, id: string, params?: GetParams): ProductProjection | null;
396
402
  query(context: RepositoryContext, params?: ProductProjectionQueryParams): {
397
403
  count: number;
398
404
  total: number;
@@ -439,7 +445,7 @@ declare class ReviewRepository extends AbstractResourceRepository<"review"> {
439
445
  declare class ShippingMethodRepository extends AbstractResourceRepository<"shipping-method"> {
440
446
  constructor(storage: AbstractStorage);
441
447
  create(context: RepositoryContext, draft: ShippingMethodDraft): ShippingMethod;
442
- matchingCart(context: RepositoryContext, cartId: string, params?: GetParams$1): {
448
+ matchingCart(context: RepositoryContext, cartId: string, params?: GetParams): {
443
449
  results: {
444
450
  zoneRates: {
445
451
  zone: ZoneReference;
@@ -519,6 +525,10 @@ declare class ZoneRepository extends AbstractResourceRepository<"zone"> {
519
525
 
520
526
  type RepositoryMap = ReturnType<typeof createRepositories>;
521
527
  declare const createRepositories: (storage: AbstractStorage) => {
528
+ "as-associate": {
529
+ cart: AsAssociateCartRepository;
530
+ order: AsAssociateOrderRepository;
531
+ };
522
532
  "associate-role": AssociateRoleRepository;
523
533
  "attribute-group": AttributeGroupRepository;
524
534
  "business-unit": BusinessUnitRepository;
@@ -568,7 +578,7 @@ declare class ProjectAPI {
568
578
  private _repositories;
569
579
  constructor(projectKey: string, repositories: RepositoryMap, storage: AbstractStorage);
570
580
  add<T extends keyof RepositoryMap & keyof ResourceMap>(typeId: T, resource: ResourceMap[T]): void;
571
- get<RT extends ResourceType>(typeId: RT, id: string, params?: GetParams$1): ResourceMap[RT];
581
+ get<RT extends ResourceType>(typeId: RT, id: string, params?: GetParams): ResourceMap[RT];
572
582
  getRepository<RT extends keyof RepositoryMap>(typeId: RT): RepositoryMap[RT];
573
583
  }
574
584
 
@@ -589,7 +599,6 @@ declare class CommercetoolsMock {
589
599
  private _storage;
590
600
  private _oauth2;
591
601
  private _mswServer;
592
- private _services;
593
602
  private _repositories;
594
603
  private _projectService?;
595
604
  constructor(options?: Partial<CommercetoolsMockOptions>);
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 { QueryParam, BaseResource, Project, UpdateAction, ResourceIdentifier, ProductTailoring, AssociateRoleDraft, AssociateRole, AttributeGroupDraft, AttributeGroup, BusinessUnitDraft, BusinessUnit, CartDraft, Cart, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CategoryDraft, Category, ChannelDraft, Channel, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerCreatePasswordResetToken, CustomerToken, CustomerResetPassword, MyCustomerResetPassword, CustomerGroupDraft, CustomerGroup, DiscountCodeDraft, DiscountCode, ExtensionDraft, Extension, InventoryEntryDraft, InventoryEntry, MyCustomerChangePassword, MyCustomerEmailVerify, OrderFromCartDraft, Order, CartReference, OrderImportDraft, 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 } from '@commercetools/platform-sdk';
4
+ import { Project, ResourceIdentifier, QueryParam, BaseResource, 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 } from '@commercetools/platform-sdk';
5
5
 
6
6
  type Token = {
7
7
  access_token: string;
@@ -27,50 +27,6 @@ declare class OAuth2Store {
27
27
  validateToken(token: string): boolean;
28
28
  }
29
29
 
30
- type QueryParams$1 = {
31
- expand?: string[];
32
- where?: string[];
33
- offset?: number;
34
- limit?: number;
35
- [key: string]: QueryParam;
36
- };
37
- type GetParams$1 = {
38
- expand?: string[];
39
- };
40
- type RepositoryContext = {
41
- projectKey: string;
42
- storeKey?: string;
43
- };
44
- declare abstract class AbstractRepository<R extends BaseResource | Project> {
45
- protected _storage: AbstractStorage;
46
- protected actions: AbstractUpdateHandler | undefined;
47
- constructor(storage: AbstractStorage);
48
- abstract saveNew({ projectKey }: RepositoryContext, resource: R): void;
49
- abstract saveUpdate({ projectKey }: RepositoryContext, version: number, resource: R): void;
50
- abstract postProcessResource(context: RepositoryContext, resource: any): any;
51
- processUpdateActions(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
52
- }
53
- declare abstract class AbstractResourceRepository<T extends ResourceType> extends AbstractRepository<ResourceMap[T]> {
54
- protected _typeId: T;
55
- constructor(typeId: T, storage: AbstractStorage);
56
- abstract create(context: RepositoryContext, draft: any): ResourceMap[T];
57
- protected getTypeId(): T;
58
- delete(context: RepositoryContext, id: string, params?: GetParams$1): ResourceMap[T] | null;
59
- get(context: RepositoryContext, id: string, params?: GetParams$1): ResourceMap[T] | null;
60
- getByKey(context: RepositoryContext, key: string, params?: GetParams$1): ResourceMap[T] | null;
61
- postProcessResource(context: RepositoryContext, resource: ResourceMap[T], params?: GetParams$1): ResourceMap[T];
62
- query(context: RepositoryContext, params?: QueryParams$1): PagedQueryResponseMap[T] & {
63
- results: ResourceMap[T][];
64
- };
65
- saveNew(context: RepositoryContext, resource: ShallowWritable<ResourceMap[T]>): ResourceMap[T];
66
- saveUpdate(context: RepositoryContext, version: number, resource: ShallowWritable<ResourceMap[T]>): ShallowWritable<ResourceMap[T]>;
67
- }
68
- declare class AbstractUpdateHandler {
69
- protected _storage: AbstractStorage;
70
- constructor(_storage: AbstractStorage);
71
- apply<R extends BaseResource | Project>(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
72
- }
73
-
74
30
  type Writable<T> = {
75
31
  -readonly [P in keyof T]: Writable<T[P]>;
76
32
  };
@@ -159,10 +115,10 @@ type PagedQueryResponseMap = {
159
115
  "zone": ctp.ZonePagedQueryResponse;
160
116
  };
161
117
 
162
- type GetParams = {
118
+ type GetParams$1 = {
163
119
  expand?: string[];
164
120
  };
165
- type QueryParams = {
121
+ type QueryParams$1 = {
166
122
  expand?: string | string[];
167
123
  sort?: string | string[];
168
124
  limit?: number;
@@ -175,22 +131,88 @@ declare abstract class AbstractStorage {
175
131
  abstract clear(): void;
176
132
  abstract all<RT extends ResourceType>(projectKey: string, typeId: RT): Array<ResourceMap[RT]>;
177
133
  abstract add<RT extends ResourceType>(projectKey: string, typeId: RT, obj: ResourceMap[RT]): ResourceMap[RT];
178
- abstract get<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params?: GetParams): ResourceMap[RT] | null;
179
- abstract getByKey<RT extends ResourceType>(projectKey: string, typeId: RT, key: string, params: GetParams): ResourceMap[RT] | null;
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;
180
136
  abstract addProject(projectKey: string): Project;
181
137
  abstract getProject(projectKey: string): Project;
182
138
  abstract saveProject(project: Project): Project;
183
- abstract delete<RT extends ResourceType>(projectKey: string, typeId: RT, id: string, params: GetParams): ResourceMap[RT] | null;
184
- abstract query<RT extends ResourceType>(projectKey: string, typeId: RT, params: QueryParams): PagedQueryResponseMap[RT];
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];
185
141
  abstract getByResourceIdentifier<RT extends ResourceType>(projectKey: string, identifier: ResourceIdentifier): ResourceMap[RT];
186
142
  abstract expand<T>(projectKey: string, obj: T, clause: undefined | string | string[]): T;
187
143
  }
188
144
 
145
+ type QueryParams = {
146
+ expand?: string[];
147
+ where?: string[];
148
+ offset?: number;
149
+ limit?: number;
150
+ [key: string]: QueryParam;
151
+ };
152
+ type GetParams = {
153
+ expand?: string[];
154
+ };
155
+ type RepositoryContext = {
156
+ projectKey: string;
157
+ storeKey?: string;
158
+ };
159
+ declare abstract class AbstractRepository<R extends BaseResource | Project> {
160
+ protected _storage: AbstractStorage;
161
+ protected actions: AbstractUpdateHandler | undefined;
162
+ constructor(storage: AbstractStorage);
163
+ abstract saveNew({ projectKey }: RepositoryContext, resource: R): void;
164
+ abstract saveUpdate({ projectKey }: RepositoryContext, version: number, resource: R): void;
165
+ abstract postProcessResource(context: RepositoryContext, resource: any): any;
166
+ processUpdateActions(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
167
+ }
168
+ declare abstract class AbstractResourceRepository<T extends ResourceType> extends AbstractRepository<ResourceMap[T]> {
169
+ protected _typeId: T;
170
+ constructor(typeId: T, storage: AbstractStorage);
171
+ abstract create(context: RepositoryContext, draft: any): ResourceMap[T];
172
+ 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] & {
178
+ results: ResourceMap[T][];
179
+ };
180
+ saveNew(context: RepositoryContext, resource: ShallowWritable<ResourceMap[T]>): ResourceMap[T];
181
+ saveUpdate(context: RepositoryContext, version: number, resource: ShallowWritable<ResourceMap[T]>): ShallowWritable<ResourceMap[T]>;
182
+ }
183
+ declare class AbstractUpdateHandler {
184
+ protected _storage: AbstractStorage;
185
+ constructor(_storage: AbstractStorage);
186
+ apply<R extends BaseResource | Project>(context: RepositoryContext, resource: R, version: number, actions: UpdateAction[]): R;
187
+ }
188
+
189
189
  declare class ProductTailoringRepository extends AbstractResourceRepository<"product-tailoring"> {
190
190
  constructor(storage: AbstractStorage);
191
191
  create(context: RepositoryContext, draft: any): ProductTailoring;
192
192
  }
193
193
 
194
+ declare class CartRepository extends AbstractResourceRepository<"cart"> {
195
+ constructor(storage: AbstractStorage);
196
+ create(context: RepositoryContext, draft: CartDraft): Cart;
197
+ getActiveCart(projectKey: string): Cart | undefined;
198
+ draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft, currency: string, country: string | undefined) => LineItem;
199
+ }
200
+
201
+ declare class OrderRepository extends AbstractResourceRepository<"order"> {
202
+ constructor(storage: AbstractStorage);
203
+ create(context: RepositoryContext, draft: OrderFromCartDraft): Order;
204
+ createFromCart(context: RepositoryContext, cartReference: CartReference, orderNumber?: string): Order;
205
+ import(context: RepositoryContext, draft: OrderImportDraft): Order;
206
+ private lineItemFromImportDraft;
207
+ private customLineItemFromImportDraft;
208
+ getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams): Order | undefined;
209
+ }
210
+
211
+ declare class AsAssociateOrderRepository extends OrderRepository {
212
+ }
213
+ declare class AsAssociateCartRepository extends CartRepository {
214
+ }
215
+
194
216
  declare class AssociateRoleRepository extends AbstractResourceRepository<"associate-role"> {
195
217
  constructor(storage: AbstractStorage);
196
218
  create(context: RepositoryContext, draft: AssociateRoleDraft): AssociateRole;
@@ -208,13 +230,6 @@ declare class BusinessUnitRepository extends AbstractResourceRepository<"busines
208
230
  private _isDivisionDraft;
209
231
  }
210
232
 
211
- declare class CartRepository extends AbstractResourceRepository<"cart"> {
212
- constructor(storage: AbstractStorage);
213
- create(context: RepositoryContext, draft: CartDraft): Cart;
214
- getActiveCart(projectKey: string): Cart | undefined;
215
- draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft, currency: string, country: string | undefined) => LineItem;
216
- }
217
-
218
233
  declare class CartDiscountRepository extends AbstractResourceRepository<"cart-discount"> {
219
234
  constructor(storage: AbstractStorage);
220
235
  create(context: RepositoryContext, draft: CartDiscountDraft): CartDiscount;
@@ -224,7 +239,7 @@ declare class CartDiscountRepository extends AbstractResourceRepository<"cart-di
224
239
  declare class CategoryRepository extends AbstractResourceRepository<"category"> {
225
240
  constructor(storage: AbstractStorage);
226
241
  create(context: RepositoryContext, draft: CategoryDraft): Category;
227
- postProcessResource(context: RepositoryContext, resource: Writable<Category>, params?: GetParams$1): Category;
242
+ postProcessResource(context: RepositoryContext, resource: Writable<Category>, params?: GetParams): Category;
228
243
  }
229
244
 
230
245
  declare class ChannelRepository extends AbstractResourceRepository<"channel"> {
@@ -236,7 +251,7 @@ declare class CustomObjectRepository extends AbstractResourceRepository<"key-val
236
251
  constructor(storage: AbstractStorage);
237
252
  create(context: RepositoryContext, draft: Writable<CustomObjectDraft>): CustomObject;
238
253
  getWithContainerAndKey(context: RepositoryContext, container: string, key: string): CustomObject | undefined;
239
- queryWithContainer(context: RepositoryContext, container: string, params?: QueryParams$1): ctp.CustomObjectPagedQueryResponse;
254
+ queryWithContainer(context: RepositoryContext, container: string, params?: QueryParams): ctp.CustomObjectPagedQueryResponse;
240
255
  }
241
256
 
242
257
  declare class CustomerRepository extends AbstractResourceRepository<"customer"> {
@@ -246,6 +261,7 @@ declare class CustomerRepository extends AbstractResourceRepository<"customer">
246
261
  passwordResetToken(context: RepositoryContext, request: CustomerCreatePasswordResetToken): CustomerToken;
247
262
  passwordReset(context: RepositoryContext, resetPassword: CustomerResetPassword | MyCustomerResetPassword): Writable<Customer>;
248
263
  verifyEmailToken(context: RepositoryContext, id: string): CustomerToken;
264
+ private storeReferenceToStoreKeyReference;
249
265
  }
250
266
 
251
267
  declare class CustomerGroupRepository extends AbstractResourceRepository<"customer-group"> {
@@ -276,16 +292,6 @@ declare class MyCustomerRepository extends CustomerRepository {
276
292
  getMe(context: RepositoryContext): Customer | undefined;
277
293
  }
278
294
 
279
- declare class OrderRepository extends AbstractResourceRepository<"order"> {
280
- constructor(storage: AbstractStorage);
281
- create(context: RepositoryContext, draft: OrderFromCartDraft): Order;
282
- createFromCart(context: RepositoryContext, cartReference: CartReference, orderNumber?: string): Order;
283
- import(context: RepositoryContext, draft: OrderImportDraft): Order;
284
- private lineItemFromImportDraft;
285
- private customLineItemFromImportDraft;
286
- getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams$1): Order | undefined;
287
- }
288
-
289
295
  declare class MyOrderRepository extends OrderRepository {
290
296
  create(context: RepositoryContext, draft: MyOrderFromCartDraft): Order;
291
297
  }
@@ -392,7 +398,7 @@ declare class ProductProjectionRepository extends AbstractResourceRepository<"pr
392
398
  protected _searchService: ProductProjectionSearch;
393
399
  constructor(storage: AbstractStorage);
394
400
  create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
395
- get(context: RepositoryContext, id: string, params?: GetParams$1): ProductProjection | null;
401
+ get(context: RepositoryContext, id: string, params?: GetParams): ProductProjection | null;
396
402
  query(context: RepositoryContext, params?: ProductProjectionQueryParams): {
397
403
  count: number;
398
404
  total: number;
@@ -439,7 +445,7 @@ declare class ReviewRepository extends AbstractResourceRepository<"review"> {
439
445
  declare class ShippingMethodRepository extends AbstractResourceRepository<"shipping-method"> {
440
446
  constructor(storage: AbstractStorage);
441
447
  create(context: RepositoryContext, draft: ShippingMethodDraft): ShippingMethod;
442
- matchingCart(context: RepositoryContext, cartId: string, params?: GetParams$1): {
448
+ matchingCart(context: RepositoryContext, cartId: string, params?: GetParams): {
443
449
  results: {
444
450
  zoneRates: {
445
451
  zone: ZoneReference;
@@ -519,6 +525,10 @@ declare class ZoneRepository extends AbstractResourceRepository<"zone"> {
519
525
 
520
526
  type RepositoryMap = ReturnType<typeof createRepositories>;
521
527
  declare const createRepositories: (storage: AbstractStorage) => {
528
+ "as-associate": {
529
+ cart: AsAssociateCartRepository;
530
+ order: AsAssociateOrderRepository;
531
+ };
522
532
  "associate-role": AssociateRoleRepository;
523
533
  "attribute-group": AttributeGroupRepository;
524
534
  "business-unit": BusinessUnitRepository;
@@ -568,7 +578,7 @@ declare class ProjectAPI {
568
578
  private _repositories;
569
579
  constructor(projectKey: string, repositories: RepositoryMap, storage: AbstractStorage);
570
580
  add<T extends keyof RepositoryMap & keyof ResourceMap>(typeId: T, resource: ResourceMap[T]): void;
571
- get<RT extends ResourceType>(typeId: RT, id: string, params?: GetParams$1): ResourceMap[RT];
581
+ get<RT extends ResourceType>(typeId: RT, id: string, params?: GetParams): ResourceMap[RT];
572
582
  getRepository<RT extends keyof RepositoryMap>(typeId: RT): RepositoryMap[RT];
573
583
  }
574
584
 
@@ -589,7 +599,6 @@ declare class CommercetoolsMock {
589
599
  private _storage;
590
600
  private _oauth2;
591
601
  private _mswServer;
592
- private _services;
593
602
  private _repositories;
594
603
  private _projectService?;
595
604
  constructor(options?: Partial<CommercetoolsMockOptions>);