@commercetools/sdk-client-v2 2.4.1 → 2.5.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/CHANGELOG.md +9 -0
- package/dist/commercetools-sdk-client-v2.browser.cjs.js +30 -6
- package/dist/commercetools-sdk-client-v2.browser.esm.js +30 -6
- package/dist/commercetools-sdk-client-v2.cjs.d.ts +1 -1
- package/dist/commercetools-sdk-client-v2.cjs.dev.js +30 -6
- package/dist/commercetools-sdk-client-v2.cjs.prod.js +30 -6
- package/dist/commercetools-sdk-client-v2.esm.js +30 -6
- package/dist/commercetools-sdk-client-v2.umd.js +1 -1
- package/dist/declarations/src/client-builder/ClientBuilder.d.ts +6 -2
- package/dist/declarations/src/types/sdk.d.ts +16 -7
- package/package.json +3 -3
- package/dist/commercetools-sdk-client-v2.cjs.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @commercetools/sdk-client-v2
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#676](https://github.com/commercetools/commercetools-sdk-typescript/pull/676) [`8b1aecc`](https://github.com/commercetools/commercetools-sdk-typescript/commit/8b1aecce5859248f3a90c8cc856db64d2932b5d5) Thanks [@ajimae](https://github.com/ajimae)! - Add custom logger function
|
|
8
|
+
|
|
9
|
+
- [#679](https://github.com/commercetools/commercetools-sdk-typescript/pull/679) [`b8bc24d`](https://github.com/commercetools/commercetools-sdk-typescript/commit/b8bc24df5db74feef7fb5743b6f24b425d43b738) Thanks [@ajimae](https://github.com/ajimae)! - - Add a before middleware function that runs before the coco api call is initiated
|
|
10
|
+
- Add an after middleware function that runs after the coco api call is done executing
|
|
11
|
+
|
|
3
12
|
## 2.4.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -22,7 +22,7 @@ function toPrimitive(t, r) {
|
|
|
22
22
|
|
|
23
23
|
function toPropertyKey(t) {
|
|
24
24
|
var i = toPrimitive(t, "string");
|
|
25
|
-
return "symbol" == typeof i ? i :
|
|
25
|
+
return "symbol" == typeof i ? i : i + "";
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function _defineProperty(obj, key, value) {
|
|
@@ -1068,7 +1068,7 @@ function createQueueMiddleware({
|
|
|
1068
1068
|
|
|
1069
1069
|
var packageJson = {
|
|
1070
1070
|
name: "@commercetools/sdk-client-v2",
|
|
1071
|
-
version: "2.
|
|
1071
|
+
version: "2.5.0",
|
|
1072
1072
|
engines: {
|
|
1073
1073
|
node: ">=14"
|
|
1074
1074
|
},
|
|
@@ -1118,8 +1118,8 @@ var packageJson = {
|
|
|
1118
1118
|
devDependencies: {
|
|
1119
1119
|
"abort-controller": "3.0.0",
|
|
1120
1120
|
"common-tags": "1.8.2",
|
|
1121
|
-
dotenv: "16.
|
|
1122
|
-
jest: "29.
|
|
1121
|
+
dotenv: "16.4.5",
|
|
1122
|
+
jest: "29.7.0",
|
|
1123
1123
|
nock: "12.0.3",
|
|
1124
1124
|
"organize-imports-cli": "0.10.0"
|
|
1125
1125
|
},
|
|
@@ -1203,6 +1203,8 @@ class ClientBuilder {
|
|
|
1203
1203
|
_defineProperty(this, "loggerMiddleware", void 0);
|
|
1204
1204
|
_defineProperty(this, "queueMiddleware", void 0);
|
|
1205
1205
|
_defineProperty(this, "telemetryMiddleware", void 0);
|
|
1206
|
+
_defineProperty(this, "beforeMiddleware", void 0);
|
|
1207
|
+
_defineProperty(this, "afterMiddleware", void 0);
|
|
1206
1208
|
_defineProperty(this, "middlewares", []);
|
|
1207
1209
|
}
|
|
1208
1210
|
withProjectKey(key) {
|
|
@@ -1308,8 +1310,12 @@ class ClientBuilder {
|
|
|
1308
1310
|
});
|
|
1309
1311
|
return this;
|
|
1310
1312
|
}
|
|
1311
|
-
withLoggerMiddleware() {
|
|
1312
|
-
|
|
1313
|
+
withLoggerMiddleware(options) {
|
|
1314
|
+
const {
|
|
1315
|
+
logger,
|
|
1316
|
+
...rest
|
|
1317
|
+
} = options || {};
|
|
1318
|
+
this.loggerMiddleware = typeof options?.logger == 'function' && options.logger(rest) || createLoggerMiddleware();
|
|
1313
1319
|
return this;
|
|
1314
1320
|
}
|
|
1315
1321
|
withCorrelationIdMiddleware(options) {
|
|
@@ -1330,14 +1336,32 @@ class ClientBuilder {
|
|
|
1330
1336
|
this.telemetryMiddleware = createTelemetryMiddleware(rest);
|
|
1331
1337
|
return this;
|
|
1332
1338
|
}
|
|
1339
|
+
withBeforeExecutionMiddleware(options) {
|
|
1340
|
+
const {
|
|
1341
|
+
middleware,
|
|
1342
|
+
...rest
|
|
1343
|
+
} = options || {};
|
|
1344
|
+
this.beforeMiddleware = options.middleware(rest);
|
|
1345
|
+
return this;
|
|
1346
|
+
}
|
|
1347
|
+
withAfterExecutionMiddleware(options) {
|
|
1348
|
+
const {
|
|
1349
|
+
middleware,
|
|
1350
|
+
...rest
|
|
1351
|
+
} = options || {};
|
|
1352
|
+
this.afterMiddleware = options.middleware(rest);
|
|
1353
|
+
return this;
|
|
1354
|
+
}
|
|
1333
1355
|
build() {
|
|
1334
1356
|
const middlewares = this.middlewares.slice();
|
|
1335
1357
|
if (this.telemetryMiddleware) middlewares.push(this.telemetryMiddleware);
|
|
1336
1358
|
if (this.correlationIdMiddleware) middlewares.push(this.correlationIdMiddleware);
|
|
1337
1359
|
if (this.userAgentMiddleware) middlewares.push(this.userAgentMiddleware);
|
|
1338
1360
|
if (this.authMiddleware) middlewares.push(this.authMiddleware);
|
|
1361
|
+
if (this.beforeMiddleware) middlewares.push(this.beforeMiddleware);
|
|
1339
1362
|
if (this.queueMiddleware) middlewares.push(this.queueMiddleware);
|
|
1340
1363
|
if (this.httpMiddleware) middlewares.push(this.httpMiddleware);
|
|
1364
|
+
if (this.afterMiddleware) middlewares.push(this.afterMiddleware);
|
|
1341
1365
|
if (this.loggerMiddleware) middlewares.push(this.loggerMiddleware);
|
|
1342
1366
|
return createClient({
|
|
1343
1367
|
middlewares
|
|
@@ -14,7 +14,7 @@ function toPrimitive(t, r) {
|
|
|
14
14
|
|
|
15
15
|
function toPropertyKey(t) {
|
|
16
16
|
var i = toPrimitive(t, "string");
|
|
17
|
-
return "symbol" == typeof i ? i :
|
|
17
|
+
return "symbol" == typeof i ? i : i + "";
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function _defineProperty(obj, key, value) {
|
|
@@ -1060,7 +1060,7 @@ function createQueueMiddleware({
|
|
|
1060
1060
|
|
|
1061
1061
|
var packageJson = {
|
|
1062
1062
|
name: "@commercetools/sdk-client-v2",
|
|
1063
|
-
version: "2.
|
|
1063
|
+
version: "2.5.0",
|
|
1064
1064
|
engines: {
|
|
1065
1065
|
node: ">=14"
|
|
1066
1066
|
},
|
|
@@ -1110,8 +1110,8 @@ var packageJson = {
|
|
|
1110
1110
|
devDependencies: {
|
|
1111
1111
|
"abort-controller": "3.0.0",
|
|
1112
1112
|
"common-tags": "1.8.2",
|
|
1113
|
-
dotenv: "16.
|
|
1114
|
-
jest: "29.
|
|
1113
|
+
dotenv: "16.4.5",
|
|
1114
|
+
jest: "29.7.0",
|
|
1115
1115
|
nock: "12.0.3",
|
|
1116
1116
|
"organize-imports-cli": "0.10.0"
|
|
1117
1117
|
},
|
|
@@ -1195,6 +1195,8 @@ class ClientBuilder {
|
|
|
1195
1195
|
_defineProperty(this, "loggerMiddleware", void 0);
|
|
1196
1196
|
_defineProperty(this, "queueMiddleware", void 0);
|
|
1197
1197
|
_defineProperty(this, "telemetryMiddleware", void 0);
|
|
1198
|
+
_defineProperty(this, "beforeMiddleware", void 0);
|
|
1199
|
+
_defineProperty(this, "afterMiddleware", void 0);
|
|
1198
1200
|
_defineProperty(this, "middlewares", []);
|
|
1199
1201
|
}
|
|
1200
1202
|
withProjectKey(key) {
|
|
@@ -1300,8 +1302,12 @@ class ClientBuilder {
|
|
|
1300
1302
|
});
|
|
1301
1303
|
return this;
|
|
1302
1304
|
}
|
|
1303
|
-
withLoggerMiddleware() {
|
|
1304
|
-
|
|
1305
|
+
withLoggerMiddleware(options) {
|
|
1306
|
+
const {
|
|
1307
|
+
logger,
|
|
1308
|
+
...rest
|
|
1309
|
+
} = options || {};
|
|
1310
|
+
this.loggerMiddleware = typeof options?.logger == 'function' && options.logger(rest) || createLoggerMiddleware();
|
|
1305
1311
|
return this;
|
|
1306
1312
|
}
|
|
1307
1313
|
withCorrelationIdMiddleware(options) {
|
|
@@ -1322,14 +1328,32 @@ class ClientBuilder {
|
|
|
1322
1328
|
this.telemetryMiddleware = createTelemetryMiddleware(rest);
|
|
1323
1329
|
return this;
|
|
1324
1330
|
}
|
|
1331
|
+
withBeforeExecutionMiddleware(options) {
|
|
1332
|
+
const {
|
|
1333
|
+
middleware,
|
|
1334
|
+
...rest
|
|
1335
|
+
} = options || {};
|
|
1336
|
+
this.beforeMiddleware = options.middleware(rest);
|
|
1337
|
+
return this;
|
|
1338
|
+
}
|
|
1339
|
+
withAfterExecutionMiddleware(options) {
|
|
1340
|
+
const {
|
|
1341
|
+
middleware,
|
|
1342
|
+
...rest
|
|
1343
|
+
} = options || {};
|
|
1344
|
+
this.afterMiddleware = options.middleware(rest);
|
|
1345
|
+
return this;
|
|
1346
|
+
}
|
|
1325
1347
|
build() {
|
|
1326
1348
|
const middlewares = this.middlewares.slice();
|
|
1327
1349
|
if (this.telemetryMiddleware) middlewares.push(this.telemetryMiddleware);
|
|
1328
1350
|
if (this.correlationIdMiddleware) middlewares.push(this.correlationIdMiddleware);
|
|
1329
1351
|
if (this.userAgentMiddleware) middlewares.push(this.userAgentMiddleware);
|
|
1330
1352
|
if (this.authMiddleware) middlewares.push(this.authMiddleware);
|
|
1353
|
+
if (this.beforeMiddleware) middlewares.push(this.beforeMiddleware);
|
|
1331
1354
|
if (this.queueMiddleware) middlewares.push(this.queueMiddleware);
|
|
1332
1355
|
if (this.httpMiddleware) middlewares.push(this.httpMiddleware);
|
|
1356
|
+
if (this.afterMiddleware) middlewares.push(this.afterMiddleware);
|
|
1333
1357
|
if (this.loggerMiddleware) middlewares.push(this.loggerMiddleware);
|
|
1334
1358
|
return createClient({
|
|
1335
1359
|
middlewares
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./declarations/src/index";
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1zZGstY2xpZW50LXYyLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -22,7 +22,7 @@ function toPrimitive(t, r) {
|
|
|
22
22
|
|
|
23
23
|
function toPropertyKey(t) {
|
|
24
24
|
var i = toPrimitive(t, "string");
|
|
25
|
-
return "symbol" == typeof i ? i :
|
|
25
|
+
return "symbol" == typeof i ? i : i + "";
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function _defineProperty(obj, key, value) {
|
|
@@ -1068,7 +1068,7 @@ function createQueueMiddleware({
|
|
|
1068
1068
|
|
|
1069
1069
|
var packageJson = {
|
|
1070
1070
|
name: "@commercetools/sdk-client-v2",
|
|
1071
|
-
version: "2.
|
|
1071
|
+
version: "2.5.0",
|
|
1072
1072
|
engines: {
|
|
1073
1073
|
node: ">=14"
|
|
1074
1074
|
},
|
|
@@ -1118,8 +1118,8 @@ var packageJson = {
|
|
|
1118
1118
|
devDependencies: {
|
|
1119
1119
|
"abort-controller": "3.0.0",
|
|
1120
1120
|
"common-tags": "1.8.2",
|
|
1121
|
-
dotenv: "16.
|
|
1122
|
-
jest: "29.
|
|
1121
|
+
dotenv: "16.4.5",
|
|
1122
|
+
jest: "29.7.0",
|
|
1123
1123
|
nock: "12.0.3",
|
|
1124
1124
|
"organize-imports-cli": "0.10.0"
|
|
1125
1125
|
},
|
|
@@ -1203,6 +1203,8 @@ class ClientBuilder {
|
|
|
1203
1203
|
_defineProperty(this, "loggerMiddleware", void 0);
|
|
1204
1204
|
_defineProperty(this, "queueMiddleware", void 0);
|
|
1205
1205
|
_defineProperty(this, "telemetryMiddleware", void 0);
|
|
1206
|
+
_defineProperty(this, "beforeMiddleware", void 0);
|
|
1207
|
+
_defineProperty(this, "afterMiddleware", void 0);
|
|
1206
1208
|
_defineProperty(this, "middlewares", []);
|
|
1207
1209
|
}
|
|
1208
1210
|
withProjectKey(key) {
|
|
@@ -1308,8 +1310,12 @@ class ClientBuilder {
|
|
|
1308
1310
|
});
|
|
1309
1311
|
return this;
|
|
1310
1312
|
}
|
|
1311
|
-
withLoggerMiddleware() {
|
|
1312
|
-
|
|
1313
|
+
withLoggerMiddleware(options) {
|
|
1314
|
+
const {
|
|
1315
|
+
logger,
|
|
1316
|
+
...rest
|
|
1317
|
+
} = options || {};
|
|
1318
|
+
this.loggerMiddleware = typeof options?.logger == 'function' && options.logger(rest) || createLoggerMiddleware();
|
|
1313
1319
|
return this;
|
|
1314
1320
|
}
|
|
1315
1321
|
withCorrelationIdMiddleware(options) {
|
|
@@ -1330,14 +1336,32 @@ class ClientBuilder {
|
|
|
1330
1336
|
this.telemetryMiddleware = createTelemetryMiddleware(rest);
|
|
1331
1337
|
return this;
|
|
1332
1338
|
}
|
|
1339
|
+
withBeforeExecutionMiddleware(options) {
|
|
1340
|
+
const {
|
|
1341
|
+
middleware,
|
|
1342
|
+
...rest
|
|
1343
|
+
} = options || {};
|
|
1344
|
+
this.beforeMiddleware = options.middleware(rest);
|
|
1345
|
+
return this;
|
|
1346
|
+
}
|
|
1347
|
+
withAfterExecutionMiddleware(options) {
|
|
1348
|
+
const {
|
|
1349
|
+
middleware,
|
|
1350
|
+
...rest
|
|
1351
|
+
} = options || {};
|
|
1352
|
+
this.afterMiddleware = options.middleware(rest);
|
|
1353
|
+
return this;
|
|
1354
|
+
}
|
|
1333
1355
|
build() {
|
|
1334
1356
|
const middlewares = this.middlewares.slice();
|
|
1335
1357
|
if (this.telemetryMiddleware) middlewares.push(this.telemetryMiddleware);
|
|
1336
1358
|
if (this.correlationIdMiddleware) middlewares.push(this.correlationIdMiddleware);
|
|
1337
1359
|
if (this.userAgentMiddleware) middlewares.push(this.userAgentMiddleware);
|
|
1338
1360
|
if (this.authMiddleware) middlewares.push(this.authMiddleware);
|
|
1361
|
+
if (this.beforeMiddleware) middlewares.push(this.beforeMiddleware);
|
|
1339
1362
|
if (this.queueMiddleware) middlewares.push(this.queueMiddleware);
|
|
1340
1363
|
if (this.httpMiddleware) middlewares.push(this.httpMiddleware);
|
|
1364
|
+
if (this.afterMiddleware) middlewares.push(this.afterMiddleware);
|
|
1341
1365
|
if (this.loggerMiddleware) middlewares.push(this.loggerMiddleware);
|
|
1342
1366
|
return createClient({
|
|
1343
1367
|
middlewares
|
|
@@ -22,7 +22,7 @@ function toPrimitive(t, r) {
|
|
|
22
22
|
|
|
23
23
|
function toPropertyKey(t) {
|
|
24
24
|
var i = toPrimitive(t, "string");
|
|
25
|
-
return "symbol" == typeof i ? i :
|
|
25
|
+
return "symbol" == typeof i ? i : i + "";
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function _defineProperty(obj, key, value) {
|
|
@@ -1068,7 +1068,7 @@ function createQueueMiddleware({
|
|
|
1068
1068
|
|
|
1069
1069
|
var packageJson = {
|
|
1070
1070
|
name: "@commercetools/sdk-client-v2",
|
|
1071
|
-
version: "2.
|
|
1071
|
+
version: "2.5.0",
|
|
1072
1072
|
engines: {
|
|
1073
1073
|
node: ">=14"
|
|
1074
1074
|
},
|
|
@@ -1118,8 +1118,8 @@ var packageJson = {
|
|
|
1118
1118
|
devDependencies: {
|
|
1119
1119
|
"abort-controller": "3.0.0",
|
|
1120
1120
|
"common-tags": "1.8.2",
|
|
1121
|
-
dotenv: "16.
|
|
1122
|
-
jest: "29.
|
|
1121
|
+
dotenv: "16.4.5",
|
|
1122
|
+
jest: "29.7.0",
|
|
1123
1123
|
nock: "12.0.3",
|
|
1124
1124
|
"organize-imports-cli": "0.10.0"
|
|
1125
1125
|
},
|
|
@@ -1203,6 +1203,8 @@ class ClientBuilder {
|
|
|
1203
1203
|
_defineProperty(this, "loggerMiddleware", void 0);
|
|
1204
1204
|
_defineProperty(this, "queueMiddleware", void 0);
|
|
1205
1205
|
_defineProperty(this, "telemetryMiddleware", void 0);
|
|
1206
|
+
_defineProperty(this, "beforeMiddleware", void 0);
|
|
1207
|
+
_defineProperty(this, "afterMiddleware", void 0);
|
|
1206
1208
|
_defineProperty(this, "middlewares", []);
|
|
1207
1209
|
}
|
|
1208
1210
|
withProjectKey(key) {
|
|
@@ -1308,8 +1310,12 @@ class ClientBuilder {
|
|
|
1308
1310
|
});
|
|
1309
1311
|
return this;
|
|
1310
1312
|
}
|
|
1311
|
-
withLoggerMiddleware() {
|
|
1312
|
-
|
|
1313
|
+
withLoggerMiddleware(options) {
|
|
1314
|
+
const {
|
|
1315
|
+
logger,
|
|
1316
|
+
...rest
|
|
1317
|
+
} = options || {};
|
|
1318
|
+
this.loggerMiddleware = typeof options?.logger == 'function' && options.logger(rest) || createLoggerMiddleware();
|
|
1313
1319
|
return this;
|
|
1314
1320
|
}
|
|
1315
1321
|
withCorrelationIdMiddleware(options) {
|
|
@@ -1330,14 +1336,32 @@ class ClientBuilder {
|
|
|
1330
1336
|
this.telemetryMiddleware = createTelemetryMiddleware(rest);
|
|
1331
1337
|
return this;
|
|
1332
1338
|
}
|
|
1339
|
+
withBeforeExecutionMiddleware(options) {
|
|
1340
|
+
const {
|
|
1341
|
+
middleware,
|
|
1342
|
+
...rest
|
|
1343
|
+
} = options || {};
|
|
1344
|
+
this.beforeMiddleware = options.middleware(rest);
|
|
1345
|
+
return this;
|
|
1346
|
+
}
|
|
1347
|
+
withAfterExecutionMiddleware(options) {
|
|
1348
|
+
const {
|
|
1349
|
+
middleware,
|
|
1350
|
+
...rest
|
|
1351
|
+
} = options || {};
|
|
1352
|
+
this.afterMiddleware = options.middleware(rest);
|
|
1353
|
+
return this;
|
|
1354
|
+
}
|
|
1333
1355
|
build() {
|
|
1334
1356
|
const middlewares = this.middlewares.slice();
|
|
1335
1357
|
if (this.telemetryMiddleware) middlewares.push(this.telemetryMiddleware);
|
|
1336
1358
|
if (this.correlationIdMiddleware) middlewares.push(this.correlationIdMiddleware);
|
|
1337
1359
|
if (this.userAgentMiddleware) middlewares.push(this.userAgentMiddleware);
|
|
1338
1360
|
if (this.authMiddleware) middlewares.push(this.authMiddleware);
|
|
1361
|
+
if (this.beforeMiddleware) middlewares.push(this.beforeMiddleware);
|
|
1339
1362
|
if (this.queueMiddleware) middlewares.push(this.queueMiddleware);
|
|
1340
1363
|
if (this.httpMiddleware) middlewares.push(this.httpMiddleware);
|
|
1364
|
+
if (this.afterMiddleware) middlewares.push(this.afterMiddleware);
|
|
1341
1365
|
if (this.loggerMiddleware) middlewares.push(this.loggerMiddleware);
|
|
1342
1366
|
return createClient({
|
|
1343
1367
|
middlewares
|
|
@@ -14,7 +14,7 @@ function toPrimitive(t, r) {
|
|
|
14
14
|
|
|
15
15
|
function toPropertyKey(t) {
|
|
16
16
|
var i = toPrimitive(t, "string");
|
|
17
|
-
return "symbol" == typeof i ? i :
|
|
17
|
+
return "symbol" == typeof i ? i : i + "";
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function _defineProperty(obj, key, value) {
|
|
@@ -1060,7 +1060,7 @@ function createQueueMiddleware({
|
|
|
1060
1060
|
|
|
1061
1061
|
var packageJson = {
|
|
1062
1062
|
name: "@commercetools/sdk-client-v2",
|
|
1063
|
-
version: "2.
|
|
1063
|
+
version: "2.5.0",
|
|
1064
1064
|
engines: {
|
|
1065
1065
|
node: ">=14"
|
|
1066
1066
|
},
|
|
@@ -1110,8 +1110,8 @@ var packageJson = {
|
|
|
1110
1110
|
devDependencies: {
|
|
1111
1111
|
"abort-controller": "3.0.0",
|
|
1112
1112
|
"common-tags": "1.8.2",
|
|
1113
|
-
dotenv: "16.
|
|
1114
|
-
jest: "29.
|
|
1113
|
+
dotenv: "16.4.5",
|
|
1114
|
+
jest: "29.7.0",
|
|
1115
1115
|
nock: "12.0.3",
|
|
1116
1116
|
"organize-imports-cli": "0.10.0"
|
|
1117
1117
|
},
|
|
@@ -1195,6 +1195,8 @@ class ClientBuilder {
|
|
|
1195
1195
|
_defineProperty(this, "loggerMiddleware", void 0);
|
|
1196
1196
|
_defineProperty(this, "queueMiddleware", void 0);
|
|
1197
1197
|
_defineProperty(this, "telemetryMiddleware", void 0);
|
|
1198
|
+
_defineProperty(this, "beforeMiddleware", void 0);
|
|
1199
|
+
_defineProperty(this, "afterMiddleware", void 0);
|
|
1198
1200
|
_defineProperty(this, "middlewares", []);
|
|
1199
1201
|
}
|
|
1200
1202
|
withProjectKey(key) {
|
|
@@ -1300,8 +1302,12 @@ class ClientBuilder {
|
|
|
1300
1302
|
});
|
|
1301
1303
|
return this;
|
|
1302
1304
|
}
|
|
1303
|
-
withLoggerMiddleware() {
|
|
1304
|
-
|
|
1305
|
+
withLoggerMiddleware(options) {
|
|
1306
|
+
const {
|
|
1307
|
+
logger,
|
|
1308
|
+
...rest
|
|
1309
|
+
} = options || {};
|
|
1310
|
+
this.loggerMiddleware = typeof options?.logger == 'function' && options.logger(rest) || createLoggerMiddleware();
|
|
1305
1311
|
return this;
|
|
1306
1312
|
}
|
|
1307
1313
|
withCorrelationIdMiddleware(options) {
|
|
@@ -1322,14 +1328,32 @@ class ClientBuilder {
|
|
|
1322
1328
|
this.telemetryMiddleware = createTelemetryMiddleware(rest);
|
|
1323
1329
|
return this;
|
|
1324
1330
|
}
|
|
1331
|
+
withBeforeExecutionMiddleware(options) {
|
|
1332
|
+
const {
|
|
1333
|
+
middleware,
|
|
1334
|
+
...rest
|
|
1335
|
+
} = options || {};
|
|
1336
|
+
this.beforeMiddleware = options.middleware(rest);
|
|
1337
|
+
return this;
|
|
1338
|
+
}
|
|
1339
|
+
withAfterExecutionMiddleware(options) {
|
|
1340
|
+
const {
|
|
1341
|
+
middleware,
|
|
1342
|
+
...rest
|
|
1343
|
+
} = options || {};
|
|
1344
|
+
this.afterMiddleware = options.middleware(rest);
|
|
1345
|
+
return this;
|
|
1346
|
+
}
|
|
1325
1347
|
build() {
|
|
1326
1348
|
const middlewares = this.middlewares.slice();
|
|
1327
1349
|
if (this.telemetryMiddleware) middlewares.push(this.telemetryMiddleware);
|
|
1328
1350
|
if (this.correlationIdMiddleware) middlewares.push(this.correlationIdMiddleware);
|
|
1329
1351
|
if (this.userAgentMiddleware) middlewares.push(this.userAgentMiddleware);
|
|
1330
1352
|
if (this.authMiddleware) middlewares.push(this.authMiddleware);
|
|
1353
|
+
if (this.beforeMiddleware) middlewares.push(this.beforeMiddleware);
|
|
1331
1354
|
if (this.queueMiddleware) middlewares.push(this.queueMiddleware);
|
|
1332
1355
|
if (this.httpMiddleware) middlewares.push(this.httpMiddleware);
|
|
1356
|
+
if (this.afterMiddleware) middlewares.push(this.afterMiddleware);
|
|
1333
1357
|
if (this.loggerMiddleware) middlewares.push(this.loggerMiddleware);
|
|
1334
1358
|
return createClient({
|
|
1335
1359
|
middlewares
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@commercetools/sdk-client-v2"]=t():e["@commercetools/sdk-client-v2"]=t()}(self,(()=>(()=>{var e={146:()=>{},830:()=>{},33:()=>{},633:()=>{},854:()=>{},435:(e,t,r)=>{"use strict";r.d(t,{A:()=>O});var n=r(33),o=r.n(n),i=r(822),a=r(571),s=r(241),c=r(901),u=r(646),l=r(726),h=r(510),d=r(650),f=r(345),p=r(412),y=r(15),w=function(){return w=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},w.apply(this,arguments)},v=u.A,g=a.A,m=s.A,b=l.A,A=c.A;const O=function(){function e(){this.middlewares=[]}return e.prototype.withProjectKey=function(e){return this.projectKey=e,this},e.prototype.defaultClient=function(e,t,r,n){return this.withClientCredentialsFlow({host:r,projectKey:n||this.projectKey,credentials:t}).withHttpMiddleware({host:e,fetch:o()}).withLoggerMiddleware().withUserAgentMiddleware()},e.prototype.withAuthMiddleware=function(e){return this.authMiddleware=e,this},e.prototype.withMiddleware=function(e){return this.middlewares.push(e),this},e.prototype.withClientCredentialsFlow=function(e){return this.withAuthMiddleware(m(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||""},oauthUri:e.oauthUri||"",scopes:e.scopes,fetch:e.fetch||o()},e)))},e.prototype.withPasswordFlow=function(e){return this.withAuthMiddleware(v(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||"",user:{username:e.credentials.user.username||"",password:e.credentials.user.password||""}},fetch:e.fetch||o()},e)))},e.prototype.withAnonymousSessionFlow=function(e){return this.withAuthMiddleware(g(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||"",anonymousId:e.credentials.anonymousId||""},fetch:e.fetch||o()},e)))},e.prototype.withRefreshTokenFlow=function(e){return this.withAuthMiddleware(b(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||""},fetch:e.fetch||o(),refreshToken:e.refreshToken||""},e)))},e.prototype.withExistingTokenFlow=function(e,t){return this.withAuthMiddleware(A(e,w({force:t.force||!0},t)))},e.prototype.withHttpMiddleware=function(e){return this.httpMiddleware=(0,d.A)(w({host:e.host||"https://api.europe-west1.gcp.commercetools.com",fetch:e.fetch||o()},e)),this},e.prototype.withUserAgentMiddleware=function(e){return this.userAgentMiddleware=(0,y.A)(e),this},e.prototype.withQueueMiddleware=function(e){return this.queueMiddleware=(0,p.A)(w({concurrency:e.concurrency||20},e)),this},e.prototype.withLoggerMiddleware=function(){return this.loggerMiddleware=(0,f.A)(),this},e.prototype.withCorrelationIdMiddleware=function(e){return this.correlationIdMiddleware=(0,h.A)(w({generate:e.generate||null},e)),this},e.prototype.withTelemetryMiddleware=function(e){var t=e.createTelemetryMiddleware,r=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["createTelemetryMiddleware"]);return this.withUserAgentMiddleware({customAgent:(null==r?void 0:r.userAgent)||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=t(r),this},e.prototype.build=function(){var e=this.middlewares.slice();return this.telemetryMiddleware&&e.push(this.telemetryMiddleware),this.correlationIdMiddleware&&e.push(this.correlationIdMiddleware),this.userAgentMiddleware&&e.push(this.userAgentMiddleware),this.authMiddleware&&e.push(this.authMiddleware),this.queueMiddleware&&e.push(this.queueMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.loggerMiddleware&&e.push(this.loggerMiddleware),(0,i.Ay)({middlewares:e})},e}()},822:(e,t,r)=>{"use strict";r.d(t,{Ay:()=>b,eh:()=>m});var n=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function i(e){return null!=e}function a(e){var t,r,n={},i=new URLSearchParams(e);try{for(var a=o(i.keys()),s=a.next();!s.done;s=a.next()){var c=s.value;i.getAll(c).length>1?n[c]=i.getAll(c):n[c]=i.get(c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return n}function s(e){var t,r,a;if(e=i(a=e)?"string"==typeof a?a:Object.fromEntries(Object.entries(a).filter((function(e){var t=n(e,2),r=(t[0],t[1]);return![null,void 0,""].includes(r)}))):"",!e)return"";var s=new URLSearchParams(e),c=function(e,t){Array.isArray(t)&&(s.delete(e),t.filter(i).forEach((function(t){return s.append(e,t)})))};try{for(var u=o(Object.entries(e)),l=u.next();!l.done;l=u.next()){var h=n(l.value,2);c(h[0],h[1])}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return s.toString()}function c(e,t){return void 0===t&&(t=s),t(e)}const u=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function l(e,t,r){if(void 0===r&&(r={allowedMethods:u}),!t)throw new Error('The "'.concat(e,'" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if("string"!=typeof t.uri)throw new Error('The "'.concat(e,'" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if(!r.allowedMethods.includes(t.method))throw new Error('The "'.concat(e,'" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'))}var h,d=function(){return d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},d.apply(this,arguments)},f=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},p=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},y=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},w=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},v=20;function g(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===(e=e.filter((function(e){return"function"==typeof e}))).length?e[0]:e.reduce((function(e,t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return e(t.apply(void 0,w([],y(r),!1)))}}))}function m(e,t,r){var n=this;if(l("process",e,{allowedMethods:["GET"]}),"function"!=typeof t)throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');var o=d({limit:v,total:Number.POSITIVE_INFINITY,accumulate:!0},r);return new Promise((function(r,i){var s,u="";if(e&&e.uri){var l=y(e.uri.split("?"),2),w=l[0],v=l[1];s=w,u=v}var g,m=d({},(void 0===g&&(g=a),g(u))),A=d({limit:o.limit},m),O=!1,j=o.total,C=function(a,u){return void 0===u&&(u=[]),f(n,void 0,void 0,(function(){var n,l,f,y,w,v,g,m,M,E,S,k,T,q;return p(this,(function(p){switch(p.label){case 0:n=A.limit<j?A.limit:j,l=c(d(d({},A),{limit:n})),f=d({sort:o.sort||"id asc",withTotal:!1},a?{where:'id > "'.concat(a,'"')}:{}),y=c(f),w=d(d({},e),{uri:"".concat(s,"?").concat(y,"&").concat(l)}),p.label=1;case 1:return p.trys.push([1,4,,5]),[4,b(h).execute(w)];case 2:return v=p.sent(),g=v.body,m=g.results,!(M=g.count)&&O?[2,r(u||[])]:[4,Promise.resolve(t(v))];case 3:return E=p.sent(),S=[],O=!0,o.accumulate&&(S=u.concat(E||[])),j-=M,M<A.limit||!j?[2,r(S||[])]:(k=m[M-1],T=k&&k.id,C(T,S),[3,5]);case 4:return q=p.sent(),i(q),[3,5];case 5:return[2]}}))}))};C()}))}function b(e){if(h=e,!e)throw new Error("Missing required options");if(e.middlewares&&!Array.isArray(e.middlewares))throw new Error("Middlewares should be an array");if(!e.middlewares||!Array.isArray(e.middlewares)||!e.middlewares.length)throw new Error("You need to provide at least one middleware");return{process:m,execute:function(t){return l("exec",t),new Promise((function(r,n){g.apply(void 0,w([],y(e.middlewares),!1))((function(e,t){if(t.error)t.reject(t.error);else{var r={body:t.body||{},statusCode:t.statusCode};t.headers&&(r.headers=t.headers),t.request&&(r.request=t.request),t.resolve(r)}}))(t,{resolve:r,reject:n,body:void 0,error:void 0})}))}}}},367:(e,t,r)=>{"use strict";r.d(t,{Ay:()=>y,Dr:()=>a,j$:()=>s});var n=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function i(e,t,r){void 0===r&&(r={}),this.status=this.statusCode=this.code=e,this.message=t,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,0],n(e),!1))}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this],n(e),!1))}function c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,400],n(e),!1))}function u(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,401],n(e),!1))}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,403],n(e),!1))}function h(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,404],n(e),!1))}function d(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,409],n(e),!1))}function f(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,500],n(e),!1))}function p(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,503],n(e),!1))}function y(e){switch(e){case 0:return a;case 400:return c;case 401:return u;case 403:return l;case 404:return h;case 409:return d;case 500:return f;case 503:return p;default:return}}},571:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(105),o=r(486),i=r(539),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.A)({token:"",expirationTime:-1}),r=[],s=(0,i.A)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.O4)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.A)(l,i,e)}}}}},105:(e,t,r)=>{"use strict";r.d(t,{A:()=>l});var n=r(486),o=r(146),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},a=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},s=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};function c(e,t){return i(i({},t),{headers:i(i({},t.headers),{Authorization:"Bearer ".concat(e)})})}function u(e){var t=e.fetcher,r=e.url,n=e.basicAuth,i=e.body,u=e.tokenCache,l=e.requestState,h=e.pendingTasks,d=e.response,f=e.tokenCacheKey;return a(this,void 0,void 0,(function(){var e,a,p,y,w,v,g,m,b,A,O;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),[4,t(r,{method:"POST",headers:{Authorization:"Basic ".concat(n),"Content-Length":o.Buffer.byteLength(i).toString(),"Content-Type":"application/x-www-form-urlencoded"},body:i})];case 1:return(e=s.sent()).ok?[4,e.json()]:[3,3];case 2:return a=s.sent(),p=a.access_token,y=a.expires_in,w=a.refresh_token,v=function(e){return Date.now()+1e3*e-3e5}(y),u.set({token:p,expirationTime:v,refreshToken:w},f),l.set(!1),g=h.slice(),h=[],g.forEach((function(e){var t=c(p,e.request);e.next(t,e.response)})),[2];case 3:return m=void 0,[4,e.text()];case 4:b=s.sent();try{m=JSON.parse(b)}catch(e){}return A=new Error(m?m.message:b),m&&(A.body=m),l.set(!1),d.reject(A),[3,6];case 5:return O=s.sent(),l.set(!1),d&&"function"==typeof d.reject&&d.reject(O),[3,6];case 6:return[2]}}))}))}function l(e,t,r){var o=e.request,a=e.response,s=e.url,l=e.basicAuth,h=e.body,d=e.pendingTasks,f=e.requestState,p=e.tokenCache,y=e.tokenCacheKey,w=e.fetch;if(!w&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(w||(w=fetch),o.headers&&o.headers.authorization||o.headers&&o.headers.Authorization)t(o,a);else{var v=p.get(y);if(v&&v.token&&Date.now()<v.expirationTime)t(c(v.token,o),a);else if(d.push({request:o,response:a,next:t}),!f.get())if(f.set(!0),v&&v.refreshToken&&(!v.token||v.token&&Date.now()>v.expirationTime)){if(!r)throw new Error("Missing required options");u(i(i({fetcher:w},(0,n.nO)(i(i({},r),{refreshToken:v.refreshToken}))),{tokenCacheKey:y,tokenCache:p,requestState:f,pendingTasks:d,response:a}))}else u({fetcher:w,url:s,basicAuth:l,body:h,tokenCacheKey:y,tokenCache:p,requestState:f,pendingTasks:d,response:a})}}},486:(e,t,r)=>{"use strict";r.d(t,{O4:()=>c,Wh:()=>a,nO:()=>s,wg:()=>i});var n=r(146),o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function i(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");var t=e.credentials,r=t.clientId,o=t.clientSecret;if(!r||!o)throw new Error("Missing required credentials (clientId, clientSecret)");var i=e.scopes?e.scopes.join(" "):void 0,a=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),s=e.oauthUri||"/oauth/token";return{basicAuth:a,url:e.host.replace(/\/$/,"")+s,body:"grant_type=client_credentials".concat(i?"&scope=".concat(i):"")}}function a(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");var t=e.credentials,r=t.clientId,o=t.clientSecret,i=t.user,a=e.projectKey;if(!(r&&o&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");var s=i.username,c=i.password;if(!s||!c)throw new Error("Missing required user credentials (username, password)");var u=(e.scopes||[]).join(" "),l=u?"&scope=".concat(u):"",h=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),d=e.oauthUri||"/oauth/".concat(a,"/customers/token");return{basicAuth:h,url:e.host.replace(/\/$/,"")+d,body:"grant_type=password&username=".concat(encodeURIComponent(s),"&password=").concat(encodeURIComponent(c)).concat(l)}}function s(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");if(!e.refreshToken)throw new Error("Missing required option (refreshToken)");var t=e.credentials,r=t.clientId,o=t.clientSecret;if(!r||!o)throw new Error("Missing required credentials (clientId, clientSecret)");var i=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),a=e.oauthUri||"/oauth/token";return{basicAuth:i,url:e.host.replace(/\/$/,"")+a,body:"grant_type=refresh_token&refresh_token=".concat(encodeURIComponent(e.refreshToken))}}function c(e){if(!e)throw new Error("Missing required options");if(!e.projectKey)throw new Error("Missing required option (projectKey)");var t=e.projectKey;e.oauthUri=e.oauthUri||"/oauth/".concat(t,"/anonymous/token");var r=i(e);return e.credentials.anonymousId&&(r.body+="&anonymous_id=".concat(e.credentials.anonymousId)),o({},r)}},241:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var n=r(105),o=r(486);function i(e){return{clientId:e.credentials.clientId,host:e.host,projectKey:e.projectKey}}var a=r(539),s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function c(e){var t=e.tokenCache||(0,a.A)({token:"",expirationTime:-1}),r=(0,a.A)(!1),c=[];return function(a){return function(u,l){if(u.headers&&u.headers.authorization||u.headers&&u.headers.Authorization)a(u,l);else{var h=s(s({request:u,response:l},(0,o.wg)(e)),{pendingTasks:c,requestState:r,tokenCache:t,tokenCacheKey:i(e),fetch:e.fetch});(0,n.A)(h,a)}}}}},901:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t){return void 0===e&&(e=""),void 0===t&&(t={}),function(r){return function(o,i){if("string"!=typeof e)throw new Error("authorization must be a string");var a=void 0===t.force||t.force;if(!e||(o.headers&&o.headers.authorization||o.headers&&o.headers.Authorization)&&!1===a)return r(o,i);var s=n(n({},o),{headers:n(n({},o.headers),{Authorization:e})});return r(s,i)}}}},646:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(105),o=r(486),i=r(539),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.A)({}),r=[],s=(0,i.A)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.Wh)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.A)(l,i,e)}}}}},726:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(105),o=r(486),i=r(539),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.A)({token:"",expirationTime:-1}),r=[],s=(0,i.A)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.nO)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.A)(l,i)}}}}},539:(e,t,r)=>{"use strict";function n(e){var t=e;return{get:function(e){return t},set:function(e,r){t=e}}}r.d(t,{A:()=>n})},510:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e){return function(t){return function(r,o){var i=n(n({},r),{headers:n(n({},r.headers),{"X-Correlation-ID":e.generate()})});t(i,o)}}}},650:(e,t,r)=>{"use strict";r.d(t,{A:()=>f});var n=r(146),o=r(367);function i(e){if(e.raw)return e.raw();if(!e.forEach)return{};var t={};return e.forEach((function(e,r){t[r]=e})),t}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)},s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},c=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},u=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function l(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function h(e,t,r,n,o){return n&&0!==e?Math.min(Math.round((Math.random()+1)*t*Math.pow(2,e)),o):t}function d(e,t){t&&(e&&e.headers&&e.headers.authorization&&(e.headers.authorization="Bearer ********"),e&&e.headers&&e.headers.Authorization&&(e.headers.Authorization="Bearer ********"))}function f(e){var t,r=e.host,f=e.credentialsMode,p=e.includeResponseHeaders,y=e.includeOriginalRequest,w=e.includeRequestInErrorResponse,v=void 0===w||w,g=e.maskSensitiveHeaderData,m=void 0===g||g,b=e.headersWithStringBody,A=void 0===b?[]:b,O=e.enableRetry,j=e.timeout,C=e.retryConfig,M=void 0===C?{}:C,E=M.maxRetries,S=void 0===E?10:E,k=M.backoff,T=void 0===k||k,q=M.retryDelay,x=void 0===q?200:q,P=M.maxDelay,I=void 0===P?1/0:P,K=M.retryOnAbort,R=void 0!==K&&K,U=M.retryCodes,N=void 0===U?[503]:U,F=e.fetch,B=e.getAbortController;if(!F)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(j&&!B)throw new Error("`AbortController` is not available. Please pass in `getAbortController` as an option or have AbortController globally available when using timeout.");if(t=F||fetch,!Array.isArray(N))throw new Error("`retryCodes` option must be an array of retry status (error) codes.");if(!Array.isArray(A))throw new Error("`headersWithStringBody` option must be an array of strings");return function(e){return function(w,g){var b=r.replace(/\/$/,"")+w.uri,C=a({},w.headers);Object.prototype.hasOwnProperty.call(C,"Content-Type")||Object.prototype.hasOwnProperty.call(C,"content-type")||(C["Content-Type"]="application/json"),null===C["Content-Type"]&&delete C["Content-Type"];var M=u(["application/json","application/graphql"],c(A),!1).indexOf(C["Content-Type"])>-1&&"string"==typeof w.body||l(w.body)?w.body:JSON.stringify(w.body||void 0);M&&("string"==typeof M||l(M))&&(C["Content-Length"]=n.Buffer.byteLength(M).toString());var E={method:w.method,headers:C};f&&(E.credentialsMode=f),M&&(E.body=M);var k=0;!function r(){var n,c;j&&(c=(B?B():null)||new AbortController,E.signal=c.signal,n=setTimeout((function(){c.abort()}),j)),t(b,E).then((function(t){if(t.ok)return"HEAD"===E.method?void e(w,a(a({},g),{statusCode:t.status})):void t.text().then((function(n){var o;try{o=n.length>0?JSON.parse(n):{}}catch(e){if(O&&k<S)return setTimeout(r,h(k,x,0,T,I)),void(k+=1);o=n}var s=a(a({},g),{body:o,statusCode:t.status});p&&(s.headers=i(t.headers)),y&&(s.request=a({},E),d(s.request,m)),e(w,s)})).catch((function(t){if(O&&k<S)return setTimeout(r,h(k,x,0,T,I)),void(k+=1);var n=new o.Dr(t.message,a(a({},v?{originalRequest:w}:{}),{retryCount:k}));d(n.originalRequest,m),e(w,a(a({},g),{error:n,statusCode:0}))}));t.text().then((function(n){var c;try{c=JSON.parse(n)}catch(u){c=n}var u=function(e){var t,r=e.statusCode,n=e.message,i=s(e,["statusCode","message"]),a=n||"Unexpected non-JSON error response";404===r&&(a="URI not found: ".concat((null===(t=i.originalRequest)||void 0===t?void 0:t.uri)||i.uri),delete i.uri);var c=(0,o.Ay)(r);return c?new c(a,i):new o.j$(r,a,i)}(a(a(a({statusCode:t.status},v?{originalRequest:w}:404===t.status?{uri:w.uri}:{}),{retryCount:k,headers:i(t.headers)}),"object"==typeof c?{message:c.message,body:c}:{message:c,body:c}));if(O&&(-1!==N.indexOf(u.statusCode)||-1!==(null==N?void 0:N.indexOf(u.message)))&&k<S)return setTimeout(r,h(k,x,0,T,I)),void(k+=1);d(u.originalRequest,m);var l=a(a({},g),{error:u,statusCode:t.status});e(w,l)}))}),(function(t){if(O&&(R||!c||!c.signal)&&k<S)return setTimeout(r,h(k,x,0,T,I)),void(k+=1);var n=new o.Dr(t.message,a(a({},v?{originalRequest:w}:{}),{retryCount:k}));d(n.originalRequest,m),e(w,a(a({},g),{error:n,statusCode:0}))})).finally((function(){clearTimeout(n)}))}()}}}},345:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=r(830);function o(){return function(e){return function(t,r){var o=r.error,i=r.body,a=r.statusCode;n.log("Request: ",t),n.log("Response: ",{error:o,body:i,statusCode:a}),e(t,r)}}}},412:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e){var t=e.concurrency,r=void 0===t?20:t,o=[],i=0,a=function(e){if(i-=1,o.length&&i<=r){var t=o.shift();i+=1,e(t.request,t.response)}};return function(e){return function(t,s){var c=n(n({},s),{resolve:function(t){s.resolve(t),a(e)},reject:function(t){s.reject(t),a(e)}});if(o.push({request:t,response:c}),i<r){var u=o.shift();i+=1,e(u.request,u.response)}}}}},15:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});const n={rE:"2.4.1"};var o=r(633),i=function(){return"undefined"!=typeof window&&window.document&&9===window.document.nodeType};var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=function(e){if(!e||0===Object.keys(e).length||!{}.hasOwnProperty.call(e,"name"))throw new Error("Missing required option `name`");var t=e.version?"".concat(e.name,"/").concat(e.version):e.name,r=null;e.libraryName&&!e.libraryVersion?r=e.libraryName:e.libraryName&&e.libraryVersion&&(r="".concat(e.libraryName,"/").concat(e.libraryVersion));var n=null;return e.contactUrl&&!e.contactEmail?n="(+".concat(e.contactUrl,")"):!e.contactUrl&&e.contactEmail?n="(+".concat(e.contactEmail,")"):e.contactUrl&&e.contactEmail&&(n="(+".concat(e.contactUrl,"; +").concat(e.contactEmail,")")),[t,function(){if(i())return window.navigator.userAgent;var e=(null==o?void 0:o.version.slice(1))||"12";return"node.js/".concat(e)}(),r,n,e.customAgent||""].filter(Boolean).join(" ")}(a(a({},e),{name:"commercetools-sdk-javascript-v2/".concat(n.rE)}));return function(e){return function(r,n){var o=a(a({},r),{headers:a(a({},r.headers),{"User-Agent":t})});e(o,n)}}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{ClientBuilder:()=>e.A,Process:()=>t.eh,createAuthForAnonymousSessionFlow:()=>i.A,createAuthForClientCredentialsFlow:()=>a.A,createAuthForPasswordFlow:()=>c.A,createAuthForRefreshTokenFlow:()=>u.A,createAuthWithExistingToken:()=>s.A,createClient:()=>t.Ay,createCorrelationIdMiddleware:()=>l.A,createHttpClient:()=>h.A,createLoggerMiddleware:()=>d.A,createQueueMiddleware:()=>f.A,createUserAgentMiddleware:()=>p.A,getErrorByCode:()=>o.Ay});var e=r(435),t=r(822),o=r(367),i=r(571),a=r(241),s=r(901),c=r(646),u=r(726),l=r(510),h=r(650),d=r(345),f=r(412),p=r(15),y=r(854),w={};for(const e in y)["default","ClientBuilder","createClient","Process","getErrorByCode","createAuthForAnonymousSessionFlow","createAuthForClientCredentialsFlow","createAuthWithExistingToken","createAuthForPasswordFlow","createAuthForRefreshTokenFlow","createCorrelationIdMiddleware","createHttpClient","createLoggerMiddleware","createQueueMiddleware","createUserAgentMiddleware"].indexOf(e)<0&&(w[e]=()=>y[e]);r.d(n,w)})(),n})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@commercetools/sdk-client-v2"]=t():e["@commercetools/sdk-client-v2"]=t()}(self,(()=>(()=>{var e={146:()=>{},830:()=>{},33:()=>{},633:()=>{},854:()=>{},435:(e,t,r)=>{"use strict";r.d(t,{A:()=>j});var n=r(33),o=r.n(n),i=r(822),a=r(571),s=r(241),c=r(901),u=r(646),l=r(726),d=r(510),h=r(650),f=r(345),p=r(412),y=r(15),w=function(){return w=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},w.apply(this,arguments)},v=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},g=u.A,m=a.A,b=s.A,A=l.A,O=c.A;const j=function(){function e(){this.middlewares=[]}return e.prototype.withProjectKey=function(e){return this.projectKey=e,this},e.prototype.defaultClient=function(e,t,r,n){return this.withClientCredentialsFlow({host:r,projectKey:n||this.projectKey,credentials:t}).withHttpMiddleware({host:e,fetch:o()}).withLoggerMiddleware().withUserAgentMiddleware()},e.prototype.withAuthMiddleware=function(e){return this.authMiddleware=e,this},e.prototype.withMiddleware=function(e){return this.middlewares.push(e),this},e.prototype.withClientCredentialsFlow=function(e){return this.withAuthMiddleware(b(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||""},oauthUri:e.oauthUri||"",scopes:e.scopes,fetch:e.fetch||o()},e)))},e.prototype.withPasswordFlow=function(e){return this.withAuthMiddleware(g(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||"",user:{username:e.credentials.user.username||"",password:e.credentials.user.password||""}},fetch:e.fetch||o()},e)))},e.prototype.withAnonymousSessionFlow=function(e){return this.withAuthMiddleware(m(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||"",anonymousId:e.credentials.anonymousId||""},fetch:e.fetch||o()},e)))},e.prototype.withRefreshTokenFlow=function(e){return this.withAuthMiddleware(A(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||""},fetch:e.fetch||o(),refreshToken:e.refreshToken||""},e)))},e.prototype.withExistingTokenFlow=function(e,t){return this.withAuthMiddleware(O(e,w({force:t.force||!0},t)))},e.prototype.withHttpMiddleware=function(e){return this.httpMiddleware=(0,h.A)(w({host:e.host||"https://api.europe-west1.gcp.commercetools.com",fetch:e.fetch||o()},e)),this},e.prototype.withUserAgentMiddleware=function(e){return this.userAgentMiddleware=(0,y.A)(e),this},e.prototype.withQueueMiddleware=function(e){return this.queueMiddleware=(0,p.A)(w({concurrency:e.concurrency||20},e)),this},e.prototype.withLoggerMiddleware=function(e){var t=e||{},r=(t.logger,v(t,["logger"]));return this.loggerMiddleware="function"==typeof(null==e?void 0:e.logger)&&e.logger(r)||(0,f.A)(),this},e.prototype.withCorrelationIdMiddleware=function(e){return this.correlationIdMiddleware=(0,d.A)(w({generate:e.generate||null},e)),this},e.prototype.withTelemetryMiddleware=function(e){var t=e.createTelemetryMiddleware,r=v(e,["createTelemetryMiddleware"]);return this.withUserAgentMiddleware({customAgent:(null==r?void 0:r.userAgent)||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=t(r),this},e.prototype.withBeforeExecutionMiddleware=function(e){var t=e||{},r=(t.middleware,v(t,["middleware"]));return this.beforeMiddleware=e.middleware(r),this},e.prototype.withAfterExecutionMiddleware=function(e){var t=e||{},r=(t.middleware,v(t,["middleware"]));return this.afterMiddleware=e.middleware(r),this},e.prototype.build=function(){var e=this.middlewares.slice();return this.telemetryMiddleware&&e.push(this.telemetryMiddleware),this.correlationIdMiddleware&&e.push(this.correlationIdMiddleware),this.userAgentMiddleware&&e.push(this.userAgentMiddleware),this.authMiddleware&&e.push(this.authMiddleware),this.beforeMiddleware&&e.push(this.beforeMiddleware),this.queueMiddleware&&e.push(this.queueMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.afterMiddleware&&e.push(this.afterMiddleware),this.loggerMiddleware&&e.push(this.loggerMiddleware),(0,i.Ay)({middlewares:e})},e}()},822:(e,t,r)=>{"use strict";r.d(t,{Ay:()=>b,eh:()=>m});var n=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function i(e){return null!=e}function a(e){var t,r,n={},i=new URLSearchParams(e);try{for(var a=o(i.keys()),s=a.next();!s.done;s=a.next()){var c=s.value;i.getAll(c).length>1?n[c]=i.getAll(c):n[c]=i.get(c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return n}function s(e){var t,r,a;if(e=i(a=e)?"string"==typeof a?a:Object.fromEntries(Object.entries(a).filter((function(e){var t=n(e,2),r=(t[0],t[1]);return![null,void 0,""].includes(r)}))):"",!e)return"";var s=new URLSearchParams(e),c=function(e,t){Array.isArray(t)&&(s.delete(e),t.filter(i).forEach((function(t){return s.append(e,t)})))};try{for(var u=o(Object.entries(e)),l=u.next();!l.done;l=u.next()){var d=n(l.value,2);c(d[0],d[1])}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return s.toString()}function c(e,t){return void 0===t&&(t=s),t(e)}const u=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function l(e,t,r){if(void 0===r&&(r={allowedMethods:u}),!t)throw new Error('The "'.concat(e,'" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if("string"!=typeof t.uri)throw new Error('The "'.concat(e,'" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if(!r.allowedMethods.includes(t.method))throw new Error('The "'.concat(e,'" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'))}var d,h=function(){return h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},h.apply(this,arguments)},f=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},p=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},y=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},w=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},v=20;function g(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===(e=e.filter((function(e){return"function"==typeof e}))).length?e[0]:e.reduce((function(e,t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return e(t.apply(void 0,w([],y(r),!1)))}}))}function m(e,t,r){var n=this;if(l("process",e,{allowedMethods:["GET"]}),"function"!=typeof t)throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');var o=h({limit:v,total:Number.POSITIVE_INFINITY,accumulate:!0},r);return new Promise((function(r,i){var s,u="";if(e&&e.uri){var l=y(e.uri.split("?"),2),v=l[0],g=l[1];s=v,u=g}var m,A=h({},(void 0===m&&(m=a),m(u))),O=h({limit:o.limit},A),j=!1,M=o.total,C=function(a){for(var u=[],l=1;l<arguments.length;l++)u[l-1]=arguments[l];return f(n,w([a],y(u),!1),void 0,(function(n,a){var u,l,f,y,w,v,g,m,A,E,S,k,T,q;return void 0===a&&(a=[]),p(this,(function(p){switch(p.label){case 0:u=O.limit<M?O.limit:M,l=c(h(h({},O),{limit:u})),f=h({sort:o.sort||"id asc",withTotal:!1},n?{where:'id > "'.concat(n,'"')}:{}),y=c(f),w=h(h({},e),{uri:"".concat(s,"?").concat(y,"&").concat(l)}),p.label=1;case 1:return p.trys.push([1,4,,5]),[4,b(d).execute(w)];case 2:return v=p.sent(),g=v.body,m=g.results,!(A=g.count)&&j?[2,r(a||[])]:[4,Promise.resolve(t(v))];case 3:return E=p.sent(),S=[],j=!0,o.accumulate&&(S=a.concat(E||[])),M-=A,A<O.limit||!M?[2,r(S||[])]:(k=m[A-1],T=k&&k.id,C(T,S),[3,5]);case 4:return q=p.sent(),i(q),[3,5];case 5:return[2]}}))}))};C()}))}function b(e){if(d=e,!e)throw new Error("Missing required options");if(e.middlewares&&!Array.isArray(e.middlewares))throw new Error("Middlewares should be an array");if(!e.middlewares||!Array.isArray(e.middlewares)||!e.middlewares.length)throw new Error("You need to provide at least one middleware");return{process:m,execute:function(t){return l("exec",t),new Promise((function(r,n){g.apply(void 0,w([],y(e.middlewares),!1))((function(e,t){if(t.error)t.reject(t.error);else{var r={body:t.body||{},statusCode:t.statusCode};t.headers&&(r.headers=t.headers),t.request&&(r.request=t.request),t.resolve(r)}}))(t,{resolve:r,reject:n,body:void 0,error:void 0})}))}}}},367:(e,t,r)=>{"use strict";r.d(t,{Ay:()=>y,Dr:()=>a,j$:()=>s});var n=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function i(e,t,r){void 0===r&&(r={}),this.status=this.statusCode=this.code=e,this.message=t,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,0],n(e),!1))}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this],n(e),!1))}function c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,400],n(e),!1))}function u(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,401],n(e),!1))}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,403],n(e),!1))}function d(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,404],n(e),!1))}function h(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,409],n(e),!1))}function f(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,500],n(e),!1))}function p(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.call.apply(i,o([this,503],n(e),!1))}function y(e){switch(e){case 0:return a;case 400:return c;case 401:return u;case 403:return l;case 404:return d;case 409:return h;case 500:return f;case 503:return p;default:return}}},571:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(105),o=r(486),i=r(539),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.A)({token:"",expirationTime:-1}),r=[],s=(0,i.A)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.O4)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.A)(l,i,e)}}}}},105:(e,t,r)=>{"use strict";r.d(t,{A:()=>l});var n=r(486),o=r(146),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},a=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},s=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};function c(e,t){return i(i({},t),{headers:i(i({},t.headers),{Authorization:"Bearer ".concat(e)})})}function u(e){return a(this,arguments,void 0,(function(e){var t,r,n,i,a,u,l,d,h,f,p,y=e.fetcher,w=e.url,v=e.basicAuth,g=e.body,m=e.tokenCache,b=e.requestState,A=e.pendingTasks,O=e.response,j=e.tokenCacheKey;return s(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,y(w,{method:"POST",headers:{Authorization:"Basic ".concat(v),"Content-Length":o.Buffer.byteLength(g).toString(),"Content-Type":"application/x-www-form-urlencoded"},body:g})];case 1:return(t=e.sent()).ok?[4,t.json()]:[3,3];case 2:return r=e.sent(),n=r.access_token,i=r.expires_in,a=r.refresh_token,u=function(e){return Date.now()+1e3*e-3e5}(i),m.set({token:n,expirationTime:u,refreshToken:a},j),b.set(!1),l=A.slice(),A=[],l.forEach((function(e){var t=c(n,e.request);e.next(t,e.response)})),[2];case 3:return d=void 0,[4,t.text()];case 4:h=e.sent();try{d=JSON.parse(h)}catch(e){}return f=new Error(d?d.message:h),d&&(f.body=d),b.set(!1),O.reject(f),[3,6];case 5:return p=e.sent(),b.set(!1),O&&"function"==typeof O.reject&&O.reject(p),[3,6];case 6:return[2]}}))}))}function l(e,t,r){var o=e.request,a=e.response,s=e.url,l=e.basicAuth,d=e.body,h=e.pendingTasks,f=e.requestState,p=e.tokenCache,y=e.tokenCacheKey,w=e.fetch;if(!w&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(w||(w=fetch),o.headers&&o.headers.authorization||o.headers&&o.headers.Authorization)t(o,a);else{var v=p.get(y);if(v&&v.token&&Date.now()<v.expirationTime)t(c(v.token,o),a);else if(h.push({request:o,response:a,next:t}),!f.get())if(f.set(!0),v&&v.refreshToken&&(!v.token||v.token&&Date.now()>v.expirationTime)){if(!r)throw new Error("Missing required options");u(i(i({fetcher:w},(0,n.nO)(i(i({},r),{refreshToken:v.refreshToken}))),{tokenCacheKey:y,tokenCache:p,requestState:f,pendingTasks:h,response:a}))}else u({fetcher:w,url:s,basicAuth:l,body:d,tokenCacheKey:y,tokenCache:p,requestState:f,pendingTasks:h,response:a})}}},486:(e,t,r)=>{"use strict";r.d(t,{O4:()=>c,Wh:()=>a,nO:()=>s,wg:()=>i});var n=r(146),o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function i(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");var t=e.credentials,r=t.clientId,o=t.clientSecret;if(!r||!o)throw new Error("Missing required credentials (clientId, clientSecret)");var i=e.scopes?e.scopes.join(" "):void 0,a=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),s=e.oauthUri||"/oauth/token";return{basicAuth:a,url:e.host.replace(/\/$/,"")+s,body:"grant_type=client_credentials".concat(i?"&scope=".concat(i):"")}}function a(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");var t=e.credentials,r=t.clientId,o=t.clientSecret,i=t.user,a=e.projectKey;if(!(r&&o&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");var s=i.username,c=i.password;if(!s||!c)throw new Error("Missing required user credentials (username, password)");var u=(e.scopes||[]).join(" "),l=u?"&scope=".concat(u):"",d=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),h=e.oauthUri||"/oauth/".concat(a,"/customers/token");return{basicAuth:d,url:e.host.replace(/\/$/,"")+h,body:"grant_type=password&username=".concat(encodeURIComponent(s),"&password=").concat(encodeURIComponent(c)).concat(l)}}function s(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");if(!e.refreshToken)throw new Error("Missing required option (refreshToken)");var t=e.credentials,r=t.clientId,o=t.clientSecret;if(!r||!o)throw new Error("Missing required credentials (clientId, clientSecret)");var i=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),a=e.oauthUri||"/oauth/token";return{basicAuth:i,url:e.host.replace(/\/$/,"")+a,body:"grant_type=refresh_token&refresh_token=".concat(encodeURIComponent(e.refreshToken))}}function c(e){if(!e)throw new Error("Missing required options");if(!e.projectKey)throw new Error("Missing required option (projectKey)");var t=e.projectKey;e.oauthUri=e.oauthUri||"/oauth/".concat(t,"/anonymous/token");var r=i(e);return e.credentials.anonymousId&&(r.body+="&anonymous_id=".concat(e.credentials.anonymousId)),o({},r)}},241:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var n=r(105),o=r(486);function i(e){return{clientId:e.credentials.clientId,host:e.host,projectKey:e.projectKey}}var a=r(539),s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function c(e){var t=e.tokenCache||(0,a.A)({token:"",expirationTime:-1}),r=(0,a.A)(!1),c=[];return function(a){return function(u,l){if(u.headers&&u.headers.authorization||u.headers&&u.headers.Authorization)a(u,l);else{var d=s(s({request:u,response:l},(0,o.wg)(e)),{pendingTasks:c,requestState:r,tokenCache:t,tokenCacheKey:i(e),fetch:e.fetch});(0,n.A)(d,a)}}}}},901:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t){return void 0===e&&(e=""),void 0===t&&(t={}),function(r){return function(o,i){if("string"!=typeof e)throw new Error("authorization must be a string");var a=void 0===t.force||t.force;if(!e||(o.headers&&o.headers.authorization||o.headers&&o.headers.Authorization)&&!1===a)return r(o,i);var s=n(n({},o),{headers:n(n({},o.headers),{Authorization:e})});return r(s,i)}}}},646:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(105),o=r(486),i=r(539),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.A)({}),r=[],s=(0,i.A)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.Wh)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.A)(l,i,e)}}}}},726:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(105),o=r(486),i=r(539),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.A)({token:"",expirationTime:-1}),r=[],s=(0,i.A)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.nO)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.A)(l,i)}}}}},539:(e,t,r)=>{"use strict";function n(e){var t=e;return{get:function(e){return t},set:function(e,r){t=e}}}r.d(t,{A:()=>n})},510:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e){return function(t){return function(r,o){var i=n(n({},r),{headers:n(n({},r.headers),{"X-Correlation-ID":e.generate()})});t(i,o)}}}},650:(e,t,r)=>{"use strict";r.d(t,{A:()=>f});var n=r(146),o=r(367);function i(e){if(e.raw)return e.raw();if(!e.forEach)return{};var t={};return e.forEach((function(e,r){t[r]=e})),t}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)},s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},c=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},u=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function l(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function d(e,t,r,n,o){return n&&0!==e?Math.min(Math.round((Math.random()+1)*t*Math.pow(2,e)),o):t}function h(e,t){t&&(e&&e.headers&&e.headers.authorization&&(e.headers.authorization="Bearer ********"),e&&e.headers&&e.headers.Authorization&&(e.headers.Authorization="Bearer ********"))}function f(e){var t,r=e.host,f=e.credentialsMode,p=e.includeResponseHeaders,y=e.includeOriginalRequest,w=e.includeRequestInErrorResponse,v=void 0===w||w,g=e.maskSensitiveHeaderData,m=void 0===g||g,b=e.headersWithStringBody,A=void 0===b?[]:b,O=e.enableRetry,j=e.timeout,M=e.retryConfig,C=void 0===M?{}:M,E=C.maxRetries,S=void 0===E?10:E,k=C.backoff,T=void 0===k||k,q=C.retryDelay,x=void 0===q?200:q,P=C.maxDelay,I=void 0===P?1/0:P,K=C.retryOnAbort,R=void 0!==K&&K,U=C.retryCodes,N=void 0===U?[503]:U,B=e.fetch,F=e.getAbortController;if(!B)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(j&&!F)throw new Error("`AbortController` is not available. Please pass in `getAbortController` as an option or have AbortController globally available when using timeout.");if(t=B||fetch,!Array.isArray(N))throw new Error("`retryCodes` option must be an array of retry status (error) codes.");if(!Array.isArray(A))throw new Error("`headersWithStringBody` option must be an array of strings");return function(e){return function(w,g){var b=r.replace(/\/$/,"")+w.uri,M=a({},w.headers);Object.prototype.hasOwnProperty.call(M,"Content-Type")||Object.prototype.hasOwnProperty.call(M,"content-type")||(M["Content-Type"]="application/json"),null===M["Content-Type"]&&delete M["Content-Type"];var C=u(["application/json","application/graphql"],c(A),!1).indexOf(M["Content-Type"])>-1&&"string"==typeof w.body||l(w.body)?w.body:JSON.stringify(w.body||void 0);C&&("string"==typeof C||l(C))&&(M["Content-Length"]=n.Buffer.byteLength(C).toString());var E={method:w.method,headers:M};f&&(E.credentialsMode=f),C&&(E.body=C);var k=0;!function r(){var n,c;j&&(c=(F?F():null)||new AbortController,E.signal=c.signal,n=setTimeout((function(){c.abort()}),j)),t(b,E).then((function(t){if(t.ok)return"HEAD"===E.method?void e(w,a(a({},g),{statusCode:t.status})):void t.text().then((function(n){var o;try{o=n.length>0?JSON.parse(n):{}}catch(e){if(O&&k<S)return setTimeout(r,d(k,x,0,T,I)),void(k+=1);o=n}var s=a(a({},g),{body:o,statusCode:t.status});p&&(s.headers=i(t.headers)),y&&(s.request=a({},E),h(s.request,m)),e(w,s)})).catch((function(t){if(O&&k<S)return setTimeout(r,d(k,x,0,T,I)),void(k+=1);var n=new o.Dr(t.message,a(a({},v?{originalRequest:w}:{}),{retryCount:k}));h(n.originalRequest,m),e(w,a(a({},g),{error:n,statusCode:0}))}));t.text().then((function(n){var c;try{c=JSON.parse(n)}catch(u){c=n}var u=function(e){var t,r=e.statusCode,n=e.message,i=s(e,["statusCode","message"]),a=n||"Unexpected non-JSON error response";404===r&&(a="URI not found: ".concat((null===(t=i.originalRequest)||void 0===t?void 0:t.uri)||i.uri),delete i.uri);var c=(0,o.Ay)(r);return c?new c(a,i):new o.j$(r,a,i)}(a(a(a({statusCode:t.status},v?{originalRequest:w}:404===t.status?{uri:w.uri}:{}),{retryCount:k,headers:i(t.headers)}),"object"==typeof c?{message:c.message,body:c}:{message:c,body:c}));if(O&&(-1!==N.indexOf(u.statusCode)||-1!==(null==N?void 0:N.indexOf(u.message)))&&k<S)return setTimeout(r,d(k,x,0,T,I)),void(k+=1);h(u.originalRequest,m);var l=a(a({},g),{error:u,statusCode:t.status});e(w,l)}))}),(function(t){if(O&&(R||!c||!c.signal)&&k<S)return setTimeout(r,d(k,x,0,T,I)),void(k+=1);var n=new o.Dr(t.message,a(a({},v?{originalRequest:w}:{}),{retryCount:k}));h(n.originalRequest,m),e(w,a(a({},g),{error:n,statusCode:0}))})).finally((function(){clearTimeout(n)}))}()}}}},345:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=r(830);function o(){return function(e){return function(t,r){var o=r.error,i=r.body,a=r.statusCode;n.log("Request: ",t),n.log("Response: ",{error:o,body:i,statusCode:a}),e(t,r)}}}},412:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e){var t=e.concurrency,r=void 0===t?20:t,o=[],i=0,a=function(e){if(i-=1,o.length&&i<=r){var t=o.shift();i+=1,e(t.request,t.response)}};return function(e){return function(t,s){var c=n(n({},s),{resolve:function(t){s.resolve(t),a(e)},reject:function(t){s.reject(t),a(e)}});if(o.push({request:t,response:c}),i<r){var u=o.shift();i+=1,e(u.request,u.response)}}}}},15:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});const n={rE:"2.5.0"};var o=r(633),i=function(){return"undefined"!=typeof window&&window.document&&9===window.document.nodeType};var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=function(e){if(!e||0===Object.keys(e).length||!{}.hasOwnProperty.call(e,"name"))throw new Error("Missing required option `name`");var t=e.version?"".concat(e.name,"/").concat(e.version):e.name,r=null;e.libraryName&&!e.libraryVersion?r=e.libraryName:e.libraryName&&e.libraryVersion&&(r="".concat(e.libraryName,"/").concat(e.libraryVersion));var n=null;return e.contactUrl&&!e.contactEmail?n="(+".concat(e.contactUrl,")"):!e.contactUrl&&e.contactEmail?n="(+".concat(e.contactEmail,")"):e.contactUrl&&e.contactEmail&&(n="(+".concat(e.contactUrl,"; +").concat(e.contactEmail,")")),[t,function(){if(i())return window.navigator.userAgent;var e=(null==o?void 0:o.version.slice(1))||"12";return"node.js/".concat(e)}(),r,n,e.customAgent||""].filter(Boolean).join(" ")}(a(a({},e),{name:"commercetools-sdk-javascript-v2/".concat(n.rE)}));return function(e){return function(r,n){var o=a(a({},r),{headers:a(a({},r.headers),{"User-Agent":t})});e(o,n)}}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{ClientBuilder:()=>e.A,Process:()=>t.eh,createAuthForAnonymousSessionFlow:()=>i.A,createAuthForClientCredentialsFlow:()=>a.A,createAuthForPasswordFlow:()=>c.A,createAuthForRefreshTokenFlow:()=>u.A,createAuthWithExistingToken:()=>s.A,createClient:()=>t.Ay,createCorrelationIdMiddleware:()=>l.A,createHttpClient:()=>d.A,createLoggerMiddleware:()=>h.A,createQueueMiddleware:()=>f.A,createUserAgentMiddleware:()=>p.A,getErrorByCode:()=>o.Ay});var e=r(435),t=r(822),o=r(367),i=r(571),a=r(241),s=r(901),c=r(646),u=r(726),l=r(510),d=r(650),h=r(345),f=r(412),p=r(15),y=r(854),w={};for(const e in y)["default","ClientBuilder","createClient","Process","getErrorByCode","createAuthForAnonymousSessionFlow","createAuthForClientCredentialsFlow","createAuthWithExistingToken","createAuthForPasswordFlow","createAuthForRefreshTokenFlow","createCorrelationIdMiddleware","createHttpClient","createLoggerMiddleware","createQueueMiddleware","createUserAgentMiddleware"].indexOf(e)<0&&(w[e]=()=>y[e]);r.d(n,w)})(),n})()));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnonymousAuthMiddlewareOptions, AuthMiddlewareOptions, Client, CorrelationIdMiddlewareOptions, Credentials, ExistingTokenMiddlewareOptions, HttpMiddlewareOptions, HttpUserAgentOptions, Middleware, PasswordAuthMiddlewareOptions, QueueMiddlewareOptions, RefreshAuthMiddlewareOptions, TelemetryOptions } from "../types/sdk.js";
|
|
1
|
+
import { AfterExecutionMiddlewareOptions, AnonymousAuthMiddlewareOptions, AuthMiddlewareOptions, BeforeExecutionMiddlewareOptions, Client, CorrelationIdMiddlewareOptions, Credentials, ExistingTokenMiddlewareOptions, HttpMiddlewareOptions, HttpUserAgentOptions, LoggerMiddlewareOptions, Middleware, PasswordAuthMiddlewareOptions, QueueMiddlewareOptions, RefreshAuthMiddlewareOptions, TelemetryOptions } from "../types/sdk.js";
|
|
2
2
|
export default class ClientBuilder {
|
|
3
3
|
private projectKey;
|
|
4
4
|
private authMiddleware;
|
|
@@ -8,6 +8,8 @@ export default class ClientBuilder {
|
|
|
8
8
|
private loggerMiddleware;
|
|
9
9
|
private queueMiddleware;
|
|
10
10
|
private telemetryMiddleware;
|
|
11
|
+
private beforeMiddleware;
|
|
12
|
+
private afterMiddleware;
|
|
11
13
|
private middlewares;
|
|
12
14
|
withProjectKey(key: string): ClientBuilder;
|
|
13
15
|
defaultClient(baseUri: string, credentials: Credentials, oauthUri?: string, projectKey?: string): ClientBuilder;
|
|
@@ -21,8 +23,10 @@ export default class ClientBuilder {
|
|
|
21
23
|
withHttpMiddleware(options: HttpMiddlewareOptions): ClientBuilder;
|
|
22
24
|
withUserAgentMiddleware(options?: HttpUserAgentOptions): ClientBuilder;
|
|
23
25
|
withQueueMiddleware(options: QueueMiddlewareOptions): ClientBuilder;
|
|
24
|
-
withLoggerMiddleware():
|
|
26
|
+
withLoggerMiddleware(options?: LoggerMiddlewareOptions): ClientBuilder;
|
|
25
27
|
withCorrelationIdMiddleware(options: CorrelationIdMiddlewareOptions): ClientBuilder;
|
|
26
28
|
withTelemetryMiddleware<T extends TelemetryOptions>(options: T): ClientBuilder;
|
|
29
|
+
withBeforeExecutionMiddleware(options: BeforeExecutionMiddlewareOptions): this;
|
|
30
|
+
withAfterExecutionMiddleware(options: AfterExecutionMiddlewareOptions): this;
|
|
27
31
|
build(): Client;
|
|
28
32
|
}
|
|
@@ -359,6 +359,12 @@ export type UserAgentMiddlewareOptions = {
|
|
|
359
359
|
contactEmail?: string
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
export type GenericOmit<T, U extends string | number | symbol> = Omit<T, U>;
|
|
363
|
+
export type LoggerMiddlewareOptions = {
|
|
364
|
+
[key: string]: any;
|
|
365
|
+
logger: (options?: GenericOmit<LoggerMiddlewareOptions, 'logger'>) => Middleware;
|
|
366
|
+
}
|
|
367
|
+
|
|
362
368
|
export type Next = (
|
|
363
369
|
request: MiddlewareRequest,
|
|
364
370
|
response: MiddlewareResponse
|
|
@@ -538,16 +544,19 @@ export type CorrelationIdMiddlewareOptions = {
|
|
|
538
544
|
generate: () => string
|
|
539
545
|
}
|
|
540
546
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
+
export type BeforeExecutionMiddlewareOptions = {
|
|
548
|
+
[key: string]: any;
|
|
549
|
+
middleware: (options?: GenericOmit<BeforeExecutionMiddlewareOptions, 'middleware'>) => Middleware
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export type AfterExecutionMiddlewareOptions = {
|
|
553
|
+
[key: string]: any;
|
|
554
|
+
middleware: (options?: GenericOmit<AfterExecutionMiddlewareOptions, 'middleware'>) => Middleware
|
|
555
|
+
}
|
|
547
556
|
|
|
548
557
|
export type TelemetryOptions = {
|
|
549
558
|
apm?: Function;
|
|
550
559
|
tracer?: Function;
|
|
551
560
|
userAgent?: string;
|
|
552
|
-
createTelemetryMiddleware: (options?:
|
|
561
|
+
createTelemetryMiddleware: (options?: GenericOmit<TelemetryOptions, 'createTelemetryMiddleware'>) => Middleware
|
|
553
562
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools/sdk-client-v2",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=14"
|
|
6
6
|
},
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"abort-controller": "3.0.0",
|
|
49
49
|
"common-tags": "1.8.2",
|
|
50
|
-
"dotenv": "16.
|
|
51
|
-
"jest": "29.
|
|
50
|
+
"dotenv": "16.4.5",
|
|
51
|
+
"jest": "29.7.0",
|
|
52
52
|
"nock": "12.0.3",
|
|
53
53
|
"organize-imports-cli": "0.10.0"
|
|
54
54
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commercetools-sdk-client-v2.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
|