@microsoft/managed-apps-cli 0.9.2 → 0.11.0
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 +18 -342
- package/dist/ArgumentProvider.d.ts.map +1 -1
- package/dist/ArgumentProvider.js +8 -1
- package/dist/ArgumentProvider.js.map +1 -1
- package/dist/Authentication/NodeMsalAuthenticationProvider.js +20 -1
- package/dist/Authentication/NodeMsalAuthenticationProvider.js.map +1 -1
- package/dist/Cli.d.ts.map +1 -1
- package/dist/Cli.js +15 -3
- package/dist/Cli.js.map +1 -1
- package/dist/Constants/CommandRegistry.d.ts +1 -2
- package/dist/Constants/CommandRegistry.d.ts.map +1 -1
- package/dist/Constants/CommandRegistry.js +26 -45
- package/dist/Constants/CommandRegistry.js.map +1 -1
- package/dist/Constants/HelpStrings.d.ts +12 -8
- package/dist/Constants/HelpStrings.d.ts.map +1 -1
- package/dist/Constants/HelpStrings.js +98 -80
- package/dist/Constants/HelpStrings.js.map +1 -1
- package/dist/Errors/GitHubErrorMap.d.ts +43 -14
- package/dist/Errors/GitHubErrorMap.d.ts.map +1 -1
- package/dist/Errors/GitHubErrorMap.js +189 -147
- package/dist/Errors/GitHubErrorMap.js.map +1 -1
- package/dist/Logger/CliLogger.d.ts +2 -0
- package/dist/Logger/CliLogger.d.ts.map +1 -1
- package/dist/Logger/CliLogger.js +12 -3
- package/dist/Logger/CliLogger.js.map +1 -1
- package/dist/Logger/ConsoleWriter.d.ts +2 -0
- package/dist/Logger/ConsoleWriter.d.ts.map +1 -1
- package/dist/Logger/ConsoleWriter.js +17 -7
- package/dist/Logger/ConsoleWriter.js.map +1 -1
- package/dist/Types/Argument.types.d.ts +1 -0
- package/dist/Types/Argument.types.d.ts.map +1 -1
- package/dist/Types/Command.types.d.ts +6 -0
- package/dist/Types/Command.types.d.ts.map +1 -1
- package/dist/Types/Command.types.js +8 -0
- package/dist/Types/Command.types.js.map +1 -1
- package/dist/Utils/BuildVerbDescriptionTable.d.ts.map +1 -1
- package/dist/Utils/BuildVerbDescriptionTable.js +6 -2
- package/dist/Utils/BuildVerbDescriptionTable.js.map +1 -1
- package/dist/Utils/ConnectorIds.d.ts +12 -0
- package/dist/Utils/ConnectorIds.d.ts.map +1 -0
- package/dist/Utils/ConnectorIds.js +20 -0
- package/dist/Utils/ConnectorIds.js.map +1 -0
- package/dist/Utils/DcfRecovery.d.ts +7 -7
- package/dist/Utils/DcfRecovery.d.ts.map +1 -1
- package/dist/Utils/DcfRecovery.js +17 -37
- package/dist/Utils/DcfRecovery.js.map +1 -1
- package/dist/Utils/DownloadTemplate.d.ts +45 -0
- package/dist/Utils/DownloadTemplate.d.ts.map +1 -0
- package/dist/Utils/DownloadTemplate.js +161 -0
- package/dist/Utils/DownloadTemplate.js.map +1 -0
- package/dist/Utils/EnvVars.d.ts +1 -1
- package/dist/Utils/EnvVars.d.ts.map +1 -1
- package/dist/Utils/EnvVars.js.map +1 -1
- package/dist/Utils/EnvironmentRoutingUtils.d.ts +20 -1
- package/dist/Utils/EnvironmentRoutingUtils.d.ts.map +1 -1
- package/dist/Utils/EnvironmentRoutingUtils.js +78 -3
- package/dist/Utils/EnvironmentRoutingUtils.js.map +1 -1
- package/dist/Utils/GitErrorClassifier.d.ts +40 -0
- package/dist/Utils/GitErrorClassifier.d.ts.map +1 -0
- package/dist/Utils/GitErrorClassifier.js +120 -0
- package/dist/Utils/GitErrorClassifier.js.map +1 -0
- package/dist/Utils/GitRunner.d.ts +107 -0
- package/dist/Utils/GitRunner.d.ts.map +1 -0
- package/dist/Utils/GitRunner.js +89 -0
- package/dist/Utils/GitRunner.js.map +1 -0
- package/dist/Utils/GitUtils.d.ts +12 -0
- package/dist/Utils/GitUtils.d.ts.map +1 -1
- package/dist/Utils/GitUtils.js +83 -20
- package/dist/Utils/GitUtils.js.map +1 -1
- package/dist/Utils/GitVersionChecker.d.ts +38 -0
- package/dist/Utils/GitVersionChecker.d.ts.map +1 -0
- package/dist/Utils/GitVersionChecker.js +64 -0
- package/dist/Utils/GitVersionChecker.js.map +1 -0
- package/dist/Utils/MaafAppConfig.d.ts +22 -0
- package/dist/Utils/MaafAppConfig.d.ts.map +1 -0
- package/dist/Utils/MaafAppConfig.js +32 -0
- package/dist/Utils/MaafAppConfig.js.map +1 -0
- package/dist/Utils/NodeVersionChecker.d.ts +3 -6
- package/dist/Utils/NodeVersionChecker.d.ts.map +1 -1
- package/dist/Utils/NodeVersionChecker.js +9 -26
- package/dist/Utils/NodeVersionChecker.js.map +1 -1
- package/dist/Utils/Paging.d.ts +6 -0
- package/dist/Utils/Paging.d.ts.map +1 -1
- package/dist/Utils/Paging.js +36 -1
- package/dist/Utils/Paging.js.map +1 -1
- package/dist/Utils/PinCli.d.ts +28 -0
- package/dist/Utils/PinCli.d.ts.map +1 -0
- package/dist/Utils/PinCli.js +58 -0
- package/dist/Utils/PinCli.js.map +1 -0
- package/dist/Utils/RepoDetails.d.ts +29 -0
- package/dist/Utils/RepoDetails.d.ts.map +1 -0
- package/dist/Utils/RepoDetails.js +37 -0
- package/dist/Utils/RepoDetails.js.map +1 -0
- package/dist/Utils/RepoOption.d.ts +35 -0
- package/dist/Utils/RepoOption.d.ts.map +1 -0
- package/dist/Utils/RepoOption.js +36 -0
- package/dist/Utils/RepoOption.js.map +1 -0
- package/dist/Utils/ResolveCommand.d.ts.map +1 -1
- package/dist/Utils/ResolveCommand.js +6 -4
- package/dist/Utils/ResolveCommand.js.map +1 -1
- package/dist/Utils/Spinner.d.ts.map +1 -1
- package/dist/Utils/Spinner.js +3 -0
- package/dist/Utils/Spinner.js.map +1 -1
- package/dist/Verbs/AddAction.js +6 -6
- package/dist/Verbs/AddAction.js.map +1 -1
- package/dist/Verbs/AddConnector.d.ts +6 -4
- package/dist/Verbs/AddConnector.d.ts.map +1 -1
- package/dist/Verbs/AddConnector.js +54 -14
- package/dist/Verbs/AddConnector.js.map +1 -1
- package/dist/Verbs/AddConnectorFlows.d.ts +29 -16
- package/dist/Verbs/AddConnectorFlows.d.ts.map +1 -1
- package/dist/Verbs/AddConnectorFlows.js +73 -25
- package/dist/Verbs/AddConnectorFlows.js.map +1 -1
- package/dist/Verbs/AddDataSource.d.ts +3 -4
- package/dist/Verbs/AddDataSource.d.ts.map +1 -1
- package/dist/Verbs/AddDataSource.js +9 -20
- package/dist/Verbs/AddDataSource.js.map +1 -1
- package/dist/Verbs/AddTable.js +7 -7
- package/dist/Verbs/AddTable.js.map +1 -1
- package/dist/Verbs/AuthStatus.d.ts.map +1 -1
- package/dist/Verbs/AuthStatus.js +7 -4
- package/dist/Verbs/AuthStatus.js.map +1 -1
- package/dist/Verbs/BuildMaafApp.js +1 -1
- package/dist/Verbs/BuildMaafApp.js.map +1 -1
- package/dist/Verbs/ConnectorHelpers.d.ts +5 -4
- package/dist/Verbs/ConnectorHelpers.d.ts.map +1 -1
- package/dist/Verbs/ConnectorHelpers.js +14 -9
- package/dist/Verbs/ConnectorHelpers.js.map +1 -1
- package/dist/Verbs/CreateMaafApp.d.ts +25 -42
- package/dist/Verbs/CreateMaafApp.d.ts.map +1 -1
- package/dist/Verbs/CreateMaafApp.js +346 -268
- package/dist/Verbs/CreateMaafApp.js.map +1 -1
- package/dist/Verbs/DeployMaafApp.d.ts.map +1 -1
- package/dist/Verbs/DeployMaafApp.js +4 -4
- package/dist/Verbs/DeployMaafApp.js.map +1 -1
- package/dist/Verbs/Dev.js +1 -1
- package/dist/Verbs/Dev.js.map +1 -1
- package/dist/Verbs/GetMaafApp.d.ts.map +1 -1
- package/dist/Verbs/GetMaafApp.js +10 -0
- package/dist/Verbs/GetMaafApp.js.map +1 -1
- package/dist/Verbs/GetMaafBuildStatus.d.ts.map +1 -1
- package/dist/Verbs/GetMaafBuildStatus.js +52 -3
- package/dist/Verbs/GetMaafBuildStatus.js.map +1 -1
- package/dist/Verbs/GetSettings.js +1 -1
- package/dist/Verbs/GetSettings.js.map +1 -1
- package/dist/Verbs/Init.d.ts.map +1 -1
- package/dist/Verbs/Init.js +183 -60
- package/dist/Verbs/Init.js.map +1 -1
- package/dist/Verbs/ListConnectorActions.js +12 -9
- package/dist/Verbs/ListConnectorActions.js.map +1 -1
- package/dist/Verbs/ListConnectors.d.ts.map +1 -1
- package/dist/Verbs/ListConnectors.js +3 -2
- package/dist/Verbs/ListConnectors.js.map +1 -1
- package/dist/Verbs/ListMaafApps.js +3 -3
- package/dist/Verbs/ListMaafApps.js.map +1 -1
- package/dist/Verbs/MaafAppPermissions.d.ts.map +1 -1
- package/dist/Verbs/MaafAppPermissions.js +89 -17
- package/dist/Verbs/MaafAppPermissions.js.map +1 -1
- package/dist/Verbs/Pack.d.ts +1 -1
- package/dist/Verbs/RefreshDataSource.js +1 -1
- package/dist/Verbs/RefreshDataSource.js.map +1 -1
- package/dist/Verbs/RefreshGitAuth.d.ts.map +1 -1
- package/dist/Verbs/RefreshGitAuth.js +3 -15
- package/dist/Verbs/RefreshGitAuth.js.map +1 -1
- package/dist/Verbs/{DeleteDataSource.d.ts → RemoveDataSource.d.ts} +2 -2
- package/dist/Verbs/RemoveDataSource.d.ts.map +1 -0
- package/dist/Verbs/RemoveDataSource.js +158 -0
- package/dist/Verbs/RemoveDataSource.js.map +1 -0
- package/dist/Verbs/SetSetting.js +2 -2
- package/dist/Verbs/SetSetting.js.map +1 -1
- package/dist/Verbs/ShareLinkList.js +1 -1
- package/dist/Verbs/ShareLinkList.js.map +1 -1
- package/dist/Verbs/ShowMaafApp.d.ts +6 -0
- package/dist/Verbs/ShowMaafApp.d.ts.map +1 -1
- package/dist/Verbs/ShowMaafApp.js +10 -2
- package/dist/Verbs/ShowMaafApp.js.map +1 -1
- package/dist/Verbs/VerbConstants.d.ts +20 -23
- package/dist/Verbs/VerbConstants.d.ts.map +1 -1
- package/dist/Verbs/VerbConstants.js +20 -23
- package/dist/Verbs/VerbConstants.js.map +1 -1
- package/dist/Verbs/index.d.ts +1 -1
- package/dist/Verbs/index.d.ts.map +1 -1
- package/dist/Verbs/index.js +1 -1
- package/dist/Verbs/index.js.map +1 -1
- package/package.json +11 -9
- package/dist/Verbs/DeleteDataSource.d.ts.map +0 -1
- package/dist/Verbs/DeleteDataSource.js +0 -105
- package/dist/Verbs/DeleteDataSource.js.map +0 -1
|
@@ -2,193 +2,235 @@
|
|
|
2
2
|
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Maps structured server error codes
|
|
6
|
-
* subclasses
|
|
7
|
-
*
|
|
5
|
+
* Maps structured GRS server error codes onto CLI-facing {@link AppError}
|
|
6
|
+
* subclasses. The server is the source of truth for human-readable text:
|
|
7
|
+
* we pass `payload.message` through verbatim for the 13 codes in
|
|
8
|
+
* {@link mapGitHubServerErrorToCliError}'s switch and the 5 codes recognized
|
|
9
|
+
* by {@link matchGitHubAuthError} (3 of which overlap with the switch). The
|
|
10
|
+
* AppError subclass we choose only determines the CLI exit code — wording
|
|
11
|
+
* is owned by GRS so it can be updated server-side without a CLI release.
|
|
8
12
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* One intentional exception to the passthrough contract: if a recognized
|
|
14
|
+
* code arrives with an empty / whitespace-only / missing `message`,
|
|
15
|
+
* {@link mapGitHubServerErrorToCliError} returns `null` rather than
|
|
16
|
+
* constructing an AppError with an empty body. Callers (e.g. the top-level
|
|
17
|
+
* CLI catch) use `?? rawErr` so the original error bubbles up untouched —
|
|
18
|
+
* preferable to swallowing it behind a blank typed error.
|
|
19
|
+
*
|
|
20
|
+
* Three entry points:
|
|
21
|
+
* - {@link mapGitHubServerErrorToCliError} — given a parsed payload, return
|
|
22
|
+
* the mapped AppError (or null for unrecognized codes / empty messages).
|
|
23
|
+
* - {@link formatServerError} — given an arbitrary thrown value, detect a
|
|
24
|
+
* recognized GRS envelope inside (GrsServerError, HttpClientError body, or
|
|
25
|
+
* a plain Error whose message embeds the JSON envelope) and return the
|
|
26
|
+
* mapped AppError. Wired into the global Cli.boot catch. Values that are
|
|
27
|
+
* already an {@link AppError} (e.g. errors thrown directly by a verb) are
|
|
28
|
+
* passed through untouched — we return `null` so the caller's `?? rawErr`
|
|
29
|
+
* keeps the original typed error rather than risking the greedy
|
|
30
|
+
* `\{[\s\S]*\}` regex matching braces inside an existing message.
|
|
31
|
+
* - {@link matchGitHubAuthError} — used by the DCF auto-recovery path to
|
|
32
|
+
* detect the recoverable mapping-error codes
|
|
33
|
+
* ({@link RECOVERABLE_MAPPING_CODES}).
|
|
18
34
|
*/
|
|
19
35
|
import { GrsServerError } from '@microsoft/managed-apps-actions';
|
|
20
|
-
import {
|
|
21
|
-
import { AuthenticationError, ConfigurationError, NetworkError, UsageError, } from './CliError.js';
|
|
36
|
+
import { HttpClientError } from '@microsoft/managed-apps-common/services';
|
|
37
|
+
import { AppError, AuthenticationError, ConfigurationError, NetworkError, UsageError, } from './CliError.js';
|
|
22
38
|
/**
|
|
23
|
-
*
|
|
39
|
+
* Server error codes that signal a recoverable GitHub mapping problem the
|
|
40
|
+
* CLI can resolve in-process via the Device Code Flow (DCF) auto-recovery
|
|
41
|
+
* path. {@link matchGitHubAuthError} uses this tuple to gate dispatch into
|
|
42
|
+
* the verb's catch-and-retry flow.
|
|
43
|
+
*/
|
|
44
|
+
const RECOVERABLE_MAPPING_CODES = [
|
|
45
|
+
'GitHubMappingMissing',
|
|
46
|
+
'GitHubMappingExpired',
|
|
47
|
+
'GitHubMappingStale',
|
|
48
|
+
];
|
|
49
|
+
function isRecoverableMappingCode(code) {
|
|
50
|
+
return (typeof code === 'string' && RECOVERABLE_MAPPING_CODES.includes(code));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Map a structured server error payload to a CLI-facing {@link AppError}.
|
|
54
|
+
* The AppError subclass selects the CLI exit code; the message is the
|
|
55
|
+
* server-supplied `payload.message` passed through verbatim (server is the
|
|
56
|
+
* source of truth for user-facing wording on these codes).
|
|
57
|
+
*
|
|
24
58
|
* Returns `null` for codes the CLI doesn't recognize so callers can fall back
|
|
25
59
|
* to generic error handling.
|
|
26
60
|
*/
|
|
27
|
-
export function mapGitHubServerErrorToCliError(payload
|
|
61
|
+
export function mapGitHubServerErrorToCliError(payload) {
|
|
28
62
|
const code = payload.code;
|
|
29
63
|
if (!code)
|
|
30
64
|
return null;
|
|
31
|
-
|
|
32
|
-
|
|
65
|
+
// The server message is the source of truth. If it's missing or
|
|
66
|
+
// whitespace-only, return null so the caller's `?? rawErr` keeps the
|
|
67
|
+
// original (informative) error rather than replacing it with an AppError
|
|
68
|
+
// that has an empty message.
|
|
69
|
+
const message = payload.message;
|
|
70
|
+
if (!message || !message.trim())
|
|
71
|
+
return null;
|
|
33
72
|
switch (code) {
|
|
73
|
+
// --- Authentication (exit 3) ----------------------------------------
|
|
34
74
|
case 'GitHubMappingMissing':
|
|
35
|
-
return new AuthenticationError(`Your GitHub identity isn't established for ${ownerRepo}. ` +
|
|
36
|
-
`Run \`ms git auth refresh --repo ${host}/${ownerRepo}\` and retry.`);
|
|
37
75
|
case 'GitHubMappingExpired':
|
|
38
|
-
return new AuthenticationError(`Your GitHub authentication for ${ownerRepo} has expired. ` +
|
|
39
|
-
`Run \`ms git auth refresh --repo ${host}/${ownerRepo}\` to refresh.`);
|
|
40
76
|
case 'GitHubMappingStale':
|
|
41
|
-
return new AuthenticationError(`Your stored GitHub identity for ${ownerRepo} no longer matches your GitHub account ` +
|
|
42
|
-
`(it may have been renamed or reassigned). Run \`ms git auth refresh --repo ${host}/${ownerRepo}\` to refresh.`);
|
|
43
|
-
case 'GitHubAppNotInstalled': {
|
|
44
|
-
const appName = stringDetail(details, 'appName') ?? '<app-name>';
|
|
45
|
-
return new ConfigurationError(`The Managed Apps GitHub App isn't installed on the org owning ${ownerRepo}. ` +
|
|
46
|
-
`Ask an admin to install it: https://${host}/apps/${appName}/installations/new`);
|
|
47
|
-
}
|
|
48
77
|
case 'GitHubUserLacksAccess':
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
case 'GitHubUserLacksRequiredLevel': {
|
|
52
|
-
const minLevel = stringDetail(details, 'minLevel') ?? 'a higher level of';
|
|
53
|
-
const actualLevel = stringDetail(details, 'actualLevel') ?? 'lower';
|
|
54
|
-
return new AuthenticationError(`Operation requires ${minLevel} access on ${ownerRepo}; you have ${actualLevel}.`);
|
|
55
|
-
}
|
|
56
|
-
case 'GitHubRepoArchived':
|
|
57
|
-
return new UsageError(`${ownerRepo} is archived. Unarchive it before continuing.`);
|
|
58
|
-
case 'GitHubInstallationSuspended':
|
|
59
|
-
return new ConfigurationError(`The Managed Apps GitHub App installation for the org owning ${ownerRepo} is suspended. ` +
|
|
60
|
-
`Ask an admin to unsuspend it.`);
|
|
61
|
-
case 'GitHubAuthSessionExpired': {
|
|
62
|
-
const expiresIn = numericDetail(details, 'expiresIn');
|
|
63
|
-
const window = expiresIn !== undefined ? `${expiresIn} seconds` : 'the displayed time window';
|
|
64
|
-
return new AuthenticationError(`Authentication session expired before completion. Re-run the command and complete ` +
|
|
65
|
-
`the GitHub sign-in within ${window}.`);
|
|
66
|
-
}
|
|
78
|
+
case 'GitHubUserLacksRequiredLevel':
|
|
79
|
+
case 'GitHubAuthSessionExpired':
|
|
67
80
|
case 'GitHubAuthSessionNotFound':
|
|
68
|
-
return new AuthenticationError('Authentication session was not found (the server may have restarted). Re-run the command.');
|
|
69
81
|
case 'GitHubAuthDenied':
|
|
70
|
-
return new AuthenticationError("You declined to authorize the Managed Apps GitHub App. The repository binding can't proceed without authorization.");
|
|
71
82
|
case 'GitHubAuthCancelled':
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const safeUrl = host !== '<tenant>.ghe.com' && ownerRepo !== '<owner>/<repo>'
|
|
88
|
-
? `https://${host}/${ownerRepo}`
|
|
89
|
-
: 'The supplied repository URL';
|
|
90
|
-
return new UsageError(`${safeUrl} is not a valid GitHub repository URL. The server expects an https:// ` +
|
|
91
|
-
`URL on a *.ghe.com tenant (e.g. 'https://contoso.ghe.com/<owner>/<repo>') or ` +
|
|
92
|
-
`'https://github.com/<owner>/<repo>'.`);
|
|
93
|
-
}
|
|
94
|
-
case 'GitHubUpstreamError': {
|
|
95
|
-
// Upstream errors carry server diagnostics (e.g. Key Vault failures, GitHub
|
|
96
|
-
// API responses) that are the only useful diagnostic for the user. Surface
|
|
97
|
-
// the underlying message verbatim rather than swallowing it.
|
|
98
|
-
const detail = payload.message?.trim();
|
|
99
|
-
return new NetworkError(detail
|
|
100
|
-
? `GitHub returned an unexpected error: ${detail}`
|
|
101
|
-
: 'GitHub returned an unexpected error. Try again.');
|
|
102
|
-
}
|
|
83
|
+
return new AuthenticationError(message);
|
|
84
|
+
// --- Configuration (exit 4) -----------------------------------------
|
|
85
|
+
case 'GitHubAppNotInstalled':
|
|
86
|
+
case 'GitHubInstallationSuspended':
|
|
87
|
+
return new ConfigurationError(message);
|
|
88
|
+
// --- Network (exit 5) -----------------------------------------------
|
|
89
|
+
case 'GitHubRateLimited':
|
|
90
|
+
case 'GitHubEvaluationError':
|
|
91
|
+
case 'GitHubUpstreamError':
|
|
92
|
+
return new NetworkError(message);
|
|
93
|
+
// --- Usage (exit 2) -------------------------------------------------
|
|
94
|
+
case 'GitHubRepoArchived':
|
|
95
|
+
case 'GitHubRepoNotEnterprise':
|
|
96
|
+
case 'GitHubRepoNotFound':
|
|
97
|
+
return new UsageError(message);
|
|
103
98
|
default:
|
|
104
99
|
return null;
|
|
105
100
|
}
|
|
106
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Inspect an arbitrary thrown value and, if it carries a recognized GRS
|
|
104
|
+
* envelope, return the mapped {@link AppError}. Returns `null` otherwise.
|
|
105
|
+
*
|
|
106
|
+
* Accepts:
|
|
107
|
+
* - {@link GrsServerError} — direct field access.
|
|
108
|
+
* - {@link HttpClientError} — parse `body` as JSON for `error.code|message`.
|
|
109
|
+
* - Plain {@link Error} whose `.message` embeds `{"error":{...}}` (legacy
|
|
110
|
+
* pre-`allowErrorResponse` path).
|
|
111
|
+
*
|
|
112
|
+
* Intended for the top-level CLI catch so all verbs get envelope handling for
|
|
113
|
+
* free without each having to special-case GrsServerError.
|
|
114
|
+
*/
|
|
115
|
+
export function formatServerError(error) {
|
|
116
|
+
// If the thrown value is already a CLI-typed AppError (e.g. a verb threw
|
|
117
|
+
// UsageError directly, or this function was previously invoked and the
|
|
118
|
+
// mapped error was re-thrown), don't try to re-parse it. The plain-Error
|
|
119
|
+
// branch's greedy `\{[\s\S]*\}` regex would otherwise risk matching
|
|
120
|
+
// unintended braces inside an existing message. Returning null here lets
|
|
121
|
+
// the top-level catch's `?? rawErr` fall through to the original AppError
|
|
122
|
+
// unchanged.
|
|
123
|
+
if (error instanceof AppError)
|
|
124
|
+
return null;
|
|
125
|
+
const payload = extractServerErrorPayload(error);
|
|
126
|
+
if (!payload)
|
|
127
|
+
return null;
|
|
128
|
+
return mapGitHubServerErrorToCliError(payload);
|
|
129
|
+
}
|
|
107
130
|
/**
|
|
108
131
|
* Inspect an unknown error and decide whether the CLI should run the DCF
|
|
109
132
|
* recovery flow (i.e. the verb's catch-and-retry path). Returns the parsed
|
|
110
133
|
* payload + matched code, or `null` if the error is unrelated.
|
|
111
134
|
*
|
|
112
135
|
* Matches:
|
|
113
|
-
* - `GrsServerError` with `code
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
136
|
+
* - `GrsServerError` with `code` in {@link RECOVERABLE_MAPPING_CODES}
|
|
137
|
+
* (status accepted as-is from the typed envelope).
|
|
138
|
+
* - Any other shape recognized by {@link extractServerErrorPayload}
|
|
139
|
+
* (`HttpClientError`, or a plain `Error` whose message embeds the JSON
|
|
140
|
+
* envelope) with a recoverable code AND HTTP status 401.
|
|
141
|
+
*
|
|
142
|
+
* Intentionally narrower than {@link extractServerErrorPayload}: that helper
|
|
143
|
+
* recovers any recognized envelope for generic error formatting, whereas this
|
|
144
|
+
* function exists solely to dispatch DCF auto-recovery and therefore gates on
|
|
145
|
+
* (a) the specific recoverable codes and (b) for legacy / untyped shapes,
|
|
146
|
+
* HTTP 401 only. A 401 with a non-recoverable code, or a recoverable code at
|
|
147
|
+
* a different status, must not trigger the recovery flow.
|
|
117
148
|
*/
|
|
118
149
|
export function matchGitHubAuthError(error) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
error.code === 'GitHubMappingExpired' ||
|
|
122
|
-
error.code === 'GitHubMappingStale') {
|
|
123
|
-
return {
|
|
124
|
-
code: error.code,
|
|
125
|
-
payload: {
|
|
126
|
-
code: error.code,
|
|
127
|
-
message: error.message,
|
|
128
|
-
status: error.status,
|
|
129
|
-
details: error.details,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
150
|
+
const payload = extractServerErrorPayload(error);
|
|
151
|
+
if (!payload)
|
|
133
152
|
return null;
|
|
153
|
+
const code = payload.code;
|
|
154
|
+
if (!isRecoverableMappingCode(code))
|
|
155
|
+
return null;
|
|
156
|
+
// Status gating: GrsServerError carries an authoritative status from a
|
|
157
|
+
// typed envelope, so we trust whatever it reports. Every other wire shape
|
|
158
|
+
// (HttpClientError body, plain Error with embedded JSON) is the legacy
|
|
159
|
+
// fallback path and must additionally be HTTP 401 — a recoverable code at
|
|
160
|
+
// any other status indicates a different failure mode (e.g. a 500 echoing
|
|
161
|
+
// a mapping code in its body) that DCF recovery cannot fix.
|
|
162
|
+
if (!(error instanceof GrsServerError) && payload.status !== 401)
|
|
163
|
+
return null;
|
|
164
|
+
return { code, payload };
|
|
165
|
+
}
|
|
166
|
+
// === Helpers ==================================================================
|
|
167
|
+
/**
|
|
168
|
+
* Extract a {@link ServerErrorPayload} from any of the supported wire-error
|
|
169
|
+
* shapes. Returns `null` if no envelope can be recovered.
|
|
170
|
+
*/
|
|
171
|
+
function extractServerErrorPayload(error) {
|
|
172
|
+
if (error instanceof GrsServerError) {
|
|
173
|
+
return {
|
|
174
|
+
code: error.code,
|
|
175
|
+
message: error.message,
|
|
176
|
+
status: error.status,
|
|
177
|
+
details: error.details,
|
|
178
|
+
};
|
|
134
179
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (!statusMatch || statusMatch[1] !== '401')
|
|
180
|
+
if (error instanceof HttpClientError) {
|
|
181
|
+
const parsed = parseEnvelope(error.body);
|
|
182
|
+
if (!parsed)
|
|
139
183
|
return null;
|
|
184
|
+
// Intentionally do NOT fall back to `error.message`: on HttpClientError
|
|
185
|
+
// that's the verbose HTTP blob ("HTTP error status: 403 for POST ...:
|
|
186
|
+
// {...}") which we must never surface to the user. An empty string here
|
|
187
|
+
// makes the mapper's empty-message guard fire, so the caller's `?? rawErr`
|
|
188
|
+
// path preserves the original error instead.
|
|
189
|
+
return {
|
|
190
|
+
code: parsed.code,
|
|
191
|
+
message: parsed.message ?? '',
|
|
192
|
+
status: error.status,
|
|
193
|
+
details: parsed.details,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if (error instanceof Error) {
|
|
140
197
|
const jsonMatch = error.message.match(/\{[\s\S]*\}/);
|
|
141
198
|
if (!jsonMatch)
|
|
142
199
|
return null;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
161
|
-
// Not JSON — not a match.
|
|
162
|
-
}
|
|
200
|
+
const parsed = parseEnvelope(jsonMatch[0]);
|
|
201
|
+
if (!parsed?.code)
|
|
202
|
+
return null;
|
|
203
|
+
const statusMatch = error.message.match(/status:\s*(\d+)/i);
|
|
204
|
+
// See HttpClientError branch above: `error.message` here is the same
|
|
205
|
+
// verbose blob (the envelope JSON was extracted *from* it), so falling
|
|
206
|
+
// back to it would defeat the mapper's empty-message guard.
|
|
207
|
+
return {
|
|
208
|
+
code: parsed.code,
|
|
209
|
+
message: parsed.message ?? '',
|
|
210
|
+
status: statusMatch ? Number(statusMatch[1]) : 0,
|
|
211
|
+
details: parsed.details,
|
|
212
|
+
};
|
|
163
213
|
}
|
|
164
214
|
return null;
|
|
165
215
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
216
|
+
function parseEnvelope(body) {
|
|
217
|
+
if (!body)
|
|
218
|
+
return null;
|
|
219
|
+
try {
|
|
220
|
+
const data = JSON.parse(body);
|
|
221
|
+
const error = data?.error;
|
|
222
|
+
if (!error || typeof error !== 'object')
|
|
223
|
+
return null;
|
|
224
|
+
return {
|
|
225
|
+
code: typeof error.code === 'string' ? error.code : undefined,
|
|
226
|
+
message: typeof error.message === 'string' ? error.message : undefined,
|
|
227
|
+
details: error.details && typeof error.details === 'object'
|
|
228
|
+
? error.details
|
|
229
|
+
: undefined,
|
|
230
|
+
};
|
|
173
231
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
function stringDetail(details, key) {
|
|
177
|
-
const v = details[key];
|
|
178
|
-
return typeof v === 'string' ? v : undefined;
|
|
179
|
-
}
|
|
180
|
-
function numericDetail(details, key) {
|
|
181
|
-
const v = details[key];
|
|
182
|
-
if (typeof v === 'number' && Number.isFinite(v))
|
|
183
|
-
return v;
|
|
184
|
-
// Servers sometimes encode integer details as strings (e.g. JSON producers
|
|
185
|
-
// that stringify all `number | bigint` fields). Coerce on a best-effort basis
|
|
186
|
-
// so the user-facing message keeps the seconds/retry value instead of
|
|
187
|
-
// silently dropping it.
|
|
188
|
-
if (typeof v === 'string') {
|
|
189
|
-
const n = Number(v);
|
|
190
|
-
return Number.isFinite(n) ? n : undefined;
|
|
232
|
+
catch {
|
|
233
|
+
return null;
|
|
191
234
|
}
|
|
192
|
-
return undefined;
|
|
193
235
|
}
|
|
194
236
|
//# sourceMappingURL=GitHubErrorMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubErrorMap.js","sourceRoot":"","sources":["../../src/Errors/GitHubErrorMap.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH
|
|
1
|
+
{"version":3,"file":"GitHubErrorMap.js","sourceRoot":"","sources":["../../src/Errors/GitHubErrorMap.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE1E,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG;IAChC,sBAAsB;IACtB,sBAAsB;IACtB,oBAAoB;CACZ,CAAC;AAIX,SAAS,wBAAwB,CAAC,IAAa;IAC7C,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ,IAAK,yBAA+C,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC5F,CAAC;AACJ,CAAC;AAUD;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAAC,OAA2B;IACxE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,gEAAgE;IAChE,qEAAqE;IACrE,yEAAyE;IACzE,6BAA6B;IAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CA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,OAAO,CAAC,CAAC,CAAC,SAAS;YACtE,OAAO,EACL,KAAK,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;gBAChD,CAAC,CAAE,KAAK,CAAC,OAAmC;gBAC5C,CAAC,CAAC,SAAS;SAChB,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -29,7 +29,9 @@ import type { CliSettings, IAuthenticationProvider } from '../Types/Cli.types.js
|
|
|
29
29
|
export declare class CliLogger implements ILogger {
|
|
30
30
|
private _telemetryWriters;
|
|
31
31
|
private _unauthWriter?;
|
|
32
|
+
private readonly _customDimensions;
|
|
32
33
|
private _upgradeFired;
|
|
34
|
+
private readonly _sessionId;
|
|
33
35
|
private _upgradeConfig?;
|
|
34
36
|
private constructor();
|
|
35
37
|
static create(cliSettings: CliSettings, httpClient: CliHttpClient, authenticationProvider: IAuthenticationProvider): Promise<CliLogger>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliLogger.d.ts","sourceRoot":"","sources":["../../src/Logger/CliLogger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAIzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EAExB,MAAM,oBAAoB,CAAC;AA0F5B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,SAAU,YAAW,OAAO;IACvC,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,aAAa,CAAC,CAAc;IACpC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAC,CAMrB;IAEF,OAAO;
|
|
1
|
+
{"version":3,"file":"CliLogger.d.ts","sourceRoot":"","sources":["../../src/Logger/CliLogger.ts"],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AE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIvD,YAAY,CAAC,SAAS,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAI5E,IAAW,SAAS,IAAI,MAAM,GAAG,SAAS,CAEzC;IAED,IAAW,SAAS,CAAC,MAAM,EAAE,MAAM,EAElC;IAEM,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,OAAO;CAMjF"}
|
package/dist/Logger/CliLogger.js
CHANGED
|
@@ -108,10 +108,13 @@ function createScenarioLogger(telemetryWriters, name, data) {
|
|
|
108
108
|
export class CliLogger {
|
|
109
109
|
_telemetryWriters = [];
|
|
110
110
|
_unauthWriter;
|
|
111
|
+
_customDimensions = {};
|
|
111
112
|
_upgradeFired = false;
|
|
113
|
+
_sessionId;
|
|
112
114
|
_upgradeConfig;
|
|
113
|
-
constructor(telemetryWriters) {
|
|
115
|
+
constructor(telemetryWriters, sessionId) {
|
|
114
116
|
this._telemetryWriters = telemetryWriters;
|
|
117
|
+
this._sessionId = sessionId;
|
|
115
118
|
}
|
|
116
119
|
static async create(cliSettings, httpClient, authenticationProvider) {
|
|
117
120
|
const environmentId = cliSettings.appConfig?.environmentId;
|
|
@@ -123,7 +126,7 @@ export class CliLogger {
|
|
|
123
126
|
if (userTelemetrySettings.console) {
|
|
124
127
|
telemetryWriters.push(new ConsoleWriter(sessionId, cliSettings.origin));
|
|
125
128
|
}
|
|
126
|
-
const instance = new CliLogger(telemetryWriters);
|
|
129
|
+
const instance = new CliLogger(telemetryWriters, sessionId);
|
|
127
130
|
if (userTelemetrySettings.remote && region && environmentId) {
|
|
128
131
|
// Push the unauthenticated writer immediately. Defaults to the global 1DS endpoint
|
|
129
132
|
// and omits `geoLocation`; if/when auth succeeds, the upgrade swaps in the EU-aware
|
|
@@ -195,6 +198,10 @@ export class CliLogger {
|
|
|
195
198
|
this._telemetryWriters.push(authed);
|
|
196
199
|
}
|
|
197
200
|
this._unauthWriter = authed;
|
|
201
|
+
// Re-apply previously set dimensions to the replacement writer.
|
|
202
|
+
for (const [key, value] of Object.entries(this._customDimensions)) {
|
|
203
|
+
authed.setCustomDimension(key, value);
|
|
204
|
+
}
|
|
198
205
|
// Set the tenantId dimension AFTER the swap so it lands on the authed writer
|
|
199
206
|
// (and any ConsoleWriter that's still in the list), not the discarded unauth one.
|
|
200
207
|
const tenantId = authenticationProvider.getUserTenantId();
|
|
@@ -211,6 +218,8 @@ export class CliLogger {
|
|
|
211
218
|
if (!_key || !_value) {
|
|
212
219
|
return;
|
|
213
220
|
}
|
|
221
|
+
// not guarding on _upgradeFired to preserve dimensions set before the swap is complete
|
|
222
|
+
this._customDimensions[_key] = _value;
|
|
214
223
|
this._telemetryWriters.forEach((writer) => {
|
|
215
224
|
writer.setCustomDimension(_key, _value);
|
|
216
225
|
});
|
|
@@ -272,7 +281,7 @@ export class CliLogger {
|
|
|
272
281
|
// No-op — CLI identifies users via setCustomDimension
|
|
273
282
|
}
|
|
274
283
|
get sessionId() {
|
|
275
|
-
return
|
|
284
|
+
return this._sessionId;
|
|
276
285
|
}
|
|
277
286
|
set sessionId(_value) {
|
|
278
287
|
// No-op
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliLogger.js","sourceRoot":"","sources":["../../src/Logger/CliLogger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAe,MAAM,yCAAyC,CAAC;AAEzF,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,WAAW,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAQnE,OAAO,EAAE,aAAa,EAAE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C;IAEM,YAAY,CAAC,OAAkD;QACpE,oEAAoE;QACpE,wEAAwE;QACxE,+CAA+C;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -7,6 +7,7 @@ export declare class ConsoleWriter implements ITelemetryWriter {
|
|
|
7
7
|
private readonly _scenario;
|
|
8
8
|
private readonly _error;
|
|
9
9
|
private readonly _warn;
|
|
10
|
+
private readonly _customDimensions;
|
|
10
11
|
constructor(sessionId: string, origin: string);
|
|
11
12
|
trackActivityEvent(eventName: string, eventData?: object): void;
|
|
12
13
|
trackErrorEvent(eventName: string, eventData?: object): void;
|
|
@@ -16,5 +17,6 @@ export declare class ConsoleWriter implements ITelemetryWriter {
|
|
|
16
17
|
scenarioCompletedWithError(scenarioName: string, completeWithErrorData?: object): void;
|
|
17
18
|
flush(): Promise<void>;
|
|
18
19
|
setCustomDimension(_key: string, _value: string): void;
|
|
20
|
+
private _withCustomDimensions;
|
|
19
21
|
}
|
|
20
22
|
//# sourceMappingURL=ConsoleWriter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleWriter.d.ts","sourceRoot":"","sources":["../../src/Logger/ConsoleWriter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAwBnE,qBAAa,aAAc,YAAW,gBAAgB;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;
|
|
1
|
+
{"version":3,"file":"ConsoleWriter.d.ts","sourceRoot":"","sources":["../../src/Logger/ConsoleWriter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAwBnE,qBAAa,aAAc,YAAW,gBAAgB;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA8B;gBAE7C,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAO7C,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAI/D,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5D,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAI7D,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAInE,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAIhE,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI;IAOtF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAO7D,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -18,6 +18,7 @@ export class ConsoleWriter {
|
|
|
18
18
|
_scenario;
|
|
19
19
|
_error;
|
|
20
20
|
_warn;
|
|
21
|
+
_customDimensions = {};
|
|
21
22
|
constructor(sessionId, origin) {
|
|
22
23
|
this._activity = makeLoggerFn(sessionId, origin, ['white', 'bold']);
|
|
23
24
|
this._scenario = makeLoggerFn(sessionId, origin, ['cyan', 'bold']);
|
|
@@ -25,28 +26,37 @@ export class ConsoleWriter {
|
|
|
25
26
|
this._warn = makeLoggerFn(sessionId, origin, ['yellow', 'bold']);
|
|
26
27
|
}
|
|
27
28
|
trackActivityEvent(eventName, eventData) {
|
|
28
|
-
this._activity(eventName, eventData
|
|
29
|
+
this._activity(eventName, this._withCustomDimensions(eventData));
|
|
29
30
|
}
|
|
30
31
|
trackErrorEvent(eventName, eventData) {
|
|
31
|
-
this._error(eventName, eventData
|
|
32
|
+
this._error(eventName, this._withCustomDimensions(eventData));
|
|
32
33
|
}
|
|
33
34
|
startScenario(scenarioName, startData) {
|
|
34
|
-
this._scenario(`[scenario:start] ${scenarioName}`, startData
|
|
35
|
+
this._scenario(`[scenario:start] ${scenarioName}`, this._withCustomDimensions(startData));
|
|
35
36
|
}
|
|
36
37
|
completeScenario(scenarioName, completeData) {
|
|
37
|
-
this._scenario(`[scenario:complete] ${scenarioName}`, completeData
|
|
38
|
+
this._scenario(`[scenario:complete] ${scenarioName}`, this._withCustomDimensions(completeData));
|
|
38
39
|
}
|
|
39
40
|
scenarioFailed(scenarioName, failureData) {
|
|
40
|
-
this._error(`[scenario:failure] ${scenarioName}`, failureData
|
|
41
|
+
this._error(`[scenario:failure] ${scenarioName}`, this._withCustomDimensions(failureData));
|
|
41
42
|
}
|
|
42
43
|
scenarioCompletedWithError(scenarioName, completeWithErrorData) {
|
|
43
|
-
this._warn(`[scenario:completeWithError] ${scenarioName}`, completeWithErrorData
|
|
44
|
+
this._warn(`[scenario:completeWithError] ${scenarioName}`, this._withCustomDimensions(completeWithErrorData));
|
|
44
45
|
}
|
|
45
46
|
flush() {
|
|
46
47
|
return Promise.resolve();
|
|
47
48
|
}
|
|
48
49
|
setCustomDimension(_key, _value) {
|
|
49
|
-
|
|
50
|
+
if (!_key || !_value) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this._customDimensions[_key] = _value;
|
|
54
|
+
}
|
|
55
|
+
_withCustomDimensions(eventData) {
|
|
56
|
+
return {
|
|
57
|
+
...this._customDimensions,
|
|
58
|
+
...(eventData ?? {}),
|
|
59
|
+
};
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|