@commercetools/sdk-client-v2 2.1.1 → 2.1.3

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @commercetools/sdk-client-v2
2
2
 
3
+ ## 2.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#423](https://github.com/commercetools/commercetools-sdk-typescript/pull/423) [`4c87f46`](https://github.com/commercetools/commercetools-sdk-typescript/commit/4c87f46c811788543ee2b3b6d7f70e221e05c07e) Thanks [@ajimae](https://github.com/ajimae)! - Change all instances of `require` to `import`
8
+
9
+ ## 2.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#415](https://github.com/commercetools/commercetools-sdk-typescript/pull/415) [`caca661`](https://github.com/commercetools/commercetools-sdk-typescript/commit/caca661ff4c91cf256b6ee406135a45478b7ae47) Thanks [@ajimae](https://github.com/ajimae)! - fix uri `notfound error` for 404 error when `includeRequestInErrorResponse` is set to false.
14
+
3
15
  ## 2.1.1
4
16
 
5
17
  ### Patch Changes
@@ -11,7 +11,24 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
11
11
  var fetch__default = /*#__PURE__*/_interopDefault(fetch$1);
12
12
  var qs__default = /*#__PURE__*/_interopDefault(qs);
13
13
 
14
+ function _toPrimitive(input, hint) {
15
+ if (typeof input !== "object" || input === null) return input;
16
+ var prim = input[Symbol.toPrimitive];
17
+ if (prim !== undefined) {
18
+ var res = prim.call(input, hint || "default");
19
+ if (typeof res !== "object") return res;
20
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ return (hint === "string" ? String : Number)(input);
23
+ }
24
+
25
+ function _toPropertyKey(arg) {
26
+ var key = _toPrimitive(arg, "string");
27
+ return typeof key === "symbol" ? key : String(key);
28
+ }
29
+
14
30
  function _defineProperty(obj, key, value) {
31
+ key = _toPropertyKey(key);
15
32
  if (key in obj) {
16
33
  Object.defineProperty(obj, key, {
17
34
  value: value,
@@ -171,9 +188,6 @@ function createClient(options) {
171
188
  };
172
189
  }
173
190
 
174
- // POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
175
- // Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
176
- const Buffer$1 = require('buffer/').Buffer;
177
191
  function buildRequestForClientCredentialsFlow(options) {
178
192
  if (!options) throw new Error('Missing required options');
179
193
  if (!options.host) throw new Error('Missing required option (host)');
@@ -185,7 +199,7 @@ function buildRequestForClientCredentialsFlow(options) {
185
199
  } = options.credentials;
186
200
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
187
201
  const scope = options.scopes ? options.scopes.join(' ') : undefined;
188
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
202
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
189
203
  // This is mostly useful for internal testing purposes to be able to check
190
204
  // other oauth endpoints.
191
205
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -216,7 +230,7 @@ function buildRequestForPasswordFlow(options) {
216
230
  if (!(username && password)) throw new Error('Missing required user credentials (username, password)');
217
231
  const scope = (options.scopes || []).join(' ');
218
232
  const scopeStr = scope ? `&scope=${scope}` : '';
219
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
233
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
220
234
  /**
221
235
  * This is mostly useful for internal testing purposes to be able to check
222
236
  * other oauth endpoints.
@@ -242,7 +256,7 @@ function buildRequestForRefreshTokenFlow(options) {
242
256
  clientSecret
243
257
  } = options.credentials;
244
258
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
245
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
259
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
246
260
  // This is mostly useful for internal testing purposes to be able to check
247
261
  // other oauth endpoints.
248
262
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -266,7 +280,6 @@ function buildRequestForAnonymousSessionFlow(options) {
266
280
  };
267
281
  }
268
282
 
269
- const Buffer = require('buffer/').Buffer;
270
283
  function mergeAuthHeader(token, req) {
271
284
  return {
272
285
  ...req,
@@ -297,7 +310,7 @@ async function executeRequest({
297
310
  method: 'POST',
298
311
  headers: {
299
312
  Authorization: `Basic ${basicAuth}`,
300
- 'Content-Length': Buffer.byteLength(body).toString(),
313
+ 'Content-Length': _.Buffer.byteLength(body).toString(),
301
314
  'Content-Type': 'application/x-www-form-urlencoded'
302
315
  },
303
316
  body
@@ -703,7 +716,12 @@ function createError({
703
716
  ...rest
704
717
  }) {
705
718
  let errorMessage = message || 'Unexpected non-JSON error response';
706
- if (statusCode === 404) errorMessage = `URI not found: ${rest.originalRequest.uri}`;
719
+ if (statusCode === 404) {
720
+ var _rest$originalRequest;
721
+ errorMessage = `URI not found: ${((_rest$originalRequest = rest.originalRequest) === null || _rest$originalRequest === void 0 ? void 0 : _rest$originalRequest.uri) || rest.uri}`;
722
+ delete rest.uri; // remove the `uri` property from the response
723
+ }
724
+
707
725
  const ResponseError = getErrorByCode(statusCode);
708
726
  if (ResponseError) return new ResponseError(errorMessage, rest);
709
727
  return new HttpError(statusCode, errorMessage, rest);
@@ -856,6 +874,8 @@ function createHttpMiddleware({
856
874
  statusCode: res.status,
857
875
  ...(includeRequestInErrorResponse ? {
858
876
  originalRequest: request
877
+ } : res.status === 404 ? {
878
+ uri: request.uri
859
879
  } : {}),
860
880
  retryCount,
861
881
  headers: parseHeaders(res.headers),
@@ -981,7 +1001,7 @@ function createQueueMiddleware({
981
1001
 
982
1002
  var packageJson = {
983
1003
  name: "@commercetools/sdk-client-v2",
984
- version: "2.1.1",
1004
+ version: "2.1.3",
985
1005
  engines: {
986
1006
  node: ">=14"
987
1007
  },
@@ -1033,7 +1053,7 @@ var packageJson = {
1033
1053
  "abort-controller": "3.0.0",
1034
1054
  "common-tags": "1.8.2",
1035
1055
  dotenv: "16.0.3",
1036
- jest: "29.3.1",
1056
+ jest: "29.4.2",
1037
1057
  nock: "12.0.3",
1038
1058
  "organize-imports-cli": "0.10.0"
1039
1059
  },
@@ -1,8 +1,25 @@
1
1
  import fetch$1 from 'node-fetch';
2
2
  import qs from 'querystring';
3
- import { Buffer as Buffer$2 } from 'buffer/';
3
+ import { Buffer } from 'buffer/';
4
+
5
+ function _toPrimitive(input, hint) {
6
+ if (typeof input !== "object" || input === null) return input;
7
+ var prim = input[Symbol.toPrimitive];
8
+ if (prim !== undefined) {
9
+ var res = prim.call(input, hint || "default");
10
+ if (typeof res !== "object") return res;
11
+ throw new TypeError("@@toPrimitive must return a primitive value.");
12
+ }
13
+ return (hint === "string" ? String : Number)(input);
14
+ }
15
+
16
+ function _toPropertyKey(arg) {
17
+ var key = _toPrimitive(arg, "string");
18
+ return typeof key === "symbol" ? key : String(key);
19
+ }
4
20
 
5
21
  function _defineProperty(obj, key, value) {
22
+ key = _toPropertyKey(key);
6
23
  if (key in obj) {
7
24
  Object.defineProperty(obj, key, {
8
25
  value: value,
@@ -162,9 +179,6 @@ function createClient(options) {
162
179
  };
163
180
  }
164
181
 
165
- // POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
166
- // Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
167
- const Buffer$1 = require('buffer/').Buffer;
168
182
  function buildRequestForClientCredentialsFlow(options) {
169
183
  if (!options) throw new Error('Missing required options');
170
184
  if (!options.host) throw new Error('Missing required option (host)');
@@ -176,7 +190,7 @@ function buildRequestForClientCredentialsFlow(options) {
176
190
  } = options.credentials;
177
191
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
178
192
  const scope = options.scopes ? options.scopes.join(' ') : undefined;
179
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
193
+ const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
180
194
  // This is mostly useful for internal testing purposes to be able to check
181
195
  // other oauth endpoints.
182
196
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -207,7 +221,7 @@ function buildRequestForPasswordFlow(options) {
207
221
  if (!(username && password)) throw new Error('Missing required user credentials (username, password)');
208
222
  const scope = (options.scopes || []).join(' ');
209
223
  const scopeStr = scope ? `&scope=${scope}` : '';
210
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
224
+ const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
211
225
  /**
212
226
  * This is mostly useful for internal testing purposes to be able to check
213
227
  * other oauth endpoints.
@@ -233,7 +247,7 @@ function buildRequestForRefreshTokenFlow(options) {
233
247
  clientSecret
234
248
  } = options.credentials;
235
249
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
236
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
250
+ const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
237
251
  // This is mostly useful for internal testing purposes to be able to check
238
252
  // other oauth endpoints.
239
253
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -257,7 +271,6 @@ function buildRequestForAnonymousSessionFlow(options) {
257
271
  };
258
272
  }
259
273
 
260
- const Buffer = require('buffer/').Buffer;
261
274
  function mergeAuthHeader(token, req) {
262
275
  return {
263
276
  ...req,
@@ -694,7 +707,12 @@ function createError({
694
707
  ...rest
695
708
  }) {
696
709
  let errorMessage = message || 'Unexpected non-JSON error response';
697
- if (statusCode === 404) errorMessage = `URI not found: ${rest.originalRequest.uri}`;
710
+ if (statusCode === 404) {
711
+ var _rest$originalRequest;
712
+ errorMessage = `URI not found: ${((_rest$originalRequest = rest.originalRequest) === null || _rest$originalRequest === void 0 ? void 0 : _rest$originalRequest.uri) || rest.uri}`;
713
+ delete rest.uri; // remove the `uri` property from the response
714
+ }
715
+
698
716
  const ResponseError = getErrorByCode(statusCode);
699
717
  if (ResponseError) return new ResponseError(errorMessage, rest);
700
718
  return new HttpError(statusCode, errorMessage, rest);
@@ -767,7 +785,7 @@ function createHttpMiddleware({
767
785
  // Ensure body is a string if content type is application/json
768
786
  const body = ['application/json', 'application/graphql'].indexOf(requestHeader['Content-Type']) > -1 && typeof request.body === 'string' || isBuffer(request.body) ? request.body : JSON.stringify(request.body || undefined);
769
787
  if (body && (typeof body === 'string' || isBuffer(body))) {
770
- requestHeader['Content-Length'] = Buffer$2.byteLength(body).toString();
788
+ requestHeader['Content-Length'] = Buffer.byteLength(body).toString();
771
789
  }
772
790
  const fetchOptions = {
773
791
  method: request.method,
@@ -847,6 +865,8 @@ function createHttpMiddleware({
847
865
  statusCode: res.status,
848
866
  ...(includeRequestInErrorResponse ? {
849
867
  originalRequest: request
868
+ } : res.status === 404 ? {
869
+ uri: request.uri
850
870
  } : {}),
851
871
  retryCount,
852
872
  headers: parseHeaders(res.headers),
@@ -972,7 +992,7 @@ function createQueueMiddleware({
972
992
 
973
993
  var packageJson = {
974
994
  name: "@commercetools/sdk-client-v2",
975
- version: "2.1.1",
995
+ version: "2.1.3",
976
996
  engines: {
977
997
  node: ">=14"
978
998
  },
@@ -1024,7 +1044,7 @@ var packageJson = {
1024
1044
  "abort-controller": "3.0.0",
1025
1045
  "common-tags": "1.8.2",
1026
1046
  dotenv: "16.0.3",
1027
- jest: "29.3.1",
1047
+ jest: "29.4.2",
1028
1048
  nock: "12.0.3",
1029
1049
  "organize-imports-cli": "0.10.0"
1030
1050
  },
@@ -11,7 +11,24 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
11
11
  var fetch__default = /*#__PURE__*/_interopDefault(fetch$1);
12
12
  var qs__default = /*#__PURE__*/_interopDefault(qs);
13
13
 
14
+ function _toPrimitive(input, hint) {
15
+ if (typeof input !== "object" || input === null) return input;
16
+ var prim = input[Symbol.toPrimitive];
17
+ if (prim !== undefined) {
18
+ var res = prim.call(input, hint || "default");
19
+ if (typeof res !== "object") return res;
20
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ return (hint === "string" ? String : Number)(input);
23
+ }
24
+
25
+ function _toPropertyKey(arg) {
26
+ var key = _toPrimitive(arg, "string");
27
+ return typeof key === "symbol" ? key : String(key);
28
+ }
29
+
14
30
  function _defineProperty(obj, key, value) {
31
+ key = _toPropertyKey(key);
15
32
  if (key in obj) {
16
33
  Object.defineProperty(obj, key, {
17
34
  value: value,
@@ -171,9 +188,6 @@ function createClient(options) {
171
188
  };
172
189
  }
173
190
 
174
- // POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
175
- // Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
176
- const Buffer$1 = require('buffer/').Buffer;
177
191
  function buildRequestForClientCredentialsFlow(options) {
178
192
  if (!options) throw new Error('Missing required options');
179
193
  if (!options.host) throw new Error('Missing required option (host)');
@@ -185,7 +199,7 @@ function buildRequestForClientCredentialsFlow(options) {
185
199
  } = options.credentials;
186
200
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
187
201
  const scope = options.scopes ? options.scopes.join(' ') : undefined;
188
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
202
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
189
203
  // This is mostly useful for internal testing purposes to be able to check
190
204
  // other oauth endpoints.
191
205
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -216,7 +230,7 @@ function buildRequestForPasswordFlow(options) {
216
230
  if (!(username && password)) throw new Error('Missing required user credentials (username, password)');
217
231
  const scope = (options.scopes || []).join(' ');
218
232
  const scopeStr = scope ? `&scope=${scope}` : '';
219
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
233
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
220
234
  /**
221
235
  * This is mostly useful for internal testing purposes to be able to check
222
236
  * other oauth endpoints.
@@ -242,7 +256,7 @@ function buildRequestForRefreshTokenFlow(options) {
242
256
  clientSecret
243
257
  } = options.credentials;
244
258
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
245
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
259
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
246
260
  // This is mostly useful for internal testing purposes to be able to check
247
261
  // other oauth endpoints.
248
262
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -266,7 +280,6 @@ function buildRequestForAnonymousSessionFlow(options) {
266
280
  };
267
281
  }
268
282
 
269
- const Buffer = require('buffer/').Buffer;
270
283
  function mergeAuthHeader(token, req) {
271
284
  return {
272
285
  ...req,
@@ -297,7 +310,7 @@ async function executeRequest({
297
310
  method: 'POST',
298
311
  headers: {
299
312
  Authorization: `Basic ${basicAuth}`,
300
- 'Content-Length': Buffer.byteLength(body).toString(),
313
+ 'Content-Length': _.Buffer.byteLength(body).toString(),
301
314
  'Content-Type': 'application/x-www-form-urlencoded'
302
315
  },
303
316
  body
@@ -703,7 +716,12 @@ function createError({
703
716
  ...rest
704
717
  }) {
705
718
  let errorMessage = message || 'Unexpected non-JSON error response';
706
- if (statusCode === 404) errorMessage = `URI not found: ${rest.originalRequest.uri}`;
719
+ if (statusCode === 404) {
720
+ var _rest$originalRequest;
721
+ errorMessage = `URI not found: ${((_rest$originalRequest = rest.originalRequest) === null || _rest$originalRequest === void 0 ? void 0 : _rest$originalRequest.uri) || rest.uri}`;
722
+ delete rest.uri; // remove the `uri` property from the response
723
+ }
724
+
707
725
  const ResponseError = getErrorByCode(statusCode);
708
726
  if (ResponseError) return new ResponseError(errorMessage, rest);
709
727
  return new HttpError(statusCode, errorMessage, rest);
@@ -856,6 +874,8 @@ function createHttpMiddleware({
856
874
  statusCode: res.status,
857
875
  ...(includeRequestInErrorResponse ? {
858
876
  originalRequest: request
877
+ } : res.status === 404 ? {
878
+ uri: request.uri
859
879
  } : {}),
860
880
  retryCount,
861
881
  headers: parseHeaders(res.headers),
@@ -981,7 +1001,7 @@ function createQueueMiddleware({
981
1001
 
982
1002
  var packageJson = {
983
1003
  name: "@commercetools/sdk-client-v2",
984
- version: "2.1.1",
1004
+ version: "2.1.3",
985
1005
  engines: {
986
1006
  node: ">=14"
987
1007
  },
@@ -1033,7 +1053,7 @@ var packageJson = {
1033
1053
  "abort-controller": "3.0.0",
1034
1054
  "common-tags": "1.8.2",
1035
1055
  dotenv: "16.0.3",
1036
- jest: "29.3.1",
1056
+ jest: "29.4.2",
1037
1057
  nock: "12.0.3",
1038
1058
  "organize-imports-cli": "0.10.0"
1039
1059
  },
@@ -11,7 +11,24 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
11
11
  var fetch__default = /*#__PURE__*/_interopDefault(fetch$1);
12
12
  var qs__default = /*#__PURE__*/_interopDefault(qs);
13
13
 
14
+ function _toPrimitive(input, hint) {
15
+ if (typeof input !== "object" || input === null) return input;
16
+ var prim = input[Symbol.toPrimitive];
17
+ if (prim !== undefined) {
18
+ var res = prim.call(input, hint || "default");
19
+ if (typeof res !== "object") return res;
20
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ return (hint === "string" ? String : Number)(input);
23
+ }
24
+
25
+ function _toPropertyKey(arg) {
26
+ var key = _toPrimitive(arg, "string");
27
+ return typeof key === "symbol" ? key : String(key);
28
+ }
29
+
14
30
  function _defineProperty(obj, key, value) {
31
+ key = _toPropertyKey(key);
15
32
  if (key in obj) {
16
33
  Object.defineProperty(obj, key, {
17
34
  value: value,
@@ -171,9 +188,6 @@ function createClient(options) {
171
188
  };
172
189
  }
173
190
 
174
- // POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
175
- // Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
176
- const Buffer$1 = require('buffer/').Buffer;
177
191
  function buildRequestForClientCredentialsFlow(options) {
178
192
  if (!options) throw new Error('Missing required options');
179
193
  if (!options.host) throw new Error('Missing required option (host)');
@@ -185,7 +199,7 @@ function buildRequestForClientCredentialsFlow(options) {
185
199
  } = options.credentials;
186
200
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
187
201
  const scope = options.scopes ? options.scopes.join(' ') : undefined;
188
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
202
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
189
203
  // This is mostly useful for internal testing purposes to be able to check
190
204
  // other oauth endpoints.
191
205
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -216,7 +230,7 @@ function buildRequestForPasswordFlow(options) {
216
230
  if (!(username && password)) throw new Error('Missing required user credentials (username, password)');
217
231
  const scope = (options.scopes || []).join(' ');
218
232
  const scopeStr = scope ? `&scope=${scope}` : '';
219
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
233
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
220
234
  /**
221
235
  * This is mostly useful for internal testing purposes to be able to check
222
236
  * other oauth endpoints.
@@ -242,7 +256,7 @@ function buildRequestForRefreshTokenFlow(options) {
242
256
  clientSecret
243
257
  } = options.credentials;
244
258
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
245
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
259
+ const basicAuth = _.Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
246
260
  // This is mostly useful for internal testing purposes to be able to check
247
261
  // other oauth endpoints.
248
262
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -266,7 +280,6 @@ function buildRequestForAnonymousSessionFlow(options) {
266
280
  };
267
281
  }
268
282
 
269
- const Buffer = require('buffer/').Buffer;
270
283
  function mergeAuthHeader(token, req) {
271
284
  return {
272
285
  ...req,
@@ -297,7 +310,7 @@ async function executeRequest({
297
310
  method: 'POST',
298
311
  headers: {
299
312
  Authorization: `Basic ${basicAuth}`,
300
- 'Content-Length': Buffer.byteLength(body).toString(),
313
+ 'Content-Length': _.Buffer.byteLength(body).toString(),
301
314
  'Content-Type': 'application/x-www-form-urlencoded'
302
315
  },
303
316
  body
@@ -703,7 +716,12 @@ function createError({
703
716
  ...rest
704
717
  }) {
705
718
  let errorMessage = message || 'Unexpected non-JSON error response';
706
- if (statusCode === 404) errorMessage = `URI not found: ${rest.originalRequest.uri}`;
719
+ if (statusCode === 404) {
720
+ var _rest$originalRequest;
721
+ errorMessage = `URI not found: ${((_rest$originalRequest = rest.originalRequest) === null || _rest$originalRequest === void 0 ? void 0 : _rest$originalRequest.uri) || rest.uri}`;
722
+ delete rest.uri; // remove the `uri` property from the response
723
+ }
724
+
707
725
  const ResponseError = getErrorByCode(statusCode);
708
726
  if (ResponseError) return new ResponseError(errorMessage, rest);
709
727
  return new HttpError(statusCode, errorMessage, rest);
@@ -856,6 +874,8 @@ function createHttpMiddleware({
856
874
  statusCode: res.status,
857
875
  ...(includeRequestInErrorResponse ? {
858
876
  originalRequest: request
877
+ } : res.status === 404 ? {
878
+ uri: request.uri
859
879
  } : {}),
860
880
  retryCount,
861
881
  headers: parseHeaders(res.headers),
@@ -981,7 +1001,7 @@ function createQueueMiddleware({
981
1001
 
982
1002
  var packageJson = {
983
1003
  name: "@commercetools/sdk-client-v2",
984
- version: "2.1.1",
1004
+ version: "2.1.3",
985
1005
  engines: {
986
1006
  node: ">=14"
987
1007
  },
@@ -1033,7 +1053,7 @@ var packageJson = {
1033
1053
  "abort-controller": "3.0.0",
1034
1054
  "common-tags": "1.8.2",
1035
1055
  dotenv: "16.0.3",
1036
- jest: "29.3.1",
1056
+ jest: "29.4.2",
1037
1057
  nock: "12.0.3",
1038
1058
  "organize-imports-cli": "0.10.0"
1039
1059
  },
@@ -1,8 +1,25 @@
1
1
  import fetch$1 from 'node-fetch';
2
2
  import qs from 'querystring';
3
- import { Buffer as Buffer$2 } from 'buffer/';
3
+ import { Buffer } from 'buffer/';
4
+
5
+ function _toPrimitive(input, hint) {
6
+ if (typeof input !== "object" || input === null) return input;
7
+ var prim = input[Symbol.toPrimitive];
8
+ if (prim !== undefined) {
9
+ var res = prim.call(input, hint || "default");
10
+ if (typeof res !== "object") return res;
11
+ throw new TypeError("@@toPrimitive must return a primitive value.");
12
+ }
13
+ return (hint === "string" ? String : Number)(input);
14
+ }
15
+
16
+ function _toPropertyKey(arg) {
17
+ var key = _toPrimitive(arg, "string");
18
+ return typeof key === "symbol" ? key : String(key);
19
+ }
4
20
 
5
21
  function _defineProperty(obj, key, value) {
22
+ key = _toPropertyKey(key);
6
23
  if (key in obj) {
7
24
  Object.defineProperty(obj, key, {
8
25
  value: value,
@@ -162,9 +179,6 @@ function createClient(options) {
162
179
  };
163
180
  }
164
181
 
165
- // POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
166
- // Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
167
- const Buffer$1 = require('buffer/').Buffer;
168
182
  function buildRequestForClientCredentialsFlow(options) {
169
183
  if (!options) throw new Error('Missing required options');
170
184
  if (!options.host) throw new Error('Missing required option (host)');
@@ -176,7 +190,7 @@ function buildRequestForClientCredentialsFlow(options) {
176
190
  } = options.credentials;
177
191
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
178
192
  const scope = options.scopes ? options.scopes.join(' ') : undefined;
179
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
193
+ const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
180
194
  // This is mostly useful for internal testing purposes to be able to check
181
195
  // other oauth endpoints.
182
196
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -207,7 +221,7 @@ function buildRequestForPasswordFlow(options) {
207
221
  if (!(username && password)) throw new Error('Missing required user credentials (username, password)');
208
222
  const scope = (options.scopes || []).join(' ');
209
223
  const scopeStr = scope ? `&scope=${scope}` : '';
210
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
224
+ const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
211
225
  /**
212
226
  * This is mostly useful for internal testing purposes to be able to check
213
227
  * other oauth endpoints.
@@ -233,7 +247,7 @@ function buildRequestForRefreshTokenFlow(options) {
233
247
  clientSecret
234
248
  } = options.credentials;
235
249
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
236
- const basicAuth = Buffer$1.from(`${clientId}:${clientSecret}`).toString('base64');
250
+ const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
237
251
  // This is mostly useful for internal testing purposes to be able to check
238
252
  // other oauth endpoints.
239
253
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -257,7 +271,6 @@ function buildRequestForAnonymousSessionFlow(options) {
257
271
  };
258
272
  }
259
273
 
260
- const Buffer = require('buffer/').Buffer;
261
274
  function mergeAuthHeader(token, req) {
262
275
  return {
263
276
  ...req,
@@ -694,7 +707,12 @@ function createError({
694
707
  ...rest
695
708
  }) {
696
709
  let errorMessage = message || 'Unexpected non-JSON error response';
697
- if (statusCode === 404) errorMessage = `URI not found: ${rest.originalRequest.uri}`;
710
+ if (statusCode === 404) {
711
+ var _rest$originalRequest;
712
+ errorMessage = `URI not found: ${((_rest$originalRequest = rest.originalRequest) === null || _rest$originalRequest === void 0 ? void 0 : _rest$originalRequest.uri) || rest.uri}`;
713
+ delete rest.uri; // remove the `uri` property from the response
714
+ }
715
+
698
716
  const ResponseError = getErrorByCode(statusCode);
699
717
  if (ResponseError) return new ResponseError(errorMessage, rest);
700
718
  return new HttpError(statusCode, errorMessage, rest);
@@ -767,7 +785,7 @@ function createHttpMiddleware({
767
785
  // Ensure body is a string if content type is application/json
768
786
  const body = ['application/json', 'application/graphql'].indexOf(requestHeader['Content-Type']) > -1 && typeof request.body === 'string' || isBuffer(request.body) ? request.body : JSON.stringify(request.body || undefined);
769
787
  if (body && (typeof body === 'string' || isBuffer(body))) {
770
- requestHeader['Content-Length'] = Buffer$2.byteLength(body).toString();
788
+ requestHeader['Content-Length'] = Buffer.byteLength(body).toString();
771
789
  }
772
790
  const fetchOptions = {
773
791
  method: request.method,
@@ -847,6 +865,8 @@ function createHttpMiddleware({
847
865
  statusCode: res.status,
848
866
  ...(includeRequestInErrorResponse ? {
849
867
  originalRequest: request
868
+ } : res.status === 404 ? {
869
+ uri: request.uri
850
870
  } : {}),
851
871
  retryCount,
852
872
  headers: parseHeaders(res.headers),
@@ -972,7 +992,7 @@ function createQueueMiddleware({
972
992
 
973
993
  var packageJson = {
974
994
  name: "@commercetools/sdk-client-v2",
975
- version: "2.1.1",
995
+ version: "2.1.3",
976
996
  engines: {
977
997
  node: ">=14"
978
998
  },
@@ -1024,7 +1044,7 @@ var packageJson = {
1024
1044
  "abort-controller": "3.0.0",
1025
1045
  "common-tags": "1.8.2",
1026
1046
  dotenv: "16.0.3",
1027
- jest: "29.3.1",
1047
+ jest: "29.4.2",
1028
1048
  nock: "12.0.3",
1029
1049
  "organize-imports-cli": "0.10.0"
1030
1050
  },
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@commercetools/sdk-client-v2"]=t():e["@commercetools/sdk-client-v2"]=t()}(self,(()=>(()=>{var e={754:()=>{},169:()=>{},872:()=>{},696:()=>{},305:()=>{},52:()=>{},392:(e,t,r)=>{"use strict";r.d(t,{Z:()=>C});var n=r(872),o=r.n(n),i=r(202),a=r(584),s=r(554),c=r(352),u=r(637),l=r(589),h=r(386),d=r(349),f=r(357),p=r(324),y=r(406),w=function(){return w=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},w.apply(this,arguments)},v=u.Z,g=a.Z,m=s.Z,b=l.Z,j=c.Z;const C=function(){function e(){this.middlewares=[]}return e.prototype.withProjectKey=function(e){return this.projectKey=e,this},e.prototype.defaultClient=function(e,t,r,n){return this.withClientCredentialsFlow({host:r,projectKey:n||this.projectKey,credentials:t}).withHttpMiddleware({host:e,fetch:o()}).withLoggerMiddleware().withUserAgentMiddleware()},e.prototype.withAuthMiddleware=function(e){return this.authMiddleware=e,this},e.prototype.withMiddleware=function(e){return this.middlewares.push(e),this},e.prototype.withClientCredentialsFlow=function(e){return this.withAuthMiddleware(m(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||""},oauthUri:e.oauthUri||"",scopes:e.scopes,fetch:e.fetch||o()},e)))},e.prototype.withPasswordFlow=function(e){return this.withAuthMiddleware(v(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||"",user:{username:e.credentials.user.username||"",password:e.credentials.user.password||""}},fetch:e.fetch||o()},e)))},e.prototype.withAnonymousSessionFlow=function(e){return this.withAuthMiddleware(g(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||"",anonymousId:e.credentials.anonymousId||""},fetch:e.fetch||o()},e)))},e.prototype.withRefreshTokenFlow=function(e){return this.withAuthMiddleware(b(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||""},fetch:e.fetch||o(),refreshToken:e.refreshToken||""},e)))},e.prototype.withExistingTokenFlow=function(e,t){return this.withAuthMiddleware(j(e,w({force:t.force||!0},t)))},e.prototype.withHttpMiddleware=function(e){return this.httpMiddleware=(0,d.Z)(w({host:e.host||"https://api.europe-west1.gcp.commercetools.com",fetch:e.fetch||o()},e)),this},e.prototype.withUserAgentMiddleware=function(e){return this.userAgentMiddleware=(0,y.Z)(e),this},e.prototype.withQueueMiddleware=function(e){return this.queueMiddleware=(0,p.Z)(w({concurrency:e.concurrency||20},e)),this},e.prototype.withLoggerMiddleware=function(){return this.loggerMiddleware=(0,f.Z)(),this},e.prototype.withCorrelationIdMiddleware=function(e){return this.correlationIdMiddleware=(0,h.Z)(w({generate:e.generate||null},e)),this},e.prototype.build=function(){var e=this.middlewares.slice();return this.correlationIdMiddleware&&e.push(this.correlationIdMiddleware),this.userAgentMiddleware&&e.push(this.userAgentMiddleware),this.authMiddleware&&e.push(this.authMiddleware),this.queueMiddleware&&e.push(this.queueMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.loggerMiddleware&&e.push(this.loggerMiddleware),(0,i.Z)({middlewares:e})},e}()},202:(e,t,r)=>{"use strict";r.d(t,{Z:()=>h,N:()=>l});var n=r(305),o=r.n(n);const i=["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 a(e,t,r){if(void 0===r&&(r={allowedMethods:i}),!t)throw new Error('The "'.concat(e,'" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if("string"!=typeof t.uri)throw new Error('The "'.concat(e,'" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if(!r.allowedMethods.includes(t.method))throw new Error('The "'.concat(e,'" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'))}var s,c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},c.apply(this,arguments)};function u(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===(e=e.filter((function(e){return"function"==typeof e}))).length?e[0]:e.reduce((function(e,t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return e(t.apply(void 0,r))}}))}function l(e,t,r){var n=this;if(a("process",e,{allowedMethods:["GET"]}),"function"!=typeof t)throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');var i=c({total:Number.POSITIVE_INFINITY,accumulate:!0},r);return new Promise((function(r,a){var u,l="";if(e&&e.uri){var d=e.uri.split("?"),f=d[0],p=d[1];u=f,l=p}var y=c({},o().parse(l)),w=c({limit:20},y),v=!1,g=i.total,m=function(l,d){return void 0===d&&(d=[]),f=n,p=void 0,b=function(){var n,f,p,y,b,j,C,O,M,k,E,T,A,q;return function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,(function(S){switch(S.label){case 0:n=w.limit<g?w.limit:g,f=o().stringify(c(c({},w),{limit:n})),p=c({sort:"id asc",withTotal:!1},l?{where:'id > "'.concat(l,'"')}:{}),y=o().stringify(p),b=c(c({},e),{uri:"".concat(u,"?").concat(y,"&").concat(f)}),S.label=1;case 1:return S.trys.push([1,4,,5]),[4,h(s).execute(b)];case 2:return j=S.sent(),C=j.body,O=C.results,!(M=C.count)&&v?[2,r(d||[])]:[4,Promise.resolve(t(j))];case 3:return k=S.sent(),E=void 0,v=!0,i.accumulate&&(E=d.concat(k||[])),g-=M,M<w.limit||!g?[2,r(E||[])]:(T=O[M-1],A=T&&T.id,m(A,E),[3,5]);case 4:return q=S.sent(),a(q),[3,5];case 5:return[2]}}))},new((y=void 0)||(y=Promise))((function(e,t){function r(e){try{o(b.next(e))}catch(e){t(e)}}function n(e){try{o(b.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof y?o:new y((function(e){e(o)}))).then(r,n)}o((b=b.apply(f,p||[])).next())}));var f,p,y,b};m()}))}function h(e){if(s=e,!e)throw new Error("Missing required options");if(e.middlewares&&!Array.isArray(e.middlewares))throw new Error("Middlewares should be an array");if(!e.middlewares||!Array.isArray(e.middlewares)||!e.middlewares.length)throw new Error("You need to provide at least one middleware");return{process:l,execute:function(t){return a("exec",t),new Promise((function(r,n){u.apply(void 0,e.middlewares)((function(e,t){if(t.error)t.reject(t.error);else{var r={body:t.body||{},statusCode:t.statusCode};t.headers&&(r.headers=t.headers),t.request&&(r.request=t.request),t.resolve(r)}}))(t,{resolve:r,reject:n,body:void 0,error:void 0})}))}}}},109:(e,t,r)=>{"use strict";r.d(t,{F7:()=>i,ZP:()=>p,oo:()=>a});var n=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function o(e,t,r){void 0===r&&(r={}),this.status=this.statusCode=this.code=e,this.message=t,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,0],e,!1))}function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this],e,!1))}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,400],e,!1))}function c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,401],e,!1))}function u(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,403],e,!1))}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,404],e,!1))}function h(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,409],e,!1))}function d(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,500],e,!1))}function f(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,503],e,!1))}function p(e){switch(e){case 0:return i;case 400:return s;case 401:return c;case 403:return u;case 404:return l;case 409:return h;case 500:return d;case 503:return f;default:return}}},584:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var n=r(893),o=r(935),i=r(156),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.Z)({token:"",expirationTime:-1}),r=[],s=(0,i.Z)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.Vk)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.Z)(l,i,e)}}}}},893:(e,t,r)=>{"use strict";r.d(t,{Z:()=>c});var n=r(935),o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)},i=r(754).Buffer;function a(e,t){return o(o({},t),{headers:o(o({},t.headers),{Authorization:"Bearer ".concat(e)})})}function s(e){var t,r,n,o,s=e.fetcher,c=e.url,u=e.basicAuth,l=e.body,h=e.tokenCache,d=e.requestState,f=e.pendingTasks,p=e.response,y=e.tokenCacheKey;return t=this,r=void 0,o=function(){var e,t,r,n,o,w,v,g,m,b,j;return function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,(function(C){switch(C.label){case 0:return C.trys.push([0,5,,6]),[4,s(c,{method:"POST",headers:{Authorization:"Basic ".concat(u),"Content-Length":i.byteLength(l).toString(),"Content-Type":"application/x-www-form-urlencoded"},body:l})];case 1:return(e=C.sent()).ok?[4,e.json()]:[3,3];case 2:return t=C.sent(),r=t.access_token,n=t.expires_in,o=t.refresh_token,w=function(e){return Date.now()+1e3*e-3e5}(n),h.set({token:r,expirationTime:w,refreshToken:o},y),d.set(!1),v=f.slice(),f=[],v.forEach((function(e){var t=a(r,e.request);e.next(t,e.response)})),[2];case 3:return g=void 0,[4,e.text()];case 4:m=C.sent();try{g=JSON.parse(m)}catch(e){}return b=new Error(g?g.message:m),g&&(b.body=g),d.set(!1),p.reject(b),[3,6];case 5:return j=C.sent(),d.set(!1),p&&"function"==typeof p.reject&&p.reject(j),[3,6];case 6:return[2]}}))},new((n=void 0)||(n=Promise))((function(e,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,s)}c((o=o.apply(t,r||[])).next())}))}function c(e,t,r){var i=e.request,c=e.response,u=e.url,l=e.basicAuth,h=e.body,d=e.pendingTasks,f=e.requestState,p=e.tokenCache,y=e.tokenCacheKey,w=e.fetch;if(!w&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(w||(w=fetch),i.headers&&i.headers.authorization||i.headers&&i.headers.Authorization)t(i,c);else{var v=p.get(y);if(v&&v.token&&Date.now()<v.expirationTime)t(a(v.token,i),c);else if(d.push({request:i,response:c,next:t}),!f.get())if(f.set(!0),v&&v.refreshToken&&(!v.token||v.token&&Date.now()>v.expirationTime)){if(!r)throw new Error("Missing required options");s(o(o({fetcher:w},(0,n.Um)(o(o({},r),{refreshToken:v.refreshToken}))),{tokenCacheKey:y,tokenCache:p,requestState:f,pendingTasks:d,response:c}))}else s({fetcher:w,url:u,basicAuth:l,body:h,tokenCacheKey:y,tokenCache:p,requestState:f,pendingTasks:d,response:c})}}},935:(e,t,r)=>{"use strict";r.d(t,{BB:()=>i,Um:()=>s,Vk:()=>c,_T:()=>a});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=r(754).Buffer;function i(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");var t=e.credentials,r=t.clientId,n=t.clientSecret;if(!r||!n)throw new Error("Missing required credentials (clientId, clientSecret)");var i=e.scopes?e.scopes.join(" "):void 0,a=o.from("".concat(r,":").concat(n)).toString("base64"),s=e.oauthUri||"/oauth/token";return{basicAuth:a,url:e.host.replace(/\/$/,"")+s,body:"grant_type=client_credentials".concat(i?"&scope=".concat(i):"")}}function a(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");var t=e.credentials,r=t.clientId,n=t.clientSecret,i=t.user,a=e.projectKey;if(!(r&&n&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");var s=i.username,c=i.password;if(!s||!c)throw new Error("Missing required user credentials (username, password)");var u=(e.scopes||[]).join(" "),l=u?"&scope=".concat(u):"",h=o.from("".concat(r,":").concat(n)).toString("base64"),d=e.oauthUri||"/oauth/".concat(a,"/customers/token");return{basicAuth:h,url:e.host.replace(/\/$/,"")+d,body:"grant_type=password&username=".concat(encodeURIComponent(s),"&password=").concat(encodeURIComponent(c)).concat(l)}}function s(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");if(!e.refreshToken)throw new Error("Missing required option (refreshToken)");var t=e.credentials,r=t.clientId,n=t.clientSecret;if(!r||!n)throw new Error("Missing required credentials (clientId, clientSecret)");var i=o.from("".concat(r,":").concat(n)).toString("base64"),a=e.oauthUri||"/oauth/token";return{basicAuth:i,url:e.host.replace(/\/$/,"")+a,body:"grant_type=refresh_token&refresh_token=".concat(encodeURIComponent(e.refreshToken))}}function c(e){if(!e)throw new Error("Missing required options");if(!e.projectKey)throw new Error("Missing required option (projectKey)");var t=e.projectKey;e.oauthUri=e.oauthUri||"/oauth/".concat(t,"/anonymous/token");var r=i(e);return e.credentials.anonymousId&&(r.body+="&anonymous_id=".concat(e.credentials.anonymousId)),n({},r)}},554:(e,t,r)=>{"use strict";r.d(t,{Z:()=>c});var n=r(893),o=r(935);function i(e){return{clientId:e.credentials.clientId,host:e.host,projectKey:e.projectKey}}var a=r(156),s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function c(e){var t=e.tokenCache||(0,a.Z)({token:"",expirationTime:-1}),r=(0,a.Z)(!1),c=[];return function(a){return function(u,l){if(u.headers&&u.headers.authorization||u.headers&&u.headers.Authorization)a(u,l);else{var h=s(s({request:u,response:l},(0,o.BB)(e)),{pendingTasks:c,requestState:r,tokenCache:t,tokenCacheKey:i(e),fetch:e.fetch});(0,n.Z)(h,a)}}}}},352:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t){return void 0===e&&(e=""),void 0===t&&(t={}),function(r){return function(o,i){if("string"!=typeof e)throw new Error("authorization must be a string");var a=void 0===t.force||t.force;if(!e||(o.headers&&o.headers.authorization||o.headers&&o.headers.Authorization)&&!1===a)return r(o,i);var s=n(n({},o),{headers:n(n({},o.headers),{Authorization:e})});return r(s,i)}}}},637:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var n=r(893),o=r(935),i=r(156),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.Z)({}),r=[],s=(0,i.Z)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o._T)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.Z)(l,i,e)}}}}},589:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var n=r(893),o=r(935),i=r(156),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.Z)({token:"",expirationTime:-1}),r=[],s=(0,i.Z)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.Um)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.Z)(l,i)}}}}},156:(e,t,r)=>{"use strict";function n(e){var t=e;return{get:function(e){return t},set:function(e,r){t=e}}}r.d(t,{Z:()=>n})},386:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e){return function(t){return function(r,o){var i=n(n({},r),{headers:n(n({},r.headers),{"X-Correlation-ID":e.generate()})});t(i,o)}}}},349:(e,t,r)=>{"use strict";r.d(t,{Z:()=>l});var n=r(754),o=r(109);function i(e){if(e.raw)return e.raw();if(!e.forEach)return{};var t={};return e.forEach((function(e,r){t[r]=e})),t}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function c(e,t,r,n,o){return n&&0!==e?Math.min(Math.round((Math.random()+1)*t*Math.pow(2,e)),o):t}function u(e,t){t&&(e&&e.headers&&e.headers.authorization&&(e.headers.authorization="Bearer ********"),e&&e.headers&&e.headers.Authorization&&(e.headers.Authorization="Bearer ********"))}function l(e){var t,r=e.host,l=e.credentialsMode,h=e.includeResponseHeaders,d=e.includeOriginalRequest,f=e.includeRequestInErrorResponse,p=void 0===f||f,y=e.maskSensitiveHeaderData,w=void 0===y||y,v=e.enableRetry,g=e.timeout,m=e.retryConfig,b=void 0===m?{}:m,j=b.maxRetries,C=void 0===j?10:j,O=b.backoff,M=void 0===O||O,k=b.retryDelay,E=void 0===k?200:k,T=b.maxDelay,A=void 0===T?1/0:T,q=b.retryOnAbort,S=void 0!==q&&q,P=b.retryCodes,Z=void 0===P?[503]:P,I=e.fetch,x=e.getAbortController;if(!I)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(g&&!x)throw new Error("`AbortController` is not available. Please pass in `getAbortController` as an option or have AbortController globally available when using timeout.");if(t=I||fetch,!Array.isArray(Z))throw new Error("`retryCodes` option must be an array of retry status (error) codes.");return function(e){return function(f,y){var m=r.replace(/\/$/,"")+f.uri,b=a({},f.headers);null===b["Content-Type"]&&delete b["Content-Type"],Object.prototype.hasOwnProperty.call(b,"Content-Type")||Object.prototype.hasOwnProperty.call(b,"content-type")||(b["Content-Type"]="application/json");var j=["application/json","application/graphql"].indexOf(b["Content-Type"])>-1&&"string"==typeof f.body||s(f.body)?f.body:JSON.stringify(f.body||void 0);j&&("string"==typeof j||s(j))&&(b["Content-Length"]=n.Buffer.byteLength(j).toString());var O={method:f.method,headers:b};l&&(O.credentialsMode=l),j&&(O.body=j);var k=0;!function r(){var n,s;g&&(s=(x?x():null)||new AbortController,O.signal=s.signal,n=setTimeout((function(){s.abort()}),g)),t(m,O).then((function(t){if(t.ok)return"HEAD"===O.method?void e(f,a(a({},y),{statusCode:t.status})):void t.text().then((function(n){var o;try{o=n.length>0?JSON.parse(n):{}}catch(e){if(v&&k<C)return setTimeout(r,c(k,E,0,M,A)),void(k+=1);o=n}var s=a(a({},y),{body:o,statusCode:t.status});h&&(s.headers=i(t.headers)),d&&(s.request=a({},O),u(s.request,w)),e(f,s)}));t.text().then((function(n){var s;try{s=JSON.parse(n)}catch(l){s=n}var l=function(e){var t=e.statusCode,r=e.message,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["statusCode","message"]),i=r||"Unexpected non-JSON error response";404===t&&(i="URI not found: ".concat(n.originalRequest.uri));var a=(0,o.ZP)(t);return a?new a(i,n):new o.oo(t,i,n)}(a(a(a({statusCode:t.status},p?{originalRequest:f}:{}),{retryCount:k,headers:i(t.headers)}),"object"==typeof s?{message:s.message,body:s}:{message:s,body:s}));if(v&&(-1!==Z.indexOf(l.statusCode)||-1!==(null==Z?void 0:Z.indexOf(l.message)))&&k<C)return setTimeout(r,c(k,E,0,M,A)),void(k+=1);u(l.originalRequest,w);var h=a(a({},y),{error:l,statusCode:t.status});e(f,h)}))}),(function(t){if(v&&(S||!s||!s.signal)&&k<C)return setTimeout(r,c(k,E,0,M,A)),void(k+=1);var n=new o.F7(t.message,a(a({},p?{originalRequest:f}:{}),{retryCount:k}));u(n.originalRequest,w),e(f,a(a({},y),{error:n,statusCode:0}))})).finally((function(){clearTimeout(n)}))}()}}}},357:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var n=r(169);function o(){return function(e){return function(t,r){var o=r.error,i=r.body,a=r.statusCode;n.log("Request: ",t),n.log("Response: ",{error:o,body:i,statusCode:a}),e(t,r)}}}},324:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e){var t=e.concurrency,r=void 0===t?20:t,o=[],i=0,a=function(e){if(i-=1,o.length&&i<=r){var t=o.shift();i+=1,e(t.request,t.response)}};return function(e){return function(t,s){var c=n(n({},s),{resolve:function(t){s.resolve(t),a(e)},reject:function(t){s.reject(t),a(e)}});if(o.push({request:t,response:c}),i<r){var u=o.shift();i+=1,e(u.request,u.response)}}}}},406:(e,t,r)=>{"use strict";r.d(t,{Z:()=>a});var n=r(696);function o(){if("undefined"!=typeof window&&window.document&&9===window.document.nodeType)return window.navigator.userAgent;var e=(null==n?void 0:n.version.slice(1))||"12";return"node.js/".concat(e)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)};function a(e){var t=function(e){if(!e||0===Object.keys(e).length||!{}.hasOwnProperty.call(e,"name"))throw new Error("Missing required option `name`");var t=e.version?"".concat(e.name,"/").concat(e.version):e.name,r=null;e.libraryName&&!e.libraryVersion?r=e.libraryName:e.libraryName&&e.libraryVersion&&(r="".concat(e.libraryName,"/").concat(e.libraryVersion));var n=null;return e.contactUrl&&!e.contactEmail?n="(+".concat(e.contactUrl,")"):!e.contactUrl&&e.contactEmail?n="(+".concat(e.contactEmail,")"):e.contactUrl&&e.contactEmail&&(n="(+".concat(e.contactUrl,"; +").concat(e.contactEmail,")")),[t,o(),r,n,e.customAgent||""].filter(Boolean).join(" ")}(i(i({},e),{name:"commercetools-sdk-javascript-v2/".concat("2.1.1")}));return function(e){return function(r,n){var o=i(i({},r),{headers:i(i({},r.headers),{"User-Agent":t})});e(o,n)}}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{ClientBuilder:()=>e.Z,Process:()=>t.N,createAuthForAnonymousSessionFlow:()=>i.Z,createAuthForClientCredentialsFlow:()=>a.Z,createAuthForPasswordFlow:()=>c.Z,createAuthForRefreshTokenFlow:()=>u.Z,createAuthWithExistingToken:()=>s.Z,createClient:()=>t.Z,createCorrelationIdMiddleware:()=>l.Z,createHttpClient:()=>h.Z,createLoggerMiddleware:()=>d.Z,createQueueMiddleware:()=>f.Z,createUserAgentMiddleware:()=>p.Z,getErrorByCode:()=>o.ZP});var e=r(392),t=r(202),o=r(109),i=r(584),a=r(554),s=r(352),c=r(637),u=r(589),l=r(386),h=r(349),d=r(357),f=r(324),p=r(406),y=r(52),w={};for(const e in y)["default","ClientBuilder","createClient","Process","getErrorByCode","createAuthForAnonymousSessionFlow","createAuthForClientCredentialsFlow","createAuthWithExistingToken","createAuthForPasswordFlow","createAuthForRefreshTokenFlow","createCorrelationIdMiddleware","createHttpClient","createLoggerMiddleware","createQueueMiddleware","createUserAgentMiddleware"].indexOf(e)<0&&(w[e]=()=>y[e]);r.d(n,w)})(),n})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@commercetools/sdk-client-v2"]=t():e["@commercetools/sdk-client-v2"]=t()}(self,(()=>(()=>{var e={754:()=>{},169:()=>{},872:()=>{},696:()=>{},305:()=>{},52:()=>{},392:(e,t,r)=>{"use strict";r.d(t,{Z:()=>C});var n=r(872),o=r.n(n),i=r(202),a=r(584),s=r(554),c=r(352),u=r(637),l=r(589),h=r(386),d=r(349),f=r(357),p=r(324),y=r(406),w=function(){return w=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},w.apply(this,arguments)},v=u.Z,g=a.Z,m=s.Z,b=l.Z,j=c.Z;const C=function(){function e(){this.middlewares=[]}return e.prototype.withProjectKey=function(e){return this.projectKey=e,this},e.prototype.defaultClient=function(e,t,r,n){return this.withClientCredentialsFlow({host:r,projectKey:n||this.projectKey,credentials:t}).withHttpMiddleware({host:e,fetch:o()}).withLoggerMiddleware().withUserAgentMiddleware()},e.prototype.withAuthMiddleware=function(e){return this.authMiddleware=e,this},e.prototype.withMiddleware=function(e){return this.middlewares.push(e),this},e.prototype.withClientCredentialsFlow=function(e){return this.withAuthMiddleware(m(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||""},oauthUri:e.oauthUri||"",scopes:e.scopes,fetch:e.fetch||o()},e)))},e.prototype.withPasswordFlow=function(e){return this.withAuthMiddleware(v(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||"",user:{username:e.credentials.user.username||"",password:e.credentials.user.password||""}},fetch:e.fetch||o()},e)))},e.prototype.withAnonymousSessionFlow=function(e){return this.withAuthMiddleware(g(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||"",anonymousId:e.credentials.anonymousId||""},fetch:e.fetch||o()},e)))},e.prototype.withRefreshTokenFlow=function(e){return this.withAuthMiddleware(b(w({host:e.host||"https://auth.europe-west1.gcp.commercetools.com",projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||"",clientSecret:e.credentials.clientSecret||""},fetch:e.fetch||o(),refreshToken:e.refreshToken||""},e)))},e.prototype.withExistingTokenFlow=function(e,t){return this.withAuthMiddleware(j(e,w({force:t.force||!0},t)))},e.prototype.withHttpMiddleware=function(e){return this.httpMiddleware=(0,d.Z)(w({host:e.host||"https://api.europe-west1.gcp.commercetools.com",fetch:e.fetch||o()},e)),this},e.prototype.withUserAgentMiddleware=function(e){return this.userAgentMiddleware=(0,y.Z)(e),this},e.prototype.withQueueMiddleware=function(e){return this.queueMiddleware=(0,p.Z)(w({concurrency:e.concurrency||20},e)),this},e.prototype.withLoggerMiddleware=function(){return this.loggerMiddleware=(0,f.Z)(),this},e.prototype.withCorrelationIdMiddleware=function(e){return this.correlationIdMiddleware=(0,h.Z)(w({generate:e.generate||null},e)),this},e.prototype.build=function(){var e=this.middlewares.slice();return this.correlationIdMiddleware&&e.push(this.correlationIdMiddleware),this.userAgentMiddleware&&e.push(this.userAgentMiddleware),this.authMiddleware&&e.push(this.authMiddleware),this.queueMiddleware&&e.push(this.queueMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.loggerMiddleware&&e.push(this.loggerMiddleware),(0,i.Z)({middlewares:e})},e}()},202:(e,t,r)=>{"use strict";r.d(t,{Z:()=>f,N:()=>d});var n=r(305),o=r.n(n);const i=["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 a(e,t,r){if(void 0===r&&(r={allowedMethods:i}),!t)throw new Error('The "'.concat(e,'" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if("string"!=typeof t.uri)throw new Error('The "'.concat(e,'" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if(!r.allowedMethods.includes(t.method))throw new Error('The "'.concat(e,'" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'))}var s,c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},c.apply(this,arguments)},u=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},l=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};function h(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===(e=e.filter((function(e){return"function"==typeof e}))).length?e[0]:e.reduce((function(e,t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return e(t.apply(void 0,r))}}))}function d(e,t,r){var n=this;if(a("process",e,{allowedMethods:["GET"]}),"function"!=typeof t)throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');var i=c({total:Number.POSITIVE_INFINITY,accumulate:!0},r);return new Promise((function(r,a){var h,d="";if(e&&e.uri){var p=e.uri.split("?"),y=p[0],w=p[1];h=y,d=w}var v=c({},o().parse(d)),g=c({limit:20},v),m=!1,b=i.total,j=function(d,p){return void 0===p&&(p=[]),u(n,void 0,void 0,(function(){var n,u,y,w,v,C,O,M,k,E,T,A,q,S;return l(this,(function(l){switch(l.label){case 0:n=g.limit<b?g.limit:b,u=o().stringify(c(c({},g),{limit:n})),y=c({sort:"id asc",withTotal:!1},d?{where:'id > "'.concat(d,'"')}:{}),w=o().stringify(y),v=c(c({},e),{uri:"".concat(h,"?").concat(w,"&").concat(u)}),l.label=1;case 1:return l.trys.push([1,4,,5]),[4,f(s).execute(v)];case 2:return C=l.sent(),O=C.body,M=O.results,!(k=O.count)&&m?[2,r(p||[])]:[4,Promise.resolve(t(C))];case 3:return E=l.sent(),T=void 0,m=!0,i.accumulate&&(T=p.concat(E||[])),b-=k,k<g.limit||!b?[2,r(T||[])]:(A=M[k-1],q=A&&A.id,j(q,T),[3,5]);case 4:return S=l.sent(),a(S),[3,5];case 5:return[2]}}))}))};j()}))}function f(e){if(s=e,!e)throw new Error("Missing required options");if(e.middlewares&&!Array.isArray(e.middlewares))throw new Error("Middlewares should be an array");if(!e.middlewares||!Array.isArray(e.middlewares)||!e.middlewares.length)throw new Error("You need to provide at least one middleware");return{process:d,execute:function(t){return a("exec",t),new Promise((function(r,n){h.apply(void 0,e.middlewares)((function(e,t){if(t.error)t.reject(t.error);else{var r={body:t.body||{},statusCode:t.statusCode};t.headers&&(r.headers=t.headers),t.request&&(r.request=t.request),t.resolve(r)}}))(t,{resolve:r,reject:n,body:void 0,error:void 0})}))}}}},109:(e,t,r)=>{"use strict";r.d(t,{F7:()=>i,ZP:()=>p,oo:()=>a});var n=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function o(e,t,r){void 0===r&&(r={}),this.status=this.statusCode=this.code=e,this.message=t,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,0],e,!1))}function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this],e,!1))}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,400],e,!1))}function c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,401],e,!1))}function u(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,403],e,!1))}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,404],e,!1))}function h(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,409],e,!1))}function d(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,500],e,!1))}function f(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.call.apply(o,n([this,503],e,!1))}function p(e){switch(e){case 0:return i;case 400:return s;case 401:return c;case 403:return u;case 404:return l;case 409:return h;case 500:return d;case 503:return f;default:return}}},584:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var n=r(893),o=r(935),i=r(156),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.Z)({token:"",expirationTime:-1}),r=[],s=(0,i.Z)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.Vk)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.Z)(l,i,e)}}}}},893:(e,t,r)=>{"use strict";r.d(t,{Z:()=>l});var n=r(935),o=r(754),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},a=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},s=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};function c(e,t){return i(i({},t),{headers:i(i({},t.headers),{Authorization:"Bearer ".concat(e)})})}function u(e){var t=e.fetcher,r=e.url,n=e.basicAuth,i=e.body,u=e.tokenCache,l=e.requestState,h=e.pendingTasks,d=e.response,f=e.tokenCacheKey;return a(this,void 0,void 0,(function(){var e,a,p,y,w,v,g,m,b,j,C;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),[4,t(r,{method:"POST",headers:{Authorization:"Basic ".concat(n),"Content-Length":o.Buffer.byteLength(i).toString(),"Content-Type":"application/x-www-form-urlencoded"},body:i})];case 1:return(e=s.sent()).ok?[4,e.json()]:[3,3];case 2:return a=s.sent(),p=a.access_token,y=a.expires_in,w=a.refresh_token,v=function(e){return Date.now()+1e3*e-3e5}(y),u.set({token:p,expirationTime:v,refreshToken:w},f),l.set(!1),g=h.slice(),h=[],g.forEach((function(e){var t=c(p,e.request);e.next(t,e.response)})),[2];case 3:return m=void 0,[4,e.text()];case 4:b=s.sent();try{m=JSON.parse(b)}catch(e){}return j=new Error(m?m.message:b),m&&(j.body=m),l.set(!1),d.reject(j),[3,6];case 5:return C=s.sent(),l.set(!1),d&&"function"==typeof d.reject&&d.reject(C),[3,6];case 6:return[2]}}))}))}function l(e,t,r){var o=e.request,a=e.response,s=e.url,l=e.basicAuth,h=e.body,d=e.pendingTasks,f=e.requestState,p=e.tokenCache,y=e.tokenCacheKey,w=e.fetch;if(!w&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(w||(w=fetch),o.headers&&o.headers.authorization||o.headers&&o.headers.Authorization)t(o,a);else{var v=p.get(y);if(v&&v.token&&Date.now()<v.expirationTime)t(c(v.token,o),a);else if(d.push({request:o,response:a,next:t}),!f.get())if(f.set(!0),v&&v.refreshToken&&(!v.token||v.token&&Date.now()>v.expirationTime)){if(!r)throw new Error("Missing required options");u(i(i({fetcher:w},(0,n.Um)(i(i({},r),{refreshToken:v.refreshToken}))),{tokenCacheKey:y,tokenCache:p,requestState:f,pendingTasks:d,response:a}))}else u({fetcher:w,url:s,basicAuth:l,body:h,tokenCacheKey:y,tokenCache:p,requestState:f,pendingTasks:d,response:a})}}},935:(e,t,r)=>{"use strict";r.d(t,{BB:()=>i,Um:()=>s,Vk:()=>c,_T:()=>a});var n=r(754),o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function i(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");var t=e.credentials,r=t.clientId,o=t.clientSecret;if(!r||!o)throw new Error("Missing required credentials (clientId, clientSecret)");var i=e.scopes?e.scopes.join(" "):void 0,a=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),s=e.oauthUri||"/oauth/token";return{basicAuth:a,url:e.host.replace(/\/$/,"")+s,body:"grant_type=client_credentials".concat(i?"&scope=".concat(i):"")}}function a(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");var t=e.credentials,r=t.clientId,o=t.clientSecret,i=t.user,a=e.projectKey;if(!(r&&o&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");var s=i.username,c=i.password;if(!s||!c)throw new Error("Missing required user credentials (username, password)");var u=(e.scopes||[]).join(" "),l=u?"&scope=".concat(u):"",h=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),d=e.oauthUri||"/oauth/".concat(a,"/customers/token");return{basicAuth:h,url:e.host.replace(/\/$/,"")+d,body:"grant_type=password&username=".concat(encodeURIComponent(s),"&password=").concat(encodeURIComponent(c)).concat(l)}}function s(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");if(!e.refreshToken)throw new Error("Missing required option (refreshToken)");var t=e.credentials,r=t.clientId,o=t.clientSecret;if(!r||!o)throw new Error("Missing required credentials (clientId, clientSecret)");var i=n.Buffer.from("".concat(r,":").concat(o)).toString("base64"),a=e.oauthUri||"/oauth/token";return{basicAuth:i,url:e.host.replace(/\/$/,"")+a,body:"grant_type=refresh_token&refresh_token=".concat(encodeURIComponent(e.refreshToken))}}function c(e){if(!e)throw new Error("Missing required options");if(!e.projectKey)throw new Error("Missing required option (projectKey)");var t=e.projectKey;e.oauthUri=e.oauthUri||"/oauth/".concat(t,"/anonymous/token");var r=i(e);return e.credentials.anonymousId&&(r.body+="&anonymous_id=".concat(e.credentials.anonymousId)),o({},r)}},554:(e,t,r)=>{"use strict";r.d(t,{Z:()=>c});var n=r(893),o=r(935);function i(e){return{clientId:e.credentials.clientId,host:e.host,projectKey:e.projectKey}}var a=r(156),s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function c(e){var t=e.tokenCache||(0,a.Z)({token:"",expirationTime:-1}),r=(0,a.Z)(!1),c=[];return function(a){return function(u,l){if(u.headers&&u.headers.authorization||u.headers&&u.headers.Authorization)a(u,l);else{var h=s(s({request:u,response:l},(0,o.BB)(e)),{pendingTasks:c,requestState:r,tokenCache:t,tokenCacheKey:i(e),fetch:e.fetch});(0,n.Z)(h,a)}}}}},352:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t){return void 0===e&&(e=""),void 0===t&&(t={}),function(r){return function(o,i){if("string"!=typeof e)throw new Error("authorization must be a string");var a=void 0===t.force||t.force;if(!e||(o.headers&&o.headers.authorization||o.headers&&o.headers.Authorization)&&!1===a)return r(o,i);var s=n(n({},o),{headers:n(n({},o.headers),{Authorization:e})});return r(s,i)}}}},637:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var n=r(893),o=r(935),i=r(156),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.Z)({}),r=[],s=(0,i.Z)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o._T)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.Z)(l,i,e)}}}}},589:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var n=r(893),o=r(935),i=r(156),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=e.tokenCache||(0,i.Z)({token:"",expirationTime:-1}),r=[],s=(0,i.Z)(!1);return function(i){return function(c,u){if(c.headers&&c.headers.authorization||c.headers&&c.headers.Authorization)i(c,u);else{var l=a(a({request:c,response:u},(0,o.Um)(e)),{pendingTasks:r,requestState:s,tokenCache:t,fetch:e.fetch});(0,n.Z)(l,i)}}}}},156:(e,t,r)=>{"use strict";function n(e){var t=e;return{get:function(e){return t},set:function(e,r){t=e}}}r.d(t,{Z:()=>n})},386:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e){return function(t){return function(r,o){var i=n(n({},r),{headers:n(n({},r.headers),{"X-Correlation-ID":e.generate()})});t(i,o)}}}},349:(e,t,r)=>{"use strict";r.d(t,{Z:()=>h});var n=r(754),o=r(109);function i(e){if(e.raw)return e.raw();if(!e.forEach)return{};var t={};return e.forEach((function(e,r){t[r]=e})),t}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)},s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};function c(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function u(e,t,r,n,o){return n&&0!==e?Math.min(Math.round((Math.random()+1)*t*Math.pow(2,e)),o):t}function l(e,t){t&&(e&&e.headers&&e.headers.authorization&&(e.headers.authorization="Bearer ********"),e&&e.headers&&e.headers.Authorization&&(e.headers.Authorization="Bearer ********"))}function h(e){var t,r=e.host,h=e.credentialsMode,d=e.includeResponseHeaders,f=e.includeOriginalRequest,p=e.includeRequestInErrorResponse,y=void 0===p||p,w=e.maskSensitiveHeaderData,v=void 0===w||w,g=e.enableRetry,m=e.timeout,b=e.retryConfig,j=void 0===b?{}:b,C=j.maxRetries,O=void 0===C?10:C,M=j.backoff,k=void 0===M||M,E=j.retryDelay,T=void 0===E?200:E,A=j.maxDelay,q=void 0===A?1/0:A,S=j.retryOnAbort,P=void 0!==S&&S,Z=j.retryCodes,I=void 0===Z?[503]:Z,x=e.fetch,K=e.getAbortController;if(!x)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(m&&!K)throw new Error("`AbortController` is not available. Please pass in `getAbortController` as an option or have AbortController globally available when using timeout.");if(t=x||fetch,!Array.isArray(I))throw new Error("`retryCodes` option must be an array of retry status (error) codes.");return function(e){return function(p,w){var b=r.replace(/\/$/,"")+p.uri,j=a({},p.headers);null===j["Content-Type"]&&delete j["Content-Type"],Object.prototype.hasOwnProperty.call(j,"Content-Type")||Object.prototype.hasOwnProperty.call(j,"content-type")||(j["Content-Type"]="application/json");var C=["application/json","application/graphql"].indexOf(j["Content-Type"])>-1&&"string"==typeof p.body||c(p.body)?p.body:JSON.stringify(p.body||void 0);C&&("string"==typeof C||c(C))&&(j["Content-Length"]=n.Buffer.byteLength(C).toString());var M={method:p.method,headers:j};h&&(M.credentialsMode=h),C&&(M.body=C);var E=0;!function r(){var n,c;m&&(c=(K?K():null)||new AbortController,M.signal=c.signal,n=setTimeout((function(){c.abort()}),m)),t(b,M).then((function(t){if(t.ok)return"HEAD"===M.method?void e(p,a(a({},w),{statusCode:t.status})):void t.text().then((function(n){var o;try{o=n.length>0?JSON.parse(n):{}}catch(e){if(g&&E<O)return setTimeout(r,u(E,T,0,k,q)),void(E+=1);o=n}var s=a(a({},w),{body:o,statusCode:t.status});d&&(s.headers=i(t.headers)),f&&(s.request=a({},M),l(s.request,v)),e(p,s)}));t.text().then((function(n){var c;try{c=JSON.parse(n)}catch(h){c=n}var h=function(e){var t,r=e.statusCode,n=e.message,i=s(e,["statusCode","message"]),a=n||"Unexpected non-JSON error response";404===r&&(a="URI not found: ".concat((null===(t=i.originalRequest)||void 0===t?void 0:t.uri)||i.uri),delete i.uri);var c=(0,o.ZP)(r);return c?new c(a,i):new o.oo(r,a,i)}(a(a(a({statusCode:t.status},y?{originalRequest:p}:404===t.status?{uri:p.uri}:{}),{retryCount:E,headers:i(t.headers)}),"object"==typeof c?{message:c.message,body:c}:{message:c,body:c}));if(g&&(-1!==I.indexOf(h.statusCode)||-1!==(null==I?void 0:I.indexOf(h.message)))&&E<O)return setTimeout(r,u(E,T,0,k,q)),void(E+=1);l(h.originalRequest,v);var d=a(a({},w),{error:h,statusCode:t.status});e(p,d)}))}),(function(t){if(g&&(P||!c||!c.signal)&&E<O)return setTimeout(r,u(E,T,0,k,q)),void(E+=1);var n=new o.F7(t.message,a(a({},y?{originalRequest:p}:{}),{retryCount:E}));l(n.originalRequest,v),e(p,a(a({},w),{error:n,statusCode:0}))})).finally((function(){clearTimeout(n)}))}()}}}},357:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var n=r(169);function o(){return function(e){return function(t,r){var o=r.error,i=r.body,a=r.statusCode;n.log("Request: ",t),n.log("Response: ",{error:o,body:i,statusCode:a}),e(t,r)}}}},324:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e){var t=e.concurrency,r=void 0===t?20:t,o=[],i=0,a=function(e){if(i-=1,o.length&&i<=r){var t=o.shift();i+=1,e(t.request,t.response)}};return function(e){return function(t,s){var c=n(n({},s),{resolve:function(t){s.resolve(t),a(e)},reject:function(t){s.reject(t),a(e)}});if(o.push({request:t,response:c}),i<r){var u=o.shift();i+=1,e(u.request,u.response)}}}}},406:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});const n={i8:"2.1.3"};var o=r(696),i=function(){return"undefined"!=typeof window&&window.document&&9===window.document.nodeType};var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e){var t=function(e){if(!e||0===Object.keys(e).length||!{}.hasOwnProperty.call(e,"name"))throw new Error("Missing required option `name`");var t=e.version?"".concat(e.name,"/").concat(e.version):e.name,r=null;e.libraryName&&!e.libraryVersion?r=e.libraryName:e.libraryName&&e.libraryVersion&&(r="".concat(e.libraryName,"/").concat(e.libraryVersion));var n=null;return e.contactUrl&&!e.contactEmail?n="(+".concat(e.contactUrl,")"):!e.contactUrl&&e.contactEmail?n="(+".concat(e.contactEmail,")"):e.contactUrl&&e.contactEmail&&(n="(+".concat(e.contactUrl,"; +").concat(e.contactEmail,")")),[t,function(){if(i())return window.navigator.userAgent;var e=(null==o?void 0:o.version.slice(1))||"12";return"node.js/".concat(e)}(),r,n,e.customAgent||""].filter(Boolean).join(" ")}(a(a({},e),{name:"commercetools-sdk-javascript-v2/".concat(n.i8)}));return function(e){return function(r,n){var o=a(a({},r),{headers:a(a({},r.headers),{"User-Agent":t})});e(o,n)}}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{ClientBuilder:()=>e.Z,Process:()=>t.N,createAuthForAnonymousSessionFlow:()=>i.Z,createAuthForClientCredentialsFlow:()=>a.Z,createAuthForPasswordFlow:()=>c.Z,createAuthForRefreshTokenFlow:()=>u.Z,createAuthWithExistingToken:()=>s.Z,createClient:()=>t.Z,createCorrelationIdMiddleware:()=>l.Z,createHttpClient:()=>h.Z,createLoggerMiddleware:()=>d.Z,createQueueMiddleware:()=>f.Z,createUserAgentMiddleware:()=>p.Z,getErrorByCode:()=>o.ZP});var e=r(392),t=r(202),o=r(109),i=r(584),a=r(554),s=r(352),c=r(637),u=r(589),l=r(386),h=r(349),d=r(357),f=r(324),p=r(406),y=r(52),w={};for(const e in y)["default","ClientBuilder","createClient","Process","getErrorByCode","createAuthForAnonymousSessionFlow","createAuthForClientCredentialsFlow","createAuthWithExistingToken","createAuthForPasswordFlow","createAuthForRefreshTokenFlow","createCorrelationIdMiddleware","createHttpClient","createLoggerMiddleware","createQueueMiddleware","createUserAgentMiddleware"].indexOf(e)<0&&(w[e]=()=>y[e]);r.d(n,w)})(),n})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/sdk-client-v2",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "engines": {
5
5
  "node": ">=14"
6
6
  },
@@ -49,7 +49,7 @@
49
49
  "abort-controller": "3.0.0",
50
50
  "common-tags": "1.8.2",
51
51
  "dotenv": "16.0.3",
52
- "jest": "29.3.1",
52
+ "jest": "29.4.2",
53
53
  "nock": "12.0.3",
54
54
  "organize-imports-cli": "0.10.0"
55
55
  },