@lightdash-tools/cli 0.5.0 → 0.7.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.
Files changed (109) hide show
  1. package/README.md +6 -2
  2. package/dist/commands/agentops/apply.d.ts +5 -0
  3. package/dist/commands/agentops/apply.js +53 -0
  4. package/dist/commands/agentops/bundle-schema.d.ts +5 -0
  5. package/dist/commands/agentops/bundle-schema.js +16 -0
  6. package/dist/commands/agentops/drift.d.ts +5 -0
  7. package/dist/commands/agentops/drift.js +46 -0
  8. package/dist/commands/agentops/evaluate-gate.d.ts +5 -0
  9. package/dist/commands/agentops/evaluate-gate.js +89 -0
  10. package/dist/commands/agentops/gate-schema.d.ts +5 -0
  11. package/dist/commands/agentops/gate-schema.js +16 -0
  12. package/dist/commands/agentops/plan.d.ts +5 -0
  13. package/dist/commands/agentops/plan.js +42 -0
  14. package/dist/commands/agentops/state.d.ts +4 -0
  15. package/dist/commands/agentops/state.js +8 -0
  16. package/dist/commands/agentops.d.ts +8 -0
  17. package/dist/commands/agentops.js +26 -0
  18. package/dist/commands/agentops.test.d.ts +1 -0
  19. package/dist/commands/agentops.test.js +400 -0
  20. package/dist/commands/agents-crud.d.ts +8 -0
  21. package/dist/commands/agents-crud.js +144 -0
  22. package/dist/commands/agents-discovery.d.ts +8 -0
  23. package/dist/commands/agents-discovery.js +139 -0
  24. package/dist/commands/agents-discovery.test.d.ts +1 -0
  25. package/dist/commands/agents-discovery.test.js +13 -0
  26. package/dist/commands/agents-evals.d.ts +8 -0
  27. package/dist/commands/agents-evals.js +246 -0
  28. package/dist/commands/agents-threads.d.ts +8 -0
  29. package/dist/commands/agents-threads.js +83 -0
  30. package/dist/commands/agents.js +8 -360
  31. package/dist/commands/ai-agents.js +52 -70
  32. package/dist/commands/charts.js +35 -46
  33. package/dist/commands/content.js +3 -12
  34. package/dist/commands/dashboards.js +3 -12
  35. package/dist/commands/explores.js +12 -21
  36. package/dist/commands/groups.js +44 -63
  37. package/dist/commands/metrics.js +6 -15
  38. package/dist/commands/organization-roles.js +28 -39
  39. package/dist/commands/organization.js +3 -12
  40. package/dist/commands/project-access.js +9 -18
  41. package/dist/commands/project-role-assignments.js +15 -24
  42. package/dist/commands/projects.js +33 -26
  43. package/dist/commands/query.js +30 -41
  44. package/dist/commands/schedulers.js +6 -15
  45. package/dist/commands/schema.js +33 -10
  46. package/dist/commands/schema.test.js +58 -1
  47. package/dist/commands/space-access.js +12 -21
  48. package/dist/commands/spaces.js +6 -15
  49. package/dist/commands/tags.js +6 -15
  50. package/dist/commands/users.js +23 -41
  51. package/dist/index.js +18 -16
  52. package/dist/index.test.js +9 -9
  53. package/dist/utils/cli-params.d.ts +4 -0
  54. package/dist/utils/cli-params.js +15 -0
  55. package/dist/utils/cli-params.test.d.ts +1 -0
  56. package/dist/utils/cli-params.test.js +12 -0
  57. package/dist/utils/file-input.d.ts +30 -0
  58. package/dist/utils/file-input.js +77 -0
  59. package/dist/utils/file-input.test.d.ts +1 -0
  60. package/dist/utils/file-input.test.js +68 -0
  61. package/dist/utils/safety.d.ts +5 -0
  62. package/dist/utils/safety.js +97 -109
  63. package/dist/utils/safety.test.js +135 -33
  64. package/package.json +14 -5
  65. package/src/commands/agentops/apply.ts +77 -0
  66. package/src/commands/agentops/bundle-schema.ts +20 -0
  67. package/src/commands/agentops/drift.ts +63 -0
  68. package/src/commands/agentops/evaluate-gate.ts +128 -0
  69. package/src/commands/agentops/gate-schema.ts +20 -0
  70. package/src/commands/agentops/plan.ts +55 -0
  71. package/src/commands/agentops/state.ts +5 -0
  72. package/src/commands/agentops.test.ts +454 -0
  73. package/src/commands/agentops.ts +28 -0
  74. package/src/commands/agents-crud.ts +193 -0
  75. package/src/commands/agents-discovery.test.ts +16 -0
  76. package/src/commands/agents-discovery.ts +180 -0
  77. package/src/commands/agents-evals.ts +353 -0
  78. package/src/commands/agents-threads.ts +116 -0
  79. package/src/commands/agents.ts +9 -493
  80. package/src/commands/ai-agents.ts +37 -28
  81. package/src/commands/charts.ts +6 -3
  82. package/src/commands/content.ts +3 -1
  83. package/src/commands/dashboards.ts +3 -1
  84. package/src/commands/explores.ts +3 -1
  85. package/src/commands/groups.ts +33 -33
  86. package/src/commands/metrics.ts +3 -1
  87. package/src/commands/organization-roles.ts +3 -1
  88. package/src/commands/organization.ts +3 -1
  89. package/src/commands/project-access.ts +3 -1
  90. package/src/commands/project-role-assignments.ts +3 -1
  91. package/src/commands/projects.ts +44 -18
  92. package/src/commands/query.ts +4 -1
  93. package/src/commands/schedulers.ts +3 -1
  94. package/src/commands/schema.test.ts +72 -1
  95. package/src/commands/schema.ts +60 -14
  96. package/src/commands/space-access.ts +3 -1
  97. package/src/commands/spaces.ts +3 -1
  98. package/src/commands/tags.ts +3 -1
  99. package/src/commands/users.ts +29 -25
  100. package/src/index.test.ts +10 -9
  101. package/src/index.ts +19 -16
  102. package/src/utils/cli-params.test.ts +13 -0
  103. package/src/utils/cli-params.ts +12 -0
  104. package/src/utils/client.test.ts +1 -0
  105. package/src/utils/file-input.test.ts +91 -0
  106. package/src/utils/file-input.ts +83 -0
  107. package/src/utils/safety.test.ts +158 -2
  108. package/src/utils/safety.ts +27 -20
  109. package/tsconfig.json +2 -1
@@ -9,8 +9,8 @@ exports.listResources = listResources;
9
9
  exports.registerSchemaCommand = registerSchemaCommand;
10
10
  const common_1 = require("@lightdash-tools/common");
11
11
  const safety_1 = require("../utils/safety");
12
- /** Maps resource identifiers to API path + method + description. */
13
- const SCHEMA_REGISTRY = {
12
+ /** Maps legacy resource identifiers to API path + method + description. */
13
+ const LEGACY_SCHEMA_REGISTRY = {
14
14
  'organization.get': {
15
15
  path: '/api/v1/org',
16
16
  method: 'GET',
@@ -34,13 +34,13 @@ const SCHEMA_REGISTRY = {
34
34
  params: ['projectUuid'],
35
35
  },
36
36
  'charts.code.list': {
37
- path: '/api/v1/projects/{projectUuid}/charts/code',
37
+ path: '/api/v1/projects/{projectUuid}/code/charts',
38
38
  method: 'GET',
39
39
  description: 'Get charts in code representation',
40
40
  params: ['projectUuid'],
41
41
  },
42
42
  'charts.code.upsert': {
43
- path: '/api/v1/projects/{projectUuid}/charts/{slug}/code',
43
+ path: '/api/v1/projects/{projectUuid}/code/charts/{slug}',
44
44
  method: 'POST',
45
45
  description: 'Create or update chart by slug',
46
46
  params: ['projectUuid', 'slug'],
@@ -90,11 +90,19 @@ const SCHEMA_REGISTRY = {
90
90
  params: ['projectUuid'],
91
91
  },
92
92
  };
93
- function getSchema(resource) {
93
+ function extractPathParams(path) {
94
+ const params = [];
95
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
96
+ params.push(match[1]);
97
+ }
98
+ return params;
99
+ }
100
+ function operationToSchema(operation) {
101
+ var _a;
102
+ return Object.assign({ resource: operation.id, path: operation.http.path, method: operation.http.method, description: operation.summary, params: extractPathParams(operation.http.path), cliCommand: operation.cli.commandPath, agentExposure: (_a = operation.agentExposure) !== null && _a !== void 0 ? _a : 'agent', profiles: [...operation.profiles], safetyImpact: operation.authorization.safetyImpact }, (operation.workflow != null ? { workflow: [...operation.workflow] } : {}));
103
+ }
104
+ function legacyToSchema(resource, entry) {
94
105
  var _a;
95
- const entry = SCHEMA_REGISTRY[resource];
96
- if (!entry)
97
- return null;
98
106
  return {
99
107
  resource,
100
108
  path: entry.path,
@@ -103,8 +111,23 @@ function getSchema(resource) {
103
111
  params: (_a = entry.params) !== null && _a !== void 0 ? _a : [],
104
112
  };
105
113
  }
114
+ function getSchema(resource) {
115
+ const legacy = LEGACY_SCHEMA_REGISTRY[resource];
116
+ if (legacy) {
117
+ return legacyToSchema(resource, legacy);
118
+ }
119
+ const operation = (0, common_1.getOperation)(resource);
120
+ if (operation) {
121
+ return operationToSchema(operation);
122
+ }
123
+ return null;
124
+ }
106
125
  function listResources() {
107
- return Object.keys(SCHEMA_REGISTRY).sort();
126
+ const resources = new Set([
127
+ ...Object.keys(LEGACY_SCHEMA_REGISTRY),
128
+ ...(0, common_1.listOperations)().map((operation) => operation.id),
129
+ ]);
130
+ return [...resources].sort();
108
131
  }
109
132
  /**
110
133
  * Registers the schema introspection command.
@@ -122,7 +145,7 @@ function registerSchemaCommand(program) {
122
145
  }));
123
146
  schemaCmd
124
147
  .command('get <resource>')
125
- .description('Get schema for a resource (e.g. charts.list, ai-agents.settings.get)')
148
+ .description('Get schema for a resource (e.g. charts.list, ai-agents.project.agents.list)')
126
149
  .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (resource) => {
127
150
  const schema = getSchema(resource);
128
151
  if (!schema) {
@@ -14,12 +14,63 @@ const schema_1 = require("./schema");
14
14
  (0, vitest_1.expect)(schema).toHaveProperty('description');
15
15
  (0, vitest_1.expect)(schema).toHaveProperty('resource', 'charts.list');
16
16
  });
17
- (0, vitest_1.it)('returns schema for ai-agents.settings.update', () => {
17
+ (0, vitest_1.it)('returns schema for ai-agents.settings.update (legacy key)', () => {
18
18
  const schema = (0, schema_1.getSchema)('ai-agents.settings.update');
19
19
  (0, vitest_1.expect)(schema).not.toBeNull();
20
20
  (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/aiAgents/admin/settings');
21
21
  (0, vitest_1.expect)(schema).toHaveProperty('method', 'PATCH');
22
22
  });
23
+ (0, vitest_1.it)('returns schema for ai-agents.project.agents.list from operation registry', () => {
24
+ const schema = (0, schema_1.getSchema)('ai-agents.project.agents.list');
25
+ (0, vitest_1.expect)(schema).not.toBeNull();
26
+ (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents');
27
+ (0, vitest_1.expect)(schema).toHaveProperty('method', 'GET');
28
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents list');
29
+ (0, vitest_1.expect)(schema).toHaveProperty('profiles');
30
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.profiles).toContain('core-lifecycle');
31
+ });
32
+ (0, vitest_1.it)('returns schema for ai-agents.project.evaluations.create from operation registry', () => {
33
+ const schema = (0, schema_1.getSchema)('ai-agents.project.evaluations.create');
34
+ (0, vitest_1.expect)(schema).not.toBeNull();
35
+ (0, vitest_1.expect)(schema).toHaveProperty('method', 'POST');
36
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents evals create');
37
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.params).toEqual(vitest_1.expect.arrayContaining(['projectUuid', 'agentUuid']));
38
+ });
39
+ (0, vitest_1.it)('returns schema for ai-agents.project.threads.start from operation registry', () => {
40
+ const schema = (0, schema_1.getSchema)('ai-agents.project.threads.start');
41
+ (0, vitest_1.expect)(schema).not.toBeNull();
42
+ (0, vitest_1.expect)(schema).toHaveProperty('method', 'POST');
43
+ (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads');
44
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents threads start');
45
+ (0, vitest_1.expect)(schema).toHaveProperty('safetyImpact', 'external-side-effect');
46
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.workflow).toEqual(vitest_1.expect.arrayContaining([
47
+ vitest_1.expect.objectContaining({
48
+ method: 'POST',
49
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/generate',
50
+ }),
51
+ ]));
52
+ });
53
+ (0, vitest_1.it)('returns workflow for ai-agents.project.threads.continue from operation registry', () => {
54
+ const schema = (0, schema_1.getSchema)('ai-agents.project.threads.continue');
55
+ (0, vitest_1.expect)(schema).not.toBeNull();
56
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.workflow).toEqual(vitest_1.expect.arrayContaining([
57
+ vitest_1.expect.objectContaining({
58
+ method: 'POST',
59
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/messages',
60
+ }),
61
+ vitest_1.expect.objectContaining({
62
+ method: 'POST',
63
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/generate',
64
+ }),
65
+ ]));
66
+ });
67
+ (0, vitest_1.it)('returns schema for users.members.delete with client-only exposure', () => {
68
+ const schema = (0, schema_1.getSchema)('users.members.delete');
69
+ (0, vitest_1.expect)(schema).not.toBeNull();
70
+ (0, vitest_1.expect)(schema).toHaveProperty('method', 'DELETE');
71
+ (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/org/user/{userUuid}');
72
+ (0, vitest_1.expect)(schema).toHaveProperty('agentExposure', 'client-only');
73
+ });
23
74
  (0, vitest_1.it)('returns null for unknown resource', () => {
24
75
  const schema = (0, schema_1.getSchema)('unknown.resource');
25
76
  (0, vitest_1.expect)(schema).toBeNull();
@@ -35,5 +86,11 @@ const schema_1 = require("./schema");
35
86
  (0, vitest_1.it)('includes charts.list', () => {
36
87
  (0, vitest_1.expect)((0, schema_1.listResources)()).toContain('charts.list');
37
88
  });
89
+ (0, vitest_1.it)('includes project-scoped registry operation ids', () => {
90
+ const resources = (0, schema_1.listResources)();
91
+ (0, vitest_1.expect)(resources).toContain('ai-agents.project.agents.list');
92
+ (0, vitest_1.expect)(resources).toContain('ai-agents.project.evaluations.run');
93
+ (0, vitest_1.expect)(resources).toContain('ai-agents.project.threads.continue');
94
+ });
38
95
  });
39
96
  });
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Space access (v1) command implementation.
4
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
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.registerSpaceAccessCommand = registerSpaceAccessCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -31,10 +22,10 @@ function registerSpaceAccessCommand(program) {
31
22
  userCmd
32
23
  .command('grant <projectUuid> <spaceUuid> <userUuid> <role>')
33
24
  .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* () {
25
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (projectUuid, spaceUuid, userUuid, role) => {
35
26
  try {
36
27
  const client = (0, client_1.getClient)();
37
- yield client.v1.spaces.grantUserAccessToSpace(projectUuid, spaceUuid, {
28
+ await client.v1.spaces.grantUserAccessToSpace(projectUuid, spaceUuid, {
38
29
  userUuid,
39
30
  spaceRole: role,
40
31
  });
@@ -44,29 +35,29 @@ function registerSpaceAccessCommand(program) {
44
35
  console.error('Error granting user access to space:', error instanceof Error ? error.message : String(error));
45
36
  process.exit(1);
46
37
  }
47
- })));
38
+ }));
48
39
  userCmd
49
40
  .command('revoke <projectUuid> <spaceUuid> <userUuid>')
50
41
  .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* () {
42
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (projectUuid, spaceUuid, userUuid) => {
52
43
  try {
53
44
  const client = (0, client_1.getClient)();
54
- yield client.v1.spaces.revokeUserAccessToSpace(projectUuid, spaceUuid, userUuid);
45
+ await client.v1.spaces.revokeUserAccessToSpace(projectUuid, spaceUuid, userUuid);
55
46
  console.error(`Successfully revoked access for user ${userUuid} in space ${spaceUuid}`);
56
47
  }
57
48
  catch (error) {
58
49
  console.error('Error revoking user access from space:', error instanceof Error ? error.message : String(error));
59
50
  process.exit(1);
60
51
  }
61
- })));
52
+ }));
62
53
  const groupCmd = spaceAccessCmd.command('group').description('Manage group access to a space');
63
54
  groupCmd
64
55
  .command('grant <projectUuid> <spaceUuid> <groupUuid> <role>')
65
56
  .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* () {
57
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (projectUuid, spaceUuid, groupUuid, role) => {
67
58
  try {
68
59
  const client = (0, client_1.getClient)();
69
- yield client.v1.spaces.grantGroupAccessToSpace(projectUuid, spaceUuid, {
60
+ await client.v1.spaces.grantGroupAccessToSpace(projectUuid, spaceUuid, {
70
61
  groupUuid,
71
62
  spaceRole: role,
72
63
  });
@@ -76,19 +67,19 @@ function registerSpaceAccessCommand(program) {
76
67
  console.error('Error granting group access to space:', error instanceof Error ? error.message : String(error));
77
68
  process.exit(1);
78
69
  }
79
- })));
70
+ }));
80
71
  groupCmd
81
72
  .command('revoke <projectUuid> <spaceUuid> <groupUuid>')
82
73
  .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* () {
74
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (projectUuid, spaceUuid, groupUuid) => {
84
75
  try {
85
76
  const client = (0, client_1.getClient)();
86
- yield client.v1.spaces.revokeGroupAccessToSpace(projectUuid, spaceUuid, groupUuid);
77
+ await client.v1.spaces.revokeGroupAccessToSpace(projectUuid, spaceUuid, groupUuid);
87
78
  console.error(`Successfully revoked access for group ${groupUuid} in space ${spaceUuid}`);
88
79
  }
89
80
  catch (error) {
90
81
  console.error('Error revoking group access from space:', error instanceof Error ? error.message : String(error));
91
82
  process.exit(1);
92
83
  }
93
- })));
84
+ }));
94
85
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Spaces (v1) command implementation.
4
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
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.registerSpacesCommand = registerSpacesCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -28,29 +19,29 @@ function registerSpacesCommand(program) {
28
19
  spacesCmd
29
20
  .command('list <projectUuid>')
30
21
  .description('List spaces in a project')
31
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
22
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
32
23
  try {
33
24
  const client = (0, client_1.getClient)();
34
- const result = yield client.v1.spaces.listSpacesInProject(projectUuid);
25
+ const result = await client.v1.spaces.listSpacesInProject(projectUuid);
35
26
  console.log(JSON.stringify(result, null, 2));
36
27
  }
37
28
  catch (error) {
38
29
  console.error('Error listing spaces:', error instanceof Error ? error.message : String(error));
39
30
  process.exit(1);
40
31
  }
41
- })));
32
+ }));
42
33
  spacesCmd
43
34
  .command('get <projectUuid> <spaceUuid>')
44
35
  .description('Get a space by UUID')
45
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, spaceUuid) => __awaiter(this, void 0, void 0, function* () {
36
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, spaceUuid) => {
46
37
  try {
47
38
  const client = (0, client_1.getClient)();
48
- const result = yield client.v1.spaces.getSpace(projectUuid, spaceUuid);
39
+ const result = await client.v1.spaces.getSpace(projectUuid, spaceUuid);
49
40
  console.log(JSON.stringify(result, null, 2));
50
41
  }
51
42
  catch (error) {
52
43
  console.error('Error fetching space:', error instanceof Error ? error.message : String(error));
53
44
  process.exit(1);
54
45
  }
55
- })));
46
+ }));
56
47
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Tags command implementation.
4
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
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.registerTagsCommand = registerTagsCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -24,29 +15,29 @@ function registerTagsCommand(program) {
24
15
  tagsCmd
25
16
  .command('list <projectUuid>')
26
17
  .description('List tags in a project')
27
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
18
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
28
19
  try {
29
20
  const client = (0, client_1.getClient)();
30
- const result = yield client.v1.tags.listTags(projectUuid);
21
+ const result = await client.v1.tags.listTags(projectUuid);
31
22
  console.log(JSON.stringify(result, null, 2));
32
23
  }
33
24
  catch (error) {
34
25
  console.error('Error listing tags:', error instanceof Error ? error.message : String(error));
35
26
  process.exit(1);
36
27
  }
37
- })));
28
+ }));
38
29
  tagsCmd
39
30
  .command('get <projectUuid> <tagUuid>')
40
31
  .description('Get a tag by UUID')
41
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, tagUuid) => __awaiter(this, void 0, void 0, function* () {
32
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, tagUuid) => {
42
33
  try {
43
34
  const client = (0, client_1.getClient)();
44
- const result = yield client.v1.tags.getTag(projectUuid, tagUuid);
35
+ const result = await client.v1.tags.getTag(projectUuid, tagUuid);
45
36
  console.log(JSON.stringify(result, null, 2));
46
37
  }
47
38
  catch (error) {
48
39
  console.error('Error fetching tag:', error instanceof Error ? error.message : String(error));
49
40
  process.exit(1);
50
41
  }
51
- })));
42
+ }));
52
43
  }
@@ -2,20 +2,22 @@
2
2
  /**
3
3
  * Users command implementation.
4
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
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.registerUsersCommand = registerUsersCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
8
+ const cli_params_1 = require("../utils/cli-params");
17
9
  const client_1 = require("../utils/client");
18
10
  const safety_1 = require("../utils/safety");
11
+ async function listUsers(client, options) {
12
+ const searchQuery = options.search;
13
+ if (options.all) {
14
+ const list = await client.v1.users.listAllMembers((0, cli_params_1.pickDefined)({ searchQuery }));
15
+ console.log(JSON.stringify(list, null, 2));
16
+ return;
17
+ }
18
+ const result = await client.v1.users.listMembers((0, cli_params_1.pickDefined)({ page: options.page, pageSize: options.pageSize, searchQuery }));
19
+ console.log(JSON.stringify(result, null, 2));
20
+ }
19
21
  /**
20
22
  * Registers the users command and its subcommands.
21
23
  * Uses client.v1.users (typed client) per ADR-0010.
@@ -29,48 +31,28 @@ function registerUsersCommand(program) {
29
31
  .option('--page <number>', 'Page number (1-based)', (v) => parseInt(v, 10))
30
32
  .option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
31
33
  .option('--search <query>', 'Search query')
32
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, 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
- if (options.all) {
38
- const listParams = {};
39
- if (options.search != null)
40
- listParams.searchQuery = options.search;
41
- const list = yield client.v1.users.listAllMembers(Object.keys(listParams).length > 0 ? listParams : undefined);
42
- console.log(JSON.stringify(list, null, 2));
43
- }
44
- else {
45
- const params = {};
46
- if (options.page != null)
47
- params.page = options.page;
48
- if (options.pageSize != null)
49
- params.pageSize = options.pageSize;
50
- if (options.search != null)
51
- params.searchQuery = options.search;
52
- const result = yield client.v1.users.listMembers(Object.keys(params).length > 0 ? params : undefined);
53
- console.log(JSON.stringify(result, null, 2));
54
- }
55
- }
56
- catch (error) {
57
- console.error('Error listing users:', error instanceof Error ? error.message : String(error));
58
- process.exit(1);
59
- }
60
- });
34
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async function () {
35
+ const options = this.opts();
36
+ try {
37
+ await listUsers((0, client_1.getClient)(), options);
38
+ }
39
+ catch (error) {
40
+ console.error('Error listing users:', error instanceof Error ? error.message : String(error));
41
+ process.exit(1);
42
+ }
61
43
  }));
62
44
  usersCmd
63
45
  .command('get <userUuid>')
64
46
  .description('Get a user by UUID')
65
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (userUuid) => __awaiter(this, void 0, void 0, function* () {
47
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (userUuid) => {
66
48
  try {
67
49
  const client = (0, client_1.getClient)();
68
- const member = yield client.v1.users.getMemberByUuid(userUuid);
50
+ const member = await client.v1.users.getMemberByUuid(userUuid);
69
51
  console.log(JSON.stringify(member, null, 2));
70
52
  }
71
53
  catch (error) {
72
54
  console.error('Error fetching user:', error instanceof Error ? error.message : String(error));
73
55
  process.exit(1);
74
56
  }
75
- })));
57
+ }));
76
58
  }
package/dist/index.js CHANGED
@@ -4,35 +4,36 @@
4
4
  * Main entry point for Lightdash AI CLI.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
7
  const common_1 = require("@lightdash-tools/common");
9
- const organization_1 = require("./commands/organization");
10
- const organization_roles_1 = require("./commands/organization-roles");
11
- const projects_1 = require("./commands/projects");
12
- const project_role_assignments_1 = require("./commands/project-role-assignments");
13
- const project_access_1 = require("./commands/project-access");
14
- const spaces_1 = require("./commands/spaces");
15
- const space_access_1 = require("./commands/space-access");
8
+ const commander_1 = require("commander");
9
+ const agentops_1 = require("./commands/agentops");
10
+ const agents_1 = require("./commands/agents");
11
+ const ai_agents_1 = require("./commands/ai-agents");
16
12
  const charts_1 = require("./commands/charts");
13
+ const content_1 = require("./commands/content");
17
14
  const dashboards_1 = require("./commands/dashboards");
18
- const ai_agents_1 = require("./commands/ai-agents");
19
- const agents_1 = require("./commands/agents");
20
- const groups_1 = require("./commands/groups");
21
- const users_1 = require("./commands/users");
22
- const query_1 = require("./commands/query");
23
15
  const explores_1 = require("./commands/explores");
16
+ const groups_1 = require("./commands/groups");
24
17
  const metrics_1 = require("./commands/metrics");
18
+ const organization_1 = require("./commands/organization");
19
+ const organization_roles_1 = require("./commands/organization-roles");
20
+ const project_access_1 = require("./commands/project-access");
21
+ const project_role_assignments_1 = require("./commands/project-role-assignments");
22
+ const projects_1 = require("./commands/projects");
23
+ const query_1 = require("./commands/query");
25
24
  const schedulers_1 = require("./commands/schedulers");
26
- const tags_1 = require("./commands/tags");
27
- const content_1 = require("./commands/content");
28
25
  const schema_1 = require("./commands/schema");
26
+ const space_access_1 = require("./commands/space-access");
27
+ const spaces_1 = require("./commands/spaces");
28
+ const tags_1 = require("./commands/tags");
29
+ const users_1 = require("./commands/users");
29
30
  // Initialise audit log before any command runs (uses LIGHTDASH_TOOLS_AUDIT_LOG env var).
30
31
  (0, common_1.initAuditLog)(process.env.LIGHTDASH_TOOLS_AUDIT_LOG);
31
32
  const program = new commander_1.Command();
32
33
  program
33
34
  .name('lightdash-ai')
34
35
  .description('CLI for Lightdash AI')
35
- .version('0.5.0')
36
+ .version('0.7.0')
36
37
  .option('--safety-mode <mode>', 'Safety mode (read-only, write-idempotent, write-destructive)', 'read-only')
37
38
  .option('--projects <uuids>', 'Comma-separated list of allowed project UUIDs (security guardrail)')
38
39
  .option('--dry-run', 'Simulate mutating operations without executing (env: LIGHTDASH_TOOLS_DRY_RUN=1)');
@@ -47,6 +48,7 @@ program
47
48
  (0, charts_1.registerChartsCommand)(program);
48
49
  (0, dashboards_1.registerDashboardsCommand)(program);
49
50
  (0, ai_agents_1.registerAiAgentsCommand)(program);
51
+ (0, agentops_1.registerAgentopsCommand)(program);
50
52
  (0, agents_1.registerAgentsCommand)(program);
51
53
  (0, groups_1.registerGroupsCommand)(program);
52
54
  (0, users_1.registerUsersCommand)(program);
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
3
  const commander_1 = require("commander");
4
+ const vitest_1 = require("vitest");
5
+ const ai_agents_1 = require("./commands/ai-agents");
6
+ const charts_1 = require("./commands/charts");
7
+ const dashboards_1 = require("./commands/dashboards");
8
+ const explores_1 = require("./commands/explores");
9
+ const groups_1 = require("./commands/groups");
5
10
  const organization_1 = require("./commands/organization");
6
11
  const organization_roles_1 = require("./commands/organization-roles");
7
- const projects_1 = require("./commands/projects");
8
- const project_role_assignments_1 = require("./commands/project-role-assignments");
9
12
  const project_access_1 = require("./commands/project-access");
10
- const spaces_1 = require("./commands/spaces");
13
+ const project_role_assignments_1 = require("./commands/project-role-assignments");
14
+ const projects_1 = require("./commands/projects");
11
15
  const space_access_1 = require("./commands/space-access");
12
- const charts_1 = require("./commands/charts");
13
- const dashboards_1 = require("./commands/dashboards");
14
- const ai_agents_1 = require("./commands/ai-agents");
15
- const groups_1 = require("./commands/groups");
16
+ const spaces_1 = require("./commands/spaces");
16
17
  const users_1 = require("./commands/users");
17
- const explores_1 = require("./commands/explores");
18
18
  (0, vitest_1.describe)('CLI Command Registration', () => {
19
19
  (0, vitest_1.it)('should register organization command', () => {
20
20
  const program = new commander_1.Command();
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Build optional API params from CLI options, omitting null/undefined values.
3
+ */
4
+ export declare function pickDefined<T extends Record<string, unknown>>(source: T): Partial<T> | undefined;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pickDefined = pickDefined;
4
+ /**
5
+ * Build optional API params from CLI options, omitting null/undefined values.
6
+ */
7
+ function pickDefined(source) {
8
+ const params = {};
9
+ for (const [key, value] of Object.entries(source)) {
10
+ if (value != null) {
11
+ params[key] = value;
12
+ }
13
+ }
14
+ return Object.keys(params).length > 0 ? params : undefined;
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const cli_params_1 = require("./cli-params");
5
+ (0, vitest_1.describe)('pickDefined', () => {
6
+ (0, vitest_1.it)('returns undefined when all values are null or undefined', () => {
7
+ (0, vitest_1.expect)((0, cli_params_1.pickDefined)({ page: undefined, search: null })).toBeUndefined();
8
+ });
9
+ (0, vitest_1.it)('returns only defined entries', () => {
10
+ (0, vitest_1.expect)((0, cli_params_1.pickDefined)({ page: 1, search: undefined, name: 'x' })).toEqual({ page: 1, name: 'x' });
11
+ });
12
+ });
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Read and parse JSON or YAML from --file or stdin.
3
+ */
4
+ export type FileInputOptions = {
5
+ file?: string;
6
+ stdin?: boolean;
7
+ };
8
+ /**
9
+ * True when the caller explicitly requested file or stdin input (--file / --stdin).
10
+ * Unlike {@link readFileOrStdin}, does not treat a non-TTY stdin as implicit input,
11
+ * so flag-only commands work in CI where stdin is closed.
12
+ */
13
+ export declare function hasExplicitFileInput(options: FileInputOptions): boolean;
14
+ /**
15
+ * Reads YAML/JSON only when --file or --stdin was explicitly requested.
16
+ * Use for commands that also support flag-based bodies in non-TTY environments.
17
+ */
18
+ export declare function readExplicitFileOrStdin(options: FileInputOptions): Promise<string>;
19
+ /**
20
+ * Reads raw text from a file path or stdin (when --stdin is set or stdin is piped).
21
+ */
22
+ export declare function readFileOrStdin(options: FileInputOptions): Promise<string>;
23
+ /**
24
+ * Parses a string as JSON (object/array) or YAML.
25
+ */
26
+ export declare function parseJsonOrYaml(content: string): unknown;
27
+ /**
28
+ * Reads from file or stdin and parses as JSON or YAML.
29
+ */
30
+ export declare function readParsedInput(options: FileInputOptions): Promise<unknown>;