appmesh 3.1.5 → 3.1.7
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/README.md +27 -23
- package/dist/appmesh.esm.js +1 -1
- package/package.json +2 -2
- package/src/appmesh.js +77 -71
- package/src/appmesh_tcp.js +317 -215
- package/src/worker.js +34 -44
package/src/appmesh.js
CHANGED
|
@@ -113,9 +113,7 @@ function parseDuration(duration) {
|
|
|
113
113
|
const datePattern = `(${numbers}Y)?(${numbers}M)?(${numbers}W)?(${numbers}D)?`;
|
|
114
114
|
const timePattern = `T(${fractionalNumbers}H)?(${fractionalNumbers}M)?(${fractionalNumbers}S)?`;
|
|
115
115
|
const iso8601 = `P(?:${datePattern}(?:${timePattern})?)`;
|
|
116
|
-
const objMap = [
|
|
117
|
-
"years", "months", "weeks", "days", "hours", "minutes", "seconds",
|
|
118
|
-
];
|
|
116
|
+
const objMap = ["years", "months", "weeks", "days", "hours", "minutes", "seconds"];
|
|
119
117
|
|
|
120
118
|
// Parse duration string
|
|
121
119
|
const matches = duration.replace(/,/g, ".").match(new RegExp(iso8601));
|
|
@@ -252,7 +250,8 @@ async function _lookupGroup(key, value) {
|
|
|
252
250
|
return parts[0] && !isNaN(gid) ? { name: parts[0], gid } : null;
|
|
253
251
|
}
|
|
254
252
|
// macOS: "name: staff" / "gid: 20" lines, and empty output when unknown
|
|
255
|
-
const macResult = spawnSync('dscacheutil', ['-q', 'group', '-a', key, String(value)],
|
|
253
|
+
const macResult = spawnSync('dscacheutil', ['-q', 'group', '-a', key, String(value)],
|
|
254
|
+
{ encoding: 'utf8', timeout: 3000 });
|
|
256
255
|
if (macResult.status !== 0 || !macResult.stdout) return null;
|
|
257
256
|
const lines = macResult.stdout.split('\n');
|
|
258
257
|
const nameLine = lines.find(entry => entry.startsWith('name:'));
|
|
@@ -360,7 +359,8 @@ class AppMeshClient {
|
|
|
360
359
|
* rejectUnauthorized: true
|
|
361
360
|
* };
|
|
362
361
|
*/
|
|
363
|
-
constructor(baseURL = ENV.isNode ? 'https://127.0.0.1:6060' : window.location.origin,
|
|
362
|
+
constructor(baseURL = ENV.isNode ? 'https://127.0.0.1:6060' : window.location.origin,
|
|
363
|
+
sslConfig = null, tokenProvider = null) {
|
|
364
364
|
// Base URL for API requests
|
|
365
365
|
this.baseURL = baseURL;
|
|
366
366
|
|
|
@@ -371,7 +371,7 @@ class AppMeshClient {
|
|
|
371
371
|
// read from it via _getAccessToken()
|
|
372
372
|
this._tokenProvider = null;
|
|
373
373
|
if (tokenProvider) {
|
|
374
|
-
this.
|
|
374
|
+
this.setTokenProvider(tokenProvider);
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
// Configure axios instance
|
|
@@ -411,15 +411,14 @@ class AppMeshClient {
|
|
|
411
411
|
);
|
|
412
412
|
|
|
413
413
|
// Response interceptor
|
|
414
|
-
this._client.interceptors.response.use(
|
|
415
|
-
response => this._handleUnauthorizedRetry(response),
|
|
416
|
-
error => {
|
|
414
|
+
this._client.interceptors.response.use(response => this._handleUnauthorizedRetry(response), error => {
|
|
417
415
|
// Typed SDK errors (e.g. JSON parse failures from transformResponse) pass through unchanged
|
|
418
416
|
if (error instanceof AppMeshError) {
|
|
419
417
|
return Promise.reject(error);
|
|
420
418
|
}
|
|
421
419
|
// Network-level failure (DNS, connection refused, timeout, ...)
|
|
422
|
-
const err = new AppMeshError('Request failed: ' + (error.message || 'Unknown error'),
|
|
420
|
+
const err = new AppMeshError('Request failed: ' + (error.message || 'Unknown error'),
|
|
421
|
+
error.response?.status ?? null, error.response?.data ?? null);
|
|
423
422
|
err.cause = error;
|
|
424
423
|
return Promise.reject(err);
|
|
425
424
|
}
|
|
@@ -432,7 +431,7 @@ class AppMeshClient {
|
|
|
432
431
|
* and `clear()` follow the contract in token_provider.js.
|
|
433
432
|
* @param {Object} provider - Token provider
|
|
434
433
|
*/
|
|
435
|
-
|
|
434
|
+
setTokenProvider(provider) {
|
|
436
435
|
if (!provider || typeof provider.getAccessToken !== 'function') {
|
|
437
436
|
throw new TypeError('tokenProvider must implement async getAccessToken()');
|
|
438
437
|
}
|
|
@@ -440,21 +439,21 @@ class AppMeshClient {
|
|
|
440
439
|
}
|
|
441
440
|
|
|
442
441
|
/** Attach a caller-owned, non-refreshing access token in memory. */
|
|
443
|
-
|
|
442
|
+
setBearerToken(token) {
|
|
444
443
|
if (token === null || token === undefined) {
|
|
445
|
-
this.
|
|
444
|
+
this.clearBearerToken();
|
|
446
445
|
return;
|
|
447
446
|
}
|
|
448
|
-
this.
|
|
447
|
+
this.setTokenProvider(new StaticAccessTokenProvider(token));
|
|
449
448
|
}
|
|
450
449
|
|
|
451
|
-
/** Source-compatible alias for
|
|
452
|
-
|
|
453
|
-
this.
|
|
450
|
+
/** Source-compatible alias for setBearerToken(). */
|
|
451
|
+
setToken(token) {
|
|
452
|
+
this.setBearerToken(token);
|
|
454
453
|
}
|
|
455
454
|
|
|
456
455
|
/** Remove the locally attached bearer without contacting Engine or the authentication service. */
|
|
457
|
-
|
|
456
|
+
clearBearerToken() {
|
|
458
457
|
const provider = this._tokenProvider;
|
|
459
458
|
if (provider && typeof provider.clear === 'function') {
|
|
460
459
|
provider.clear();
|
|
@@ -508,12 +507,12 @@ class AppMeshClient {
|
|
|
508
507
|
}
|
|
509
508
|
|
|
510
509
|
/** Return Engine's public OAuth/OIDC configuration. */
|
|
511
|
-
async
|
|
510
|
+
async getAuthConfig() {
|
|
512
511
|
return (await this._request("get", "/appmesh/auth/config")).data;
|
|
513
512
|
}
|
|
514
513
|
|
|
515
514
|
/** Return the verified principal represented by the current bearer. */
|
|
516
|
-
async
|
|
515
|
+
async getCurrentPrincipal() {
|
|
517
516
|
return (await this._request("get", "/appmesh/principal/self")).data;
|
|
518
517
|
}
|
|
519
518
|
|
|
@@ -521,7 +520,7 @@ class AppMeshClient {
|
|
|
521
520
|
* Get all applications info
|
|
522
521
|
* @returns {Object} All apps info
|
|
523
522
|
*/
|
|
524
|
-
async
|
|
523
|
+
async listApps() {
|
|
525
524
|
const response = await this._request("get", "/appmesh/applications");
|
|
526
525
|
return response.data;
|
|
527
526
|
}
|
|
@@ -531,7 +530,7 @@ class AppMeshClient {
|
|
|
531
530
|
* @param {string} name - App name
|
|
532
531
|
* @returns {Object} App config
|
|
533
532
|
*/
|
|
534
|
-
async
|
|
533
|
+
async getApp(name) {
|
|
535
534
|
const response = await this._request("get", `/appmesh/app/${name}`);
|
|
536
535
|
return response.data;
|
|
537
536
|
}
|
|
@@ -542,7 +541,7 @@ class AppMeshClient {
|
|
|
542
541
|
* @returns {boolean} True if healthy; false only when the daemon's health verdict says unhealthy
|
|
543
542
|
* @throws {AppMeshError} On auth/missing-app/server errors (non-200) or network/transport failure
|
|
544
543
|
*/
|
|
545
|
-
async
|
|
544
|
+
async checkAppHealth(name) {
|
|
546
545
|
const response = await this._request("get", `/appmesh/app/${name}/health`);
|
|
547
546
|
return parseInt(response.data, 10) === 0;
|
|
548
547
|
}
|
|
@@ -579,9 +578,9 @@ class AppMeshClient {
|
|
|
579
578
|
* resource_limit: { cpu_shares: null, memory_mb: null, memory_virt_mb: null },
|
|
580
579
|
* behavior: { exit: "standby", exit_code_actions: { "0": "keepalive" } }
|
|
581
580
|
* };
|
|
582
|
-
* await client.
|
|
581
|
+
* await client.addApp("ping", appConfig);
|
|
583
582
|
*/
|
|
584
|
-
async
|
|
583
|
+
async addApp(name, appJson) {
|
|
585
584
|
const response = await this._request("put", `/appmesh/app/${name}`, appJson);
|
|
586
585
|
return response.data;
|
|
587
586
|
}
|
|
@@ -591,7 +590,7 @@ class AppMeshClient {
|
|
|
591
590
|
* @param {string} name - App name
|
|
592
591
|
* @returns {Promise<boolean>} Success status
|
|
593
592
|
*/
|
|
594
|
-
async
|
|
593
|
+
async deleteApp(name) {
|
|
595
594
|
try {
|
|
596
595
|
const response = await this._request("delete", `/appmesh/app/${name}`);
|
|
597
596
|
return response.status === 200;
|
|
@@ -606,7 +605,7 @@ class AppMeshClient {
|
|
|
606
605
|
* @param {string} name - App name
|
|
607
606
|
* @returns {Promise<boolean>} true on success; failures throw AppMeshError
|
|
608
607
|
*/
|
|
609
|
-
async
|
|
608
|
+
async enableApp(name) {
|
|
610
609
|
await this._request("post", `/appmesh/app/${name}/enable`);
|
|
611
610
|
return true;
|
|
612
611
|
}
|
|
@@ -616,7 +615,7 @@ class AppMeshClient {
|
|
|
616
615
|
* @param {string} name - App name
|
|
617
616
|
* @returns {Promise<boolean>} true on success; failures throw AppMeshError
|
|
618
617
|
*/
|
|
619
|
-
async
|
|
618
|
+
async disableApp(name) {
|
|
620
619
|
await this._request("post", `/appmesh/app/${name}/disable`);
|
|
621
620
|
return true;
|
|
622
621
|
}
|
|
@@ -632,7 +631,8 @@ class AppMeshClient {
|
|
|
632
631
|
* @param {number} [timeout=0] - Server long-poll timeout in seconds
|
|
633
632
|
* @returns {Promise<AppOutput>} Output body, next cursor, and exit code when available
|
|
634
633
|
*/
|
|
635
|
-
async
|
|
634
|
+
async getAppOutput(app_name, stdout_position = 0, stdout_index = 0, stdout_maxsize = 10240,
|
|
635
|
+
process_uuid = "", timeout = 0) {
|
|
636
636
|
const params = {
|
|
637
637
|
stdout_position: stdout_position.toString(),
|
|
638
638
|
stdout_index: stdout_index.toString(),
|
|
@@ -658,7 +658,8 @@ class AppMeshClient {
|
|
|
658
658
|
* @param {number|string} [lifecycle] - Lifecycle time
|
|
659
659
|
* @returns {Promise<number|null>} Exit code parsed from `X-Exit-Code`, or `null` when absent
|
|
660
660
|
*/
|
|
661
|
-
async
|
|
661
|
+
async runAppSync(app, stdoutHandler = defaultOutputHandler, maxTime = CONSTANTS.DEFAULT_RUN_APP_TIMEOUT_SECONDS,
|
|
662
|
+
lifecycle = CONSTANTS.DEFAULT_RUN_APP_LIFECYCLE_SECONDS) {
|
|
662
663
|
const params = {
|
|
663
664
|
timeout: parseDuration(maxTime),
|
|
664
665
|
lifecycle: parseDuration(lifecycle)
|
|
@@ -667,17 +668,15 @@ class AppMeshClient {
|
|
|
667
668
|
const response = await this._request("post", "/appmesh/app/syncrun", app, { params });
|
|
668
669
|
let exitCode = null;
|
|
669
670
|
|
|
671
|
+
if (stdoutHandler) {
|
|
672
|
+
stdoutHandler(response.data, 0);
|
|
673
|
+
}
|
|
670
674
|
if (response.status === 200) {
|
|
671
|
-
if (stdoutHandler) {
|
|
672
|
-
stdoutHandler(response.data, 0);
|
|
673
|
-
}
|
|
674
675
|
// axios lowercases header names; the TCP transport keeps the daemon's exact case
|
|
675
676
|
const exitCodeHeader = _getHeader(response.headers, "X-Exit-Code");
|
|
676
677
|
if (exitCodeHeader) {
|
|
677
678
|
exitCode = parseInt(exitCodeHeader, 10);
|
|
678
679
|
}
|
|
679
|
-
} else if (stdoutHandler) {
|
|
680
|
-
stdoutHandler(response.data, 0);
|
|
681
680
|
}
|
|
682
681
|
|
|
683
682
|
return exitCode;
|
|
@@ -690,7 +689,8 @@ class AppMeshClient {
|
|
|
690
689
|
* @param {string|number} [lifecycle] - Lifecycle time
|
|
691
690
|
* @returns {AppRun} Running app handle that also snapshots the current forwarding host
|
|
692
691
|
*/
|
|
693
|
-
async
|
|
692
|
+
async runAppAsync(app, maxTime = CONSTANTS.DEFAULT_RUN_APP_TIMEOUT_SECONDS,
|
|
693
|
+
lifecycle = CONSTANTS.DEFAULT_RUN_APP_LIFECYCLE_SECONDS) {
|
|
694
694
|
const params = {
|
|
695
695
|
timeout: parseDuration(maxTime),
|
|
696
696
|
lifecycle: parseDuration(lifecycle)
|
|
@@ -709,14 +709,14 @@ class AppMeshClient {
|
|
|
709
709
|
* the SDK also attempts to delete the temporary run app.
|
|
710
710
|
* @throws {AppMeshError} If polling the app output fails.
|
|
711
711
|
*/
|
|
712
|
-
async
|
|
712
|
+
async waitForAsyncRun(run, stdoutHandler = defaultOutputHandler, timeout = 0) {
|
|
713
713
|
if (run) {
|
|
714
714
|
let lastOutputPosition = 0;
|
|
715
715
|
const start = new Date();
|
|
716
716
|
const interval = 1;
|
|
717
717
|
|
|
718
718
|
while (run.procUid.length > 0) {
|
|
719
|
-
const appOut = await this.
|
|
719
|
+
const appOut = await this.getAppOutput(run.appName, lastOutputPosition, 0, 20480, run.procUid, interval);
|
|
720
720
|
if (appOut.output && stdoutHandler) {
|
|
721
721
|
stdoutHandler(appOut.output, lastOutputPosition);
|
|
722
722
|
}
|
|
@@ -727,7 +727,7 @@ class AppMeshClient {
|
|
|
727
727
|
|
|
728
728
|
if (appOut.exitCode !== null) {
|
|
729
729
|
// Process finished
|
|
730
|
-
await this.
|
|
730
|
+
await this.deleteApp(run.appName);
|
|
731
731
|
return appOut.exitCode;
|
|
732
732
|
}
|
|
733
733
|
|
|
@@ -749,7 +749,7 @@ class AppMeshClient {
|
|
|
749
749
|
* @param {number} [timeout=300] - Timeout in seconds
|
|
750
750
|
* @returns {Promise<string>} Response from app
|
|
751
751
|
*/
|
|
752
|
-
async
|
|
752
|
+
async runTask(appName, data, timeout = 300) {
|
|
753
753
|
if (timeout <= 0) {
|
|
754
754
|
timeout = 300;
|
|
755
755
|
}
|
|
@@ -764,7 +764,7 @@ class AppMeshClient {
|
|
|
764
764
|
* @param {string} appName - App name
|
|
765
765
|
* @returns {Promise<boolean>} true on success; failures throw AppMeshError
|
|
766
766
|
*/
|
|
767
|
-
async
|
|
767
|
+
async cancelTask(appName) {
|
|
768
768
|
await this._request("delete", `/appmesh/app/${appName}/task`);
|
|
769
769
|
return true;
|
|
770
770
|
}
|
|
@@ -785,7 +785,7 @@ class AppMeshClient {
|
|
|
785
785
|
* @param {boolean} [applyAttrs=false] - Node.js only: apply returned mode and best-effort
|
|
786
786
|
* owner/group metadata on non-Windows platforms
|
|
787
787
|
*/
|
|
788
|
-
async
|
|
788
|
+
async downloadFile(filePath, localFile = null, applyAttrs = false) {
|
|
789
789
|
if (!localFile) localFile = filePath.split(/[\\/]/).pop();
|
|
790
790
|
const headers = { [CONSTANTS.HTTP_HEADER_KEY_X_FILE_PATH]: encodeURIComponent(filePath) };
|
|
791
791
|
const response = await this._request("get", "/appmesh/file/download", null, {
|
|
@@ -851,7 +851,7 @@ class AppMeshClient {
|
|
|
851
851
|
* @param {boolean} [applyAttrs=false] - In Node.js, send local permission bits plus
|
|
852
852
|
* user/group (names when resolvable locally, numeric ids otherwise)
|
|
853
853
|
*/
|
|
854
|
-
async
|
|
854
|
+
async uploadFile(localFile, filePath = null, applyAttrs = false) {
|
|
855
855
|
if (!filePath) {
|
|
856
856
|
// Node.js passes a path string; browser passes a File (use its name)
|
|
857
857
|
const sourceName = typeof localFile === 'string' ? localFile : localFile && localFile.name;
|
|
@@ -927,7 +927,7 @@ class AppMeshClient {
|
|
|
927
927
|
* Get host resource usage
|
|
928
928
|
* @returns {Object} Resource stats
|
|
929
929
|
*/
|
|
930
|
-
async
|
|
930
|
+
async getHostResources() {
|
|
931
931
|
const response = await this._request("get", "/appmesh/resources");
|
|
932
932
|
return response.data;
|
|
933
933
|
}
|
|
@@ -936,7 +936,7 @@ class AppMeshClient {
|
|
|
936
936
|
* Get current configuration
|
|
937
937
|
* @returns {Promise<Object>} Config JSON
|
|
938
938
|
*/
|
|
939
|
-
async
|
|
939
|
+
async getConfig() {
|
|
940
940
|
const response = await this._request("get", "/appmesh/config");
|
|
941
941
|
return response.data;
|
|
942
942
|
}
|
|
@@ -946,7 +946,7 @@ class AppMeshClient {
|
|
|
946
946
|
* @param {Object} config - Partial config document to POST to `/appmesh/config`
|
|
947
947
|
* @returns {Object} Updated config
|
|
948
948
|
*/
|
|
949
|
-
async
|
|
949
|
+
async setConfig(config) {
|
|
950
950
|
const response = await this._request("post", "/appmesh/config", config);
|
|
951
951
|
return response.data;
|
|
952
952
|
}
|
|
@@ -956,8 +956,8 @@ class AppMeshClient {
|
|
|
956
956
|
* @param {string} [level="DEBUG"] - Log level
|
|
957
957
|
* @returns {string} Updated level
|
|
958
958
|
*/
|
|
959
|
-
async
|
|
960
|
-
const response = await this.
|
|
959
|
+
async setLogLevel(level = "DEBUG") {
|
|
960
|
+
const response = await this.setConfig({ BaseConfig: { LogLevel: level } });
|
|
961
961
|
return response.BaseConfig.LogLevel;
|
|
962
962
|
}
|
|
963
963
|
|
|
@@ -967,7 +967,7 @@ class AppMeshClient {
|
|
|
967
967
|
* @param {string} labelValue - Label value
|
|
968
968
|
* @returns {Promise<boolean>} true on success; failures throw AppMeshError
|
|
969
969
|
*/
|
|
970
|
-
async
|
|
970
|
+
async addLabel(labelName, labelValue) {
|
|
971
971
|
await this._request("put", `/appmesh/label/${labelName}`, null, { params: { value: labelValue } });
|
|
972
972
|
return true;
|
|
973
973
|
}
|
|
@@ -978,7 +978,7 @@ class AppMeshClient {
|
|
|
978
978
|
* @param {string} labelName - Label name
|
|
979
979
|
* @returns {Promise<boolean>} true on success; failures throw AppMeshError
|
|
980
980
|
*/
|
|
981
|
-
async
|
|
981
|
+
async deleteLabel(labelName) {
|
|
982
982
|
await this._request("delete", `/appmesh/label/${labelName}`);
|
|
983
983
|
return true;
|
|
984
984
|
}
|
|
@@ -988,59 +988,59 @@ class AppMeshClient {
|
|
|
988
988
|
* Get all server labels
|
|
989
989
|
* @returns {Promise<Object>} All labels
|
|
990
990
|
*/
|
|
991
|
-
async
|
|
991
|
+
async listLabels() {
|
|
992
992
|
const response = await this._request("get", "/appmesh/labels");
|
|
993
993
|
return response.data;
|
|
994
994
|
}
|
|
995
995
|
|
|
996
996
|
|
|
997
997
|
/** List Engine authorization overlays keyed by immutable principal ID. */
|
|
998
|
-
async
|
|
998
|
+
async listPrincipals() {
|
|
999
999
|
return (await this._request("get", "/appmesh/principals")).data;
|
|
1000
1000
|
}
|
|
1001
1001
|
|
|
1002
1002
|
/** Update an Engine authorization overlay; never mutate IdP account data. */
|
|
1003
|
-
async
|
|
1003
|
+
async updatePrincipal(principalId, policy) {
|
|
1004
1004
|
await this._request("post", `/appmesh/principal/${encodeURIComponent(principalId)}`, policy);
|
|
1005
1005
|
return true;
|
|
1006
1006
|
}
|
|
1007
1007
|
|
|
1008
1008
|
/** Delete only an Engine authorization overlay. */
|
|
1009
|
-
async
|
|
1009
|
+
async deletePrincipal(principalId) {
|
|
1010
1010
|
await this._request("delete", `/appmesh/principal/${encodeURIComponent(principalId)}`);
|
|
1011
1011
|
return true;
|
|
1012
1012
|
}
|
|
1013
1013
|
|
|
1014
1014
|
/** Safe compatibility alias returning a Principal, not an IdP user. */
|
|
1015
|
-
async
|
|
1016
|
-
return this.
|
|
1015
|
+
async getCurrentUser() {
|
|
1016
|
+
return this.getCurrentPrincipal();
|
|
1017
1017
|
}
|
|
1018
1018
|
|
|
1019
1019
|
/**
|
|
1020
1020
|
* Get available permissions
|
|
1021
1021
|
* @returns {Object[]} Permission list
|
|
1022
1022
|
*/
|
|
1023
|
-
async
|
|
1023
|
+
async listPermissions() {
|
|
1024
1024
|
const response = await this._request("get", "/appmesh/permissions");
|
|
1025
1025
|
return response.data;
|
|
1026
1026
|
}
|
|
1027
1027
|
|
|
1028
1028
|
/** Get effective permissions for the current verified principal. */
|
|
1029
|
-
async
|
|
1029
|
+
async getPrincipalPermissions() {
|
|
1030
1030
|
const response = await this._request("get", "/appmesh/principal/self/permissions");
|
|
1031
1031
|
return response.data;
|
|
1032
1032
|
}
|
|
1033
1033
|
|
|
1034
|
-
/** Safe compatibility alias for
|
|
1035
|
-
async
|
|
1036
|
-
return this.
|
|
1034
|
+
/** Safe compatibility alias for getPrincipalPermissions(). */
|
|
1035
|
+
async getUserPermissions() {
|
|
1036
|
+
return this.getPrincipalPermissions();
|
|
1037
1037
|
}
|
|
1038
1038
|
|
|
1039
1039
|
/**
|
|
1040
1040
|
* Get all roles and permissions
|
|
1041
1041
|
* @returns {Object[]} Role array
|
|
1042
1042
|
*/
|
|
1043
|
-
async
|
|
1043
|
+
async listRoles() {
|
|
1044
1044
|
const response = await this._request("get", "/appmesh/roles");
|
|
1045
1045
|
return response.data;
|
|
1046
1046
|
}
|
|
@@ -1051,7 +1051,7 @@ class AppMeshClient {
|
|
|
1051
1051
|
* @param {Object} rolePermissionJson - Permission IDs
|
|
1052
1052
|
* @returns {Promise<boolean>} true on success; failures throw AppMeshError
|
|
1053
1053
|
*/
|
|
1054
|
-
async
|
|
1054
|
+
async updateRole(roleName, rolePermissionJson) {
|
|
1055
1055
|
await this._request("post", `/appmesh/role/${roleName}`, rolePermissionJson);
|
|
1056
1056
|
return true;
|
|
1057
1057
|
}
|
|
@@ -1061,7 +1061,7 @@ class AppMeshClient {
|
|
|
1061
1061
|
* @param {string} roleName - Role name
|
|
1062
1062
|
* @returns {Promise<boolean>} true on success; failures throw AppMeshError
|
|
1063
1063
|
*/
|
|
1064
|
-
async
|
|
1064
|
+
async deleteRole(roleName) {
|
|
1065
1065
|
await this._request("delete", `/appmesh/role/${roleName}`);
|
|
1066
1066
|
return true;
|
|
1067
1067
|
}
|
|
@@ -1070,7 +1070,7 @@ class AppMeshClient {
|
|
|
1070
1070
|
* Get raw Prometheus metrics text from the server.
|
|
1071
1071
|
* @returns {Promise<string>} Metrics text
|
|
1072
1072
|
*/
|
|
1073
|
-
async
|
|
1073
|
+
async getMetrics() {
|
|
1074
1074
|
const response = await this._request("get", "/appmesh/metrics", null, {
|
|
1075
1075
|
config: { responseType: "text" }
|
|
1076
1076
|
});
|
|
@@ -1082,7 +1082,8 @@ class AppMeshClient {
|
|
|
1082
1082
|
* @throws {AppMeshError} Always — use AppMeshClientTCP for event subscriptions.
|
|
1083
1083
|
*/
|
|
1084
1084
|
async subscribe() {
|
|
1085
|
-
throw new AppMeshError("subscribe requires the TCP client (AppMeshClientTCP, imported from 'appmesh/tcp');
|
|
1085
|
+
throw new AppMeshError("subscribe requires the TCP client (AppMeshClientTCP, imported from 'appmesh/tcp'); " +
|
|
1086
|
+
"the HTTP client does not support event subscriptions");
|
|
1086
1087
|
}
|
|
1087
1088
|
|
|
1088
1089
|
/**
|
|
@@ -1090,7 +1091,8 @@ class AppMeshClient {
|
|
|
1090
1091
|
* @throws {AppMeshError} Always — use AppMeshClientTCP for event subscriptions.
|
|
1091
1092
|
*/
|
|
1092
1093
|
async unsubscribe() {
|
|
1093
|
-
throw new AppMeshError("unsubscribe requires the TCP client (AppMeshClientTCP, imported from 'appmesh/tcp');
|
|
1094
|
+
throw new AppMeshError("unsubscribe requires the TCP client (AppMeshClientTCP, imported from 'appmesh/tcp'); " +
|
|
1095
|
+
"the HTTP client does not support event subscriptions");
|
|
1094
1096
|
}
|
|
1095
1097
|
|
|
1096
1098
|
/**
|
|
@@ -1297,7 +1299,7 @@ class AppRun {
|
|
|
1297
1299
|
* @param {function} callback - Function to execute within the forward host context
|
|
1298
1300
|
* @returns {Promise<*>} Result of the callback function
|
|
1299
1301
|
*/
|
|
1300
|
-
async
|
|
1302
|
+
async withForwardingHost(callback) {
|
|
1301
1303
|
const originalValue = this._client.forwardingHost;
|
|
1302
1304
|
this._client.forwardingHost = this._forwardingHost;
|
|
1303
1305
|
try {
|
|
@@ -1314,14 +1316,18 @@ class AppRun {
|
|
|
1314
1316
|
* @returns {Promise<number|null>} Return exit code if process finished, return null for timeout or exception
|
|
1315
1317
|
*/
|
|
1316
1318
|
async wait(stdoutHandler = defaultOutputHandler, timeout = 0) {
|
|
1317
|
-
return this.
|
|
1318
|
-
this._client.
|
|
1319
|
+
return this.withForwardingHost(() =>
|
|
1320
|
+
this._client.waitForAsyncRun(this, stdoutHandler, timeout)
|
|
1319
1321
|
);
|
|
1320
1322
|
}
|
|
1321
1323
|
}
|
|
1322
1324
|
|
|
1323
1325
|
// Export the main classes
|
|
1324
|
-
export {
|
|
1326
|
+
export {
|
|
1327
|
+
AppMeshClient, AppOutput, AppRun, AppMeshError, AppRemovedError, TransportDisconnectedError,
|
|
1328
|
+
DEFAULT_CA_FILE, StaticAccessTokenProvider, RefreshTokenProvider
|
|
1329
|
+
};
|
|
1325
1330
|
// Exported for the TCP client (Node.js only); not part of the browser-facing API
|
|
1326
1331
|
export { _resolveUid, _resolveGid, _resolveUserName, _resolveGroupName };
|
|
1327
1332
|
export default AppMeshClient;
|
|
1333
|
+
|