@kontent-ai/core-sdk 10.7.0 → 10.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sdkInfo = void 0;
4
4
  exports.sdkInfo = {
5
5
  host: 'npmjs.com',
6
- version: '10.7.0',
6
+ version: '10.8.0',
7
7
  name: '@kontent-ai/core-sdk'
8
8
  };
9
9
  //# sourceMappingURL=sdk-info.generated.js.map
@@ -1,6 +1,6 @@
1
1
  export const sdkInfo = {
2
2
  host: 'npmjs.com',
3
- version: '10.7.0',
3
+ version: '10.8.0',
4
4
  name: '@kontent-ai/core-sdk'
5
5
  };
6
6
  //# sourceMappingURL=sdk-info.generated.js.map
@@ -1,6 +1,6 @@
1
1
  export const sdkInfo = {
2
2
  host: 'npmjs.com',
3
- version: '10.7.0',
3
+ version: '10.8.0',
4
4
  name: '@kontent-ai/core-sdk'
5
5
  };
6
6
  //# sourceMappingURL=sdk-info.generated.js.map
@@ -899,7 +899,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
899
899
  \***************************************************/
900
900
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
901
901
 
902
- // Axios v1.7.4 Copyright (c) 2024 Matt Zabriskie and contributors
902
+ // Axios v1.7.7 Copyright (c) 2024 Matt Zabriskie and contributors
903
903
 
904
904
 
905
905
  function bind(fn, thisArg) {
@@ -1690,7 +1690,10 @@ function AxiosError(message, code, config, request, response) {
1690
1690
  code && (this.code = code);
1691
1691
  config && (this.config = config);
1692
1692
  request && (this.request = request);
1693
- response && (this.response = response);
1693
+ if (response) {
1694
+ this.response = response;
1695
+ this.status = response.status ? response.status : null;
1696
+ }
1694
1697
  }
1695
1698
 
1696
1699
  utils$1.inherits(AxiosError, Error, {
@@ -1710,7 +1713,7 @@ utils$1.inherits(AxiosError, Error, {
1710
1713
  // Axios
1711
1714
  config: utils$1.toJSONObject(this.config),
1712
1715
  code: this.code,
1713
- status: this.response && this.response.status ? this.response.status : null
1716
+ status: this.status
1714
1717
  };
1715
1718
  }
1716
1719
  });
@@ -2178,6 +2181,8 @@ var platform$1 = {
2178
2181
 
2179
2182
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2180
2183
 
2184
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
2185
+
2181
2186
  /**
2182
2187
  * Determine if we're running in a standard browser environment
2183
2188
  *
@@ -2195,10 +2200,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
2195
2200
  *
2196
2201
  * @returns {boolean}
2197
2202
  */
2198
- const hasStandardBrowserEnv = (
2199
- (product) => {
2200
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
2201
- })(typeof navigator !== 'undefined' && navigator.product);
2203
+ const hasStandardBrowserEnv = hasBrowserEnv &&
2204
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
2202
2205
 
2203
2206
  /**
2204
2207
  * Determine if we're running in a standard browser webWorker environment
@@ -2225,6 +2228,7 @@ var utils = /*#__PURE__*/Object.freeze({
2225
2228
  hasBrowserEnv: hasBrowserEnv,
2226
2229
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2227
2230
  hasStandardBrowserEnv: hasStandardBrowserEnv,
2231
+ navigator: _navigator,
2228
2232
  origin: origin
2229
2233
  });
2230
2234
 
@@ -3054,7 +3058,7 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
3054
3058
  // Standard browser envs have full support of the APIs needed to test
3055
3059
  // whether the request URL is of the same origin as current location.
3056
3060
  (function standardBrowserEnv() {
3057
- const msie = /(msie|trident)/i.test(navigator.userAgent);
3061
+ const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
3058
3062
  const urlParsingNode = document.createElement('a');
3059
3063
  let originURL;
3060
3064
 
@@ -3534,45 +3538,46 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
3534
3538
  };
3535
3539
 
3536
3540
  const composeSignals = (signals, timeout) => {
3537
- let controller = new AbortController();
3541
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
3538
3542
 
3539
- let aborted;
3543
+ if (timeout || length) {
3544
+ let controller = new AbortController();
3540
3545
 
3541
- const onabort = function (cancel) {
3542
- if (!aborted) {
3543
- aborted = true;
3544
- unsubscribe();
3545
- const err = cancel instanceof Error ? cancel : this.reason;
3546
- controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3547
- }
3548
- };
3546
+ let aborted;
3549
3547
 
3550
- let timer = timeout && setTimeout(() => {
3551
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
3552
- }, timeout);
3548
+ const onabort = function (reason) {
3549
+ if (!aborted) {
3550
+ aborted = true;
3551
+ unsubscribe();
3552
+ const err = reason instanceof Error ? reason : this.reason;
3553
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3554
+ }
3555
+ };
3553
3556
 
3554
- const unsubscribe = () => {
3555
- if (signals) {
3556
- timer && clearTimeout(timer);
3557
+ let timer = timeout && setTimeout(() => {
3557
3558
  timer = null;
3558
- signals.forEach(signal => {
3559
- signal &&
3560
- (signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
3561
- });
3562
- signals = null;
3563
- }
3564
- };
3559
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
3560
+ }, timeout);
3561
+
3562
+ const unsubscribe = () => {
3563
+ if (signals) {
3564
+ timer && clearTimeout(timer);
3565
+ timer = null;
3566
+ signals.forEach(signal => {
3567
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
3568
+ });
3569
+ signals = null;
3570
+ }
3571
+ };
3565
3572
 
3566
- signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
3573
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
3567
3574
 
3568
- const {signal} = controller;
3575
+ const {signal} = controller;
3569
3576
 
3570
- signal.unsubscribe = unsubscribe;
3577
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
3571
3578
 
3572
- return [signal, () => {
3573
- timer && clearTimeout(timer);
3574
- timer = null;
3575
- }];
3579
+ return signal;
3580
+ }
3576
3581
  };
3577
3582
 
3578
3583
  var composeSignals$1 = composeSignals;
@@ -3595,14 +3600,34 @@ const streamChunk = function* (chunk, chunkSize) {
3595
3600
  }
3596
3601
  };
3597
3602
 
3598
- const readBytes = async function* (iterable, chunkSize, encode) {
3599
- for await (const chunk of iterable) {
3600
- yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
3603
+ const readBytes = async function* (iterable, chunkSize) {
3604
+ for await (const chunk of readStream(iterable)) {
3605
+ yield* streamChunk(chunk, chunkSize);
3606
+ }
3607
+ };
3608
+
3609
+ const readStream = async function* (stream) {
3610
+ if (stream[Symbol.asyncIterator]) {
3611
+ yield* stream;
3612
+ return;
3613
+ }
3614
+
3615
+ const reader = stream.getReader();
3616
+ try {
3617
+ for (;;) {
3618
+ const {done, value} = await reader.read();
3619
+ if (done) {
3620
+ break;
3621
+ }
3622
+ yield value;
3623
+ }
3624
+ } finally {
3625
+ await reader.cancel();
3601
3626
  }
3602
3627
  };
3603
3628
 
3604
- const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
3605
- const iterator = readBytes(stream, chunkSize, encode);
3629
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3630
+ const iterator = readBytes(stream, chunkSize);
3606
3631
 
3607
3632
  let bytes = 0;
3608
3633
  let done;
@@ -3705,7 +3730,11 @@ const getBodyLength = async (body) => {
3705
3730
  }
3706
3731
 
3707
3732
  if(utils$1.isSpecCompliantForm(body)) {
3708
- return (await new Request(body).arrayBuffer()).byteLength;
3733
+ const _request = new Request(platform.origin, {
3734
+ method: 'POST',
3735
+ body,
3736
+ });
3737
+ return (await _request.arrayBuffer()).byteLength;
3709
3738
  }
3710
3739
 
3711
3740
  if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
@@ -3745,18 +3774,13 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3745
3774
 
3746
3775
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3747
3776
 
3748
- let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
3749
- composeSignals$1([signal, cancelToken], timeout) : [];
3750
-
3751
- let finished, request;
3777
+ let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3752
3778
 
3753
- const onFinish = () => {
3754
- !finished && setTimeout(() => {
3755
- composedSignal && composedSignal.unsubscribe();
3756
- });
3779
+ let request;
3757
3780
 
3758
- finished = true;
3759
- };
3781
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3782
+ composedSignal.unsubscribe();
3783
+ });
3760
3784
 
3761
3785
  let requestContentLength;
3762
3786
 
@@ -3783,7 +3807,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3783
3807
  progressEventReducer(asyncDecorator(onUploadProgress))
3784
3808
  );
3785
3809
 
3786
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush, encodeText);
3810
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3787
3811
  }
3788
3812
  }
3789
3813
 
@@ -3791,6 +3815,9 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3791
3815
  withCredentials = withCredentials ? 'include' : 'omit';
3792
3816
  }
3793
3817
 
3818
+ // Cloudflare Workers throws when credentials are defined
3819
+ // see https://github.com/cloudflare/workerd/issues/902
3820
+ const isCredentialsSupported = "credentials" in Request.prototype;
3794
3821
  request = new Request(url, {
3795
3822
  ...fetchOptions,
3796
3823
  signal: composedSignal,
@@ -3798,14 +3825,14 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3798
3825
  headers: headers.normalize().toJSON(),
3799
3826
  body: data,
3800
3827
  duplex: "half",
3801
- credentials: withCredentials
3828
+ credentials: isCredentialsSupported ? withCredentials : undefined
3802
3829
  });
3803
3830
 
3804
3831
  let response = await fetch(request);
3805
3832
 
3806
3833
  const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3807
3834
 
3808
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
3835
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3809
3836
  const options = {};
3810
3837
 
3811
3838
  ['status', 'statusText', 'headers'].forEach(prop => {
@@ -3822,8 +3849,8 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3822
3849
  response = new Response(
3823
3850
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3824
3851
  flush && flush();
3825
- isStreamResponse && onFinish();
3826
- }, encodeText),
3852
+ unsubscribe && unsubscribe();
3853
+ }),
3827
3854
  options
3828
3855
  );
3829
3856
  }
@@ -3832,9 +3859,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3832
3859
 
3833
3860
  let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3834
3861
 
3835
- !isStreamResponse && onFinish();
3836
-
3837
- stopTimeout && stopTimeout();
3862
+ !isStreamResponse && unsubscribe && unsubscribe();
3838
3863
 
3839
3864
  return await new Promise((resolve, reject) => {
3840
3865
  settle(resolve, reject, {
@@ -3847,7 +3872,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3847
3872
  });
3848
3873
  })
3849
3874
  } catch (err) {
3850
- onFinish();
3875
+ unsubscribe && unsubscribe();
3851
3876
 
3852
3877
  if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3853
3878
  throw Object.assign(
@@ -4009,7 +4034,7 @@ function dispatchRequest(config) {
4009
4034
  });
4010
4035
  }
4011
4036
 
4012
- const VERSION = "1.7.4";
4037
+ const VERSION = "1.7.7";
4013
4038
 
4014
4039
  const validators$1 = {};
4015
4040
 
@@ -4416,6 +4441,20 @@ class CancelToken {
4416
4441
  }
4417
4442
  }
4418
4443
 
4444
+ toAbortSignal() {
4445
+ const controller = new AbortController();
4446
+
4447
+ const abort = (err) => {
4448
+ controller.abort(err);
4449
+ };
4450
+
4451
+ this.subscribe(abort);
4452
+
4453
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
4454
+
4455
+ return controller.signal;
4456
+ }
4457
+
4419
4458
  /**
4420
4459
  * Returns an object that contains a new `CancelToken` and a function that, when called,
4421
4460
  * cancels the `CancelToken`.