contentful-management 11.71.0 → 11.72.1

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.
@@ -8197,7 +8197,8 @@ function createEnvironmentApi(makeRequest) {
8197
8197
  wrapAgentCollection = _entities$agent.wrapAgentCollection;
8198
8198
  var _entities$agentRun = _entities__WEBPACK_IMPORTED_MODULE_2__["default"].agentRun,
8199
8199
  wrapAgentRun = _entities$agentRun.wrapAgentRun,
8200
- wrapAgentRunCollection = _entities$agentRun.wrapAgentRunCollection;
8200
+ wrapAgentRunCollection = _entities$agentRun.wrapAgentRunCollection,
8201
+ wrapAgentGenerateResponse = _entities$agentRun.wrapAgentGenerateResponse;
8201
8202
  var wrapResourceTypesForEnvironmentCollection = _entities__WEBPACK_IMPORTED_MODULE_2__["default"].resourceType.wrapResourceTypesForEnvironmentCollection;
8202
8203
  var wrapResourceCollection = _entities__WEBPACK_IMPORTED_MODULE_2__["default"].resource.wrapResourceCollection;
8203
8204
  var wrapSemanticDuplicates = _entities__WEBPACK_IMPORTED_MODULE_2__["default"].semanticDuplicates.wrapSemanticDuplicates;
@@ -11214,31 +11215,38 @@ function createEnvironmentApi(makeRequest) {
11214
11215
  * Generates content using an AI Agent
11215
11216
  * @param agentId - AI Agent ID
11216
11217
  * @param payload - Generation payload
11217
- * @return Promise for the generation response
11218
+ * @return Promise for a simplified response containing `sys.id`, `sys.type`, and `sys.status`.
11219
+ * Use `getAgentRun()` with the returned `sys.id` to poll for full results.
11218
11220
  * @example ```javascript
11219
11221
  * const contentful = require('contentful-management')
11220
11222
  *
11221
- * const client = contentful.createClient({
11222
- * accessToken: '<content_management_api_key>'
11223
- * })
11223
+ * async function generateContent() {
11224
+ * const client = contentful.createClient({
11225
+ * accessToken: '<content_management_api_key>'
11226
+ * })
11224
11227
  *
11225
- * client.getSpace('<space_id>')
11226
- * .then((space) => space.getEnvironment('<environment_id>'))
11227
- * .then((environment) => environment.generateWithAgent('<agent_id>', {
11228
+ * const space = await client.getSpace('<space_id>')
11229
+ * const environment = await space.getEnvironment('<environment_id>')
11230
+ *
11231
+ * // Start generation (returns 202 Accepted)
11232
+ * const response = await environment.generateWithAgent('<agent_id>', {
11228
11233
  * messages: [
11229
11234
  * {
11230
- * parts: [
11231
- * {
11232
- * type: 'text',
11233
- * text: 'Write a short poem about Contentful'
11234
- * }
11235
- * ],
11235
+ * parts: [{ type: 'text', text: 'Write a short poem about Contentful' }],
11236
11236
  * role: 'user'
11237
11237
  * }
11238
11238
  * ]
11239
- * }))
11240
- * .then((result) => console.log(result))
11241
- * .catch(console.error)
11239
+ * })
11240
+ *
11241
+ * // Poll for full results
11242
+ * let run = await environment.getAgentRun(response.sys.id)
11243
+ * while (run.sys.status === 'IN_PROGRESS') {
11244
+ * await new Promise((resolve) => setTimeout(resolve, 1000))
11245
+ * run = await environment.getAgentRun(response.sys.id)
11246
+ * }
11247
+ *
11248
+ * console.log(run)
11249
+ * }
11242
11250
  * ```
11243
11251
  */
11244
11252
  generateWithAgent: function generateWithAgent(agentId, payload) {
@@ -11253,7 +11261,7 @@ function createEnvironmentApi(makeRequest) {
11253
11261
  },
11254
11262
  payload: payload
11255
11263
  }).then(function (data) {
11256
- return wrapAgentRun(makeRequest, data);
11264
+ return wrapAgentGenerateResponse(makeRequest, data);
11257
11265
  });
11258
11266
  },
11259
11267
  /**
@@ -15229,6 +15237,7 @@ var wrapAccessTokenCollection = (0,_common_utils__WEBPACK_IMPORTED_MODULE_3__.wr
15229
15237
  "use strict";
15230
15238
  __webpack_require__.r(__webpack_exports__);
15231
15239
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
15240
+ /* harmony export */ wrapAgentGenerateResponse: function() { return /* binding */ wrapAgentGenerateResponse; },
15232
15241
  /* harmony export */ wrapAgentRun: function() { return /* binding */ wrapAgentRun; },
15233
15242
  /* harmony export */ wrapAgentRunCollection: function() { return /* binding */ wrapAgentRunCollection; }
15234
15243
  /* harmony export */ });
@@ -15242,6 +15251,10 @@ function wrapAgentRun(_makeRequest, data) {
15242
15251
  var agentRun = (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.toPlainObject)((0,fast_copy__WEBPACK_IMPORTED_MODULE_1__["default"])(data));
15243
15252
  return (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.freezeSys)(agentRun);
15244
15253
  }
15254
+ function wrapAgentGenerateResponse(_makeRequest, data) {
15255
+ var response = (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.toPlainObject)((0,fast_copy__WEBPACK_IMPORTED_MODULE_1__["default"])(data));
15256
+ return (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.freezeSys)(response);
15257
+ }
15245
15258
  var wrapAgentRunCollection = (0,_common_utils__WEBPACK_IMPORTED_MODULE_2__.wrapCollection)(wrapAgentRun);
15246
15259
 
15247
15260
  /***/ }),
@@ -15285,7 +15298,7 @@ function createAgentApi(makeRequest) {
15285
15298
  params: getParams(self),
15286
15299
  payload: payload
15287
15300
  }).then(function (data) {
15288
- return (0,_agent_run__WEBPACK_IMPORTED_MODULE_4__.wrapAgentRun)(makeRequest, data);
15301
+ return (0,_agent_run__WEBPACK_IMPORTED_MODULE_4__.wrapAgentGenerateResponse)(makeRequest, data);
15289
15302
  });
15290
15303
  }
15291
15304
  };