Skip to content

Commit fce3a30

Browse files
committed
feat: add 'all' option to list process and user tasks to include completed instances
1 parent 4b8cdbe commit fce3a30

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/commands/process-instances.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export async function listProcessInstances(options: {
1313
profile?: string;
1414
processDefinitionId?: string;
1515
state?: string;
16+
all?: boolean;
1617
}): Promise<void> {
1718
const logger = getLogger();
1819
const client = createClient(options.profile);
@@ -31,6 +32,9 @@ export async function listProcessInstances(options: {
3132

3233
if (options.state) {
3334
filter.filter.state = options.state;
35+
} else if (!options.all) {
36+
// By default, exclude COMPLETED instances unless --all is specified
37+
filter.filter.state = 'ACTIVE';
3438
}
3539

3640
const result = await client.searchProcessInstances(filter, { consistency: { waitUpToMs: 0 } });

src/commands/user-tasks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export async function listUserTasks(options: {
1313
profile?: string;
1414
state?: string;
1515
assignee?: string;
16+
all?: boolean;
1617
}): Promise<void> {
1718
const logger = getLogger();
1819
const client = createClient(options.profile);
@@ -27,6 +28,9 @@ export async function listUserTasks(options: {
2728

2829
if (options.state) {
2930
filter.filter.state = options.state;
31+
} else if (!options.all) {
32+
// By default, exclude COMPLETED tasks unless --all is specified
33+
filter.filter.state = 'CREATED';
3034
}
3135

3236
if (options.assignee) {

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function parseCliArgs() {
5858
options: {
5959
help: { type: 'boolean', short: 'h' },
6060
version: { type: 'boolean', short: 'v' },
61+
all: { type: 'boolean' },
6162
profile: { type: 'string' },
6263
bpmnProcessId: { type: 'string' },
6364
processInstanceKey: { type: 'string' },
@@ -235,6 +236,7 @@ async function main() {
235236
profile: values.profile as string | undefined,
236237
bpmnProcessId: values.bpmnProcessId as string | undefined,
237238
state: values.state as string | undefined,
239+
all: values.all as boolean | undefined,
238240
});
239241
return;
240242
}
@@ -277,6 +279,7 @@ async function main() {
277279
profile: values.profile as string | undefined,
278280
state: values.state as string | undefined,
279281
assignee: values.assignee as string | undefined,
282+
all: values.all as boolean | undefined,
280283
});
281284
return;
282285
}

0 commit comments

Comments
 (0)