@commercetools/ts-client 2.1.1 → 2.1.2
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 +7 -0
- package/dist/commercetools-ts-client.browser.cjs.js +23 -6
- package/dist/commercetools-ts-client.browser.esm.js +23 -6
- package/dist/commercetools-ts-client.cjs.dev.js +23 -6
- package/dist/commercetools-ts-client.cjs.prod.js +23 -6
- package/dist/commercetools-ts-client.esm.js +23 -6
- package/dist/commercetools-ts-client.umd.js +1 -1
- package/dist/declarations/src/client/builder.d.ts.map +1 -1
- package/dist/declarations/src/middleware/auth-middleware/anonymous-session-flow.d.ts.map +1 -1
- package/dist/declarations/src/middleware/auth-middleware/client-credentials-flow.d.ts.map +1 -1
- package/dist/declarations/src/middleware/auth-middleware/password-flow.d.ts.map +1 -1
- package/dist/declarations/src/middleware/auth-middleware/refresh-token-flow.d.ts.map +1 -1
- package/dist/declarations/src/types/types.d.ts +12 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @commercetools/ts-client
|
|
2
2
|
|
|
3
|
+
## 2.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#848](https://github.com/commercetools/commercetools-sdk-typescript/pull/848) [`39c5298`](https://github.com/commercetools/commercetools-sdk-typescript/commit/39c5298c8b6abb71bce47ef437e6e7359c3e8195) Thanks [@ajimae](https://github.com/ajimae)! - - add `httpClientOptions` to all supported `authMiddlewareOption` and `httpMiddlewareOptions`
|
|
8
|
+
- add options used for configuring the behaviour of the supported `httpClients` (fetch and axios)
|
|
9
|
+
|
|
3
10
|
## 2.1.1
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -175,11 +175,10 @@ async function executor(request) {
|
|
|
175
175
|
validateRetryCodes(retryCodes);
|
|
176
176
|
async function execute() {
|
|
177
177
|
return httpClient(url, {
|
|
178
|
-
...rest,
|
|
179
178
|
...options,
|
|
179
|
+
...rest,
|
|
180
180
|
headers: {
|
|
181
181
|
...rest.headers,
|
|
182
|
-
...options.headers,
|
|
183
182
|
// axios header encoding
|
|
184
183
|
'Accept-Encoding': 'application/json'
|
|
185
184
|
},
|
|
@@ -266,7 +265,15 @@ async function executor(request) {
|
|
|
266
265
|
* middleware options or from
|
|
267
266
|
* http client config
|
|
268
267
|
*/
|
|
269
|
-
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* we want to suppress axios internal
|
|
271
|
+
* error handling behaviour to make it
|
|
272
|
+
* consistent with native fetch.
|
|
273
|
+
*/
|
|
274
|
+
{
|
|
275
|
+
validateStatus: status => true
|
|
276
|
+
});
|
|
270
277
|
return data;
|
|
271
278
|
}
|
|
272
279
|
|
|
@@ -465,9 +472,12 @@ function createUserAgent(options) {
|
|
|
465
472
|
* validate some essential http options
|
|
466
473
|
* @param options
|
|
467
474
|
*/
|
|
468
|
-
function
|
|
475
|
+
function validateHttpClientOptions(options) {
|
|
469
476
|
if (!options.host) throw new Error('Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`');
|
|
470
477
|
if (!options.httpClient && typeof options.httpClient !== 'function') throw new Error('An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.');
|
|
478
|
+
if (options.httpClientOptions && Object.prototype.toString.call(options.httpClientOptions) !== '[object Object]') {
|
|
479
|
+
throw new Error('`httpClientOptions` must be an object type');
|
|
480
|
+
}
|
|
471
481
|
}
|
|
472
482
|
|
|
473
483
|
/**
|
|
@@ -626,6 +636,7 @@ function buildRequestForPasswordFlow(options) {
|
|
|
626
636
|
async function executeRequest$1(options) {
|
|
627
637
|
const {
|
|
628
638
|
httpClient,
|
|
639
|
+
httpClientOptions,
|
|
629
640
|
tokenCache,
|
|
630
641
|
userOption,
|
|
631
642
|
tokenCacheObject
|
|
@@ -668,6 +679,7 @@ async function executeRequest$1(options) {
|
|
|
668
679
|
'Content-Length': byteLength(body)
|
|
669
680
|
},
|
|
670
681
|
httpClient,
|
|
682
|
+
httpClientOptions,
|
|
671
683
|
body
|
|
672
684
|
});
|
|
673
685
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
@@ -733,6 +745,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
|
|
|
733
745
|
tokenCache,
|
|
734
746
|
tokenCacheKey,
|
|
735
747
|
httpClient: options.httpClient || fetch__default["default"],
|
|
748
|
+
httpClientOptions: options.httpClientOptions,
|
|
736
749
|
...buildRequestForAnonymousSessionFlow(options),
|
|
737
750
|
userOption: options,
|
|
738
751
|
next
|
|
@@ -787,6 +800,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
|
|
|
787
800
|
tokenCacheKey,
|
|
788
801
|
tokenCacheObject,
|
|
789
802
|
httpClient: options.httpClient || fetch__default["default"],
|
|
803
|
+
httpClientOptions: options.httpClientOptions,
|
|
790
804
|
...buildRequestForClientCredentialsFlow(options),
|
|
791
805
|
next
|
|
792
806
|
};
|
|
@@ -862,6 +876,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
|
|
|
862
876
|
tokenCache,
|
|
863
877
|
tokenCacheKey,
|
|
864
878
|
httpClient: options.httpClient || fetch__default["default"],
|
|
879
|
+
httpClientOptions: options.httpClientOptions,
|
|
865
880
|
...buildRequestForPasswordFlow(options),
|
|
866
881
|
userOption: options,
|
|
867
882
|
next
|
|
@@ -912,6 +927,7 @@ function createAuthMiddlewareForRefreshTokenFlow$1(options) {
|
|
|
912
927
|
request,
|
|
913
928
|
tokenCache,
|
|
914
929
|
httpClient: options.httpClient || fetch,
|
|
930
|
+
httpClientOptions: options.httpClientOptions,
|
|
915
931
|
...buildRequestForRefreshTokenFlow(options),
|
|
916
932
|
next
|
|
917
933
|
};
|
|
@@ -1100,7 +1116,7 @@ async function executeRequest({
|
|
|
1100
1116
|
}
|
|
1101
1117
|
function createHttpMiddleware$1(options) {
|
|
1102
1118
|
// validate response
|
|
1103
|
-
|
|
1119
|
+
validateHttpClientOptions(options);
|
|
1104
1120
|
const {
|
|
1105
1121
|
host,
|
|
1106
1122
|
credentialsMode,
|
|
@@ -1251,7 +1267,7 @@ function createQueueMiddleware$1({
|
|
|
1251
1267
|
|
|
1252
1268
|
var packageJson = {
|
|
1253
1269
|
name: "@commercetools/ts-client",
|
|
1254
|
-
version: "2.1.
|
|
1270
|
+
version: "2.1.2",
|
|
1255
1271
|
engines: {
|
|
1256
1272
|
node: ">=14"
|
|
1257
1273
|
},
|
|
@@ -1538,6 +1554,7 @@ class ClientBuilder {
|
|
|
1538
1554
|
host: oauthUri,
|
|
1539
1555
|
projectKey: projectKey || this.projectKey,
|
|
1540
1556
|
credentials,
|
|
1557
|
+
httpClient: httpClient || fetch__default["default"],
|
|
1541
1558
|
scopes
|
|
1542
1559
|
}).withHttpMiddleware({
|
|
1543
1560
|
host: baseUri,
|
|
@@ -166,11 +166,10 @@ async function executor(request) {
|
|
|
166
166
|
validateRetryCodes(retryCodes);
|
|
167
167
|
async function execute() {
|
|
168
168
|
return httpClient(url, {
|
|
169
|
-
...rest,
|
|
170
169
|
...options,
|
|
170
|
+
...rest,
|
|
171
171
|
headers: {
|
|
172
172
|
...rest.headers,
|
|
173
|
-
...options.headers,
|
|
174
173
|
// axios header encoding
|
|
175
174
|
'Accept-Encoding': 'application/json'
|
|
176
175
|
},
|
|
@@ -257,7 +256,15 @@ async function executor(request) {
|
|
|
257
256
|
* middleware options or from
|
|
258
257
|
* http client config
|
|
259
258
|
*/
|
|
260
|
-
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* we want to suppress axios internal
|
|
262
|
+
* error handling behaviour to make it
|
|
263
|
+
* consistent with native fetch.
|
|
264
|
+
*/
|
|
265
|
+
{
|
|
266
|
+
validateStatus: status => true
|
|
267
|
+
});
|
|
261
268
|
return data;
|
|
262
269
|
}
|
|
263
270
|
|
|
@@ -456,9 +463,12 @@ function createUserAgent(options) {
|
|
|
456
463
|
* validate some essential http options
|
|
457
464
|
* @param options
|
|
458
465
|
*/
|
|
459
|
-
function
|
|
466
|
+
function validateHttpClientOptions(options) {
|
|
460
467
|
if (!options.host) throw new Error('Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`');
|
|
461
468
|
if (!options.httpClient && typeof options.httpClient !== 'function') throw new Error('An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.');
|
|
469
|
+
if (options.httpClientOptions && Object.prototype.toString.call(options.httpClientOptions) !== '[object Object]') {
|
|
470
|
+
throw new Error('`httpClientOptions` must be an object type');
|
|
471
|
+
}
|
|
462
472
|
}
|
|
463
473
|
|
|
464
474
|
/**
|
|
@@ -617,6 +627,7 @@ function buildRequestForPasswordFlow(options) {
|
|
|
617
627
|
async function executeRequest$1(options) {
|
|
618
628
|
const {
|
|
619
629
|
httpClient,
|
|
630
|
+
httpClientOptions,
|
|
620
631
|
tokenCache,
|
|
621
632
|
userOption,
|
|
622
633
|
tokenCacheObject
|
|
@@ -659,6 +670,7 @@ async function executeRequest$1(options) {
|
|
|
659
670
|
'Content-Length': byteLength(body)
|
|
660
671
|
},
|
|
661
672
|
httpClient,
|
|
673
|
+
httpClientOptions,
|
|
662
674
|
body
|
|
663
675
|
});
|
|
664
676
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
@@ -724,6 +736,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
|
|
|
724
736
|
tokenCache,
|
|
725
737
|
tokenCacheKey,
|
|
726
738
|
httpClient: options.httpClient || fetch$1,
|
|
739
|
+
httpClientOptions: options.httpClientOptions,
|
|
727
740
|
...buildRequestForAnonymousSessionFlow(options),
|
|
728
741
|
userOption: options,
|
|
729
742
|
next
|
|
@@ -778,6 +791,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
|
|
|
778
791
|
tokenCacheKey,
|
|
779
792
|
tokenCacheObject,
|
|
780
793
|
httpClient: options.httpClient || fetch$1,
|
|
794
|
+
httpClientOptions: options.httpClientOptions,
|
|
781
795
|
...buildRequestForClientCredentialsFlow(options),
|
|
782
796
|
next
|
|
783
797
|
};
|
|
@@ -853,6 +867,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
|
|
|
853
867
|
tokenCache,
|
|
854
868
|
tokenCacheKey,
|
|
855
869
|
httpClient: options.httpClient || fetch$1,
|
|
870
|
+
httpClientOptions: options.httpClientOptions,
|
|
856
871
|
...buildRequestForPasswordFlow(options),
|
|
857
872
|
userOption: options,
|
|
858
873
|
next
|
|
@@ -903,6 +918,7 @@ function createAuthMiddlewareForRefreshTokenFlow$1(options) {
|
|
|
903
918
|
request,
|
|
904
919
|
tokenCache,
|
|
905
920
|
httpClient: options.httpClient || fetch,
|
|
921
|
+
httpClientOptions: options.httpClientOptions,
|
|
906
922
|
...buildRequestForRefreshTokenFlow(options),
|
|
907
923
|
next
|
|
908
924
|
};
|
|
@@ -1091,7 +1107,7 @@ async function executeRequest({
|
|
|
1091
1107
|
}
|
|
1092
1108
|
function createHttpMiddleware$1(options) {
|
|
1093
1109
|
// validate response
|
|
1094
|
-
|
|
1110
|
+
validateHttpClientOptions(options);
|
|
1095
1111
|
const {
|
|
1096
1112
|
host,
|
|
1097
1113
|
credentialsMode,
|
|
@@ -1242,7 +1258,7 @@ function createQueueMiddleware$1({
|
|
|
1242
1258
|
|
|
1243
1259
|
var packageJson = {
|
|
1244
1260
|
name: "@commercetools/ts-client",
|
|
1245
|
-
version: "2.1.
|
|
1261
|
+
version: "2.1.2",
|
|
1246
1262
|
engines: {
|
|
1247
1263
|
node: ">=14"
|
|
1248
1264
|
},
|
|
@@ -1529,6 +1545,7 @@ class ClientBuilder {
|
|
|
1529
1545
|
host: oauthUri,
|
|
1530
1546
|
projectKey: projectKey || this.projectKey,
|
|
1531
1547
|
credentials,
|
|
1548
|
+
httpClient: httpClient || fetch$1,
|
|
1532
1549
|
scopes
|
|
1533
1550
|
}).withHttpMiddleware({
|
|
1534
1551
|
host: baseUri,
|
|
@@ -175,11 +175,10 @@ async function executor(request) {
|
|
|
175
175
|
validateRetryCodes(retryCodes);
|
|
176
176
|
async function execute() {
|
|
177
177
|
return httpClient(url, {
|
|
178
|
-
...rest,
|
|
179
178
|
...options,
|
|
179
|
+
...rest,
|
|
180
180
|
headers: {
|
|
181
181
|
...rest.headers,
|
|
182
|
-
...options.headers,
|
|
183
182
|
// axios header encoding
|
|
184
183
|
'Accept-Encoding': 'application/json'
|
|
185
184
|
},
|
|
@@ -266,7 +265,15 @@ async function executor(request) {
|
|
|
266
265
|
* middleware options or from
|
|
267
266
|
* http client config
|
|
268
267
|
*/
|
|
269
|
-
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* we want to suppress axios internal
|
|
271
|
+
* error handling behaviour to make it
|
|
272
|
+
* consistent with native fetch.
|
|
273
|
+
*/
|
|
274
|
+
{
|
|
275
|
+
validateStatus: status => true
|
|
276
|
+
});
|
|
270
277
|
return data;
|
|
271
278
|
}
|
|
272
279
|
|
|
@@ -465,9 +472,12 @@ function createUserAgent(options) {
|
|
|
465
472
|
* validate some essential http options
|
|
466
473
|
* @param options
|
|
467
474
|
*/
|
|
468
|
-
function
|
|
475
|
+
function validateHttpClientOptions(options) {
|
|
469
476
|
if (!options.host) throw new Error('Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`');
|
|
470
477
|
if (!options.httpClient && typeof options.httpClient !== 'function') throw new Error('An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.');
|
|
478
|
+
if (options.httpClientOptions && Object.prototype.toString.call(options.httpClientOptions) !== '[object Object]') {
|
|
479
|
+
throw new Error('`httpClientOptions` must be an object type');
|
|
480
|
+
}
|
|
471
481
|
}
|
|
472
482
|
|
|
473
483
|
/**
|
|
@@ -626,6 +636,7 @@ function buildRequestForPasswordFlow(options) {
|
|
|
626
636
|
async function executeRequest$1(options) {
|
|
627
637
|
const {
|
|
628
638
|
httpClient,
|
|
639
|
+
httpClientOptions,
|
|
629
640
|
tokenCache,
|
|
630
641
|
userOption,
|
|
631
642
|
tokenCacheObject
|
|
@@ -668,6 +679,7 @@ async function executeRequest$1(options) {
|
|
|
668
679
|
'Content-Length': byteLength(body)
|
|
669
680
|
},
|
|
670
681
|
httpClient,
|
|
682
|
+
httpClientOptions,
|
|
671
683
|
body
|
|
672
684
|
});
|
|
673
685
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
@@ -733,6 +745,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
|
|
|
733
745
|
tokenCache,
|
|
734
746
|
tokenCacheKey,
|
|
735
747
|
httpClient: options.httpClient || fetch__default["default"],
|
|
748
|
+
httpClientOptions: options.httpClientOptions,
|
|
736
749
|
...buildRequestForAnonymousSessionFlow(options),
|
|
737
750
|
userOption: options,
|
|
738
751
|
next
|
|
@@ -787,6 +800,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
|
|
|
787
800
|
tokenCacheKey,
|
|
788
801
|
tokenCacheObject,
|
|
789
802
|
httpClient: options.httpClient || fetch__default["default"],
|
|
803
|
+
httpClientOptions: options.httpClientOptions,
|
|
790
804
|
...buildRequestForClientCredentialsFlow(options),
|
|
791
805
|
next
|
|
792
806
|
};
|
|
@@ -862,6 +876,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
|
|
|
862
876
|
tokenCache,
|
|
863
877
|
tokenCacheKey,
|
|
864
878
|
httpClient: options.httpClient || fetch__default["default"],
|
|
879
|
+
httpClientOptions: options.httpClientOptions,
|
|
865
880
|
...buildRequestForPasswordFlow(options),
|
|
866
881
|
userOption: options,
|
|
867
882
|
next
|
|
@@ -912,6 +927,7 @@ function createAuthMiddlewareForRefreshTokenFlow$1(options) {
|
|
|
912
927
|
request,
|
|
913
928
|
tokenCache,
|
|
914
929
|
httpClient: options.httpClient || fetch,
|
|
930
|
+
httpClientOptions: options.httpClientOptions,
|
|
915
931
|
...buildRequestForRefreshTokenFlow(options),
|
|
916
932
|
next
|
|
917
933
|
};
|
|
@@ -1100,7 +1116,7 @@ async function executeRequest({
|
|
|
1100
1116
|
}
|
|
1101
1117
|
function createHttpMiddleware$1(options) {
|
|
1102
1118
|
// validate response
|
|
1103
|
-
|
|
1119
|
+
validateHttpClientOptions(options);
|
|
1104
1120
|
const {
|
|
1105
1121
|
host,
|
|
1106
1122
|
credentialsMode,
|
|
@@ -1251,7 +1267,7 @@ function createQueueMiddleware$1({
|
|
|
1251
1267
|
|
|
1252
1268
|
var packageJson = {
|
|
1253
1269
|
name: "@commercetools/ts-client",
|
|
1254
|
-
version: "2.1.
|
|
1270
|
+
version: "2.1.2",
|
|
1255
1271
|
engines: {
|
|
1256
1272
|
node: ">=14"
|
|
1257
1273
|
},
|
|
@@ -1538,6 +1554,7 @@ class ClientBuilder {
|
|
|
1538
1554
|
host: oauthUri,
|
|
1539
1555
|
projectKey: projectKey || this.projectKey,
|
|
1540
1556
|
credentials,
|
|
1557
|
+
httpClient: httpClient || fetch__default["default"],
|
|
1541
1558
|
scopes
|
|
1542
1559
|
}).withHttpMiddleware({
|
|
1543
1560
|
host: baseUri,
|
|
@@ -175,11 +175,10 @@ async function executor(request) {
|
|
|
175
175
|
validateRetryCodes(retryCodes);
|
|
176
176
|
async function execute() {
|
|
177
177
|
return httpClient(url, {
|
|
178
|
-
...rest,
|
|
179
178
|
...options,
|
|
179
|
+
...rest,
|
|
180
180
|
headers: {
|
|
181
181
|
...rest.headers,
|
|
182
|
-
...options.headers,
|
|
183
182
|
// axios header encoding
|
|
184
183
|
'Accept-Encoding': 'application/json'
|
|
185
184
|
},
|
|
@@ -266,7 +265,15 @@ async function executor(request) {
|
|
|
266
265
|
* middleware options or from
|
|
267
266
|
* http client config
|
|
268
267
|
*/
|
|
269
|
-
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* we want to suppress axios internal
|
|
271
|
+
* error handling behaviour to make it
|
|
272
|
+
* consistent with native fetch.
|
|
273
|
+
*/
|
|
274
|
+
{
|
|
275
|
+
validateStatus: status => true
|
|
276
|
+
});
|
|
270
277
|
return data;
|
|
271
278
|
}
|
|
272
279
|
|
|
@@ -465,9 +472,12 @@ function createUserAgent(options) {
|
|
|
465
472
|
* validate some essential http options
|
|
466
473
|
* @param options
|
|
467
474
|
*/
|
|
468
|
-
function
|
|
475
|
+
function validateHttpClientOptions(options) {
|
|
469
476
|
if (!options.host) throw new Error('Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`');
|
|
470
477
|
if (!options.httpClient && typeof options.httpClient !== 'function') throw new Error('An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.');
|
|
478
|
+
if (options.httpClientOptions && Object.prototype.toString.call(options.httpClientOptions) !== '[object Object]') {
|
|
479
|
+
throw new Error('`httpClientOptions` must be an object type');
|
|
480
|
+
}
|
|
471
481
|
}
|
|
472
482
|
|
|
473
483
|
/**
|
|
@@ -626,6 +636,7 @@ function buildRequestForPasswordFlow(options) {
|
|
|
626
636
|
async function executeRequest$1(options) {
|
|
627
637
|
const {
|
|
628
638
|
httpClient,
|
|
639
|
+
httpClientOptions,
|
|
629
640
|
tokenCache,
|
|
630
641
|
userOption,
|
|
631
642
|
tokenCacheObject
|
|
@@ -668,6 +679,7 @@ async function executeRequest$1(options) {
|
|
|
668
679
|
'Content-Length': byteLength(body)
|
|
669
680
|
},
|
|
670
681
|
httpClient,
|
|
682
|
+
httpClientOptions,
|
|
671
683
|
body
|
|
672
684
|
});
|
|
673
685
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
@@ -733,6 +745,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
|
|
|
733
745
|
tokenCache,
|
|
734
746
|
tokenCacheKey,
|
|
735
747
|
httpClient: options.httpClient || fetch__default["default"],
|
|
748
|
+
httpClientOptions: options.httpClientOptions,
|
|
736
749
|
...buildRequestForAnonymousSessionFlow(options),
|
|
737
750
|
userOption: options,
|
|
738
751
|
next
|
|
@@ -787,6 +800,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
|
|
|
787
800
|
tokenCacheKey,
|
|
788
801
|
tokenCacheObject,
|
|
789
802
|
httpClient: options.httpClient || fetch__default["default"],
|
|
803
|
+
httpClientOptions: options.httpClientOptions,
|
|
790
804
|
...buildRequestForClientCredentialsFlow(options),
|
|
791
805
|
next
|
|
792
806
|
};
|
|
@@ -862,6 +876,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
|
|
|
862
876
|
tokenCache,
|
|
863
877
|
tokenCacheKey,
|
|
864
878
|
httpClient: options.httpClient || fetch__default["default"],
|
|
879
|
+
httpClientOptions: options.httpClientOptions,
|
|
865
880
|
...buildRequestForPasswordFlow(options),
|
|
866
881
|
userOption: options,
|
|
867
882
|
next
|
|
@@ -912,6 +927,7 @@ function createAuthMiddlewareForRefreshTokenFlow$1(options) {
|
|
|
912
927
|
request,
|
|
913
928
|
tokenCache,
|
|
914
929
|
httpClient: options.httpClient || fetch,
|
|
930
|
+
httpClientOptions: options.httpClientOptions,
|
|
915
931
|
...buildRequestForRefreshTokenFlow(options),
|
|
916
932
|
next
|
|
917
933
|
};
|
|
@@ -1100,7 +1116,7 @@ async function executeRequest({
|
|
|
1100
1116
|
}
|
|
1101
1117
|
function createHttpMiddleware$1(options) {
|
|
1102
1118
|
// validate response
|
|
1103
|
-
|
|
1119
|
+
validateHttpClientOptions(options);
|
|
1104
1120
|
const {
|
|
1105
1121
|
host,
|
|
1106
1122
|
credentialsMode,
|
|
@@ -1251,7 +1267,7 @@ function createQueueMiddleware$1({
|
|
|
1251
1267
|
|
|
1252
1268
|
var packageJson = {
|
|
1253
1269
|
name: "@commercetools/ts-client",
|
|
1254
|
-
version: "2.1.
|
|
1270
|
+
version: "2.1.2",
|
|
1255
1271
|
engines: {
|
|
1256
1272
|
node: ">=14"
|
|
1257
1273
|
},
|
|
@@ -1538,6 +1554,7 @@ class ClientBuilder {
|
|
|
1538
1554
|
host: oauthUri,
|
|
1539
1555
|
projectKey: projectKey || this.projectKey,
|
|
1540
1556
|
credentials,
|
|
1557
|
+
httpClient: httpClient || fetch__default["default"],
|
|
1541
1558
|
scopes
|
|
1542
1559
|
}).withHttpMiddleware({
|
|
1543
1560
|
host: baseUri,
|
|
@@ -166,11 +166,10 @@ async function executor(request) {
|
|
|
166
166
|
validateRetryCodes(retryCodes);
|
|
167
167
|
async function execute() {
|
|
168
168
|
return httpClient(url, {
|
|
169
|
-
...rest,
|
|
170
169
|
...options,
|
|
170
|
+
...rest,
|
|
171
171
|
headers: {
|
|
172
172
|
...rest.headers,
|
|
173
|
-
...options.headers,
|
|
174
173
|
// axios header encoding
|
|
175
174
|
'Accept-Encoding': 'application/json'
|
|
176
175
|
},
|
|
@@ -257,7 +256,15 @@ async function executor(request) {
|
|
|
257
256
|
* middleware options or from
|
|
258
257
|
* http client config
|
|
259
258
|
*/
|
|
260
|
-
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* we want to suppress axios internal
|
|
262
|
+
* error handling behaviour to make it
|
|
263
|
+
* consistent with native fetch.
|
|
264
|
+
*/
|
|
265
|
+
{
|
|
266
|
+
validateStatus: status => true
|
|
267
|
+
});
|
|
261
268
|
return data;
|
|
262
269
|
}
|
|
263
270
|
|
|
@@ -456,9 +463,12 @@ function createUserAgent(options) {
|
|
|
456
463
|
* validate some essential http options
|
|
457
464
|
* @param options
|
|
458
465
|
*/
|
|
459
|
-
function
|
|
466
|
+
function validateHttpClientOptions(options) {
|
|
460
467
|
if (!options.host) throw new Error('Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`');
|
|
461
468
|
if (!options.httpClient && typeof options.httpClient !== 'function') throw new Error('An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.');
|
|
469
|
+
if (options.httpClientOptions && Object.prototype.toString.call(options.httpClientOptions) !== '[object Object]') {
|
|
470
|
+
throw new Error('`httpClientOptions` must be an object type');
|
|
471
|
+
}
|
|
462
472
|
}
|
|
463
473
|
|
|
464
474
|
/**
|
|
@@ -617,6 +627,7 @@ function buildRequestForPasswordFlow(options) {
|
|
|
617
627
|
async function executeRequest$1(options) {
|
|
618
628
|
const {
|
|
619
629
|
httpClient,
|
|
630
|
+
httpClientOptions,
|
|
620
631
|
tokenCache,
|
|
621
632
|
userOption,
|
|
622
633
|
tokenCacheObject
|
|
@@ -659,6 +670,7 @@ async function executeRequest$1(options) {
|
|
|
659
670
|
'Content-Length': byteLength(body)
|
|
660
671
|
},
|
|
661
672
|
httpClient,
|
|
673
|
+
httpClientOptions,
|
|
662
674
|
body
|
|
663
675
|
});
|
|
664
676
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
@@ -724,6 +736,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
|
|
|
724
736
|
tokenCache,
|
|
725
737
|
tokenCacheKey,
|
|
726
738
|
httpClient: options.httpClient || fetch$1,
|
|
739
|
+
httpClientOptions: options.httpClientOptions,
|
|
727
740
|
...buildRequestForAnonymousSessionFlow(options),
|
|
728
741
|
userOption: options,
|
|
729
742
|
next
|
|
@@ -778,6 +791,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
|
|
|
778
791
|
tokenCacheKey,
|
|
779
792
|
tokenCacheObject,
|
|
780
793
|
httpClient: options.httpClient || fetch$1,
|
|
794
|
+
httpClientOptions: options.httpClientOptions,
|
|
781
795
|
...buildRequestForClientCredentialsFlow(options),
|
|
782
796
|
next
|
|
783
797
|
};
|
|
@@ -853,6 +867,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
|
|
|
853
867
|
tokenCache,
|
|
854
868
|
tokenCacheKey,
|
|
855
869
|
httpClient: options.httpClient || fetch$1,
|
|
870
|
+
httpClientOptions: options.httpClientOptions,
|
|
856
871
|
...buildRequestForPasswordFlow(options),
|
|
857
872
|
userOption: options,
|
|
858
873
|
next
|
|
@@ -903,6 +918,7 @@ function createAuthMiddlewareForRefreshTokenFlow$1(options) {
|
|
|
903
918
|
request,
|
|
904
919
|
tokenCache,
|
|
905
920
|
httpClient: options.httpClient || fetch,
|
|
921
|
+
httpClientOptions: options.httpClientOptions,
|
|
906
922
|
...buildRequestForRefreshTokenFlow(options),
|
|
907
923
|
next
|
|
908
924
|
};
|
|
@@ -1091,7 +1107,7 @@ async function executeRequest({
|
|
|
1091
1107
|
}
|
|
1092
1108
|
function createHttpMiddleware$1(options) {
|
|
1093
1109
|
// validate response
|
|
1094
|
-
|
|
1110
|
+
validateHttpClientOptions(options);
|
|
1095
1111
|
const {
|
|
1096
1112
|
host,
|
|
1097
1113
|
credentialsMode,
|
|
@@ -1242,7 +1258,7 @@ function createQueueMiddleware$1({
|
|
|
1242
1258
|
|
|
1243
1259
|
var packageJson = {
|
|
1244
1260
|
name: "@commercetools/ts-client",
|
|
1245
|
-
version: "2.1.
|
|
1261
|
+
version: "2.1.2",
|
|
1246
1262
|
engines: {
|
|
1247
1263
|
node: ">=14"
|
|
1248
1264
|
},
|
|
@@ -1529,6 +1545,7 @@ class ClientBuilder {
|
|
|
1529
1545
|
host: oauthUri,
|
|
1530
1546
|
projectKey: projectKey || this.projectKey,
|
|
1531
1547
|
credentials,
|
|
1548
|
+
httpClient: httpClient || fetch$1,
|
|
1532
1549
|
scopes
|
|
1533
1550
|
}).withHttpMiddleware({
|
|
1534
1551
|
host: baseUri,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var window;(window||={})["@commercetools/ts-client"]=(()=>{var Lr=Object.create;var Me=Object.defineProperty;var Hr=Object.getOwnPropertyDescriptor;var Dr=Object.getOwnPropertyNames;var $r=Object.getPrototypeOf,Kr=Object.prototype.hasOwnProperty;var ue=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ne=(t,e)=>{for(var r in e)Me(t,r,{get:e[r],enumerable:!0})},tr=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dr(e))!Kr.call(t,n)&&n!==r&&Me(t,n,{get:()=>e[n],enumerable:!(i=Hr(e,n))||i.enumerable});return t};var le=(t,e,r)=>(r=t!=null?Lr($r(t)):{},tr(e||!t||!t.__esModule?Me(r,"default",{value:t,enumerable:!0}):r,t)),zr=t=>tr(Me({},"__esModule",{value:!0}),t);var ce=ue((Q,ir)=>{"use strict";var Gr=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},L=Gr();ir.exports=Q=L.fetch;L.fetch&&(Q.default=L.fetch.bind(L));Q.Headers=L.Headers;Q.Request=L.Request;Q.Response=L.Response});var sr=ue(Ee=>{"use strict";Ee.byteLength=Jr;Ee.toByteArray=Yr;Ee.fromByteArray=Xr;var T=[],C=[],Qr=typeof Uint8Array<"u"?Uint8Array:Array,_e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(H=0,nr=_e.length;H<nr;++H)T[H]=_e[H],C[_e.charCodeAt(H)]=H;var H,nr;C[45]=62;C[95]=63;function or(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var i=r===e?0:4-r%4;return[r,i]}function Jr(t){var e=or(t),r=e[0],i=e[1];return(r+i)*3/4-i}function Vr(t,e,r){return(e+r)*3/4-r}function Yr(t){var e,r=or(t),i=r[0],n=r[1],o=new Qr(Vr(t,i,n)),s=0,u=n>0?i-4:i,c;for(c=0;c<u;c+=4)e=C[t.charCodeAt(c)]<<18|C[t.charCodeAt(c+1)]<<12|C[t.charCodeAt(c+2)]<<6|C[t.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return n===2&&(e=C[t.charCodeAt(c)]<<2|C[t.charCodeAt(c+1)]>>4,o[s++]=e&255),n===1&&(e=C[t.charCodeAt(c)]<<10|C[t.charCodeAt(c+1)]<<4|C[t.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Wr(t){return T[t>>18&63]+T[t>>12&63]+T[t>>6&63]+T[t&63]}function vr(t,e,r){for(var i,n=[],o=e;o<r;o+=3)i=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),n.push(Wr(i));return n.join("")}function Xr(t){for(var e,r=t.length,i=r%3,n=[],o=16383,s=0,u=r-i;s<u;s+=o)n.push(vr(t,s,s+o>u?u:s+o));return i===1?(e=t[r-1],n.push(T[e>>2]+T[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],n.push(T[e>>10]+T[e>>4&63]+T[e<<2&63]+"=")),n.join("")}});var ar=ue(qe=>{qe.read=function(t,e,r,i,n){var o,s,u=n*8-i-1,c=(1<<u)-1,h=c>>1,l=-7,d=r?n-1:0,p=r?-1:1,w=t[e+d];for(d+=p,o=w&(1<<-l)-1,w>>=-l,l+=u;l>0;o=o*256+t[e+d],d+=p,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=i;l>0;s=s*256+t[e+d],d+=p,l-=8);if(o===0)o=1-h;else{if(o===c)return s?NaN:(w?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-h}return(w?-1:1)*s*Math.pow(2,o-i)};qe.write=function(t,e,r,i,n,o){var s,u,c,h=o*8-n-1,l=(1<<h)-1,d=l>>1,p=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=i?0:o-1,f=i?1:-1,E=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+d>=1?e+=p/c:e+=p*Math.pow(2,1-d),e*c>=2&&(s++,c/=2),s+d>=l?(u=0,s=l):s+d>=1?(u=(e*c-1)*Math.pow(2,n),s=s+d):(u=e*Math.pow(2,d-1)*Math.pow(2,n),s=0));n>=8;t[r+w]=u&255,w+=f,u/=256,n-=8);for(s=s<<n|u,h+=n;h>0;t[r+w]=s&255,w+=f,s/=256,h-=8);t[r+w-f]|=E*128}});var Rr=ue(W=>{"use strict";var je=sr(),V=ar(),ur=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;W.Buffer=a;W.SlowBuffer=nt;W.INSPECT_MAX_BYTES=50;var Ce=2147483647;W.kMaxLength=Ce;a.TYPED_ARRAY_SUPPORT=Zr();!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Zr(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}});Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function O(t){if(t>Ce)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return $e(t)}return hr(t,e,r)}a.poolSize=8192;function hr(t,e,r){if(typeof t=="string")return rt(t,e);if(ArrayBuffer.isView(t))return tt(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(b(t,ArrayBuffer)||t&&b(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(b(t,SharedArrayBuffer)||t&&b(t.buffer,SharedArrayBuffer)))return He(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=t.valueOf&&t.valueOf();if(i!=null&&i!==t)return a.from(i,e,r);let n=it(t);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}a.from=function(t,e,r){return hr(t,e,r)};Object.setPrototypeOf(a.prototype,Uint8Array.prototype);Object.setPrototypeOf(a,Uint8Array);function fr(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function et(t,e,r){return fr(t),t<=0?O(t):e!==void 0?typeof r=="string"?O(t).fill(e,r):O(t).fill(e):O(t)}a.alloc=function(t,e,r){return et(t,e,r)};function $e(t){return fr(t),O(t<0?0:Ke(t)|0)}a.allocUnsafe=function(t){return $e(t)};a.allocUnsafeSlow=function(t){return $e(t)};function rt(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=pr(t,e)|0,i=O(r),n=i.write(t,e);return n!==r&&(i=i.slice(0,n)),i}function Le(t){let e=t.length<0?0:Ke(t.length)|0,r=O(e);for(let i=0;i<e;i+=1)r[i]=t[i]&255;return r}function tt(t){if(b(t,Uint8Array)){let e=new Uint8Array(t);return He(e.buffer,e.byteOffset,e.byteLength)}return Le(t)}function He(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&r===void 0?i=new Uint8Array(t):r===void 0?i=new Uint8Array(t,e):i=new Uint8Array(t,e,r),Object.setPrototypeOf(i,a.prototype),i}function it(t){if(a.isBuffer(t)){let e=Ke(t.length)|0,r=O(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Ge(t.length)?O(0):Le(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Le(t.data)}function Ke(t){if(t>=Ce)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ce.toString(16)+" bytes");return t|0}function nt(t){return+t!=t&&(t=0),a.alloc(+t)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype};a.compare=function(e,r){if(b(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),b(r,Uint8Array)&&(r=a.from(r,r.offset,r.byteLength)),!a.isBuffer(e)||!a.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let i=e.length,n=r.length;for(let o=0,s=Math.min(i,n);o<s;++o)if(e[o]!==r[o]){i=e[o],n=r[o];break}return i<n?-1:n<i?1:0};a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let i;if(r===void 0)for(r=0,i=0;i<e.length;++i)r+=e[i].length;let n=a.allocUnsafe(r),o=0;for(i=0;i<e.length;++i){let s=e[i];if(b(s,Uint8Array))o+s.length>n.length?(a.isBuffer(s)||(s=a.from(s)),s.copy(n,o)):Uint8Array.prototype.set.call(n,s,o);else if(a.isBuffer(s))s.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return n};function pr(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||b(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&r===0)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return De(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ar(t).length;default:if(n)return i?-1:De(t).length;e=(""+e).toLowerCase(),n=!0}}a.byteLength=pr;function ot(t,e,r){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return wt(this,e,r);case"utf8":case"utf-8":return mr(this,e,r);case"ascii":return ft(this,e,r);case"latin1":case"binary":return pt(this,e,r);case"base64":return dt(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mt(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}a.prototype._isBuffer=!0;function D(t,e,r){let i=t[e];t[e]=t[r],t[r]=i}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)D(this,r,r+1);return this};a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)D(this,r,r+3),D(this,r+1,r+2);return this};a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)D(this,r,r+7),D(this,r+1,r+6),D(this,r+2,r+5),D(this,r+3,r+4);return this};a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?mr(this,0,e):ot.apply(this,arguments)};a.prototype.toLocaleString=a.prototype.toString;a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0};a.prototype.inspect=function(){let e="",r=W.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ur&&(a.prototype[ur]=a.prototype.inspect);a.prototype.compare=function(e,r,i,n,o){if(b(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),r<0||i>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=i)return 0;if(n>=o)return-1;if(r>=i)return 1;if(r>>>=0,i>>>=0,n>>>=0,o>>>=0,this===e)return 0;let s=o-n,u=i-r,c=Math.min(s,u),h=this.slice(n,o),l=e.slice(r,i);for(let d=0;d<c;++d)if(h[d]!==l[d]){s=h[d],u=l[d];break}return s<u?-1:u<s?1:0};function wr(t,e,r,i,n){if(t.length===0)return-1;if(typeof r=="string"?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Ge(r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0)if(n)r=0;else return-1;if(typeof e=="string"&&(e=a.from(e,i)),a.isBuffer(e))return e.length===0?-1:lr(t,e,r,i,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):lr(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function lr(t,e,r,i,n){let o=1,s=t.length,u=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,u/=2,r/=2}function c(l,d){return o===1?l[d]:l.readUInt16BE(d*o)}let h;if(n){let l=-1;for(h=r;h<s;h++)if(c(t,h)===c(e,l===-1?0:h-l)){if(l===-1&&(l=h),h-l+1===u)return l*o}else l!==-1&&(h-=h-l),l=-1}else for(r+u>s&&(r=s-u),h=r;h>=0;h--){let l=!0;for(let d=0;d<u;d++)if(c(t,h+d)!==c(e,d)){l=!1;break}if(l)return h}return-1}a.prototype.includes=function(e,r,i){return this.indexOf(e,r,i)!==-1};a.prototype.indexOf=function(e,r,i){return wr(this,e,r,i,!0)};a.prototype.lastIndexOf=function(e,r,i){return wr(this,e,r,i,!1)};function st(t,e,r,i){r=Number(r)||0;let n=t.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;let o=e.length;i>o/2&&(i=o/2);let s;for(s=0;s<i;++s){let u=parseInt(e.substr(s*2,2),16);if(Ge(u))return s;t[r+s]=u}return s}function at(t,e,r,i){return Ae(De(e,t.length-r),t,r,i)}function ut(t,e,r,i){return Ae(Mt(e),t,r,i)}function lt(t,e,r,i){return Ae(Ar(e),t,r,i)}function ct(t,e,r,i){return Ae(Et(e,t.length-r),t,r,i)}a.prototype.write=function(e,r,i,n){if(r===void 0)n="utf8",i=this.length,r=0;else if(i===void 0&&typeof r=="string")n=r,i=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((i===void 0||i>o)&&(i=o),e.length>0&&(i<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return st(this,e,r,i);case"utf8":case"utf-8":return at(this,e,r,i);case"ascii":case"latin1":case"binary":return ut(this,e,r,i);case"base64":return lt(this,e,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ct(this,e,r,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function dt(t,e,r){return e===0&&r===t.length?je.fromByteArray(t):je.fromByteArray(t.slice(e,r))}function mr(t,e,r){r=Math.min(t.length,r);let i=[],n=e;for(;n<r;){let o=t[n],s=null,u=o>239?4:o>223?3:o>191?2:1;if(n+u<=r){let c,h,l,d;switch(u){case 1:o<128&&(s=o);break;case 2:c=t[n+1],(c&192)===128&&(d=(o&31)<<6|c&63,d>127&&(s=d));break;case 3:c=t[n+1],h=t[n+2],(c&192)===128&&(h&192)===128&&(d=(o&15)<<12|(c&63)<<6|h&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=t[n+1],h=t[n+2],l=t[n+3],(c&192)===128&&(h&192)===128&&(l&192)===128&&(d=(o&15)<<18|(c&63)<<12|(h&63)<<6|l&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|s&1023),i.push(s),n+=u}return ht(i)}var cr=4096;function ht(t){let e=t.length;if(e<=cr)return String.fromCharCode.apply(String,t);let r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=cr));return r}function ft(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(t[n]&127);return i}function pt(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function wt(t,e,r){let i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);let n="";for(let o=e;o<r;++o)n+=Ct[t[o]];return n}function mt(t,e,r){let i=t.slice(e,r),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}a.prototype.slice=function(e,r){let i=this.length;e=~~e,r=r===void 0?i:~~r,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),r<e&&(r=e);let n=this.subarray(e,r);return Object.setPrototypeOf(n,a.prototype),n};function m(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,r,i){e=e>>>0,r=r>>>0,i||m(e,r,this.length);let n=this[e],o=1,s=0;for(;++s<r&&(o*=256);)n+=this[e+s]*o;return n};a.prototype.readUintBE=a.prototype.readUIntBE=function(e,r,i){e=e>>>0,r=r>>>0,i||m(e,r,this.length);let n=this[e+--r],o=1;for(;r>0&&(o*=256);)n+=this[e+--r]*o;return n};a.prototype.readUint8=a.prototype.readUInt8=function(e,r){return e=e>>>0,r||m(e,1,this.length),this[e]};a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||m(e,2,this.length),this[e]|this[e+1]<<8};a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||m(e,2,this.length),this[e]<<8|this[e+1]};a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||m(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||m(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};a.prototype.readBigUInt64LE=P(function(e){e=e>>>0,Y(e,"offset");let r=this[e],i=this[e+7];(r===void 0||i===void 0)&&de(e,this.length-8);let n=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});a.prototype.readBigUInt64BE=P(function(e){e=e>>>0,Y(e,"offset");let r=this[e],i=this[e+7];(r===void 0||i===void 0)&&de(e,this.length-8);let n=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});a.prototype.readIntLE=function(e,r,i){e=e>>>0,r=r>>>0,i||m(e,r,this.length);let n=this[e],o=1,s=0;for(;++s<r&&(o*=256);)n+=this[e+s]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*r)),n};a.prototype.readIntBE=function(e,r,i){e=e>>>0,r=r>>>0,i||m(e,r,this.length);let n=r,o=1,s=this[e+--n];for(;n>0&&(o*=256);)s+=this[e+--n]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};a.prototype.readInt8=function(e,r){return e=e>>>0,r||m(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};a.prototype.readInt16LE=function(e,r){e=e>>>0,r||m(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};a.prototype.readInt16BE=function(e,r){e=e>>>0,r||m(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};a.prototype.readInt32LE=function(e,r){return e=e>>>0,r||m(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};a.prototype.readInt32BE=function(e,r){return e=e>>>0,r||m(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};a.prototype.readBigInt64LE=P(function(e){e=e>>>0,Y(e,"offset");let r=this[e],i=this[e+7];(r===void 0||i===void 0)&&de(e,this.length-8);let n=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});a.prototype.readBigInt64BE=P(function(e){e=e>>>0,Y(e,"offset");let r=this[e],i=this[e+7];(r===void 0||i===void 0)&&de(e,this.length-8);let n=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)});a.prototype.readFloatLE=function(e,r){return e=e>>>0,r||m(e,4,this.length),V.read(this,e,!0,23,4)};a.prototype.readFloatBE=function(e,r){return e=e>>>0,r||m(e,4,this.length),V.read(this,e,!1,23,4)};a.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||m(e,8,this.length),V.read(this,e,!0,52,8)};a.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||m(e,8,this.length),V.read(this,e,!1,52,8)};function x(t,e,r,i,n,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,r,i,n){if(e=+e,r=r>>>0,i=i>>>0,!n){let u=Math.pow(2,8*i)-1;x(this,e,r,i,u,0)}let o=1,s=0;for(this[r]=e&255;++s<i&&(o*=256);)this[r+s]=e/o&255;return r+i};a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,r,i,n){if(e=+e,r=r>>>0,i=i>>>0,!n){let u=Math.pow(2,8*i)-1;x(this,e,r,i,u,0)}let o=i-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+i};a.prototype.writeUint8=a.prototype.writeUInt8=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,1,255,0),this[r]=e&255,r+1};a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function yr(t,e,r,i,n){Cr(e,i,n,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function gr(t,e,r,i,n){Cr(e,i,n,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}a.prototype.writeBigUInt64LE=P(function(e,r=0){return yr(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeBigUInt64BE=P(function(e,r=0){return gr(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeIntLE=function(e,r,i,n){if(e=+e,r=r>>>0,!n){let c=Math.pow(2,8*i-1);x(this,e,r,i,c-1,-c)}let o=0,s=1,u=0;for(this[r]=e&255;++o<i&&(s*=256);)e<0&&u===0&&this[r+o-1]!==0&&(u=1),this[r+o]=(e/s>>0)-u&255;return r+i};a.prototype.writeIntBE=function(e,r,i,n){if(e=+e,r=r>>>0,!n){let c=Math.pow(2,8*i-1);x(this,e,r,i,c-1,-c)}let o=i-1,s=1,u=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&u===0&&this[r+o+1]!==0&&(u=1),this[r+o]=(e/s>>0)-u&255;return r+i};a.prototype.writeInt8=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};a.prototype.writeInt16LE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};a.prototype.writeInt16BE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};a.prototype.writeInt32LE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};a.prototype.writeInt32BE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};a.prototype.writeBigInt64LE=P(function(e,r=0){return yr(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});a.prototype.writeBigInt64BE=P(function(e,r=0){return gr(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xr(t,e,r,i,n,o){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Mr(t,e,r,i,n){return e=+e,r=r>>>0,n||xr(t,e,r,4,34028234663852886e22,-34028234663852886e22),V.write(t,e,r,i,23,4),r+4}a.prototype.writeFloatLE=function(e,r,i){return Mr(this,e,r,!0,i)};a.prototype.writeFloatBE=function(e,r,i){return Mr(this,e,r,!1,i)};function Er(t,e,r,i,n){return e=+e,r=r>>>0,n||xr(t,e,r,8,17976931348623157e292,-17976931348623157e292),V.write(t,e,r,i,52,8),r+8}a.prototype.writeDoubleLE=function(e,r,i){return Er(this,e,r,!0,i)};a.prototype.writeDoubleBE=function(e,r,i){return Er(this,e,r,!1,i)};a.prototype.copy=function(e,r,i,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),r>=e.length&&(r=e.length),r||(r=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-r<n-i&&(n=e.length-r+i);let o=n-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,i,n):Uint8Array.prototype.set.call(e,this.subarray(i,n),r),o};a.prototype.fill=function(e,r,i,n){if(typeof e=="string"){if(typeof r=="string"?(n=r,r=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){let s=e.charCodeAt(0);(n==="utf8"&&s<128||n==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<i)throw new RangeError("Out of range index");if(i<=r)return this;r=r>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<i;++o)this[o]=e;else{let s=a.isBuffer(e)?e:a.from(e,n),u=s.length;if(u===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<i-r;++o)this[o+r]=s[o%u]}return this};var J={};function ze(t,e,r){J[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}ze("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ze("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);ze("ERR_OUT_OF_RANGE",function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=dr(String(r)):typeof r=="bigint"&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=dr(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i},RangeError);function dr(t){let e="",r=t.length,i=t[0]==="-"?1:0;for(;r>=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function yt(t,e,r){Y(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&de(e,t.length-(r+1))}function Cr(t,e,r,i,n,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",u;throw o>3?e===0||e===BigInt(0)?u=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:u=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:u=`>= ${e}${s} and <= ${r}${s}`,new J.ERR_OUT_OF_RANGE("value",u,t)}yt(i,n,o)}function Y(t,e){if(typeof t!="number")throw new J.ERR_INVALID_ARG_TYPE(e,"number",t)}function de(t,e,r){throw Math.floor(t)!==t?(Y(t,r),new J.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var gt=/[^+/0-9A-Za-z-_]/g;function xt(t){if(t=t.split("=")[0],t=t.trim().replace(gt,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function De(t,e){e=e||1/0;let r,i=t.length,n=null,o=[];for(let s=0;s<i;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),n=r;continue}r=(n-55296<<10|r-56320)+65536}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Mt(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Et(t,e){let r,i,n,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),i=r>>8,n=r%256,o.push(n),o.push(i);return o}function Ar(t){return je.toByteArray(xt(t))}function Ae(t,e,r,i){let n;for(n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function b(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Ge(t){return t!==t}var Ct=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let i=r*16;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function P(t){return typeof BigInt>"u"?At:t}function At(){throw new Error("BigInt not supported")}});var Pr=ue((kn,Oe)=>{"use strict";var{AbortController:Sr,AbortSignal:Gt}=typeof self<"u"?self:typeof window<"u"?window:void 0;Oe.exports=Sr;Oe.exports.AbortSignal=Gt;Oe.exports.default=Sr});var oi={};Ne(oi,{ClientBuilder:()=>oe,Process:()=>Se,createAuthMiddlewareForAnonymousSessionFlow:()=>ee,createAuthMiddlewareForClientCredentialsFlow:()=>re,createAuthMiddlewareForExistingTokenFlow:()=>te,createAuthMiddlewareForPasswordFlow:()=>ie,createAuthMiddlewareForRefreshTokenFlow:()=>ne,createClient:()=>K,createConcurrentModificationMiddleware:()=>fe,createCorrelationIdMiddleware:()=>pe,createHttpMiddleware:()=>we,createLoggerMiddleware:()=>me,createQueueMiddleware:()=>ye,createUserAgentMiddleware:()=>ge});var z=le(ce());var rr={};Ne(rr,{createAuthMiddlewareForAnonymousSessionFlow:()=>ee,createAuthMiddlewareForClientCredentialsFlow:()=>re,createAuthMiddlewareForExistingTokenFlow:()=>te,createAuthMiddlewareForPasswordFlow:()=>ie,createAuthMiddlewareForRefreshTokenFlow:()=>ne,createConcurrentModificationMiddleware:()=>fe,createCorrelationIdMiddleware:()=>pe,createErrorMiddleware:()=>er,createHttpMiddleware:()=>we,createLoggerMiddleware:()=>me,createQueueMiddleware:()=>ye,createUserAgentMiddleware:()=>ge});var Ur=le(ce());var Rt=Rr().Buffer;function v(t){return t&&(typeof t=="string"||t instanceof Uint8Array)?Rt.byteLength(t).toString():t&&typeof t=="object"?new TextEncoder().encode(JSON.stringify(t)).length.toString():"0"}var A={};Ne(A,{CONCURRENCT_REQUEST:()=>Tt,CTP_API_URL:()=>bt,CTP_AUTH_URL:()=>It,DEFAULT_HEADERS:()=>Qe,HEADERS_CONTENT_TYPES:()=>Bt});var Bt=["application/json","application/graphql"],Tt=20,bt="https://api.europe-west1.gcp.commercetools.com",It="https://auth.europe-west1.gcp.commercetools.com",Qe=["content-type","access-control-allow-origin","access-control-allow-headers","access-control-allow-methods","access-control-expose-headers","access-control-max-ag","x-correlation-id","server-timing","date","server","transfer-encoding","access-control-max-age","content-encoding","x-envoy-upstream-service-time","via","alt-svc","connection"];function S(t,e,r={}){this.status=this.statusCode=this.code=t,this.message=e,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function Br(...t){S.call(this,0,...t)}function Tr(...t){S.call(this,...t)}function Ft(...t){S.call(this,400,...t)}function Ut(...t){S.call(this,401,...t)}function kt(...t){S.call(this,403,...t)}function Ot(...t){S.call(this,404,...t)}function St(...t){S.call(this,409,...t)}function Pt(...t){S.call(this,500,...t)}function Nt(...t){S.call(this,503,...t)}function Je(t){switch(t){case 0:return Br;case 400:return Ft;case 401:return Ut;case 403:return kt;case 404:return Ot;case 409:return St;case 500:return Pt;case 503:return Nt;default:return}}function _t({statusCode:t,message:e,...r}){let i=e||"Unexpected non-JSON error response";t===404&&(i=`URI not found: ${r.originalRequest?.uri||r.uri}`);let n=Je(t);return n?new n(i,r):new Tr(t,i,r)}var X=_t;function qt(t,e){return[503,...t].includes(e?.status||e?.statusCode)}async function jt(t,e){async function r(){return await t({...e,headers:{...e.headers}})}return r().catch(i=>Promise.reject(i))}async function Z(t){let{url:e,httpClient:r,...i}=t;return await jt(async o=>{let{enableRetry:s,retryConfig:u,abortController:c}=i,{retryCodes:h=[],maxDelay:l=1/0,maxRetries:d=3,backoff:p=!0,retryDelay:w=200,retryOnAbort:f=!0}=u||{},E,k,g=0;Ve(h);async function R(){return r(e,{...i,...o,headers:{...i.headers,...o.headers,"Accept-Encoding":"application/json"},...i.body?{data:i.body}:{},withCredentials:o.credentialsMode==="include"})}async function B(){let _=async(j,se)=>{let ae={};try{if(ae=await R(),ae.status>399&&qt(j,ae))return{_response:ae,shouldRetry:!0}}catch(Pe){if(Pe.name.includes("AbortError")&&se)return{_response:Pe,shouldRetry:!0};throw Pe}return{_response:ae,shouldRetry:!1}},q=f||!c||!c.signal,{_response:xe,shouldRetry:G}=await _(h,q);for(;s&&G&&g<d;){g++;let j=await _(h,q);xe=j._response,G=j.shouldRetry;let se=Re({retryCount:g,retryDelay:w,maxRetries:d,backoff:p,maxDelay:l});await Be(se)}return xe}let y=await B();try{y.text&&typeof y.text=="function"?(E=await y.text()||y[Object.getOwnPropertySymbols(y)[1]],k=JSON.parse(E)):k=y.data||y}catch{k=E}return{data:k,retryCount:g,statusCode:y.status||y.statusCode||k.statusCode,headers:y.headers}},{})}function Te(){return("1000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(parseInt(t)^Math.floor(Math.random()*256)&15>>parseInt(t)/4).toString(16))}function Lt(t){return Qe.reduce((e,r)=>{let i=t[r]?t[r]:typeof t.get=="function"?t.get(r):null;return i&&(e[r]=i),e},{})}function I(t){if(!t)return null;if(t.raw&&typeof t.raw=="function")return t.raw();if(!t.forEach)return Lt(t);let e={};return t.forEach((r,i)=>e[i]=r)}function he(t){return t!=null&&t.constructor!=null&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function $(t){let e=Object.assign({},t);return e?.headers&&(e.headers.Authorization&&(e.headers.Authorization="Bearer ********"),e.headers.authorization&&(e.headers.authorization="Bearer ********")),e}function M(t,e){return{...e,headers:{...e.headers,Authorization:`Bearer ${t}`}}}var Ye=["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 Re({retryCount:t,retryDelay:e,backoff:r,maxDelay:i}){return r&&t!==0?Math.min(Math.round((Math.random()+1)*e*2**t),i):e}Math.min(Math.round((Math.random()+1)*200*2**10),1/0);function Be(t){return new Promise(e=>{setTimeout(e,t)})}function F(t){if(!t?.credentials?.clientId||!t.projectKey||!t.host)throw new Error("Missing required options.");return{clientId:t.credentials.clientId,host:t.host,projectKey:t.projectKey}}function be(t){return Date.now()+t*1e3-5*60*1e3}function U(t){let e=t;return{get:r=>e,set:(r,i)=>{e=r}}}function br(t){return typeof t<"u"&&t!==null}function Ht(t){return br(t)?typeof t=="string"?t:Object.fromEntries(Object.entries(t).filter(([e,r])=>![null,void 0,""].includes(r))):""}function Dt(t){let e={},r=new URLSearchParams(t);for(let i of r.keys())r.getAll(i).length>1?e[i]=r.getAll(i):e[i]=r.get(i);return e}function $t(t){if(t=Ht(t),!t)return"";let e=new URLSearchParams(t);for(let[r,i]of Object.entries(t))Array.isArray(i)&&(e.delete(r),i.filter(br).forEach(n=>e.append(r,n)));return e.toString()}function We(t,e=Dt){return e(t)}function Ie(t,e=$t){return e(t)}var Kt=()=>typeof window<"u"&&window.document&&window.document.nodeType===9;function zt(){if(Kt())return window.navigator.userAgent;let t=process?.version.slice(1)||"unknow",e=`(${process.platform}; ${process.arch})`;return`node.js/${t} ${e}`}function Fe(t){let e=null,r=null;if(!t)throw new Error("Missing required option `name`");let i=t.version?`${t.name}/${t.version}`:t.name;t.libraryName&&!t.libraryVersion?e=t.libraryName:t.libraryName&&t.libraryVersion&&(e=`${t.libraryName}/${t.libraryVersion}`),t.contactUrl&&!t.contactEmail?r=`(+${t.contactUrl})`:!t.contactUrl&&t.contactEmail?r=`(+${t.contactEmail})`:t.contactUrl&&t.contactEmail&&(r=`(+${t.contactUrl}; +${t.contactEmail})`);let n=zt(),o=t.customAgent||"";return[i,n,e,r,o].filter(Boolean).join(" ")}function ve(t){if(!t.host)throw new Error("Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`");if(!t.httpClient&&typeof t.httpClient!="function")throw new Error("An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.")}function Ve(t){if(!Array.isArray(t))throw new Error("`retryCodes` option must be an array of retry status (error) codes and/or messages.")}function Xe(t){if(!t)throw new Error("Missing required options");if(t.middlewares&&!Array.isArray(t.middlewares))throw new Error("Middlewares should be an array");if(!t.middlewares||!Array.isArray(t.middlewares)||!t.middlewares.length)throw new Error("You need to provide at least one middleware")}function Ue(t,e,r={allowedMethods:Ye}){if(!e)throw new Error(`The "${t}" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(typeof e.uri!="string")throw new Error(`The "${t}" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(!r.allowedMethods.includes(e.method))throw new Error(`The "${t}" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`)}function Ze(t){if(!t)throw new Error("Missing required options");if(!t.host)throw new Error("Missing required option (host)");if(!t.projectKey)throw new Error("Missing required option (projectKey)");if(!t.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:r}=t.credentials||{};if(!(e&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let i=t.scopes?t.scopes.join(" "):void 0,n=btoa(`${e}:${r}`),o=t.oauthUri||"/oauth/token",s=t.host.replace(/\/$/,"")+o,u=`grant_type=client_credentials${i?`&scope=${i}`:""}`;return{url:s,body:u,basicAuth:n}}function Ir(t){if(!t)throw new Error("Missing required options");if(!t.projectKey)throw new Error("Missing required option (projectKey)");let e=t.projectKey;t.oauthUri=t.oauthUri||`/oauth/${e}/anonymous/token`;let r=Ze(t);return t.credentials.anonymousId&&(r.body+=`&anonymous_id=${t.credentials.anonymousId}`),{...r}}function ke(t){if(!t)throw new Error("Missing required options");if(!t.host)throw new Error("Missing required option (host)");if(!t.projectKey)throw new Error("Missing required option (projectKey)");if(!t.credentials)throw new Error("Missing required option (credentials)");if(!t.refreshToken)throw new Error("Missing required option (refreshToken)");let{clientId:e,clientSecret:r}=t.credentials;if(!(e&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let i=btoa(`${e}:${r}`),n=t.oauthUri||"/oauth/token",o=t.host.replace(/\/$/,"")+n,s=`grant_type=refresh_token&refresh_token=${encodeURIComponent(t.refreshToken)}`;return{basicAuth:i,url:o,body:s}}function Fr(t){if(!t)throw new Error("Missing required options");if(!t.host)throw new Error("Missing required option (host)");if(!t.projectKey)throw new Error("Missing required option (projectKey)");if(!t.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:r,user:i}=t.credentials,n=t.projectKey;if(!(e&&r&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");let{username:o,password:s}=i;if(!(o&&s))throw new Error("Missing required user credentials (username, password)");let u=(t.scopes||[]).join(" "),c=u?`&scope=${u}`:"",h=btoa(`${e}:${r}`),l=t.oauthUri||`/oauth/${n}/customers/token`,d=t.host.replace(/\/$/,"")+l,p=`grant_type=password&username=${encodeURIComponent(o)}&password=${encodeURIComponent(s)}${c}`;return{basicAuth:h,url:d,body:p}}async function N(t){let{httpClient:e,tokenCache:r,userOption:i,tokenCacheObject:n}=t,o=t.url,s=t.body,u=t.basicAuth;if(!e||typeof e!="function")throw new Error("an `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(n&&n.refreshToken&&(!n.token||n.token&&Date.now()>n.expirationTime)){if(!i)throw new Error("Missing required options.");let h={...ke({...i,refreshToken:n.refreshToken})};o=h.url,s=h.body,u=h.basicAuth}let c;try{if(c=await Z({url:o,method:"POST",headers:{Authorization:`Basic ${u}`,"Content-Type":"application/x-www-form-urlencoded","Content-Length":v(s)},httpClient:e,body:s}),c.statusCode>=200&&c.statusCode<300){let{access_token:h,expires_in:l,refresh_token:d}=c?.data,p=be(l);return r.set({token:h,expirationTime:p,refreshToken:d}),Promise.resolve(!0)}throw X({code:c.data.error,statusCode:c.data.statusCode,message:c.data.message,error:c.data.errors})}catch(h){throw h}}function ee(t){let e=t.tokenCache||U({token:"",expirationTime:-1}),r,i=null,n=F(t);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(r=e.get(n),r&&r.token&&Date.now()<r.expirationTime)return o(M(r.token,s));let u={request:s,tokenCache:e,tokenCacheKey:n,httpClient:t.httpClient||Ur.default,...Ir(t),userOption:t,next:o};return i?await i:(i=N(u),await i,i=null),r=e.get(n),o(M(r.token,s))}}var kr=le(ce());function re(t){let e=t.tokenCache||U({token:"",expirationTime:-1}),r,i=null,n=F(t);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(r=e.get(n),r&&r.token&&Date.now()<r.expirationTime)return o(M(r.token,s));let u={request:s,tokenCache:e,tokenCacheKey:n,tokenCacheObject:r,httpClient:t.httpClient||kr.default,...Ze(t),next:o};return i?await i:(i=N(u),await i,i=null),r=e.get(n),o(M(r.token,s))}}function te(t,e){return r=>async i=>{if(typeof t!="string")throw new Error("authorization must be a string");let n=e?.force===void 0?!0:e.force;if(!t||i.headers&&(i.headers.Authorization||i.headers.authorization)&&n===!1)return r(i);let o={...i,headers:{...i.headers,Authorization:t}};return r(o)}}var Or=le(ce());function ie(t){let e=t.tokenCache||U({token:"",expirationTime:-1}),r,i=null,n=F(t);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(r=e.get(n),r&&r.token&&Date.now()<r.expirationTime)return o(M(r.token,s));let u={request:s,tokenCache:e,tokenCacheKey:n,httpClient:t.httpClient||Or.default,...Fr(t),userOption:t,next:o};return i?await i:(i=N(u),await i,i=null),r=e.get(n),o(M(r.token,s))}}function ne(t){let e=t.tokenCache||U({token:"",tokenCacheKey:null}),r,i=null,n=F(t);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(r=e.get(n),r&&r.token&&Date.now()<r.expirationTime)return o(M(r.token,s));let u={request:s,tokenCache:e,httpClient:t.httpClient||fetch,...ke(t),next:o};return i?await i:(i=N(u),await i,i=null),r=e.get(n),o(M(r.token,s))}}function fe(t){return e=>async r=>{let i=await e(r);if(i.statusCode==409){let n=i.error.body?.errors?.[0]?.currentVersion;if(n)return t&&typeof t=="function"?r.body=await t(n,r,i):r.body=typeof r.body=="string"?{...JSON.parse(r.body),version:n}:{...r.body,version:n},e(r)}return i}}function pe(t){return e=>r=>{let i={...r,headers:{...r.headers,"X-Correlation-ID":t.generate&&typeof t.generate=="function"?t.generate():Te()}};return e(i)}}function er(t){return e=>async r=>{let i=await e(r);if(i.error){let{error:n}=i;return{...i,statusCode:n.statusCode||0,headers:n.headers||I({}),error:{...n,body:n.data||n}}}return i}}var Nr=le(Pr());async function Qt({url:t,httpClient:e,clientOptions:r}){let i,{timeout:n,request:o,abortController:s,maskSensitiveHeaderData:u,includeRequestInErrorResponse:c,includeResponseHeaders:h}=r;try{n&&(i=setTimeout(()=>{s.abort()},n));let l=await Z({url:t,...r,httpClient:e,method:r.method,...r.body?{body:r.body}:{}});if(h||(l.headers=null),l.statusCode>=200&&l.statusCode<300)return r.method=="HEAD"?{body:null,statusCode:l.statusCode,retryCount:l.retryCount,headers:I(l.headers)}:{body:l.data,statusCode:l.statusCode,retryCount:l.retryCount,headers:I(l.headers)};let d=X({message:l?.data?.message||l?.message,statusCode:l.statusCode||l?.data?.statusCode,headers:I(l.headers),method:r.method,body:l.data,retryCount:l.retryCount,...c?{originalRequest:u?$(o):o}:{uri:o.uri}});return{body:l.data,code:l.statusCode,statusCode:l.statusCode,headers:I(l.headers),error:d}}catch(l){let d=h?I(l.response?.headers):null,p=l.response?.status||l.response?.data0||0,w=l.response?.data?.message,f=X({statusCode:p,code:p,status:p,message:w||l.message,headers:d,body:l.response?.data||l,error:l.response?.data,...c?{originalRequest:u?$(o):o}:{uri:o.uri}});throw{body:f,error:f}}finally{clearTimeout(i)}}function we(t){ve(t);let{host:e,credentialsMode:r,httpClient:i,timeout:n,enableRetry:o,retryConfig:s,getAbortController:u,includeOriginalRequest:c,includeRequestInErrorResponse:h=!0,includeResponseHeaders:l=!0,maskSensitiveHeaderData:d,httpClientOptions:p}=t;return w=>async f=>{let E;(n||u)&&(E=(u?u():null)||new Nr.default);let k=e.replace(/\/$/,"")+f.uri,g={...f.headers};Object.prototype.hasOwnProperty.call(g,"Content-Type")||Object.prototype.hasOwnProperty.call(g,"content-type")||(g["Content-Type"]="application/json"),g["Content-Type"]===null&&delete g["Content-Type"];let R=A.HEADERS_CONTENT_TYPES.indexOf(g["Content-Type"])>-1&&typeof f.body=="string"||he(f.body)?f.body:JSON.stringify(f.body||void 0);R&&(typeof R=="string"||he(R))&&(g["Content-Length"]=v(R));let B={enableRetry:o,retryConfig:s,request:f,method:f.method,headers:g,includeRequestInErrorResponse:h,maskSensitiveHeaderData:d,includeResponseHeaders:l,...p};r&&(B.credentialsMode=r),E&&(B.signal=E.signal),n&&(B.timeout=n,B.abortController=E),R&&(B.body=R);let y=await Qt({url:k,clientOptions:B,httpClient:i}),_={...f,includeOriginalRequest:c,maskSensitiveHeaderData:d,response:y};return w(_)}}function me(t){return e=>async r=>{let i=await e(r),n=Object.assign({},i),{loggerFn:o=console.log}=t||{};return o&&typeof o=="function"&&o(i),n}}function ye({concurrency:t=20}){let e=0,r=[],i=()=>0>=t?Promise.resolve():new Promise(o=>{let s=()=>{e<t?(e++,o()):r.push(s)};s()}),n=()=>{if(e--,r.length>0){let o=r.shift();o&&o()}};return o=>s=>i().then(()=>{let u={...s,resolve(c){s.resolve(c),n()},reject(c){s.reject(c),n()}};return o(u).finally(()=>{n()})})}var _r={name:"@commercetools/ts-client",version:"2.1.1",engines:{node:">=14"},description:"commercetools Composable Commerce TypeScript SDK client.",keywords:["commercetools","composable commerce","sdk","typescript","client","middleware","http","oauth","auth"],homepage:"https://github.com/commercetools/commercetools-sdk-typescript",license:"MIT",directories:{lib:"lib",test:"test"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/commercetools/commercetools-sdk-typescript.git"},bugs:{url:"https://github.com/commercetools/commercetools-sdk-typescript/issues"},dependencies:{"abort-controller":"3.0.0",buffer:"^6.0.3","node-fetch":"^2.6.1"},files:["dist","CHANGELOG.md"],author:"Chukwuemeka Ajima <meeky.ae@gmail.com>",main:"dist/commercetools-ts-client.cjs.js",module:"dist/commercetools-ts-client.esm.js",browser:{"./dist/commercetools-ts-client.cjs.js":"./dist/commercetools-ts-client.browser.cjs.js","./dist/commercetools-ts-client.esm.js":"./dist/commercetools-ts-client.browser.esm.js"},devDependencies:{"common-tags":"1.8.2",dotenv:"16.4.5",jest:"29.7.0",nock:"12.0.3","organize-imports-cli":"0.10.0"},scripts:{organize_imports:"find src -type f -name '*.ts' | xargs organize-imports-cli",postbuild:"yarn organize_imports",post_process_generate:"yarn organize_imports",docs:"typedoc --out docs"}};function ge(t){return e=>async r=>{let i=Fe({...t,name:`${t.name?t.name+"/":""}commercetools-sdk-javascript-v3/${_r.version}`}),n={...r,headers:{...r.headers,"User-Agent":i}};return e(n)}}function Vt({middlewares:t}){return t.length===1?t[0]:t.slice().reduce((r,i)=>(...n)=>r(i.apply(null,n)))}var qr;function Se(t,e,r){if(Ue("process",t,{allowedMethods:["GET"]}),typeof e!="function")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');let i={total:Number.POSITIVE_INFINITY,accumulate:!0,...r};return new Promise((n,o)=>{let s,u="";if(t&&t.uri){let[w,f]=t.uri.split("?");s=w,u=f}let h={limit:20,...{...We(u)}},l=i.total,d=!1,p=async(w,f=[])=>{let E=h.limit<l?h.limit:l,k=Ie({...h,limit:E}),g={sort:"id asc",withTotal:!1,...w?{where:`id > "${w}"`}:{}},R=Ie(g),B={...t,uri:`${s}?${R}&${k}`};try{let y=await K(qr).execute(B),{results:_,count:q}=y?.body||{};if(!q&&d)return n(f||[]);let xe=await Promise.resolve(e(y)),G;if(d=!0,i.accumulate&&(G=f.concat(xe||[])),l-=q,q<h.limit||!l)return n(G||[]);let j=_[q-1],se=j&&j.id;p(se,G)}catch(y){o(y)}};p()})}function K(t){qr=t,Xe(t);let e=!1,r={async resolve(n){let{response:o,includeOriginalRequest:s,maskSensitiveHeaderData:u,...c}=n,{retryCount:h,...l}=o;return e=u,{body:null,error:null,reject:n.reject,resolve:n.resolve,...l,...s?{originalRequest:c}:{},...o?.retryCount?{retryCount:o.retryCount}:{}}}},i=Vt(t)(r.resolve);return{process:Se,execute(n){return Ue("exec",n),new Promise(async(o,s)=>{try{let u=await i({reject:s,resolve:o,...n});if(u.error)return s(u.error);u.originalRequest&&e&&(u.originalRequest=$(u.originalRequest)),o(u)}catch(u){s(u)}})}}}var{createAuthMiddlewareForPasswordFlow:Yt,createAuthMiddlewareForAnonymousSessionFlow:Wt,createAuthMiddlewareForClientCredentialsFlow:vt,createAuthMiddlewareForRefreshTokenFlow:Xt,createAuthMiddlewareForExistingTokenFlow:Zt,createCorrelationIdMiddleware:ei,createHttpMiddleware:ri,createLoggerMiddleware:ti,createQueueMiddleware:ii,createUserAgentMiddleware:jr,createConcurrentModificationMiddleware:ni}=rr,oe=class{projectKey;authMiddleware;httpMiddleware;userAgentMiddleware;correlationIdMiddleware;loggerMiddleware;queueMiddleware;concurrentMiddleware;telemetryMiddleware;beforeMiddleware;afterMiddleware;middlewares=[];constructor(){this.userAgentMiddleware=jr({})}withProjectKey(e){return this.projectKey=e,this}defaultClient(e,r,i,n,o,s){return this.withClientCredentialsFlow({host:i,projectKey:n||this.projectKey,credentials:r,scopes:o}).withHttpMiddleware({host:e,httpClient:s||z.default})}withAuthMiddleware(e){return this.authMiddleware=e,this}withMiddleware(e){return this.middlewares.push(e),this}withClientCredentialsFlow(e){return this.withAuthMiddleware(vt({host:e.host||A.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},oauthUri:e.oauthUri||null,scopes:e.scopes,httpClient:e.httpClient||z.default,...e}))}withPasswordFlow(e){return this.withAuthMiddleware(Yt({host:e.host||A.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,user:{username:e.credentials.user.username||null,password:e.credentials.user.password||null}},httpClient:e.httpClient||z.default,...e}))}withAnonymousSessionFlow(e){return this.withAuthMiddleware(Wt({host:e.host||A.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,anonymousId:e.credentials.anonymousId||null},httpClient:e.httpClient||z.default,...e}))}withRefreshTokenFlow(e){return this.withAuthMiddleware(Xt({host:e.host||A.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},httpClient:e.httpClient||z.default,refreshToken:e.refreshToken||null,...e}))}withExistingTokenFlow(e,r){return this.withAuthMiddleware(Zt(e,{force:r.force||!0,...r}))}withHttpMiddleware(e){return this.httpMiddleware=ri({host:e.host||A.CTP_API_URL,httpClient:e.httpClient||z.default,...e}),this}withUserAgentMiddleware(e){return this.userAgentMiddleware=jr(e),this}withQueueMiddleware(e){return this.queueMiddleware=ii({concurrency:e.concurrency||A.CONCURRENCT_REQUEST,...e}),this}withLoggerMiddleware(e){return this.loggerMiddleware=ti(e),this}withCorrelationIdMiddleware(e){return this.correlationIdMiddleware=ei({generate:e?.generate,...e}),this}withConcurrentModificationMiddleware(e){return this.concurrentMiddleware=ni(e?.concurrentModificationHandlerFn),this}withTelemetryMiddleware(e){let{createTelemetryMiddleware:r,...i}=e;return this.withUserAgentMiddleware({customAgent:i?.userAgent||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=r(i),this}withBeforeExecutionMiddleware(e){let{middleware:r,...i}=e||{};return this.beforeMiddleware=e.middleware(i),this}withAfterExecutionMiddleware(e){let{middleware:r,...i}=e||{};return this.afterMiddleware=e.middleware(i),this}build(){let 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.loggerMiddleware&&e.push(this.loggerMiddleware),this.concurrentMiddleware&&e.push(this.concurrentMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.afterMiddleware&&e.push(this.afterMiddleware),K({middlewares:e})}};return zr(oi);})();
|
|
1
|
+
var window;(window||={})["@commercetools/ts-client"]=(()=>{var Lt=Object.create;var Me=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var $t=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty;var le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ne=(r,e)=>{for(var t in e)Me(r,t,{get:e[t],enumerable:!0})},rt=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dt(e))!Kt.call(r,n)&&n!==t&&Me(r,n,{get:()=>e[n],enumerable:!(i=Ht(e,n))||i.enumerable});return r};var ue=(r,e,t)=>(t=r!=null?Lt($t(r)):{},rt(e||!r||!r.__esModule?Me(t,"default",{value:r,enumerable:!0}):t,r)),zt=r=>rt(Me({},"__esModule",{value:!0}),r);var ce=le((Q,it)=>{"use strict";var Gt=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},H=Gt();it.exports=Q=H.fetch;H.fetch&&(Q.default=H.fetch.bind(H));Q.Headers=H.Headers;Q.Request=H.Request;Q.Response=H.Response});var st=le(Ce=>{"use strict";Ce.byteLength=Jt;Ce.toByteArray=Yt;Ce.fromByteArray=Xt;var T=[],E=[],Qt=typeof Uint8Array<"u"?Uint8Array:Array,_e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(D=0,nt=_e.length;D<nt;++D)T[D]=_e[D],E[_e.charCodeAt(D)]=D;var D,nt;E[45]=62;E[95]=63;function ot(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function Jt(r){var e=ot(r),t=e[0],i=e[1];return(t+i)*3/4-i}function Vt(r,e,t){return(e+t)*3/4-t}function Yt(r){var e,t=ot(r),i=t[0],n=t[1],o=new Qt(Vt(r,i,n)),s=0,l=n>0?i-4:i,c;for(c=0;c<l;c+=4)e=E[r.charCodeAt(c)]<<18|E[r.charCodeAt(c+1)]<<12|E[r.charCodeAt(c+2)]<<6|E[r.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return n===2&&(e=E[r.charCodeAt(c)]<<2|E[r.charCodeAt(c+1)]>>4,o[s++]=e&255),n===1&&(e=E[r.charCodeAt(c)]<<10|E[r.charCodeAt(c+1)]<<4|E[r.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function vt(r){return T[r>>18&63]+T[r>>12&63]+T[r>>6&63]+T[r&63]}function Wt(r,e,t){for(var i,n=[],o=e;o<t;o+=3)i=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),n.push(vt(i));return n.join("")}function Xt(r){for(var e,t=r.length,i=t%3,n=[],o=16383,s=0,l=t-i;s<l;s+=o)n.push(Wt(r,s,s+o>l?l:s+o));return i===1?(e=r[t-1],n.push(T[e>>2]+T[e<<4&63]+"==")):i===2&&(e=(r[t-2]<<8)+r[t-1],n.push(T[e>>10]+T[e>>4&63]+T[e<<2&63]+"=")),n.join("")}});var at=le(je=>{je.read=function(r,e,t,i,n){var o,s,l=n*8-i-1,c=(1<<l)-1,h=c>>1,u=-7,d=t?n-1:0,w=t?-1:1,p=r[e+d];for(d+=w,o=p&(1<<-u)-1,p>>=-u,u+=l;u>0;o=o*256+r[e+d],d+=w,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=i;u>0;s=s*256+r[e+d],d+=w,u-=8);if(o===0)o=1-h;else{if(o===c)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-h}return(p?-1:1)*s*Math.pow(2,o-i)};je.write=function(r,e,t,i,n,o){var s,l,c,h=o*8-n-1,u=(1<<h)-1,d=u>>1,w=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:o-1,f=i?1:-1,C=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+d>=1?e+=w/c:e+=w*Math.pow(2,1-d),e*c>=2&&(s++,c/=2),s+d>=u?(l=0,s=u):s+d>=1?(l=(e*c-1)*Math.pow(2,n),s=s+d):(l=e*Math.pow(2,d-1)*Math.pow(2,n),s=0));n>=8;r[t+p]=l&255,p+=f,l/=256,n-=8);for(s=s<<n|l,h+=n;h>0;r[t+p]=s&255,p+=f,s/=256,h-=8);r[t+p-f]|=C*128}});var Rt=le(v=>{"use strict";var qe=st(),V=at(),lt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;v.Buffer=a;v.SlowBuffer=nr;v.INSPECT_MAX_BYTES=50;var Ee=2147483647;v.kMaxLength=Ee;a.TYPED_ARRAY_SUPPORT=Zt();!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Zt(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}});Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function O(r){if(r>Ee)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,a.prototype),e}function a(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return $e(r)}return ht(r,e,t)}a.poolSize=8192;function ht(r,e,t){if(typeof r=="string")return tr(r,e);if(ArrayBuffer.isView(r))return rr(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(b(r,ArrayBuffer)||r&&b(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(b(r,SharedArrayBuffer)||r&&b(r.buffer,SharedArrayBuffer)))return He(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return a.from(i,e,t);let n=ir(r);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return a.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}a.from=function(r,e,t){return ht(r,e,t)};Object.setPrototypeOf(a.prototype,Uint8Array.prototype);Object.setPrototypeOf(a,Uint8Array);function pt(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function er(r,e,t){return pt(r),r<=0?O(r):e!==void 0?typeof t=="string"?O(r).fill(e,t):O(r).fill(e):O(r)}a.alloc=function(r,e,t){return er(r,e,t)};function $e(r){return pt(r),O(r<0?0:Ke(r)|0)}a.allocUnsafe=function(r){return $e(r)};a.allocUnsafeSlow=function(r){return $e(r)};function tr(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=ft(r,e)|0,i=O(t),n=i.write(r,e);return n!==t&&(i=i.slice(0,n)),i}function Le(r){let e=r.length<0?0:Ke(r.length)|0,t=O(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function rr(r){if(b(r,Uint8Array)){let e=new Uint8Array(r);return He(e.buffer,e.byteOffset,e.byteLength)}return Le(r)}function He(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,a.prototype),i}function ir(r){if(a.isBuffer(r)){let e=Ke(r.length)|0,t=O(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Ge(r.length)?O(0):Le(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Le(r.data)}function Ke(r){if(r>=Ee)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ee.toString(16)+" bytes");return r|0}function nr(r){return+r!=r&&(r=0),a.alloc(+r)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype};a.compare=function(e,t){if(b(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),b(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,n=t.length;for(let o=0,s=Math.min(i,n);o<s;++o)if(e[o]!==t[o]){i=e[o],n=t[o];break}return i<n?-1:n<i?1:0};a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let n=a.allocUnsafe(t),o=0;for(i=0;i<e.length;++i){let s=e[i];if(b(s,Uint8Array))o+s.length>n.length?(a.isBuffer(s)||(s=a.from(s)),s.copy(n,o)):Uint8Array.prototype.set.call(n,s,o);else if(a.isBuffer(s))s.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return n};function ft(r,e){if(a.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||b(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return De(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return At(r).length;default:if(n)return i?-1:De(r).length;e=(""+e).toLowerCase(),n=!0}}a.byteLength=ft;function or(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return wr(this,e,t);case"utf8":case"utf-8":return mt(this,e,t);case"ascii":return pr(this,e,t);case"latin1":case"binary":return fr(this,e,t);case"base64":return dr(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mr(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}a.prototype._isBuffer=!0;function $(r,e,t){let i=r[e];r[e]=r[t],r[t]=i}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)$(this,t,t+1);return this};a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)$(this,t,t+3),$(this,t+1,t+2);return this};a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)$(this,t,t+7),$(this,t+1,t+6),$(this,t+2,t+5),$(this,t+3,t+4);return this};a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?mt(this,0,e):or.apply(this,arguments)};a.prototype.toLocaleString=a.prototype.toString;a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0};a.prototype.inspect=function(){let e="",t=v.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};lt&&(a.prototype[lt]=a.prototype.inspect);a.prototype.compare=function(e,t,i,n,o){if(b(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||i>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=i)return 0;if(n>=o)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,o>>>=0,this===e)return 0;let s=o-n,l=i-t,c=Math.min(s,l),h=this.slice(n,o),u=e.slice(t,i);for(let d=0;d<c;++d)if(h[d]!==u[d]){s=h[d],l=u[d];break}return s<l?-1:l<s?1:0};function wt(r,e,t,i,n){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Ge(t)&&(t=n?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(n)return-1;t=r.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=a.from(e,i)),a.isBuffer(e))return e.length===0?-1:ut(r,e,t,i,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ut(r,[e],t,i,n);throw new TypeError("val must be string, number or Buffer")}function ut(r,e,t,i,n){let o=1,s=r.length,l=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,l/=2,t/=2}function c(u,d){return o===1?u[d]:u.readUInt16BE(d*o)}let h;if(n){let u=-1;for(h=t;h<s;h++)if(c(r,h)===c(e,u===-1?0:h-u)){if(u===-1&&(u=h),h-u+1===l)return u*o}else u!==-1&&(h-=h-u),u=-1}else for(t+l>s&&(t=s-l),h=t;h>=0;h--){let u=!0;for(let d=0;d<l;d++)if(c(r,h+d)!==c(e,d)){u=!1;break}if(u)return h}return-1}a.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1};a.prototype.indexOf=function(e,t,i){return wt(this,e,t,i,!0)};a.prototype.lastIndexOf=function(e,t,i){return wt(this,e,t,i,!1)};function sr(r,e,t,i){t=Number(t)||0;let n=r.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;let o=e.length;i>o/2&&(i=o/2);let s;for(s=0;s<i;++s){let l=parseInt(e.substr(s*2,2),16);if(Ge(l))return s;r[t+s]=l}return s}function ar(r,e,t,i){return Ae(De(e,r.length-t),r,t,i)}function lr(r,e,t,i){return Ae(Mr(e),r,t,i)}function ur(r,e,t,i){return Ae(At(e),r,t,i)}function cr(r,e,t,i){return Ae(Cr(e,r.length-t),r,t,i)}a.prototype.write=function(e,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((i===void 0||i>o)&&(i=o),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return sr(this,e,t,i);case"utf8":case"utf-8":return ar(this,e,t,i);case"ascii":case"latin1":case"binary":return lr(this,e,t,i);case"base64":return ur(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cr(this,e,t,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function dr(r,e,t){return e===0&&t===r.length?qe.fromByteArray(r):qe.fromByteArray(r.slice(e,t))}function mt(r,e,t){t=Math.min(r.length,t);let i=[],n=e;for(;n<t;){let o=r[n],s=null,l=o>239?4:o>223?3:o>191?2:1;if(n+l<=t){let c,h,u,d;switch(l){case 1:o<128&&(s=o);break;case 2:c=r[n+1],(c&192)===128&&(d=(o&31)<<6|c&63,d>127&&(s=d));break;case 3:c=r[n+1],h=r[n+2],(c&192)===128&&(h&192)===128&&(d=(o&15)<<12|(c&63)<<6|h&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=r[n+1],h=r[n+2],u=r[n+3],(c&192)===128&&(h&192)===128&&(u&192)===128&&(d=(o&15)<<18|(c&63)<<12|(h&63)<<6|u&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,l=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|s&1023),i.push(s),n+=l}return hr(i)}var ct=4096;function hr(r){let e=r.length;if(e<=ct)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=ct));return t}function pr(r,e,t){let i="";t=Math.min(r.length,t);for(let n=e;n<t;++n)i+=String.fromCharCode(r[n]&127);return i}function fr(r,e,t){let i="";t=Math.min(r.length,t);for(let n=e;n<t;++n)i+=String.fromCharCode(r[n]);return i}function wr(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let n="";for(let o=e;o<t;++o)n+=Er[r[o]];return n}function mr(r,e,t){let i=r.slice(e,t),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}a.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let n=this.subarray(e,t);return Object.setPrototypeOf(n,a.prototype),n};function m(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e],o=1,s=0;for(;++s<t&&(o*=256);)n+=this[e+s]*o;return n};a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e+--t],o=1;for(;t>0&&(o*=256);)n+=this[e+--t]*o;return n};a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||m(e,1,this.length),this[e]};a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||m(e,2,this.length),this[e]|this[e+1]<<8};a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||m(e,2,this.length),this[e]<<8|this[e+1]};a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||m(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};a.prototype.readBigUInt64LE=P(function(e){e=e>>>0,Y(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let n=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});a.prototype.readBigUInt64BE=P(function(e){e=e>>>0,Y(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let n=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});a.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e],o=1,s=0;for(;++s<t&&(o*=256);)n+=this[e+s]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};a.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=t,o=1,s=this[e+--n];for(;n>0&&(o*=256);)s+=this[e+--n]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s};a.prototype.readInt8=function(e,t){return e=e>>>0,t||m(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};a.prototype.readInt16LE=function(e,t){e=e>>>0,t||m(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};a.prototype.readInt16BE=function(e,t){e=e>>>0,t||m(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};a.prototype.readBigInt64LE=P(function(e){e=e>>>0,Y(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let n=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});a.prototype.readBigInt64BE=P(function(e){e=e>>>0,Y(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let n=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)});a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||m(e,4,this.length),V.read(this,e,!0,23,4)};a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||m(e,4,this.length),V.read(this,e,!1,23,4)};a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||m(e,8,this.length),V.read(this,e,!0,52,8)};a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||m(e,8,this.length),V.read(this,e,!1,52,8)};function x(r,e,t,i,n,o){if(!a.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){let l=Math.pow(2,8*i)-1;x(this,e,t,i,l,0)}let o=1,s=0;for(this[t]=e&255;++s<i&&(o*=256);)this[t+s]=e/o&255;return t+i};a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){let l=Math.pow(2,8*i)-1;x(this,e,t,i,l,0)}let o=i-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+i};a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,1,255,0),this[t]=e&255,t+1};a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function yt(r,e,t,i,n){Et(e,i,n,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function gt(r,e,t,i,n){Et(e,i,n,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}a.prototype.writeBigUInt64LE=P(function(e,t=0){return yt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeBigUInt64BE=P(function(e,t=0){return gt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t=t>>>0,!n){let c=Math.pow(2,8*i-1);x(this,e,t,i,c-1,-c)}let o=0,s=1,l=0;for(this[t]=e&255;++o<i&&(s*=256);)e<0&&l===0&&this[t+o-1]!==0&&(l=1),this[t+o]=(e/s>>0)-l&255;return t+i};a.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t=t>>>0,!n){let c=Math.pow(2,8*i-1);x(this,e,t,i,c-1,-c)}let o=i-1,s=1,l=0;for(this[t+o]=e&255;--o>=0&&(s*=256);)e<0&&l===0&&this[t+o+1]!==0&&(l=1),this[t+o]=(e/s>>0)-l&255;return t+i};a.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};a.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};a.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};a.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};a.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||x(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};a.prototype.writeBigInt64LE=P(function(e,t=0){return yt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});a.prototype.writeBigInt64BE=P(function(e,t=0){return gt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xt(r,e,t,i,n,o){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Mt(r,e,t,i,n){return e=+e,t=t>>>0,n||xt(r,e,t,4,34028234663852886e22,-34028234663852886e22),V.write(r,e,t,i,23,4),t+4}a.prototype.writeFloatLE=function(e,t,i){return Mt(this,e,t,!0,i)};a.prototype.writeFloatBE=function(e,t,i){return Mt(this,e,t,!1,i)};function Ct(r,e,t,i,n){return e=+e,t=t>>>0,n||xt(r,e,t,8,17976931348623157e292,-17976931348623157e292),V.write(r,e,t,i,52,8),t+8}a.prototype.writeDoubleLE=function(e,t,i){return Ct(this,e,t,!0,i)};a.prototype.writeDoubleBE=function(e,t,i){return Ct(this,e,t,!1,i)};a.prototype.copy=function(e,t,i,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);let o=n-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(e,this.subarray(i,n),t),o};a.prototype.fill=function(e,t,i,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){let s=e.charCodeAt(0);(n==="utf8"&&s<128||n==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<i;++o)this[o]=e;else{let s=a.isBuffer(e)?e:a.from(e,n),l=s.length;if(l===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=s[o%l]}return this};var J={};function ze(r,e,t){J[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ze("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ze("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);ze("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=dt(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=dt(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i},RangeError);function dt(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function yr(r,e,t){Y(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&de(e,r.length-(t+1))}function Et(r,e,t,i,n,o){if(r>t||r<e){let s=typeof e=="bigint"?"n":"",l;throw o>3?e===0||e===BigInt(0)?l=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:l=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:l=`>= ${e}${s} and <= ${t}${s}`,new J.ERR_OUT_OF_RANGE("value",l,r)}yr(i,n,o)}function Y(r,e){if(typeof r!="number")throw new J.ERR_INVALID_ARG_TYPE(e,"number",r)}function de(r,e,t){throw Math.floor(r)!==r?(Y(r,t),new J.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var gr=/[^+/0-9A-Za-z-_]/g;function xr(r){if(r=r.split("=")[0],r=r.trim().replace(gr,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function De(r,e){e=e||1/0;let t,i=r.length,n=null,o=[];for(let s=0;s<i;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function Mr(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Cr(r,e){let t,i,n,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),i=t>>8,n=t%256,o.push(n),o.push(i);return o}function At(r){return qe.toByteArray(xr(r))}function Ae(r,e,t,i){let n;for(n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function b(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Ge(r){return r!==r}var Er=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let n=0;n<16;++n)e[i+n]=r[t]+r[n]}return e}();function P(r){return typeof BigInt>"u"?Ar:r}function Ar(){throw new Error("BigInt not supported")}});var Pt=le((kn,Oe)=>{"use strict";var{AbortController:St,AbortSignal:Gr}=typeof self<"u"?self:typeof window<"u"?window:void 0;Oe.exports=St;Oe.exports.AbortSignal=Gr;Oe.exports.default=St});var oi={};Ne(oi,{ClientBuilder:()=>oe,Process:()=>Se,createAuthMiddlewareForAnonymousSessionFlow:()=>ee,createAuthMiddlewareForClientCredentialsFlow:()=>te,createAuthMiddlewareForExistingTokenFlow:()=>re,createAuthMiddlewareForPasswordFlow:()=>ie,createAuthMiddlewareForRefreshTokenFlow:()=>ne,createClient:()=>z,createConcurrentModificationMiddleware:()=>pe,createCorrelationIdMiddleware:()=>fe,createHttpMiddleware:()=>we,createLoggerMiddleware:()=>me,createQueueMiddleware:()=>ye,createUserAgentMiddleware:()=>ge});var _=ue(ce());var tt={};Ne(tt,{createAuthMiddlewareForAnonymousSessionFlow:()=>ee,createAuthMiddlewareForClientCredentialsFlow:()=>te,createAuthMiddlewareForExistingTokenFlow:()=>re,createAuthMiddlewareForPasswordFlow:()=>ie,createAuthMiddlewareForRefreshTokenFlow:()=>ne,createConcurrentModificationMiddleware:()=>pe,createCorrelationIdMiddleware:()=>fe,createErrorMiddleware:()=>et,createHttpMiddleware:()=>we,createLoggerMiddleware:()=>me,createQueueMiddleware:()=>ye,createUserAgentMiddleware:()=>ge});var Ut=ue(ce());var Rr=Rt().Buffer;function W(r){return r&&(typeof r=="string"||r instanceof Uint8Array)?Rr.byteLength(r).toString():r&&typeof r=="object"?new TextEncoder().encode(JSON.stringify(r)).length.toString():"0"}var A={};Ne(A,{CONCURRENCT_REQUEST:()=>Tr,CTP_API_URL:()=>br,CTP_AUTH_URL:()=>Ir,DEFAULT_HEADERS:()=>Qe,HEADERS_CONTENT_TYPES:()=>Br});var Br=["application/json","application/graphql"],Tr=20,br="https://api.europe-west1.gcp.commercetools.com",Ir="https://auth.europe-west1.gcp.commercetools.com",Qe=["content-type","access-control-allow-origin","access-control-allow-headers","access-control-allow-methods","access-control-expose-headers","access-control-max-ag","x-correlation-id","server-timing","date","server","transfer-encoding","access-control-max-age","content-encoding","x-envoy-upstream-service-time","via","alt-svc","connection"];function S(r,e,t={}){this.status=this.statusCode=this.code=r,this.message=e,Object.assign(this,t),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function Bt(...r){S.call(this,0,...r)}function Tt(...r){S.call(this,...r)}function Fr(...r){S.call(this,400,...r)}function Ur(...r){S.call(this,401,...r)}function kr(...r){S.call(this,403,...r)}function Or(...r){S.call(this,404,...r)}function Sr(...r){S.call(this,409,...r)}function Pr(...r){S.call(this,500,...r)}function Nr(...r){S.call(this,503,...r)}function Je(r){switch(r){case 0:return Bt;case 400:return Fr;case 401:return Ur;case 403:return kr;case 404:return Or;case 409:return Sr;case 500:return Pr;case 503:return Nr;default:return}}function _r({statusCode:r,message:e,...t}){let i=e||"Unexpected non-JSON error response";r===404&&(i=`URI not found: ${t.originalRequest?.uri||t.uri}`);let n=Je(r);return n?new n(i,t):new Tt(r,i,t)}var X=_r;function jr(r,e){return[503,...r].includes(e?.status||e?.statusCode)}async function qr(r,e){async function t(){return await r({...e,headers:{...e.headers}})}return t().catch(i=>Promise.reject(i))}async function Z(r){let{url:e,httpClient:t,...i}=r;return await qr(async o=>{let{enableRetry:s,retryConfig:l,abortController:c}=i,{retryCodes:h=[],maxDelay:u=1/0,maxRetries:d=3,backoff:w=!0,retryDelay:p=200,retryOnAbort:f=!0}=l||{},C,k,g=0;Ve(h);async function R(){return t(e,{...o,...i,headers:{...i.headers,"Accept-Encoding":"application/json"},...i.body?{data:i.body}:{},withCredentials:o.credentialsMode==="include"})}async function B(){let j=async(L,se)=>{let ae={};try{if(ae=await R(),ae.status>399&&jr(L,ae))return{_response:ae,shouldRetry:!0}}catch(Pe){if(Pe.name.includes("AbortError")&&se)return{_response:Pe,shouldRetry:!0};throw Pe}return{_response:ae,shouldRetry:!1}},q=f||!c||!c.signal,{_response:xe,shouldRetry:G}=await j(h,q);for(;s&&G&&g<d;){g++;let L=await j(h,q);xe=L._response,G=L.shouldRetry;let se=Re({retryCount:g,retryDelay:p,maxRetries:d,backoff:w,maxDelay:u});await Be(se)}return xe}let y=await B();try{y.text&&typeof y.text=="function"?(C=await y.text()||y[Object.getOwnPropertySymbols(y)[1]],k=JSON.parse(C)):k=y.data||y}catch{k=C}return{data:k,retryCount:g,statusCode:y.status||y.statusCode||k.statusCode,headers:y.headers}},{validateStatus:o=>!0})}function Te(){return("1000000-1000-4000-8000"+-1e11).replace(/[018]/g,r=>(parseInt(r)^Math.floor(Math.random()*256)&15>>parseInt(r)/4).toString(16))}function Lr(r){return Qe.reduce((e,t)=>{let i=r[t]?r[t]:typeof r.get=="function"?r.get(t):null;return i&&(e[t]=i),e},{})}function I(r){if(!r)return null;if(r.raw&&typeof r.raw=="function")return r.raw();if(!r.forEach)return Lr(r);let e={};return r.forEach((t,i)=>e[i]=t)}function he(r){return r!=null&&r.constructor!=null&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function K(r){let e=Object.assign({},r);return e?.headers&&(e.headers.Authorization&&(e.headers.Authorization="Bearer ********"),e.headers.authorization&&(e.headers.authorization="Bearer ********")),e}function M(r,e){return{...e,headers:{...e.headers,Authorization:`Bearer ${r}`}}}var Ye=["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 Re({retryCount:r,retryDelay:e,backoff:t,maxDelay:i}){return t&&r!==0?Math.min(Math.round((Math.random()+1)*e*2**r),i):e}Math.min(Math.round((Math.random()+1)*200*2**10),1/0);function Be(r){return new Promise(e=>{setTimeout(e,r)})}function F(r){if(!r?.credentials?.clientId||!r.projectKey||!r.host)throw new Error("Missing required options.");return{clientId:r.credentials.clientId,host:r.host,projectKey:r.projectKey}}function be(r){return Date.now()+r*1e3-5*60*1e3}function U(r){let e=r;return{get:t=>e,set:(t,i)=>{e=t}}}function bt(r){return typeof r<"u"&&r!==null}function Hr(r){return bt(r)?typeof r=="string"?r:Object.fromEntries(Object.entries(r).filter(([e,t])=>![null,void 0,""].includes(t))):""}function Dr(r){let e={},t=new URLSearchParams(r);for(let i of t.keys())t.getAll(i).length>1?e[i]=t.getAll(i):e[i]=t.get(i);return e}function $r(r){if(r=Hr(r),!r)return"";let e=new URLSearchParams(r);for(let[t,i]of Object.entries(r))Array.isArray(i)&&(e.delete(t),i.filter(bt).forEach(n=>e.append(t,n)));return e.toString()}function ve(r,e=Dr){return e(r)}function Ie(r,e=$r){return e(r)}var Kr=()=>typeof window<"u"&&window.document&&window.document.nodeType===9;function zr(){if(Kr())return window.navigator.userAgent;let r=process?.version.slice(1)||"unknow",e=`(${process.platform}; ${process.arch})`;return`node.js/${r} ${e}`}function Fe(r){let e=null,t=null;if(!r)throw new Error("Missing required option `name`");let i=r.version?`${r.name}/${r.version}`:r.name;r.libraryName&&!r.libraryVersion?e=r.libraryName:r.libraryName&&r.libraryVersion&&(e=`${r.libraryName}/${r.libraryVersion}`),r.contactUrl&&!r.contactEmail?t=`(+${r.contactUrl})`:!r.contactUrl&&r.contactEmail?t=`(+${r.contactEmail})`:r.contactUrl&&r.contactEmail&&(t=`(+${r.contactUrl}; +${r.contactEmail})`);let n=zr(),o=r.customAgent||"";return[i,n,e,t,o].filter(Boolean).join(" ")}function We(r){if(!r.host)throw new Error("Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`");if(!r.httpClient&&typeof r.httpClient!="function")throw new Error("An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(r.httpClientOptions&&Object.prototype.toString.call(r.httpClientOptions)!=="[object Object]")throw new Error("`httpClientOptions` must be an object type")}function Ve(r){if(!Array.isArray(r))throw new Error("`retryCodes` option must be an array of retry status (error) codes and/or messages.")}function Xe(r){if(!r)throw new Error("Missing required options");if(r.middlewares&&!Array.isArray(r.middlewares))throw new Error("Middlewares should be an array");if(!r.middlewares||!Array.isArray(r.middlewares)||!r.middlewares.length)throw new Error("You need to provide at least one middleware")}function Ue(r,e,t={allowedMethods:Ye}){if(!e)throw new Error(`The "${r}" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(typeof e.uri!="string")throw new Error(`The "${r}" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(!t.allowedMethods.includes(e.method))throw new Error(`The "${r}" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`)}function Ze(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:t}=r.credentials||{};if(!(e&&t))throw new Error("Missing required credentials (clientId, clientSecret)");let i=r.scopes?r.scopes.join(" "):void 0,n=btoa(`${e}:${t}`),o=r.oauthUri||"/oauth/token",s=r.host.replace(/\/$/,"")+o,l=`grant_type=client_credentials${i?`&scope=${i}`:""}`;return{url:s,body:l,basicAuth:n}}function It(r){if(!r)throw new Error("Missing required options");if(!r.projectKey)throw new Error("Missing required option (projectKey)");let e=r.projectKey;r.oauthUri=r.oauthUri||`/oauth/${e}/anonymous/token`;let t=Ze(r);return r.credentials.anonymousId&&(t.body+=`&anonymous_id=${r.credentials.anonymousId}`),{...t}}function ke(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");if(!r.refreshToken)throw new Error("Missing required option (refreshToken)");let{clientId:e,clientSecret:t}=r.credentials;if(!(e&&t))throw new Error("Missing required credentials (clientId, clientSecret)");let i=btoa(`${e}:${t}`),n=r.oauthUri||"/oauth/token",o=r.host.replace(/\/$/,"")+n,s=`grant_type=refresh_token&refresh_token=${encodeURIComponent(r.refreshToken)}`;return{basicAuth:i,url:o,body:s}}function Ft(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:t,user:i}=r.credentials,n=r.projectKey;if(!(e&&t&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");let{username:o,password:s}=i;if(!(o&&s))throw new Error("Missing required user credentials (username, password)");let l=(r.scopes||[]).join(" "),c=l?`&scope=${l}`:"",h=btoa(`${e}:${t}`),u=r.oauthUri||`/oauth/${n}/customers/token`,d=r.host.replace(/\/$/,"")+u,w=`grant_type=password&username=${encodeURIComponent(o)}&password=${encodeURIComponent(s)}${c}`;return{basicAuth:h,url:d,body:w}}async function N(r){let{httpClient:e,httpClientOptions:t,tokenCache:i,userOption:n,tokenCacheObject:o}=r,s=r.url,l=r.body,c=r.basicAuth;if(!e||typeof e!="function")throw new Error("an `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(o&&o.refreshToken&&(!o.token||o.token&&Date.now()>o.expirationTime)){if(!n)throw new Error("Missing required options.");let u={...ke({...n,refreshToken:o.refreshToken})};s=u.url,l=u.body,c=u.basicAuth}let h;try{if(h=await Z({url:s,method:"POST",headers:{Authorization:`Basic ${c}`,"Content-Type":"application/x-www-form-urlencoded","Content-Length":W(l)},httpClient:e,httpClientOptions:t,body:l}),h.statusCode>=200&&h.statusCode<300){let{access_token:u,expires_in:d,refresh_token:w}=h?.data,p=be(d);return i.set({token:u,expirationTime:p,refreshToken:w}),Promise.resolve(!0)}throw X({code:h.data.error,statusCode:h.data.statusCode,message:h.data.message,error:h.data.errors})}catch(u){throw u}}function ee(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(M(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,httpClient:r.httpClient||Ut.default,httpClientOptions:r.httpClientOptions,...It(r),userOption:r,next:o};return i?await i:(i=N(l),await i,i=null),t=e.get(n),o(M(t.token,s))}}var kt=ue(ce());function te(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(M(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,tokenCacheObject:t,httpClient:r.httpClient||kt.default,httpClientOptions:r.httpClientOptions,...Ze(r),next:o};return i?await i:(i=N(l),await i,i=null),t=e.get(n),o(M(t.token,s))}}function re(r,e){return t=>async i=>{if(typeof r!="string")throw new Error("authorization must be a string");let n=e?.force===void 0?!0:e.force;if(!r||i.headers&&(i.headers.Authorization||i.headers.authorization)&&n===!1)return t(i);let o={...i,headers:{...i.headers,Authorization:r}};return t(o)}}var Ot=ue(ce());function ie(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(M(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,httpClient:r.httpClient||Ot.default,httpClientOptions:r.httpClientOptions,...Ft(r),userOption:r,next:o};return i?await i:(i=N(l),await i,i=null),t=e.get(n),o(M(t.token,s))}}function ne(r){let e=r.tokenCache||U({token:"",tokenCacheKey:null}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(M(t.token,s));let l={request:s,tokenCache:e,httpClient:r.httpClient||fetch,httpClientOptions:r.httpClientOptions,...ke(r),next:o};return i?await i:(i=N(l),await i,i=null),t=e.get(n),o(M(t.token,s))}}function pe(r){return e=>async t=>{let i=await e(t);if(i.statusCode==409){let n=i.error.body?.errors?.[0]?.currentVersion;if(n)return r&&typeof r=="function"?t.body=await r(n,t,i):t.body=typeof t.body=="string"?{...JSON.parse(t.body),version:n}:{...t.body,version:n},e(t)}return i}}function fe(r){return e=>t=>{let i={...t,headers:{...t.headers,"X-Correlation-ID":r.generate&&typeof r.generate=="function"?r.generate():Te()}};return e(i)}}function et(r){return e=>async t=>{let i=await e(t);if(i.error){let{error:n}=i;return{...i,statusCode:n.statusCode||0,headers:n.headers||I({}),error:{...n,body:n.data||n}}}return i}}var Nt=ue(Pt());async function Qr({url:r,httpClient:e,clientOptions:t}){let i,{timeout:n,request:o,abortController:s,maskSensitiveHeaderData:l,includeRequestInErrorResponse:c,includeResponseHeaders:h}=t;try{n&&(i=setTimeout(()=>{s.abort()},n));let u=await Z({url:r,...t,httpClient:e,method:t.method,...t.body?{body:t.body}:{}});if(h||(u.headers=null),u.statusCode>=200&&u.statusCode<300)return t.method=="HEAD"?{body:null,statusCode:u.statusCode,retryCount:u.retryCount,headers:I(u.headers)}:{body:u.data,statusCode:u.statusCode,retryCount:u.retryCount,headers:I(u.headers)};let d=X({message:u?.data?.message||u?.message,statusCode:u.statusCode||u?.data?.statusCode,headers:I(u.headers),method:t.method,body:u.data,retryCount:u.retryCount,...c?{originalRequest:l?K(o):o}:{uri:o.uri}});return{body:u.data,code:u.statusCode,statusCode:u.statusCode,headers:I(u.headers),error:d}}catch(u){let d=h?I(u.response?.headers):null,w=u.response?.status||u.response?.data0||0,p=u.response?.data?.message,f=X({statusCode:w,code:w,status:w,message:p||u.message,headers:d,body:u.response?.data||u,error:u.response?.data,...c?{originalRequest:l?K(o):o}:{uri:o.uri}});throw{body:f,error:f}}finally{clearTimeout(i)}}function we(r){We(r);let{host:e,credentialsMode:t,httpClient:i,timeout:n,enableRetry:o,retryConfig:s,getAbortController:l,includeOriginalRequest:c,includeRequestInErrorResponse:h=!0,includeResponseHeaders:u=!0,maskSensitiveHeaderData:d,httpClientOptions:w}=r;return p=>async f=>{let C;(n||l)&&(C=(l?l():null)||new Nt.default);let k=e.replace(/\/$/,"")+f.uri,g={...f.headers};Object.prototype.hasOwnProperty.call(g,"Content-Type")||Object.prototype.hasOwnProperty.call(g,"content-type")||(g["Content-Type"]="application/json"),g["Content-Type"]===null&&delete g["Content-Type"];let R=A.HEADERS_CONTENT_TYPES.indexOf(g["Content-Type"])>-1&&typeof f.body=="string"||he(f.body)?f.body:JSON.stringify(f.body||void 0);R&&(typeof R=="string"||he(R))&&(g["Content-Length"]=W(R));let B={enableRetry:o,retryConfig:s,request:f,method:f.method,headers:g,includeRequestInErrorResponse:h,maskSensitiveHeaderData:d,includeResponseHeaders:u,...w};t&&(B.credentialsMode=t),C&&(B.signal=C.signal),n&&(B.timeout=n,B.abortController=C),R&&(B.body=R);let y=await Qr({url:k,clientOptions:B,httpClient:i}),j={...f,includeOriginalRequest:c,maskSensitiveHeaderData:d,response:y};return p(j)}}function me(r){return e=>async t=>{let i=await e(t),n=Object.assign({},i),{loggerFn:o=console.log}=r||{};return o&&typeof o=="function"&&o(i),n}}function ye({concurrency:r=20}){let e=0,t=[],i=()=>0>=r?Promise.resolve():new Promise(o=>{let s=()=>{e<r?(e++,o()):t.push(s)};s()}),n=()=>{if(e--,t.length>0){let o=t.shift();o&&o()}};return o=>s=>i().then(()=>{let l={...s,resolve(c){s.resolve(c),n()},reject(c){s.reject(c),n()}};return o(l).finally(()=>{n()})})}var _t={name:"@commercetools/ts-client",version:"2.1.2",engines:{node:">=14"},description:"commercetools Composable Commerce TypeScript SDK client.",keywords:["commercetools","composable commerce","sdk","typescript","client","middleware","http","oauth","auth"],homepage:"https://github.com/commercetools/commercetools-sdk-typescript",license:"MIT",directories:{lib:"lib",test:"test"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/commercetools/commercetools-sdk-typescript.git"},bugs:{url:"https://github.com/commercetools/commercetools-sdk-typescript/issues"},dependencies:{"abort-controller":"3.0.0",buffer:"^6.0.3","node-fetch":"^2.6.1"},files:["dist","CHANGELOG.md"],author:"Chukwuemeka Ajima <meeky.ae@gmail.com>",main:"dist/commercetools-ts-client.cjs.js",module:"dist/commercetools-ts-client.esm.js",browser:{"./dist/commercetools-ts-client.cjs.js":"./dist/commercetools-ts-client.browser.cjs.js","./dist/commercetools-ts-client.esm.js":"./dist/commercetools-ts-client.browser.esm.js"},devDependencies:{"common-tags":"1.8.2",dotenv:"16.4.5",jest:"29.7.0",nock:"12.0.3","organize-imports-cli":"0.10.0"},scripts:{organize_imports:"find src -type f -name '*.ts' | xargs organize-imports-cli",postbuild:"yarn organize_imports",post_process_generate:"yarn organize_imports",docs:"typedoc --out docs"}};function ge(r){return e=>async t=>{let i=Fe({...r,name:`${r.name?r.name+"/":""}commercetools-sdk-javascript-v3/${_t.version}`}),n={...t,headers:{...t.headers,"User-Agent":i}};return e(n)}}function Vr({middlewares:r}){return r.length===1?r[0]:r.slice().reduce((t,i)=>(...n)=>t(i.apply(null,n)))}var jt;function Se(r,e,t){if(Ue("process",r,{allowedMethods:["GET"]}),typeof e!="function")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');let i={total:Number.POSITIVE_INFINITY,accumulate:!0,...t};return new Promise((n,o)=>{let s,l="";if(r&&r.uri){let[p,f]=r.uri.split("?");s=p,l=f}let h={limit:20,...{...ve(l)}},u=i.total,d=!1,w=async(p,f=[])=>{let C=h.limit<u?h.limit:u,k=Ie({...h,limit:C}),g={sort:"id asc",withTotal:!1,...p?{where:`id > "${p}"`}:{}},R=Ie(g),B={...r,uri:`${s}?${R}&${k}`};try{let y=await z(jt).execute(B),{results:j,count:q}=y?.body||{};if(!q&&d)return n(f||[]);let xe=await Promise.resolve(e(y)),G;if(d=!0,i.accumulate&&(G=f.concat(xe||[])),u-=q,q<h.limit||!u)return n(G||[]);let L=j[q-1],se=L&&L.id;w(se,G)}catch(y){o(y)}};w()})}function z(r){jt=r,Xe(r);let e=!1,t={async resolve(n){let{response:o,includeOriginalRequest:s,maskSensitiveHeaderData:l,...c}=n,{retryCount:h,...u}=o;return e=l,{body:null,error:null,reject:n.reject,resolve:n.resolve,...u,...s?{originalRequest:c}:{},...o?.retryCount?{retryCount:o.retryCount}:{}}}},i=Vr(r)(t.resolve);return{process:Se,execute(n){return Ue("exec",n),new Promise(async(o,s)=>{try{let l=await i({reject:s,resolve:o,...n});if(l.error)return s(l.error);l.originalRequest&&e&&(l.originalRequest=K(l.originalRequest)),o(l)}catch(l){s(l)}})}}}var{createAuthMiddlewareForPasswordFlow:Yr,createAuthMiddlewareForAnonymousSessionFlow:vr,createAuthMiddlewareForClientCredentialsFlow:Wr,createAuthMiddlewareForRefreshTokenFlow:Xr,createAuthMiddlewareForExistingTokenFlow:Zr,createCorrelationIdMiddleware:ei,createHttpMiddleware:ti,createLoggerMiddleware:ri,createQueueMiddleware:ii,createUserAgentMiddleware:qt,createConcurrentModificationMiddleware:ni}=tt,oe=class{projectKey;authMiddleware;httpMiddleware;userAgentMiddleware;correlationIdMiddleware;loggerMiddleware;queueMiddleware;concurrentMiddleware;telemetryMiddleware;beforeMiddleware;afterMiddleware;middlewares=[];constructor(){this.userAgentMiddleware=qt({})}withProjectKey(e){return this.projectKey=e,this}defaultClient(e,t,i,n,o,s){return this.withClientCredentialsFlow({host:i,projectKey:n||this.projectKey,credentials:t,httpClient:s||_.default,scopes:o}).withHttpMiddleware({host:e,httpClient:s||_.default})}withAuthMiddleware(e){return this.authMiddleware=e,this}withMiddleware(e){return this.middlewares.push(e),this}withClientCredentialsFlow(e){return this.withAuthMiddleware(Wr({host:e.host||A.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},oauthUri:e.oauthUri||null,scopes:e.scopes,httpClient:e.httpClient||_.default,...e}))}withPasswordFlow(e){return this.withAuthMiddleware(Yr({host:e.host||A.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,user:{username:e.credentials.user.username||null,password:e.credentials.user.password||null}},httpClient:e.httpClient||_.default,...e}))}withAnonymousSessionFlow(e){return this.withAuthMiddleware(vr({host:e.host||A.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,anonymousId:e.credentials.anonymousId||null},httpClient:e.httpClient||_.default,...e}))}withRefreshTokenFlow(e){return this.withAuthMiddleware(Xr({host:e.host||A.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},httpClient:e.httpClient||_.default,refreshToken:e.refreshToken||null,...e}))}withExistingTokenFlow(e,t){return this.withAuthMiddleware(Zr(e,{force:t.force||!0,...t}))}withHttpMiddleware(e){return this.httpMiddleware=ti({host:e.host||A.CTP_API_URL,httpClient:e.httpClient||_.default,...e}),this}withUserAgentMiddleware(e){return this.userAgentMiddleware=qt(e),this}withQueueMiddleware(e){return this.queueMiddleware=ii({concurrency:e.concurrency||A.CONCURRENCT_REQUEST,...e}),this}withLoggerMiddleware(e){return this.loggerMiddleware=ri(e),this}withCorrelationIdMiddleware(e){return this.correlationIdMiddleware=ei({generate:e?.generate,...e}),this}withConcurrentModificationMiddleware(e){return this.concurrentMiddleware=ni(e?.concurrentModificationHandlerFn),this}withTelemetryMiddleware(e){let{createTelemetryMiddleware:t,...i}=e;return this.withUserAgentMiddleware({customAgent:i?.userAgent||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=t(i),this}withBeforeExecutionMiddleware(e){let{middleware:t,...i}=e||{};return this.beforeMiddleware=e.middleware(i),this}withAfterExecutionMiddleware(e){let{middleware:t,...i}=e||{};return this.afterMiddleware=e.middleware(i),this}build(){let 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.loggerMiddleware&&e.push(this.loggerMiddleware),this.concurrentMiddleware&&e.push(this.concurrentMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.afterMiddleware&&e.push(this.afterMiddleware),z({middlewares:e})}};return zt(oi);})();
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
ieee754/index.js:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"../../../../src/client","sources":["builder.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,gCAAgC,EAChC,MAAM,EACN,uCAAuC,EACvC,8BAA8B,EAC9B,WAAW,EACX,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EAEV,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EACjB,0BAAsB;AAiBvB,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,UAAU,CAAoB;IAEtC,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,oBAAoB,CAAsB;IAClD,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAE7C,OAAO,CAAC,WAAW,CAAwB;;IAMpC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa;IAK1C,aAAa,CAClB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,EACxB,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACtB,UAAU,CAAC,EAAE,QAAQ,GACpB,aAAa;
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"../../../../src/client","sources":["builder.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,gCAAgC,EAChC,MAAM,EACN,uCAAuC,EACvC,8BAA8B,EAC9B,WAAW,EACX,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EAEV,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EACjB,0BAAsB;AAiBvB,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,UAAU,CAAoB;IAEtC,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,oBAAoB,CAAsB;IAClD,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAE7C,OAAO,CAAC,WAAW,CAAwB;;IAMpC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa;IAK1C,aAAa,CAClB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,EACxB,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACtB,UAAU,CAAC,EAAE,QAAQ,GACpB,aAAa;IAahB,OAAO,CAAC,kBAAkB;IAKnB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa;IAKrD,yBAAyB,CAC9B,OAAO,EAAE,qBAAqB,GAC7B,aAAa;IAiBT,gBAAgB,CACrB,OAAO,EAAE,6BAA6B,GACrC,aAAa;IAmBT,wBAAwB,CAC7B,OAAO,EAAE,qBAAqB,GAC7B,aAAa;IAgBT,oBAAoB,CACzB,OAAO,EAAE,4BAA4B,GACpC,aAAa;IAgBT,qBAAqB,CAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,8BAA8B,GACvC,aAAa;IAST,kBAAkB,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa;IAUjE,uBAAuB,CAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa;IAMT,mBAAmB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,aAAa;IASpE,oBAAoB,CAAC,OAAO,CAAC,EAAE,uBAAuB;IAMtD,2BAA2B,CAChC,OAAO,CAAC,EAAE,8BAA8B,GACvC,aAAa;IAST,oCAAoC,CACzC,OAAO,CAAC,EAAE,uCAAuC,GAChD,aAAa;IAQT,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,EACvD,OAAO,EAAE,CAAC,GACT,aAAa;IAUT,6BAA6B,CAClC,OAAO,EAAE,gCAAgC;IAOpC,4BAA4B,CACjC,OAAO,EAAE,+BAA+B;IAO1C,KAAK,IAAI,MAAM;CAiBhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anonymous-session-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["anonymous-session-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,2CAA2C,CACjE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,
|
|
1
|
+
{"version":3,"file":"anonymous-session-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["anonymous-session-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,2CAA2C,CACjE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA+DZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-credentials-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["client-credentials-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,4CAA4C,CAClE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,
|
|
1
|
+
{"version":3,"file":"client-credentials-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["client-credentials-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,4CAA4C,CAClE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA+DZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["password-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAIV,6BAA6B,EAE9B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,OAAO,EAAE,6BAA6B,GACrC,UAAU,
|
|
1
|
+
{"version":3,"file":"password-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["password-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAIV,6BAA6B,EAE9B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,OAAO,EAAE,6BAA6B,GACrC,UAAU,CA6DZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-token-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["refresh-token-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,4BAA4B,EAE7B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,uCAAuC,CAC7D,OAAO,EAAE,4BAA4B,GACpC,UAAU,
|
|
1
|
+
{"version":3,"file":"refresh-token-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["refresh-token-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,4BAA4B,EAE7B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,uCAAuC,CAC7D,OAAO,EAAE,4BAA4B,GACpC,UAAU,CA2DZ"}
|
|
@@ -98,8 +98,9 @@ export type AuthMiddlewareOptions = {
|
|
|
98
98
|
scopes?: Array<string>
|
|
99
99
|
// For internal usage only
|
|
100
100
|
oauthUri?: string
|
|
101
|
-
httpClient?: Function
|
|
102
101
|
tokenCache?: TokenCache
|
|
102
|
+
httpClient: Function
|
|
103
|
+
httpClientOptions?: object
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
export type TokenCacheOptions = {
|
|
@@ -138,7 +139,8 @@ export type RefreshAuthMiddlewareOptions = {
|
|
|
138
139
|
tokenCache?: TokenCache,
|
|
139
140
|
// For internal usage only
|
|
140
141
|
oauthUri?: string
|
|
141
|
-
httpClient
|
|
142
|
+
httpClient: Function
|
|
143
|
+
httpClientOptions?: object
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
/* Request */
|
|
@@ -147,9 +149,10 @@ type requestBaseOptions = {
|
|
|
147
149
|
body: string
|
|
148
150
|
basicAuth: string
|
|
149
151
|
request: MiddlewareRequest
|
|
150
|
-
tokenCache: TokenCache
|
|
151
|
-
tokenCacheKey?: TokenCacheOptions
|
|
152
|
+
tokenCache: TokenCache
|
|
153
|
+
tokenCacheKey?: TokenCacheOptions
|
|
152
154
|
tokenCacheObject?: TokenStore
|
|
155
|
+
httpClientOptions?: object
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
export type executeRequestOptions = requestBaseOptions & {
|
|
@@ -160,11 +163,9 @@ export type executeRequestOptions = requestBaseOptions & {
|
|
|
160
163
|
|
|
161
164
|
export type AuthMiddlewareBaseOptions = requestBaseOptions & {
|
|
162
165
|
request: MiddlewareRequest
|
|
163
|
-
httpClient
|
|
166
|
+
httpClient: Function
|
|
164
167
|
}
|
|
165
168
|
|
|
166
|
-
export type RequestState = boolean
|
|
167
|
-
|
|
168
169
|
export type Task = {
|
|
169
170
|
request: MiddlewareRequest
|
|
170
171
|
next?: Next
|
|
@@ -187,7 +188,8 @@ export type PasswordAuthMiddlewareOptions = {
|
|
|
187
188
|
tokenCache?: TokenCache,
|
|
188
189
|
// For internal usage only
|
|
189
190
|
oauthUri?: string
|
|
190
|
-
httpClient
|
|
191
|
+
httpClient: Function
|
|
192
|
+
httpClientOptions?: object
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
export type TokenInfo = {
|
|
@@ -214,8 +216,8 @@ export type HttpMiddlewareOptions = {
|
|
|
214
216
|
enableRetry?: boolean
|
|
215
217
|
retryConfig?: RetryOptions
|
|
216
218
|
httpClient: Function
|
|
217
|
-
getAbortController?: () => AbortController
|
|
218
219
|
httpClientOptions?: object // will be passed as a second argument to your httpClient function for configuration
|
|
220
|
+
getAbortController?: () => AbortController
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
export type RetryOptions = RetryMiddlewareOptions
|
|
@@ -297,6 +299,7 @@ export type IClientOptions = {
|
|
|
297
299
|
enableRetry?: boolean
|
|
298
300
|
retryConfig?: RetryOptions
|
|
299
301
|
maskSensitiveHeaderData?: boolean
|
|
302
|
+
httpClientOptions?: object
|
|
300
303
|
}
|
|
301
304
|
|
|
302
305
|
export type HttpClientOptions = IClientOptions & Optional
|