@docbrasil/api-systemmanager 1.1.81 → 1.1.83

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.
@@ -314,6 +314,129 @@
314
314
 
315
315
 
316
316
 
317
+
318
+ </div>
319
+
320
+ <div class="member">
321
+
322
+
323
+
324
+ <h4 class="name" id="getAkamaiClient">
325
+ <a class="href-link" href="#getAkamaiClient">#</a>
326
+
327
+ <span class="code-name">
328
+
329
+ getAkamaiClient<span class="signature">()</span><span class="type-signature"> &rarr; {AxiosInstance}</span>
330
+
331
+ </span>
332
+ </h4>
333
+
334
+
335
+
336
+
337
+ <div class="description">
338
+ Get the Akamai Axios client. Falls back to the default client
339
+ for backward compatibility (e.g., PROD where NGiNX proxies all routes).
340
+ </div>
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+ <dl class="details">
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+ <p class="tag-source">
388
+ <a href="dispatch.js.html" class="button">View Source</a>
389
+ <span>
390
+ <a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#line222">line 222</a>
391
+ </span>
392
+ </p>
393
+
394
+ </dl>
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+ <div class='columns method-parameter'>
414
+ <div class="column is-2"><label>Returns:</label></div>
415
+ <div class="column is-10">
416
+
417
+
418
+
419
+ <div class="columns">
420
+
421
+ <div class='param-desc column is-7'>The Akamai client or default client.</div>
422
+
423
+
424
+ <div class='column is-5 has-text-left'>
425
+ <label>Type: </label>
426
+
427
+ <code class="param-type">AxiosInstance</code>
428
+
429
+
430
+ </div>
431
+
432
+ </div>
433
+
434
+
435
+ </div>
436
+ </div>
437
+
438
+
439
+
317
440
 
318
441
  </div>
319
442
 
@@ -673,6 +796,154 @@
673
796
 
674
797
 
675
798
 
799
+
800
+ </div>
801
+
802
+ <div class="member">
803
+
804
+
805
+
806
+ <h4 class="name" id="setAkamaiBaseUrl">
807
+ <a class="href-link" href="#setAkamaiBaseUrl">#</a>
808
+
809
+ <span class="code-name">
810
+
811
+ setAkamaiBaseUrl<span class="signature">(url)</span><span class="type-signature"></span>
812
+
813
+ </span>
814
+ </h4>
815
+
816
+
817
+
818
+
819
+ <div class="description">
820
+ Create a dedicated Axios client for Akamai routes.
821
+ </div>
822
+
823
+
824
+
825
+
826
+
827
+
828
+
829
+
830
+
831
+
832
+ <h5>Parameters:</h5>
833
+
834
+ <div class="table-container">
835
+ <table class="params table">
836
+ <thead>
837
+ <tr>
838
+
839
+ <th>Name</th>
840
+
841
+
842
+ <th>Type</th>
843
+
844
+
845
+
846
+
847
+
848
+ <th class="last">Description</th>
849
+ </tr>
850
+ </thead>
851
+
852
+ <tbody>
853
+
854
+
855
+
856
+ <tr class="deep-level-0">
857
+
858
+ <td class="name"><code>url</code></td>
859
+
860
+
861
+ <td class="type">
862
+
863
+
864
+ <code class="param-type">string</code>
865
+
866
+
867
+
868
+ </td>
869
+
870
+
871
+
872
+
873
+
874
+ <td class="description last">The Akamai base URL (e.g., http://localhost:9008 in DEV).</td>
875
+ </tr>
876
+
877
+
878
+
879
+ </tbody>
880
+ </table>
881
+ </div>
882
+
883
+
884
+
885
+
886
+
887
+ <dl class="details">
888
+
889
+
890
+
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+
904
+
905
+
906
+
907
+
908
+
909
+
910
+
911
+
912
+
913
+
914
+
915
+
916
+
917
+
918
+
919
+ <p class="tag-source">
920
+ <a href="dispatch.js.html" class="button">View Source</a>
921
+ <span>
922
+ <a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#line207">line 207</a>
923
+ </span>
924
+ </p>
925
+
926
+ </dl>
927
+
928
+
929
+
930
+
931
+
932
+
933
+
934
+
935
+
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+
676
947
 
677
948
  </div>
678
949
 
package/docs/MyndAI.html CHANGED
@@ -632,7 +632,7 @@
632
632
  <p class="tag-source">
633
633
  <a href="ai_index.js.html" class="button">View Source</a>
634
634
  <span>
635
- <a href="ai_index.js.html">ai/index.js</a>, <a href="ai_index.js.html#line88">line 88</a>
635
+ <a href="ai_index.js.html">ai/index.js</a>, <a href="ai_index.js.html#line87">line 87</a>
636
636
  </span>
637
637
  </p>
638
638
 
@@ -102,7 +102,6 @@ class MyndAI {
102
102
 
103
103
  const self = this;
104
104
  self.parent = options.parent;
105
- self._client = self.parent.dispatch.getClient();
106
105
 
107
106
  self.sessions = new AISession(options);
108
107
  }
@@ -179,7 +178,8 @@ class MyndAI {
179
178
  Joi.assert(params, Joi.object().required().error(new Error('params is required')));
180
179
  Joi.assert(params.prompt, Joi.string().required().error(new Error('Provide a prompt')));
181
180
 
182
- const apiCall = self._client
181
+ const client = self.parent.dispatch.getAkamaiClient();
182
+ const apiCall = client
183
183
  .post('/agents/explain', params, self._setHeader(authorization));
184
184
 
185
185
  return self._returnData(await apiCall);
@@ -101,7 +101,6 @@ class AISession {
101
101
 
102
102
  const self = this;
103
103
  self.parent = options.parent;
104
- self._client = self.parent.dispatch.getClient();
105
104
  }
106
105
 
107
106
  /**
@@ -165,8 +164,9 @@ class AISession {
165
164
  Joi.assert(params, Joi.object().required().error(new Error('params is required')));
166
165
  Joi.assert(params.documentId, Joi.string().required().error(new Error('documentId is required')));
167
166
 
168
- const apiCall = self._client
169
- .get(`/akamai/agents/session/document/${params.documentId}`, self._setHeader(authorization));
167
+ const client = self.parent.dispatch.getAkamaiClient();
168
+ const apiCall = client
169
+ .get(`/agents/session/document/${params.documentId}`, self._setHeader(authorization));
170
170
 
171
171
  return self._returnData(await apiCall);
172
172
  } catch (ex) {
@@ -227,8 +227,101 @@ class AISession {
227
227
 
228
228
  const { documentId, ...payload } = params;
229
229
 
230
- const apiCall = self._client
231
- .patch(`/akamai/agents/session/document/${documentId}`, payload, self._setHeader(authorization));
230
+ const client = self.parent.dispatch.getAkamaiClient();
231
+ const apiCall = client
232
+ .patch(`/agents/session/document/${documentId}`, payload, self._setHeader(authorization));
233
+
234
+ return self._returnData(await apiCall);
235
+ } catch (ex) {
236
+ throw ex;
237
+ }
238
+ }
239
+
240
+ /**
241
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
242
+ * @description Create a new agent session.
243
+ * Use this to create a session with full metadata before triggering execution.
244
+ * @param {object} params Parameters
245
+ * @param {string} params.agentType The agent type (e.g., 'doc-rlm-ingest')
246
+ * @param {object} [params.config] Agent configuration options
247
+ * @param {object} [params.metadata] Session metadata (documentId, pipelineVariant, analysisMode, etc.)
248
+ * @param {string} authorization Authorization token
249
+ * @return {Promise&lt;object>} data The created session
250
+ * @return {string} data.sessionId The session ID
251
+ * @return {string} data.status The session status
252
+ * @public
253
+ * @async
254
+ * @example
255
+ *
256
+ * const API = require('@docbrasil/api-systemmanager');
257
+ * const api = new API();
258
+ * const authorization = '...';
259
+ * const params = {
260
+ * agentType: 'doc-rlm-ingest',
261
+ * metadata: {
262
+ * documentId: 'doc-123',
263
+ * documentName: 'Patient Report.pdf',
264
+ * pipelineVariant: 'A',
265
+ * analysisMode: 'full'
266
+ * }
267
+ * };
268
+ * const retData = await api.ai.sessions.create(params, authorization);
269
+ */
270
+ async create(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.agentType, Joi.string().required().error(new Error('agentType is required')));
276
+
277
+ const client = self.parent.dispatch.getAkamaiClient();
278
+ const apiCall = client
279
+ .post('/agents/create', params, self._setHeader(authorization));
280
+
281
+ return self._returnData(await apiCall);
282
+ } catch (ex) {
283
+ throw ex;
284
+ }
285
+ }
286
+
287
+ /**
288
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
289
+ * @description Start execution on an existing agent session.
290
+ * @param {object} params Parameters
291
+ * @param {string} params.sessionId The session ID to execute
292
+ * @param {object} [params.input] Execution input (documentId, options, etc.)
293
+ * @param {string} authorization Authorization token
294
+ * @return {Promise&lt;object>} data The execution data
295
+ * @return {string} data.executionId The execution ID
296
+ * @return {string} data.status The execution status
297
+ * @public
298
+ * @async
299
+ * @example
300
+ *
301
+ * const API = require('@docbrasil/api-systemmanager');
302
+ * const api = new API();
303
+ * const authorization = '...';
304
+ * const params = {
305
+ * sessionId: 'session-abc-123',
306
+ * input: {
307
+ * documentId: 'doc-123',
308
+ * options: { pipelineVariant: 'A', analysisMode: 'full' }
309
+ * }
310
+ * };
311
+ * const retData = await api.ai.sessions.execute(params, authorization);
312
+ */
313
+ async execute(params, authorization) {
314
+ const self = this;
315
+
316
+ try {
317
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
318
+ Joi.assert(params.sessionId, Joi.string().required().error(new Error('sessionId is required')));
319
+
320
+ const { sessionId, ...payload } = params;
321
+
322
+ const client = self.parent.dispatch.getAkamaiClient();
323
+ const apiCall = client
324
+ .post(`/agents/${sessionId}/execute`, payload, self._setHeader(authorization));
232
325
 
233
326
  return self._returnData(await apiCall);
234
327
  } catch (ex) {
@@ -285,6 +285,30 @@ class Dispatch {
285
285
  getClient() {
286
286
  return this._client;
287
287
  }
288
+
289
+ /**
290
+ * @description Create a dedicated Axios client for Akamai routes.
291
+ * @param {string} url The Akamai base URL (e.g., http://localhost:9008 in DEV).
292
+ * @public
293
+ */
294
+ setAkamaiBaseUrl(url) {
295
+ Joi.assert(url, Joi.string().required());
296
+
297
+ this._akamaiClient = Axios.create({
298
+ baseURL: url,
299
+ withCredentials: true
300
+ });
301
+ }
302
+
303
+ /**
304
+ * @description Get the Akamai Axios client. Falls back to the default client
305
+ * for backward compatibility (e.g., PROD where NGiNX proxies all routes).
306
+ * @return {AxiosInstance} The Akamai client or default client.
307
+ * @public
308
+ */
309
+ getAkamaiClient() {
310
+ return this._akamaiClient || this._client;
311
+ }
288
312
  }
289
313
 
290
314
  export default Dispatch;
package/index.js CHANGED
@@ -68,6 +68,7 @@ class API {
68
68
  }
69
69
  },
70
70
  uri: 'http://localhost:8080',
71
+ akamaiUri: null,
71
72
  attemptsRetry: 3,
72
73
  httpStatusToRetry: [401],
73
74
  debug: {success: true, error: true}
@@ -83,6 +84,20 @@ class API {
83
84
  self.admin = new Admin({parent: self});
84
85
  self.external = new External({parent: self});
85
86
  self.ai = new MyndAI({parent: self});
87
+
88
+ // If akamaiUri was provided in options, configure the Akamai client
89
+ if (self.options.akamaiUri) {
90
+ self.dispatch.setAkamaiBaseUrl(self.options.akamaiUri);
91
+ }
92
+ }
93
+
94
+ /**
95
+ * @description Set the Akamai base URL for agent/AI routes.
96
+ * @param {string} url The Akamai base URL.
97
+ * @public
98
+ */
99
+ setAkamaiBaseUrl(url) {
100
+ this.dispatch.setAkamaiBaseUrl(url);
86
101
  }
87
102
  }
88
103
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docbrasil/api-systemmanager",
3
3
  "description": "Module API System Manager",
4
- "version": "1.1.81",
4
+ "version": "1.1.83",
5
5
  "scripts": {
6
6
  "htmldoc": "rm -rf docs && jsdoc api/** -d docs -t ./node_modules/better-docs",
7
7
  "doc": "rm -rf doc && mkdir doc && jsdoc2md api/**/* api/* > doc/api.md",