@labdigital/commercetools-mock 2.46.0 → 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 +568 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +782 -58
- package/dist/index.d.ts +782 -58
- package/dist/index.js +556 -229
- 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 +62 -62
- package/src/lib/predicateParser.ts +32 -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/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 +8 -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 +15 -15
- package/src/services/category.test.ts +1 -1
- package/src/services/customer.test.ts +4 -4
- 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 +1 -1
- 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 +1 -1
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
1
2
|
import type { Order, Payment, State } from "@commercetools/platform-sdk";
|
|
2
|
-
import assert from "assert";
|
|
3
3
|
import supertest from "supertest";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
5
5
|
import { generateRandomString } from "~src/helpers";
|
|
@@ -46,7 +46,7 @@ describe("Order Query", () => {
|
|
|
46
46
|
test("no filter", async () => {
|
|
47
47
|
assert(order, "order not created");
|
|
48
48
|
|
|
49
|
-
const response = await supertest(ctMock.app).get(
|
|
49
|
+
const response = await supertest(ctMock.app).get("/dummy/orders");
|
|
50
50
|
expect(response.status).toBe(200);
|
|
51
51
|
expect(response.body.count).toBe(1);
|
|
52
52
|
expect(response.body.total).toBe(1);
|
|
@@ -59,14 +59,14 @@ describe("Order Query", () => {
|
|
|
59
59
|
|
|
60
60
|
{
|
|
61
61
|
const response = await supertest(ctMock.app)
|
|
62
|
-
.get(
|
|
62
|
+
.get("/dummy/orders")
|
|
63
63
|
.query({ where: 'orderNumber="nomatch"' });
|
|
64
64
|
expect(response.status).toBe(200);
|
|
65
65
|
expect(response.body.count).toBe(0);
|
|
66
66
|
}
|
|
67
67
|
{
|
|
68
68
|
const response = await supertest(ctMock.app)
|
|
69
|
-
.get(
|
|
69
|
+
.get("/dummy/orders")
|
|
70
70
|
.query({ where: 'orderNumber="foobar"' });
|
|
71
71
|
expect(response.status).toBe(200);
|
|
72
72
|
expect(response.body.count).toBe(1);
|
|
@@ -171,7 +171,7 @@ describe("Order payment tests", () => {
|
|
|
171
171
|
ctMock.project().add("order", order);
|
|
172
172
|
|
|
173
173
|
const response = await supertest(ctMock.app)
|
|
174
|
-
.get(
|
|
174
|
+
.get("/dummy/orders")
|
|
175
175
|
.query({ where: `paymentInfo(payments(id="${payment.id}"))` });
|
|
176
176
|
|
|
177
177
|
expect(response.status).toBe(200);
|
|
@@ -179,8 +179,8 @@ describe("Order payment tests", () => {
|
|
|
179
179
|
|
|
180
180
|
{
|
|
181
181
|
const response = await supertest(ctMock.app)
|
|
182
|
-
.get(
|
|
183
|
-
.query({ where:
|
|
182
|
+
.get("/dummy/orders")
|
|
183
|
+
.query({ where: "paymentInfo(payments(id is defined))" });
|
|
184
184
|
|
|
185
185
|
expect(response.status).toBe(200);
|
|
186
186
|
expect(response.body.results[0].id).toBe(order.id);
|
|
@@ -800,7 +800,7 @@ describe("Order Import", () => {
|
|
|
800
800
|
|
|
801
801
|
test("Import", async () => {
|
|
802
802
|
const response = await supertest(ctMock.app)
|
|
803
|
-
.post(
|
|
803
|
+
.post("/dummy/orders/import")
|
|
804
804
|
.send({
|
|
805
805
|
orderNumber: "100000001",
|
|
806
806
|
totalPrice: {
|
|
@@ -181,7 +181,7 @@ beforeEach(async () => {
|
|
|
181
181
|
],
|
|
182
182
|
assets: [],
|
|
183
183
|
images: [],
|
|
184
|
-
attributes: productDraft.variants
|
|
184
|
+
attributes: productDraft.variants?.[0].attributes,
|
|
185
185
|
},
|
|
186
186
|
],
|
|
187
187
|
name: productDraft.name,
|
|
@@ -236,8 +236,8 @@ describe("Product Projection Query - Generic", () => {
|
|
|
236
236
|
const response = await supertest(ctMock.app)
|
|
237
237
|
.get("/dummy/product-projections")
|
|
238
238
|
.query({
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
limit: 50,
|
|
240
|
+
where: ["slug(nl-NL=:slug)"],
|
|
241
241
|
"var.slug": "test-product",
|
|
242
242
|
});
|
|
243
243
|
|
|
@@ -257,8 +257,8 @@ describe("Product Projection Query - Generic", () => {
|
|
|
257
257
|
const response = await supertest(ctMock.app)
|
|
258
258
|
.get("/dummy/product-projections")
|
|
259
259
|
.query({
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
limit: 50,
|
|
261
|
+
where: ["slug(nl-NL=:slug)"],
|
|
262
262
|
"var.slug": "missing-product",
|
|
263
263
|
});
|
|
264
264
|
|
|
@@ -40,21 +40,19 @@ export class ProductProjectionService extends AbstractService {
|
|
|
40
40
|
search(request: Request, response: Response) {
|
|
41
41
|
const query = request.query;
|
|
42
42
|
const searchParams: ProductProjectionQueryParams = {
|
|
43
|
-
|
|
43
|
+
filter: queryParamsArray(query.filter),
|
|
44
44
|
"filter.query": queryParamsArray(query["filter.query"]),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
: undefined,
|
|
57
|
-
"limit": query.limit ? Number(queryParamsValue(query.limit)) : undefined,
|
|
45
|
+
facet: queryParamsArray(query.facet),
|
|
46
|
+
expand: queryParamsArray(query.expand),
|
|
47
|
+
staged: queryParamsValue(query.staged) === "true",
|
|
48
|
+
localeProjection: queryParamsValue(query.localeProjection),
|
|
49
|
+
storeProjection: queryParamsValue(query.storeProjection),
|
|
50
|
+
priceChannel: queryParamsValue(query.priceChannel),
|
|
51
|
+
priceCountry: queryParamsValue(query.priceCountry),
|
|
52
|
+
priceCurrency: queryParamsValue(query.priceCurrency),
|
|
53
|
+
priceCustomerGroup: queryParamsValue(query.priceCustomerGroup),
|
|
54
|
+
offset: query.offset ? Number(queryParamsValue(query.offset)) : undefined,
|
|
55
|
+
limit: query.limit ? Number(queryParamsValue(query.limit)) : undefined,
|
|
58
56
|
};
|
|
59
57
|
const resource = this.repository.search(
|
|
60
58
|
getRepositoryContext(request),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
1
2
|
import type {
|
|
2
3
|
Category,
|
|
3
4
|
CategoryDraft,
|
|
@@ -19,7 +20,6 @@ import type {
|
|
|
19
20
|
Type,
|
|
20
21
|
TypeDraft,
|
|
21
22
|
} from "@commercetools/platform-sdk";
|
|
22
|
-
import assert from "assert";
|
|
23
23
|
import supertest from "supertest";
|
|
24
24
|
import {
|
|
25
25
|
afterAll,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import supertest from "supertest";
|
|
2
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
3
|
+
import { customerDraftFactory } from "~src/testing/customer";
|
|
4
|
+
import { CommercetoolsMock } from "../index";
|
|
5
|
+
|
|
6
|
+
describe("Quote Request Create", () => {
|
|
7
|
+
const ctMock = new CommercetoolsMock();
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
ctMock.clear();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should create a quote request", async () => {
|
|
14
|
+
const customer = await customerDraftFactory(ctMock).create();
|
|
15
|
+
let response = await supertest(ctMock.app)
|
|
16
|
+
.post("/dummy/carts")
|
|
17
|
+
.send({
|
|
18
|
+
currency: "EUR",
|
|
19
|
+
customerId: customer.id,
|
|
20
|
+
custom: {
|
|
21
|
+
type: {
|
|
22
|
+
key: "my-cart",
|
|
23
|
+
},
|
|
24
|
+
fields: {
|
|
25
|
+
description: "example description",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
expect(response.status).toBe(201);
|
|
30
|
+
const cart = response.body;
|
|
31
|
+
|
|
32
|
+
response = await supertest(ctMock.app)
|
|
33
|
+
.post("/dummy/quote-requests")
|
|
34
|
+
.send({
|
|
35
|
+
cart: {
|
|
36
|
+
typeId: "cart",
|
|
37
|
+
id: cart.id,
|
|
38
|
+
},
|
|
39
|
+
cartVersion: cart.version,
|
|
40
|
+
});
|
|
41
|
+
expect(response.status).toBe(201);
|
|
42
|
+
const quote = response.body;
|
|
43
|
+
|
|
44
|
+
expect(quote.cart).toEqual({
|
|
45
|
+
typeId: "cart",
|
|
46
|
+
id: cart.id,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
response = await supertest(ctMock.app)
|
|
50
|
+
.get(`/dummy/quote-requests/${quote.id}`)
|
|
51
|
+
.send();
|
|
52
|
+
|
|
53
|
+
const quoteResult = response.body;
|
|
54
|
+
expect(quoteResult.cart).toEqual({
|
|
55
|
+
typeId: "cart",
|
|
56
|
+
id: cart.id,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Router } from "express";
|
|
2
|
+
import type { QuoteRequestRepository } from "~src/repositories/quote-request";
|
|
3
|
+
import AbstractService from "./abstract";
|
|
4
|
+
|
|
5
|
+
export class QuoteRequestService extends AbstractService {
|
|
6
|
+
public repository: QuoteRequestRepository;
|
|
7
|
+
|
|
8
|
+
constructor(parent: Router, repository: QuoteRequestRepository) {
|
|
9
|
+
super(parent);
|
|
10
|
+
this.repository = repository;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getBasePath() {
|
|
14
|
+
return "quote-requests";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Router } from "express";
|
|
2
|
+
import type { StagedQuoteRepository } from "~src/repositories/quote-staged";
|
|
3
|
+
import AbstractService from "./abstract";
|
|
4
|
+
|
|
5
|
+
export class StagedQuoteService extends AbstractService {
|
|
6
|
+
public repository: StagedQuoteRepository;
|
|
7
|
+
|
|
8
|
+
constructor(parent: Router, repository: StagedQuoteRepository) {
|
|
9
|
+
super(parent);
|
|
10
|
+
this.repository = repository;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getBasePath() {
|
|
14
|
+
return "staged-quotes";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Router } from "express";
|
|
2
|
+
import type { QuoteRepository } from "~src/repositories/quote";
|
|
3
|
+
import AbstractService from "./abstract";
|
|
4
|
+
|
|
5
|
+
export class QuoteService extends AbstractService {
|
|
6
|
+
public repository: QuoteRepository;
|
|
7
|
+
|
|
8
|
+
constructor(parent: Router, repository: QuoteRepository) {
|
|
9
|
+
super(parent);
|
|
10
|
+
this.repository = repository;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getBasePath() {
|
|
14
|
+
return "quotes";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -120,7 +120,7 @@ describe("Standalone price Actions", () => {
|
|
|
120
120
|
|
|
121
121
|
test("changeValue", async () => {
|
|
122
122
|
const response = await supertest(ctMock.app)
|
|
123
|
-
.post(
|
|
123
|
+
.post(`/dummy/standalone-prices/${id}`)
|
|
124
124
|
.send({
|
|
125
125
|
version: 1,
|
|
126
126
|
actions: [
|
|
@@ -159,7 +159,7 @@ describe("Standalone price Actions", () => {
|
|
|
159
159
|
|
|
160
160
|
test("setActive", async () => {
|
|
161
161
|
const response = await supertest(ctMock.app)
|
|
162
|
-
.post(
|
|
162
|
+
.post(`/dummy/standalone-prices/${id}`)
|
|
163
163
|
.send({
|
|
164
164
|
version: 1,
|
|
165
165
|
actions: [
|
|
@@ -195,7 +195,7 @@ describe("Standalone price Actions", () => {
|
|
|
195
195
|
|
|
196
196
|
test("setDiscounted", async () => {
|
|
197
197
|
const response = await supertest(ctMock.app)
|
|
198
|
-
.post(
|
|
198
|
+
.post(`/dummy/standalone-prices/${id}`)
|
|
199
199
|
.send({
|
|
200
200
|
version: 1,
|
|
201
201
|
actions: [
|
|
@@ -250,7 +250,7 @@ describe("Standalone price Actions", () => {
|
|
|
250
250
|
});
|
|
251
251
|
|
|
252
252
|
const response2 = await supertest(ctMock.app)
|
|
253
|
-
.post(
|
|
253
|
+
.post(`/dummy/standalone-prices/${id}`)
|
|
254
254
|
.send({
|
|
255
255
|
version: 2,
|
|
256
256
|
actions: [
|
|
@@ -21,7 +21,7 @@ describe("Store", () => {
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
const response = await supertest(ctMock.app).get(
|
|
24
|
-
|
|
24
|
+
"/dummy/stores/key=STOREKEY",
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
expect(response.status).toBe(200);
|
|
@@ -54,7 +54,7 @@ describe("Store", () => {
|
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
const response = await supertest(ctMock.app).get(
|
|
57
|
-
|
|
57
|
+
"/dummy/stores/key=DOESNOTEXIST",
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
expect(response.status).toBe(404);
|
|
@@ -65,7 +65,7 @@ describe("Tax Category", () => {
|
|
|
65
65
|
expect(createResponse.status).toBe(201);
|
|
66
66
|
|
|
67
67
|
const response = await supertest(ctMock.app)
|
|
68
|
-
.get(
|
|
68
|
+
.get("/dummy/tax-categories/")
|
|
69
69
|
.query({ where: `key="${createResponse.body.key}"` });
|
|
70
70
|
|
|
71
71
|
expect(response.status).toBe(200);
|
package/src/shipping.ts
CHANGED
|
@@ -106,12 +106,12 @@ export const getShippingMethodsMatchingCart = (
|
|
|
106
106
|
context.projectKey,
|
|
107
107
|
"shipping-method",
|
|
108
108
|
{
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
where: [
|
|
110
|
+
"zoneRates(zone(id in (:zoneIds)))",
|
|
111
111
|
`zoneRates(shippingRates(price(currencyCode="${cart.totalPrice.currencyCode}")))`,
|
|
112
112
|
],
|
|
113
113
|
"var.zoneIds": zoneIds,
|
|
114
|
-
|
|
114
|
+
expand: params.expand,
|
|
115
115
|
},
|
|
116
116
|
);
|
|
117
117
|
|
package/src/storage/in-memory.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
1
2
|
import type {
|
|
2
3
|
InvalidJsonInputError,
|
|
3
4
|
ReferencedResourceNotFoundError,
|
|
4
5
|
ShoppingListLineItem,
|
|
5
6
|
} from "@commercetools/platform-sdk";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
7
|
+
import type {
|
|
8
|
+
AssociateRole,
|
|
9
|
+
AttributeGroup,
|
|
10
|
+
BusinessUnit,
|
|
11
|
+
Cart,
|
|
12
|
+
CartDiscount,
|
|
13
|
+
Category,
|
|
14
|
+
Channel,
|
|
15
|
+
CustomObject,
|
|
16
|
+
Customer,
|
|
17
|
+
CustomerGroup,
|
|
18
|
+
DiscountCode,
|
|
19
|
+
Extension,
|
|
20
|
+
InvalidInputError,
|
|
21
|
+
InventoryEntry,
|
|
22
|
+
Order,
|
|
23
|
+
PagedQueryResponse,
|
|
24
|
+
Payment,
|
|
25
|
+
Product,
|
|
26
|
+
ProductDiscount,
|
|
27
|
+
ProductProjection,
|
|
28
|
+
ProductTailoring,
|
|
29
|
+
ProductType,
|
|
30
|
+
Project,
|
|
31
|
+
Quote,
|
|
32
|
+
QuoteRequest,
|
|
33
|
+
Reference,
|
|
34
|
+
ResourceIdentifier,
|
|
35
|
+
ShippingMethod,
|
|
36
|
+
ShoppingList,
|
|
37
|
+
StagedQuote,
|
|
38
|
+
State,
|
|
39
|
+
Store,
|
|
40
|
+
Subscription,
|
|
41
|
+
TaxCategory,
|
|
42
|
+
Type,
|
|
43
|
+
Zone,
|
|
43
44
|
} from "@commercetools/platform-sdk";
|
|
44
|
-
import assert from "assert";
|
|
45
45
|
import { CommercetoolsError } from "~src/exceptions";
|
|
46
46
|
import { cloneObject } from "../helpers";
|
|
47
47
|
import { parseExpandClause } from "../lib/expandParser";
|
|
@@ -174,38 +174,38 @@ export class InMemoryStorage extends AbstractStorage {
|
|
|
174
174
|
"associate-role": new Map<string, AssociateRole>(),
|
|
175
175
|
"attribute-group": new Map<string, AttributeGroup>(),
|
|
176
176
|
"business-unit": new Map<string, BusinessUnit>(),
|
|
177
|
-
|
|
177
|
+
cart: new Map<string, Cart>(),
|
|
178
178
|
"cart-discount": new Map<string, CartDiscount>(),
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
category: new Map<string, Category>(),
|
|
180
|
+
channel: new Map<string, Channel>(),
|
|
181
|
+
customer: new Map<string, Customer>(),
|
|
182
182
|
"customer-group": new Map<string, CustomerGroup>(),
|
|
183
183
|
"discount-code": new Map<string, DiscountCode>(),
|
|
184
|
-
|
|
184
|
+
extension: new Map<string, Extension>(),
|
|
185
185
|
"inventory-entry": new Map<string, InventoryEntry>(),
|
|
186
186
|
"key-value-document": new Map<string, CustomObject>(),
|
|
187
|
-
|
|
187
|
+
order: new Map<string, Order>(),
|
|
188
188
|
"order-edit": new Map<string, any>(),
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
payment: new Map<string, Payment>(),
|
|
190
|
+
product: new Map<string, Product>(),
|
|
191
|
+
quote: new Map<string, Quote>(),
|
|
192
192
|
"quote-request": new Map<string, QuoteRequest>(),
|
|
193
193
|
"product-discount": new Map<string, ProductDiscount>(),
|
|
194
194
|
"product-selection": new Map<string, any>(),
|
|
195
195
|
"product-type": new Map<string, ProductType>(),
|
|
196
196
|
"product-projection": new Map<string, ProductProjection>(),
|
|
197
197
|
"product-tailoring": new Map<string, ProductTailoring>(),
|
|
198
|
-
|
|
198
|
+
review: new Map<string, any>(),
|
|
199
199
|
"shipping-method": new Map<string, ShippingMethod>(),
|
|
200
200
|
"staged-quote": new Map<string, StagedQuote>(),
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
state: new Map<string, State>(),
|
|
202
|
+
store: new Map<string, Store>(),
|
|
203
203
|
"shopping-list": new Map<string, ShoppingList>(),
|
|
204
204
|
"standalone-price": new Map<string, any>(),
|
|
205
|
-
|
|
205
|
+
subscription: new Map<string, Subscription>(),
|
|
206
206
|
"tax-category": new Map<string, TaxCategory>(),
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
type: new Map<string, Type>(),
|
|
208
|
+
zone: new Map<string, Zone>(),
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
211
|
return projectStorage;
|
|
@@ -416,11 +416,7 @@ export class InMemoryStorage extends AbstractStorage {
|
|
|
416
416
|
|
|
417
417
|
throw new CommercetoolsError<ReferencedResourceNotFoundError>({
|
|
418
418
|
code: "ReferencedResourceNotFound",
|
|
419
|
-
message:
|
|
420
|
-
`The referenced object of type '${identifier.typeId}' with id ` +
|
|
421
|
-
`'${identifier.id}' was not found. It either doesn't exist, or it ` +
|
|
422
|
-
`can't be accessed from this endpoint (e.g., if the endpoint ` +
|
|
423
|
-
`filters by store or customer account).`,
|
|
419
|
+
message: `The referenced object of type '${identifier.typeId}' with id '${identifier.id}' was not found. It either doesn't exist, or it can't be accessed from this endpoint (e.g., if the endpoint filters by store or customer account).`,
|
|
424
420
|
typeId: identifier.typeId,
|
|
425
421
|
id: identifier.id,
|
|
426
422
|
});
|
|
@@ -438,11 +434,7 @@ export class InMemoryStorage extends AbstractStorage {
|
|
|
438
434
|
|
|
439
435
|
throw new CommercetoolsError<ReferencedResourceNotFoundError>({
|
|
440
436
|
code: "ReferencedResourceNotFound",
|
|
441
|
-
message:
|
|
442
|
-
`The referenced object of type '${identifier.typeId}' with key ` +
|
|
443
|
-
`'${identifier.key}' was not found. It either doesn't exist, or it ` +
|
|
444
|
-
`can't be accessed from this endpoint (e.g., if the endpoint ` +
|
|
445
|
-
`filters by store or customer account).`,
|
|
437
|
+
message: `The referenced object of type '${identifier.typeId}' with key '${identifier.key}' was not found. It either doesn't exist, or it can't be accessed from this endpoint (e.g., if the endpoint filters by store or customer account).`,
|
|
446
438
|
typeId: identifier.typeId,
|
|
447
439
|
key: identifier.key,
|
|
448
440
|
});
|
package/src/testing/customer.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const customerDraftFactory = (m: CommercetoolsMock) =>
|
|
|
7
7
|
Factory.define<CustomerDraft, CustomerDraft, Customer>(({ onCreate }) => {
|
|
8
8
|
onCreate(async (draft) => {
|
|
9
9
|
const response = await supertest(m.app)
|
|
10
|
-
.post(
|
|
10
|
+
.post("/dummy/customers")
|
|
11
11
|
.send(draft);
|
|
12
12
|
|
|
13
13
|
return response.body.customer;
|
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
|
};
|