@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.
- package/browser.json +2 -1
- package/dist/folder-picker-interactive-2kj361mt.js +1850 -0
- package/dist/folder-resolver-htdmzdhy.js +92 -0
- package/dist/index.js +5 -3
- package/dist/tool-0n9mj887.js +2448 -0
- package/dist/tool-rsk1xt86.js +6026 -0
- package/dist/{tool-vw6gha5d.js → tool-xcy3gbe4.js} +7469 -10469
- package/dist/tool.js +3 -2
- package/package.json +2 -2
- package/src/commands/_shared/catalog-options.spec.ts +114 -0
- package/src/commands/_shared/catalog-options.ts +122 -0
- package/src/commands/_shared/connect.spec.ts +52 -0
- package/src/commands/_shared/connect.ts +31 -0
- package/src/commands/_shared/constants.ts +1 -0
- package/src/commands/_shared/folder-picker-interactive.spec.ts +92 -0
- package/src/commands/_shared/folder-picker-interactive.ts +76 -0
- package/src/commands/_shared/folder-picker.spec.ts +159 -0
- package/src/commands/_shared/folder-picker.ts +113 -0
- package/src/commands/_shared/folder-resolver.spec.ts +152 -0
- package/src/commands/_shared/folder-resolver.ts +113 -0
- package/src/commands/_shared/parse.spec.ts +69 -0
- package/src/commands/_shared/parse.ts +43 -0
- package/src/commands/catalogs.ts +277 -0
- package/src/commands/comments.ts +160 -0
- package/src/commands/data.ts +137 -0
- package/src/commands/labels.ts +93 -0
- package/src/commands/metadata.ts +139 -0
- package/src/commands/tasks.spec.ts +1557 -2
- package/src/commands/tasks.ts +191 -280
- package/src/tool.ts +10 -0
- package/src/utils/sdk-client.ts +5 -0
- package/tests/assignable-users.e2e.test.ts +58 -4
- package/tests/catalogs.e2e.test.ts +393 -0
- package/tests/comments.e2e.test.ts +223 -0
- package/tests/complete.e2e.test.ts +9 -9
- package/tests/data.e2e.test.ts +187 -0
- package/tests/get.e2e.test.ts +4 -2
- package/tests/labels.e2e.test.ts +184 -0
- package/tests/list.e2e.test.ts +110 -0
- package/tests/metadata.e2e.test.ts +186 -0
package/src/commands/tasks.ts
CHANGED
|
@@ -9,11 +9,17 @@ import {
|
|
|
9
9
|
RESULTS,
|
|
10
10
|
} from "@uipath/common";
|
|
11
11
|
import type { TaskCompletionOptions } from "@uipath/uipath-typescript";
|
|
12
|
-
import type
|
|
12
|
+
import { type Command, Option } from "commander";
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
import { connectTasksClient } from "./_shared/connect";
|
|
15
|
+
import { DEFAULT_PAGE_SIZE } from "./_shared/constants";
|
|
16
|
+
import {
|
|
17
|
+
addFolderScopeOptions,
|
|
18
|
+
type FolderScopeOptions,
|
|
19
|
+
resolveFolderId,
|
|
20
|
+
resolveFolderScope,
|
|
21
|
+
} from "./_shared/folder-picker";
|
|
22
|
+
import { parseIntArg } from "./_shared/parse";
|
|
17
23
|
|
|
18
24
|
const VALID_TASK_TYPES = [
|
|
19
25
|
"FormTask",
|
|
@@ -26,17 +32,13 @@ const VALID_TASK_TYPES = [
|
|
|
26
32
|
] as const;
|
|
27
33
|
type ValidTaskType = (typeof VALID_TASK_TYPES)[number];
|
|
28
34
|
|
|
29
|
-
interface ListOptions {
|
|
30
|
-
tenant?: string;
|
|
31
|
-
folderId?: string;
|
|
35
|
+
interface ListOptions extends FolderScopeOptions {
|
|
32
36
|
asAdmin?: boolean;
|
|
33
37
|
limit?: string;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
interface GetOptions {
|
|
37
|
-
tenant?: string;
|
|
40
|
+
interface GetOptions extends FolderScopeOptions {
|
|
38
41
|
taskType?: string;
|
|
39
|
-
folderId?: string;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
interface AssignOptions {
|
|
@@ -45,15 +47,13 @@ interface AssignOptions {
|
|
|
45
47
|
user?: string;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
interface CompleteOptions {
|
|
49
|
-
tenant?: string;
|
|
50
|
+
interface CompleteOptions extends FolderScopeOptions {
|
|
50
51
|
type: string;
|
|
51
52
|
data?: string;
|
|
52
53
|
action?: string;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
interface UsersOptions {
|
|
56
|
-
tenant?: string;
|
|
56
|
+
interface UsersOptions extends FolderScopeOptions {
|
|
57
57
|
limit?: string;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -100,58 +100,56 @@ const TASKS_USERS_EXAMPLES: CommandExample[] = [
|
|
|
100
100
|
],
|
|
101
101
|
},
|
|
102
102
|
},
|
|
103
|
+
{
|
|
104
|
+
Description:
|
|
105
|
+
"List users by folder path instead of the numeric folder ID",
|
|
106
|
+
Command: 'uip tasks users --folder-path "Shared/Finance"',
|
|
107
|
+
Output: {
|
|
108
|
+
Code: "TaskUserList",
|
|
109
|
+
Data: [
|
|
110
|
+
{
|
|
111
|
+
id: 1,
|
|
112
|
+
name: "Alice",
|
|
113
|
+
surname: "Smith",
|
|
114
|
+
userName: "alice",
|
|
115
|
+
emailAddress: "alice@company.com",
|
|
116
|
+
displayName: "Alice Smith",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
103
121
|
];
|
|
104
122
|
|
|
105
123
|
export const registerTasksCommand = (program: Command) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
addFolderScopeOptions(
|
|
125
|
+
program
|
|
126
|
+
.command("list")
|
|
127
|
+
.description("List tasks across folders")
|
|
128
|
+
.addOption(
|
|
129
|
+
createHiddenDeprecatedTenantOption(
|
|
130
|
+
"-t, --tenant <tenant-name>",
|
|
131
|
+
),
|
|
132
|
+
),
|
|
133
|
+
"Filter by folder ID",
|
|
134
|
+
)
|
|
113
135
|
.option("--as-admin", "List tasks as admin")
|
|
114
136
|
.option(
|
|
115
137
|
"-l, --limit <number>",
|
|
116
138
|
"Maximum number of items to return (fetches all if omitted)",
|
|
117
139
|
)
|
|
118
140
|
.trackedAction(processContext, async (options: ListOptions) => {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
if (clientError) {
|
|
124
|
-
OutputFormatter.error({
|
|
125
|
-
Result: RESULTS.Failure,
|
|
126
|
-
Message: "Error connecting to Action Center",
|
|
127
|
-
Instructions: await extractErrorMessage(clientError),
|
|
128
|
-
});
|
|
129
|
-
processContext.exit(1);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
141
|
+
const sdk = await connectTasksClient(options.tenant);
|
|
142
|
+
if (!sdk) return;
|
|
132
143
|
|
|
133
144
|
let limit: number | undefined;
|
|
134
145
|
if (options.limit) {
|
|
135
|
-
const parsed =
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
limit = parsed.value;
|
|
146
|
+
const parsed = parseIntArg(options.limit, "--limit");
|
|
147
|
+
if (parsed === null) return;
|
|
148
|
+
limit = parsed;
|
|
141
149
|
}
|
|
142
150
|
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
const parsed = parsePositiveInt(
|
|
146
|
-
options.folderId,
|
|
147
|
-
"--folder-id",
|
|
148
|
-
);
|
|
149
|
-
if (!parsed.valid) {
|
|
150
|
-
reportInvalidInt(parsed);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
folderId = parsed.value;
|
|
154
|
-
}
|
|
151
|
+
const folderId = await resolveFolderScope(options);
|
|
152
|
+
if (folderId === null) return;
|
|
155
153
|
|
|
156
154
|
const allItems: unknown[] = [];
|
|
157
155
|
let cursor: { value: string } | undefined;
|
|
@@ -211,96 +209,72 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
211
209
|
});
|
|
212
210
|
});
|
|
213
211
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (options.taskType && !options.folderId) {
|
|
255
|
-
OutputFormatter.error({
|
|
256
|
-
Result: RESULTS.Failure,
|
|
257
|
-
Message:
|
|
258
|
-
"--folder-id is required when --task-type is specified",
|
|
259
|
-
Instructions:
|
|
260
|
-
"Provide a folder ID with --folder-id <id>.",
|
|
261
|
-
});
|
|
262
|
-
processContext.exit(1);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
212
|
+
addFolderScopeOptions(
|
|
213
|
+
program
|
|
214
|
+
.command("get")
|
|
215
|
+
.description(
|
|
216
|
+
"Get details of a task by ID. Use 'tasks list' to find task IDs.",
|
|
217
|
+
)
|
|
218
|
+
.argument("<id>", "Task ID")
|
|
219
|
+
.addOption(
|
|
220
|
+
createHiddenDeprecatedTenantOption(
|
|
221
|
+
"-t, --tenant <tenant-name>",
|
|
222
|
+
),
|
|
223
|
+
)
|
|
224
|
+
.option(
|
|
225
|
+
"--task-type <type>",
|
|
226
|
+
"Task type (FormTask, ExternalTask, AppTask, DocumentValidationTask, DocumentClassificationTask, DataLabelingTask, QuickFormTask)",
|
|
227
|
+
),
|
|
228
|
+
"Folder ID (a folder is required when task-type is specified)",
|
|
229
|
+
).trackedAction(processContext, async (id: string, options: GetOptions) => {
|
|
230
|
+
const sdk = await connectTasksClient(options.tenant);
|
|
231
|
+
if (!sdk) return;
|
|
232
|
+
|
|
233
|
+
const parsedId = parseIntArg(id, "<id>");
|
|
234
|
+
if (parsedId === null) return;
|
|
235
|
+
|
|
236
|
+
const hasFolderScope =
|
|
237
|
+
options.folderId !== undefined ||
|
|
238
|
+
options.folderPath !== undefined ||
|
|
239
|
+
options.folderKey !== undefined;
|
|
240
|
+
if (options.taskType && !hasFolderScope) {
|
|
241
|
+
OutputFormatter.error({
|
|
242
|
+
Result: RESULTS.Failure,
|
|
243
|
+
Message: "A folder is required when --task-type is specified",
|
|
244
|
+
Instructions:
|
|
245
|
+
"Pass --folder-id <id>, --folder-path <path>, or --folder-key <key>.",
|
|
246
|
+
});
|
|
247
|
+
processContext.exit(1);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
265
250
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const parsed = parsePositiveInt(
|
|
273
|
-
options.folderId,
|
|
274
|
-
"--folder-id",
|
|
275
|
-
);
|
|
276
|
-
if (!parsed.valid) {
|
|
277
|
-
reportInvalidInt(parsed);
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
folderId = parsed.value;
|
|
281
|
-
}
|
|
251
|
+
const getOptions: Record<string, unknown> = {};
|
|
252
|
+
if (options.taskType) {
|
|
253
|
+
getOptions.taskType = options.taskType;
|
|
254
|
+
}
|
|
255
|
+
const folderId = await resolveFolderScope(options);
|
|
256
|
+
if (folderId === null) return;
|
|
282
257
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
258
|
+
const [getError, task] = await catchError(
|
|
259
|
+
sdk.tasks.getById(parsedId, getOptions, folderId),
|
|
260
|
+
);
|
|
286
261
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
262
|
+
if (getError) {
|
|
263
|
+
OutputFormatter.error({
|
|
264
|
+
Result: RESULTS.Failure,
|
|
265
|
+
Message: `Error getting task '${id}'`,
|
|
266
|
+
Instructions: await extractErrorMessage(getError),
|
|
267
|
+
});
|
|
268
|
+
processContext.exit(1);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
296
271
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
);
|
|
272
|
+
OutputFormatter.success({
|
|
273
|
+
Result: RESULTS.Success,
|
|
274
|
+
Code: "TaskDetails",
|
|
275
|
+
Data: task,
|
|
276
|
+
});
|
|
277
|
+
});
|
|
304
278
|
|
|
305
279
|
program
|
|
306
280
|
.command("assign")
|
|
@@ -350,28 +324,14 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
350
324
|
.trackedAction(
|
|
351
325
|
processContext,
|
|
352
326
|
async (taskId: string, options: { tenant?: string }) => {
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
);
|
|
327
|
+
const sdk = await connectTasksClient(options.tenant);
|
|
328
|
+
if (!sdk) return;
|
|
356
329
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
Result: RESULTS.Failure,
|
|
360
|
-
Message: "Error connecting to Action Center",
|
|
361
|
-
Instructions: await extractErrorMessage(clientError),
|
|
362
|
-
});
|
|
363
|
-
processContext.exit(1);
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
const parsedId = parsePositiveInt(taskId, "<task-id>");
|
|
368
|
-
if (!parsedId.valid) {
|
|
369
|
-
reportInvalidInt(parsedId);
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
330
|
+
const parsedId = parseIntArg(taskId, "<task-id>");
|
|
331
|
+
if (parsedId === null) return;
|
|
372
332
|
|
|
373
333
|
const [unassignError, result] = await catchError(
|
|
374
|
-
sdk.tasks.unassign(parsedId
|
|
334
|
+
sdk.tasks.unassign(parsedId),
|
|
375
335
|
);
|
|
376
336
|
|
|
377
337
|
if (unassignError) {
|
|
@@ -392,18 +352,21 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
392
352
|
},
|
|
393
353
|
);
|
|
394
354
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
355
|
+
addFolderScopeOptions(
|
|
356
|
+
program
|
|
357
|
+
.command("complete")
|
|
358
|
+
.description("Complete a task with an action and optional data")
|
|
359
|
+
.argument("<task-id>", "Task ID")
|
|
360
|
+
.requiredOption(
|
|
361
|
+
"--type <type>",
|
|
362
|
+
"Task type (FormTask, ExternalTask, AppTask, DocumentValidationTask, DocumentClassificationTask, DataLabelingTask, QuickFormTask)",
|
|
363
|
+
)
|
|
364
|
+
.addOption(
|
|
365
|
+
createHiddenDeprecatedTenantOption(
|
|
366
|
+
"-t, --tenant <tenant-name>",
|
|
367
|
+
),
|
|
368
|
+
),
|
|
369
|
+
)
|
|
407
370
|
.option("--data <json>", "Task data as JSON string")
|
|
408
371
|
.option(
|
|
409
372
|
"--action <action>",
|
|
@@ -411,38 +374,12 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
411
374
|
)
|
|
412
375
|
.trackedAction(
|
|
413
376
|
processContext,
|
|
414
|
-
async (
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
) => {
|
|
418
|
-
const [clientError, sdk] = await catchError(
|
|
419
|
-
createTasksClient(options.tenant),
|
|
420
|
-
);
|
|
377
|
+
async (taskId: string, options: CompleteOptions) => {
|
|
378
|
+
const sdk = await connectTasksClient(options.tenant);
|
|
379
|
+
if (!sdk) return;
|
|
421
380
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
Result: RESULTS.Failure,
|
|
425
|
-
Message: "Error connecting to Action Center",
|
|
426
|
-
Instructions: await extractErrorMessage(clientError),
|
|
427
|
-
});
|
|
428
|
-
processContext.exit(1);
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const parsedTaskId = parsePositiveInt(taskId, "<task-id>");
|
|
433
|
-
if (!parsedTaskId.valid) {
|
|
434
|
-
reportInvalidInt(parsedTaskId);
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
const parsedFolderId = parsePositiveInt(
|
|
439
|
-
options.folderId,
|
|
440
|
-
"--folder-id",
|
|
441
|
-
);
|
|
442
|
-
if (!parsedFolderId.valid) {
|
|
443
|
-
reportInvalidInt(parsedFolderId);
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
381
|
+
const parsedTaskId = parseIntArg(taskId, "<task-id>");
|
|
382
|
+
if (parsedTaskId === null) return;
|
|
446
383
|
|
|
447
384
|
if (!VALID_TASK_TYPES.includes(options.type as ValidTaskType)) {
|
|
448
385
|
OutputFormatter.error({
|
|
@@ -454,8 +391,11 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
454
391
|
return;
|
|
455
392
|
}
|
|
456
393
|
|
|
394
|
+
const folderId = await resolveFolderId(options);
|
|
395
|
+
if (folderId === null) return;
|
|
396
|
+
|
|
457
397
|
const completionOptions: Record<string, unknown> = {
|
|
458
|
-
taskId: parsedTaskId
|
|
398
|
+
taskId: parsedTaskId,
|
|
459
399
|
type: options.type,
|
|
460
400
|
};
|
|
461
401
|
|
|
@@ -485,7 +425,7 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
485
425
|
const [completeError, result] = await catchError(
|
|
486
426
|
sdk.tasks.complete(
|
|
487
427
|
completionOptions as unknown as TaskCompletionOptions,
|
|
488
|
-
|
|
428
|
+
folderId,
|
|
489
429
|
),
|
|
490
430
|
);
|
|
491
431
|
|
|
@@ -512,10 +452,25 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
512
452
|
.description(
|
|
513
453
|
"List users with task permissions in a folder. Use the user ID with 'tasks assign'.",
|
|
514
454
|
)
|
|
515
|
-
.argument(
|
|
455
|
+
.argument(
|
|
456
|
+
"[folder-id]",
|
|
457
|
+
"Folder ID (alternatively pass --folder-path or --folder-key)",
|
|
458
|
+
)
|
|
516
459
|
.addOption(
|
|
517
460
|
createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>"),
|
|
518
461
|
)
|
|
462
|
+
.addOption(
|
|
463
|
+
new Option(
|
|
464
|
+
"--folder-path <path>",
|
|
465
|
+
"Folder path (alternative to the folder-id argument)",
|
|
466
|
+
).conflicts("folderKey"),
|
|
467
|
+
)
|
|
468
|
+
.addOption(
|
|
469
|
+
new Option(
|
|
470
|
+
"--folder-key <key>",
|
|
471
|
+
"Folder key (alternative to the folder-id argument)",
|
|
472
|
+
),
|
|
473
|
+
)
|
|
519
474
|
.option(
|
|
520
475
|
"-l, --limit <number>",
|
|
521
476
|
"Maximum number of items to return (fetches all if omitted)",
|
|
@@ -523,38 +478,40 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
523
478
|
.examples(TASKS_USERS_EXAMPLES)
|
|
524
479
|
.trackedAction(
|
|
525
480
|
processContext,
|
|
526
|
-
async (folderId: string, options: UsersOptions) => {
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
481
|
+
async (folderId: string | undefined, options: UsersOptions) => {
|
|
482
|
+
const sdk = await connectTasksClient(options.tenant);
|
|
483
|
+
if (!sdk) return;
|
|
484
|
+
|
|
485
|
+
if (
|
|
486
|
+
folderId !== undefined &&
|
|
487
|
+
(options.folderPath !== undefined ||
|
|
488
|
+
options.folderKey !== undefined)
|
|
489
|
+
) {
|
|
532
490
|
OutputFormatter.error({
|
|
533
491
|
Result: RESULTS.Failure,
|
|
534
|
-
Message:
|
|
535
|
-
|
|
492
|
+
Message:
|
|
493
|
+
"The folder-id argument cannot be used with --folder-path or --folder-key",
|
|
494
|
+
Instructions:
|
|
495
|
+
"Pass the folder as a numeric argument, or as --folder-path/--folder-key, not both.",
|
|
536
496
|
});
|
|
537
497
|
processContext.exit(1);
|
|
538
498
|
return;
|
|
539
499
|
}
|
|
540
500
|
|
|
541
|
-
const parsedFolderId =
|
|
542
|
-
folderId
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
501
|
+
const parsedFolderId =
|
|
502
|
+
folderId !== undefined
|
|
503
|
+
? parseIntArg(folderId, "<folder-id>")
|
|
504
|
+
: await resolveFolderId(
|
|
505
|
+
options,
|
|
506
|
+
"Pass the folder-id argument, --folder-path <path>, or --folder-key <key> (run 'uip or folders list' to find one).",
|
|
507
|
+
);
|
|
508
|
+
if (parsedFolderId === null) return;
|
|
549
509
|
|
|
550
510
|
let limit: number | undefined;
|
|
551
511
|
if (options.limit) {
|
|
552
|
-
const parsed =
|
|
553
|
-
if (
|
|
554
|
-
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
limit = parsed.value;
|
|
512
|
+
const parsed = parseIntArg(options.limit, "--limit");
|
|
513
|
+
if (parsed === null) return;
|
|
514
|
+
limit = parsed;
|
|
558
515
|
}
|
|
559
516
|
|
|
560
517
|
const allItems: unknown[] = [];
|
|
@@ -569,7 +526,7 @@ export const registerTasksCommand = (program: Command) => {
|
|
|
569
526
|
}
|
|
570
527
|
|
|
571
528
|
const [usersError, result] = await catchError(
|
|
572
|
-
sdk.tasks.getUsers(parsedFolderId
|
|
529
|
+
sdk.tasks.getUsers(parsedFolderId, getOptions),
|
|
573
530
|
);
|
|
574
531
|
|
|
575
532
|
if (usersError) {
|
|
@@ -629,36 +586,19 @@ async function assignOrReassign(
|
|
|
629
586
|
return;
|
|
630
587
|
}
|
|
631
588
|
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
);
|
|
589
|
+
const sdk = await connectTasksClient(options.tenant);
|
|
590
|
+
if (!sdk) return;
|
|
635
591
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
Result: RESULTS.Failure,
|
|
639
|
-
Message: "Error connecting to Action Center",
|
|
640
|
-
Instructions: await extractErrorMessage(clientError),
|
|
641
|
-
});
|
|
642
|
-
processContext.exit(1);
|
|
643
|
-
return;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
const parsedTaskId = parsePositiveInt(taskId, "<task-id>");
|
|
647
|
-
if (!parsedTaskId.valid) {
|
|
648
|
-
reportInvalidInt(parsedTaskId);
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
592
|
+
const parsedTaskId = parseIntArg(taskId, "<task-id>");
|
|
593
|
+
if (parsedTaskId === null) return;
|
|
651
594
|
|
|
652
595
|
const assignment: Record<string, unknown> = {
|
|
653
|
-
taskId: parsedTaskId
|
|
596
|
+
taskId: parsedTaskId,
|
|
654
597
|
};
|
|
655
598
|
if (options.userId) {
|
|
656
|
-
const parsedUserId =
|
|
657
|
-
if (
|
|
658
|
-
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
assignment.userId = parsedUserId.value;
|
|
599
|
+
const parsedUserId = parseIntArg(options.userId, "--user-id");
|
|
600
|
+
if (parsedUserId === null) return;
|
|
601
|
+
assignment.userId = parsedUserId;
|
|
662
602
|
} else {
|
|
663
603
|
assignment.userNameOrEmail = options.user;
|
|
664
604
|
}
|
|
@@ -689,32 +629,3 @@ async function assignOrReassign(
|
|
|
689
629
|
Data: result,
|
|
690
630
|
});
|
|
691
631
|
}
|
|
692
|
-
|
|
693
|
-
function parsePositiveInt(
|
|
694
|
-
value: string,
|
|
695
|
-
label: string,
|
|
696
|
-
):
|
|
697
|
-
| { valid: true; value: number }
|
|
698
|
-
| { valid: false; message: string; instructions: string } {
|
|
699
|
-
const parsed = Number(value);
|
|
700
|
-
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
701
|
-
return {
|
|
702
|
-
valid: false,
|
|
703
|
-
message: `Invalid ${label}: ${value}`,
|
|
704
|
-
instructions: "Must be a positive integer.",
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
return { valid: true, value: parsed };
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
function reportInvalidInt(error: {
|
|
711
|
-
message: string;
|
|
712
|
-
instructions: string;
|
|
713
|
-
}): void {
|
|
714
|
-
OutputFormatter.error({
|
|
715
|
-
Result: RESULTS.Failure,
|
|
716
|
-
Message: error.message,
|
|
717
|
-
Instructions: error.instructions,
|
|
718
|
-
});
|
|
719
|
-
processContext.exit(1);
|
|
720
|
-
}
|
package/src/tool.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import pkg from "../package.json" with { type: "json" };
|
|
3
|
+
import { registerCatalogsCommand } from "./commands/catalogs";
|
|
4
|
+
import { registerCommentsCommand } from "./commands/comments";
|
|
5
|
+
import { registerDataCommand } from "./commands/data";
|
|
6
|
+
import { registerLabelsCommand } from "./commands/labels";
|
|
7
|
+
import { registerMetadataCommand } from "./commands/metadata";
|
|
3
8
|
import { registerTasksCommand } from "./commands/tasks";
|
|
4
9
|
|
|
5
10
|
export const metadata = {
|
|
@@ -11,4 +16,9 @@ export const metadata = {
|
|
|
11
16
|
|
|
12
17
|
export const registerCommands = async (program: Command): Promise<void> => {
|
|
13
18
|
registerTasksCommand(program);
|
|
19
|
+
registerCatalogsCommand(program);
|
|
20
|
+
registerCommentsCommand(program);
|
|
21
|
+
registerLabelsCommand(program);
|
|
22
|
+
registerMetadataCommand(program);
|
|
23
|
+
registerDataCommand(program);
|
|
14
24
|
};
|
package/src/utils/sdk-client.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getLoginStatusAsync } from "@uipath/auth";
|
|
2
2
|
import { UiPath } from "@uipath/uipath-typescript";
|
|
3
|
+
import { TaskCatalogs } from "@uipath/uipath-typescript/tasks";
|
|
3
4
|
|
|
4
5
|
export const createTasksClient = async (
|
|
5
6
|
tenantOverride?: string,
|
|
@@ -23,3 +24,7 @@ export const createTasksClient = async (
|
|
|
23
24
|
tenantName: tenantOverride ?? status.tenantName,
|
|
24
25
|
});
|
|
25
26
|
};
|
|
27
|
+
|
|
28
|
+
// Task catalogs live on their own service in the SDK, not on `sdk.tasks`.
|
|
29
|
+
export const createTaskCatalogsClient = (sdk: UiPath): TaskCatalogs =>
|
|
30
|
+
new TaskCatalogs(sdk);
|