@lightdash-tools/cli 0.1.0
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/LICENSE +201 -0
- package/README.md +113 -0
- package/dist/commands/ai-agents.d.ts +8 -0
- package/dist/commands/ai-agents.js +74 -0
- package/dist/commands/charts.d.ts +8 -0
- package/dist/commands/charts.js +117 -0
- package/dist/commands/dashboards.d.ts +8 -0
- package/dist/commands/dashboards.js +42 -0
- package/dist/commands/explores.d.ts +8 -0
- package/dist/commands/explores.js +56 -0
- package/dist/commands/groups.d.ts +9 -0
- package/dist/commands/groups.js +79 -0
- package/dist/commands/organization-roles.d.ts +9 -0
- package/dist/commands/organization-roles.js +106 -0
- package/dist/commands/organization.d.ts +8 -0
- package/dist/commands/organization.js +36 -0
- package/dist/commands/project-access.d.ts +8 -0
- package/dist/commands/project-access.js +69 -0
- package/dist/commands/project-role-assignments.d.ts +8 -0
- package/dist/commands/project-role-assignments.js +102 -0
- package/dist/commands/projects.d.ts +8 -0
- package/dist/commands/projects.js +55 -0
- package/dist/commands/query.d.ts +8 -0
- package/dist/commands/query.js +86 -0
- package/dist/commands/spaces.d.ts +8 -0
- package/dist/commands/spaces.js +54 -0
- package/dist/commands/users.d.ts +9 -0
- package/dist/commands/users.js +74 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +38 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +159 -0
- package/dist/utils/client.d.ts +11 -0
- package/dist/utils/client.js +16 -0
- package/dist/utils/client.test.d.ts +1 -0
- package/dist/utils/client.test.js +30 -0
- package/package.json +24 -0
- package/src/commands/ai-agents.ts +72 -0
- package/src/commands/charts.ts +125 -0
- package/src/commands/dashboards.ts +37 -0
- package/src/commands/explores.ts +54 -0
- package/src/commands/groups.ts +84 -0
- package/src/commands/organization-roles.ts +109 -0
- package/src/commands/organization.ts +30 -0
- package/src/commands/project-access.ts +70 -0
- package/src/commands/project-role-assignments.ts +117 -0
- package/src/commands/projects.ts +52 -0
- package/src/commands/query.ts +83 -0
- package/src/commands/spaces.ts +52 -0
- package/src/commands/users.ts +73 -0
- package/src/index.test.ts +192 -0
- package/src/index.ts +41 -0
- package/src/utils/client.test.ts +37 -0
- package/src/utils/client.ts +15 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Groups command implementation.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerGroupsCommand = registerGroupsCommand;
|
|
16
|
+
const client_1 = require("../utils/client");
|
|
17
|
+
/**
|
|
18
|
+
* Registers the groups command and its subcommands.
|
|
19
|
+
* Uses client.v1.groups (typed client) per ADR-0010 and OpenSpec cli-parity-with-client.
|
|
20
|
+
*/
|
|
21
|
+
function registerGroupsCommand(program) {
|
|
22
|
+
const groupsCmd = program.command('groups').description('Manage groups');
|
|
23
|
+
groupsCmd
|
|
24
|
+
.command('list')
|
|
25
|
+
.description('List all groups in the current organization')
|
|
26
|
+
.option('--all', 'Fetch all pages and output the full list')
|
|
27
|
+
.option('--page <number>', 'Page number (1-based)', (v) => parseInt(v, 10))
|
|
28
|
+
.option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
|
|
29
|
+
.option('--search <query>', 'Search query')
|
|
30
|
+
.option('--include-members <number>', 'Include members (0 or 1)', (v) => parseInt(v, 10))
|
|
31
|
+
.action(function () {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const options = this.opts();
|
|
34
|
+
try {
|
|
35
|
+
const client = (0, client_1.getClient)();
|
|
36
|
+
if (options.all) {
|
|
37
|
+
const listParams = {};
|
|
38
|
+
if (options.search != null)
|
|
39
|
+
listParams.searchQuery = options.search;
|
|
40
|
+
if (options.includeMembers != null)
|
|
41
|
+
listParams.includeMembers = options.includeMembers;
|
|
42
|
+
const list = yield client.v1.groups.listAllGroups(Object.keys(listParams).length > 0 ? listParams : undefined);
|
|
43
|
+
console.log(JSON.stringify(list, null, 2));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const params = {};
|
|
47
|
+
if (options.page != null)
|
|
48
|
+
params.page = options.page;
|
|
49
|
+
if (options.pageSize != null)
|
|
50
|
+
params.pageSize = options.pageSize;
|
|
51
|
+
if (options.search != null)
|
|
52
|
+
params.searchQuery = options.search;
|
|
53
|
+
if (options.includeMembers != null)
|
|
54
|
+
params.includeMembers = options.includeMembers;
|
|
55
|
+
const result = yield client.v1.groups.listGroups(Object.keys(params).length > 0 ? params : undefined);
|
|
56
|
+
console.log(JSON.stringify(result, null, 2));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error('Error listing groups:', error instanceof Error ? error.message : String(error));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
groupsCmd
|
|
66
|
+
.command('get <groupUuid>')
|
|
67
|
+
.description('Get a group by UUID')
|
|
68
|
+
.action((groupUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
try {
|
|
70
|
+
const client = (0, client_1.getClient)();
|
|
71
|
+
const group = yield client.v1.groups.getGroup(groupUuid);
|
|
72
|
+
console.log(JSON.stringify(group, null, 2));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.error('Error fetching group:', error instanceof Error ? error.message : String(error));
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization roles (v2) command implementation.
|
|
3
|
+
*/
|
|
4
|
+
import type { Command } from 'commander';
|
|
5
|
+
/**
|
|
6
|
+
* Registers the organization roles subcommands under the existing organization command.
|
|
7
|
+
* Resolves org UUID via getCurrentOrganization().organizationUuid.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerOrganizationRolesCommand(program: Command): void;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Organization roles (v2) command implementation.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerOrganizationRolesCommand = registerOrganizationRolesCommand;
|
|
16
|
+
const client_1 = require("../utils/client");
|
|
17
|
+
/**
|
|
18
|
+
* Registers the organization roles subcommands under the existing organization command.
|
|
19
|
+
* Resolves org UUID via getCurrentOrganization().organizationUuid.
|
|
20
|
+
*/
|
|
21
|
+
function registerOrganizationRolesCommand(program) {
|
|
22
|
+
const orgCmd = program.commands.find((c) => c.name() === 'organization');
|
|
23
|
+
if (!orgCmd) {
|
|
24
|
+
throw new Error('organization command must be registered before organization-roles');
|
|
25
|
+
}
|
|
26
|
+
const rolesCmd = orgCmd.command('roles').description('Manage organization roles (v2)');
|
|
27
|
+
rolesCmd
|
|
28
|
+
.command('list')
|
|
29
|
+
.description('List organization roles')
|
|
30
|
+
.option('--load <value>', 'Load query param')
|
|
31
|
+
.option('--role-type-filter <value>', 'Filter by role type')
|
|
32
|
+
.action(function () {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const options = this.opts();
|
|
35
|
+
try {
|
|
36
|
+
const client = (0, client_1.getClient)();
|
|
37
|
+
const org = yield client.v1.organizations.getCurrentOrganization();
|
|
38
|
+
const orgUuid = org.organizationUuid;
|
|
39
|
+
const params = options.load != null || options.roleTypeFilter != null
|
|
40
|
+
? { load: options.load, roleTypeFilter: options.roleTypeFilter }
|
|
41
|
+
: undefined;
|
|
42
|
+
const result = yield client.v2.organizationRoles.getRoles(orgUuid, params);
|
|
43
|
+
console.log(JSON.stringify(result, null, 2));
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error('Error listing organization roles:', error instanceof Error ? error.message : String(error));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
rolesCmd
|
|
52
|
+
.command('get <roleUuid>')
|
|
53
|
+
.description('Get an organization role by UUID')
|
|
54
|
+
.action((roleUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
const client = (0, client_1.getClient)();
|
|
57
|
+
const org = yield client.v1.organizations.getCurrentOrganization();
|
|
58
|
+
const orgUuid = org.organizationUuid;
|
|
59
|
+
const role = yield client.v2.organizationRoles.getRole(orgUuid, roleUuid);
|
|
60
|
+
console.log(JSON.stringify(role, null, 2));
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error('Error fetching organization role:', error instanceof Error ? error.message : String(error));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
const assignmentsCmd = rolesCmd
|
|
68
|
+
.command('assignments')
|
|
69
|
+
.description('Organization role assignments');
|
|
70
|
+
assignmentsCmd
|
|
71
|
+
.command('list')
|
|
72
|
+
.description('List organization role assignments')
|
|
73
|
+
.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
try {
|
|
75
|
+
const client = (0, client_1.getClient)();
|
|
76
|
+
const org = yield client.v1.organizations.getCurrentOrganization();
|
|
77
|
+
const orgUuid = org.organizationUuid;
|
|
78
|
+
const result = yield client.v2.organizationRoles.listRoleAssignments(orgUuid);
|
|
79
|
+
console.log(JSON.stringify(result, null, 2));
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error('Error listing role assignments:', error instanceof Error ? error.message : String(error));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
rolesCmd
|
|
87
|
+
.command('assign <userUuid>')
|
|
88
|
+
.description('Assign an organization role to a user')
|
|
89
|
+
.requiredOption('--role-id <roleId>', 'Role ID to assign')
|
|
90
|
+
.action((userUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const options = cmd.opts();
|
|
92
|
+
try {
|
|
93
|
+
const client = (0, client_1.getClient)();
|
|
94
|
+
const org = yield client.v1.organizations.getCurrentOrganization();
|
|
95
|
+
const orgUuid = org.organizationUuid;
|
|
96
|
+
const result = yield client.v2.organizationRoles.assignRoleToUser(orgUuid, userUuid, {
|
|
97
|
+
roleId: options.roleId,
|
|
98
|
+
});
|
|
99
|
+
console.log(JSON.stringify(result, null, 2));
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
console.error('Error assigning role to user:', error instanceof Error ? error.message : String(error));
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Organization command implementation.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerOrganizationCommand = registerOrganizationCommand;
|
|
16
|
+
const client_1 = require("../utils/client");
|
|
17
|
+
/**
|
|
18
|
+
* Registers the organization command and its subcommands.
|
|
19
|
+
*/
|
|
20
|
+
function registerOrganizationCommand(program) {
|
|
21
|
+
const orgCmd = program.command('organization').description('Manage organization');
|
|
22
|
+
orgCmd
|
|
23
|
+
.command('get')
|
|
24
|
+
.description('Get current organization')
|
|
25
|
+
.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const client = (0, client_1.getClient)();
|
|
28
|
+
const org = yield client.v1.organizations.getCurrentOrganization();
|
|
29
|
+
console.log(JSON.stringify(org, null, 2));
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('Error fetching organization:', error instanceof Error ? error.message : String(error));
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project access (v1) command implementation.
|
|
3
|
+
*/
|
|
4
|
+
import type { Command } from 'commander';
|
|
5
|
+
/**
|
|
6
|
+
* Registers the projects access subcommands under the existing projects command.
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerProjectAccessCommand(program: Command): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Project access (v1) command implementation.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerProjectAccessCommand = registerProjectAccessCommand;
|
|
16
|
+
const client_1 = require("../utils/client");
|
|
17
|
+
/**
|
|
18
|
+
* Registers the projects access subcommands under the existing projects command.
|
|
19
|
+
*/
|
|
20
|
+
function registerProjectAccessCommand(program) {
|
|
21
|
+
const projectsCmd = program.commands.find((c) => c.name() === 'projects');
|
|
22
|
+
if (!projectsCmd) {
|
|
23
|
+
throw new Error('projects command must be registered before project-access');
|
|
24
|
+
}
|
|
25
|
+
const accessCmd = projectsCmd.command('access').description('Manage project access (v1)');
|
|
26
|
+
accessCmd
|
|
27
|
+
.command('list <projectUuid>')
|
|
28
|
+
.description('List users with project access')
|
|
29
|
+
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
const client = (0, client_1.getClient)();
|
|
32
|
+
const result = yield client.v1.projectAccess.listProjectAccess(projectUuid);
|
|
33
|
+
console.log(JSON.stringify(result, null, 2));
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error listing project access:', error instanceof Error ? error.message : String(error));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
const groupsCmd = accessCmd.command('groups').description('Project group access');
|
|
41
|
+
groupsCmd
|
|
42
|
+
.command('list <projectUuid>')
|
|
43
|
+
.description('List group access for a project')
|
|
44
|
+
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
const client = (0, client_1.getClient)();
|
|
47
|
+
const result = yield client.v1.projectAccess.listProjectGroupAccesses(projectUuid);
|
|
48
|
+
console.log(JSON.stringify(result, null, 2));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('Error listing project group access:', error instanceof Error ? error.message : String(error));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
accessCmd
|
|
56
|
+
.command('get <projectUuid> <userUuid>')
|
|
57
|
+
.description('Get a project member access')
|
|
58
|
+
.action((projectUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
try {
|
|
60
|
+
const client = (0, client_1.getClient)();
|
|
61
|
+
const result = yield client.v1.projectAccess.getProjectMemberAccess(projectUuid, userUuid);
|
|
62
|
+
console.log(JSON.stringify(result, null, 2));
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error('Error fetching project member access:', error instanceof Error ? error.message : String(error));
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project role assignments (v2) command implementation.
|
|
3
|
+
*/
|
|
4
|
+
import type { Command } from 'commander';
|
|
5
|
+
/**
|
|
6
|
+
* Registers the projects roles subcommands under the existing projects command.
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerProjectRoleAssignmentsCommand(program: Command): void;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Project role assignments (v2) command implementation.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerProjectRoleAssignmentsCommand = registerProjectRoleAssignmentsCommand;
|
|
16
|
+
const client_1 = require("../utils/client");
|
|
17
|
+
/**
|
|
18
|
+
* Registers the projects roles subcommands under the existing projects command.
|
|
19
|
+
*/
|
|
20
|
+
function registerProjectRoleAssignmentsCommand(program) {
|
|
21
|
+
const projectsCmd = program.commands.find((c) => c.name() === 'projects');
|
|
22
|
+
if (!projectsCmd) {
|
|
23
|
+
throw new Error('projects command must be registered before project-role-assignments');
|
|
24
|
+
}
|
|
25
|
+
const rolesCmd = projectsCmd.command('roles').description('Manage project role assignments (v2)');
|
|
26
|
+
rolesCmd
|
|
27
|
+
.command('list <projectUuid>')
|
|
28
|
+
.description('List project role assignments')
|
|
29
|
+
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
const client = (0, client_1.getClient)();
|
|
32
|
+
const result = yield client.v2.projectRoleAssignments.listAssignments(projectUuid);
|
|
33
|
+
console.log(JSON.stringify(result, null, 2));
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error listing project role assignments:', error instanceof Error ? error.message : String(error));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
const assignCmd = rolesCmd.command('assign').description('Assign role to user or group');
|
|
41
|
+
assignCmd
|
|
42
|
+
.command('user <projectUuid> <userUuid>')
|
|
43
|
+
.description('Assign a role to a user in a project')
|
|
44
|
+
.requiredOption('--role-id <roleId>', 'Role ID to assign')
|
|
45
|
+
.action((projectUuid, userUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const opts = cmd.opts();
|
|
47
|
+
try {
|
|
48
|
+
const client = (0, client_1.getClient)();
|
|
49
|
+
const result = yield client.v2.projectRoleAssignments.upsertUserAssignment(projectUuid, userUuid, { roleId: opts.roleId });
|
|
50
|
+
console.log(JSON.stringify(result, null, 2));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error('Error assigning role to user:', error instanceof Error ? error.message : String(error));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
assignCmd
|
|
58
|
+
.command('group <projectUuid> <groupId>')
|
|
59
|
+
.description('Assign a role to a group in a project')
|
|
60
|
+
.requiredOption('--role-id <roleId>', 'Role ID to assign')
|
|
61
|
+
.action((projectUuid, groupId, cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const opts = cmd.opts();
|
|
63
|
+
try {
|
|
64
|
+
const client = (0, client_1.getClient)();
|
|
65
|
+
const result = yield client.v2.projectRoleAssignments.upsertGroupAssignment(projectUuid, groupId, { roleId: opts.roleId });
|
|
66
|
+
console.log(JSON.stringify(result, null, 2));
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error('Error assigning role to group:', error instanceof Error ? error.message : String(error));
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
const unassignCmd = rolesCmd.command('unassign').description('Remove role assignment');
|
|
74
|
+
unassignCmd
|
|
75
|
+
.command('user <projectUuid> <userUuid>')
|
|
76
|
+
.description('Remove role assignment from a user')
|
|
77
|
+
.action((projectUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
try {
|
|
79
|
+
const client = (0, client_1.getClient)();
|
|
80
|
+
yield client.v2.projectRoleAssignments.deleteUserAssignment(projectUuid, userUuid);
|
|
81
|
+
console.log(JSON.stringify({ ok: true }, null, 2));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error('Error removing user role assignment:', error instanceof Error ? error.message : String(error));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
unassignCmd
|
|
89
|
+
.command('group <projectUuid> <groupId>')
|
|
90
|
+
.description('Remove role assignment from a group')
|
|
91
|
+
.action((projectUuid, groupId) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
try {
|
|
93
|
+
const client = (0, client_1.getClient)();
|
|
94
|
+
yield client.v2.projectRoleAssignments.deleteGroupAssignment(projectUuid, groupId);
|
|
95
|
+
console.log(JSON.stringify({ ok: true }, null, 2));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error('Error removing group role assignment:', error instanceof Error ? error.message : String(error));
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Projects command implementation.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerProjectsCommand = registerProjectsCommand;
|
|
16
|
+
const client_1 = require("../utils/client");
|
|
17
|
+
/**
|
|
18
|
+
* Registers the projects command and its subcommands.
|
|
19
|
+
*/
|
|
20
|
+
function registerProjectsCommand(program) {
|
|
21
|
+
const projectsCmd = program.command('projects').description('Manage projects');
|
|
22
|
+
projectsCmd
|
|
23
|
+
.command('get')
|
|
24
|
+
.description('Get a project by UUID')
|
|
25
|
+
.argument('<projectUuid>', 'Project UUID')
|
|
26
|
+
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
try {
|
|
28
|
+
if (!projectUuid) {
|
|
29
|
+
console.error('Error: projectUuid is required');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
const client = (0, client_1.getClient)();
|
|
33
|
+
const project = yield client.v1.projects.getProject(projectUuid);
|
|
34
|
+
console.log(JSON.stringify(project, null, 2));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error('Error fetching project:', error instanceof Error ? error.message : String(error));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
projectsCmd
|
|
42
|
+
.command('list')
|
|
43
|
+
.description('List all projects in the current organization')
|
|
44
|
+
.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
const client = (0, client_1.getClient)();
|
|
47
|
+
const projects = yield client.v1.projects.listProjects();
|
|
48
|
+
console.log(JSON.stringify(projects, null, 2));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('Error listing projects:', error instanceof Error ? error.message : String(error));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Query command implementation.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerQueryCommand = registerQueryCommand;
|
|
16
|
+
const fs_1 = require("fs");
|
|
17
|
+
const client_1 = require("../utils/client");
|
|
18
|
+
/**
|
|
19
|
+
* Reads JSON from stdin or a file.
|
|
20
|
+
*/
|
|
21
|
+
function readJsonInput(filePath) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (filePath) {
|
|
24
|
+
const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
|
|
25
|
+
return JSON.parse(content);
|
|
26
|
+
}
|
|
27
|
+
// Read from stdin
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
// Check if stdin is a TTY (interactive terminal)
|
|
30
|
+
if (process.stdin.isTTY) {
|
|
31
|
+
reject(new Error('No input provided. Use --file <path> or pipe JSON to stdin.'));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const chunks = [];
|
|
35
|
+
process.stdin.setEncoding('utf8');
|
|
36
|
+
process.stdin.on('data', (chunk) => {
|
|
37
|
+
chunks.push(Buffer.from(chunk));
|
|
38
|
+
});
|
|
39
|
+
process.stdin.on('end', () => {
|
|
40
|
+
try {
|
|
41
|
+
const input = Buffer.concat(chunks).toString('utf-8');
|
|
42
|
+
resolve(JSON.parse(input));
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
reject(new Error(`Failed to parse JSON: ${err instanceof Error ? err.message : String(err)}`));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
process.stdin.on('error', (err) => {
|
|
49
|
+
reject(err);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Registers the query command and its subcommands.
|
|
56
|
+
*/
|
|
57
|
+
function registerQueryCommand(program) {
|
|
58
|
+
const queryCmd = program.command('query').description('Query operations');
|
|
59
|
+
queryCmd
|
|
60
|
+
.command('compile')
|
|
61
|
+
.description('Compile a metric query for an explore')
|
|
62
|
+
.argument('<projectUuid>', 'Project UUID')
|
|
63
|
+
.argument('<exploreId>', 'Explore ID')
|
|
64
|
+
.option('--file <path>', 'Read metric query JSON from file (default: read from stdin)')
|
|
65
|
+
.action((projectUuid, exploreId, options) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
if (!projectUuid) {
|
|
68
|
+
console.error('Error: projectUuid is required');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
if (!exploreId) {
|
|
72
|
+
console.error('Error: exploreId is required');
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
// Read JSON input
|
|
76
|
+
const body = (yield readJsonInput(options.file));
|
|
77
|
+
const client = (0, client_1.getClient)();
|
|
78
|
+
const result = yield client.v1.query.compileQuery(projectUuid, exploreId, body);
|
|
79
|
+
console.log(JSON.stringify(result, null, 2));
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error('Error compiling query:', error instanceof Error ? error.message : String(error));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Spaces (v1) command implementation.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerSpacesCommand = registerSpacesCommand;
|
|
16
|
+
const client_1 = require("../utils/client");
|
|
17
|
+
/**
|
|
18
|
+
* Registers the projects spaces subcommands under the existing projects command.
|
|
19
|
+
*/
|
|
20
|
+
function registerSpacesCommand(program) {
|
|
21
|
+
const projectsCmd = program.commands.find((c) => c.name() === 'projects');
|
|
22
|
+
if (!projectsCmd) {
|
|
23
|
+
throw new Error('projects command must be registered before spaces');
|
|
24
|
+
}
|
|
25
|
+
const spacesCmd = projectsCmd.command('spaces').description('Manage project spaces (v1)');
|
|
26
|
+
spacesCmd
|
|
27
|
+
.command('list <projectUuid>')
|
|
28
|
+
.description('List spaces in a project')
|
|
29
|
+
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
const client = (0, client_1.getClient)();
|
|
32
|
+
const result = yield client.v1.spaces.listSpacesInProject(projectUuid);
|
|
33
|
+
console.log(JSON.stringify(result, null, 2));
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error listing spaces:', error instanceof Error ? error.message : String(error));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
spacesCmd
|
|
41
|
+
.command('get <projectUuid> <spaceUuid>')
|
|
42
|
+
.description('Get a space by UUID')
|
|
43
|
+
.action((projectUuid, spaceUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
try {
|
|
45
|
+
const client = (0, client_1.getClient)();
|
|
46
|
+
const result = yield client.v1.spaces.getSpace(projectUuid, spaceUuid);
|
|
47
|
+
console.log(JSON.stringify(result, null, 2));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('Error fetching space:', error instanceof Error ? error.message : String(error));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
}
|