@labdigital/commercetools-mock 2.17.0 → 2.18.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 +4219 -3989
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +268 -415
- package/dist/index.d.ts +268 -415
- package/dist/index.js +4219 -3989
- package/dist/index.js.map +1 -1
- package/package.json +44 -46
- package/src/constants.ts +2 -2
- package/src/ctMock.test.ts +11 -11
- package/src/ctMock.ts +141 -127
- package/src/deprecation.ts +8 -0
- package/src/exceptions.ts +17 -15
- package/src/helpers.ts +32 -32
- package/src/index.test.ts +128 -128
- package/src/index.ts +3 -3
- package/src/lib/expandParser.ts +13 -13
- package/src/lib/haversine.test.ts +9 -9
- package/src/lib/haversine.ts +11 -11
- package/src/lib/masking.ts +11 -11
- package/src/lib/parser.ts +2 -2
- package/src/lib/password.ts +23 -3
- package/src/lib/predicateParser.test.ts +185 -183
- package/src/lib/predicateParser.ts +234 -234
- package/src/lib/projectionSearchFilter.test.ts +103 -101
- package/src/lib/projectionSearchFilter.ts +152 -150
- package/src/lib/proxy.ts +5 -5
- package/src/oauth/errors.ts +4 -4
- package/src/oauth/helpers.ts +6 -6
- package/src/oauth/server.test.ts +110 -67
- package/src/oauth/server.ts +161 -141
- package/src/oauth/store.ts +49 -44
- package/src/priceSelector.test.ts +35 -35
- package/src/priceSelector.ts +30 -30
- package/src/product-projection-search.ts +136 -134
- package/src/projectAPI.test.ts +7 -7
- package/src/projectAPI.ts +24 -22
- package/src/repositories/abstract.ts +168 -116
- package/src/repositories/associate-role.ts +90 -77
- package/src/repositories/attribute-group.ts +51 -40
- package/src/repositories/business-unit.ts +168 -148
- package/src/repositories/cart/actions.ts +489 -0
- package/src/repositories/cart/helpers.ts +30 -0
- package/src/repositories/cart/index.ts +180 -0
- package/src/repositories/cart-discount/actions.ts +148 -0
- package/src/repositories/cart-discount/index.ts +86 -0
- package/src/repositories/category/actions.ts +231 -0
- package/src/repositories/category/index.ts +52 -0
- package/src/repositories/channel.ts +88 -90
- package/src/repositories/custom-object.ts +46 -45
- package/src/repositories/customer/actions.ts +165 -0
- package/src/repositories/customer/index.ts +79 -0
- package/src/repositories/customer-group.ts +66 -55
- package/src/repositories/discount-code/actions.ts +149 -0
- package/src/repositories/discount-code/index.ts +50 -0
- package/src/repositories/errors.ts +10 -10
- package/src/repositories/extension.ts +64 -62
- package/src/repositories/helpers.ts +117 -118
- package/src/repositories/index.ts +80 -79
- package/src/repositories/inventory-entry/actions.ts +84 -0
- package/src/repositories/inventory-entry/index.ts +44 -0
- package/src/repositories/my-customer.ts +114 -0
- package/src/repositories/my-order.ts +8 -8
- package/src/repositories/order/actions.ts +281 -0
- package/src/repositories/{order.test.ts → order/index.test.ts} +77 -77
- package/src/repositories/order/index.ts +260 -0
- package/src/repositories/order-edit.ts +10 -23
- package/src/repositories/payment/actions.ts +305 -0
- package/src/repositories/payment/helpers.ts +17 -0
- package/src/repositories/payment/index.ts +56 -0
- package/src/repositories/product/actions.ts +943 -0
- package/src/repositories/product/helpers.ts +98 -0
- package/src/repositories/product/index.ts +130 -0
- package/src/repositories/product-discount.ts +127 -117
- package/src/repositories/product-projection.ts +56 -62
- package/src/repositories/product-selection.ts +31 -28
- package/src/repositories/product-type.ts +136 -134
- package/src/repositories/project.ts +133 -118
- package/src/repositories/quote-request.ts +7 -19
- package/src/repositories/quote.ts +7 -22
- package/src/repositories/review.ts +13 -26
- package/src/repositories/shipping-method/actions.ts +198 -0
- package/src/repositories/shipping-method/helpers.ts +10 -0
- package/src/repositories/shipping-method/index.ts +138 -0
- package/src/repositories/shopping-list/actions.ts +295 -0
- package/src/repositories/shopping-list/index.ts +122 -0
- package/src/repositories/staged-quote.ts +7 -20
- package/src/repositories/standalone-price.ts +57 -44
- package/src/repositories/state.ts +113 -68
- package/src/repositories/store.ts +106 -94
- package/src/repositories/subscription.ts +46 -22
- package/src/repositories/tax-category/actions.ts +94 -0
- package/src/repositories/tax-category/helpers.ts +8 -0
- package/src/repositories/tax-category/index.ts +25 -0
- package/src/repositories/type/actions.ts +162 -0
- package/src/repositories/type/index.ts +24 -0
- package/src/repositories/zone.ts +62 -58
- package/src/server.ts +9 -9
- package/src/services/abstract.ts +75 -72
- package/src/services/associate-roles.test.ts +27 -27
- package/src/services/associate-roles.ts +7 -7
- package/src/services/attribute-group.ts +7 -7
- package/src/services/business-units.test.ts +28 -28
- package/src/services/business-units.ts +7 -7
- package/src/services/cart-discount.test.ts +199 -199
- package/src/services/cart-discount.ts +7 -7
- package/src/services/cart.test.ts +261 -261
- package/src/services/cart.ts +22 -21
- package/src/services/category.test.ts +121 -121
- package/src/services/category.ts +7 -7
- package/src/services/channel.ts +7 -7
- package/src/services/custom-object.test.ts +130 -130
- package/src/services/custom-object.ts +34 -31
- package/src/services/customer-group.ts +7 -7
- package/src/services/customer.test.ts +205 -205
- package/src/services/customer.ts +31 -29
- package/src/services/discount-code.ts +7 -7
- package/src/services/extension.ts +7 -7
- package/src/services/index.ts +85 -81
- package/src/services/inventory-entry.test.ts +106 -106
- package/src/services/inventory-entry.ts +7 -7
- package/src/services/my-cart.test.ts +56 -56
- package/src/services/my-cart.ts +20 -20
- package/src/services/my-customer.test.ts +155 -104
- package/src/services/my-customer.ts +61 -75
- package/src/services/my-order.ts +16 -16
- package/src/services/my-payment.test.ts +40 -40
- package/src/services/my-payment.ts +7 -7
- package/src/services/my-shopping-list.ts +7 -7
- package/src/services/order.test.ts +243 -243
- package/src/services/order.ts +23 -18
- package/src/services/payment.test.ts +40 -40
- package/src/services/payment.ts +7 -7
- package/src/services/product-discount.ts +7 -7
- package/src/services/product-projection.test.ts +190 -190
- package/src/services/product-projection.ts +34 -32
- package/src/services/product-selection.test.ts +19 -19
- package/src/services/product-selection.ts +7 -7
- package/src/services/product-type.test.ts +38 -38
- package/src/services/product-type.ts +7 -7
- package/src/services/product.test.ts +658 -656
- package/src/services/product.ts +7 -7
- package/src/services/project.test.ts +24 -24
- package/src/services/project.ts +17 -17
- package/src/services/reviews.ts +7 -7
- package/src/services/shipping-method.test.ts +78 -78
- package/src/services/shipping-method.ts +16 -16
- package/src/services/shopping-list.test.ts +170 -170
- package/src/services/shopping-list.ts +7 -7
- package/src/services/standalone-price.test.ts +112 -112
- package/src/services/standalone-price.ts +7 -7
- package/src/services/state.test.ts +30 -30
- package/src/services/state.ts +7 -7
- package/src/services/store.test.ts +40 -40
- package/src/services/store.ts +7 -7
- package/src/services/subscription.ts +7 -7
- package/src/services/tax-category.test.ts +43 -43
- package/src/services/tax-category.ts +7 -7
- package/src/services/type.ts +7 -7
- package/src/services/zone.ts +7 -7
- package/src/shippingCalculator.test.ts +43 -43
- package/src/shippingCalculator.ts +23 -23
- package/src/storage/abstract.ts +36 -34
- package/src/storage/in-memory.ts +237 -233
- package/src/storage/index.ts +2 -2
- package/src/types.ts +91 -91
- package/src/repositories/cart-discount.ts +0 -219
- package/src/repositories/cart.ts +0 -659
- package/src/repositories/category.ts +0 -256
- package/src/repositories/customer.ts +0 -228
- package/src/repositories/discount-code.ts +0 -181
- package/src/repositories/inventory-entry.ts +0 -109
- package/src/repositories/order.ts +0 -514
- package/src/repositories/payment.ts +0 -342
- package/src/repositories/product.ts +0 -1106
- package/src/repositories/shipping-method.ts +0 -312
- package/src/repositories/shopping-list.ts +0 -392
- package/src/repositories/tax-category.ts +0 -111
- package/src/repositories/type.ts +0 -172
package/src/oauth/store.ts
CHANGED
|
@@ -1,79 +1,84 @@
|
|
|
1
|
-
import { randomBytes } from
|
|
2
|
-
import { v4 as uuidv4 } from
|
|
1
|
+
import { randomBytes } from "crypto";
|
|
2
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3
3
|
|
|
4
4
|
type Token = {
|
|
5
|
-
access_token: string
|
|
6
|
-
token_type:
|
|
7
|
-
expires_in: number
|
|
8
|
-
scope: string
|
|
9
|
-
refresh_token?: string
|
|
10
|
-
}
|
|
5
|
+
access_token: string;
|
|
6
|
+
token_type: "Bearer";
|
|
7
|
+
expires_in: number;
|
|
8
|
+
scope: string;
|
|
9
|
+
refresh_token?: string;
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
export class OAuth2Store {
|
|
13
|
-
tokens: Token[] = []
|
|
14
|
-
|
|
13
|
+
tokens: Token[] = [];
|
|
14
|
+
|
|
15
|
+
validate = true;
|
|
15
16
|
|
|
16
17
|
constructor(validate = true) {
|
|
17
|
-
this.validate = validate
|
|
18
|
+
this.validate = validate;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
addToken(token: Token) {
|
|
21
|
-
this.tokens.push(token)
|
|
22
|
+
this.tokens.push(token);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
getClientToken(clientId: string, clientSecret: string, scope?: string) {
|
|
25
26
|
const token: Token = {
|
|
26
|
-
access_token: randomBytes(16).toString(
|
|
27
|
-
token_type:
|
|
27
|
+
access_token: randomBytes(16).toString("base64"),
|
|
28
|
+
token_type: "Bearer",
|
|
28
29
|
expires_in: 172800,
|
|
29
|
-
scope: scope ||
|
|
30
|
-
refresh_token: `my-project-${randomBytes(16).toString(
|
|
31
|
-
}
|
|
32
|
-
this.addToken(token)
|
|
33
|
-
return token
|
|
30
|
+
scope: scope || "todo",
|
|
31
|
+
refresh_token: `my-project-${randomBytes(16).toString("base64")}`,
|
|
32
|
+
};
|
|
33
|
+
this.addToken(token);
|
|
34
|
+
return token;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
getAnonymousToken(
|
|
37
|
+
getAnonymousToken(
|
|
38
|
+
projectKey: string,
|
|
39
|
+
anonymousId: string | undefined,
|
|
40
|
+
scope: string,
|
|
41
|
+
) {
|
|
37
42
|
if (!anonymousId) {
|
|
38
|
-
anonymousId = uuidv4()
|
|
43
|
+
anonymousId = uuidv4();
|
|
39
44
|
}
|
|
40
45
|
const token: Token = {
|
|
41
|
-
access_token: randomBytes(16).toString(
|
|
42
|
-
token_type:
|
|
46
|
+
access_token: randomBytes(16).toString("base64"),
|
|
47
|
+
token_type: "Bearer",
|
|
43
48
|
expires_in: 172800,
|
|
44
49
|
scope: scope
|
|
45
50
|
? `${scope} anonymous_id:${anonymousId}`
|
|
46
51
|
: `anonymous_id:${anonymousId}`,
|
|
47
|
-
refresh_token:
|
|
48
|
-
}
|
|
49
|
-
this.addToken(token)
|
|
50
|
-
return token
|
|
52
|
+
refresh_token: `${projectKey}:${randomBytes(16).toString("base64")}`,
|
|
53
|
+
};
|
|
54
|
+
this.addToken(token);
|
|
55
|
+
return token;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
getCustomerToken(
|
|
58
|
+
getCustomerToken(projectKey: string, customerId: string, scope: string) {
|
|
54
59
|
const token: Token = {
|
|
55
|
-
access_token: randomBytes(16).toString(
|
|
56
|
-
token_type:
|
|
60
|
+
access_token: randomBytes(16).toString("base64"),
|
|
61
|
+
token_type: "Bearer",
|
|
57
62
|
expires_in: 172800,
|
|
58
63
|
scope: scope
|
|
59
64
|
? `${scope} customer_id:${customerId}`
|
|
60
65
|
: `customer_id:${customerId}`,
|
|
61
|
-
refresh_token:
|
|
62
|
-
}
|
|
63
|
-
this.addToken(token)
|
|
64
|
-
return token
|
|
66
|
+
refresh_token: `${projectKey}:${randomBytes(16).toString("base64")}`,
|
|
67
|
+
};
|
|
68
|
+
this.addToken(token);
|
|
69
|
+
return token;
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
refreshToken(clientId: string, clientSecret: string, refreshToken: string) {
|
|
68
|
-
const existing = this.tokens.find((t) => t.refresh_token === refreshToken)
|
|
73
|
+
const existing = this.tokens.find((t) => t.refresh_token === refreshToken);
|
|
69
74
|
if (!existing) {
|
|
70
|
-
return undefined
|
|
75
|
+
return undefined;
|
|
71
76
|
}
|
|
72
77
|
const token: Token = {
|
|
73
78
|
...existing,
|
|
74
|
-
access_token: randomBytes(16).toString(
|
|
75
|
-
}
|
|
76
|
-
this.addToken(token)
|
|
79
|
+
access_token: randomBytes(16).toString("base64"),
|
|
80
|
+
};
|
|
81
|
+
this.addToken(token);
|
|
77
82
|
|
|
78
83
|
// We don't want to return the refresh_token again
|
|
79
84
|
return {
|
|
@@ -81,16 +86,16 @@ export class OAuth2Store {
|
|
|
81
86
|
token_type: token.token_type,
|
|
82
87
|
expires_in: token.expires_in,
|
|
83
88
|
scope: token.scope,
|
|
84
|
-
}
|
|
89
|
+
};
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
validateToken(token: string) {
|
|
88
|
-
if (!this.validate) return true
|
|
93
|
+
if (!this.validate) return true;
|
|
89
94
|
|
|
90
|
-
const foundToken = this.tokens.find((t) => t.access_token === token)
|
|
95
|
+
const foundToken = this.tokens.find((t) => t.access_token === token);
|
|
91
96
|
if (foundToken) {
|
|
92
|
-
return true
|
|
97
|
+
return true;
|
|
93
98
|
}
|
|
94
|
-
return false
|
|
99
|
+
return false;
|
|
95
100
|
}
|
|
96
101
|
}
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import type { ProductProjection } from
|
|
2
|
-
import { beforeEach, describe, expect, test } from
|
|
3
|
-
import { applyPriceSelector } from
|
|
1
|
+
import type { ProductProjection } from "@commercetools/platform-sdk";
|
|
2
|
+
import { beforeEach, describe, expect, test } from "vitest";
|
|
3
|
+
import { applyPriceSelector } from "./priceSelector";
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
let product: ProductProjection
|
|
5
|
+
describe("priceSelector", () => {
|
|
6
|
+
let product: ProductProjection;
|
|
7
7
|
|
|
8
8
|
beforeEach(() => {
|
|
9
9
|
product = {
|
|
10
|
-
id:
|
|
10
|
+
id: "7401d82f-1378-47ba-996a-85beeb87ac87",
|
|
11
11
|
version: 2,
|
|
12
|
-
createdAt:
|
|
13
|
-
lastModifiedAt:
|
|
12
|
+
createdAt: "2022-07-22T10:02:40.851Z",
|
|
13
|
+
lastModifiedAt: "2022-07-22T10:02:44.427Z",
|
|
14
14
|
productType: {
|
|
15
|
-
typeId:
|
|
16
|
-
id:
|
|
15
|
+
typeId: "product-type",
|
|
16
|
+
id: "b9b4b426-938b-4ccb-9f36-c6f933e8446e",
|
|
17
17
|
},
|
|
18
18
|
name: {
|
|
19
|
-
|
|
19
|
+
"nl-NL": "test",
|
|
20
20
|
},
|
|
21
21
|
slug: {
|
|
22
|
-
|
|
22
|
+
"nl-NL": "test",
|
|
23
23
|
},
|
|
24
24
|
variants: [],
|
|
25
25
|
searchKeywords: {},
|
|
26
26
|
categories: [],
|
|
27
27
|
masterVariant: {
|
|
28
28
|
id: 1,
|
|
29
|
-
sku:
|
|
29
|
+
sku: "MYSKU",
|
|
30
30
|
attributes: [
|
|
31
31
|
{
|
|
32
|
-
name:
|
|
32
|
+
name: "Country",
|
|
33
33
|
value: {
|
|
34
|
-
key:
|
|
34
|
+
key: "NL",
|
|
35
35
|
label: {
|
|
36
|
-
de:
|
|
37
|
-
en:
|
|
38
|
-
nl:
|
|
36
|
+
de: "niederlande",
|
|
37
|
+
en: "netherlands",
|
|
38
|
+
nl: "nederland",
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
name:
|
|
43
|
+
name: "number",
|
|
44
44
|
value: 4,
|
|
45
45
|
},
|
|
46
46
|
],
|
|
47
47
|
prices: [
|
|
48
48
|
{
|
|
49
|
-
id:
|
|
49
|
+
id: "dummy-uuid",
|
|
50
50
|
value: {
|
|
51
|
-
type:
|
|
52
|
-
currencyCode:
|
|
51
|
+
type: "centPrecision",
|
|
52
|
+
currencyCode: "EUR",
|
|
53
53
|
centAmount: 1789,
|
|
54
54
|
fractionDigits: 2,
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
],
|
|
58
58
|
},
|
|
59
|
-
}
|
|
60
|
-
})
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
61
|
|
|
62
|
-
test(
|
|
63
|
-
applyPriceSelector([product], { currency:
|
|
62
|
+
test("currency (match)", async () => {
|
|
63
|
+
applyPriceSelector([product], { currency: "EUR" });
|
|
64
64
|
|
|
65
65
|
expect(product).toMatchObject({
|
|
66
66
|
masterVariant: {
|
|
67
|
-
sku:
|
|
67
|
+
sku: "MYSKU",
|
|
68
68
|
scopedPrice: { value: { centAmount: 1789 } },
|
|
69
69
|
},
|
|
70
|
-
})
|
|
71
|
-
})
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
72
|
|
|
73
|
-
test(
|
|
74
|
-
applyPriceSelector([product], { currency:
|
|
75
|
-
expect(product.masterVariant.scopedPrice).toBeUndefined()
|
|
76
|
-
expect(product.masterVariant.scopedPrice).toBeUndefined()
|
|
77
|
-
})
|
|
78
|
-
})
|
|
73
|
+
test("currency, country (no match)", async () => {
|
|
74
|
+
applyPriceSelector([product], { currency: "EUR", country: "US" });
|
|
75
|
+
expect(product.masterVariant.scopedPrice).toBeUndefined();
|
|
76
|
+
expect(product.masterVariant.scopedPrice).toBeUndefined();
|
|
77
|
+
});
|
|
78
|
+
});
|
package/src/priceSelector.ts
CHANGED
|
@@ -3,16 +3,16 @@ import type {
|
|
|
3
3
|
Price,
|
|
4
4
|
ProductProjection,
|
|
5
5
|
ProductVariant,
|
|
6
|
-
} from
|
|
7
|
-
import { CommercetoolsError } from
|
|
8
|
-
import type { Writable } from
|
|
6
|
+
} from "@commercetools/platform-sdk";
|
|
7
|
+
import { CommercetoolsError } from "./exceptions";
|
|
8
|
+
import type { Writable } from "./types";
|
|
9
9
|
|
|
10
10
|
export type PriceSelector = {
|
|
11
|
-
currency?: string
|
|
12
|
-
country?: string
|
|
13
|
-
customerGroup?: string
|
|
14
|
-
channel?: string
|
|
15
|
-
}
|
|
11
|
+
currency?: string;
|
|
12
|
+
country?: string;
|
|
13
|
+
customerGroup?: string;
|
|
14
|
+
channel?: string;
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Apply the price selector on all the variants. The price selector is applied
|
|
@@ -22,36 +22,36 @@ export type PriceSelector = {
|
|
|
22
22
|
export const applyPriceSelector = (
|
|
23
23
|
products: ProductProjection[],
|
|
24
24
|
selector: PriceSelector,
|
|
25
|
-
noScopedPrice: boolean = false
|
|
25
|
+
noScopedPrice: boolean = false,
|
|
26
26
|
) => {
|
|
27
|
-
validatePriceSelector(selector)
|
|
27
|
+
validatePriceSelector(selector);
|
|
28
28
|
|
|
29
29
|
for (const product of products) {
|
|
30
30
|
// Get list of all variants (master + variants)
|
|
31
31
|
const variants: Writable<ProductVariant>[] = [
|
|
32
32
|
product.masterVariant,
|
|
33
33
|
...(product.variants ?? []),
|
|
34
|
-
].filter((x) => x != undefined)
|
|
34
|
+
].filter((x) => x != undefined);
|
|
35
35
|
|
|
36
36
|
for (const variant of variants) {
|
|
37
37
|
const scopedPrices =
|
|
38
|
-
variant.prices?.filter((p) => priceSelectorFilter(p, selector)) ?? []
|
|
38
|
+
variant.prices?.filter((p) => priceSelectorFilter(p, selector)) ?? [];
|
|
39
39
|
|
|
40
40
|
if (scopedPrices.length > 0) {
|
|
41
|
-
const price = scopedPrices[0]
|
|
41
|
+
const price = scopedPrices[0];
|
|
42
42
|
|
|
43
|
-
variant.price = scopedPrices[0]
|
|
43
|
+
variant.price = scopedPrices[0];
|
|
44
44
|
if (!noScopedPrice) {
|
|
45
|
-
variant.scopedPriceDiscounted = false
|
|
45
|
+
variant.scopedPriceDiscounted = false;
|
|
46
46
|
variant.scopedPrice = {
|
|
47
47
|
...price,
|
|
48
48
|
currentValue: price.value,
|
|
49
|
-
}
|
|
49
|
+
};
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
};
|
|
55
55
|
|
|
56
56
|
const validatePriceSelector = (selector: PriceSelector) => {
|
|
57
57
|
if (
|
|
@@ -60,15 +60,15 @@ const validatePriceSelector = (selector: PriceSelector) => {
|
|
|
60
60
|
) {
|
|
61
61
|
throw new CommercetoolsError<InvalidInputError>(
|
|
62
62
|
{
|
|
63
|
-
code:
|
|
63
|
+
code: "InvalidInput",
|
|
64
64
|
message:
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
"The price selecting parameters country, channel and customerGroup " +
|
|
66
|
+
"cannot be used without the currency.",
|
|
67
67
|
},
|
|
68
|
-
400
|
|
69
|
-
)
|
|
68
|
+
400,
|
|
69
|
+
);
|
|
70
70
|
}
|
|
71
|
-
}
|
|
71
|
+
};
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Return a boolean to indicate if the price matches the selector. Price
|
|
@@ -77,35 +77,35 @@ const validatePriceSelector = (selector: PriceSelector) => {
|
|
|
77
77
|
*/
|
|
78
78
|
export const priceSelectorFilter = (
|
|
79
79
|
price: Price,
|
|
80
|
-
selector: PriceSelector
|
|
80
|
+
selector: PriceSelector,
|
|
81
81
|
): boolean => {
|
|
82
82
|
if (
|
|
83
83
|
(selector.country || price.country) &&
|
|
84
84
|
selector.country !== price.country
|
|
85
85
|
) {
|
|
86
|
-
return false
|
|
86
|
+
return false;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
if (
|
|
90
90
|
(selector.currency || price.value.currencyCode) &&
|
|
91
91
|
selector.currency !== price.value.currencyCode
|
|
92
92
|
) {
|
|
93
|
-
return false
|
|
93
|
+
return false;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (
|
|
97
97
|
(selector.channel || price.channel?.id) &&
|
|
98
98
|
selector.channel !== price.channel?.id
|
|
99
99
|
) {
|
|
100
|
-
return false
|
|
100
|
+
return false;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
if (
|
|
104
104
|
(selector.customerGroup || price.customerGroup?.id) &&
|
|
105
105
|
selector.customerGroup !== price.customerGroup?.id
|
|
106
106
|
) {
|
|
107
|
-
return false
|
|
107
|
+
return false;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
return true
|
|
111
|
-
}
|
|
110
|
+
return true;
|
|
111
|
+
};
|