@lightdash-tools/cli 0.2.5 → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * AI agents (v1) command implementation.
3
+ * AI agents (v1) command implementation — admin endpoints.
4
4
  */
5
5
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
6
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -17,13 +17,15 @@ const common_1 = require("@lightdash-tools/common");
17
17
  const client_1 = require("../utils/client");
18
18
  const safety_1 = require("../utils/safety");
19
19
  /**
20
- * Registers the top-level ai-agents command and its subcommands.
20
+ * Registers the top-level ai-agents command and its subcommands (admin scope).
21
21
  */
22
22
  function registerAiAgentsCommand(program) {
23
- const aiAgentsCmd = program.command('ai-agents').description('Manage AI agents (admin, v1)');
23
+ const aiAgentsCmd = program
24
+ .command('ai-agents')
25
+ .description('Manage AI agents — admin endpoints (cross-project)');
24
26
  aiAgentsCmd
25
27
  .command('list')
26
- .description('List all AI agents (admin)')
28
+ .description('List all AI agents across the organization (admin)')
27
29
  .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
28
30
  try {
29
31
  const client = (0, client_1.getClient)();
@@ -37,9 +39,22 @@ function registerAiAgentsCommand(program) {
37
39
  })));
38
40
  aiAgentsCmd
39
41
  .command('threads')
40
- .description('List AI agent threads (admin)')
42
+ .description('List AI agent threads across the organization (admin)')
41
43
  .option('--page <number>', 'Page number', (v) => parseInt(v, 10))
42
44
  .option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
45
+ .option('--agent <uuid>', 'Filter by agent UUID (repeatable)', (v, prev) => [
46
+ ...(prev !== null && prev !== void 0 ? prev : []),
47
+ v,
48
+ ])
49
+ .option('--project <uuid>', 'Filter by project UUID (repeatable)', (v, prev) => [
50
+ ...(prev !== null && prev !== void 0 ? prev : []),
51
+ v,
52
+ ])
53
+ .option('--human-score <number>', 'Filter by human score (-1, 0, or 1)', (v) => parseInt(v, 10))
54
+ .option('--date-from <date>', 'Start date filter (YYYY-MM-DD)')
55
+ .option('--date-to <date>', 'End date filter (YYYY-MM-DD)')
56
+ .option('--sort <field>', 'Sort field: createdAt | title')
57
+ .option('--sort-direction <dir>', 'Sort direction: asc | desc')
43
58
  .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
44
59
  return __awaiter(this, void 0, void 0, function* () {
45
60
  const options = this.opts();
@@ -50,6 +65,20 @@ function registerAiAgentsCommand(program) {
50
65
  params.page = options.page;
51
66
  if (options.pageSize != null)
52
67
  params.pageSize = options.pageSize;
68
+ if (options.agent != null)
69
+ params.agentUuids = options.agent;
70
+ if (options.project != null)
71
+ params.projectUuids = options.project;
72
+ if (options.humanScore != null)
73
+ params.humanScore = options.humanScore;
74
+ if (options.dateFrom != null)
75
+ params.dateFrom = options.dateFrom;
76
+ if (options.dateTo != null)
77
+ params.dateTo = options.dateTo;
78
+ if (options.sort != null)
79
+ params.sortField = options.sort;
80
+ if (options.sortDirection != null)
81
+ params.sortDirection = options.sortDirection;
53
82
  const result = yield client.v1.aiAgents.getAdminThreads(Object.keys(params).length > 0 ? params : undefined);
54
83
  console.log(JSON.stringify(result, null, 2));
55
84
  }
@@ -59,8 +88,11 @@ function registerAiAgentsCommand(program) {
59
88
  }
60
89
  });
61
90
  }));
62
- aiAgentsCmd
91
+ const settingsCmd = aiAgentsCmd
63
92
  .command('settings')
93
+ .description('Manage AI organization settings');
94
+ settingsCmd
95
+ .command('get')
64
96
  .description('Get AI organization settings')
65
97
  .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
66
98
  try {
@@ -73,4 +105,34 @@ function registerAiAgentsCommand(program) {
73
105
  process.exit(1);
74
106
  }
75
107
  })));
108
+ settingsCmd
109
+ .command('update')
110
+ .description('Update AI organization settings')
111
+ .option('--ai-agents-visible <bool>', 'Show/hide AI agents feature (true|false)')
112
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, function () {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ const options = this.opts();
115
+ const body = {};
116
+ if (options.aiAgentsVisible != null) {
117
+ if (options.aiAgentsVisible !== 'true' && options.aiAgentsVisible !== 'false') {
118
+ console.error(`Error: --ai-agents-visible must be 'true' or 'false', got: '${options.aiAgentsVisible}'`);
119
+ process.exit(1);
120
+ }
121
+ body['aiAgentsVisible'] = options.aiAgentsVisible === 'true';
122
+ }
123
+ if (Object.keys(body).length === 0) {
124
+ console.error('Error: at least one option is required (e.g. --ai-agents-visible)');
125
+ process.exit(1);
126
+ }
127
+ try {
128
+ const client = (0, client_1.getClient)();
129
+ const result = yield client.v1.aiAgents.updateAiOrganizationSettings(body);
130
+ console.log(JSON.stringify(result, null, 2));
131
+ }
132
+ catch (error) {
133
+ console.error('Error updating AI organization settings:', error instanceof Error ? error.message : String(error));
134
+ process.exit(1);
135
+ }
136
+ });
137
+ }));
76
138
  }
@@ -24,7 +24,7 @@ function registerContentCommand(program) {
24
24
  contentCmd
25
25
  .command('search <query>')
26
26
  .description('Search project content (charts, dashboards, spaces)')
27
- .option('--project <uuids...>', 'Filter by project UUIDs')
27
+ .option('--projects <uuids...>', 'Filter by project UUIDs')
28
28
  .option('--type <types...>', 'Filter by content types (chart, dashboard, space)')
29
29
  .option('--page <number>', 'Page number', (v) => parseInt(v, 10))
30
30
  .option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
@@ -33,7 +33,7 @@ function registerContentCommand(program) {
33
33
  const client = (0, client_1.getClient)();
34
34
  const result = yield client.v2.content.searchContent({
35
35
  search: query,
36
- projectUuids: options.project,
36
+ projectUuids: options.projects,
37
37
  contentTypes: options.type,
38
38
  page: options.page,
39
39
  pageSize: options.pageSize,
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Space access (v1) command implementation.
3
+ */
4
+ import type { Command } from 'commander';
5
+ /**
6
+ * Registers the space access subcommands under the existing projects command.
7
+ */
8
+ export declare function registerSpaceAccessCommand(program: Command): void;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * Space 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.registerSpaceAccessCommand = registerSpaceAccessCommand;
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 space access subcommands under the existing projects command.
21
+ */
22
+ function registerSpaceAccessCommand(program) {
23
+ const projectsCmd = program.commands.find((c) => c.name() === 'projects');
24
+ if (!projectsCmd) {
25
+ throw new Error('projects command must be registered before space-access');
26
+ }
27
+ const spaceAccessCmd = projectsCmd
28
+ .command('space-access')
29
+ .description('Manage space access (v1)');
30
+ const userCmd = spaceAccessCmd.command('user').description('Manage user access to a space');
31
+ userCmd
32
+ .command('grant <projectUuid> <spaceUuid> <userUuid> <role>')
33
+ .description('Grant a user access to a space')
34
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid, spaceUuid, userUuid, role) => __awaiter(this, void 0, void 0, function* () {
35
+ try {
36
+ const client = (0, client_1.getClient)();
37
+ yield client.v1.spaces.grantUserAccessToSpace(projectUuid, spaceUuid, {
38
+ userUuid,
39
+ spaceRole: role,
40
+ });
41
+ console.error(`Successfully granted ${role} access to user ${userUuid} in space ${spaceUuid}`);
42
+ }
43
+ catch (error) {
44
+ console.error('Error granting user access to space:', error instanceof Error ? error.message : String(error));
45
+ process.exit(1);
46
+ }
47
+ })));
48
+ userCmd
49
+ .command('revoke <projectUuid> <spaceUuid> <userUuid>')
50
+ .description("Revoke a user's access to a space")
51
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (projectUuid, spaceUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
52
+ try {
53
+ const client = (0, client_1.getClient)();
54
+ yield client.v1.spaces.revokeUserAccessToSpace(projectUuid, spaceUuid, userUuid);
55
+ console.error(`Successfully revoked access for user ${userUuid} in space ${spaceUuid}`);
56
+ }
57
+ catch (error) {
58
+ console.error('Error revoking user access from space:', error instanceof Error ? error.message : String(error));
59
+ process.exit(1);
60
+ }
61
+ })));
62
+ const groupCmd = spaceAccessCmd.command('group').description('Manage group access to a space');
63
+ groupCmd
64
+ .command('grant <projectUuid> <spaceUuid> <groupUuid> <role>')
65
+ .description('Grant a group access to a space')
66
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid, spaceUuid, groupUuid, role) => __awaiter(this, void 0, void 0, function* () {
67
+ try {
68
+ const client = (0, client_1.getClient)();
69
+ yield client.v1.spaces.grantGroupAccessToSpace(projectUuid, spaceUuid, {
70
+ groupUuid,
71
+ spaceRole: role,
72
+ });
73
+ console.error(`Successfully granted ${role} access to group ${groupUuid} in space ${spaceUuid}`);
74
+ }
75
+ catch (error) {
76
+ console.error('Error granting group access to space:', error instanceof Error ? error.message : String(error));
77
+ process.exit(1);
78
+ }
79
+ })));
80
+ groupCmd
81
+ .command('revoke <projectUuid> <spaceUuid> <groupUuid>')
82
+ .description("Revoke a group's access to a space")
83
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (projectUuid, spaceUuid, groupUuid) => __awaiter(this, void 0, void 0, function* () {
84
+ try {
85
+ const client = (0, client_1.getClient)();
86
+ yield client.v1.spaces.revokeGroupAccessToSpace(projectUuid, spaceUuid, groupUuid);
87
+ console.error(`Successfully revoked access for group ${groupUuid} in space ${spaceUuid}`);
88
+ }
89
+ catch (error) {
90
+ console.error('Error revoking group access from space:', error instanceof Error ? error.message : String(error));
91
+ process.exit(1);
92
+ }
93
+ })));
94
+ }
package/dist/index.js CHANGED
@@ -5,15 +5,18 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const commander_1 = require("commander");
8
+ const common_1 = require("@lightdash-tools/common");
8
9
  const organization_1 = require("./commands/organization");
9
10
  const organization_roles_1 = require("./commands/organization-roles");
10
11
  const projects_1 = require("./commands/projects");
11
12
  const project_role_assignments_1 = require("./commands/project-role-assignments");
12
13
  const project_access_1 = require("./commands/project-access");
13
14
  const spaces_1 = require("./commands/spaces");
15
+ const space_access_1 = require("./commands/space-access");
14
16
  const charts_1 = require("./commands/charts");
15
17
  const dashboards_1 = require("./commands/dashboards");
16
18
  const ai_agents_1 = require("./commands/ai-agents");
19
+ const agents_1 = require("./commands/agents");
17
20
  const groups_1 = require("./commands/groups");
18
21
  const users_1 = require("./commands/users");
19
22
  const query_1 = require("./commands/query");
@@ -22,12 +25,15 @@ const metrics_1 = require("./commands/metrics");
22
25
  const schedulers_1 = require("./commands/schedulers");
23
26
  const tags_1 = require("./commands/tags");
24
27
  const content_1 = require("./commands/content");
28
+ // Initialise audit log before any command runs (uses LIGHTDASH_AUDIT_LOG env var).
29
+ (0, common_1.initAuditLog)(process.env.LIGHTDASH_AUDIT_LOG);
25
30
  const program = new commander_1.Command();
26
31
  program
27
32
  .name('lightdash-ai')
28
33
  .description('CLI for Lightdash AI')
29
- .version('1.0.0')
30
- .option('--safety-mode <mode>', 'Safety mode (read-only, write-idempotent, write-destructive)', 'write-destructive');
34
+ .version('0.3.1')
35
+ .option('--safety-mode <mode>', 'Safety mode (read-only, write-idempotent, write-destructive)', 'read-only')
36
+ .option('--projects <uuids>', 'Comma-separated list of allowed project UUIDs (security guardrail)');
31
37
  // Register all commands (organization and projects first so subcommands can attach)
32
38
  (0, organization_1.registerOrganizationCommand)(program);
33
39
  (0, organization_roles_1.registerOrganizationRolesCommand)(program);
@@ -35,9 +41,11 @@ program
35
41
  (0, project_role_assignments_1.registerProjectRoleAssignmentsCommand)(program);
36
42
  (0, project_access_1.registerProjectAccessCommand)(program);
37
43
  (0, spaces_1.registerSpacesCommand)(program);
44
+ (0, space_access_1.registerSpaceAccessCommand)(program);
38
45
  (0, charts_1.registerChartsCommand)(program);
39
46
  (0, dashboards_1.registerDashboardsCommand)(program);
40
47
  (0, ai_agents_1.registerAiAgentsCommand)(program);
48
+ (0, agents_1.registerAgentsCommand)(program);
41
49
  (0, groups_1.registerGroupsCommand)(program);
42
50
  (0, users_1.registerUsersCommand)(program);
43
51
  (0, query_1.registerQueryCommand)(program);
@@ -8,6 +8,7 @@ const projects_1 = require("./commands/projects");
8
8
  const project_role_assignments_1 = require("./commands/project-role-assignments");
9
9
  const project_access_1 = require("./commands/project-access");
10
10
  const spaces_1 = require("./commands/spaces");
11
+ const space_access_1 = require("./commands/space-access");
11
12
  const charts_1 = require("./commands/charts");
12
13
  const dashboards_1 = require("./commands/dashboards");
13
14
  const ai_agents_1 = require("./commands/ai-agents");
@@ -96,16 +97,18 @@ const explores_1 = require("./commands/explores");
96
97
  (0, vitest_1.expect)(rolesCmd === null || rolesCmd === void 0 ? void 0 : rolesCmd.commands.some((c) => c.name() === 'get')).toBe(true);
97
98
  (0, vitest_1.expect)(rolesCmd === null || rolesCmd === void 0 ? void 0 : rolesCmd.commands.some((c) => c.name() === 'assign')).toBe(true);
98
99
  });
99
- (0, vitest_1.it)('should register projects roles, access, spaces subcommands', () => {
100
+ (0, vitest_1.it)('should register projects roles, access, spaces, and space-access subcommands', () => {
100
101
  const program = new commander_1.Command();
101
102
  (0, projects_1.registerProjectsCommand)(program);
102
103
  (0, project_role_assignments_1.registerProjectRoleAssignmentsCommand)(program);
103
104
  (0, project_access_1.registerProjectAccessCommand)(program);
104
105
  (0, spaces_1.registerSpacesCommand)(program);
106
+ (0, space_access_1.registerSpaceAccessCommand)(program);
105
107
  const projectsCmd = program.commands.find((cmd) => cmd.name() === 'projects');
106
108
  (0, vitest_1.expect)(projectsCmd === null || projectsCmd === void 0 ? void 0 : projectsCmd.commands.some((c) => c.name() === 'roles')).toBe(true);
107
109
  (0, vitest_1.expect)(projectsCmd === null || projectsCmd === void 0 ? void 0 : projectsCmd.commands.some((c) => c.name() === 'access')).toBe(true);
108
110
  (0, vitest_1.expect)(projectsCmd === null || projectsCmd === void 0 ? void 0 : projectsCmd.commands.some((c) => c.name() === 'spaces')).toBe(true);
111
+ (0, vitest_1.expect)(projectsCmd === null || projectsCmd === void 0 ? void 0 : projectsCmd.commands.some((c) => c.name() === 'space-access')).toBe(true);
109
112
  });
110
113
  (0, vitest_1.it)('should register projects charts and dashboards subcommands', () => {
111
114
  const program = new commander_1.Command();
@@ -155,6 +158,7 @@ const explores_1 = require("./commands/explores");
155
158
  (0, project_role_assignments_1.registerProjectRoleAssignmentsCommand)(program);
156
159
  (0, project_access_1.registerProjectAccessCommand)(program);
157
160
  (0, spaces_1.registerSpacesCommand)(program);
161
+ (0, space_access_1.registerSpaceAccessCommand)(program);
158
162
  (0, charts_1.registerChartsCommand)(program);
159
163
  (0, dashboards_1.registerDashboardsCommand)(program);
160
164
  (0, ai_agents_1.registerAiAgentsCommand)(program);
@@ -172,7 +176,7 @@ const explores_1 = require("./commands/explores");
172
176
  });
173
177
  (0, vitest_1.it)('should have --safety-mode option', () => {
174
178
  const program = new commander_1.Command();
175
- program.option('--safety-mode <mode>', 'description', 'write-destructive');
179
+ program.option('--safety-mode <mode>', 'description', 'read-only');
176
180
  const option = program.options.find((opt) => opt.long === '--safety-mode');
177
181
  (0, vitest_1.expect)(option).toBeDefined();
178
182
  });
@@ -3,9 +3,16 @@ import type { ToolAnnotations } from '@lightdash-tools/common';
3
3
  import type { Command } from 'commander';
4
4
  /**
5
5
  * Resolves the safety mode from the command line options or environment variables.
6
+ * CLI --safety-mode takes priority over LIGHTDASH_TOOL_SAFETY_MODE.
6
7
  */
7
8
  export declare function getSafetyMode(cmd: Command): SafetyMode;
8
9
  /**
9
- * Wraps a CLI action with a safety check.
10
+ * Resolves the allowed project UUIDs from the command line options or environment variables.
11
+ * We specifically want the root --projects flag as the security guardrail.
12
+ * CLI root flags take priority over LIGHTDASH_TOOLS_ALLOWED_PROJECTS.
13
+ */
14
+ export declare function getAllowedProjects(cmd: Command): string[];
15
+ /**
16
+ * Wraps a CLI action with safety-mode enforcement and audit logging.
10
17
  */
11
18
  export declare function wrapAction<T extends unknown[]>(annotations: ToolAnnotations, action: (...args: T) => Promise<void> | void): (this: Command, ...args: T) => Promise<void>;
@@ -10,10 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getSafetyMode = getSafetyMode;
13
+ exports.getAllowedProjects = getAllowedProjects;
13
14
  exports.wrapAction = wrapAction;
14
15
  const common_1 = require("@lightdash-tools/common");
15
16
  /**
16
17
  * Resolves the safety mode from the command line options or environment variables.
18
+ * CLI --safety-mode takes priority over LIGHTDASH_TOOL_SAFETY_MODE.
17
19
  */
18
20
  function getSafetyMode(cmd) {
19
21
  const options = cmd.optsWithGlobals();
@@ -23,17 +25,100 @@ function getSafetyMode(cmd) {
23
25
  return (0, common_1.getSafetyModeFromEnv)();
24
26
  }
25
27
  /**
26
- * Wraps a CLI action with a safety check.
28
+ * Resolves the allowed project UUIDs from the command line options or environment variables.
29
+ * We specifically want the root --projects flag as the security guardrail.
30
+ * CLI root flags take priority over LIGHTDASH_TOOLS_ALLOWED_PROJECTS.
31
+ */
32
+ function getAllowedProjects(cmd) {
33
+ let root = cmd;
34
+ while (root.parent) {
35
+ root = root.parent;
36
+ }
37
+ const options = root.opts();
38
+ const raw = options.projects;
39
+ if (raw) {
40
+ return raw
41
+ .split(',')
42
+ .map((s) => s.trim())
43
+ .filter(Boolean);
44
+ }
45
+ return (0, common_1.getAllowedProjectUuidsFromEnv)();
46
+ }
47
+ /** Builds a human-readable command path (e.g. "lightdash-ai charts list"). */
48
+ function getCommandPath(cmd) {
49
+ const parts = [];
50
+ let current = cmd;
51
+ while (current) {
52
+ const n = current.name();
53
+ if (n)
54
+ parts.unshift(n);
55
+ current = current.parent;
56
+ }
57
+ return parts.join(' ');
58
+ }
59
+ /**
60
+ * Wraps a CLI action with safety-mode enforcement and audit logging.
27
61
  */
28
62
  function wrapAction(annotations, action) {
29
63
  return function (...args) {
30
64
  return __awaiter(this, void 0, void 0, function* () {
65
+ const start = Date.now();
66
+ const commandPath = getCommandPath(this);
31
67
  const mode = getSafetyMode(this);
68
+ const allowedProjects = getAllowedProjects(this);
69
+ const targetProjects = (0, common_1.extractProjectUuids)(args);
70
+ // ── Safety Mode Enforcement ──────────────────────────────────────────────
32
71
  if (!(0, common_1.isAllowed)(mode, annotations)) {
72
+ (0, common_1.logAuditEntry)({
73
+ timestamp: new Date().toISOString(),
74
+ sessionId: (0, common_1.getSessionId)(),
75
+ tool: commandPath,
76
+ projectUuids: targetProjects.length > 0 ? targetProjects : undefined,
77
+ status: 'blocked',
78
+ durationMs: Date.now() - start,
79
+ });
33
80
  console.error(`Error: This command is disabled in ${mode} mode. To enable it, use --safety-mode or set LIGHTDASH_TOOL_SAFETY_MODE.`);
34
81
  process.exit(1);
35
82
  }
36
- return action.apply(this, args);
83
+ // ── Project Guardrail Enforcement ────────────────────────────────────────
84
+ if (allowedProjects.length > 0) {
85
+ const deniedProjects = targetProjects.filter((p) => !(0, common_1.areAllProjectsAllowed)(allowedProjects, [p]));
86
+ if (deniedProjects.length > 0) {
87
+ (0, common_1.logAuditEntry)({
88
+ timestamp: new Date().toISOString(),
89
+ sessionId: (0, common_1.getSessionId)(),
90
+ tool: commandPath,
91
+ projectUuids: targetProjects,
92
+ status: 'blocked',
93
+ durationMs: Date.now() - start,
94
+ });
95
+ console.error(`Error: Project(s) [${deniedProjects.join(', ')}] are not in the list of allowed projects. Allowed: [${allowedProjects.join(', ')}].`);
96
+ process.exit(1);
97
+ }
98
+ }
99
+ try {
100
+ const result = yield action.apply(this, args);
101
+ (0, common_1.logAuditEntry)({
102
+ timestamp: new Date().toISOString(),
103
+ sessionId: (0, common_1.getSessionId)(),
104
+ tool: commandPath,
105
+ projectUuids: targetProjects.length > 0 ? targetProjects : undefined,
106
+ status: 'success',
107
+ durationMs: Date.now() - start,
108
+ });
109
+ return result;
110
+ }
111
+ catch (err) {
112
+ (0, common_1.logAuditEntry)({
113
+ timestamp: new Date().toISOString(),
114
+ sessionId: (0, common_1.getSessionId)(),
115
+ tool: commandPath,
116
+ projectUuids: targetProjects.length > 0 ? targetProjects : undefined,
117
+ status: 'error',
118
+ durationMs: Date.now() - start,
119
+ });
120
+ throw err;
121
+ }
37
122
  });
38
123
  };
39
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash-tools/cli",
3
- "version": "0.2.5",
3
+ "version": "0.3.1",
4
4
  "description": "CLI for Lightdash AI.",
5
5
  "keywords": [],
6
6
  "license": "Apache-2.0",
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "commander": "^14.0.3",
15
- "@lightdash-tools/client": "0.2.5",
16
- "@lightdash-tools/common": "0.2.5"
15
+ "@lightdash-tools/client": "0.3.1",
16
+ "@lightdash-tools/common": "0.3.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "^25.2.3"