@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
|
@@ -98,6 +98,13 @@ export const parseSearchQuery = (
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
if (isSearchExactExpression(searchQuery)) {
|
|
101
|
+
if (Array.isArray(searchQuery.exact.values)) {
|
|
102
|
+
return generateFieldMatchFunc(
|
|
103
|
+
(value: any) => (searchQuery.exact.values ?? []).includes(value),
|
|
104
|
+
searchQuery.exact,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
101
108
|
return generateFieldMatchFunc(
|
|
102
109
|
(value: any) => value === searchQuery.exact.value,
|
|
103
110
|
searchQuery.exact,
|
|
@@ -68,8 +68,8 @@ describe("Search filter", () => {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
test("by product key", async () => {
|
|
71
|
-
expect(match(
|
|
72
|
-
expect(match(
|
|
71
|
+
expect(match("key:exists").isMatch).toBeTruthy();
|
|
72
|
+
expect(match("key:missing").isMatch).toBeFalsy();
|
|
73
73
|
expect(match(`key:"test-product"`).isMatch).toBeTruthy();
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -80,29 +80,29 @@ describe("Search filter", () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
test("by SKU", async () => {
|
|
83
|
-
expect(match(
|
|
84
|
-
expect(match(
|
|
83
|
+
expect(match("variants.sku:exists").isMatch).toBeTruthy();
|
|
84
|
+
expect(match("variants.sku:missing").isMatch).toBeFalsy();
|
|
85
85
|
expect(match(`variants.sku:"MYSKU"`).isMatch).toBeTruthy();
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
test("by attribute value", async () => {
|
|
89
|
-
expect(match(
|
|
90
|
-
expect(match(
|
|
91
|
-
expect(match(
|
|
92
|
-
expect(match(
|
|
89
|
+
expect(match("variants.attributes.number:4").isMatch).toBeTruthy();
|
|
90
|
+
expect(match("variants.attributes.number:3,4").isMatch).toBeTruthy();
|
|
91
|
+
expect(match("variants.attributes.number:3,4,5").isMatch).toBeTruthy();
|
|
92
|
+
expect(match("variants.attributes.number:1,2,3,5").isMatch).toBeFalsy();
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
test("by attribute range", async () => {
|
|
96
96
|
expect(
|
|
97
|
-
match(
|
|
97
|
+
match("variants.attributes.number:range (0 TO 5)").isMatch,
|
|
98
98
|
).toBeTruthy();
|
|
99
99
|
|
|
100
100
|
expect(
|
|
101
|
-
match(
|
|
101
|
+
match("variants.attributes.number:range (* TO 5)").isMatch,
|
|
102
102
|
).toBeTruthy();
|
|
103
103
|
|
|
104
104
|
expect(
|
|
105
|
-
match(
|
|
105
|
+
match("variants.attributes.number:range (* TO *)").isMatch,
|
|
106
106
|
).toBeTruthy();
|
|
107
107
|
});
|
|
108
108
|
|
|
@@ -118,14 +118,14 @@ describe("Search filter", () => {
|
|
|
118
118
|
|
|
119
119
|
test("by price range", async () => {
|
|
120
120
|
expect(
|
|
121
|
-
match(
|
|
121
|
+
match("variants.price.centAmount:range (1500 TO 2000)").isMatch,
|
|
122
122
|
).toBeTruthy();
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
test("by price range - or", async () => {
|
|
126
126
|
expect(
|
|
127
127
|
match(
|
|
128
|
-
|
|
128
|
+
"variants.price.centAmount:range (2 TO 1500 ), (1500 TO 3000), (3000 TO 6000)",
|
|
129
129
|
).isMatch,
|
|
130
130
|
).toBeTruthy();
|
|
131
131
|
});
|
|
@@ -136,7 +136,7 @@ describe("Search filter", () => {
|
|
|
136
136
|
|
|
137
137
|
// No currency given
|
|
138
138
|
result = match(
|
|
139
|
-
|
|
139
|
+
"variants.scopedPrice.value.centAmount:range (1500 TO 2000)",
|
|
140
140
|
);
|
|
141
141
|
expect(result.isMatch).toBeFalsy();
|
|
142
142
|
|
|
@@ -145,7 +145,7 @@ describe("Search filter", () => {
|
|
|
145
145
|
applyPriceSelector(products, { currency: "EUR" });
|
|
146
146
|
|
|
147
147
|
result = match(
|
|
148
|
-
|
|
148
|
+
"variants.scopedPrice.value.centAmount:range (1500 TO 2000)",
|
|
149
149
|
products[0],
|
|
150
150
|
);
|
|
151
151
|
expect(result.isMatch).toBeTruthy();
|
|
@@ -161,7 +161,7 @@ describe("Search filter", () => {
|
|
|
161
161
|
applyPriceSelector(products, { currency: "USD" });
|
|
162
162
|
|
|
163
163
|
result = match(
|
|
164
|
-
|
|
164
|
+
"variants.scopedPrice.value.centAmount:range (1500 TO 2000)",
|
|
165
165
|
products[0],
|
|
166
166
|
);
|
|
167
167
|
expect(result.isMatch).toBeFalsy();
|
|
@@ -170,7 +170,7 @@ describe("Search filter", () => {
|
|
|
170
170
|
products = [cloneObject(exampleProduct)];
|
|
171
171
|
applyPriceSelector(products, { currency: "EUR", country: "NL" });
|
|
172
172
|
result = match(
|
|
173
|
-
|
|
173
|
+
"variants.scopedPrice.value.centAmount:range (1500 TO 2000)",
|
|
174
174
|
products[0],
|
|
175
175
|
);
|
|
176
176
|
expect(result.isMatch).toBeFalsy();
|
|
@@ -154,7 +154,7 @@ const parseFilter = (filter: string): ExpressionSet => {
|
|
|
154
154
|
({
|
|
155
155
|
type: "Symbol",
|
|
156
156
|
kind: "int",
|
|
157
|
-
value: parseInt(t.token.match, 10),
|
|
157
|
+
value: Number.parseInt(t.token.match, 10),
|
|
158
158
|
}) as TypeSymbol,
|
|
159
159
|
)
|
|
160
160
|
.nud("STAR", 5, (_) => ({
|
|
@@ -184,9 +184,8 @@ const parseFilter = (filter: string): ExpressionSet => {
|
|
|
184
184
|
const expr: any = parser.parse({ terminals: [bp - 1] });
|
|
185
185
|
if (Array.isArray(expr)) {
|
|
186
186
|
return [left, ...expr];
|
|
187
|
-
} else {
|
|
188
|
-
return [left, expr];
|
|
189
187
|
}
|
|
188
|
+
return [left, expr];
|
|
190
189
|
})
|
|
191
190
|
.nud("(", 100, (t) => {
|
|
192
191
|
const expr: any = parser.parse({ terminals: [")"] });
|
package/src/oauth/server.test.ts
CHANGED
|
@@ -55,7 +55,7 @@ describe("OAuth2Server", () => {
|
|
|
55
55
|
|
|
56
56
|
it("should refresh a token", async () => {
|
|
57
57
|
const createResponse = await supertest(app)
|
|
58
|
-
.post(
|
|
58
|
+
.post("/my-project/anonymous/token")
|
|
59
59
|
.auth("validClientId", "validClientSecret")
|
|
60
60
|
.query({ grant_type: "client_credentials" })
|
|
61
61
|
.send();
|
package/src/oauth/server.ts
CHANGED
|
@@ -180,7 +180,8 @@ export class OAuth2Server {
|
|
|
180
180
|
request.query.scope?.toString(),
|
|
181
181
|
);
|
|
182
182
|
return response.status(200).send(token);
|
|
183
|
-
}
|
|
183
|
+
}
|
|
184
|
+
if (grantType === "refresh_token") {
|
|
184
185
|
const refreshToken =
|
|
185
186
|
request.query.refresh_token?.toString() || request.body.refresh_token;
|
|
186
187
|
if (!refreshToken) {
|
|
@@ -214,17 +215,16 @@ export class OAuth2Server {
|
|
|
214
215
|
);
|
|
215
216
|
}
|
|
216
217
|
return response.status(200).send(token);
|
|
217
|
-
} else {
|
|
218
|
-
return next(
|
|
219
|
-
new CommercetoolsError<UnsupportedGrantType>(
|
|
220
|
-
{
|
|
221
|
-
code: "unsupported_grant_type",
|
|
222
|
-
message: `Invalid parameter: grant_type: Invalid grant type: ${grantType}`,
|
|
223
|
-
},
|
|
224
|
-
400,
|
|
225
|
-
),
|
|
226
|
-
);
|
|
227
218
|
}
|
|
219
|
+
return next(
|
|
220
|
+
new CommercetoolsError<UnsupportedGrantType>(
|
|
221
|
+
{
|
|
222
|
+
code: "unsupported_grant_type",
|
|
223
|
+
message: `Invalid parameter: grant_type: Invalid grant type: ${grantType}`,
|
|
224
|
+
},
|
|
225
|
+
400,
|
|
226
|
+
),
|
|
227
|
+
);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
async customerTokenHandler(
|
package/src/priceSelector.ts
CHANGED
|
@@ -27,25 +27,25 @@ import type { AbstractStorage } from "./storage";
|
|
|
27
27
|
import type { Writable } from "./types";
|
|
28
28
|
|
|
29
29
|
export type ProductProjectionSearchParams = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
fuzzy?: boolean;
|
|
31
|
+
fuzzyLevel?: number;
|
|
32
|
+
markMatchingVariants?: boolean;
|
|
33
|
+
staged?: boolean;
|
|
34
|
+
filter?: string[];
|
|
35
35
|
"filter.facets"?: string[];
|
|
36
36
|
"filter.query"?: string[];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
facet?: string | string[];
|
|
38
|
+
sort?: string | string[];
|
|
39
|
+
limit?: number;
|
|
40
|
+
offset?: number;
|
|
41
|
+
withTotal?: boolean;
|
|
42
|
+
priceCurrency?: string;
|
|
43
|
+
priceCountry?: string;
|
|
44
|
+
priceCustomerGroup?: string;
|
|
45
|
+
priceChannel?: string;
|
|
46
|
+
localeProjection?: string;
|
|
47
|
+
storeProjection?: string;
|
|
48
|
+
expand?: string | string[];
|
|
49
49
|
[key: string]: QueryParam;
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -342,9 +342,8 @@ export class ProductProjectionSearch {
|
|
|
342
342
|
max: numValues > 0 ? Math.max(...values) : 0,
|
|
343
343
|
mean: numValues > 0 ? mean(values) : 0,
|
|
344
344
|
};
|
|
345
|
-
} else {
|
|
346
|
-
throw new Error("not supported");
|
|
347
345
|
}
|
|
346
|
+
throw new Error("not supported");
|
|
348
347
|
}) || [];
|
|
349
348
|
const data: RangeFacetResult = {
|
|
350
349
|
type: "range",
|
|
@@ -7,21 +7,21 @@ import type {
|
|
|
7
7
|
CompanyDraft,
|
|
8
8
|
DivisionDraft,
|
|
9
9
|
} from "@commercetools/platform-sdk";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
import type {
|
|
11
|
+
Associate,
|
|
12
|
+
BusinessUnit,
|
|
13
|
+
BusinessUnitAddAddressAction,
|
|
14
|
+
BusinessUnitAddAssociateAction,
|
|
15
|
+
BusinessUnitAddStoreAction,
|
|
16
|
+
BusinessUnitChangeAddressAction,
|
|
17
|
+
BusinessUnitChangeNameAction,
|
|
18
|
+
BusinessUnitChangeParentUnitAction,
|
|
19
|
+
BusinessUnitDraft,
|
|
20
|
+
BusinessUnitSetAssociatesAction,
|
|
21
|
+
BusinessUnitSetContactEmailAction,
|
|
22
|
+
BusinessUnitSetStoreModeAction,
|
|
23
|
+
Company,
|
|
24
|
+
Division,
|
|
25
25
|
} from "@commercetools/platform-sdk";
|
|
26
26
|
import type { Config } from "~src/config";
|
|
27
27
|
import { generateRandomString, getBaseResourceProperties } from "../helpers";
|
|
@@ -110,7 +110,8 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business
|
|
|
110
110
|
|
|
111
111
|
this.saveNew(context, division);
|
|
112
112
|
return division;
|
|
113
|
-
}
|
|
113
|
+
}
|
|
114
|
+
if (this._isCompanyDraft(draft)) {
|
|
114
115
|
const company = resource as Company;
|
|
115
116
|
|
|
116
117
|
this.saveNew(context, company);
|
|
@@ -7,36 +7,36 @@ import type {
|
|
|
7
7
|
MissingTaxRateForCountryError,
|
|
8
8
|
ShippingMethodDoesNotMatchCartError,
|
|
9
9
|
} from "@commercetools/platform-sdk";
|
|
10
|
-
import {
|
|
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
|
-
|
|
10
|
+
import type {
|
|
11
|
+
Address,
|
|
12
|
+
AddressDraft,
|
|
13
|
+
Cart,
|
|
14
|
+
CartAddItemShippingAddressAction,
|
|
15
|
+
CartAddLineItemAction,
|
|
16
|
+
CartChangeLineItemQuantityAction,
|
|
17
|
+
CartChangeTaxRoundingModeAction,
|
|
18
|
+
CartRemoveDiscountCodeAction,
|
|
19
|
+
CartRemoveLineItemAction,
|
|
20
|
+
CartSetBillingAddressAction,
|
|
21
|
+
CartSetBillingAddressCustomTypeAction,
|
|
22
|
+
CartSetCountryAction,
|
|
23
|
+
CartSetCustomFieldAction,
|
|
24
|
+
CartSetCustomShippingMethodAction,
|
|
25
|
+
CartSetCustomTypeAction,
|
|
26
|
+
CartSetCustomerEmailAction,
|
|
27
|
+
CartSetDirectDiscountsAction,
|
|
28
|
+
CartSetLineItemShippingDetailsAction,
|
|
29
|
+
CartSetLocaleAction,
|
|
30
|
+
CartSetShippingAddressAction,
|
|
31
|
+
CartSetShippingAddressCustomTypeAction,
|
|
32
|
+
CartSetShippingMethodAction,
|
|
33
|
+
CustomFields,
|
|
34
|
+
GeneralError,
|
|
35
|
+
ItemShippingDetails,
|
|
36
|
+
LineItem,
|
|
37
|
+
Product,
|
|
38
|
+
ProductPagedQueryResponse,
|
|
39
|
+
ProductVariant,
|
|
40
40
|
} from "@commercetools/platform-sdk";
|
|
41
41
|
import type {
|
|
42
42
|
DirectDiscount,
|
|
@@ -232,7 +232,7 @@ export class CartUpdateHandler
|
|
|
232
232
|
} else {
|
|
233
233
|
throw new CommercetoolsError<GeneralError>({
|
|
234
234
|
code: "General",
|
|
235
|
-
message:
|
|
235
|
+
message: "Either lineItemid or lineItemKey needs to be provided.",
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -656,7 +656,7 @@ export class CartUpdateHandler
|
|
|
656
656
|
// Locations cannot be assigned to more than one zone.
|
|
657
657
|
// See https://docs.commercetools.com/api/projects/zones#location
|
|
658
658
|
const zoneRate = method.zoneRates.find((rate) =>
|
|
659
|
-
rate.zone.obj
|
|
659
|
+
rate.zone.obj?.locations.some((loc) => loc.country === country),
|
|
660
660
|
);
|
|
661
661
|
|
|
662
662
|
if (!zoneRate) {
|
|
@@ -24,7 +24,7 @@ export const selectPrice = ({
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export const calculateLineItemTotalPrice = (lineItem: LineItem): number =>
|
|
27
|
-
lineItem.price
|
|
27
|
+
lineItem.price?.value.centAmount * lineItem.quantity;
|
|
28
28
|
|
|
29
29
|
export const calculateCartTotalPrice = (cart: Cart): number =>
|
|
30
30
|
cart.lineItems.reduce((cur, item) => cur + item.totalPrice.centAmount, 0);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { InvalidOperationError } from "@commercetools/platform-sdk";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import type {
|
|
3
|
+
Cart,
|
|
4
|
+
CartDraft,
|
|
5
|
+
GeneralError,
|
|
6
|
+
LineItem,
|
|
7
|
+
LineItemDraft,
|
|
8
|
+
Product,
|
|
9
|
+
ProductPagedQueryResponse,
|
|
10
10
|
} from "@commercetools/platform-sdk";
|
|
11
11
|
import { v4 as uuidv4 } from "uuid";
|
|
12
12
|
import type { Config } from "~src/config";
|
|
@@ -65,10 +65,7 @@ export class CartDiscountUpdateHandler
|
|
|
65
65
|
throw new CommercetoolsError<InvalidOperationError>(
|
|
66
66
|
{
|
|
67
67
|
code: "InvalidOperation",
|
|
68
|
-
message:
|
|
69
|
-
"Cannot remove custom field " +
|
|
70
|
-
name +
|
|
71
|
-
" because it does not exist.",
|
|
68
|
+
message: `Cannot remove custom field ${name} because it does not exist.`,
|
|
72
69
|
},
|
|
73
70
|
400,
|
|
74
71
|
);
|
|
@@ -100,17 +100,13 @@ export class CategoryUpdateHandler
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if (assetId) {
|
|
103
|
-
resource.assets = resource.assets.filter(
|
|
104
|
-
return obj.id !== assetId;
|
|
105
|
-
});
|
|
103
|
+
resource.assets = resource.assets.filter((obj) => obj.id !== assetId);
|
|
106
104
|
|
|
107
105
|
return;
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
if (assetKey) {
|
|
111
|
-
resource.assets = resource.assets.filter(
|
|
112
|
-
return obj.key !== assetKey;
|
|
113
|
-
});
|
|
109
|
+
resource.assets = resource.assets.filter((obj) => obj.key !== assetKey);
|
|
114
110
|
|
|
115
111
|
return;
|
|
116
112
|
}
|
|
@@ -42,28 +42,27 @@ export class CustomObjectRepository extends AbstractResourceRepository<"key-valu
|
|
|
42
42
|
return updated;
|
|
43
43
|
}
|
|
44
44
|
return current;
|
|
45
|
-
} else {
|
|
46
|
-
// If the resource is new the only valid version is 0
|
|
47
|
-
if (draft.version) {
|
|
48
|
-
throw new CommercetoolsError<InvalidOperationError>(
|
|
49
|
-
{
|
|
50
|
-
code: "InvalidOperation",
|
|
51
|
-
message: "version on create must be 0",
|
|
52
|
-
},
|
|
53
|
-
400,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
const baseProperties = getBaseResourceProperties();
|
|
57
|
-
const resource: CustomObject = {
|
|
58
|
-
...baseProperties,
|
|
59
|
-
container: draft.container,
|
|
60
|
-
key: draft.key,
|
|
61
|
-
value: draft.value,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
this.saveNew(context, resource);
|
|
65
|
-
return resource;
|
|
66
45
|
}
|
|
46
|
+
// If the resource is new the only valid version is 0
|
|
47
|
+
if (draft.version) {
|
|
48
|
+
throw new CommercetoolsError<InvalidOperationError>(
|
|
49
|
+
{
|
|
50
|
+
code: "InvalidOperation",
|
|
51
|
+
message: "version on create must be 0",
|
|
52
|
+
},
|
|
53
|
+
400,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const baseProperties = getBaseResourceProperties();
|
|
57
|
+
const resource: CustomObject = {
|
|
58
|
+
...baseProperties,
|
|
59
|
+
container: draft.container,
|
|
60
|
+
key: draft.key,
|
|
61
|
+
value: draft.value,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
this.saveNew(context, resource);
|
|
65
|
+
return resource;
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
getWithContainerAndKey(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
1
2
|
import type {
|
|
2
3
|
Address,
|
|
3
4
|
BaseAddress,
|
|
@@ -38,7 +39,6 @@ import type {
|
|
|
38
39
|
InvalidJsonInputError,
|
|
39
40
|
InvalidOperationError,
|
|
40
41
|
} from "@commercetools/platform-sdk";
|
|
41
|
-
import assert from "node:assert";
|
|
42
42
|
import { CommercetoolsError } from "~src/exceptions";
|
|
43
43
|
import { generateRandomString } from "~src/helpers";
|
|
44
44
|
import { hashPassword } from "~src/lib/password";
|
|
@@ -49,7 +49,7 @@ import { createAddress, createCustomFields } from "../helpers";
|
|
|
49
49
|
|
|
50
50
|
export class CustomerUpdateHandler
|
|
51
51
|
extends AbstractUpdateHandler
|
|
52
|
-
implements UpdateHandlerInterface<Customer, CustomerUpdateAction
|
|
52
|
+
implements Partial<UpdateHandlerInterface<Customer, CustomerUpdateAction>>
|
|
53
53
|
{
|
|
54
54
|
addAddress(
|
|
55
55
|
_context: RepositoryContext,
|
|
@@ -234,7 +234,7 @@ export class CustomerUpdateHandler
|
|
|
234
234
|
}
|
|
235
235
|
resource.authenticationMode = authMode;
|
|
236
236
|
if (authMode === "ExternalAuth") {
|
|
237
|
-
|
|
237
|
+
resource.password = undefined;
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
240
|
if (authMode === "Password") {
|
|
@@ -461,7 +461,7 @@ export class CustomerUpdateHandler
|
|
|
461
461
|
resource: Writable<Customer>,
|
|
462
462
|
addressId: string | undefined,
|
|
463
463
|
addressKey: string | undefined,
|
|
464
|
-
required
|
|
464
|
+
required = false,
|
|
465
465
|
): Address | undefined {
|
|
466
466
|
if (addressKey) {
|
|
467
467
|
const address = resource.addresses.find((a) => a.key === addressKey);
|
|
@@ -49,7 +49,8 @@ export class ExtensionRepository extends AbstractResourceRepository<"extension">
|
|
|
49
49
|
extension,
|
|
50
50
|
"destination.authentication.headerValue",
|
|
51
51
|
);
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
|
+
if (extension.destination.type === "AWSLambda") {
|
|
53
54
|
return maskSecretValue(resource, "destination.accessSecret");
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -5,39 +5,39 @@ import type {
|
|
|
5
5
|
BusinessUnitResourceIdentifier,
|
|
6
6
|
RoundingMode,
|
|
7
7
|
} from "@commercetools/platform-sdk";
|
|
8
|
-
import {
|
|
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
|
-
|
|
8
|
+
import type {
|
|
9
|
+
Address,
|
|
10
|
+
Associate,
|
|
11
|
+
AssociateDraft,
|
|
12
|
+
AssociateRoleAssignment,
|
|
13
|
+
AssociateRoleAssignmentDraft,
|
|
14
|
+
AssociateRoleKeyReference,
|
|
15
|
+
AssociateRoleResourceIdentifier,
|
|
16
|
+
BaseAddress,
|
|
17
|
+
CentPrecisionMoney,
|
|
18
|
+
CustomFields,
|
|
19
|
+
CustomFieldsDraft,
|
|
20
|
+
HighPrecisionMoney,
|
|
21
|
+
HighPrecisionMoneyDraft,
|
|
22
|
+
InvalidJsonInputError,
|
|
23
|
+
Price,
|
|
24
|
+
PriceDraft,
|
|
25
|
+
Reference,
|
|
26
|
+
ReferencedResourceNotFoundError,
|
|
27
|
+
ResourceIdentifier,
|
|
28
|
+
Store,
|
|
29
|
+
StoreKeyReference,
|
|
30
|
+
StoreReference,
|
|
31
|
+
StoreResourceIdentifier,
|
|
32
|
+
Type,
|
|
33
|
+
_Money,
|
|
34
34
|
} from "@commercetools/platform-sdk";
|
|
35
35
|
import { Decimal } from "decimal.js/decimal";
|
|
36
36
|
import type { Request } from "express";
|
|
37
37
|
import { v4 as uuidv4 } from "uuid";
|
|
38
38
|
import { CommercetoolsError } from "~src/exceptions";
|
|
39
39
|
import type { AbstractStorage } from "../storage";
|
|
40
|
-
import {
|
|
40
|
+
import type { RepositoryContext } from "./abstract";
|
|
41
41
|
|
|
42
42
|
export const createAddress = (
|
|
43
43
|
base: BaseAddress | undefined,
|