@camunda8/cli 2.6.1 → 2.7.0-alpha.1

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.
@@ -0,0 +1,895 @@
1
+ /**
2
+ * Declarative command registry — single source of truth for all
3
+ * verb×resource combinations, their flags, constraints, and metadata.
4
+ *
5
+ * Consumers (help, completion, validation, dispatch) derive their
6
+ * data from this registry instead of maintaining separate copies.
7
+ */
8
+ // ─── Resource Aliases ────────────────────────────────────────────────────────
9
+ /**
10
+ * Maps short/plural resource names to their canonical singular form.
11
+ * Used by the dispatch layer to normalize user input before lookup.
12
+ */
13
+ export const RESOURCE_ALIASES = {
14
+ pi: "process-instance",
15
+ pd: "process-definition",
16
+ ut: "user-task",
17
+ inc: "incident",
18
+ msg: "message",
19
+ vars: "variable",
20
+ profile: "profile",
21
+ profiles: "profile",
22
+ plugin: "plugin",
23
+ plugins: "plugin",
24
+ auth: "authorization",
25
+ authorizations: "authorization",
26
+ mr: "mapping-rule",
27
+ "mapping-rules": "mapping-rule",
28
+ users: "user",
29
+ roles: "role",
30
+ groups: "group",
31
+ tenants: "tenant",
32
+ };
33
+ // ─── Global Flags ────────────────────────────────────────────────────────────
34
+ /**
35
+ * Flags accepted by every command (infrastructure/agent flags).
36
+ */
37
+ export const GLOBAL_FLAGS = {
38
+ help: { type: "boolean", description: "Show help", short: "h" },
39
+ version: {
40
+ type: "string",
41
+ description: "Show CLI version, or filter by process definition version on supported commands",
42
+ short: "v",
43
+ },
44
+ profile: { type: "string", description: "Use a specific profile" },
45
+ "dry-run": {
46
+ type: "boolean",
47
+ description: "Preview the API request without executing",
48
+ },
49
+ verbose: { type: "boolean", description: "Show verbose output" },
50
+ fields: {
51
+ type: "string",
52
+ description: "Comma-separated list of fields to display",
53
+ },
54
+ };
55
+ /**
56
+ * Flags shared across all search/list commands.
57
+ */
58
+ export const SEARCH_FLAGS = {
59
+ sortBy: { type: "string", description: "Sort results by field" },
60
+ asc: { type: "boolean", description: "Sort ascending" },
61
+ desc: { type: "boolean", description: "Sort descending" },
62
+ limit: { type: "string", description: "Maximum number of results" },
63
+ between: {
64
+ type: "string",
65
+ description: "Date range filter (e.g. 7d, 30d, 2024-01-01..2024-12-31)",
66
+ },
67
+ dateField: {
68
+ type: "string",
69
+ description: "Date field for --between filter",
70
+ },
71
+ };
72
+ // ─── Reusable flag sets ──────────────────────────────────────────────────────
73
+ const PI_SEARCH_FLAGS = {
74
+ bpmnProcessId: {
75
+ type: "string",
76
+ description: "Filter by BPMN process ID",
77
+ },
78
+ id: { type: "string", description: "Filter by BPMN process ID (alias)" },
79
+ processDefinitionId: {
80
+ type: "string",
81
+ description: "Filter by process definition ID",
82
+ },
83
+ processDefinitionKey: {
84
+ type: "string",
85
+ description: "Filter by process definition key",
86
+ },
87
+ state: { type: "string", description: "Filter by state" },
88
+ key: { type: "string", description: "Filter by key" },
89
+ parentProcessInstanceKey: {
90
+ type: "string",
91
+ description: "Filter by parent process instance key",
92
+ },
93
+ iid: {
94
+ type: "string",
95
+ description: "Case-insensitive filter by BPMN process ID",
96
+ },
97
+ };
98
+ const PD_SEARCH_FLAGS = {
99
+ bpmnProcessId: {
100
+ type: "string",
101
+ description: "Filter by BPMN process ID",
102
+ },
103
+ id: { type: "string", description: "Filter by BPMN process ID (alias)" },
104
+ processDefinitionId: {
105
+ type: "string",
106
+ description: "Filter by process definition ID",
107
+ },
108
+ name: { type: "string", description: "Filter by name" },
109
+ key: { type: "string", description: "Filter by key" },
110
+ iid: {
111
+ type: "string",
112
+ description: "Case-insensitive filter by BPMN process ID",
113
+ },
114
+ iname: { type: "string", description: "Case-insensitive filter by name" },
115
+ };
116
+ const UT_SEARCH_FLAGS = {
117
+ state: { type: "string", description: "Filter by state" },
118
+ assignee: { type: "string", description: "Filter by assignee" },
119
+ processInstanceKey: {
120
+ type: "string",
121
+ description: "Filter by process instance key",
122
+ },
123
+ processDefinitionKey: {
124
+ type: "string",
125
+ description: "Filter by process definition key",
126
+ },
127
+ elementId: { type: "string", description: "Filter by element ID" },
128
+ iassignee: {
129
+ type: "string",
130
+ description: "Case-insensitive filter by assignee",
131
+ },
132
+ };
133
+ const INC_SEARCH_FLAGS = {
134
+ state: { type: "string", description: "Filter by state" },
135
+ processInstanceKey: {
136
+ type: "string",
137
+ description: "Filter by process instance key",
138
+ },
139
+ processDefinitionKey: {
140
+ type: "string",
141
+ description: "Filter by process definition key",
142
+ },
143
+ bpmnProcessId: {
144
+ type: "string",
145
+ description: "Filter by BPMN process ID",
146
+ },
147
+ id: { type: "string", description: "Filter by BPMN process ID (alias)" },
148
+ processDefinitionId: {
149
+ type: "string",
150
+ description: "Filter by process definition ID",
151
+ },
152
+ errorType: { type: "string", description: "Filter by error type" },
153
+ errorMessage: {
154
+ type: "string",
155
+ description: "Filter by error message",
156
+ },
157
+ ierrorMessage: {
158
+ type: "string",
159
+ description: "Case-insensitive filter by error message",
160
+ },
161
+ iid: {
162
+ type: "string",
163
+ description: "Case-insensitive filter by BPMN process ID",
164
+ },
165
+ };
166
+ const JOB_SEARCH_FLAGS = {
167
+ state: { type: "string", description: "Filter by state" },
168
+ type: { type: "string", description: "Filter by job type" },
169
+ processInstanceKey: {
170
+ type: "string",
171
+ description: "Filter by process instance key",
172
+ },
173
+ processDefinitionKey: {
174
+ type: "string",
175
+ description: "Filter by process definition key",
176
+ },
177
+ itype: {
178
+ type: "string",
179
+ description: "Case-insensitive filter by job type",
180
+ },
181
+ };
182
+ const VAR_SEARCH_FLAGS = {
183
+ name: { type: "string", description: "Filter by variable name" },
184
+ value: { type: "string", description: "Filter by value" },
185
+ processInstanceKey: {
186
+ type: "string",
187
+ description: "Filter by process instance key",
188
+ },
189
+ scopeKey: { type: "string", description: "Filter by scope key" },
190
+ fullValue: {
191
+ type: "boolean",
192
+ description: "Return full variable values (not truncated)",
193
+ },
194
+ iname: {
195
+ type: "string",
196
+ description: "Case-insensitive filter by name",
197
+ },
198
+ ivalue: {
199
+ type: "string",
200
+ description: "Case-insensitive filter by value",
201
+ },
202
+ };
203
+ const USER_SEARCH_FLAGS = {
204
+ username: { type: "string", description: "Filter by username" },
205
+ name: { type: "string", description: "Filter by name" },
206
+ email: { type: "string", description: "Filter by email" },
207
+ };
208
+ const ROLE_SEARCH_FLAGS = {
209
+ roleId: { type: "string", description: "Filter by role ID" },
210
+ name: { type: "string", description: "Filter by name" },
211
+ };
212
+ const GROUP_SEARCH_FLAGS = {
213
+ groupId: { type: "string", description: "Filter by group ID" },
214
+ name: { type: "string", description: "Filter by name" },
215
+ };
216
+ const TENANT_SEARCH_FLAGS = {
217
+ tenantId: { type: "string", description: "Filter by tenant ID" },
218
+ name: { type: "string", description: "Filter by name" },
219
+ };
220
+ const AUTH_SEARCH_FLAGS = {
221
+ ownerId: { type: "string", description: "Filter by owner ID" },
222
+ ownerType: { type: "string", description: "Filter by owner type" },
223
+ resourceType: {
224
+ type: "string",
225
+ description: "Filter by resource type",
226
+ },
227
+ resourceId: { type: "string", description: "Filter by resource ID" },
228
+ };
229
+ const MR_SEARCH_FLAGS = {
230
+ mappingRuleId: {
231
+ type: "string",
232
+ description: "Filter by mapping rule ID",
233
+ },
234
+ name: { type: "string", description: "Filter by name" },
235
+ claimName: { type: "string", description: "Filter by claim name" },
236
+ claimValue: { type: "string", description: "Filter by claim value" },
237
+ };
238
+ const ASSIGN_FLAGS = {
239
+ "to-user": { type: "string", description: "Target user ID" },
240
+ "to-group": { type: "string", description: "Target group ID" },
241
+ "to-tenant": { type: "string", description: "Target tenant ID" },
242
+ "to-mapping-rule": {
243
+ type: "string",
244
+ description: "Target mapping rule ID",
245
+ },
246
+ };
247
+ const UNASSIGN_FLAGS = {
248
+ "from-user": { type: "string", description: "Source user ID" },
249
+ "from-group": { type: "string", description: "Source group ID" },
250
+ "from-tenant": { type: "string", description: "Source tenant ID" },
251
+ "from-mapping-rule": {
252
+ type: "string",
253
+ description: "Source mapping rule ID",
254
+ },
255
+ };
256
+ const PROFILE_CONNECTION_FLAGS = {
257
+ baseUrl: { type: "string", description: "Cluster base URL" },
258
+ clientId: { type: "string", description: "OAuth client ID" },
259
+ clientSecret: { type: "string", description: "OAuth client secret" },
260
+ audience: { type: "string", description: "OAuth audience" },
261
+ oAuthUrl: { type: "string", description: "OAuth token URL" },
262
+ defaultTenantId: { type: "string", description: "Default tenant ID" },
263
+ username: { type: "string", description: "Basic auth username" },
264
+ password: { type: "string", description: "Basic auth password" },
265
+ "from-file": { type: "string", description: "Import from .env file" },
266
+ "from-env": {
267
+ type: "boolean",
268
+ description: "Import from environment variables",
269
+ },
270
+ };
271
+ // ─── Command Registry ────────────────────────────────────────────────────────
272
+ export const COMMAND_REGISTRY = {
273
+ // ── Read commands ──────────────────────────────────────────────────────
274
+ list: {
275
+ description: "List resources (process, identity)",
276
+ mutating: false,
277
+ requiresResource: true,
278
+ resources: [
279
+ "pi",
280
+ "pd",
281
+ "ut",
282
+ "inc",
283
+ "jobs",
284
+ "profiles",
285
+ "plugins",
286
+ "users",
287
+ "roles",
288
+ "groups",
289
+ "tenants",
290
+ "auth",
291
+ "mapping-rules",
292
+ ],
293
+ flags: {
294
+ all: {
295
+ type: "boolean",
296
+ description: "List all (disable pagination limit)",
297
+ },
298
+ ...SEARCH_FLAGS,
299
+ // List supports the same resource-specific filters as search;
300
+ // per-resource scoping is handled by SEARCH_RESOURCE_FLAGS.
301
+ ...PI_SEARCH_FLAGS,
302
+ ...PD_SEARCH_FLAGS,
303
+ ...UT_SEARCH_FLAGS,
304
+ ...INC_SEARCH_FLAGS,
305
+ ...JOB_SEARCH_FLAGS,
306
+ ...USER_SEARCH_FLAGS,
307
+ ...ROLE_SEARCH_FLAGS,
308
+ ...GROUP_SEARCH_FLAGS,
309
+ ...TENANT_SEARCH_FLAGS,
310
+ ...AUTH_SEARCH_FLAGS,
311
+ ...MR_SEARCH_FLAGS,
312
+ },
313
+ },
314
+ search: {
315
+ description: "Search resources with filters",
316
+ mutating: false,
317
+ requiresResource: true,
318
+ resources: [
319
+ "pi",
320
+ "pd",
321
+ "ut",
322
+ "inc",
323
+ "jobs",
324
+ "vars",
325
+ "users",
326
+ "roles",
327
+ "groups",
328
+ "tenants",
329
+ "auth",
330
+ "mapping-rules",
331
+ ],
332
+ flags: {
333
+ ...SEARCH_FLAGS,
334
+ // Resource-specific flags are all accepted; per-resource scoping
335
+ // is handled by SEARCH_RESOURCE_FLAGS below.
336
+ ...PI_SEARCH_FLAGS,
337
+ ...PD_SEARCH_FLAGS,
338
+ ...UT_SEARCH_FLAGS,
339
+ ...INC_SEARCH_FLAGS,
340
+ ...JOB_SEARCH_FLAGS,
341
+ ...VAR_SEARCH_FLAGS,
342
+ ...USER_SEARCH_FLAGS,
343
+ ...ROLE_SEARCH_FLAGS,
344
+ ...GROUP_SEARCH_FLAGS,
345
+ ...TENANT_SEARCH_FLAGS,
346
+ ...AUTH_SEARCH_FLAGS,
347
+ ...MR_SEARCH_FLAGS,
348
+ },
349
+ },
350
+ get: {
351
+ description: "Get resource by key",
352
+ mutating: false,
353
+ requiresResource: true,
354
+ resources: [
355
+ "pi",
356
+ "pd",
357
+ "inc",
358
+ "topology",
359
+ "form",
360
+ "user",
361
+ "role",
362
+ "group",
363
+ "tenant",
364
+ "auth",
365
+ "mapping-rule",
366
+ ],
367
+ flags: {
368
+ xml: {
369
+ type: "boolean",
370
+ description: "Get BPMN XML (process definitions)",
371
+ },
372
+ userTask: {
373
+ type: "boolean",
374
+ description: "Get form for user task",
375
+ },
376
+ processDefinition: {
377
+ type: "boolean",
378
+ description: "Get form for process definition",
379
+ },
380
+ },
381
+ },
382
+ // ── Mutating commands ──────────────────────────────────────────────────
383
+ create: {
384
+ description: "Create resource",
385
+ mutating: true,
386
+ requiresResource: true,
387
+ resources: [
388
+ "pi",
389
+ "user",
390
+ "role",
391
+ "group",
392
+ "tenant",
393
+ "auth",
394
+ "mapping-rule",
395
+ ],
396
+ flags: {
397
+ // Process instance creation
398
+ processDefinitionId: {
399
+ type: "string",
400
+ description: "Process definition ID (BPMN process ID)",
401
+ },
402
+ id: {
403
+ type: "string",
404
+ description: "Process definition ID (alias for --processDefinitionId)",
405
+ },
406
+ bpmnProcessId: {
407
+ type: "string",
408
+ description: "BPMN process ID (alias for --processDefinitionId)",
409
+ },
410
+ variables: { type: "string", description: "JSON variables" },
411
+ awaitCompletion: {
412
+ type: "boolean",
413
+ description: "Wait for process to complete",
414
+ },
415
+ fetchVariables: {
416
+ type: "boolean",
417
+ description: "Fetch result variables on completion",
418
+ },
419
+ requestTimeout: {
420
+ type: "string",
421
+ description: "Await timeout in milliseconds",
422
+ },
423
+ // Identity user
424
+ username: { type: "string", description: "Username" },
425
+ name: { type: "string", description: "Display name" },
426
+ email: { type: "string", description: "Email address" },
427
+ password: { type: "string", description: "Password" },
428
+ // Identity role
429
+ roleId: { type: "string", description: "Role ID" },
430
+ // Identity group
431
+ groupId: { type: "string", description: "Group ID" },
432
+ // Identity tenant
433
+ tenantId: { type: "string", description: "Tenant ID" },
434
+ // Identity authorization
435
+ ownerId: {
436
+ type: "string",
437
+ description: "Authorization owner ID",
438
+ required: true,
439
+ },
440
+ ownerType: {
441
+ type: "string",
442
+ description: "Authorization owner type",
443
+ required: true,
444
+ },
445
+ resourceType: {
446
+ type: "string",
447
+ description: "Authorization resource type",
448
+ required: true,
449
+ },
450
+ resourceId: {
451
+ type: "string",
452
+ description: "Authorization resource ID",
453
+ required: true,
454
+ },
455
+ permissions: {
456
+ type: "string",
457
+ description: "Comma-separated permissions",
458
+ required: true,
459
+ csv: true,
460
+ },
461
+ // Identity mapping rule
462
+ mappingRuleId: {
463
+ type: "string",
464
+ description: "Mapping rule ID",
465
+ },
466
+ claimName: { type: "string", description: "Claim name" },
467
+ claimValue: { type: "string", description: "Claim value" },
468
+ },
469
+ },
470
+ delete: {
471
+ description: "Delete resource",
472
+ mutating: true,
473
+ requiresResource: true,
474
+ resources: ["user", "role", "group", "tenant", "auth", "mapping-rule"],
475
+ flags: {},
476
+ },
477
+ cancel: {
478
+ description: "Cancel resource",
479
+ mutating: true,
480
+ requiresResource: true,
481
+ resources: ["pi"],
482
+ flags: {},
483
+ },
484
+ await: {
485
+ description: "Create and await completion (alias for create --awaitCompletion)",
486
+ mutating: true,
487
+ requiresResource: true,
488
+ resources: ["pi"],
489
+ flags: {
490
+ processDefinitionId: {
491
+ type: "string",
492
+ description: "Process definition ID (BPMN process ID)",
493
+ },
494
+ id: {
495
+ type: "string",
496
+ description: "Process definition ID (alias for --processDefinitionId)",
497
+ },
498
+ bpmnProcessId: {
499
+ type: "string",
500
+ description: "BPMN process ID (alias for --processDefinitionId)",
501
+ },
502
+ variables: { type: "string", description: "JSON variables" },
503
+ fetchVariables: {
504
+ type: "boolean",
505
+ description: "Fetch result variables on completion",
506
+ },
507
+ requestTimeout: {
508
+ type: "string",
509
+ description: "Await timeout in milliseconds",
510
+ },
511
+ },
512
+ },
513
+ complete: {
514
+ description: "Complete resource",
515
+ mutating: true,
516
+ requiresResource: true,
517
+ resources: ["ut", "job"],
518
+ flags: {
519
+ variables: { type: "string", description: "JSON variables" },
520
+ },
521
+ },
522
+ fail: {
523
+ description: "Fail a job",
524
+ mutating: true,
525
+ requiresResource: true,
526
+ resources: ["job"],
527
+ flags: {
528
+ retries: {
529
+ type: "string",
530
+ description: "Remaining retries",
531
+ },
532
+ errorMessage: {
533
+ type: "string",
534
+ description: "Error message",
535
+ },
536
+ },
537
+ },
538
+ activate: {
539
+ description: "Activate jobs by type",
540
+ mutating: true,
541
+ requiresResource: true,
542
+ resources: ["jobs"],
543
+ flags: {
544
+ maxJobsToActivate: {
545
+ type: "string",
546
+ description: "Maximum number of jobs to activate",
547
+ },
548
+ timeout: {
549
+ type: "string",
550
+ description: "Job timeout in milliseconds",
551
+ },
552
+ worker: { type: "string", description: "Worker name" },
553
+ },
554
+ },
555
+ resolve: {
556
+ description: "Resolve incident",
557
+ mutating: true,
558
+ requiresResource: true,
559
+ resources: ["inc"],
560
+ flags: {},
561
+ },
562
+ publish: {
563
+ description: "Publish message",
564
+ mutating: true,
565
+ requiresResource: true,
566
+ resources: ["msg"],
567
+ flags: {
568
+ correlationKey: {
569
+ type: "string",
570
+ description: "Correlation key",
571
+ },
572
+ variables: { type: "string", description: "JSON variables" },
573
+ timeToLive: {
574
+ type: "string",
575
+ description: "Time to live in milliseconds",
576
+ },
577
+ },
578
+ },
579
+ correlate: {
580
+ description: "Correlate message",
581
+ mutating: true,
582
+ requiresResource: true,
583
+ resources: ["msg"],
584
+ flags: {
585
+ correlationKey: {
586
+ type: "string",
587
+ description: "Correlation key",
588
+ required: true,
589
+ },
590
+ variables: { type: "string", description: "JSON variables" },
591
+ timeToLive: {
592
+ type: "string",
593
+ description: "Time to live in milliseconds",
594
+ },
595
+ },
596
+ },
597
+ deploy: {
598
+ description: "Deploy BPMN/DMN/forms",
599
+ mutating: true,
600
+ requiresResource: false,
601
+ resources: [],
602
+ flags: {},
603
+ },
604
+ run: {
605
+ description: "Deploy and start process",
606
+ mutating: true,
607
+ requiresResource: true,
608
+ resources: [],
609
+ flags: {
610
+ variables: { type: "string", description: "JSON variables" },
611
+ },
612
+ },
613
+ // ── Assignment commands ────────────────────────────────────────────────
614
+ assign: {
615
+ description: "Assign resource to target",
616
+ mutating: true,
617
+ requiresResource: true,
618
+ resources: ["role", "user", "group", "mapping-rule"],
619
+ flags: { ...ASSIGN_FLAGS },
620
+ },
621
+ unassign: {
622
+ description: "Unassign resource from target",
623
+ mutating: true,
624
+ requiresResource: true,
625
+ resources: ["role", "user", "group", "mapping-rule"],
626
+ flags: { ...UNASSIGN_FLAGS },
627
+ },
628
+ // ── Operational commands ───────────────────────────────────────────────
629
+ watch: {
630
+ description: "Watch files for changes and auto-deploy",
631
+ mutating: false,
632
+ requiresResource: false,
633
+ resources: [],
634
+ flags: {
635
+ force: {
636
+ type: "boolean",
637
+ description: "Force re-deploy unchanged files",
638
+ },
639
+ },
640
+ aliases: ["w"],
641
+ },
642
+ open: {
643
+ description: "Open Camunda web application in browser",
644
+ mutating: false,
645
+ requiresResource: true,
646
+ resources: ["operate", "tasklist", "modeler", "optimize"],
647
+ flags: {},
648
+ },
649
+ // ── Profile & plugin management ────────────────────────────────────────
650
+ add: {
651
+ description: "Add a profile",
652
+ mutating: false,
653
+ requiresResource: true,
654
+ resources: ["profile"],
655
+ flags: { ...PROFILE_CONNECTION_FLAGS },
656
+ },
657
+ remove: {
658
+ description: "Remove a profile",
659
+ mutating: false,
660
+ requiresResource: true,
661
+ resources: ["profile"],
662
+ flags: {
663
+ none: {
664
+ type: "boolean",
665
+ description: "Clear active profile",
666
+ },
667
+ },
668
+ aliases: ["rm"],
669
+ },
670
+ load: {
671
+ description: "Load a c8ctl plugin",
672
+ mutating: false,
673
+ requiresResource: true,
674
+ resources: ["plugin"],
675
+ flags: {
676
+ from: {
677
+ type: "string",
678
+ description: "Load plugin from URL",
679
+ },
680
+ },
681
+ },
682
+ unload: {
683
+ description: "Unload a c8ctl plugin",
684
+ mutating: false,
685
+ requiresResource: true,
686
+ resources: ["plugin"],
687
+ flags: {
688
+ force: {
689
+ type: "boolean",
690
+ description: "Force unload without confirmation",
691
+ },
692
+ },
693
+ aliases: ["rm"],
694
+ },
695
+ upgrade: {
696
+ description: "Upgrade a plugin",
697
+ mutating: false,
698
+ requiresResource: true,
699
+ resources: ["plugin"],
700
+ flags: {},
701
+ },
702
+ downgrade: {
703
+ description: "Downgrade a plugin to a specific version",
704
+ mutating: false,
705
+ requiresResource: true,
706
+ resources: ["plugin"],
707
+ flags: {},
708
+ },
709
+ sync: {
710
+ description: "Synchronize plugins",
711
+ mutating: false,
712
+ requiresResource: true,
713
+ resources: ["plugin"],
714
+ flags: {},
715
+ },
716
+ init: {
717
+ description: "Create a new plugin from TypeScript template",
718
+ mutating: false,
719
+ requiresResource: true,
720
+ resources: ["plugin"],
721
+ flags: {},
722
+ },
723
+ // ── Session commands ───────────────────────────────────────────────────
724
+ use: {
725
+ description: "Set active profile or tenant",
726
+ mutating: false,
727
+ requiresResource: true,
728
+ resources: ["profile", "tenant"],
729
+ flags: {
730
+ none: {
731
+ type: "boolean",
732
+ description: "Clear active profile/tenant",
733
+ },
734
+ },
735
+ },
736
+ output: {
737
+ description: "Show or set output format",
738
+ mutating: false,
739
+ requiresResource: false,
740
+ resources: ["json", "text"],
741
+ flags: {},
742
+ },
743
+ // ── Utility commands ───────────────────────────────────────────────────
744
+ completion: {
745
+ description: "Generate shell completion script",
746
+ mutating: false,
747
+ requiresResource: false,
748
+ resources: ["bash", "zsh", "fish"],
749
+ flags: {},
750
+ },
751
+ "mcp-proxy": {
752
+ description: "Start a STDIO to remote HTTP MCP proxy server",
753
+ mutating: false,
754
+ requiresResource: false,
755
+ resources: [],
756
+ flags: {},
757
+ },
758
+ feedback: {
759
+ description: "Open the feedback page to report issues or request features",
760
+ mutating: false,
761
+ requiresResource: false,
762
+ resources: [],
763
+ flags: {},
764
+ },
765
+ help: {
766
+ description: "Show help",
767
+ mutating: false,
768
+ requiresResource: false,
769
+ resources: [],
770
+ flags: {},
771
+ },
772
+ which: {
773
+ description: "Show active profile",
774
+ mutating: false,
775
+ requiresResource: true,
776
+ resources: ["profile"],
777
+ flags: {},
778
+ },
779
+ };
780
+ // ─── Per-resource search flag scoping ────────────────────────────────────────
781
+ /**
782
+ * Maps each searchable resource (canonical name) to the set of flag names
783
+ * that are valid for that resource's search command. Used for unknown-flag
784
+ * detection in search commands.
785
+ */
786
+ export const SEARCH_RESOURCE_FLAGS = {
787
+ "process-definition": new Set(Object.keys(PD_SEARCH_FLAGS)),
788
+ "process-instance": new Set(Object.keys(PI_SEARCH_FLAGS)),
789
+ "user-task": new Set(Object.keys(UT_SEARCH_FLAGS)),
790
+ incident: new Set(Object.keys(INC_SEARCH_FLAGS)),
791
+ jobs: new Set(Object.keys(JOB_SEARCH_FLAGS)),
792
+ variable: new Set([...Object.keys(VAR_SEARCH_FLAGS), "limit"]),
793
+ user: new Set([...Object.keys(USER_SEARCH_FLAGS), "limit"]),
794
+ role: new Set([...Object.keys(ROLE_SEARCH_FLAGS), "limit"]),
795
+ group: new Set([...Object.keys(GROUP_SEARCH_FLAGS), "limit"]),
796
+ tenant: new Set([...Object.keys(TENANT_SEARCH_FLAGS), "limit"]),
797
+ authorization: new Set([...Object.keys(AUTH_SEARCH_FLAGS), "limit"]),
798
+ "mapping-rule": new Set([...Object.keys(MR_SEARCH_FLAGS), "limit"]),
799
+ };
800
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
801
+ /**
802
+ * Maps verb aliases to their canonical verb names.
803
+ * Built from COMMAND_REGISTRY aliases fields.
804
+ * e.g. { "rm": ["remove", "unload"], "w": ["watch"] }
805
+ */
806
+ export const VERB_ALIASES = (() => {
807
+ const map = {};
808
+ for (const [verb, def] of Object.entries(COMMAND_REGISTRY)) {
809
+ for (const alias of def.aliases ?? []) {
810
+ if (!map[alias]) {
811
+ map[alias] = [];
812
+ }
813
+ map[alias].push(verb);
814
+ }
815
+ }
816
+ return map;
817
+ })();
818
+ /**
819
+ * Resolve a resource alias to its canonical form.
820
+ * Returns the input unchanged if no alias exists.
821
+ */
822
+ export function resolveAlias(resource) {
823
+ return RESOURCE_ALIASES[resource] ?? resource;
824
+ }
825
+ /**
826
+ * Look up a command definition by verb (resolves verb aliases).
827
+ * For alias verbs that map to multiple commands (e.g. "rm" → remove + unload),
828
+ * returns the first match. Use VERB_ALIASES directly for multi-target aliases.
829
+ */
830
+ export function getCommandDef(verb) {
831
+ const direct = COMMAND_REGISTRY[verb];
832
+ if (direct)
833
+ return direct;
834
+ const targets = VERB_ALIASES[verb];
835
+ return targets ? COMMAND_REGISTRY[targets[0]] : undefined;
836
+ }
837
+ /**
838
+ * Get all flags accepted for a given verb, including global flags.
839
+ */
840
+ export function getAcceptedFlags(verb) {
841
+ const def = getCommandDef(verb);
842
+ if (!def)
843
+ return undefined;
844
+ return { ...GLOBAL_FLAGS, ...def.flags };
845
+ }
846
+ /**
847
+ * Get the set of resource-specific search flags for a given canonical resource.
848
+ */
849
+ export function getSearchFlagsForResource(resource) {
850
+ return SEARCH_RESOURCE_FLAGS[resource];
851
+ }
852
+ /**
853
+ * Check whether a verb×resource combination is valid.
854
+ * Accepts both raw aliases and canonical resource names.
855
+ */
856
+ export function isValidCommand(verb, resource) {
857
+ const def = getCommandDef(verb);
858
+ if (!def)
859
+ return false;
860
+ if (!def.requiresResource)
861
+ return true;
862
+ const canonical = resolveAlias(resource);
863
+ return (def.resources.includes(resource) ||
864
+ def.resources.includes(canonical) ||
865
+ def.resources.some((r) => resolveAlias(r) === canonical));
866
+ }
867
+ /**
868
+ * Derive parseArgs options from the registry. This produces the flat
869
+ * options object that node:util parseArgs expects, covering all flags
870
+ * from all commands plus global flags.
871
+ */
872
+ export function deriveParseArgsOptions() {
873
+ const options = {};
874
+ // Global flags
875
+ for (const [name, def] of Object.entries(GLOBAL_FLAGS)) {
876
+ options[name] = { type: def.type, ...(def.short && { short: def.short }) };
877
+ }
878
+ // Search flags
879
+ for (const [name, def] of Object.entries(SEARCH_FLAGS)) {
880
+ options[name] = { type: def.type, ...(def.short && { short: def.short }) };
881
+ }
882
+ // All command-specific flags
883
+ for (const cmd of Object.values(COMMAND_REGISTRY)) {
884
+ for (const [name, def] of Object.entries(cmd.flags)) {
885
+ if (!options[name]) {
886
+ options[name] = {
887
+ type: def.type,
888
+ ...(def.short && { short: def.short }),
889
+ };
890
+ }
891
+ }
892
+ }
893
+ return options;
894
+ }
895
+ //# sourceMappingURL=command-registry.js.map