@uipath/solution-tool 1.203.0-preview.212 → 1.204.0-preview.211

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 (76) hide show
  1. package/README.md +2 -2
  2. package/dist/THIRD-PARTY-NOTICES.md +4 -4
  3. package/dist/deploy-delete-service-gg00vadc.js +22 -0
  4. package/dist/deploy-status-service-cqfrvxpz.js +256 -0
  5. package/dist/deploy.d.ts +11 -4
  6. package/dist/deploy.js +19 -7
  7. package/dist/deployment-search-j34w33b2.js +49 -0
  8. package/dist/{embedded-file-reader-xxqe8vs8.js → embedded-file-reader-rf2g1kfj.js} +2 -2
  9. package/dist/feed-resolver-31gcvnnk.js +27 -0
  10. package/dist/feed-scope-failure-fwtdvvrh.js +18 -0
  11. package/dist/feed-session-sxga31vn.js +17 -0
  12. package/dist/index.js +27 -18
  13. package/dist/init.js +10 -7
  14. package/dist/{list-xjdnbyka.js → list-q4dzkv45.js} +9 -6
  15. package/dist/pack.js +14 -11
  16. package/dist/{packager-tool-7qmx64kz.js → packager-tool-00vh1ktg.js} +1022 -1342
  17. package/dist/packager-tool-1phh2rfx.js +37 -0
  18. package/dist/{packager-tool-vas0xg5h.js → packager-tool-2cntqvdv.js} +5 -3
  19. package/dist/{packager-tool-1haahq17.js → packager-tool-3enm2h28.js} +5 -5
  20. package/dist/{packager-tool-2syrt51a.js → packager-tool-3fv6zc86.js} +1062 -825
  21. package/dist/{packager-tool-grtmkd54.js → packager-tool-3m36mxn7.js} +16 -74
  22. package/dist/packager-tool-40vcj4wv.js +172 -0
  23. package/dist/packager-tool-482eg22x.js +322 -0
  24. package/dist/{packager-tool-k4mskzww.js → packager-tool-5dzjsw5q.js} +3 -3
  25. package/dist/{packager-tool-0f0wt9vh.js → packager-tool-5fjp60dk.js} +3071 -2794
  26. package/dist/{packager-tool-bkwnetqn.js → packager-tool-83rzavkx.js} +383 -88
  27. package/dist/{packager-tool-f423v35w.js → packager-tool-9hj0cfd0.js} +756 -359
  28. package/dist/{packager-tool-7znqtw3f.js → packager-tool-9vvdgbay.js} +8 -6
  29. package/dist/packager-tool-bqre28m1.js +43 -0
  30. package/dist/packager-tool-f5gq77m5.js +28 -0
  31. package/dist/{packager-tool-nzghfa48.js → packager-tool-fv7xyzg2.js} +550 -2
  32. package/dist/{packager-tool-3jrq7smt.js → packager-tool-gb35b4qs.js} +206 -289
  33. package/dist/{packager-tool-4kdt8mys.js → packager-tool-j30xck4w.js} +1008 -647
  34. package/dist/packager-tool-ks8spnq8.js +166 -0
  35. package/dist/packager-tool-q3tgpemc.js +113 -0
  36. package/dist/packager-tool-qdtjywsk.js +173 -0
  37. package/dist/{packager-tool-2p5yh1q9.js → packager-tool-qgaqqq41.js} +320 -151
  38. package/dist/packager-tool-qm24rbae.js +5889 -0
  39. package/dist/{packager-tool-resolver-fmjr60x8.js → packager-tool-resolver-2cbxyq6k.js} +6 -5
  40. package/dist/{packager-tool-znakt6yw.js → packager-tool-vh4ng74p.js} +8 -6
  41. package/dist/packager-tool-vmsxq1pc.js +104 -0
  42. package/dist/packager-tool-zf3929se.js +237 -0
  43. package/dist/packager-tool-zns6n8zp.js +837 -0
  44. package/dist/packager-tool.js +2 -2
  45. package/dist/prepare-solution-resources-p3gzdecy.js +25 -0
  46. package/dist/{project-contributions-cvttys34.js → project-contributions-txe8v6sm.js} +12 -9
  47. package/dist/publish.js +12 -7
  48. package/dist/resource.js +9 -6
  49. package/dist/services/activation.d.ts +17 -2
  50. package/dist/services/deploy-activate-service.d.ts +10 -0
  51. package/dist/services/deploy-delete-service.d.ts +82 -0
  52. package/dist/services/deploy-list-service.d.ts +15 -45
  53. package/dist/services/deploy-run-service.d.ts +36 -23
  54. package/dist/services/deploy-upgrade-service.d.ts +198 -39
  55. package/dist/services/deployment-feed-locator.d.ts +50 -12
  56. package/dist/services/deployment-search-client.d.ts +55 -0
  57. package/dist/services/deployment-search.d.ts +87 -34
  58. package/dist/services/deployment-state.d.ts +119 -0
  59. package/dist/services/feed-resolver.d.ts +31 -0
  60. package/dist/services/feed-session.d.ts +70 -0
  61. package/dist/services/folder-helper.d.ts +4 -27
  62. package/dist/services/http-status.d.ts +9 -0
  63. package/dist/services/incomplete-feed-sweep.d.ts +77 -0
  64. package/dist/services/legacy-deployment-search-v3.d.ts +23 -0
  65. package/dist/services/packages-list-service.d.ts +5 -0
  66. package/dist/services/pipeline-deploy-poll.d.ts +69 -0
  67. package/dist/services/publish-service.d.ts +14 -16
  68. package/dist/services/search-failure.d.ts +27 -0
  69. package/dist/templates/AGENTS.md +60 -20
  70. package/dist/tool.js +27 -18
  71. package/dist/utils/deployment-errors.d.ts +57 -0
  72. package/package.json +2 -2
  73. package/dist/packager-tool-jz2wbfjz.js +0 -2275
  74. package/dist/packager-tool-wtpe9285.js +0 -51960
  75. package/dist/prepare-solution-resources-wds3r8bq.js +0 -22
  76. package/dist/services/personal-workspace-deploy.d.ts +0 -49
@@ -0,0 +1,166 @@
1
+ import {
2
+ SolutionDeploymentAction
3
+ } from "./packager-tool-00vh1ktg.js";
4
+ import {
5
+ catchError
6
+ } from "./packager-tool-5fjp60dk.js";
7
+
8
+ // src/services/deployment-state.ts
9
+ function quoteForShell(name) {
10
+ return `'${name.replace(/'/g, "'\\''")}'`;
11
+ }
12
+ var RESOURCES_PAGE_SIZE = 50;
13
+ var RESOURCES_MAX_PAGES = 10;
14
+ async function readPendingResourcesAsync(api, deploymentKey, scope) {
15
+ const pending = [];
16
+ let complete = false;
17
+ for (let page = 0, skip = 0;page < RESOURCES_MAX_PAGES; page++) {
18
+ const [readError, result] = await catchError(api.deploymentsGetDeploymentResources({ deploymentKey, skip, take: RESOURCES_PAGE_SIZE }, scope));
19
+ if (readError || !result) {
20
+ return;
21
+ }
22
+ const values = result.values ?? [];
23
+ for (const resource of values) {
24
+ if (resource.requiresConfiguration) {
25
+ pending.push(toPendingResource(resource));
26
+ }
27
+ }
28
+ skip += values.length;
29
+ if (values.length < RESOURCES_PAGE_SIZE || typeof result.count === "number" && skip >= result.count) {
30
+ complete = true;
31
+ break;
32
+ }
33
+ }
34
+ if (!complete) {
35
+ return;
36
+ }
37
+ if (pending.length > 0) {
38
+ await attachActivationReasonsAsync(api, deploymentKey, pending, scope);
39
+ }
40
+ return pending;
41
+ }
42
+ function toPendingResource(resource) {
43
+ return {
44
+ key: resource.key,
45
+ name: resource.name,
46
+ kind: resource.kind,
47
+ type: resource.type
48
+ };
49
+ }
50
+ async function attachActivationReasonsAsync(api, deploymentKey, pending, scope) {
51
+ const [readError, validation] = await catchError(() => api.deploymentsGetValidationResult({
52
+ deploymentKey,
53
+ deploymentAction: SolutionDeploymentAction.Activate
54
+ }, scope));
55
+ if (readError || !validation) {
56
+ return;
57
+ }
58
+ const reasons = new Map;
59
+ for (const resource of validation.resourceValidationErrors ?? []) {
60
+ const texts = (resource.errors ?? []).map((error) => error.errorCode ? `[${error.errorCode}] ${error.text}` : error.text).filter(Boolean);
61
+ if (texts.length > 0) {
62
+ reasons.set(resourceIdentity(resource.name, resource.type), texts.join("; "));
63
+ }
64
+ }
65
+ for (const resource of pending) {
66
+ const reason = reasons.get(resourceIdentity(resource.name, resource.type));
67
+ if (reason) {
68
+ resource.reason = reason;
69
+ }
70
+ }
71
+ }
72
+ function resourceIdentity(name, type) {
73
+ return `${name}\x00${type ?? ""}`;
74
+ }
75
+ var MAX_LISTED_RESOURCES = 10;
76
+ function formatPendingResources(resources) {
77
+ const described = resources.slice(0, MAX_LISTED_RESOURCES).map((resource) => {
78
+ const type = resource.type && resource.type !== resource.kind ? ` (${resource.type})` : "";
79
+ const reason = resource.reason ? `: ${resource.reason}` : "";
80
+ return `${resource.kind} '${resource.name}'${type}${reason}`;
81
+ }).join("; ");
82
+ const remaining = resources.length - MAX_LISTED_RESOURCES;
83
+ return remaining > 0 ? `${described}; and ${remaining} more` : described;
84
+ }
85
+ function activationNextSteps(deployment, pendingResources) {
86
+ const name = deployment.name;
87
+ const version = deployment.currentPackageVersion ?? deployment.packageVersion;
88
+ const installed = `Deployment '${name}' is installed${version ? ` at version ${version}` : ""}`;
89
+ switch (deployment.activationStatus) {
90
+ case "NeedsSetupToActivate": {
91
+ const steps = [
92
+ `${installed} but not live: it needs 'Setup activation' before it can be activated.`,
93
+ describePendingResources(pendingResources)
94
+ ];
95
+ steps.push(`Complete 'Setup activation' for '${name}' in Orchestrator (Tenant > Solutions > Deployments, open the deployment). The CLI has no command for this step on an existing deployment: 'uip solution deploy config link' applies only to a new 'deploy run', an upgrade takes no config file, and 'uip solution deploy activate' is refused until the setup is done.`);
96
+ return steps;
97
+ }
98
+ case "ReadyToActivate":
99
+ case "Inactive":
100
+ return [
101
+ `${installed} but inactive. Activate it with: uip solution deploy activate ${quoteForShell(name)}.`
102
+ ];
103
+ case "ActivationFailed":
104
+ return [
105
+ `Activation of '${name}' failed. Inspect the deployment in Orchestrator, then retry with: uip solution deploy activate ${quoteForShell(name)}.`
106
+ ];
107
+ default:
108
+ return;
109
+ }
110
+ }
111
+ function appendDeploymentStateInstructions(instructions, deployment, pendingResources, feedSelector = "") {
112
+ const steps = deployment ? explainRefusal(deployment, pendingResources, feedSelector) : undefined;
113
+ return steps ? `${instructions}
114
+ ${steps.join(`
115
+ `)}` : instructions;
116
+ }
117
+ function explainRefusal(deployment, pendingResources, feedSelector = "") {
118
+ const explains = deployment.operationStatus === "Draft" || deployment.operationStatus === "Successful" && deployment.activationStatus === "NeedsSetupToActivate";
119
+ if (!explains) {
120
+ return;
121
+ }
122
+ const steps = deploymentNextSteps(deployment, pendingResources, feedSelector);
123
+ return steps && steps.length > 0 ? steps : undefined;
124
+ }
125
+ function needsPendingResources(deployment) {
126
+ return deployment.activationStatus === "NeedsSetupToActivate" || deployment.operationStatus === "Draft" && deployment.operation === "ActivationSetup";
127
+ }
128
+ function deploymentNextSteps(deployment, pendingResources, feedSelector = "") {
129
+ if (deployment.operationStatus === "Draft") {
130
+ const steps = [describeDraft(deployment, feedSelector)];
131
+ if (deployment.operation === "ActivationSetup") {
132
+ steps.push(describePendingResources(pendingResources));
133
+ }
134
+ return steps;
135
+ }
136
+ return activationNextSteps(deployment, pendingResources);
137
+ }
138
+ function describePendingResources(pendingResources) {
139
+ if (pendingResources === undefined) {
140
+ return "The CLI could not read which resources need configuration; the deployment's Resources tab in Orchestrator lists them.";
141
+ }
142
+ if (pendingResources.length === 0) {
143
+ return "The service lists no resource as needing configuration; the deployment's Resources tab in Orchestrator shows what it asks for.";
144
+ }
145
+ return `Resources that need configuration: ${formatPendingResources(pendingResources)}.`;
146
+ }
147
+ function describeDraft(deployment, feedSelector) {
148
+ const name = deployment.name;
149
+ const state = `(Operation: ${deployment.operation}, OperationStatus: Draft, ActivationStatus: ${deployment.activationStatus})`;
150
+ switch (deployment.operation) {
151
+ case "ActivationSetup":
152
+ return `Deployment '${name}' has a 'Setup activation' that was started but not completed ${state} and cannot be activated until it is. Finish it in Orchestrator (Tenant > Solutions > Deployments, open the deployment; the UI lists it as 'Activation setup / Draft'). The CLI has no command for this step on an existing deployment. To discard the unfinished setup instead, run: uip solution deploy delete ${quoteForShell(name)} --yes. That removes the draft alone; the deployment returns to its previous record, still waiting for setup.`;
153
+ case "VersionChange":
154
+ return `Deployment '${name}' has an upgrade that was queued but never installed ${state} and cannot be activated until it settles. 'uip solution deploy upgrade' installs the draft it queues; a draft left by another client stays until it is installed or removed; check it with: uip solution deploy list${feedSelector}.`;
155
+ case "Install":
156
+ case undefined:
157
+ case null:
158
+ return `Deployment '${name}' exists but is still in Draft state (OperationStatus: ${deployment.operationStatus}, ActivationStatus: ${deployment.activationStatus}). Draft deployments are created by deploy runs that did not complete successfully and cannot be activated. Fix the deploy run validation errors, rerun 'uip solution deploy run', then activate after 'uip solution deploy list${feedSelector}' shows the deployment is no longer Draft.`;
159
+ default:
160
+ return `Deployment '${name}' has a pending ${deployment.operation} ${state} and cannot be activated until it settles. Check it with: uip solution deploy list${feedSelector}.`;
161
+ }
162
+ }
163
+
164
+ export { quoteForShell, readPendingResourcesAsync, appendDeploymentStateInstructions, explainRefusal, needsPendingResources, deploymentNextSteps };
165
+
166
+ //# debugId=ABAB11E889A49E7364756E2164756E21
@@ -0,0 +1,113 @@
1
+ import {
2
+ INCOMPLETE_SWEEP_ADVICE,
3
+ findDeploymentAcrossFeeds,
4
+ reportIncompleteSweepAsync
5
+ } from "./packager-tool-40vcj4wv.js";
6
+ import {
7
+ Configuration,
8
+ DeploymentsApi,
9
+ WorkflowAction
10
+ } from "./packager-tool-00vh1ktg.js";
11
+ import {
12
+ getSolutionAuthContext
13
+ } from "./packager-tool-f5gq77m5.js";
14
+ import {
15
+ catchError,
16
+ extractErrorDetails
17
+ } from "./packager-tool-5fjp60dk.js";
18
+
19
+ // src/services/deploy-delete-service.ts
20
+ var fail = (reason, message, instructions, extras = {}) => ({
21
+ ok: false,
22
+ reason,
23
+ message,
24
+ instructions,
25
+ exitCode: extras.exitCode ?? 1,
26
+ errorCode: extras.errorCode,
27
+ retry: extras.retry
28
+ });
29
+ var AUTH_INSTRUCTIONS = "Run 'uip login' to refresh credentials, then retry. If the deployment is in a different tenant, switch with 'uip login tenant set <tenant>'.";
30
+ function buildUnavailableInstructions(deployment) {
31
+ const availableActions = deployment.actions?.length ? deployment.actions.join(", ") : "none";
32
+ const status = `(ActivationStatus: ${deployment.activationStatus}, OperationStatus: ${deployment.operationStatus})`;
33
+ if (deployment.operationStatus === "InProgress") {
34
+ return `Deployment '${deployment.name}' has an operation in progress ${status}. Wait for it to finish — run 'uip solution deploy list' to recheck — then retry. Available actions: ${availableActions}.`;
35
+ }
36
+ if (deployment.actions?.includes(WorkflowAction.Uninstall)) {
37
+ return `Deployment '${deployment.name}' offers Uninstall but not Delete ${status}. Run: uip solution deploy uninstall '${deployment.name}' --yes, then retry the delete. Available actions: ${availableActions}.`;
38
+ }
39
+ return `Deployment '${deployment.name}' cannot be deleted in its current state ${status}. Available actions: ${availableActions}. Run 'uip solution deploy list' to recheck its state.`;
40
+ }
41
+ function requestErrorInstructions(deploymentName, errorCode, details) {
42
+ switch (errorCode) {
43
+ case "authentication_required":
44
+ return `Your session may have expired. Run 'uip login' and retry. Details: ${details}`;
45
+ case "permission_denied":
46
+ return `Your account lacks permission to delete this deployment. Check your Orchestrator roles, then retry. Details: ${details}`;
47
+ case "rate_limited":
48
+ return `Too many requests. Wait a moment and retry. Details: ${details}`;
49
+ case "network_error":
50
+ return `Could not reach Orchestrator. Check your connection and retry. Details: ${details}`;
51
+ case "server_error":
52
+ return `Orchestrator returned a server error. Wait and retry; if it persists, check Orchestrator status. Details: ${details}`;
53
+ case "not_found":
54
+ return `Deployment '${deploymentName}' was found by name but the delete reported it missing — it may have been removed already. Run 'uip solution deploy list' to confirm. Details: ${details}`;
55
+ default:
56
+ return `Delete request failed. Run 'uip solution deploy list' to check the deployment's state, then retry. Details: ${details}`;
57
+ }
58
+ }
59
+ async function deleteDeploymentAsync(deploymentName, options = {}) {
60
+ const [authError, auth] = await catchError(getSolutionAuthContext({
61
+ tenant: options.tenant,
62
+ loginValidity: options.loginValidity,
63
+ envFilePath: options.envFilePath
64
+ }));
65
+ if (authError) {
66
+ return fail("auth_failed", authError.message, AUTH_INSTRUCTIONS, {
67
+ errorCode: "authentication_required",
68
+ retry: "RetryWillNotFix"
69
+ });
70
+ }
71
+ const sweep = await findDeploymentAcrossFeeds(auth, deploymentName, {
72
+ tenant: options.tenant,
73
+ loginValidity: options.loginValidity,
74
+ envFilePath: options.envFilePath,
75
+ includeUninstalled: true
76
+ });
77
+ const { location } = sweep;
78
+ if (!location && !sweep.complete) {
79
+ const report = await reportIncompleteSweepAsync(deploymentName, sweep.skipped);
80
+ const oneFeed = report.oneFeedFlags.map((flag) => `'uip solution deploy list ${flag}'`).join(" or ");
81
+ return fail("lookup_failed", report.message, `${INCOMPLETE_SWEEP_ADVICE} ${report.nextStep}${oneFeed ? ` To check one feed yourself, run ${oneFeed}.` : ""} Details: ${report.details}`, { errorCode: report.errorCode, retry: report.retry });
82
+ }
83
+ if (!location) {
84
+ return fail("deployment_not_found", `No deployment named '${deploymentName}' was found.`, "Run 'uip solution deploy list' to see valid deployment names.", { errorCode: "not_found", retry: "RetryWillNotFix" });
85
+ }
86
+ const { deployment, scope } = location;
87
+ if (deployment.actions?.length && !deployment.actions.includes(WorkflowAction.Delete)) {
88
+ const inProgress = deployment.operationStatus === "InProgress";
89
+ return fail("delete_unavailable", `Deployment '${deploymentName}' cannot be deleted in its current state.`, buildUnavailableInstructions(deployment), {
90
+ errorCode: "invalid_argument",
91
+ retry: inProgress ? "RetryLater" : "RetryWillNotFix"
92
+ });
93
+ }
94
+ const config = new Configuration({
95
+ basePath: auth.basePath,
96
+ accessToken: auth.accessToken
97
+ });
98
+ const deploymentsApi = new DeploymentsApi(config);
99
+ const [deleteError] = await catchError(deploymentsApi.deploymentsDelete({ deploymentKey: deployment.key }, scope));
100
+ if (deleteError) {
101
+ const detail = await extractErrorDetails(deleteError);
102
+ return fail("delete_request_failed", detail.message, requestErrorInstructions(deploymentName, detail.errorCode, detail.details), { errorCode: detail.errorCode, retry: detail.retry });
103
+ }
104
+ return {
105
+ ok: true,
106
+ deploymentName,
107
+ deploymentKey: deployment.key
108
+ };
109
+ }
110
+
111
+ export { deleteDeploymentAsync };
112
+
113
+ //# debugId=D4EB3B798936BE2864756E2164756E21
@@ -0,0 +1,173 @@
1
+ import {
2
+ getAvailablePublishLocationsV2
3
+ } from "./packager-tool-00vh1ktg.js";
4
+ import {
5
+ classifyFeedSession
6
+ } from "./packager-tool-bqre28m1.js";
7
+ import {
8
+ PersonalWorkspacesApi,
9
+ createOrchestratorConfig
10
+ } from "./packager-tool-3fv6zc86.js";
11
+ import {
12
+ extractErrorDetails
13
+ } from "./packager-tool-5fjp60dk.js";
14
+ import {
15
+ getLoginStatusAsync
16
+ } from "./packager-tool-gb35b4qs.js";
17
+
18
+ // src/services/personal-workspace-resolver.ts
19
+ async function resolvePersonalWorkspace(options) {
20
+ const config = await createOrchestratorConfig(options);
21
+ const api = new PersonalWorkspacesApi(config);
22
+ const pw = await api.personalWorkspacesGetPersonalWorkspace();
23
+ if (!pw?.key || !pw.name) {
24
+ throw new Error("Personal Workspace not configured for the current user. " + "Enable Personal Workspace in Orchestrator (or sign in as a user that has one), then retry.");
25
+ }
26
+ return { key: pw.key, name: pw.name };
27
+ }
28
+
29
+ // src/services/publish-locations-service.ts
30
+ async function resolveStudioWebTarget(options) {
31
+ const loginStatus = await getLoginStatusAsync({
32
+ ensureTokenValidityMinutes: options?.loginValidity,
33
+ envFilePath: options?.envFilePath
34
+ });
35
+ if (loginStatus.loginStatus !== "Logged in" || !loginStatus.accessToken || !loginStatus.baseUrl) {
36
+ throw new Error("Not logged in. Run 'uip login' first.");
37
+ }
38
+ if (!loginStatus.organizationName) {
39
+ throw new Error("Organization name is not available. Re-authenticate with 'uip login'.");
40
+ }
41
+ if (options?.tenant && loginStatus.tenantName && options.tenant.toLowerCase() !== loginStatus.tenantName.toLowerCase()) {
42
+ throw new Error(`Feeds are resolved for the logged-in tenant ('${loginStatus.tenantName}'), so --tenant '${options.tenant}' can't apply here. Switch tenants first with: uip login tenant set ${options.tenant}.`);
43
+ }
44
+ return {
45
+ config: {
46
+ baseUrl: loginStatus.baseUrl,
47
+ authToken: loginStatus.accessToken,
48
+ tenantId: loginStatus.tenantId
49
+ },
50
+ organizationName: loginStatus.organizationName
51
+ };
52
+ }
53
+ function isSelectableFeed(location) {
54
+ switch (location.type) {
55
+ case "Tenant":
56
+ case "Folder":
57
+ return true;
58
+ case "PersonalWorkspace":
59
+ return location.isMyPersonalWorkspace;
60
+ default:
61
+ return false;
62
+ }
63
+ }
64
+ async function listSelectablePublishLocations(options) {
65
+ const { config, organizationName } = await resolveStudioWebTarget(options);
66
+ const all = await getAvailablePublishLocationsV2(config, organizationName);
67
+ return all.filter(isSelectableFeed);
68
+ }
69
+
70
+ // src/services/feed-resolver.ts
71
+ function folderKeyInitOverride(folderKey) {
72
+ return async ({ init }) => ({
73
+ headers: { ...init.headers, "X-UIPATH-FolderKey": folderKey }
74
+ });
75
+ }
76
+ function feedScopeInitOverride(scope) {
77
+ const { folderKey } = scope;
78
+ if (!folderKey) {
79
+ return;
80
+ }
81
+ return folderKeyInitOverride(folderKey);
82
+ }
83
+ function feedSelectorFlag(scope) {
84
+ if (!scope || scope.kind === "tenant" || !scope.folderKey) {
85
+ return "";
86
+ }
87
+ return scope.kind === "personal" ? " --personal-workspace" : ` --feed ${scope.folderKey}`;
88
+ }
89
+ function feedResolutionFailureInstructions(options) {
90
+ if (options.personalWorkspace) {
91
+ return "Personal Workspace resolution needs an interactive user session and an enabled Personal Workspace. Log in as a user with a Personal Workspace, or omit --personal-workspace to use the tenant feed.";
92
+ }
93
+ if (options.feed !== undefined) {
94
+ return "List the feeds you can target with: uip solution feeds list.";
95
+ }
96
+ return "Check the selected feed and try again.";
97
+ }
98
+ async function describeFeedResolutionFailureAsync(error, options, session) {
99
+ const details = await extractErrorDetails(error);
100
+ if (options.personalWorkspace && isRefusal(details.context?.httpStatus) && classifyFeedSession(session) === "application") {
101
+ return {
102
+ message: "--personal-workspace needs a user session; this session is an external app, which has no Personal Workspace.",
103
+ instructions: "Run it with a user session that has a Personal Workspace ('uip login'). A client-credentials login cannot target one.",
104
+ errorCode: "permission_denied",
105
+ retry: "RetryWillNotFix",
106
+ context: details.context
107
+ };
108
+ }
109
+ return {
110
+ message: details.message,
111
+ instructions: feedResolutionFailureInstructions(options),
112
+ errorCode: details.errorCode,
113
+ retry: details.retry,
114
+ context: details.context
115
+ };
116
+ }
117
+ function isRefusal(status) {
118
+ return status !== undefined && status >= 400 && status < 500 && status !== 408 && status !== 429;
119
+ }
120
+ async function resolveFeedScope(options) {
121
+ const { personalWorkspace, feed } = options;
122
+ if (personalWorkspace && feed !== undefined) {
123
+ throw new Error("Use either --personal-workspace or --feed, not both.");
124
+ }
125
+ if (personalWorkspace) {
126
+ const pw = await resolvePersonalWorkspace({
127
+ tenant: options.tenant,
128
+ loginValidity: options.loginValidity,
129
+ envFilePath: options.envFilePath
130
+ });
131
+ return { kind: "personal", folderKey: pw.key, name: pw.name };
132
+ }
133
+ if (feed !== undefined) {
134
+ return resolveNamedFeed(feed, options);
135
+ }
136
+ return { kind: "tenant" };
137
+ }
138
+ async function resolveNamedFeed(feed, options) {
139
+ const locations = await listSelectablePublishLocations({
140
+ tenant: options.tenant,
141
+ envFilePath: options.envFilePath,
142
+ loginValidity: options.loginValidity
143
+ });
144
+ const match = matchFeed(feed, locations);
145
+ const kind = match.type === "Tenant" ? "tenant" : match.type === "PersonalWorkspace" ? "personal" : "folder";
146
+ if (kind !== "tenant" && !match.key) {
147
+ throw new Error(`Feed '${match.name || feed}' has no folder key in the publish-locations response, so it can't be targeted. Run 'uip solution feeds list' and pick a feed with a Key.`);
148
+ }
149
+ return {
150
+ kind,
151
+ folderKey: kind === "tenant" ? undefined : match.key,
152
+ name: match.name
153
+ };
154
+ }
155
+ function matchFeed(feed, locations) {
156
+ const byKey = locations.find((location) => location.key === feed);
157
+ if (byKey) {
158
+ return byKey;
159
+ }
160
+ const target = feed.toLowerCase();
161
+ const byName = locations.filter((location) => location.name.toLowerCase() === target);
162
+ if (byName.length === 1) {
163
+ return byName[0];
164
+ }
165
+ if (byName.length > 1) {
166
+ throw new Error(`More than one feed is named '${feed}'. Pass its key instead — ` + "'uip solution feeds list' shows each feed's key.");
167
+ }
168
+ throw new Error(`Feed '${feed}' is not an available publish location. ` + "Run 'uip solution feeds list' to see the feeds you can publish to.");
169
+ }
170
+
171
+ export { resolvePersonalWorkspace, listSelectablePublishLocations, folderKeyInitOverride, feedScopeInitOverride, feedSelectorFlag, feedResolutionFailureInstructions, describeFeedResolutionFailureAsync, resolveFeedScope };
172
+
173
+ //# debugId=F37E07288EA6F3E164756E2164756E21