@kontent-ai/core-sdk 10.7.0 → 10.9.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.9.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.9.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.9.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.9 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
  });
@@ -2050,7 +2053,7 @@ function encode(val) {
2050
2053
  *
2051
2054
  * @param {string} url The base of the url (e.g., http://www.google.com)
2052
2055
  * @param {object} [params] The params to be appended
2053
- * @param {?object} options
2056
+ * @param {?(object|Function)} options
2054
2057
  *
2055
2058
  * @returns {string} The formatted url
2056
2059
  */
@@ -2062,6 +2065,12 @@ function buildURL(url, params, options) {
2062
2065
 
2063
2066
  const _encode = options && options.encode || encode;
2064
2067
 
2068
+ if (utils$1.isFunction(options)) {
2069
+ options = {
2070
+ serialize: options
2071
+ };
2072
+ }
2073
+
2065
2074
  const serializeFn = options && options.serialize;
2066
2075
 
2067
2076
  let serializedParams;
@@ -2178,6 +2187,8 @@ var platform$1 = {
2178
2187
 
2179
2188
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2180
2189
 
2190
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
2191
+
2181
2192
  /**
2182
2193
  * Determine if we're running in a standard browser environment
2183
2194
  *
@@ -2195,10 +2206,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
2195
2206
  *
2196
2207
  * @returns {boolean}
2197
2208
  */
2198
- const hasStandardBrowserEnv = (
2199
- (product) => {
2200
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
2201
- })(typeof navigator !== 'undefined' && navigator.product);
2209
+ const hasStandardBrowserEnv = hasBrowserEnv &&
2210
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
2202
2211
 
2203
2212
  /**
2204
2213
  * Determine if we're running in a standard browser webWorker environment
@@ -2225,6 +2234,7 @@ var utils = /*#__PURE__*/Object.freeze({
2225
2234
  hasBrowserEnv: hasBrowserEnv,
2226
2235
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2227
2236
  hasStandardBrowserEnv: hasStandardBrowserEnv,
2237
+ navigator: _navigator,
2228
2238
  origin: origin
2229
2239
  });
2230
2240
 
@@ -3049,68 +3059,18 @@ const progressEventDecorator = (total, throttled) => {
3049
3059
 
3050
3060
  const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
3051
3061
 
3052
- var isURLSameOrigin = platform.hasStandardBrowserEnv ?
3053
-
3054
- // Standard browser envs have full support of the APIs needed to test
3055
- // whether the request URL is of the same origin as current location.
3056
- (function standardBrowserEnv() {
3057
- const msie = /(msie|trident)/i.test(navigator.userAgent);
3058
- const urlParsingNode = document.createElement('a');
3059
- let originURL;
3060
-
3061
- /**
3062
- * Parse a URL to discover its components
3063
- *
3064
- * @param {String} url The URL to be parsed
3065
- * @returns {Object}
3066
- */
3067
- function resolveURL(url) {
3068
- let href = url;
3069
-
3070
- if (msie) {
3071
- // IE needs attribute set twice to normalize properties
3072
- urlParsingNode.setAttribute('href', href);
3073
- href = urlParsingNode.href;
3074
- }
3075
-
3076
- urlParsingNode.setAttribute('href', href);
3077
-
3078
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
3079
- return {
3080
- href: urlParsingNode.href,
3081
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
3082
- host: urlParsingNode.host,
3083
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
3084
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
3085
- hostname: urlParsingNode.hostname,
3086
- port: urlParsingNode.port,
3087
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
3088
- urlParsingNode.pathname :
3089
- '/' + urlParsingNode.pathname
3090
- };
3091
- }
3092
-
3093
- originURL = resolveURL(window.location.href);
3062
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
3063
+ url = new URL(url, platform.origin);
3094
3064
 
3095
- /**
3096
- * Determine if a URL shares the same origin as the current location
3097
- *
3098
- * @param {String} requestURL The URL to test
3099
- * @returns {boolean} True if URL shares the same origin, otherwise false
3100
- */
3101
- return function isURLSameOrigin(requestURL) {
3102
- const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
3103
- return (parsed.protocol === originURL.protocol &&
3104
- parsed.host === originURL.host);
3105
- };
3106
- })() :
3107
-
3108
- // Non standard browser envs (web workers, react-native) lack needed support.
3109
- (function nonStandardBrowserEnv() {
3110
- return function isURLSameOrigin() {
3111
- return true;
3112
- };
3113
- })();
3065
+ return (
3066
+ origin.protocol === url.protocol &&
3067
+ origin.host === url.host &&
3068
+ (isMSIE || origin.port === url.port)
3069
+ );
3070
+ })(
3071
+ new URL(platform.origin),
3072
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
3073
+ ) : () => true;
3114
3074
 
3115
3075
  var cookies = platform.hasStandardBrowserEnv ?
3116
3076
 
@@ -3212,7 +3172,7 @@ function mergeConfig(config1, config2) {
3212
3172
  config2 = config2 || {};
3213
3173
  const config = {};
3214
3174
 
3215
- function getMergedValue(target, source, caseless) {
3175
+ function getMergedValue(target, source, prop, caseless) {
3216
3176
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
3217
3177
  return utils$1.merge.call({caseless}, target, source);
3218
3178
  } else if (utils$1.isPlainObject(source)) {
@@ -3224,11 +3184,11 @@ function mergeConfig(config1, config2) {
3224
3184
  }
3225
3185
 
3226
3186
  // eslint-disable-next-line consistent-return
3227
- function mergeDeepProperties(a, b, caseless) {
3187
+ function mergeDeepProperties(a, b, prop , caseless) {
3228
3188
  if (!utils$1.isUndefined(b)) {
3229
- return getMergedValue(a, b, caseless);
3189
+ return getMergedValue(a, b, prop , caseless);
3230
3190
  } else if (!utils$1.isUndefined(a)) {
3231
- return getMergedValue(undefined, a, caseless);
3191
+ return getMergedValue(undefined, a, prop , caseless);
3232
3192
  }
3233
3193
  }
3234
3194
 
@@ -3286,7 +3246,7 @@ function mergeConfig(config1, config2) {
3286
3246
  socketPath: defaultToConfig2,
3287
3247
  responseEncoding: defaultToConfig2,
3288
3248
  validateStatus: mergeDirectKeys,
3289
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
3249
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
3290
3250
  };
3291
3251
 
3292
3252
  utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
@@ -3534,45 +3494,46 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
3534
3494
  };
3535
3495
 
3536
3496
  const composeSignals = (signals, timeout) => {
3537
- let controller = new AbortController();
3497
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
3538
3498
 
3539
- let aborted;
3499
+ if (timeout || length) {
3500
+ let controller = new AbortController();
3540
3501
 
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
- };
3502
+ let aborted;
3549
3503
 
3550
- let timer = timeout && setTimeout(() => {
3551
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
3552
- }, timeout);
3504
+ const onabort = function (reason) {
3505
+ if (!aborted) {
3506
+ aborted = true;
3507
+ unsubscribe();
3508
+ const err = reason instanceof Error ? reason : this.reason;
3509
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3510
+ }
3511
+ };
3553
3512
 
3554
- const unsubscribe = () => {
3555
- if (signals) {
3556
- timer && clearTimeout(timer);
3513
+ let timer = timeout && setTimeout(() => {
3557
3514
  timer = null;
3558
- signals.forEach(signal => {
3559
- signal &&
3560
- (signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
3561
- });
3562
- signals = null;
3563
- }
3564
- };
3515
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
3516
+ }, timeout);
3517
+
3518
+ const unsubscribe = () => {
3519
+ if (signals) {
3520
+ timer && clearTimeout(timer);
3521
+ timer = null;
3522
+ signals.forEach(signal => {
3523
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
3524
+ });
3525
+ signals = null;
3526
+ }
3527
+ };
3565
3528
 
3566
- signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
3529
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
3567
3530
 
3568
- const {signal} = controller;
3531
+ const {signal} = controller;
3569
3532
 
3570
- signal.unsubscribe = unsubscribe;
3533
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
3571
3534
 
3572
- return [signal, () => {
3573
- timer && clearTimeout(timer);
3574
- timer = null;
3575
- }];
3535
+ return signal;
3536
+ }
3576
3537
  };
3577
3538
 
3578
3539
  var composeSignals$1 = composeSignals;
@@ -3595,14 +3556,34 @@ const streamChunk = function* (chunk, chunkSize) {
3595
3556
  }
3596
3557
  };
3597
3558
 
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);
3559
+ const readBytes = async function* (iterable, chunkSize) {
3560
+ for await (const chunk of readStream(iterable)) {
3561
+ yield* streamChunk(chunk, chunkSize);
3601
3562
  }
3602
3563
  };
3603
3564
 
3604
- const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
3605
- const iterator = readBytes(stream, chunkSize, encode);
3565
+ const readStream = async function* (stream) {
3566
+ if (stream[Symbol.asyncIterator]) {
3567
+ yield* stream;
3568
+ return;
3569
+ }
3570
+
3571
+ const reader = stream.getReader();
3572
+ try {
3573
+ for (;;) {
3574
+ const {done, value} = await reader.read();
3575
+ if (done) {
3576
+ break;
3577
+ }
3578
+ yield value;
3579
+ }
3580
+ } finally {
3581
+ await reader.cancel();
3582
+ }
3583
+ };
3584
+
3585
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3586
+ const iterator = readBytes(stream, chunkSize);
3606
3587
 
3607
3588
  let bytes = 0;
3608
3589
  let done;
@@ -3705,7 +3686,11 @@ const getBodyLength = async (body) => {
3705
3686
  }
3706
3687
 
3707
3688
  if(utils$1.isSpecCompliantForm(body)) {
3708
- return (await new Request(body).arrayBuffer()).byteLength;
3689
+ const _request = new Request(platform.origin, {
3690
+ method: 'POST',
3691
+ body,
3692
+ });
3693
+ return (await _request.arrayBuffer()).byteLength;
3709
3694
  }
3710
3695
 
3711
3696
  if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
@@ -3745,18 +3730,13 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3745
3730
 
3746
3731
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3747
3732
 
3748
- let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
3749
- composeSignals$1([signal, cancelToken], timeout) : [];
3750
-
3751
- let finished, request;
3733
+ let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3752
3734
 
3753
- const onFinish = () => {
3754
- !finished && setTimeout(() => {
3755
- composedSignal && composedSignal.unsubscribe();
3756
- });
3735
+ let request;
3757
3736
 
3758
- finished = true;
3759
- };
3737
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3738
+ composedSignal.unsubscribe();
3739
+ });
3760
3740
 
3761
3741
  let requestContentLength;
3762
3742
 
@@ -3783,7 +3763,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3783
3763
  progressEventReducer(asyncDecorator(onUploadProgress))
3784
3764
  );
3785
3765
 
3786
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush, encodeText);
3766
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3787
3767
  }
3788
3768
  }
3789
3769
 
@@ -3791,6 +3771,9 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3791
3771
  withCredentials = withCredentials ? 'include' : 'omit';
3792
3772
  }
3793
3773
 
3774
+ // Cloudflare Workers throws when credentials are defined
3775
+ // see https://github.com/cloudflare/workerd/issues/902
3776
+ const isCredentialsSupported = "credentials" in Request.prototype;
3794
3777
  request = new Request(url, {
3795
3778
  ...fetchOptions,
3796
3779
  signal: composedSignal,
@@ -3798,14 +3781,14 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3798
3781
  headers: headers.normalize().toJSON(),
3799
3782
  body: data,
3800
3783
  duplex: "half",
3801
- credentials: withCredentials
3784
+ credentials: isCredentialsSupported ? withCredentials : undefined
3802
3785
  });
3803
3786
 
3804
3787
  let response = await fetch(request);
3805
3788
 
3806
3789
  const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3807
3790
 
3808
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
3791
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3809
3792
  const options = {};
3810
3793
 
3811
3794
  ['status', 'statusText', 'headers'].forEach(prop => {
@@ -3822,8 +3805,8 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3822
3805
  response = new Response(
3823
3806
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3824
3807
  flush && flush();
3825
- isStreamResponse && onFinish();
3826
- }, encodeText),
3808
+ unsubscribe && unsubscribe();
3809
+ }),
3827
3810
  options
3828
3811
  );
3829
3812
  }
@@ -3832,9 +3815,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3832
3815
 
3833
3816
  let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3834
3817
 
3835
- !isStreamResponse && onFinish();
3836
-
3837
- stopTimeout && stopTimeout();
3818
+ !isStreamResponse && unsubscribe && unsubscribe();
3838
3819
 
3839
3820
  return await new Promise((resolve, reject) => {
3840
3821
  settle(resolve, reject, {
@@ -3847,7 +3828,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3847
3828
  });
3848
3829
  })
3849
3830
  } catch (err) {
3850
- onFinish();
3831
+ unsubscribe && unsubscribe();
3851
3832
 
3852
3833
  if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3853
3834
  throw Object.assign(
@@ -4009,7 +3990,7 @@ function dispatchRequest(config) {
4009
3990
  });
4010
3991
  }
4011
3992
 
4012
- const VERSION = "1.7.4";
3993
+ const VERSION = "1.7.9";
4013
3994
 
4014
3995
  const validators$1 = {};
4015
3996
 
@@ -4060,6 +4041,14 @@ validators$1.transitional = function transitional(validator, version, message) {
4060
4041
  };
4061
4042
  };
4062
4043
 
4044
+ validators$1.spelling = function spelling(correctSpelling) {
4045
+ return (value, opt) => {
4046
+ // eslint-disable-next-line no-console
4047
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
4048
+ return true;
4049
+ }
4050
+ };
4051
+
4063
4052
  /**
4064
4053
  * Assert object's properties type
4065
4054
  *
@@ -4129,9 +4118,9 @@ class Axios {
4129
4118
  return await this._request(configOrUrl, config);
4130
4119
  } catch (err) {
4131
4120
  if (err instanceof Error) {
4132
- let dummy;
4121
+ let dummy = {};
4133
4122
 
4134
- Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
4123
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
4135
4124
 
4136
4125
  // slice off the Error: ... line
4137
4126
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
@@ -4186,6 +4175,11 @@ class Axios {
4186
4175
  }
4187
4176
  }
4188
4177
 
4178
+ validator.assertOptions(config, {
4179
+ baseUrl: validators.spelling('baseURL'),
4180
+ withXsrfToken: validators.spelling('withXSRFToken')
4181
+ }, true);
4182
+
4189
4183
  // Set config.method
4190
4184
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
4191
4185
 
@@ -4416,6 +4410,20 @@ class CancelToken {
4416
4410
  }
4417
4411
  }
4418
4412
 
4413
+ toAbortSignal() {
4414
+ const controller = new AbortController();
4415
+
4416
+ const abort = (err) => {
4417
+ controller.abort(err);
4418
+ };
4419
+
4420
+ this.subscribe(abort);
4421
+
4422
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
4423
+
4424
+ return controller.signal;
4425
+ }
4426
+
4419
4427
  /**
4420
4428
  * Returns an object that contains a new `CancelToken` and a function that, when called,
4421
4429
  * cancels the `CancelToken`.