@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
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Lightdash AI CLI
|
|
1
|
+
# Lightdash AI CLI ([@lightdash-tools/cli](https://www.npmjs.com/package/@lightdash-tools/cli)) <!-- markdown-link-check-disable-line -->
|
|
2
2
|
|
|
3
3
|
Command-line interface for interacting with the Lightdash API.
|
|
4
4
|
|
|
@@ -90,6 +90,54 @@ lightdash-tools groups list
|
|
|
90
90
|
lightdash-tools users list
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
#### Metrics
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
lightdash-tools metrics list <projectUuid>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Schedulers
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
lightdash-tools schedulers list <projectUuid>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Tags
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
lightdash-tools tags list <projectUuid>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Content (Experimental)
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
lightdash-tools content search "query"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### AI Agents
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
lightdash-tools ai-agents list
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Project Access
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
lightdash-tools project-access list <projectUuid>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Organization Roles
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
lightdash-tools organization-roles list
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### Project Role Assignments
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
lightdash-tools project-role-assignments list <projectUuid>
|
|
139
|
+
```
|
|
140
|
+
|
|
93
141
|
#### Query
|
|
94
142
|
|
|
95
143
|
```bash
|
|
@@ -13,7 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerAiAgentsCommand = registerAiAgentsCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
16
17
|
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
17
19
|
/**
|
|
18
20
|
* Registers the top-level ai-agents command and its subcommands.
|
|
19
21
|
*/
|
|
@@ -22,7 +24,7 @@ function registerAiAgentsCommand(program) {
|
|
|
22
24
|
aiAgentsCmd
|
|
23
25
|
.command('list')
|
|
24
26
|
.description('List all AI agents (admin)')
|
|
25
|
-
.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
|
|
26
28
|
try {
|
|
27
29
|
const client = (0, client_1.getClient)();
|
|
28
30
|
const result = yield client.v1.aiAgents.listAdminAgents();
|
|
@@ -32,13 +34,13 @@ function registerAiAgentsCommand(program) {
|
|
|
32
34
|
console.error('Error listing AI agents:', error instanceof Error ? error.message : String(error));
|
|
33
35
|
process.exit(1);
|
|
34
36
|
}
|
|
35
|
-
}));
|
|
37
|
+
})));
|
|
36
38
|
aiAgentsCmd
|
|
37
39
|
.command('threads')
|
|
38
40
|
.description('List AI agent threads (admin)')
|
|
39
41
|
.option('--page <number>', 'Page number', (v) => parseInt(v, 10))
|
|
40
42
|
.option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
|
|
41
|
-
.action(function () {
|
|
43
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
|
|
42
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
45
|
const options = this.opts();
|
|
44
46
|
try {
|
|
@@ -56,11 +58,11 @@ function registerAiAgentsCommand(program) {
|
|
|
56
58
|
process.exit(1);
|
|
57
59
|
}
|
|
58
60
|
});
|
|
59
|
-
});
|
|
61
|
+
}));
|
|
60
62
|
aiAgentsCmd
|
|
61
63
|
.command('settings')
|
|
62
64
|
.description('Get AI organization settings')
|
|
63
|
-
.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
|
|
64
66
|
try {
|
|
65
67
|
const client = (0, client_1.getClient)();
|
|
66
68
|
const result = yield client.v1.aiAgents.getAiOrganizationSettings();
|
|
@@ -70,5 +72,5 @@ function registerAiAgentsCommand(program) {
|
|
|
70
72
|
console.error('Error fetching AI organization settings:', error instanceof Error ? error.message : String(error));
|
|
71
73
|
process.exit(1);
|
|
72
74
|
}
|
|
73
|
-
}));
|
|
75
|
+
})));
|
|
74
76
|
}
|
package/dist/commands/charts.js
CHANGED
|
@@ -14,7 +14,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerChartsCommand = registerChartsCommand;
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
|
+
const common_1 = require("@lightdash-tools/common");
|
|
17
18
|
const client_1 = require("../utils/client");
|
|
19
|
+
const safety_1 = require("../utils/safety");
|
|
18
20
|
/**
|
|
19
21
|
* Reads JSON from stdin or a file (for chart-as-code upsert body).
|
|
20
22
|
*/
|
|
@@ -63,7 +65,7 @@ function registerChartsCommand(program) {
|
|
|
63
65
|
chartsCmd
|
|
64
66
|
.command('list <projectUuid>')
|
|
65
67
|
.description('List charts in a project')
|
|
66
|
-
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
67
69
|
try {
|
|
68
70
|
const client = (0, client_1.getClient)();
|
|
69
71
|
const result = yield client.v1.charts.listCharts(projectUuid);
|
|
@@ -73,7 +75,7 @@ function registerChartsCommand(program) {
|
|
|
73
75
|
console.error('Error listing charts:', error instanceof Error ? error.message : String(error));
|
|
74
76
|
process.exit(1);
|
|
75
77
|
}
|
|
76
|
-
}));
|
|
78
|
+
})));
|
|
77
79
|
const codeCmd = chartsCmd
|
|
78
80
|
.command('code')
|
|
79
81
|
.description('Charts as code (get list, upsert by slug)');
|
|
@@ -83,7 +85,7 @@ function registerChartsCommand(program) {
|
|
|
83
85
|
.option('--ids <ids...>', 'Filter by chart IDs (slugs)')
|
|
84
86
|
.option('--offset <number>', 'Pagination offset', (v) => parseInt(v, 10))
|
|
85
87
|
.option('--language-map', 'Include language map in response')
|
|
86
|
-
.action((projectUuid, options) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, options) => __awaiter(this, void 0, void 0, function* () {
|
|
87
89
|
try {
|
|
88
90
|
const client = (0, client_1.getClient)();
|
|
89
91
|
const result = yield client.v1.charts.getChartsAsCode(projectUuid, {
|
|
@@ -97,12 +99,12 @@ function registerChartsCommand(program) {
|
|
|
97
99
|
console.error('Error getting charts as code:', error instanceof Error ? error.message : String(error));
|
|
98
100
|
process.exit(1);
|
|
99
101
|
}
|
|
100
|
-
}));
|
|
102
|
+
})));
|
|
101
103
|
codeCmd
|
|
102
104
|
.command('upsert <projectUuid> <slug>')
|
|
103
105
|
.description('Upsert a chart from code (body from --file or stdin)')
|
|
104
106
|
.option('--file <path>', 'Read chart JSON from file (default: stdin)')
|
|
105
|
-
.action((projectUuid, slug, options) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
.action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid, slug, options) => __awaiter(this, void 0, void 0, function* () {
|
|
106
108
|
try {
|
|
107
109
|
const body = yield readChartJsonInput(options.file);
|
|
108
110
|
const client = (0, client_1.getClient)();
|
|
@@ -113,5 +115,5 @@ function registerChartsCommand(program) {
|
|
|
113
115
|
console.error('Error upserting chart as code:', error instanceof Error ? error.message : String(error));
|
|
114
116
|
process.exit(1);
|
|
115
117
|
}
|
|
116
|
-
}));
|
|
118
|
+
})));
|
|
117
119
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Content 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.registerContentCommand = registerContentCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
17
|
+
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
19
|
+
/**
|
|
20
|
+
* Registers the content command and its subcommands.
|
|
21
|
+
*/
|
|
22
|
+
function registerContentCommand(program) {
|
|
23
|
+
const contentCmd = program.command('content').description('Manage project content');
|
|
24
|
+
contentCmd
|
|
25
|
+
.command('search <query>')
|
|
26
|
+
.description('Search project content (charts, dashboards, spaces)')
|
|
27
|
+
.option('--project <uuids...>', 'Filter by project UUIDs')
|
|
28
|
+
.option('--type <types...>', 'Filter by content types (chart, dashboard, space)')
|
|
29
|
+
.option('--page <number>', 'Page number', (v) => parseInt(v, 10))
|
|
30
|
+
.option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
|
|
31
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (query, options) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
try {
|
|
33
|
+
const client = (0, client_1.getClient)();
|
|
34
|
+
const result = yield client.v2.content.searchContent({
|
|
35
|
+
search: query,
|
|
36
|
+
projectUuids: options.project,
|
|
37
|
+
contentTypes: options.type,
|
|
38
|
+
page: options.page,
|
|
39
|
+
pageSize: options.pageSize,
|
|
40
|
+
});
|
|
41
|
+
console.log(JSON.stringify(result, null, 2));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error('Error searching content:', error instanceof Error ? error.message : String(error));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
@@ -13,7 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerDashboardsCommand = registerDashboardsCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
16
17
|
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
17
19
|
/**
|
|
18
20
|
* Registers the projects dashboards subcommands under the existing projects command.
|
|
19
21
|
*/
|
|
@@ -28,7 +30,7 @@ function registerDashboardsCommand(program) {
|
|
|
28
30
|
dashboardsCmd
|
|
29
31
|
.command('list <projectUuid>')
|
|
30
32
|
.description('List dashboards in a project')
|
|
31
|
-
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
32
34
|
try {
|
|
33
35
|
const client = (0, client_1.getClient)();
|
|
34
36
|
const result = yield client.v1.dashboards.listDashboards(projectUuid);
|
|
@@ -38,5 +40,5 @@ function registerDashboardsCommand(program) {
|
|
|
38
40
|
console.error('Error listing dashboards:', error instanceof Error ? error.message : String(error));
|
|
39
41
|
process.exit(1);
|
|
40
42
|
}
|
|
41
|
-
}));
|
|
43
|
+
})));
|
|
42
44
|
}
|
|
@@ -13,7 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerExploresCommand = registerExploresCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
16
17
|
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
17
19
|
/**
|
|
18
20
|
* Registers the projects explores subcommands under the existing projects command.
|
|
19
21
|
*/
|
|
@@ -28,7 +30,7 @@ function registerExploresCommand(program) {
|
|
|
28
30
|
exploresCmd
|
|
29
31
|
.command('list <projectUuid>')
|
|
30
32
|
.description('List explores in a project')
|
|
31
|
-
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
32
34
|
try {
|
|
33
35
|
const client = (0, client_1.getClient)();
|
|
34
36
|
const result = yield client.v1.explores.listExplores(projectUuid);
|
|
@@ -38,11 +40,11 @@ function registerExploresCommand(program) {
|
|
|
38
40
|
console.error('Error listing explores:', error instanceof Error ? error.message : String(error));
|
|
39
41
|
process.exit(1);
|
|
40
42
|
}
|
|
41
|
-
}));
|
|
43
|
+
})));
|
|
42
44
|
exploresCmd
|
|
43
45
|
.command('get <projectUuid> <exploreId>')
|
|
44
46
|
.description('Get an explore by ID')
|
|
45
|
-
.action((projectUuid, exploreId) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, exploreId) => __awaiter(this, void 0, void 0, function* () {
|
|
46
48
|
try {
|
|
47
49
|
const client = (0, client_1.getClient)();
|
|
48
50
|
const result = yield client.v1.explores.getExplore(projectUuid, exploreId);
|
|
@@ -52,5 +54,33 @@ function registerExploresCommand(program) {
|
|
|
52
54
|
console.error('Error fetching explore:', error instanceof Error ? error.message : String(error));
|
|
53
55
|
process.exit(1);
|
|
54
56
|
}
|
|
55
|
-
}));
|
|
57
|
+
})));
|
|
58
|
+
exploresCmd
|
|
59
|
+
.command('dimensions <projectUuid> <exploreId>')
|
|
60
|
+
.description('List dimensions for an explore')
|
|
61
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, exploreId) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
try {
|
|
63
|
+
const client = (0, client_1.getClient)();
|
|
64
|
+
const result = yield client.v1.explores.listDimensions(projectUuid, exploreId);
|
|
65
|
+
console.log(JSON.stringify(result, null, 2));
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('Error listing dimensions:', error instanceof Error ? error.message : String(error));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
})));
|
|
72
|
+
exploresCmd
|
|
73
|
+
.command('lineage <projectUuid> <exploreId> <fieldId>')
|
|
74
|
+
.description('Get lineage for a field in an explore')
|
|
75
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, exploreId, fieldId) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
try {
|
|
77
|
+
const client = (0, client_1.getClient)();
|
|
78
|
+
const result = yield client.v1.explores.getFieldLineage(projectUuid, exploreId, fieldId);
|
|
79
|
+
console.log(JSON.stringify(result, null, 2));
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error('Error fetching lineage:', error instanceof Error ? error.message : String(error));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
})));
|
|
56
86
|
}
|
package/dist/commands/groups.js
CHANGED
|
@@ -13,7 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerGroupsCommand = registerGroupsCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
16
17
|
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
17
19
|
/**
|
|
18
20
|
* Registers the groups command and its subcommands.
|
|
19
21
|
* Uses client.v1.groups (typed client) per ADR-0010 and OpenSpec cli-parity-with-client.
|
|
@@ -28,7 +30,7 @@ function registerGroupsCommand(program) {
|
|
|
28
30
|
.option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
|
|
29
31
|
.option('--search <query>', 'Search query')
|
|
30
32
|
.option('--include-members <number>', 'Include members (0 or 1)', (v) => parseInt(v, 10))
|
|
31
|
-
.action(function () {
|
|
33
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
|
|
32
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
35
|
const options = this.opts();
|
|
34
36
|
try {
|
|
@@ -61,11 +63,11 @@ function registerGroupsCommand(program) {
|
|
|
61
63
|
process.exit(1);
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
|
-
});
|
|
66
|
+
}));
|
|
65
67
|
groupsCmd
|
|
66
68
|
.command('get <groupUuid>')
|
|
67
69
|
.description('Get a group by UUID')
|
|
68
|
-
.action((groupUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (groupUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
69
71
|
try {
|
|
70
72
|
const client = (0, client_1.getClient)();
|
|
71
73
|
const group = yield client.v1.groups.getGroup(groupUuid);
|
|
@@ -75,5 +77,5 @@ function registerGroupsCommand(program) {
|
|
|
75
77
|
console.error('Error fetching group:', error instanceof Error ? error.message : String(error));
|
|
76
78
|
process.exit(1);
|
|
77
79
|
}
|
|
78
|
-
}));
|
|
80
|
+
})));
|
|
79
81
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Metrics 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.registerMetricsCommand = registerMetricsCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
17
|
+
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
19
|
+
/**
|
|
20
|
+
* Registers the metrics command and its subcommands.
|
|
21
|
+
*/
|
|
22
|
+
function registerMetricsCommand(program) {
|
|
23
|
+
const metricsCmd = program.command('metrics').description('Manage metrics');
|
|
24
|
+
metricsCmd
|
|
25
|
+
.command('list <projectUuid>')
|
|
26
|
+
.description('List metrics in a project')
|
|
27
|
+
.option('--search <query>', 'Search query')
|
|
28
|
+
.option('--page <number>', 'Page number', (v) => parseInt(v, 10))
|
|
29
|
+
.option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
|
|
30
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, options) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
try {
|
|
32
|
+
const client = (0, client_1.getClient)();
|
|
33
|
+
const result = yield client.v1.metrics.listMetrics(projectUuid, {
|
|
34
|
+
search: options.search,
|
|
35
|
+
page: options.page,
|
|
36
|
+
pageSize: options.pageSize,
|
|
37
|
+
});
|
|
38
|
+
console.log(JSON.stringify(result, null, 2));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error('Error listing metrics:', error instanceof Error ? error.message : String(error));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
})));
|
|
45
|
+
metricsCmd
|
|
46
|
+
.command('get <projectUuid> <tableName> <metricName>')
|
|
47
|
+
.description('Get a metric by table and name')
|
|
48
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, tableName, metricName) => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
try {
|
|
50
|
+
const client = (0, client_1.getClient)();
|
|
51
|
+
const result = yield client.v1.metrics.getMetric(projectUuid, tableName, metricName);
|
|
52
|
+
console.log(JSON.stringify(result, null, 2));
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error('Error fetching metric:', error instanceof Error ? error.message : String(error));
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
@@ -13,7 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerOrganizationRolesCommand = registerOrganizationRolesCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
16
17
|
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
17
19
|
/**
|
|
18
20
|
* Registers the organization roles subcommands under the existing organization command.
|
|
19
21
|
* Resolves org UUID via getCurrentOrganization().organizationUuid.
|
|
@@ -29,7 +31,7 @@ function registerOrganizationRolesCommand(program) {
|
|
|
29
31
|
.description('List organization roles')
|
|
30
32
|
.option('--load <value>', 'Load query param')
|
|
31
33
|
.option('--role-type-filter <value>', 'Filter by role type')
|
|
32
|
-
.action(function () {
|
|
34
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
|
|
33
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
36
|
const options = this.opts();
|
|
35
37
|
try {
|
|
@@ -47,11 +49,11 @@ function registerOrganizationRolesCommand(program) {
|
|
|
47
49
|
process.exit(1);
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
|
-
});
|
|
52
|
+
}));
|
|
51
53
|
rolesCmd
|
|
52
54
|
.command('get <roleUuid>')
|
|
53
55
|
.description('Get an organization role by UUID')
|
|
54
|
-
.action((roleUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (roleUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
55
57
|
try {
|
|
56
58
|
const client = (0, client_1.getClient)();
|
|
57
59
|
const org = yield client.v1.organizations.getCurrentOrganization();
|
|
@@ -63,14 +65,14 @@ function registerOrganizationRolesCommand(program) {
|
|
|
63
65
|
console.error('Error fetching organization role:', error instanceof Error ? error.message : String(error));
|
|
64
66
|
process.exit(1);
|
|
65
67
|
}
|
|
66
|
-
}));
|
|
68
|
+
})));
|
|
67
69
|
const assignmentsCmd = rolesCmd
|
|
68
70
|
.command('assignments')
|
|
69
71
|
.description('Organization role assignments');
|
|
70
72
|
assignmentsCmd
|
|
71
73
|
.command('list')
|
|
72
74
|
.description('List organization role assignments')
|
|
73
|
-
.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
|
|
74
76
|
try {
|
|
75
77
|
const client = (0, client_1.getClient)();
|
|
76
78
|
const org = yield client.v1.organizations.getCurrentOrganization();
|
|
@@ -82,12 +84,12 @@ function registerOrganizationRolesCommand(program) {
|
|
|
82
84
|
console.error('Error listing role assignments:', error instanceof Error ? error.message : String(error));
|
|
83
85
|
process.exit(1);
|
|
84
86
|
}
|
|
85
|
-
}));
|
|
87
|
+
})));
|
|
86
88
|
rolesCmd
|
|
87
89
|
.command('assign <userUuid>')
|
|
88
90
|
.description('Assign an organization role to a user')
|
|
89
91
|
.requiredOption('--role-id <roleId>', 'Role ID to assign')
|
|
90
|
-
.action((userUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
.action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (userUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
91
93
|
const options = cmd.opts();
|
|
92
94
|
try {
|
|
93
95
|
const client = (0, client_1.getClient)();
|
|
@@ -102,5 +104,5 @@ function registerOrganizationRolesCommand(program) {
|
|
|
102
104
|
console.error('Error assigning role to user:', error instanceof Error ? error.message : String(error));
|
|
103
105
|
process.exit(1);
|
|
104
106
|
}
|
|
105
|
-
}));
|
|
107
|
+
})));
|
|
106
108
|
}
|
|
@@ -13,7 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerOrganizationCommand = registerOrganizationCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
16
17
|
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
17
19
|
/**
|
|
18
20
|
* Registers the organization command and its subcommands.
|
|
19
21
|
*/
|
|
@@ -22,7 +24,7 @@ function registerOrganizationCommand(program) {
|
|
|
22
24
|
orgCmd
|
|
23
25
|
.command('get')
|
|
24
26
|
.description('Get current organization')
|
|
25
|
-
.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
|
|
26
28
|
try {
|
|
27
29
|
const client = (0, client_1.getClient)();
|
|
28
30
|
const org = yield client.v1.organizations.getCurrentOrganization();
|
|
@@ -32,5 +34,5 @@ function registerOrganizationCommand(program) {
|
|
|
32
34
|
console.error('Error fetching organization:', error instanceof Error ? error.message : String(error));
|
|
33
35
|
process.exit(1);
|
|
34
36
|
}
|
|
35
|
-
}));
|
|
37
|
+
})));
|
|
36
38
|
}
|
|
@@ -13,7 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerProjectAccessCommand = registerProjectAccessCommand;
|
|
16
|
+
const common_1 = require("@lightdash-tools/common");
|
|
16
17
|
const client_1 = require("../utils/client");
|
|
18
|
+
const safety_1 = require("../utils/safety");
|
|
17
19
|
/**
|
|
18
20
|
* Registers the projects access subcommands under the existing projects command.
|
|
19
21
|
*/
|
|
@@ -26,7 +28,7 @@ function registerProjectAccessCommand(program) {
|
|
|
26
28
|
accessCmd
|
|
27
29
|
.command('list <projectUuid>')
|
|
28
30
|
.description('List users with project access')
|
|
29
|
-
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
30
32
|
try {
|
|
31
33
|
const client = (0, client_1.getClient)();
|
|
32
34
|
const result = yield client.v1.projectAccess.listProjectAccess(projectUuid);
|
|
@@ -36,12 +38,12 @@ function registerProjectAccessCommand(program) {
|
|
|
36
38
|
console.error('Error listing project access:', error instanceof Error ? error.message : String(error));
|
|
37
39
|
process.exit(1);
|
|
38
40
|
}
|
|
39
|
-
}));
|
|
41
|
+
})));
|
|
40
42
|
const groupsCmd = accessCmd.command('groups').description('Project group access');
|
|
41
43
|
groupsCmd
|
|
42
44
|
.command('list <projectUuid>')
|
|
43
45
|
.description('List group access for a project')
|
|
44
|
-
.action((projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
45
47
|
try {
|
|
46
48
|
const client = (0, client_1.getClient)();
|
|
47
49
|
const result = yield client.v1.projectAccess.listProjectGroupAccesses(projectUuid);
|
|
@@ -51,11 +53,11 @@ function registerProjectAccessCommand(program) {
|
|
|
51
53
|
console.error('Error listing project group access:', error instanceof Error ? error.message : String(error));
|
|
52
54
|
process.exit(1);
|
|
53
55
|
}
|
|
54
|
-
}));
|
|
56
|
+
})));
|
|
55
57
|
accessCmd
|
|
56
58
|
.command('get <projectUuid> <userUuid>')
|
|
57
59
|
.description('Get a project member access')
|
|
58
|
-
.action((projectUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
|
|
59
61
|
try {
|
|
60
62
|
const client = (0, client_1.getClient)();
|
|
61
63
|
const result = yield client.v1.projectAccess.getProjectMemberAccess(projectUuid, userUuid);
|
|
@@ -65,5 +67,5 @@ function registerProjectAccessCommand(program) {
|
|
|
65
67
|
console.error('Error fetching project member access:', error instanceof Error ? error.message : String(error));
|
|
66
68
|
process.exit(1);
|
|
67
69
|
}
|
|
68
|
-
}));
|
|
70
|
+
})));
|
|
69
71
|
}
|