@docbrasil/api-systemmanager 1.1.83 → 1.1.85
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/dispatch.js +27 -2
- package/dist/bundle.cjs +33 -5
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +9 -2
- package/docs/Dispatch.html +91 -3
- package/docs/dispatch.js.html +27 -2
- package/index.js +6 -3
- package/package.json +1 -1
package/doc/api.md
CHANGED
|
@@ -5403,7 +5403,7 @@ Api dispatch manager
|
|
|
5403
5403
|
* [.errorOffline()](#Dispatch+errorOffline)
|
|
5404
5404
|
* [.getContext(url, [session])](#Dispatch+getContext) ⇒ <code>Promise.<object></code>
|
|
5405
5405
|
* [.getClient()](#Dispatch+getClient) ⇒ <code>AxiosInstance</code>
|
|
5406
|
-
* [.setAkamaiBaseUrl(url)](#Dispatch+setAkamaiBaseUrl)
|
|
5406
|
+
* [.setAkamaiBaseUrl(url, [options])](#Dispatch+setAkamaiBaseUrl)
|
|
5407
5407
|
* [.getAkamaiClient()](#Dispatch+getAkamaiClient) ⇒ <code>AxiosInstance</code>
|
|
5408
5408
|
|
|
5409
5409
|
<a name="Dispatch+errorOffline"></a>
|
|
@@ -5436,8 +5436,13 @@ Get the Axios client.
|
|
|
5436
5436
|
**Access**: public
|
|
5437
5437
|
<a name="Dispatch+setAkamaiBaseUrl"></a>
|
|
5438
5438
|
|
|
5439
|
-
### dispatch.setAkamaiBaseUrl(url)
|
|
5439
|
+
### dispatch.setAkamaiBaseUrl(url, [options])
|
|
5440
5440
|
Create a dedicated Axios client for Akamai routes.
|
|
5441
|
+
In DEV there is no NGiNX to translate the Authorization JWT into the
|
|
5442
|
+
x-api-key / x-user-id / x-organization-id headers that Akamai expects.
|
|
5443
|
+
When a headerBuilder function is supplied, the client adds a request
|
|
5444
|
+
interceptor that replaces the Authorization header with the x-* headers
|
|
5445
|
+
returned by the function.
|
|
5441
5446
|
|
|
5442
5447
|
**Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
|
|
5443
5448
|
**Access**: public
|
|
@@ -5445,6 +5450,8 @@ Create a dedicated Axios client for Akamai routes.
|
|
|
5445
5450
|
| Param | Type | Description |
|
|
5446
5451
|
| --- | --- | --- |
|
|
5447
5452
|
| url | <code>string</code> | The Akamai base URL (e.g., http://localhost:9008 in DEV). |
|
|
5453
|
+
| [options] | <code>object</code> | Optional configuration |
|
|
5454
|
+
| [options.headerBuilder] | <code>function</code> | A function that returns an object with the Akamai headers (x-api-key, x-user-id, x-organization-id, x-country). Called at request time so it can read live application state (e.g., auth store). |
|
|
5448
5455
|
|
|
5449
5456
|
<a name="Dispatch+getAkamaiClient"></a>
|
|
5450
5457
|
|
package/docs/Dispatch.html
CHANGED
|
@@ -387,7 +387,7 @@ for backward compatibility (e.g., PROD where NGiNX proxies all routes).
|
|
|
387
387
|
<p class="tag-source">
|
|
388
388
|
<a href="dispatch.js.html" class="button">View Source</a>
|
|
389
389
|
<span>
|
|
390
|
-
<a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#
|
|
390
|
+
<a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#line247">line 247</a>
|
|
391
391
|
</span>
|
|
392
392
|
</p>
|
|
393
393
|
|
|
@@ -808,7 +808,7 @@ for backward compatibility (e.g., PROD where NGiNX proxies all routes).
|
|
|
808
808
|
|
|
809
809
|
<span class="code-name">
|
|
810
810
|
|
|
811
|
-
setAkamaiBaseUrl<span class="signature">(url)</span><span class="type-signature"></span>
|
|
811
|
+
setAkamaiBaseUrl<span class="signature">(url, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span>
|
|
812
812
|
|
|
813
813
|
</span>
|
|
814
814
|
</h4>
|
|
@@ -818,6 +818,11 @@ for backward compatibility (e.g., PROD where NGiNX proxies all routes).
|
|
|
818
818
|
|
|
819
819
|
<div class="description">
|
|
820
820
|
Create a dedicated Axios client for Akamai routes.
|
|
821
|
+
In DEV there is no NGiNX to translate the Authorization JWT into the
|
|
822
|
+
x-api-key / x-user-id / x-organization-id headers that Akamai expects.
|
|
823
|
+
When a headerBuilder function is supplied, the client adds a request
|
|
824
|
+
interceptor that replaces the Authorization header with the x-* headers
|
|
825
|
+
returned by the function.
|
|
821
826
|
</div>
|
|
822
827
|
|
|
823
828
|
|
|
@@ -842,6 +847,8 @@ for backward compatibility (e.g., PROD where NGiNX proxies all routes).
|
|
|
842
847
|
<th>Type</th>
|
|
843
848
|
|
|
844
849
|
|
|
850
|
+
<th>Attributes</th>
|
|
851
|
+
|
|
845
852
|
|
|
846
853
|
|
|
847
854
|
|
|
@@ -868,6 +875,14 @@ for backward compatibility (e.g., PROD where NGiNX proxies all routes).
|
|
|
868
875
|
</td>
|
|
869
876
|
|
|
870
877
|
|
|
878
|
+
<td class="attributes">
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
</td>
|
|
885
|
+
|
|
871
886
|
|
|
872
887
|
|
|
873
888
|
|
|
@@ -876,6 +891,79 @@ for backward compatibility (e.g., PROD where NGiNX proxies all routes).
|
|
|
876
891
|
|
|
877
892
|
|
|
878
893
|
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
<tr class="deep-level-0">
|
|
897
|
+
|
|
898
|
+
<td class="name"><code>options</code></td>
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
<td class="type">
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
<code class="param-type">object</code>
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
</td>
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
<td class="attributes">
|
|
912
|
+
|
|
913
|
+
<optional><br>
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
</td>
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
<td class="description last">Optional configuration</td>
|
|
925
|
+
</tr>
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
<tr class="deep-level-1">
|
|
931
|
+
|
|
932
|
+
<td class="name"><code>headerBuilder</code></td>
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
<td class="type">
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
<code class="param-type">function</code>
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
</td>
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
<td class="attributes">
|
|
946
|
+
|
|
947
|
+
<optional><br>
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
</td>
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
<td class="description last">A function that returns an object
|
|
959
|
+
with the Akamai headers (x-api-key, x-user-id, x-organization-id, x-country).
|
|
960
|
+
Called at request time so it can read live application state (e.g., auth store).</td>
|
|
961
|
+
</tr>
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
879
967
|
</tbody>
|
|
880
968
|
</table>
|
|
881
969
|
</div>
|
|
@@ -919,7 +1007,7 @@ for backward compatibility (e.g., PROD where NGiNX proxies all routes).
|
|
|
919
1007
|
<p class="tag-source">
|
|
920
1008
|
<a href="dispatch.js.html" class="button">View Source</a>
|
|
921
1009
|
<span>
|
|
922
|
-
<a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#
|
|
1010
|
+
<a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#line216">line 216</a>
|
|
923
1011
|
</span>
|
|
924
1012
|
</p>
|
|
925
1013
|
|
package/docs/dispatch.js.html
CHANGED
|
@@ -288,16 +288,41 @@ class Dispatch {
|
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
290
|
* @description Create a dedicated Axios client for Akamai routes.
|
|
291
|
+
* In DEV there is no NGiNX to translate the Authorization JWT into the
|
|
292
|
+
* x-api-key / x-user-id / x-organization-id headers that Akamai expects.
|
|
293
|
+
* When a headerBuilder function is supplied, the client adds a request
|
|
294
|
+
* interceptor that replaces the Authorization header with the x-* headers
|
|
295
|
+
* returned by the function.
|
|
291
296
|
* @param {string} url The Akamai base URL (e.g., http://localhost:9008 in DEV).
|
|
297
|
+
* @param {object} [options] Optional configuration
|
|
298
|
+
* @param {function} [options.headerBuilder] A function that returns an object
|
|
299
|
+
* with the Akamai headers (x-api-key, x-user-id, x-organization-id, x-country).
|
|
300
|
+
* Called at request time so it can read live application state (e.g., auth store).
|
|
292
301
|
* @public
|
|
293
302
|
*/
|
|
294
|
-
setAkamaiBaseUrl(url) {
|
|
303
|
+
setAkamaiBaseUrl(url, options = {}) {
|
|
295
304
|
Joi.assert(url, Joi.string().required());
|
|
296
305
|
|
|
297
|
-
|
|
306
|
+
const self = this;
|
|
307
|
+
|
|
308
|
+
self._akamaiClient = Axios.create({
|
|
298
309
|
baseURL: url,
|
|
299
310
|
withCredentials: true
|
|
300
311
|
});
|
|
312
|
+
|
|
313
|
+
// When a headerBuilder is provided, add interceptor to replace Authorization with Akamai headers
|
|
314
|
+
if (typeof options.headerBuilder === 'function') {
|
|
315
|
+
self._akamaiClient.interceptors.request.use((config) => {
|
|
316
|
+
const headers = options.headerBuilder();
|
|
317
|
+
if (headers) {
|
|
318
|
+
Object.assign(config.headers, headers);
|
|
319
|
+
// Remove the Authorization header — Akamai doesn't use it
|
|
320
|
+
delete config.headers.Authorization;
|
|
321
|
+
delete config.headers.authorization;
|
|
322
|
+
}
|
|
323
|
+
return config;
|
|
324
|
+
});
|
|
325
|
+
}
|
|
301
326
|
}
|
|
302
327
|
|
|
303
328
|
/**
|
package/index.js
CHANGED
|
@@ -87,17 +87,20 @@ class API {
|
|
|
87
87
|
|
|
88
88
|
// If akamaiUri was provided in options, configure the Akamai client
|
|
89
89
|
if (self.options.akamaiUri) {
|
|
90
|
-
self.dispatch.setAkamaiBaseUrl(self.options.akamaiUri);
|
|
90
|
+
self.dispatch.setAkamaiBaseUrl(self.options.akamaiUri, { headerBuilder: self.options.akamaiHeaderBuilder });
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* @description Set the Akamai base URL for agent/AI routes.
|
|
96
96
|
* @param {string} url The Akamai base URL.
|
|
97
|
+
* @param {object} [options] Optional configuration
|
|
98
|
+
* @param {function} [options.headerBuilder] Function returning Akamai headers.
|
|
99
|
+
* Called at request time — can read live app state (e.g., auth store).
|
|
97
100
|
* @public
|
|
98
101
|
*/
|
|
99
|
-
setAkamaiBaseUrl(url) {
|
|
100
|
-
this.dispatch.setAkamaiBaseUrl(url);
|
|
102
|
+
setAkamaiBaseUrl(url, options = {}) {
|
|
103
|
+
this.dispatch.setAkamaiBaseUrl(url, options);
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
|
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.
|
|
4
|
+
"version": "1.1.85",
|
|
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",
|