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.
@@ -249,7 +249,7 @@ var del = function del(http, params, headers) {
249
249
  var publish = function publish(http, params, rawData, headers) {
250
250
  return _raw__WEBPACK_IMPORTED_MODULE_1__.put(http, "/spaces/".concat(params.spaceId, "/ai/actions/").concat(params.aiActionId, "/published"), null, {
251
251
  headers: _objectSpread({
252
- 'X-Contentful-Version': rawData.sys.version
252
+ 'X-Contentful-Version': params.version
253
253
  }, headers)
254
254
  });
255
255
  };
@@ -13385,18 +13385,16 @@ function createSpaceApi(makeRequest) {
13385
13385
  * .catch(console.error)
13386
13386
  * ```
13387
13387
  */
13388
- publishAiAction: function publishAiAction(aiActionId, data) {
13388
+ publishAiAction: function publishAiAction(aiActionId, _ref4) {
13389
+ var version = _ref4.version;
13389
13390
  var raw = this.toPlainObject();
13390
13391
  return makeRequest({
13391
13392
  entityType: 'AiAction',
13392
13393
  action: 'publish',
13393
13394
  params: {
13394
13395
  spaceId: raw.sys.id,
13395
- aiActionId: aiActionId
13396
- },
13397
- payload: data,
13398
- headers: {
13399
- 'X-Contentful-Version': data.sys.version
13396
+ aiActionId: aiActionId,
13397
+ version: version
13400
13398
  }
13401
13399
  }).then(function (response) {
13402
13400
  return wrapAiAction(makeRequest, response);
@@ -13877,8 +13875,11 @@ function createAiActionApi(makeRequest) {
13877
13875
  return makeRequest({
13878
13876
  entityType: 'AiAction',
13879
13877
  action: 'publish',
13880
- params: getParams(self),
13881
- payload: self
13878
+ params: {
13879
+ aiActionId: self.sys.id,
13880
+ spaceId: self.sys.space.sys.id,
13881
+ version: self.sys.version
13882
+ }
13882
13883
  }).then(function (data) {
13883
13884
  return wrapAiAction(makeRequest, data);
13884
13885
  });
@@ -28096,6 +28097,18 @@ __webpack_require__.r(__webpack_exports__);
28096
28097
  /* harmony export */ });
28097
28098
  /* harmony import */ var lodash_isPlainObject_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/isPlainObject.js */ "../node_modules/lodash/isPlainObject.js");
28098
28099
 
28100
+ function obscureHeaders(config) {
28101
+ // Management, Delivery and Preview API tokens
28102
+ if (config?.headers?.['Authorization']) {
28103
+ const token = `...${config.headers['Authorization'].toString().substr(-5)}`;
28104
+ config.headers['Authorization'] = `Bearer ${token}`;
28105
+ }
28106
+ // Encoded Delivery or Preview token map for Cross-Space References
28107
+ if (config?.headers?.['X-Contentful-Resource-Resolution']) {
28108
+ const token = `...${config.headers['X-Contentful-Resource-Resolution'].toString().substr(-5)}`;
28109
+ config.headers['X-Contentful-Resource-Resolution'] = token;
28110
+ }
28111
+ }
28099
28112
  /**
28100
28113
  * Handles errors received from the server. Parses the error into a more useful
28101
28114
  * format, places it in an exception and throws it.
@@ -28107,11 +28120,7 @@ __webpack_require__.r(__webpack_exports__);
28107
28120
  function errorHandler(errorResponse) {
28108
28121
  const { config, response } = errorResponse;
28109
28122
  let errorName;
28110
- // Obscure the Management token
28111
- if (config && config.headers && config.headers['Authorization']) {
28112
- const token = `...${config.headers['Authorization'].toString().substr(-5)}`;
28113
- config.headers['Authorization'] = `Bearer ${token}`;
28114
- }
28123
+ obscureHeaders(config);
28115
28124
  if (!lodash_isPlainObject_js__WEBPACK_IMPORTED_MODULE_0__(response) || !lodash_isPlainObject_js__WEBPACK_IMPORTED_MODULE_0__(config)) {
28116
28125
  throw errorResponse;
28117
28126
  }
@@ -29268,7 +29277,7 @@ function createClient(params) {
29268
29277
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
29269
29278
  var sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
29270
29279
  var userAgent = (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.getUserAgentHeader)(// @ts-expect-error
29271
- "".concat(sdkMain, "/").concat("11.50.0"), params.application, params.integration, params.feature);
29280
+ "".concat(sdkMain, "/").concat("11.51.0"), params.application, params.integration, params.feature);
29272
29281
  var adapter = (0,_create_adapter__WEBPACK_IMPORTED_MODULE_1__.createAdapter)(_objectSpread(_objectSpread({}, params), {}, {
29273
29282
  userAgent: userAgent
29274
29283
  }));