@uipath/tasks-tool 1.201.0-preview.115 → 1.201.0-preview.122

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 (40) hide show
  1. package/browser.json +2 -1
  2. package/dist/folder-picker-interactive-2kj361mt.js +1850 -0
  3. package/dist/folder-resolver-htdmzdhy.js +92 -0
  4. package/dist/index.js +5 -3
  5. package/dist/tool-0n9mj887.js +2448 -0
  6. package/dist/tool-rsk1xt86.js +6026 -0
  7. package/dist/{tool-vw6gha5d.js → tool-xcy3gbe4.js} +7469 -10469
  8. package/dist/tool.js +3 -2
  9. package/package.json +2 -2
  10. package/src/commands/_shared/catalog-options.spec.ts +114 -0
  11. package/src/commands/_shared/catalog-options.ts +122 -0
  12. package/src/commands/_shared/connect.spec.ts +52 -0
  13. package/src/commands/_shared/connect.ts +31 -0
  14. package/src/commands/_shared/constants.ts +1 -0
  15. package/src/commands/_shared/folder-picker-interactive.spec.ts +92 -0
  16. package/src/commands/_shared/folder-picker-interactive.ts +76 -0
  17. package/src/commands/_shared/folder-picker.spec.ts +159 -0
  18. package/src/commands/_shared/folder-picker.ts +113 -0
  19. package/src/commands/_shared/folder-resolver.spec.ts +152 -0
  20. package/src/commands/_shared/folder-resolver.ts +113 -0
  21. package/src/commands/_shared/parse.spec.ts +69 -0
  22. package/src/commands/_shared/parse.ts +43 -0
  23. package/src/commands/catalogs.ts +277 -0
  24. package/src/commands/comments.ts +160 -0
  25. package/src/commands/data.ts +137 -0
  26. package/src/commands/labels.ts +93 -0
  27. package/src/commands/metadata.ts +139 -0
  28. package/src/commands/tasks.spec.ts +1557 -2
  29. package/src/commands/tasks.ts +191 -280
  30. package/src/tool.ts +10 -0
  31. package/src/utils/sdk-client.ts +5 -0
  32. package/tests/assignable-users.e2e.test.ts +58 -4
  33. package/tests/catalogs.e2e.test.ts +393 -0
  34. package/tests/comments.e2e.test.ts +223 -0
  35. package/tests/complete.e2e.test.ts +9 -9
  36. package/tests/data.e2e.test.ts +187 -0
  37. package/tests/get.e2e.test.ts +4 -2
  38. package/tests/labels.e2e.test.ts +184 -0
  39. package/tests/list.e2e.test.ts +110 -0
  40. package/tests/metadata.e2e.test.ts +186 -0
@@ -0,0 +1,139 @@
1
+ import {
2
+ catchError,
3
+ extractErrorMessage,
4
+ OutputFormatter,
5
+ processContext,
6
+ RESULTS,
7
+ } from "@uipath/common";
8
+ import type { TaskEditMetadataOptions } from "@uipath/uipath-typescript";
9
+ import { TaskPriority } from "@uipath/uipath-typescript";
10
+ import type { Command } from "commander";
11
+
12
+ import { connectTasksClient } from "./_shared/connect";
13
+ import {
14
+ addFolderScopeOptions,
15
+ type FolderScopeOptions,
16
+ resolveFolderId,
17
+ } from "./_shared/folder-picker";
18
+ import { parseIntArg } from "./_shared/parse";
19
+
20
+ interface MetadataOptions extends FolderScopeOptions {
21
+ title?: string;
22
+ priority?: string;
23
+ catalogId?: string;
24
+ unsetCatalog?: boolean;
25
+ note?: string;
26
+ }
27
+
28
+ export const registerMetadataCommand = (program: Command) => {
29
+ addFolderScopeOptions(
30
+ program
31
+ .command("metadata")
32
+ .description("Edit a task's metadata")
33
+ .argument("<task-id>", "Task ID"),
34
+ )
35
+ .option("--title <title>", "New title")
36
+ .option(
37
+ "--priority <priority>",
38
+ "New priority (Low, Medium, High, Critical)",
39
+ )
40
+ .option("--catalog-id <id>", "Associate a task catalog by ID")
41
+ .option("--unset-catalog", "Remove the task's catalog association")
42
+ .option("--note <text>", "Comment recorded with the edit")
43
+ .trackedAction(
44
+ processContext,
45
+ async (taskId: string, options: MetadataOptions) => {
46
+ const sdk = await connectTasksClient();
47
+ if (!sdk) return;
48
+
49
+ const parsedTaskId = parseIntArg(taskId, "<task-id>");
50
+ if (parsedTaskId === null) return;
51
+
52
+ if (options.catalogId && options.unsetCatalog) {
53
+ OutputFormatter.error({
54
+ Result: RESULTS.Failure,
55
+ Message:
56
+ "--catalog-id and --unset-catalog cannot be used together",
57
+ Instructions:
58
+ "Pass --catalog-id to associate a catalog, or --unset-catalog to clear it, not both.",
59
+ });
60
+ processContext.exit(1);
61
+ return;
62
+ }
63
+
64
+ const hasEdit =
65
+ options.title !== undefined ||
66
+ options.priority !== undefined ||
67
+ options.catalogId !== undefined ||
68
+ options.unsetCatalog === true ||
69
+ options.note !== undefined;
70
+ if (!hasEdit) {
71
+ OutputFormatter.error({
72
+ Result: RESULTS.Failure,
73
+ Message: "No metadata changes provided",
74
+ Instructions:
75
+ "Pass at least one of --title, --priority, --catalog-id, --unset-catalog, or --note.",
76
+ });
77
+ processContext.exit(1);
78
+ return;
79
+ }
80
+
81
+ const folderId = await resolveFolderId(options);
82
+ if (folderId === null) return;
83
+
84
+ const editOptions: TaskEditMetadataOptions = { folderId };
85
+ if (options.title !== undefined) {
86
+ editOptions.title = options.title;
87
+ }
88
+ if (options.priority !== undefined) {
89
+ if (
90
+ !Object.values(TaskPriority).includes(
91
+ options.priority as TaskPriority,
92
+ )
93
+ ) {
94
+ OutputFormatter.error({
95
+ Result: RESULTS.Failure,
96
+ Message: `Invalid priority '${options.priority}'`,
97
+ Instructions: `Valid priorities: ${Object.values(TaskPriority).join(", ")}`,
98
+ });
99
+ processContext.exit(1);
100
+ return;
101
+ }
102
+ editOptions.priority = options.priority as TaskPriority;
103
+ }
104
+ if (options.catalogId !== undefined) {
105
+ const parsedCatalogId = parseIntArg(
106
+ options.catalogId,
107
+ "--catalog-id",
108
+ );
109
+ if (parsedCatalogId === null) return;
110
+ editOptions.taskCatalogId = parsedCatalogId;
111
+ }
112
+ if (options.unsetCatalog) {
113
+ editOptions.unlinkTaskCatalog = true;
114
+ }
115
+ if (options.note !== undefined) {
116
+ editOptions.noteText = options.note;
117
+ }
118
+
119
+ const [editError] = await catchError(
120
+ sdk.tasks.editMetadata(parsedTaskId, editOptions),
121
+ );
122
+ if (editError) {
123
+ OutputFormatter.error({
124
+ Result: RESULTS.Failure,
125
+ Message: `Error editing metadata on task '${taskId}'`,
126
+ Instructions: await extractErrorMessage(editError),
127
+ });
128
+ processContext.exit(1);
129
+ return;
130
+ }
131
+
132
+ OutputFormatter.success({
133
+ Result: RESULTS.Success,
134
+ Code: "TaskMetadataEdited",
135
+ Data: { taskId: parsedTaskId },
136
+ });
137
+ },
138
+ );
139
+ };