Skip to content

Commit 339bb7e

Browse files
committed
Merge remote-tracking branch 'origin/main' into copilot/implement-search-functionality
2 parents 8b923b6 + 38e0e26 commit 339bb7e

File tree

9 files changed

+101
-6
lines changed

9 files changed

+101
-6
lines changed

EXAMPLES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ c8 list pi --state=ACTIVE
4141
```bash
4242
c8 get pi 2251799813685249
4343
c8 get process-instance 2251799813685249
44+
45+
# Get process instance with variables
46+
c8 get pi 2251799813685249 --variables
4447
```
4548

4649
### Create Process Instance
@@ -139,6 +142,13 @@ c8 list inc --state=ACTIVE
139142
c8 list inc --processInstanceKey=2251799813685249
140143
```
141144

145+
### Get Incident by Key
146+
147+
```bash
148+
c8 get inc 2251799813685251
149+
c8 get incident 2251799813685251
150+
```
151+
142152
### Resolve Incident
143153

144154
```bash

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ c8ctl --version
8787
c8ctl list pi # List process instances
8888
c8ctl list pd # List process definitions
8989
c8ctl get pi 123456 # Get process instance by key
90+
c8ctl get pi 123456 --variables # Get process instance with variables
9091
c8ctl get pd 123456 --xml # Get process definition as XML
9192

9293
# Create process instance

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/completion.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _c8ctl_completions() {
2525
# Resources by verb
2626
local list_resources="process-instances process-instance pi user-tasks user-task ut incidents incident inc jobs profiles profile plugins plugin"
2727
local search_resources="process-instances process-instance pi process-definitions process-definition pd user-tasks user-task ut incidents incident inc jobs variables variable"
28-
local get_resources="process-instance pi process-definition pd topology"
28+
local get_resources="process-instance pi process-definition pd incident inc topology"
2929
local create_resources="process-instance pi"
3030
local cancel_resources="process-instance pi"
3131
local await_resources="process-instance pi"
@@ -272,6 +272,8 @@ _c8ctl() {
272272
'pi:Get process instance'
273273
'process-definition:Get process definition'
274274
'pd:Get process definition'
275+
'incident:Get incident'
276+
'inc:Get incident'
275277
'topology:Get cluster topology'
276278
)
277279
_describe 'resource' resources
@@ -624,6 +626,10 @@ complete -c c8ctl -n '__fish_seen_subcommand_from get' -a 'process-definition' -
624626
complete -c c8 -n '__fish_seen_subcommand_from get' -a 'process-definition' -d 'Get process definition'
625627
complete -c c8ctl -n '__fish_seen_subcommand_from get' -a 'pd' -d 'Get process definition'
626628
complete -c c8 -n '__fish_seen_subcommand_from get' -a 'pd' -d 'Get process definition'
629+
complete -c c8ctl -n '__fish_seen_subcommand_from get' -a 'incident' -d 'Get incident'
630+
complete -c c8 -n '__fish_seen_subcommand_from get' -a 'incident' -d 'Get incident'
631+
complete -c c8ctl -n '__fish_seen_subcommand_from get' -a 'inc' -d 'Get incident'
632+
complete -c c8 -n '__fish_seen_subcommand_from get' -a 'inc' -d 'Get incident'
627633
complete -c c8ctl -n '__fish_seen_subcommand_from get' -a 'topology' -d 'Get cluster topology'
628634
complete -c c8 -n '__fish_seen_subcommand_from get' -a 'topology' -d 'Get cluster topology'
629635

src/commands/help.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Usage: c8ctl <command> [resource] [options]
5252
Commands:
5353
list <resource> List resources (pi, pd, ut, inc, jobs, profiles)
5454
search <resource> Search resources with filters (pi, pd, ut, inc, jobs, variables)
55-
get <resource> <key> Get resource by key (pi, pd, topology)
55+
get <resource> <key> Get resource by key (pi, pd, inc, topology)
5656
create <resource> Create resource (pi)
5757
cancel <resource> <key> Cancel resource (pi)
5858
await <resource> Create and await completion (pi, alias for create --awaitCompletion)
@@ -80,6 +80,7 @@ Flags:
8080
--profile <name> Use specific profile for this command
8181
--from <url> Load plugin from URL (use with 'load plugin')
8282
--xml Get process definition as XML (use with 'get pd')
83+
--variables Get process instance with variables (use with 'get pi')
8384
--id <process-id> Process definition ID (alias for --bpmnProcessId)
8485
--awaitCompletion Wait for process instance to complete (use with 'create pi')
8586
--fetchVariables <v> Reserved for future use (all variables returned by default)
@@ -121,6 +122,7 @@ Examples:
121122
c8ctl search variables --value=foo Search for variables by value
122123
c8ctl search variables --processInstanceKey=123 --fullValue Search variables with full values
123124
c8ctl get pi 123456 Get process instance by key
125+
c8ctl get pi 123456 --variables Get process instance with variables
124126
c8ctl get pd 123456 Get process definition by key
125127
c8ctl get pd 123456 --xml Get process definition XML
126128
c8ctl create pi --id=myProcess
@@ -152,7 +154,7 @@ export function showVerbResources(verb: string): void {
152154
const resources: Record<string, string> = {
153155
list: 'process-instances (pi), process-definitions (pd), user-tasks (ut), incidents (inc), jobs, profiles, plugins',
154156
search: 'process-instances (pi), process-definitions (pd), user-tasks (ut), incidents (inc), jobs, variables',
155-
get: 'process-instance (pi), process-definition (pd), topology',
157+
get: 'process-instance (pi), process-definition (pd), incident (inc), topology',
156158
create: 'process-instance (pi)',
157159
complete: 'user-task (ut), job',
158160
cancel: 'process-instance (pi)',
@@ -248,19 +250,25 @@ Usage: c8ctl get <resource> <key> [flags]
248250
Resources and their available flags:
249251
250252
process-instance (pi) <key>
253+
--variables Include variables for the process instance
251254
--profile <name> Use specific profile
252255
253256
process-definition (pd) <key>
254257
--xml Return process definition as XML
255258
--profile <name> Use specific profile
256259
260+
incident (inc) <key>
261+
--profile <name> Use specific profile
262+
257263
topology
258264
--profile <name> Use specific profile
259265
260266
Examples:
261267
c8ctl get pi 2251799813685249
268+
c8ctl get pi 2251799813685249 --variables
262269
c8ctl get pd 2251799813685250
263270
c8ctl get pd 2251799813685250 --xml
271+
c8ctl get inc 2251799813685251
264272
c8ctl get topology
265273
`.trim());
266274
}

src/commands/incidents.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ export async function listIncidents(options: {
5454
}
5555
}
5656

57+
/**
58+
* Get incident by key
59+
*/
60+
export async function getIncident(key: string, options: {
61+
profile?: string;
62+
}): Promise<void> {
63+
const logger = getLogger();
64+
const client = createClient(options.profile);
65+
66+
try {
67+
const result = await client.getIncident({ incidentKey: key as any }, { consistency: { waitUpToMs: 0 } });
68+
logger.json(result);
69+
} catch (error) {
70+
logger.error(`Failed to get incident ${key}`, error as Error);
71+
process.exit(1);
72+
}
73+
}
74+
5775
/**
5876
* Resolve incident
5977
*/

src/commands/process-instances.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,41 @@ export async function listProcessInstances(options: {
6565
*/
6666
export async function getProcessInstance(key: string, options: {
6767
profile?: string;
68+
variables?: boolean;
6869
}): Promise<void> {
6970
const logger = getLogger();
7071
const client = createClient(options.profile);
72+
const consistencyOptions = { consistency: { waitUpToMs: 0 } };
7173

7274
try {
73-
const result = await client.getProcessInstance({ processInstanceKey: key as any }, { consistency: { waitUpToMs: 0 } });
74-
logger.json(result);
75+
const result = await client.getProcessInstance({ processInstanceKey: key as any }, consistencyOptions);
76+
77+
// Fetch variables if requested
78+
if (options.variables) {
79+
try {
80+
const variablesResult = await client.searchVariables(
81+
{
82+
filter: {
83+
processInstanceKey: key as any,
84+
},
85+
truncateValues: false, // Get full variable values
86+
},
87+
consistencyOptions
88+
);
89+
90+
// Add variables to the result
91+
const resultWithVariables = {
92+
...result,
93+
variables: variablesResult.items || [],
94+
};
95+
logger.json(resultWithVariables);
96+
} catch (varError) {
97+
logger.error(`Failed to fetch variables for process instance ${key}. The process instance was found, but variables could not be retrieved.`, varError as Error);
98+
process.exit(1);
99+
}
100+
} else {
101+
logger.json(result);
102+
}
75103
} catch (error) {
76104
logger.error(`Failed to get process instance ${key}`, error as Error);
77105
process.exit(1);

src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
searchVariables,
3131
} from './commands/search.ts';
3232
import { listUserTasks, completeUserTask } from './commands/user-tasks.ts';
33-
import { listIncidents, resolveIncident } from './commands/incidents.ts';
33+
import { listIncidents, getIncident, resolveIncident } from './commands/incidents.ts';
3434
import { listJobs, activateJobs, completeJob, failJob } from './commands/jobs.ts';
3535
import { publishMessage, correlateMessage } from './commands/messages.ts';
3636
import { getTopology } from './commands/topology.ts';
@@ -298,8 +298,11 @@ async function main() {
298298
logger.error('Process instance key required. Usage: c8 get pi <key>');
299299
process.exit(1);
300300
}
301+
// Check if --variables flag is present (for get command, it's a boolean flag)
302+
const includeVariables = process.argv.includes('--variables');
301303
await getProcessInstance(args[0], {
302304
profile: values.profile as string | undefined,
305+
variables: includeVariables,
303306
});
304307
return;
305308
}
@@ -395,6 +398,17 @@ async function main() {
395398
return;
396399
}
397400

401+
if (verb === 'get' && normalizedResource === 'incident') {
402+
if (!args[0]) {
403+
logger.error('Incident key required. Usage: c8 get inc <key>');
404+
process.exit(1);
405+
}
406+
await getIncident(args[0], {
407+
profile: values.profile as string | undefined,
408+
});
409+
return;
410+
}
411+
398412
if (verb === 'resolve' && normalizedResource === 'incident') {
399413
if (!args[0]) {
400414
logger.error('Incident key required. Usage: c8 resolve inc <key>');

tests/unit/help.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describe('Help Module', () => {
6666

6767
// Check for flags
6868
assert.ok(output.includes('--profile'));
69+
assert.ok(output.includes('--variables'));
6970
assert.ok(output.includes('--awaitCompletion'));
7071
assert.ok(output.includes('--fetchVariables'));
7172
assert.ok(output.includes('--version'));
@@ -91,6 +92,7 @@ describe('Help Module', () => {
9192
const output = consoleLogSpy.join('\n');
9293
assert.ok(output.includes('c8ctl get'));
9394
assert.ok(output.includes('process-instance'));
95+
assert.ok(output.includes('incident'));
9496
assert.ok(output.includes('topology'));
9597
});
9698

@@ -201,8 +203,10 @@ describe('Help Module', () => {
201203
const output = consoleLogSpy.join('\n');
202204
assert.ok(output.includes('c8ctl get'));
203205
assert.ok(output.includes('process-instance (pi)'));
206+
assert.ok(output.includes('--variables'));
204207
assert.ok(output.includes('process-definition (pd)'));
205208
assert.ok(output.includes('--xml'));
209+
assert.ok(output.includes('incident (inc)'));
206210
assert.ok(output.includes('topology'));
207211
});
208212

0 commit comments

Comments
 (0)