@lightdash-tools/cli 0.1.2 → 0.2.4
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 +84 -18
- 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/index.test.js +6 -0
- 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.test.ts +7 -0
- 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
|
|
|
@@ -25,6 +25,7 @@ The CLI requires the following environment variables (consistent with `@lightdas
|
|
|
25
25
|
- `LIGHTDASH_URL` - Lightdash server base URL (e.g., `https://app.lightdash.cloud`)
|
|
26
26
|
- `LIGHTDASH_API_KEY` - Personal access token (PAT)
|
|
27
27
|
- `LIGHTDASH_PROXY_AUTHORIZATION` - Optional proxy authorization header
|
|
28
|
+
- `LIGHTDASH_TOOL_SAFETY_MODE` - Optional safety mode (`read-only`, `write-idempotent`, `write-destructive`)
|
|
28
29
|
|
|
29
30
|
Example:
|
|
30
31
|
|
|
@@ -41,6 +42,7 @@ The CLI provides subcommands grouped by domain. All commands output JSON by defa
|
|
|
41
42
|
|
|
42
43
|
```bash
|
|
43
44
|
lightdash-tools organization get
|
|
45
|
+
lightdash-tools organization-roles list
|
|
44
46
|
```
|
|
45
47
|
|
|
46
48
|
#### Projects
|
|
@@ -48,46 +50,62 @@ lightdash-tools organization get
|
|
|
48
50
|
```bash
|
|
49
51
|
lightdash-tools projects list
|
|
50
52
|
lightdash-tools projects get <projectUuid>
|
|
53
|
+
lightdash-tools projects validate run <projectUuid>
|
|
54
|
+
lightdash-tools projects validate results <projectUuid>
|
|
51
55
|
```
|
|
52
56
|
|
|
53
|
-
#### Explores
|
|
57
|
+
#### Explores (Project-level)
|
|
54
58
|
|
|
55
59
|
```bash
|
|
56
|
-
lightdash-tools explores list <projectUuid>
|
|
57
|
-
lightdash-tools explores get <projectUuid> <exploreId>
|
|
60
|
+
lightdash-tools projects explores list <projectUuid>
|
|
61
|
+
lightdash-tools projects explores get <projectUuid> <exploreId>
|
|
62
|
+
lightdash-tools projects explores dimensions <projectUuid> <exploreId>
|
|
63
|
+
lightdash-tools projects explores lineage <projectUuid> <exploreId> <fieldId>
|
|
58
64
|
```
|
|
59
65
|
|
|
60
|
-
#### Charts
|
|
66
|
+
#### Charts (Project-level)
|
|
61
67
|
|
|
62
68
|
```bash
|
|
63
|
-
lightdash-tools charts list <projectUuid>
|
|
64
|
-
lightdash-tools charts
|
|
65
|
-
lightdash-tools charts
|
|
69
|
+
lightdash-tools projects charts list <projectUuid>
|
|
70
|
+
lightdash-tools projects charts code list <projectUuid> --ids <slugs...>
|
|
71
|
+
lightdash-tools projects charts code upsert <projectUuid> <slug> --file <chart.json>
|
|
66
72
|
```
|
|
67
73
|
|
|
68
|
-
#### Dashboards
|
|
74
|
+
#### Dashboards (Project-level)
|
|
69
75
|
|
|
70
76
|
```bash
|
|
71
|
-
lightdash-tools dashboards list <projectUuid>
|
|
77
|
+
lightdash-tools projects dashboards list <projectUuid>
|
|
72
78
|
```
|
|
73
79
|
|
|
74
|
-
#### Spaces
|
|
80
|
+
#### Spaces (Project-level)
|
|
75
81
|
|
|
76
82
|
```bash
|
|
77
|
-
lightdash-tools spaces list <projectUuid>
|
|
78
|
-
lightdash-tools spaces get <projectUuid> <spaceUuid>
|
|
83
|
+
lightdash-tools projects spaces list <projectUuid>
|
|
84
|
+
lightdash-tools projects spaces get <projectUuid> <spaceUuid>
|
|
79
85
|
```
|
|
80
86
|
|
|
81
|
-
#### Groups
|
|
87
|
+
#### Users & Groups
|
|
82
88
|
|
|
83
89
|
```bash
|
|
90
|
+
lightdash-tools users list
|
|
91
|
+
lightdash-tools users get <userUuid>
|
|
84
92
|
lightdash-tools groups list
|
|
85
93
|
```
|
|
86
94
|
|
|
87
|
-
####
|
|
95
|
+
#### Metrics & Schedulers
|
|
88
96
|
|
|
89
97
|
```bash
|
|
90
|
-
lightdash-tools
|
|
98
|
+
lightdash-tools metrics list <projectUuid>
|
|
99
|
+
lightdash-tools metrics get <projectUuid> <tableName> <metricName>
|
|
100
|
+
lightdash-tools schedulers list <projectUuid>
|
|
101
|
+
lightdash-tools schedulers get <schedulerUuid>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Tags
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
lightdash-tools tags list <projectUuid>
|
|
108
|
+
lightdash-tools tags get <projectUuid> <tagUuid>
|
|
91
109
|
```
|
|
92
110
|
|
|
93
111
|
#### Query
|
|
@@ -96,6 +114,25 @@ lightdash-tools users list
|
|
|
96
114
|
lightdash-tools query compile <projectUuid> <exploreId> --file <query.json>
|
|
97
115
|
```
|
|
98
116
|
|
|
117
|
+
#### Content (Experimental)
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
lightdash-tools content search "query"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### AI Agents
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
lightdash-tools ai-agents list
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Access Control (Project-level)
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
lightdash-tools projects project-access list <projectUuid>
|
|
133
|
+
lightdash-tools projects project-role-assignments list <projectUuid>
|
|
134
|
+
```
|
|
135
|
+
|
|
99
136
|
### Help
|
|
100
137
|
|
|
101
138
|
Get help for any command:
|
|
@@ -103,13 +140,42 @@ Get help for any command:
|
|
|
103
140
|
```bash
|
|
104
141
|
lightdash-tools --help
|
|
105
142
|
lightdash-tools projects --help
|
|
106
|
-
lightdash-tools charts --help
|
|
143
|
+
lightdash-tools projects charts --help
|
|
107
144
|
```
|
|
108
145
|
|
|
109
146
|
## Output Format
|
|
110
147
|
|
|
111
148
|
All commands output JSON by default, formatted with 2-space indentation.
|
|
112
149
|
|
|
150
|
+
## Safety Modes
|
|
151
|
+
|
|
152
|
+
The CLI implements a hierarchical safety model to prevent accidental destructive operations. This is the same model used by the Lightdash MCP server.
|
|
153
|
+
|
|
154
|
+
### Configuration
|
|
155
|
+
|
|
156
|
+
You can control the safety mode via the `LIGHTDASH_TOOL_SAFETY_MODE` environment variable or the global `--safety-mode` flag.
|
|
157
|
+
|
|
158
|
+
- `read-only`: Only allows non-modifying operations (e.g., list, get).
|
|
159
|
+
- `write-idempotent`: Allows read operations and non-destructive writes (e.g., upsert, validate run).
|
|
160
|
+
- `write-destructive` (default): Allows all operations, including deletions.
|
|
161
|
+
|
|
162
|
+
### Enforcement
|
|
163
|
+
|
|
164
|
+
The CLI uses **Dynamic Enforcement**: all commands remain visible in help, but if you attempt to execute a command that is forbidden in the current mode, the CLI will exit with an error message.
|
|
165
|
+
|
|
166
|
+
Example:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# This will work
|
|
170
|
+
lightdash-tools --safety-mode read-only users list
|
|
171
|
+
|
|
172
|
+
# This will fail if delete was implemented
|
|
173
|
+
lightdash-tools --safety-mode read-only users delete <uuid>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
When a command is blocked, you will see an error like:
|
|
177
|
+
`Error: This command is disabled in read-only mode. To enable it, use --safety-mode or set LIGHTDASH_TOOL_SAFETY_MODE.`
|
|
178
|
+
|
|
113
179
|
## Error Handling
|
|
114
180
|
|
|
115
181
|
The CLI provides helpful error messages for:
|
|
@@ -125,7 +191,7 @@ If you are developing the CLI itself:
|
|
|
125
191
|
1. Install dependencies: `pnpm install`
|
|
126
192
|
2. Build: `pnpm build`
|
|
127
193
|
3. Run tests: `pnpm test`
|
|
128
|
-
4. Run locally: `node dist/index.
|
|
194
|
+
4. Run locally: `node dist/index.js`
|
|
129
195
|
|
|
130
196
|
## License
|
|
131
197
|
|
|
@@ -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
|
}
|