@lightdash-tools/cli 0.1.2 → 0.2.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.
- package/README.md +49 -1
- package/dist/commands/ai-agents.js +8 -6
- package/dist/commands/charts.js +8 -6
- package/dist/commands/content.d.ts +8 -0
- package/dist/commands/content.js +48 -0
- package/dist/commands/dashboards.js +4 -2
- package/dist/commands/explores.js +34 -4
- package/dist/commands/groups.js +6 -4
- package/dist/commands/metrics.d.ts +8 -0
- package/dist/commands/metrics.js +59 -0
- package/dist/commands/organization-roles.js +10 -8
- package/dist/commands/organization.js +4 -2
- package/dist/commands/project-access.js +8 -6
- package/dist/commands/project-role-assignments.js +12 -10
- package/dist/commands/projects.js +38 -4
- package/dist/commands/query.js +4 -2
- package/dist/commands/schedulers.d.ts +8 -0
- package/dist/commands/schedulers.js +59 -0
- package/dist/commands/spaces.js +6 -4
- package/dist/commands/tags.d.ts +8 -0
- package/dist/commands/tags.js +52 -0
- package/dist/commands/users.js +6 -4
- package/dist/index.js +13 -1
- package/dist/utils/safety.d.ts +11 -0
- package/dist/utils/safety.js +39 -0
- package/dist/utils/safety.test.d.ts +1 -0
- package/dist/utils/safety.test.js +50 -0
- package/package.json +3 -3
- package/src/commands/ai-agents.ts +53 -45
- package/src/commands/charts.ts +59 -47
- package/src/commands/content.ts +55 -0
- package/src/commands/dashboards.ts +17 -13
- package/src/commands/explores.ts +77 -26
- package/src/commands/groups.ts +59 -53
- package/src/commands/metrics.ts +69 -0
- package/src/commands/organization-roles.ts +78 -68
- package/src/commands/organization.ts +17 -13
- package/src/commands/project-access.ts +50 -39
- package/src/commands/project-role-assignments.ts +87 -75
- package/src/commands/projects.ts +77 -28
- package/src/commands/query.ts +30 -23
- package/src/commands/schedulers.ts +66 -0
- package/src/commands/spaces.ts +32 -26
- package/src/commands/tags.ts +53 -0
- package/src/commands/users.ts +51 -45
- package/src/index.ts +17 -1
- package/src/utils/safety.test.ts +53 -0
- package/src/utils/safety.ts +33 -0
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
6
7
|
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Registers the top-level ai-agents command and its subcommands.
|
|
@@ -14,59 +16,65 @@ export function registerAiAgentsCommand(program: Command): void {
|
|
|
14
16
|
aiAgentsCmd
|
|
15
17
|
.command('list')
|
|
16
18
|
.description('List all AI agents (admin)')
|
|
17
|
-
.action(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
.action(
|
|
20
|
+
wrapAction(READ_ONLY_DEFAULT, async () => {
|
|
21
|
+
try {
|
|
22
|
+
const client = getClient();
|
|
23
|
+
const result = await client.v1.aiAgents.listAdminAgents();
|
|
24
|
+
console.log(JSON.stringify(result, null, 2));
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(
|
|
27
|
+
'Error listing AI agents:',
|
|
28
|
+
error instanceof Error ? error.message : String(error),
|
|
29
|
+
);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
30
34
|
|
|
31
35
|
aiAgentsCmd
|
|
32
36
|
.command('threads')
|
|
33
37
|
.description('List AI agent threads (admin)')
|
|
34
38
|
.option('--page <number>', 'Page number', (v: string) => parseInt(v, 10))
|
|
35
39
|
.option('--page-size <number>', 'Page size', (v: string) => parseInt(v, 10))
|
|
36
|
-
.action(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
.action(
|
|
41
|
+
wrapAction(READ_ONLY_DEFAULT, async function (this: Command) {
|
|
42
|
+
const options = this.opts() as { page?: number; pageSize?: number };
|
|
43
|
+
try {
|
|
44
|
+
const client = getClient();
|
|
45
|
+
const params: { page?: number; pageSize?: number } = {};
|
|
46
|
+
if (options.page != null) params.page = options.page;
|
|
47
|
+
if (options.pageSize != null) params.pageSize = options.pageSize;
|
|
48
|
+
const result = await client.v1.aiAgents.getAdminThreads(
|
|
49
|
+
Object.keys(params).length > 0 ? params : undefined,
|
|
50
|
+
);
|
|
51
|
+
console.log(JSON.stringify(result, null, 2));
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(
|
|
54
|
+
'Error listing AI agent threads:',
|
|
55
|
+
error instanceof Error ? error.message : String(error),
|
|
56
|
+
);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
55
61
|
|
|
56
62
|
aiAgentsCmd
|
|
57
63
|
.command('settings')
|
|
58
64
|
.description('Get AI organization settings')
|
|
59
|
-
.action(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
.action(
|
|
66
|
+
wrapAction(READ_ONLY_DEFAULT, async () => {
|
|
67
|
+
try {
|
|
68
|
+
const client = getClient();
|
|
69
|
+
const result = await client.v1.aiAgents.getAiOrganizationSettings();
|
|
70
|
+
console.log(JSON.stringify(result, null, 2));
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error(
|
|
73
|
+
'Error fetching AI organization settings:',
|
|
74
|
+
error instanceof Error ? error.message : String(error),
|
|
75
|
+
);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
72
80
|
}
|
package/src/commands/charts.ts
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
6
|
import { readFileSync } from 'fs';
|
|
7
|
+
import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from '@lightdash-tools/common';
|
|
7
8
|
import { getClient } from '../utils/client';
|
|
9
|
+
import { wrapAction } from '../utils/safety';
|
|
8
10
|
import type { UpsertChartAsCodeBody } from '@lightdash-tools/common';
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -57,19 +59,21 @@ export function registerChartsCommand(program: Command): void {
|
|
|
57
59
|
chartsCmd
|
|
58
60
|
.command('list <projectUuid>')
|
|
59
61
|
.description('List charts in a project')
|
|
60
|
-
.action(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
.action(
|
|
63
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string) => {
|
|
64
|
+
try {
|
|
65
|
+
const client = getClient();
|
|
66
|
+
const result = await client.v1.charts.listCharts(projectUuid);
|
|
67
|
+
console.log(JSON.stringify(result, null, 2));
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(
|
|
70
|
+
'Error listing charts:',
|
|
71
|
+
error instanceof Error ? error.message : String(error),
|
|
72
|
+
);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
73
77
|
|
|
74
78
|
const codeCmd = chartsCmd
|
|
75
79
|
.command('code')
|
|
@@ -82,44 +86,52 @@ export function registerChartsCommand(program: Command): void {
|
|
|
82
86
|
.option('--offset <number>', 'Pagination offset', (v) => parseInt(v, 10))
|
|
83
87
|
.option('--language-map', 'Include language map in response')
|
|
84
88
|
.action(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
error
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
wrapAction(
|
|
90
|
+
READ_ONLY_DEFAULT,
|
|
91
|
+
async (
|
|
92
|
+
projectUuid: string,
|
|
93
|
+
options: { ids?: string[]; offset?: number; languageMap?: boolean },
|
|
94
|
+
) => {
|
|
95
|
+
try {
|
|
96
|
+
const client = getClient();
|
|
97
|
+
const result = await client.v1.charts.getChartsAsCode(projectUuid, {
|
|
98
|
+
ids: options.ids,
|
|
99
|
+
offset: options.offset,
|
|
100
|
+
languageMap: options.languageMap,
|
|
101
|
+
});
|
|
102
|
+
console.log(JSON.stringify(result, null, 2));
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error(
|
|
105
|
+
'Error getting charts as code:',
|
|
106
|
+
error instanceof Error ? error.message : String(error),
|
|
107
|
+
);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
),
|
|
105
112
|
);
|
|
106
113
|
|
|
107
114
|
codeCmd
|
|
108
115
|
.command('upsert <projectUuid> <slug>')
|
|
109
116
|
.description('Upsert a chart from code (body from --file or stdin)')
|
|
110
117
|
.option('--file <path>', 'Read chart JSON from file (default: stdin)')
|
|
111
|
-
.action(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
.action(
|
|
119
|
+
wrapAction(
|
|
120
|
+
WRITE_IDEMPOTENT,
|
|
121
|
+
async (projectUuid: string, slug: string, options: { file?: string }) => {
|
|
122
|
+
try {
|
|
123
|
+
const body = await readChartJsonInput(options.file);
|
|
124
|
+
const client = getClient();
|
|
125
|
+
const result = await client.v1.charts.upsertChartAsCode(projectUuid, slug, body);
|
|
126
|
+
console.log(JSON.stringify(result, null, 2));
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error(
|
|
129
|
+
'Error upserting chart as code:',
|
|
130
|
+
error instanceof Error ? error.message : String(error),
|
|
131
|
+
);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
),
|
|
136
|
+
);
|
|
125
137
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content command implementation.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
7
|
+
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Registers the content command and its subcommands.
|
|
12
|
+
*/
|
|
13
|
+
export function registerContentCommand(program: Command): void {
|
|
14
|
+
const contentCmd = program.command('content').description('Manage project content');
|
|
15
|
+
|
|
16
|
+
contentCmd
|
|
17
|
+
.command('search <query>')
|
|
18
|
+
.description('Search project content (charts, dashboards, spaces)')
|
|
19
|
+
.option('--project <uuids...>', 'Filter by project UUIDs')
|
|
20
|
+
.option('--type <types...>', 'Filter by content types (chart, dashboard, space)')
|
|
21
|
+
.option('--page <number>', 'Page number', (v) => parseInt(v, 10))
|
|
22
|
+
.option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
|
|
23
|
+
.action(
|
|
24
|
+
wrapAction(
|
|
25
|
+
READ_ONLY_DEFAULT,
|
|
26
|
+
async (
|
|
27
|
+
query: string,
|
|
28
|
+
options: {
|
|
29
|
+
project?: string[];
|
|
30
|
+
type?: ('chart' | 'dashboard' | 'space')[];
|
|
31
|
+
page?: number;
|
|
32
|
+
pageSize?: number;
|
|
33
|
+
},
|
|
34
|
+
) => {
|
|
35
|
+
try {
|
|
36
|
+
const client = getClient();
|
|
37
|
+
const result = await client.v2.content.searchContent({
|
|
38
|
+
search: query,
|
|
39
|
+
projectUuids: options.project,
|
|
40
|
+
contentTypes: options.type,
|
|
41
|
+
page: options.page,
|
|
42
|
+
pageSize: options.pageSize,
|
|
43
|
+
});
|
|
44
|
+
console.log(JSON.stringify(result, null, 2));
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error(
|
|
47
|
+
'Error searching content:',
|
|
48
|
+
error instanceof Error ? error.message : String(error),
|
|
49
|
+
);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
6
7
|
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Registers the projects dashboards subcommands under the existing projects command.
|
|
@@ -21,17 +23,19 @@ export function registerDashboardsCommand(program: Command): void {
|
|
|
21
23
|
dashboardsCmd
|
|
22
24
|
.command('list <projectUuid>')
|
|
23
25
|
.description('List dashboards in a project')
|
|
24
|
-
.action(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
.action(
|
|
27
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string) => {
|
|
28
|
+
try {
|
|
29
|
+
const client = getClient();
|
|
30
|
+
const result = await client.v1.dashboards.listDashboards(projectUuid);
|
|
31
|
+
console.log(JSON.stringify(result, null, 2));
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(
|
|
34
|
+
'Error listing dashboards:',
|
|
35
|
+
error instanceof Error ? error.message : String(error),
|
|
36
|
+
);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
37
41
|
}
|
package/src/commands/explores.ts
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
6
7
|
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Registers the projects explores subcommands under the existing projects command.
|
|
@@ -21,34 +23,83 @@ export function registerExploresCommand(program: Command): void {
|
|
|
21
23
|
exploresCmd
|
|
22
24
|
.command('list <projectUuid>')
|
|
23
25
|
.description('List explores in a project')
|
|
24
|
-
.action(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
.action(
|
|
27
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string) => {
|
|
28
|
+
try {
|
|
29
|
+
const client = getClient();
|
|
30
|
+
const result = await client.v1.explores.listExplores(projectUuid);
|
|
31
|
+
console.log(JSON.stringify(result, null, 2));
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(
|
|
34
|
+
'Error listing explores:',
|
|
35
|
+
error instanceof Error ? error.message : String(error),
|
|
36
|
+
);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
37
41
|
|
|
38
42
|
exploresCmd
|
|
39
43
|
.command('get <projectUuid> <exploreId>')
|
|
40
44
|
.description('Get an explore by ID')
|
|
41
|
-
.action(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
.action(
|
|
46
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string, exploreId: string) => {
|
|
47
|
+
try {
|
|
48
|
+
const client = getClient();
|
|
49
|
+
const result = await client.v1.explores.getExplore(projectUuid, exploreId);
|
|
50
|
+
console.log(JSON.stringify(result, null, 2));
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(
|
|
53
|
+
'Error fetching explore:',
|
|
54
|
+
error instanceof Error ? error.message : String(error),
|
|
55
|
+
);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
exploresCmd
|
|
62
|
+
.command('dimensions <projectUuid> <exploreId>')
|
|
63
|
+
.description('List dimensions for an explore')
|
|
64
|
+
.action(
|
|
65
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string, exploreId: string) => {
|
|
66
|
+
try {
|
|
67
|
+
const client = getClient();
|
|
68
|
+
const result = await client.v1.explores.listDimensions(projectUuid, exploreId);
|
|
69
|
+
console.log(JSON.stringify(result, null, 2));
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error(
|
|
72
|
+
'Error listing dimensions:',
|
|
73
|
+
error instanceof Error ? error.message : String(error),
|
|
74
|
+
);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
exploresCmd
|
|
81
|
+
.command('lineage <projectUuid> <exploreId> <fieldId>')
|
|
82
|
+
.description('Get lineage for a field in an explore')
|
|
83
|
+
.action(
|
|
84
|
+
wrapAction(
|
|
85
|
+
READ_ONLY_DEFAULT,
|
|
86
|
+
async (projectUuid: string, exploreId: string, fieldId: string) => {
|
|
87
|
+
try {
|
|
88
|
+
const client = getClient();
|
|
89
|
+
const result = await client.v1.explores.getFieldLineage(
|
|
90
|
+
projectUuid,
|
|
91
|
+
exploreId,
|
|
92
|
+
fieldId,
|
|
93
|
+
);
|
|
94
|
+
console.log(JSON.stringify(result, null, 2));
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error(
|
|
97
|
+
'Error fetching lineage:',
|
|
98
|
+
error instanceof Error ? error.message : String(error),
|
|
99
|
+
);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
),
|
|
104
|
+
);
|
|
54
105
|
}
|
package/src/commands/groups.ts
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
6
7
|
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Registers the groups command and its subcommands.
|
|
@@ -22,63 +24,67 @@ export function registerGroupsCommand(program: Command): void {
|
|
|
22
24
|
.option('--include-members <number>', 'Include members (0 or 1)', (v: string) =>
|
|
23
25
|
parseInt(v, 10),
|
|
24
26
|
)
|
|
25
|
-
.action(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
.action(
|
|
28
|
+
wrapAction(READ_ONLY_DEFAULT, async function (this: Command) {
|
|
29
|
+
const options = this.opts() as {
|
|
30
|
+
all?: boolean;
|
|
31
|
+
page?: number;
|
|
32
|
+
pageSize?: number;
|
|
33
|
+
search?: string;
|
|
34
|
+
includeMembers?: number;
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
const client = getClient();
|
|
38
|
+
if (options.all) {
|
|
39
|
+
const listParams: { searchQuery?: string; includeMembers?: number } = {};
|
|
40
|
+
if (options.search != null) listParams.searchQuery = options.search;
|
|
41
|
+
if (options.includeMembers != null) listParams.includeMembers = options.includeMembers;
|
|
42
|
+
const list = await client.v1.groups.listAllGroups(
|
|
43
|
+
Object.keys(listParams).length > 0 ? listParams : undefined,
|
|
44
|
+
);
|
|
45
|
+
console.log(JSON.stringify(list, null, 2));
|
|
46
|
+
} else {
|
|
47
|
+
const params: {
|
|
48
|
+
page?: number;
|
|
49
|
+
pageSize?: number;
|
|
50
|
+
searchQuery?: string;
|
|
51
|
+
includeMembers?: number;
|
|
52
|
+
} = {};
|
|
53
|
+
if (options.page != null) params.page = options.page;
|
|
54
|
+
if (options.pageSize != null) params.pageSize = options.pageSize;
|
|
55
|
+
if (options.search != null) params.searchQuery = options.search;
|
|
56
|
+
if (options.includeMembers != null) params.includeMembers = options.includeMembers;
|
|
57
|
+
const result = await client.v1.groups.listGroups(
|
|
58
|
+
Object.keys(params).length > 0 ? params : undefined,
|
|
59
|
+
);
|
|
60
|
+
console.log(JSON.stringify(result, null, 2));
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(
|
|
64
|
+
'Error listing groups:',
|
|
65
|
+
error instanceof Error ? error.message : String(error),
|
|
41
66
|
);
|
|
42
|
-
|
|
43
|
-
} else {
|
|
44
|
-
const params: {
|
|
45
|
-
page?: number;
|
|
46
|
-
pageSize?: number;
|
|
47
|
-
searchQuery?: string;
|
|
48
|
-
includeMembers?: number;
|
|
49
|
-
} = {};
|
|
50
|
-
if (options.page != null) params.page = options.page;
|
|
51
|
-
if (options.pageSize != null) params.pageSize = options.pageSize;
|
|
52
|
-
if (options.search != null) params.searchQuery = options.search;
|
|
53
|
-
if (options.includeMembers != null) params.includeMembers = options.includeMembers;
|
|
54
|
-
const result = await client.v1.groups.listGroups(
|
|
55
|
-
Object.keys(params).length > 0 ? params : undefined,
|
|
56
|
-
);
|
|
57
|
-
console.log(JSON.stringify(result, null, 2));
|
|
67
|
+
process.exit(1);
|
|
58
68
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
'Error listing groups:',
|
|
62
|
-
error instanceof Error ? error.message : String(error),
|
|
63
|
-
);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
67
71
|
|
|
68
72
|
groupsCmd
|
|
69
73
|
.command('get <groupUuid>')
|
|
70
74
|
.description('Get a group by UUID')
|
|
71
|
-
.action(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
.action(
|
|
76
|
+
wrapAction(READ_ONLY_DEFAULT, async (groupUuid: string) => {
|
|
77
|
+
try {
|
|
78
|
+
const client = getClient();
|
|
79
|
+
const group = await client.v1.groups.getGroup(groupUuid);
|
|
80
|
+
console.log(JSON.stringify(group, null, 2));
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error(
|
|
83
|
+
'Error fetching group:',
|
|
84
|
+
error instanceof Error ? error.message : String(error),
|
|
85
|
+
);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
84
90
|
}
|