contentful-management 11.50.0 → 11.51.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.
@@ -711,7 +711,7 @@ const del = (http, params, headers) => {
711
711
  const publish = (http, params, rawData, headers) => {
712
712
  return _raw__WEBPACK_IMPORTED_MODULE_1__.put(http, `/spaces/${params.spaceId}/ai/actions/${params.aiActionId}/published`, null, {
713
713
  headers: _objectSpread({
714
- 'X-Contentful-Version': rawData.sys.version
714
+ 'X-Contentful-Version': params.version
715
715
  }, headers)
716
716
  });
717
717
  };
@@ -12961,18 +12961,17 @@ function createSpaceApi(makeRequest) {
12961
12961
  * .catch(console.error)
12962
12962
  * ```
12963
12963
  */
12964
- publishAiAction(aiActionId, data) {
12964
+ publishAiAction(aiActionId, {
12965
+ version
12966
+ }) {
12965
12967
  const raw = this.toPlainObject();
12966
12968
  return makeRequest({
12967
12969
  entityType: 'AiAction',
12968
12970
  action: 'publish',
12969
12971
  params: {
12970
12972
  spaceId: raw.sys.id,
12971
- aiActionId
12972
- },
12973
- payload: data,
12974
- headers: {
12975
- 'X-Contentful-Version': data.sys.version
12973
+ aiActionId,
12974
+ version
12976
12975
  }
12977
12976
  }).then(response => wrapAiAction(makeRequest, response));
12978
12977
  },
@@ -13409,8 +13408,11 @@ function createAiActionApi(makeRequest) {
13409
13408
  return makeRequest({
13410
13409
  entityType: 'AiAction',
13411
13410
  action: 'publish',
13412
- params: getParams(self),
13413
- payload: self
13411
+ params: {
13412
+ aiActionId: self.sys.id,
13413
+ spaceId: self.sys.space.sys.id,
13414
+ version: self.sys.version
13415
+ }
13414
13416
  }).then(data => wrapAiAction(makeRequest, data));
13415
13417
  },
13416
13418
  unpublish: function unpublish() {
@@ -31416,6 +31418,18 @@ __webpack_require__.r(__webpack_exports__);
31416
31418
  /* harmony export */ });
31417
31419
  /* harmony import */ var lodash_isPlainObject_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/isPlainObject.js */ "../node_modules/lodash/isPlainObject.js");
31418
31420
 
31421
+ function obscureHeaders(config) {
31422
+ // Management, Delivery and Preview API tokens
31423
+ if (config?.headers?.['Authorization']) {
31424
+ const token = `...${config.headers['Authorization'].toString().substr(-5)}`;
31425
+ config.headers['Authorization'] = `Bearer ${token}`;
31426
+ }
31427
+ // Encoded Delivery or Preview token map for Cross-Space References
31428
+ if (config?.headers?.['X-Contentful-Resource-Resolution']) {
31429
+ const token = `...${config.headers['X-Contentful-Resource-Resolution'].toString().substr(-5)}`;
31430
+ config.headers['X-Contentful-Resource-Resolution'] = token;
31431
+ }
31432
+ }
31419
31433
  /**
31420
31434
  * Handles errors received from the server. Parses the error into a more useful
31421
31435
  * format, places it in an exception and throws it.
@@ -31427,11 +31441,7 @@ __webpack_require__.r(__webpack_exports__);
31427
31441
  function errorHandler(errorResponse) {
31428
31442
  const { config, response } = errorResponse;
31429
31443
  let errorName;
31430
- // Obscure the Management token
31431
- if (config && config.headers && config.headers['Authorization']) {
31432
- const token = `...${config.headers['Authorization'].toString().substr(-5)}`;
31433
- config.headers['Authorization'] = `Bearer ${token}`;
31434
- }
31444
+ obscureHeaders(config);
31435
31445
  if (!lodash_isPlainObject_js__WEBPACK_IMPORTED_MODULE_0__(response) || !lodash_isPlainObject_js__WEBPACK_IMPORTED_MODULE_0__(config)) {
31436
31446
  throw errorResponse;
31437
31447
  }
@@ -32589,7 +32599,7 @@ function createClient(params, opts = {}) {
32589
32599
  const sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
32590
32600
  const userAgent = (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.getUserAgentHeader)(
32591
32601
  // @ts-expect-error
32592
- `${sdkMain}/${"11.50.0"}`, params.application, params.integration, params.feature);
32602
+ `${sdkMain}/${"11.51.0"}`, params.application, params.integration, params.feature);
32593
32603
  const adapter = (0,_create_adapter__WEBPACK_IMPORTED_MODULE_1__.createAdapter)(_objectSpread(_objectSpread({}, params), {}, {
32594
32604
  userAgent
32595
32605
  }));