@labdigital/commercetools-mock 2.45.1 → 2.47.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 +614 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +788 -59
- package/dist/index.d.ts +788 -59
- package/dist/index.js +602 -238
- package/dist/index.js.map +1 -1
- package/package.json +41 -48
- package/src/ctMock.ts +11 -13
- package/src/index.test.ts +5 -5
- package/src/lib/predicateParser.test.ts +91 -60
- package/src/lib/predicateParser.ts +38 -42
- package/src/lib/productSearchFilter.test.ts +18 -0
- package/src/lib/productSearchFilter.ts +7 -0
- package/src/lib/projectionSearchFilter.test.ts +17 -17
- package/src/lib/projectionSearchFilter.ts +2 -3
- package/src/oauth/server.test.ts +1 -1
- package/src/oauth/server.ts +11 -11
- package/src/priceSelector.ts +1 -1
- package/src/product-projection-search.ts +18 -19
- package/src/product-search.ts +48 -8
- package/src/repositories/business-unit.ts +17 -16
- package/src/repositories/cart/actions.ts +32 -32
- package/src/repositories/cart/helpers.ts +1 -1
- package/src/repositories/cart/index.ts +25 -8
- package/src/repositories/cart-discount/actions.ts +1 -4
- package/src/repositories/category/actions.ts +2 -6
- package/src/repositories/custom-object.ts +20 -21
- package/src/repositories/customer/actions.ts +4 -4
- package/src/repositories/errors.ts +1 -1
- package/src/repositories/extension.ts +2 -1
- package/src/repositories/helpers.ts +27 -27
- package/src/repositories/index.ts +17 -17
- package/src/repositories/my-customer.ts +1 -1
- package/src/repositories/my-order.ts +2 -2
- package/src/repositories/order/index.ts +1 -1
- package/src/repositories/product/actions.ts +1 -1
- package/src/repositories/quote/actions.ts +83 -0
- package/src/repositories/quote/index.ts +54 -0
- package/src/repositories/quote-request/actions.ts +84 -0
- package/src/repositories/quote-request/index.test.ts +167 -0
- package/src/repositories/quote-request/index.ts +67 -0
- package/src/repositories/quote-staged/actions.ts +84 -0
- package/src/repositories/quote-staged/index.ts +47 -0
- package/src/repositories/review.ts +4 -4
- package/src/repositories/shipping-method/actions.ts +17 -17
- package/src/repositories/shipping-method/index.ts +6 -6
- package/src/repositories/shopping-list/actions.ts +1 -1
- package/src/repositories/shopping-list/index.ts +9 -1
- package/src/repositories/subscription.ts +2 -4
- package/src/server.ts +3 -2
- package/src/services/abstract.ts +7 -7
- package/src/services/as-associate-order.test.ts +1 -1
- package/src/services/cart-discount.test.ts +1 -1
- package/src/services/cart.test.ts +40 -15
- package/src/services/category.test.ts +1 -1
- package/src/services/customer.test.ts +16 -55
- package/src/services/customer.ts +1 -1
- package/src/services/index.ts +20 -14
- package/src/services/inventory-entry.test.ts +5 -5
- package/src/services/my-cart.test.ts +2 -2
- package/src/services/my-customer.test.ts +2 -2
- package/src/services/order.test.ts +8 -8
- package/src/services/product-projection.test.ts +5 -5
- package/src/services/product-projection.ts +12 -14
- package/src/services/product.test.ts +155 -71
- package/src/services/quote-request.test.ts +59 -0
- package/src/services/quote-request.ts +16 -0
- package/src/services/quote-staged.ts +16 -0
- package/src/services/quote.ts +16 -0
- package/src/services/standalone-price.test.ts +4 -4
- package/src/services/state.test.ts +1 -1
- package/src/services/store.test.ts +2 -2
- package/src/services/tax-category.test.ts +1 -1
- package/src/shipping.ts +3 -3
- package/src/storage/in-memory.ts +55 -63
- package/src/testing/customer.ts +40 -0
- package/src/types.ts +51 -31
- package/src/repositories/quote-request.ts +0 -17
- package/src/repositories/quote.ts +0 -14
- package/src/repositories/staged-quote.ts +0 -17
package/src/types.ts
CHANGED
|
@@ -3,7 +3,27 @@ import type { RepositoryMap } from "./repositories";
|
|
|
3
3
|
|
|
4
4
|
export const isType = <T>(x: T) => x;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type Builtin =
|
|
7
|
+
| string
|
|
8
|
+
| number
|
|
9
|
+
| boolean
|
|
10
|
+
| undefined
|
|
11
|
+
| null
|
|
12
|
+
| symbol
|
|
13
|
+
| bigint
|
|
14
|
+
| Date
|
|
15
|
+
| RegExp;
|
|
16
|
+
|
|
17
|
+
export type Writable<T> = T extends Builtin
|
|
18
|
+
? T
|
|
19
|
+
: T extends ReadonlyArray<infer U>
|
|
20
|
+
? WritableArray<U>
|
|
21
|
+
: T extends object
|
|
22
|
+
? { -readonly [P in keyof T]: Writable<T[P]> }
|
|
23
|
+
: T;
|
|
24
|
+
|
|
25
|
+
export interface WritableArray<T> extends Array<Writable<T>> {}
|
|
26
|
+
|
|
7
27
|
export type ShallowWritable<T> = { -readonly [P in keyof T]: T[P] };
|
|
8
28
|
|
|
9
29
|
export type ServiceTypes =
|
|
@@ -23,40 +43,40 @@ export type ResourceMap = {
|
|
|
23
43
|
"associate-role": ctp.AssociateRole;
|
|
24
44
|
"business-unit": ctp.BusinessUnit;
|
|
25
45
|
"cart-discount": ctp.CartDiscount;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
cart: ctp.Cart;
|
|
47
|
+
category: ctp.Category;
|
|
48
|
+
channel: ctp.Channel;
|
|
29
49
|
"customer-email-token": never;
|
|
30
50
|
"customer-group": ctp.CustomerGroup;
|
|
31
51
|
"customer-password-token": never;
|
|
32
|
-
|
|
52
|
+
customer: ctp.Customer;
|
|
33
53
|
"discount-code": ctp.DiscountCode;
|
|
34
|
-
|
|
54
|
+
extension: ctp.Extension;
|
|
35
55
|
"inventory-entry": ctp.InventoryEntry;
|
|
36
56
|
"key-value-document": ctp.CustomObject;
|
|
37
57
|
"order-edit": ctp.OrderEdit;
|
|
38
|
-
|
|
39
|
-
|
|
58
|
+
order: ctp.Order;
|
|
59
|
+
payment: ctp.Payment;
|
|
40
60
|
"product-discount": ctp.ProductDiscount;
|
|
41
61
|
"product-price": ctp.StandalonePrice;
|
|
42
62
|
"product-projection": ctp.ProductProjection;
|
|
43
63
|
"product-selection": ctp.ProductSelection;
|
|
44
64
|
"product-tailoring": ctp.ProductTailoring;
|
|
45
65
|
"product-type": ctp.ProductType;
|
|
46
|
-
|
|
66
|
+
product: ctp.Product;
|
|
47
67
|
"quote-request": ctp.QuoteRequest;
|
|
48
|
-
|
|
49
|
-
|
|
68
|
+
quote: ctp.Quote;
|
|
69
|
+
review: ctp.Review;
|
|
50
70
|
"shipping-method": ctp.ShippingMethod;
|
|
51
71
|
"shopping-list": ctp.ShoppingList;
|
|
52
72
|
"staged-quote": ctp.StagedQuote;
|
|
53
73
|
"standalone-price": ctp.StandalonePrice;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
state: ctp.State;
|
|
75
|
+
store: ctp.Store;
|
|
76
|
+
subscription: ctp.Subscription;
|
|
57
77
|
"tax-category": ctp.TaxCategory;
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
type: ctp.Type;
|
|
79
|
+
zone: ctp.Zone;
|
|
60
80
|
};
|
|
61
81
|
|
|
62
82
|
export type PagedQueryResponseMap = {
|
|
@@ -64,38 +84,38 @@ export type PagedQueryResponseMap = {
|
|
|
64
84
|
"associate-role": ctp.AssociateRolePagedQueryResponse;
|
|
65
85
|
"business-unit": ctp.BusinessUnitPagedQueryResponse;
|
|
66
86
|
"cart-discount": ctp.CartDiscountPagedQueryResponse;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
cart: ctp.CartPagedQueryResponse;
|
|
88
|
+
category: ctp.CategoryPagedQueryResponse;
|
|
89
|
+
channel: ctp.ChannelPagedQueryResponse;
|
|
70
90
|
"customer-email-token": never;
|
|
71
91
|
"customer-group": ctp.CustomerGroupPagedQueryResponse;
|
|
72
92
|
"customer-password-token": never;
|
|
73
|
-
|
|
93
|
+
customer: ctp.CustomerPagedQueryResponse;
|
|
74
94
|
"discount-code": ctp.DiscountCodePagedQueryResponse;
|
|
75
|
-
|
|
95
|
+
extension: ctp.ExtensionPagedQueryResponse;
|
|
76
96
|
"inventory-entry": ctp.InventoryPagedQueryResponse;
|
|
77
97
|
"key-value-document": ctp.CustomObjectPagedQueryResponse;
|
|
78
98
|
"order-edit": ctp.OrderEditPagedQueryResponse;
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
order: ctp.OrderPagedQueryResponse;
|
|
100
|
+
payment: ctp.PaymentPagedQueryResponse;
|
|
81
101
|
"product-discount": ctp.ProductDiscountPagedQueryResponse;
|
|
82
102
|
"product-price": ctp.StandalonePricePagedQueryResponse;
|
|
83
103
|
"product-projection": ctp.ProductProjectionPagedQueryResponse;
|
|
84
104
|
"product-selection": ctp.ProductSelectionPagedQueryResponse;
|
|
85
105
|
"product-tailoring": ctp.ProductTailoringPagedQueryResponse;
|
|
86
106
|
"product-type": ctp.ProductTypePagedQueryResponse;
|
|
87
|
-
|
|
107
|
+
product: ctp.ProductPagedQueryResponse;
|
|
88
108
|
"quote-request": ctp.QuoteRequestPagedQueryResponse;
|
|
89
|
-
|
|
90
|
-
|
|
109
|
+
quote: ctp.QuotePagedQueryResponse;
|
|
110
|
+
review: ctp.ReviewPagedQueryResponse;
|
|
91
111
|
"shipping-method": ctp.ShippingMethodPagedQueryResponse;
|
|
92
112
|
"shopping-list": ctp.ShoppingListPagedQueryResponse;
|
|
93
113
|
"staged-quote": ctp.StagedQuotePagedQueryResponse;
|
|
94
114
|
"standalone-price": ctp.StandalonePricePagedQueryResponse;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
115
|
+
state: ctp.StatePagedQueryResponse;
|
|
116
|
+
store: ctp.StorePagedQueryResponse;
|
|
117
|
+
subscription: ctp.SubscriptionPagedQueryResponse;
|
|
98
118
|
"tax-category": ctp.TaxCategoryPagedQueryResponse;
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
type: ctp.TypePagedQueryResponse;
|
|
120
|
+
zone: ctp.ZonePagedQueryResponse;
|
|
101
121
|
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
QuoteRequest,
|
|
3
|
-
QuoteRequestDraft,
|
|
4
|
-
} from "@commercetools/platform-sdk";
|
|
5
|
-
import type { Config } from "~src/config";
|
|
6
|
-
import type { RepositoryContext } from "./abstract";
|
|
7
|
-
import { AbstractResourceRepository } from "./abstract";
|
|
8
|
-
|
|
9
|
-
export class QuoteRequestRepository extends AbstractResourceRepository<"quote-request"> {
|
|
10
|
-
constructor(config: Config) {
|
|
11
|
-
super("quote-request", config);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
create(context: RepositoryContext, draft: QuoteRequestDraft): QuoteRequest {
|
|
15
|
-
throw new Error("not implemented");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Quote, QuoteDraft } from "@commercetools/platform-sdk";
|
|
2
|
-
import type { Config } from "~src/config";
|
|
3
|
-
import type { RepositoryContext } from "./abstract";
|
|
4
|
-
import { AbstractResourceRepository } from "./abstract";
|
|
5
|
-
|
|
6
|
-
export class QuoteRepository extends AbstractResourceRepository<"quote"> {
|
|
7
|
-
constructor(config: Config) {
|
|
8
|
-
super("quote", config);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
create(context: RepositoryContext, draft: QuoteDraft): Quote {
|
|
12
|
-
throw new Error("not implemented");
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
StagedQuote,
|
|
3
|
-
StagedQuoteDraft,
|
|
4
|
-
} from "@commercetools/platform-sdk";
|
|
5
|
-
import type { Config } from "~src/config";
|
|
6
|
-
import type { RepositoryContext } from "./abstract";
|
|
7
|
-
import { AbstractResourceRepository } from "./abstract";
|
|
8
|
-
|
|
9
|
-
export class StagedQuoteRepository extends AbstractResourceRepository<"staged-quote"> {
|
|
10
|
-
constructor(config: Config) {
|
|
11
|
-
super("staged-quote", config);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
create(context: RepositoryContext, draft: StagedQuoteDraft): StagedQuote {
|
|
15
|
-
throw new Error("not implemented");
|
|
16
|
-
}
|
|
17
|
-
}
|