@microsoft/managed-apps-cli 0.7.0 → 0.9.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.
Files changed (152) hide show
  1. package/README.md +42 -6
  2. package/dist/ArgumentProvider.d.ts +11 -0
  3. package/dist/ArgumentProvider.d.ts.map +1 -1
  4. package/dist/ArgumentProvider.js +61 -19
  5. package/dist/ArgumentProvider.js.map +1 -1
  6. package/dist/Authentication/NodeMsalAuthenticationProvider.d.ts +16 -0
  7. package/dist/Authentication/NodeMsalAuthenticationProvider.d.ts.map +1 -1
  8. package/dist/Authentication/NodeMsalAuthenticationProvider.js +58 -6
  9. package/dist/Authentication/NodeMsalAuthenticationProvider.js.map +1 -1
  10. package/dist/Cli.d.ts.map +1 -1
  11. package/dist/Cli.js +23 -7
  12. package/dist/Cli.js.map +1 -1
  13. package/dist/CliSettings.d.ts +2 -2
  14. package/dist/CliSettings.d.ts.map +1 -1
  15. package/dist/CliSettings.js +3 -4
  16. package/dist/CliSettings.js.map +1 -1
  17. package/dist/CliUtils.d.ts +25 -8
  18. package/dist/CliUtils.d.ts.map +1 -1
  19. package/dist/CliUtils.js +19 -23
  20. package/dist/CliUtils.js.map +1 -1
  21. package/dist/Constants/CommandRegistry.d.ts.map +1 -1
  22. package/dist/Constants/CommandRegistry.js +28 -1
  23. package/dist/Constants/CommandRegistry.js.map +1 -1
  24. package/dist/Constants/HelpStrings.d.ts +55 -5
  25. package/dist/Constants/HelpStrings.d.ts.map +1 -1
  26. package/dist/Constants/HelpStrings.js +113 -42
  27. package/dist/Constants/HelpStrings.js.map +1 -1
  28. package/dist/Constants.d.ts +1 -1
  29. package/dist/Constants.d.ts.map +1 -1
  30. package/dist/Constants.js +5 -2
  31. package/dist/Constants.js.map +1 -1
  32. package/dist/Errors/GitHubErrorMap.d.ts.map +1 -1
  33. package/dist/Errors/GitHubErrorMap.js +18 -11
  34. package/dist/Errors/GitHubErrorMap.js.map +1 -1
  35. package/dist/FS/CliFs.d.ts.map +1 -1
  36. package/dist/FS/CliFs.js.map +1 -1
  37. package/dist/HttpClient/CliHttpClient.d.ts +30 -0
  38. package/dist/HttpClient/CliHttpClient.d.ts.map +1 -1
  39. package/dist/HttpClient/CliHttpClient.js +136 -1
  40. package/dist/HttpClient/CliHttpClient.js.map +1 -1
  41. package/dist/Logger/CliLogger.d.ts +50 -8
  42. package/dist/Logger/CliLogger.d.ts.map +1 -1
  43. package/dist/Logger/CliLogger.js +92 -37
  44. package/dist/Logger/CliLogger.js.map +1 -1
  45. package/dist/Logger/ConsoleWriter.d.ts +5 -0
  46. package/dist/Logger/ConsoleWriter.d.ts.map +1 -1
  47. package/dist/Logger/ConsoleWriter.js +22 -14
  48. package/dist/Logger/ConsoleWriter.js.map +1 -1
  49. package/dist/Middletier/FunctionsBundler.js +5 -1
  50. package/dist/Middletier/FunctionsBundler.js.map +1 -1
  51. package/dist/Middletier/PackFunctions.d.ts +5 -4
  52. package/dist/Middletier/PackFunctions.d.ts.map +1 -1
  53. package/dist/Middletier/PackFunctions.js +8 -7
  54. package/dist/Middletier/PackFunctions.js.map +1 -1
  55. package/dist/Types/Cli.types.d.ts +1 -1
  56. package/dist/Types/Cli.types.d.ts.map +1 -1
  57. package/dist/Types/Command.types.d.ts +14 -3
  58. package/dist/Types/Command.types.d.ts.map +1 -1
  59. package/dist/Types/Command.types.js +4 -0
  60. package/dist/Types/Command.types.js.map +1 -1
  61. package/dist/Utils/BuildPolling.d.ts +18 -0
  62. package/dist/Utils/BuildPolling.d.ts.map +1 -0
  63. package/dist/Utils/BuildPolling.js +63 -0
  64. package/dist/Utils/BuildPolling.js.map +1 -0
  65. package/dist/Utils/BuildVerbDescriptionTable.d.ts +11 -1
  66. package/dist/Utils/BuildVerbDescriptionTable.d.ts.map +1 -1
  67. package/dist/Utils/BuildVerbDescriptionTable.js +73 -17
  68. package/dist/Utils/BuildVerbDescriptionTable.js.map +1 -1
  69. package/dist/Utils/DcfRecovery.d.ts +84 -0
  70. package/dist/Utils/DcfRecovery.d.ts.map +1 -0
  71. package/dist/Utils/DcfRecovery.js +266 -0
  72. package/dist/Utils/DcfRecovery.js.map +1 -0
  73. package/dist/Utils/EnhanceNetworkError.d.ts.map +1 -1
  74. package/dist/Utils/EnhanceNetworkError.js +2 -0
  75. package/dist/Utils/EnhanceNetworkError.js.map +1 -1
  76. package/dist/Utils/EnvVars.d.ts +1 -1
  77. package/dist/Utils/EnvVars.d.ts.map +1 -1
  78. package/dist/Utils/EnvVars.js.map +1 -1
  79. package/dist/Utils/RepoUrl.d.ts +11 -6
  80. package/dist/Utils/RepoUrl.d.ts.map +1 -1
  81. package/dist/Utils/RepoUrl.js +1 -1
  82. package/dist/Utils/RepoUrl.js.map +1 -1
  83. package/dist/Utils/ResolveCommand.d.ts +37 -1
  84. package/dist/Utils/ResolveCommand.d.ts.map +1 -1
  85. package/dist/Utils/ResolveCommand.js +97 -20
  86. package/dist/Utils/ResolveCommand.js.map +1 -1
  87. package/dist/Verbs/AddConnector.d.ts.map +1 -1
  88. package/dist/Verbs/AddConnector.js.map +1 -1
  89. package/dist/Verbs/AddConnectorFlows.d.ts.map +1 -1
  90. package/dist/Verbs/AddConnectorFlows.js +2 -2
  91. package/dist/Verbs/AddConnectorFlows.js.map +1 -1
  92. package/dist/Verbs/BuildMaafApp.d.ts.map +1 -1
  93. package/dist/Verbs/BuildMaafApp.js +98 -22
  94. package/dist/Verbs/BuildMaafApp.js.map +1 -1
  95. package/dist/Verbs/ConnectorHelpers.d.ts.map +1 -1
  96. package/dist/Verbs/ConnectorHelpers.js.map +1 -1
  97. package/dist/Verbs/CreateMaafApp.d.ts +54 -5
  98. package/dist/Verbs/CreateMaafApp.d.ts.map +1 -1
  99. package/dist/Verbs/CreateMaafApp.js +238 -238
  100. package/dist/Verbs/CreateMaafApp.js.map +1 -1
  101. package/dist/Verbs/DeployMaafApp.d.ts.map +1 -1
  102. package/dist/Verbs/DeployMaafApp.js +48 -20
  103. package/dist/Verbs/DeployMaafApp.js.map +1 -1
  104. package/dist/Verbs/GetMaafBuildStatus.d.ts.map +1 -1
  105. package/dist/Verbs/GetMaafBuildStatus.js +66 -17
  106. package/dist/Verbs/GetMaafBuildStatus.js.map +1 -1
  107. package/dist/Verbs/GetSettings.d.ts.map +1 -1
  108. package/dist/Verbs/GetSettings.js +9 -18
  109. package/dist/Verbs/GetSettings.js.map +1 -1
  110. package/dist/Verbs/Init.d.ts.map +1 -1
  111. package/dist/Verbs/Init.js +63 -46
  112. package/dist/Verbs/Init.js.map +1 -1
  113. package/dist/Verbs/ListFlows.d.ts.map +1 -1
  114. package/dist/Verbs/ListFlows.js +1 -2
  115. package/dist/Verbs/ListFlows.js.map +1 -1
  116. package/dist/Verbs/MaafAppPermissions.d.ts +12 -6
  117. package/dist/Verbs/MaafAppPermissions.d.ts.map +1 -1
  118. package/dist/Verbs/MaafAppPermissions.js +208 -66
  119. package/dist/Verbs/MaafAppPermissions.js.map +1 -1
  120. package/dist/Verbs/PlayMaafApp.d.ts +22 -0
  121. package/dist/Verbs/PlayMaafApp.d.ts.map +1 -0
  122. package/dist/Verbs/PlayMaafApp.js +147 -0
  123. package/dist/Verbs/PlayMaafApp.js.map +1 -0
  124. package/dist/Verbs/RefreshDataSource.d.ts.map +1 -1
  125. package/dist/Verbs/RefreshDataSource.js.map +1 -1
  126. package/dist/Verbs/RefreshGitAuth.d.ts.map +1 -1
  127. package/dist/Verbs/RefreshGitAuth.js +31 -16
  128. package/dist/Verbs/RefreshGitAuth.js.map +1 -1
  129. package/dist/Verbs/SetSetting.d.ts.map +1 -1
  130. package/dist/Verbs/SetSetting.js +39 -49
  131. package/dist/Verbs/SetSetting.js.map +1 -1
  132. package/dist/Verbs/ShareLinkCreate.d.ts +23 -0
  133. package/dist/Verbs/ShareLinkCreate.d.ts.map +1 -0
  134. package/dist/Verbs/ShareLinkCreate.js +73 -0
  135. package/dist/Verbs/ShareLinkCreate.js.map +1 -0
  136. package/dist/Verbs/ShareLinkList.d.ts +16 -0
  137. package/dist/Verbs/ShareLinkList.d.ts.map +1 -0
  138. package/dist/Verbs/ShareLinkList.js +84 -0
  139. package/dist/Verbs/ShareLinkList.js.map +1 -0
  140. package/dist/Verbs/ShareLinkRevoke.d.ts +22 -0
  141. package/dist/Verbs/ShareLinkRevoke.d.ts.map +1 -0
  142. package/dist/Verbs/ShareLinkRevoke.js +137 -0
  143. package/dist/Verbs/ShareLinkRevoke.js.map +1 -0
  144. package/dist/Verbs/VerbConstants.d.ts +113 -16
  145. package/dist/Verbs/VerbConstants.d.ts.map +1 -1
  146. package/dist/Verbs/VerbConstants.js +102 -24
  147. package/dist/Verbs/VerbConstants.js.map +1 -1
  148. package/dist/Verbs/index.d.ts +4 -0
  149. package/dist/Verbs/index.d.ts.map +1 -1
  150. package/dist/Verbs/index.js +4 -0
  151. package/dist/Verbs/index.js.map +1 -1
  152. package/package.json +5 -5
@@ -0,0 +1,266 @@
1
+ /*!
2
+ * Copyright (C) Microsoft Corporation. All rights reserved.
3
+ */
4
+ /**
5
+ * Shared inline Device Code Flow (DCF) recovery for the github catch-and-retry
6
+ * branch of `ms app create`, `ms app init`, `ms app build`, and `ms app deploy`.
7
+ * On a missing/expired/stale
8
+ * Entra↔GitHub identity mapping, the verb's outer catch calls this helper to
9
+ * prompt the user through the same device-code flow `ms git auth refresh` runs
10
+ * and then retries the failed action exactly once. SIGINT plumbing, telemetry,
11
+ * display selection, and error mapping all live here so the caller can stay
12
+ * focused on its own happy-path flow.
13
+ */
14
+ import { authenticateForRepoAsync, GrsServerError, } from '@microsoft/managed-apps-actions';
15
+ import { getCliLogger } from '../CliSettings.js';
16
+ import { AuthenticationError } from '../Errors/CliError.js';
17
+ import { mapGitHubServerErrorToCliError, matchGitHubAuthError } from '../Errors/GitHubErrorMap.js';
18
+ import { printInfo } from './ConsoleOutput.js';
19
+ import { ConsoleGitHubDcfDisplay, JsonGitHubDcfDisplay } from './GitHubDcfFlow.js';
20
+ import { computeRepoHash, parseRemoteUrl } from './RepoUrl.js';
21
+ /**
22
+ * Inline DCF recovery branch for the github catch-and-retry. SIGINT handling
23
+ * is scoped to this helper so Ctrl+C during the device-code polling loop
24
+ * doesn't leak a listener back to the verb's outer body. Server errors thrown
25
+ * by `authenticateForRepoAsync` are mapped through
26
+ * {@link mapGitHubServerErrorToCliError} before being rethrown so the verb's
27
+ * outer catch (and the single-retry contract) sees CLI-typed errors.
28
+ *
29
+ * Telemetry event prefix is derived from the verb (e.g. `'app create'` →
30
+ * `'Maaf.Create.GitHubDcfRecovery'`) — keeps the call site a one-liner that
31
+ * can't drift out of sync with the verb field.
32
+ */
33
+ export async function runDcfRecoveryAsync(options) {
34
+ const { remoteUrl, tenantId, jsonMode, openBrowser, verb } = options;
35
+ // Best-effort generic URL split: used only for PII-safe telemetry shaping
36
+ // (host + repoHash) and to normalize the URL we forward to the actions
37
+ // layer. The CLI no longer performs scheme/host/shape validation — the
38
+ // server is the sole authoritative validator. On parse failure we still
39
+ // emit telemetry (with empty host/repoHash, preserving the property keys
40
+ // for downstream Kusto consumers) and forward the user-supplied URL
41
+ // untouched to the actions layer.
42
+ const { host, owner, repo } = parseRemoteUrl(remoteUrl);
43
+ const repoHash = owner && repo ? computeRepoHash(owner, repo) : '';
44
+ const normalizedRemoteUrl = host && owner && repo ? `https://${host}/${owner}/${repo}` : remoteUrl;
45
+ const logger = getCliLogger();
46
+ const eventPrefix = telemetryEventPrefixForVerb(verb);
47
+ // Telemetry: PII-safe — host is the parsed string, repoHash is a truncated
48
+ // SHA256. Emit Start at the top so a recovery that never reaches the retry
49
+ // (e.g. user denied auth) is still observable.
50
+ logger.trackActivityEvent(eventPrefix, {
51
+ repoHost: host,
52
+ repoHash,
53
+ });
54
+ if (!jsonMode) {
55
+ printInfo('GitHub authentication is required to bind this repository.');
56
+ }
57
+ const display = composeRecoveryDisplay({ isJson: jsonMode, openBrowser });
58
+ // SIGINT plumbing: a Ctrl+C during the (potentially 15-minute) polling
59
+ // loop drops us out cleanly rather than leaving a dangling promise.
60
+ const controller = new AbortController();
61
+ const onSigint = () => {
62
+ controller.abort();
63
+ };
64
+ process.once('SIGINT', onSigint);
65
+ try {
66
+ await authenticateForRepoAsync({
67
+ remoteUrl: normalizedRemoteUrl,
68
+ tenantId,
69
+ logger,
70
+ display,
71
+ // Browser launch is gated by the `display` object above: `composeRecoveryDisplay`
72
+ // returns a display whose `openVerificationUri` is undefined by default (no
73
+ // --open-browser flag). `skipBrowser` is the legacy lower-level kill-switch;
74
+ // hardcode to false so the display contract is the single source of truth.
75
+ skipBrowser: false,
76
+ signal: controller.signal,
77
+ });
78
+ }
79
+ catch (error) {
80
+ // Pair the Start event with a Failed event on every error path so a
81
+ // recovery that throws (DCF declined, server error, abort) still shows
82
+ // up as a closed pair in the activity stream rather than an orphaned Start.
83
+ logger.trackActivityEvent(`${eventPrefix}.Failed`, {
84
+ repoHost: host,
85
+ repoHash,
86
+ });
87
+ if (error instanceof GrsServerError) {
88
+ const mapped = mapGitHubServerErrorToCliError({
89
+ code: error.code,
90
+ message: error.message,
91
+ status: error.status,
92
+ details: error.details,
93
+ }, { repoUrl: remoteUrl, verb });
94
+ if (mapped)
95
+ throw mapped;
96
+ }
97
+ throw error;
98
+ }
99
+ finally {
100
+ process.removeListener('SIGINT', onSigint);
101
+ }
102
+ logger.trackActivityEvent(`${eventPrefix}.Complete`, {
103
+ repoHost: host,
104
+ repoHash,
105
+ });
106
+ if (!jsonMode) {
107
+ // Printed here (before the helper returns) rather than at the retry
108
+ // call site so it's adjacent to the DCF-completed telemetry event. If
109
+ // the subsequent verb retry hard-fails, the user sees this followed by the failure message.
110
+ // Still accurate: we DID resume; the resumed call is what failed.
111
+ printInfo(resumeMessageForVerb(verb));
112
+ }
113
+ }
114
+ /** Verb-specific "resuming X..." message shown after a successful DCF recovery. */
115
+ function resumeMessageForVerb(verb) {
116
+ switch (verb) {
117
+ case 'app create':
118
+ return 'Resuming create...';
119
+ case 'app init':
120
+ return 'Resuming init...';
121
+ case 'app build':
122
+ return 'Resuming build...';
123
+ case 'app deploy':
124
+ return 'Resuming deploy...';
125
+ }
126
+ }
127
+ /**
128
+ * Build the right {@link GitHubDcfDisplay} for the recovery path:
129
+ * - JSON mode → NDJSON events, never opens a browser.
130
+ * - Default (no `--open-browser`) → console output, browser launch suppressed.
131
+ * - `--open-browser` → console output + best-effort browser launch (TTY-gated).
132
+ */
133
+ function composeRecoveryDisplay(opts) {
134
+ if (opts.isJson) {
135
+ return new JsonGitHubDcfDisplay();
136
+ }
137
+ if (opts.openBrowser) {
138
+ return ConsoleGitHubDcfDisplay;
139
+ }
140
+ return {
141
+ ...ConsoleGitHubDcfDisplay,
142
+ openVerificationUri: undefined,
143
+ };
144
+ }
145
+ /**
146
+ * Map a verb name to its telemetry event prefix. Keeps the create and build
147
+ * events under their respective `Maaf.Create.*` / `Maaf.Build.*` namespaces
148
+ * so dashboards that filter by namespace continue to work.
149
+ */
150
+ function telemetryEventPrefixForVerb(verb) {
151
+ switch (verb) {
152
+ case 'app create':
153
+ return 'Maaf.Create.GitHubDcfRecovery';
154
+ case 'app init':
155
+ return 'Maaf.Init.GitHubDcfRecovery';
156
+ case 'app build':
157
+ return 'Maaf.Build.GitHubDcfRecovery';
158
+ case 'app deploy':
159
+ return 'Maaf.Deploy.GitHubDcfRecovery';
160
+ }
161
+ }
162
+ /**
163
+ * Higher-order wrapper that bolts the GitHub catch-and-retry DCF recovery
164
+ * branch onto a single async attempt. Encapsulates the
165
+ *
166
+ * try { attempt } catch { match → DCF → retry attempt → map-on-failure }
167
+ *
168
+ * pattern that `ms app create`, `ms app init`, `ms app build`, and `ms app deploy`
169
+ * all need, so the verbs stay focused on their own happy-path flow.
170
+ *
171
+ * Contract:
172
+ * - The attempt runs at most twice; DCF runs at most once. No looping.
173
+ * - The attempt callback receives `{ isRetry: false }` on the first call
174
+ * and `{ isRetry: true }` on the post-DCF retry so callers can
175
+ * conditionally alter their request (e.g. drop `forceReauth` on retry
176
+ * so the just-refreshed mapping isn't bypassed again).
177
+ * - `repoType !== 'github'` is a no-op around the attempt — the original
178
+ * error escapes untouched so native/none verbs behave identically to the
179
+ * un-wrapped call.
180
+ * - First-attempt errors that {@link matchGitHubAuthError} doesn't recognize
181
+ * are mapped via {@link mapGitHubServerErrorToCliError} (for
182
+ * {@link GrsServerError}) before being rethrown; everything else escapes
183
+ * as-is.
184
+ * - A matching first-attempt error with no `externalRepoUrl` throws a
185
+ * verb-agnostic {@link AuthenticationError} before DCF is invoked — DCF
186
+ * itself requires a URL to derive host/owner/repo.
187
+ * - Second-attempt (post-DCF) errors follow the same map-and-rethrow
188
+ * contract; a still-matching error after DCF surfaces through the
189
+ * friendly mapper rather than looping the device flow.
190
+ *
191
+ * `runDcfRecovery` is an optional dependency seam — defaults to the real
192
+ * {@link runDcfRecoveryAsync}; tests inject a stub so they don't have to
193
+ * spin up the device-code polling loop.
194
+ */
195
+ export async function withGitHubDcfRecoveryAsync(attempt, options, runDcfRecovery = runDcfRecoveryAsync) {
196
+ const { repoType, externalRepoUrl, tenantId, jsonMode, openBrowser, verb } = options;
197
+ // Local helper: if `e` is a recognized GrsServerError, return the friendly
198
+ // CLI-typed error; otherwise null. Closes over `externalRepoUrl`/`verb` so
199
+ // the two non-matching call sites below stay one line each and can't drift.
200
+ const mapGrsError = (e) => {
201
+ if (!(e instanceof GrsServerError))
202
+ return null;
203
+ return mapGitHubServerErrorToCliError({ code: e.code, message: e.message, status: e.status, details: e.details }, { repoUrl: externalRepoUrl, verb });
204
+ };
205
+ try {
206
+ // Happy path: attempt succeeds on the first try, no DCF, no retry.
207
+ return await attempt({ isRetry: false });
208
+ }
209
+ catch (err) {
210
+ if (repoType !== 'github')
211
+ throw err;
212
+ const matched = matchGitHubAuthError(err);
213
+ if (!matched) {
214
+ // Non-matching first-attempt error: map known server errors to friendly
215
+ // CLI errors, otherwise rethrow untouched.
216
+ const mapped = mapGrsError(err);
217
+ if (mapped)
218
+ throw mapped;
219
+ throw err;
220
+ }
221
+ // Legacy guard: apps created before `externalRepoUrl` was persisted to
222
+ // ms.config.json hit this branch with no URL to authenticate against.
223
+ // Fail fast with an actionable message rather than crashing inside DCF
224
+ // recovery (which would also bypass the Start telemetry).
225
+ if (!externalRepoUrl) {
226
+ throw new AuthenticationError('GitHub authentication is required, but the app config does not record the external ' +
227
+ 'repository URL needed to recover the identity mapping. This app may have been created ' +
228
+ 'before the URL was persisted to `ms.config.json`. Either add ' +
229
+ '`externalRepoUrl: "<your repo url>"` to `ms.config.json`, or recreate the app with ' +
230
+ `\`ms app create --repo <your repo url>\`, then run \`ms ${verb}\` again.`);
231
+ }
232
+ await runDcfRecovery({
233
+ remoteUrl: externalRepoUrl,
234
+ tenantId,
235
+ jsonMode,
236
+ openBrowser,
237
+ verb,
238
+ });
239
+ try {
240
+ return await attempt({ isRetry: true });
241
+ }
242
+ catch (retryErr) {
243
+ const remapped = matchGitHubAuthError(retryErr);
244
+ if (remapped) {
245
+ // Single-retry contract: a still-matching error after DCF surfaces
246
+ // through the friendly verb-agnostic mapper so the user sees the
247
+ // same wording as on a first-attempt mapping failure. We deliberately
248
+ // do NOT loop DCF — repeated failures suggest the user can't complete
249
+ // the device-code flow and another loop would just hang. Fall through
250
+ // to `retryErr` if the mapper somehow returns null (defensive — the
251
+ // mapper recognizes every code matchGitHubAuthError matches on).
252
+ const mapped = mapGitHubServerErrorToCliError(remapped.payload, {
253
+ repoUrl: externalRepoUrl,
254
+ verb,
255
+ });
256
+ throw mapped ?? retryErr;
257
+ }
258
+ // Non-matching retry error: same map-or-rethrow shape as the first attempt.
259
+ const mapped = mapGrsError(retryErr);
260
+ if (mapped)
261
+ throw mapped;
262
+ throw retryErr;
263
+ }
264
+ }
265
+ }
266
+ //# sourceMappingURL=DcfRecovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DcfRecovery.js","sourceRoot":"","sources":["../../src/Utils/DcfRecovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EACL,wBAAwB,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F"}
1
+ {"version":3,"file":"EnhanceNetworkError.d.ts","sourceRoot":"","sources":["../../src/Utils/EnhanceNetworkError.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CAgDtF"}
@@ -21,6 +21,7 @@ export function enhanceNetworkError(error, method, url) {
21
21
  const cause = error.cause;
22
22
  if (cause) {
23
23
  const errorCode = cause.code || cause.errno;
24
+ cause.code = errorCode; // Ensure code is on the cause for easier access
24
25
  if (errorCode === 'ENOTFOUND') {
25
26
  detailedMessage += ` DNS lookup failed - unable to resolve hostname.`;
26
27
  }
@@ -52,6 +53,7 @@ export function enhanceNetworkError(error, method, url) {
52
53
  `VPN/proxy configuration, firewall/certificate issues, or server not reachable.`;
53
54
  }
54
55
  const enhancedError = new Error(detailedMessage);
56
+ enhancedError.name = cause?.code;
55
57
  enhancedError.cause = error;
56
58
  return enhancedError;
57
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EnhanceNetworkError.js","sourceRoot":"","sources":["../../src/Utils/EnhanceNetworkError.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,uDAAuD;AACvD;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc,EAAE,MAAc,EAAE,GAAW;IAC7E,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7E,6CAA6C;QAC7C,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,eAAe,GAAG,8BAA8B,MAAM,IAAI,GAAG,GAAG,CAAC;IAErE,kEAAkE;IAClE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C;YACD,eAAe,IAAI,mCAAmC,SAAS,IAAI,CAAC;QACtE,CAAC;aAAM,IAAI,SAAS,EAAE,CAAC;YACrB,eAAe,IAAI,kBAAkB,SAAS,GAAG,CAAC;QACpD,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;YACrD,eAAe,IAAI,aAAa,KAAK,CAAC,OAAO,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED,iEAAiE;IACjE,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAC1B,eAAe;YACb,yEAAyE;gBACzE,gFAAgF,CAAC;IACrF,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACjD,aAAa,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC;IAChC,aAAqB,CAAC,KAAK,GAAG,KAAK,CAAC;IACrC,OAAO,aAAa,CAAC;AACvB,CAAC;AACD,sDAAsD"}
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Copyright (C) Microsoft Corporation. All rights reserved.
3
3
  */
4
- export type CliEnvVarName = 'USE_SP_AUTH' | 'SP_CLIENT_ID' | 'SP_CLIENT_SECRET' | 'SP_TENANT_ID' | 'USE_HTTP_FORWARD' | 'HTTP_FORWARD_URL' | 'HTTP_FORWARD_AUTH_TOKEN' | 'HTTP_FORWARD_TENANT_ID' | 'ENABLE_CONNECTOR_USER_CONSENT' | 'REMOTE_TELEMETRY' | 'CONSOLE_TELEMETRY' | 'CONFIG_DIR' | 'WORKING_DIRECTORY' | 'MAAF_DEBUG_ENVIRONMENT_ID' | 'MAAF_GRS_ENDPOINT_OVERRIDE' | 'ENVIRONMENT_ID' | 'APP_DISPLAY_NAME' | 'APP_DESCRIPTION' | 'APP_ID' | 'APP_TEMPLATE' | 'APP_REPOSITORY_ID' | 'APP_REPO' | 'LOCAL_APP_URL' | 'BUILD_PATH' | 'BUILD_COMMAND' | 'BUILD_ENTRY_POINT' | 'LOGO_PATH' | 'CONFIG_ONLY' | 'PORT' | 'CLOUD_INSTANCE' | 'API_ID' | 'CONNECTION_ID' | 'CONNECTION_REF' | 'CONNECTOR_ID' | 'CONNECTOR_SEARCH' | 'CONNECTOR_ACTION_SEARCH' | 'DATASET' | 'TABLE' | 'TABLE_NAME' | 'DATA_SOURCE_NAME' | 'SEARCH_TERM' | 'DATAVERSE_API_SEARCH_TERM' | 'SQL_STORED_PROCEDURE' | 'ENV_URL' | 'SOLUTION_ID' | 'ADD_CONNECTOR_AS' | 'FLOW_ID' | 'FLOW_SEARCH' | 'FLOW_DATA_SOURCE_NAME' | 'REMOVE_FLOW_ID' | 'MAAF_APP_NAME' | 'MAAF_APP_ACCESS' | 'MAAF_COMMIT_SHA' | 'MAAF_OPERATION_ID' | 'MAAF_ENVIRONMENT_ID' | 'MAAF_DEPLOY_ARTIFACT' | 'MAAF_GITHUB_REPO' | 'LIST_ENVIRONMENT_ID' | 'LIST_PERMISSION' | 'SKIP_CODEGEN' | 'USE_V1_CODEGEN' | 'APP_SHOW_HEADER';
4
+ export type CliEnvVarName = 'USE_SP_AUTH' | 'SP_CLIENT_ID' | 'SP_CLIENT_SECRET' | 'SP_TENANT_ID' | 'USE_HTTP_FORWARD' | 'HTTP_FORWARD_URL' | 'HTTP_FORWARD_AUTH_TOKEN' | 'HTTP_FORWARD_TENANT_ID' | 'ENABLE_CONNECTOR_USER_CONSENT' | 'REMOTE_TELEMETRY' | 'CONSOLE_TELEMETRY' | 'ORIGIN' | 'USE_MMA_APP_ID' | 'CONFIG_DIR' | 'WORKING_DIRECTORY' | 'MAAF_DEBUG_ENVIRONMENT_ID' | 'MAAF_GRS_ENDPOINT_OVERRIDE' | 'ENVIRONMENT_ID' | 'APP_DISPLAY_NAME' | 'APP_DESCRIPTION' | 'APP_ID' | 'APP_TEMPLATE' | 'APP_REPOSITORY_ID' | 'APP_REPO' | 'LOCAL_APP_URL' | 'BUILD_PATH' | 'BUILD_COMMAND' | 'BUILD_ENTRY_POINT' | 'LOGO_PATH' | 'CONFIG_ONLY' | 'PORT' | 'CLOUD_INSTANCE' | 'API_ID' | 'CONNECTION_ID' | 'CONNECTION_REF' | 'CONNECTOR_ID' | 'CONNECTOR_SEARCH' | 'CONNECTOR_ACTION_SEARCH' | 'DATASET' | 'TABLE' | 'TABLE_NAME' | 'DATA_SOURCE_NAME' | 'SEARCH_TERM' | 'DATAVERSE_API_SEARCH_TERM' | 'SQL_STORED_PROCEDURE' | 'ENV_URL' | 'SOLUTION_ID' | 'ADD_CONNECTOR_AS' | 'FLOW_ID' | 'FLOW_SEARCH' | 'FLOW_DATA_SOURCE_NAME' | 'REMOVE_FLOW_ID' | 'MAAF_APP_NAME' | 'MAAF_APP_ACCESS' | 'MAAF_COMMIT_SHA' | 'MAAF_PLAY_MODE' | 'MAAF_ENVIRONMENT_ID' | 'MAAF_SHARE_LINK_ID' | 'MAAF_DEPLOY_ARTIFACT' | 'MAAF_GITHUB_REPO' | 'LIST_ENVIRONMENT_ID' | 'LIST_PERMISSION' | 'SKIP_CODEGEN' | 'USE_V1_CODEGEN' | 'APP_SHOW_HEADER';
5
5
  export declare function cliEnvVarFullName(name: CliEnvVarName): string;
6
6
  export declare function getCliEnvVar(name: CliEnvVarName): string | undefined;
7
7
  export declare function getCliEnvVarBool(name: CliEnvVarName): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"EnvVars.d.ts","sourceRoot":"","sources":["../../src/Utils/EnvVars.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,MAAM,aAAa,GAErB,aAAa,GACb,cAAc,GACd,kBAAkB,GAClB,cAAc,GAEd,kBAAkB,GAClB,kBAAkB,GAClB,yBAAyB,GACzB,wBAAwB,GAExB,+BAA+B,GAE/B,kBAAkB,GAClB,mBAAmB,GAEnB,YAAY,GACZ,mBAAmB,GACnB,2BAA2B,GAC3B,4BAA4B,GAE5B,gBAAg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AgB,CAAC,IAAmB;IAClD,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC;AACvC,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAmB,EAAE,KAAa;IAC7D,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,KAAa;IACzD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAA4B;IACrD,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;AAChC,CAAC"}
@@ -2,12 +2,17 @@
2
2
  * Copyright (C) Microsoft Corporation. All rights reserved.
3
3
  */
4
4
  /**
5
- * Re-export of the canonical GitHub repo URL parser. The implementation lives
6
- * in `@microsoft/managed-apps-common/utils` so the actions package and the CLI agree
7
- * on a single parser; this file preserves the historical CLI import path for
8
- * existing consumers.
5
+ * Re-export of the canonical generic remote URL splitter. The implementation
6
+ * lives in `@microsoft/managed-apps-common/utils` so the actions package and
7
+ * the CLI agree on a single splitter; this file preserves the historical CLI
8
+ * import path for existing consumers.
9
+ *
10
+ * The CLI no longer performs scheme/host/shape validation on repo URLs — the
11
+ * server is the sole authority on URL acceptability. `parseRemoteUrl` is a
12
+ * best-effort splitter used purely for OAuth dispatch host extraction and
13
+ * PII-safe telemetry shaping.
9
14
  */
10
- export type { ParsedGitHubRepoUrl } from '@microsoft/managed-apps-common/utils';
11
- export { parseGitHubRepoUrl } from '@microsoft/managed-apps-common/utils';
15
+ export type { ParsedRemoteUrl } from '@microsoft/managed-apps-common/utils';
16
+ export { parseRemoteUrl } from '@microsoft/managed-apps-common/utils';
12
17
  export { computeRepoHash } from '@microsoft/managed-apps-common/utils/RepoHash';
13
18
  //# sourceMappingURL=RepoUrl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RepoUrl.d.ts","sourceRoot":"","sources":["../../src/Utils/RepoUrl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AAEH,YAAY,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC"}
1
+ {"version":3,"file":"RepoUrl.d.ts","sourceRoot":"","sources":["../../src/Utils/RepoUrl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;GAUG;AAEH,YAAY,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Copyright (C) Microsoft Corporation. All rights reserved.
3
3
  */
4
- export { parseGitHubRepoUrl } from '@microsoft/managed-apps-common/utils';
4
+ export { parseRemoteUrl } from '@microsoft/managed-apps-common/utils';
5
5
  export { computeRepoHash } from '@microsoft/managed-apps-common/utils/RepoHash';
6
6
  //# sourceMappingURL=RepoUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RepoUrl.js","sourceRoot":"","sources":["../../src/Utils/RepoUrl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC"}
1
+ {"version":3,"file":"RepoUrl.js","sourceRoot":"","sources":["../../src/Utils/RepoUrl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC"}
@@ -6,13 +6,49 @@ import type { CommandTree, NounKey, ResolvedCommand } from '../Types/Command.typ
6
6
  * Resolves command-line tokens against the command tree.
7
7
  *
8
8
  * Every command lives under a noun, so the minimum match is 2 tokens (noun + verb).
9
- * Typed subcommands match 3 tokens (noun + verb + type).
9
+ * Typed verbs may nest arbitrarily, so a command path can be any depth (e.g.
10
+ * `app add table` is 3 tokens, `app share link create` is 4). The walker
11
+ * descends as deep as it can; when a typed verb has its own handler ("hybrid"
12
+ * verb, like `app share`) and the next token is **not** a known subcommand,
13
+ * it falls back to the parent handler so the remaining tokens become
14
+ * positional arguments — letting `ms app share alice@contoso.com` route to
15
+ * the `share` handler. When the next token IS a known sub-group of the
16
+ * typed verb but no leaf is reached, we return null instead of falling back,
17
+ * so callers can surface group help rather than misinterpret the sub-group
18
+ * name as a positional argument.
10
19
  *
11
20
  * @param argv - The full process.argv array (argv[0] = node, argv[1] = script)
12
21
  * @param tree - The command tree to resolve against
13
22
  * @returns The resolved command, or null if no match was found
14
23
  */
15
24
  export declare function resolveCommand(argv: readonly string[], tree: CommandTree): ResolvedCommand | null;
25
+ /**
26
+ * Describes a partially-resolved typed-verb path. Returned by
27
+ * `findIncompleteTypedPath` when argv tokens reach a typed verb group but
28
+ * stop short of (or overshoot) any leaf command.
29
+ */
30
+ export interface IncompleteTypedPath {
31
+ /** Tokens that matched the command tree along a typed-verb path, e.g. ['app','share','link']. */
32
+ pathTokens: readonly string[];
33
+ /** The next non-flag argv token after `pathTokens` if it failed to match a sub-key, else undefined. */
34
+ unknownToken: string | undefined;
35
+ }
36
+ /**
37
+ * Walks argv tokens along the command tree to detect an incomplete typed-verb
38
+ * path — i.e. a path that reached one or more typed verbs (groups) but did not
39
+ * land on a leaf command. Used by `ArgumentProvider` (when `resolveCommand`
40
+ * returns null) to either:
41
+ *
42
+ * - print the typed group's flattened help (when no extra non-flag token
43
+ * follows, e.g. `ms app share link` or `ms app add --connector shared_sql`), or
44
+ * - throw an "Unknown type 'X' for 'ms <path>'" error (when a bogus
45
+ * sub-token follows, e.g. `ms app share link bogus`).
46
+ *
47
+ * Returns null when the path is fully resolvable, when the noun is unknown,
48
+ * when only a noun is provided, or when the second token is not a typed verb
49
+ * (those cases are handled elsewhere in `ArgumentProvider`).
50
+ */
51
+ export declare function findIncompleteTypedPath(argv: readonly string[], tree: CommandTree): IncompleteTypedPath | null;
16
52
  /**
17
53
  * Checks whether the given token is a known noun in the command tree.
18
54
  * Used to distinguish `ms app` (show noun help) from `ms nonexistent` (error).
@@ -1 +1 @@
1
- {"version":3,"file":"ResolveCommand.d.ts","sourceRoot":"","sources":["../../src/Utils/ResolveCommand.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGpF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAgCjG;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,KAAK,IAAI,OAAO,CAE9E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAK1F"}
1
+ {"version":3,"file":"ResolveCommand.d.ts","sourceRoot":"","sources":["../../src/Utils/ResolveCommand.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAEV,WAAW,EAEX,OAAO,EACP,eAAe,EAEhB,MAAM,wBAAwB,CAAC;AAGhC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAWjG;AAuDD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,iGAAiG;IACjG,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,uGAAuG;IACvG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,WAAW,GAChB,mBAAmB,GAAG,IAAI,CA8B5B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,KAAK,IAAI,OAAO,CAE9E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAK1F"}
@@ -1,12 +1,21 @@
1
1
  /*!
2
2
  * Copyright (C) Microsoft Corporation. All rights reserved.
3
3
  */
4
- import { isTypedVerbDef } from '../Types/Command.types.js';
4
+ import { hasParentHandler, isTypedVerbDef } from '../Types/Command.types.js';
5
5
  /**
6
6
  * Resolves command-line tokens against the command tree.
7
7
  *
8
8
  * Every command lives under a noun, so the minimum match is 2 tokens (noun + verb).
9
- * Typed subcommands match 3 tokens (noun + verb + type).
9
+ * Typed verbs may nest arbitrarily, so a command path can be any depth (e.g.
10
+ * `app add table` is 3 tokens, `app share link create` is 4). The walker
11
+ * descends as deep as it can; when a typed verb has its own handler ("hybrid"
12
+ * verb, like `app share`) and the next token is **not** a known subcommand,
13
+ * it falls back to the parent handler so the remaining tokens become
14
+ * positional arguments — letting `ms app share alice@contoso.com` route to
15
+ * the `share` handler. When the next token IS a known sub-group of the
16
+ * typed verb but no leaf is reached, we return null instead of falling back,
17
+ * so callers can surface group help rather than misinterpret the sub-group
18
+ * name as a positional argument.
10
19
  *
11
20
  * @param argv - The full process.argv array (argv[0] = node, argv[1] = script)
12
21
  * @param tree - The command tree to resolve against
@@ -14,33 +23,101 @@ import { isTypedVerbDef } from '../Types/Command.types.js';
14
23
  */
15
24
  export function resolveCommand(argv, tree) {
16
25
  const tokens = argv.slice(2);
17
- // Skip if no tokens or first token looks like a flag
18
26
  if (tokens.length === 0 || tokens[0].startsWith('-')) {
19
27
  return null;
20
28
  }
21
- const [t0, t1, t2] = tokens;
29
+ const [t0] = tokens;
22
30
  if (!isKnownNoun(t0, tree))
23
31
  return null;
24
- const nounDef = tree[t0];
25
- // Try 3-token match: noun verb type (e.g., 'app add table')
26
- if (t1 && !t1.startsWith('-') && t2 && !t2.startsWith('-')) {
27
- const verbEntry = nounDef.commands[t1];
28
- if (isTypedVerbDef(verbEntry)) {
29
- const leafDef = verbEntry.commands[t2];
30
- if (leafDef) {
31
- return { path: [t0, t1, t2], handler: leafDef.handler, tokensConsumed: 3 };
32
- }
33
- }
32
+ return walkCommands(tree[t0].commands, tokens, 1, [t0]);
33
+ }
34
+ /**
35
+ * Recursively walks the command tree, consuming one token per level.
36
+ *
37
+ * When the current token names a typed verb, we look at the *next* token to
38
+ * decide whether the user meant to drill deeper or pass a positional argument
39
+ * to a hybrid parent:
40
+ *
41
+ * - If the next token is a known sub-key of this typed verb, the user clearly
42
+ * intended to drill in. We descend and **do not** fall back to a hybrid
43
+ * ancestor if the deeper walk fails to reach a leaf — otherwise
44
+ * `ms app share link` would re-resolve as `ms app share <link>`, treating
45
+ * "link" as a positional principal. Returning null here lets
46
+ * `ArgumentProvider` surface the typed-group help (or an "Unknown type"
47
+ * error if a bogus sub-token follows).
48
+ *
49
+ * - If the next token is missing, a flag, or unrelated to this typed verb's
50
+ * children, we fall back to the typed verb's own handler when it has one
51
+ * (hybrid verb), so `ms app share alice@contoso.com` routes to `share`
52
+ * with `alice@contoso.com` as a positional argument.
53
+ */
54
+ function walkCommands(commands, tokens, index, path) {
55
+ if (index >= tokens.length)
56
+ return null;
57
+ const token = tokens[index];
58
+ if (token.startsWith('-'))
59
+ return null;
60
+ const entry = commands[token];
61
+ if (!entry)
62
+ return null;
63
+ const nextPath = [...path, token];
64
+ if (!isTypedVerbDef(entry)) {
65
+ return { path: nextPath, handler: entry.handler, tokensConsumed: index + 1 };
34
66
  }
35
- // Try 2-token match: noun verb (e.g., 'app init')
36
- if (t1 && !t1.startsWith('-')) {
37
- const verbEntry = nounDef.commands[t1];
38
- if (verbEntry && !isTypedVerbDef(verbEntry)) {
39
- return { path: [t0, t1], handler: verbEntry.handler, tokensConsumed: 2 };
40
- }
67
+ const next = tokens[index + 1];
68
+ const nextIsKnownSub = next !== undefined && !next.startsWith('-') && next in entry.commands;
69
+ if (nextIsKnownSub) {
70
+ return walkCommands(entry.commands, tokens, index + 1, nextPath);
71
+ }
72
+ if (hasParentHandler(entry)) {
73
+ return { path: nextPath, handler: entry.handler, tokensConsumed: index + 1 };
41
74
  }
42
75
  return null;
43
76
  }
77
+ /**
78
+ * Walks argv tokens along the command tree to detect an incomplete typed-verb
79
+ * path — i.e. a path that reached one or more typed verbs (groups) but did not
80
+ * land on a leaf command. Used by `ArgumentProvider` (when `resolveCommand`
81
+ * returns null) to either:
82
+ *
83
+ * - print the typed group's flattened help (when no extra non-flag token
84
+ * follows, e.g. `ms app share link` or `ms app add --connector shared_sql`), or
85
+ * - throw an "Unknown type 'X' for 'ms <path>'" error (when a bogus
86
+ * sub-token follows, e.g. `ms app share link bogus`).
87
+ *
88
+ * Returns null when the path is fully resolvable, when the noun is unknown,
89
+ * when only a noun is provided, or when the second token is not a typed verb
90
+ * (those cases are handled elsewhere in `ArgumentProvider`).
91
+ */
92
+ export function findIncompleteTypedPath(argv, tree) {
93
+ // Stop at the first flag token so flag *values* (e.g. `shared_sql` in
94
+ // `--connector shared_sql`) are not misclassified as subcommand/type tokens.
95
+ const allTokens = argv.slice(2);
96
+ const firstFlagIndex = allTokens.findIndex((t) => t.startsWith('-'));
97
+ const tokens = firstFlagIndex === -1 ? allTokens : allTokens.slice(0, firstFlagIndex);
98
+ if (tokens.length < 2)
99
+ return null;
100
+ const [noun, ...rest] = tokens;
101
+ if (!isKnownNoun(noun, tree))
102
+ return null;
103
+ let commands = tree[noun].commands;
104
+ const pathTokens = [noun];
105
+ let inTypedGroup = false;
106
+ for (const token of rest) {
107
+ const entry = commands[token];
108
+ if (!entry) {
109
+ return inTypedGroup ? { pathTokens, unknownToken: token } : null;
110
+ }
111
+ if (!isTypedVerbDef(entry)) {
112
+ // Matched a leaf — `resolveCommand` already handles this fully.
113
+ return null;
114
+ }
115
+ pathTokens.push(token);
116
+ commands = entry.commands;
117
+ inTypedGroup = true;
118
+ }
119
+ return inTypedGroup ? { pathTokens, unknownToken: undefined } : null;
120
+ }
44
121
  /**
45
122
  * Checks whether the given token is a known noun in the command tree.
46
123
  * Used to distinguish `ms app` (show noun help) from `ms nonexistent` (error).
@@ -1 +1 @@
1
- {"version":3,"file":"ResolveCommand.js","sourceRoot":"","sources":["../../src/Utils/ResolveCommand.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,IAAuB,EAAE,IAAiB;IACvE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE7B,qDAAqD;IACrD,IAAI,MAAM,CAAC,MAA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K,CAAC,CAAC;QACvB,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC1B,YAAY,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,OAAO,YAAY,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,IAAiB;IAC1D,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,IAAY,EAAE,IAAiB;IAC/E,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,SAAS,KAAK,SAAS,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;AAC9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AddConnector.d.ts","sourceRoot":"","sources":["../../src/Verbs/AddConnector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAe5D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkEzF"}
1
+ {"version":3,"file":"AddConnector.d.ts","sourceRoot":"","sources":["../../src/Verbs/AddConnector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAe5D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgEzF"}