@docbrasil/api-systemmanager 1.1.88 → 1.1.90

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.
@@ -245,6 +245,89 @@ class AISession {
245
245
  throw ex;
246
246
  }
247
247
  }
248
+ /**
249
+ * @author Myndware <augusto.pissarra@myndware.com>
250
+ * @description Add documents to an existing agent session.
251
+ * The agent will handle the documentIds accordingly.
252
+ * @param {object} params Parameters
253
+ * @param {string} params.sessionId The session ID
254
+ * @param {array<string>} params.documentIds Array of document IDs to add
255
+ * @param {string} authorization Authorization token
256
+ * @return {Promise<object>} data The result from the agent
257
+ * @public
258
+ * @async
259
+ * @example
260
+ *
261
+ * const API = require('@docbrasil/api-systemmanager');
262
+ * const api = new API();
263
+ * const authorization = '...';
264
+ * const params = {
265
+ * sessionId: 'session-abc-123',
266
+ * documentIds: ['doc-123', 'doc-456']
267
+ * };
268
+ * const retData = await api.ai.sessions.addDocuments(params, authorization);
269
+ */
270
+ async addDocuments(params, authorization) {
271
+ const self = this;
272
+
273
+ try {
274
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
275
+ Joi.assert(params.sessionId, Joi.string().required().error(new Error('sessionId is required')));
276
+ Joi.assert(params.documentIds, Joi.array().items(Joi.string()).min(1).required().error(new Error('documentIds is required and must be a non-empty array')));
277
+
278
+ const { sessionId, documentIds } = params;
279
+
280
+ const client = self.parent.dispatch.getAkamaiClient();
281
+ const apiCall = client
282
+ .post(`/agents/${sessionId}/documents/add`, { documentIds }, self._setHeader(authorization));
283
+
284
+ return self._returnData(await apiCall);
285
+ } catch (ex) {
286
+ throw ex;
287
+ }
288
+ }
289
+
290
+ /**
291
+ * @author Myndware <augusto.pissarra@myndware.com>
292
+ * @description Remove documents from an existing agent session.
293
+ * The agent will handle the documentIds accordingly.
294
+ * @param {object} params Parameters
295
+ * @param {string} params.sessionId The session ID
296
+ * @param {array<string>} params.documentIds Array of document IDs to remove
297
+ * @param {string} authorization Authorization token
298
+ * @return {Promise<object>} data The result from the agent
299
+ * @public
300
+ * @async
301
+ * @example
302
+ *
303
+ * const API = require('@docbrasil/api-systemmanager');
304
+ * const api = new API();
305
+ * const authorization = '...';
306
+ * const params = {
307
+ * sessionId: 'session-abc-123',
308
+ * documentIds: ['doc-123', 'doc-456']
309
+ * };
310
+ * const retData = await api.ai.sessions.removeDocuments(params, authorization);
311
+ */
312
+ async removeDocuments(params, authorization) {
313
+ const self = this;
314
+
315
+ try {
316
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
317
+ Joi.assert(params.sessionId, Joi.string().required().error(new Error('sessionId is required')));
318
+ Joi.assert(params.documentIds, Joi.array().items(Joi.string()).min(1).required().error(new Error('documentIds is required and must be a non-empty array')));
319
+
320
+ const { sessionId, documentIds } = params;
321
+
322
+ const client = self.parent.dispatch.getAkamaiClient();
323
+ const apiCall = client
324
+ .post(`/agents/${sessionId}/documents/remove`, { documentIds }, self._setHeader(authorization));
325
+
326
+ return self._returnData(await apiCall);
327
+ } catch (ex) {
328
+ throw ex;
329
+ }
330
+ }
248
331
  }
249
332
 
250
333
  export default AISession;