@docbrasil/api-systemmanager 1.1.82 → 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.
package/api/ai/index.js CHANGED
@@ -15,7 +15,6 @@ class MyndAI {
15
15
 
16
16
  const self = this;
17
17
  self.parent = options.parent;
18
- self._client = self.parent.dispatch.getClient();
19
18
 
20
19
  self.sessions = new AISession(options);
21
20
  }
@@ -92,7 +91,8 @@ class MyndAI {
92
91
  Joi.assert(params, Joi.object().required().error(new Error('params is required')));
93
92
  Joi.assert(params.prompt, Joi.string().required().error(new Error('Provide a prompt')));
94
93
 
95
- const apiCall = self._client
94
+ const client = self.parent.dispatch.getAkamaiClient();
95
+ const apiCall = client
96
96
  .post('/agents/explain', params, self._setHeader(authorization));
97
97
 
98
98
  return self._returnData(await apiCall);
@@ -14,7 +14,6 @@ class AISession {
14
14
 
15
15
  const self = this;
16
16
  self.parent = options.parent;
17
- self._client = self.parent.dispatch.getClient();
18
17
  }
19
18
 
20
19
  /**
@@ -78,7 +77,8 @@ class AISession {
78
77
  Joi.assert(params, Joi.object().required().error(new Error('params is required')));
79
78
  Joi.assert(params.documentId, Joi.string().required().error(new Error('documentId is required')));
80
79
 
81
- const apiCall = self._client
80
+ const client = self.parent.dispatch.getAkamaiClient();
81
+ const apiCall = client
82
82
  .get(`/agents/session/document/${params.documentId}`, self._setHeader(authorization));
83
83
 
84
84
  return self._returnData(await apiCall);
@@ -140,7 +140,8 @@ class AISession {
140
140
 
141
141
  const { documentId, ...payload } = params;
142
142
 
143
- const apiCall = self._client
143
+ const client = self.parent.dispatch.getAkamaiClient();
144
+ const apiCall = client
144
145
  .patch(`/agents/session/document/${documentId}`, payload, self._setHeader(authorization));
145
146
 
146
147
  return self._returnData(await apiCall);
@@ -186,7 +187,8 @@ class AISession {
186
187
  Joi.assert(params, Joi.object().required().error(new Error('params is required')));
187
188
  Joi.assert(params.agentType, Joi.string().required().error(new Error('agentType is required')));
188
189
 
189
- const apiCall = self._client
190
+ const client = self.parent.dispatch.getAkamaiClient();
191
+ const apiCall = client
190
192
  .post('/agents/create', params, self._setHeader(authorization));
191
193
 
192
194
  return self._returnData(await apiCall);
@@ -230,7 +232,8 @@ class AISession {
230
232
 
231
233
  const { sessionId, ...payload } = params;
232
234
 
233
- const apiCall = self._client
235
+ const client = self.parent.dispatch.getAkamaiClient();
236
+ const apiCall = client
234
237
  .post(`/agents/${sessionId}/execute`, payload, self._setHeader(authorization));
235
238
 
236
239
  return self._returnData(await apiCall);
package/api/dispatch.js CHANGED
@@ -198,6 +198,30 @@ class Dispatch {
198
198
  getClient() {
199
199
  return this._client;
200
200
  }
201
+
202
+ /**
203
+ * @description Create a dedicated Axios client for Akamai routes.
204
+ * @param {string} url The Akamai base URL (e.g., http://localhost:9008 in DEV).
205
+ * @public
206
+ */
207
+ setAkamaiBaseUrl(url) {
208
+ Joi.assert(url, Joi.string().required());
209
+
210
+ this._akamaiClient = Axios.create({
211
+ baseURL: url,
212
+ withCredentials: true
213
+ });
214
+ }
215
+
216
+ /**
217
+ * @description Get the Akamai Axios client. Falls back to the default client
218
+ * for backward compatibility (e.g., PROD where NGiNX proxies all routes).
219
+ * @return {AxiosInstance} The Akamai client or default client.
220
+ * @public
221
+ */
222
+ getAkamaiClient() {
223
+ return this._akamaiClient || this._client;
224
+ }
201
225
  }
202
226
 
203
227
  export default Dispatch;
package/dist/bundle.cjs CHANGED
@@ -210,6 +210,30 @@ class Dispatch {
210
210
  getClient() {
211
211
  return this._client;
212
212
  }
213
+
214
+ /**
215
+ * @description Create a dedicated Axios client for Akamai routes.
216
+ * @param {string} url The Akamai base URL (e.g., http://localhost:9008 in DEV).
217
+ * @public
218
+ */
219
+ setAkamaiBaseUrl(url) {
220
+ Joi__default["default"].assert(url, Joi__default["default"].string().required());
221
+
222
+ this._akamaiClient = Axios__default["default"].create({
223
+ baseURL: url,
224
+ withCredentials: true
225
+ });
226
+ }
227
+
228
+ /**
229
+ * @description Get the Akamai Axios client. Falls back to the default client
230
+ * for backward compatibility (e.g., PROD where NGiNX proxies all routes).
231
+ * @return {AxiosInstance} The Akamai client or default client.
232
+ * @public
233
+ */
234
+ getAkamaiClient() {
235
+ return this._akamaiClient || this._client;
236
+ }
213
237
  }
214
238
 
215
239
  /**
@@ -16129,7 +16153,6 @@ class AISession {
16129
16153
 
16130
16154
  const self = this;
16131
16155
  self.parent = options.parent;
16132
- self._client = self.parent.dispatch.getClient();
16133
16156
  }
16134
16157
 
16135
16158
  /**
@@ -16193,7 +16216,8 @@ class AISession {
16193
16216
  Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
16194
16217
  Joi__default["default"].assert(params.documentId, Joi__default["default"].string().required().error(new Error('documentId is required')));
16195
16218
 
16196
- const apiCall = self._client
16219
+ const client = self.parent.dispatch.getAkamaiClient();
16220
+ const apiCall = client
16197
16221
  .get(`/agents/session/document/${params.documentId}`, self._setHeader(authorization));
16198
16222
 
16199
16223
  return self._returnData(await apiCall);
@@ -16255,7 +16279,8 @@ class AISession {
16255
16279
 
16256
16280
  const { documentId, ...payload } = params;
16257
16281
 
16258
- const apiCall = self._client
16282
+ const client = self.parent.dispatch.getAkamaiClient();
16283
+ const apiCall = client
16259
16284
  .patch(`/agents/session/document/${documentId}`, payload, self._setHeader(authorization));
16260
16285
 
16261
16286
  return self._returnData(await apiCall);
@@ -16301,7 +16326,8 @@ class AISession {
16301
16326
  Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
16302
16327
  Joi__default["default"].assert(params.agentType, Joi__default["default"].string().required().error(new Error('agentType is required')));
16303
16328
 
16304
- const apiCall = self._client
16329
+ const client = self.parent.dispatch.getAkamaiClient();
16330
+ const apiCall = client
16305
16331
  .post('/agents/create', params, self._setHeader(authorization));
16306
16332
 
16307
16333
  return self._returnData(await apiCall);
@@ -16345,7 +16371,8 @@ class AISession {
16345
16371
 
16346
16372
  const { sessionId, ...payload } = params;
16347
16373
 
16348
- const apiCall = self._client
16374
+ const client = self.parent.dispatch.getAkamaiClient();
16375
+ const apiCall = client
16349
16376
  .post(`/agents/${sessionId}/execute`, payload, self._setHeader(authorization));
16350
16377
 
16351
16378
  return self._returnData(await apiCall);
@@ -16367,7 +16394,6 @@ class MyndAI {
16367
16394
 
16368
16395
  const self = this;
16369
16396
  self.parent = options.parent;
16370
- self._client = self.parent.dispatch.getClient();
16371
16397
 
16372
16398
  self.sessions = new AISession(options);
16373
16399
  }
@@ -16444,7 +16470,8 @@ class MyndAI {
16444
16470
  Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
16445
16471
  Joi__default["default"].assert(params.prompt, Joi__default["default"].string().required().error(new Error('Provide a prompt')));
16446
16472
 
16447
- const apiCall = self._client
16473
+ const client = self.parent.dispatch.getAkamaiClient();
16474
+ const apiCall = client
16448
16475
  .post('/agents/explain', params, self._setHeader(authorization));
16449
16476
 
16450
16477
  return self._returnData(await apiCall);
@@ -16511,6 +16538,7 @@ class API {
16511
16538
  }
16512
16539
  },
16513
16540
  uri: 'http://localhost:8080',
16541
+ akamaiUri: null,
16514
16542
  attemptsRetry: 3,
16515
16543
  httpStatusToRetry: [401],
16516
16544
  debug: {success: true, error: true}
@@ -16526,6 +16554,20 @@ class API {
16526
16554
  self.admin = new Admin({parent: self});
16527
16555
  self.external = new External({parent: self});
16528
16556
  self.ai = new MyndAI({parent: self});
16557
+
16558
+ // If akamaiUri was provided in options, configure the Akamai client
16559
+ if (self.options.akamaiUri) {
16560
+ self.dispatch.setAkamaiBaseUrl(self.options.akamaiUri);
16561
+ }
16562
+ }
16563
+
16564
+ /**
16565
+ * @description Set the Akamai base URL for agent/AI routes.
16566
+ * @param {string} url The Akamai base URL.
16567
+ * @public
16568
+ */
16569
+ setAkamaiBaseUrl(url) {
16570
+ this.dispatch.setAkamaiBaseUrl(url);
16529
16571
  }
16530
16572
  }
16531
16573