@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
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Organization roles (v2) 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.registerOrganizationRolesCommand = registerOrganizationRolesCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -31,71 +22,69 @@ function registerOrganizationRolesCommand(program) {
31
22
  .description('List organization roles')
32
23
  .option('--load <value>', 'Load query param')
33
24
  .option('--role-type-filter <value>', 'Filter by role type')
34
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const options = this.opts();
37
- try {
38
- const client = (0, client_1.getClient)();
39
- const org = yield client.v1.organizations.getCurrentOrganization();
40
- const orgUuid = org.organizationUuid;
41
- const params = options.load != null || options.roleTypeFilter != null
42
- ? { load: options.load, roleTypeFilter: options.roleTypeFilter }
43
- : undefined;
44
- const result = yield client.v2.organizationRoles.getRoles(orgUuid, params);
45
- console.log(JSON.stringify(result, null, 2));
46
- }
47
- catch (error) {
48
- console.error('Error listing organization roles:', error instanceof Error ? error.message : String(error));
49
- process.exit(1);
50
- }
51
- });
25
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async function () {
26
+ const options = this.opts();
27
+ try {
28
+ const client = (0, client_1.getClient)();
29
+ const org = await client.v1.organizations.getCurrentOrganization();
30
+ const orgUuid = org.organizationUuid;
31
+ const params = options.load != null || options.roleTypeFilter != null
32
+ ? { load: options.load, roleTypeFilter: options.roleTypeFilter }
33
+ : undefined;
34
+ const result = await client.v2.organizationRoles.getRoles(orgUuid, params);
35
+ console.log(JSON.stringify(result, null, 2));
36
+ }
37
+ catch (error) {
38
+ console.error('Error listing organization roles:', error instanceof Error ? error.message : String(error));
39
+ process.exit(1);
40
+ }
52
41
  }));
53
42
  rolesCmd
54
43
  .command('get <roleUuid>')
55
44
  .description('Get an organization role by UUID')
56
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (roleUuid) => __awaiter(this, void 0, void 0, function* () {
45
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (roleUuid) => {
57
46
  try {
58
47
  const client = (0, client_1.getClient)();
59
- const org = yield client.v1.organizations.getCurrentOrganization();
48
+ const org = await client.v1.organizations.getCurrentOrganization();
60
49
  const orgUuid = org.organizationUuid;
61
- const role = yield client.v2.organizationRoles.getRole(orgUuid, roleUuid);
50
+ const role = await client.v2.organizationRoles.getRole(orgUuid, roleUuid);
62
51
  console.log(JSON.stringify(role, null, 2));
63
52
  }
64
53
  catch (error) {
65
54
  console.error('Error fetching organization role:', error instanceof Error ? error.message : String(error));
66
55
  process.exit(1);
67
56
  }
68
- })));
57
+ }));
69
58
  const assignmentsCmd = rolesCmd
70
59
  .command('assignments')
71
60
  .description('Organization role assignments');
72
61
  assignmentsCmd
73
62
  .command('list')
74
63
  .description('List organization role assignments')
75
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
64
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async () => {
76
65
  try {
77
66
  const client = (0, client_1.getClient)();
78
- const org = yield client.v1.organizations.getCurrentOrganization();
67
+ const org = await client.v1.organizations.getCurrentOrganization();
79
68
  const orgUuid = org.organizationUuid;
80
- const result = yield client.v2.organizationRoles.listRoleAssignments(orgUuid);
69
+ const result = await client.v2.organizationRoles.listRoleAssignments(orgUuid);
81
70
  console.log(JSON.stringify(result, null, 2));
82
71
  }
83
72
  catch (error) {
84
73
  console.error('Error listing role assignments:', error instanceof Error ? error.message : String(error));
85
74
  process.exit(1);
86
75
  }
87
- })));
76
+ }));
88
77
  rolesCmd
89
78
  .command('assign <userUuid>')
90
79
  .description('Assign an organization role to a user')
91
80
  .requiredOption('--role-id <roleId>', 'Role ID to assign')
92
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (userUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
81
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (userUuid, cmd) => {
93
82
  const options = cmd.opts();
94
83
  try {
95
84
  const client = (0, client_1.getClient)();
96
- const org = yield client.v1.organizations.getCurrentOrganization();
85
+ const org = await client.v1.organizations.getCurrentOrganization();
97
86
  const orgUuid = org.organizationUuid;
98
- const result = yield client.v2.organizationRoles.assignRoleToUser(orgUuid, userUuid, {
87
+ const result = await client.v2.organizationRoles.assignRoleToUser(orgUuid, userUuid, {
99
88
  roleId: options.roleId,
100
89
  });
101
90
  console.log(JSON.stringify(result, null, 2));
@@ -104,5 +93,5 @@ function registerOrganizationRolesCommand(program) {
104
93
  console.error('Error assigning role to user:', error instanceof Error ? error.message : String(error));
105
94
  process.exit(1);
106
95
  }
107
- })));
96
+ }));
108
97
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Organization 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.registerOrganizationCommand = registerOrganizationCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -24,15 +15,15 @@ function registerOrganizationCommand(program) {
24
15
  orgCmd
25
16
  .command('get')
26
17
  .description('Get current organization')
27
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
18
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async () => {
28
19
  try {
29
20
  const client = (0, client_1.getClient)();
30
- const org = yield client.v1.organizations.getCurrentOrganization();
21
+ const org = await client.v1.organizations.getCurrentOrganization();
31
22
  console.log(JSON.stringify(org, null, 2));
32
23
  }
33
24
  catch (error) {
34
25
  console.error('Error fetching organization:', error instanceof Error ? error.message : String(error));
35
26
  process.exit(1);
36
27
  }
37
- })));
28
+ }));
38
29
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Project 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.registerProjectAccessCommand = registerProjectAccessCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -28,44 +19,44 @@ function registerProjectAccessCommand(program) {
28
19
  accessCmd
29
20
  .command('list <projectUuid>')
30
21
  .description('List users with project access')
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.projectAccess.listProjectAccess(projectUuid);
25
+ const result = await client.v1.projectAccess.listProjectAccess(projectUuid);
35
26
  console.log(JSON.stringify(result, null, 2));
36
27
  }
37
28
  catch (error) {
38
29
  console.error('Error listing project access:', error instanceof Error ? error.message : String(error));
39
30
  process.exit(1);
40
31
  }
41
- })));
32
+ }));
42
33
  const groupsCmd = accessCmd.command('groups').description('Project group access');
43
34
  groupsCmd
44
35
  .command('list <projectUuid>')
45
36
  .description('List group access for a project')
46
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
37
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
47
38
  try {
48
39
  const client = (0, client_1.getClient)();
49
- const result = yield client.v1.projectAccess.listProjectGroupAccesses(projectUuid);
40
+ const result = await client.v1.projectAccess.listProjectGroupAccesses(projectUuid);
50
41
  console.log(JSON.stringify(result, null, 2));
51
42
  }
52
43
  catch (error) {
53
44
  console.error('Error listing project group access:', error instanceof Error ? error.message : String(error));
54
45
  process.exit(1);
55
46
  }
56
- })));
47
+ }));
57
48
  accessCmd
58
49
  .command('get <projectUuid> <userUuid>')
59
50
  .description('Get a project member access')
60
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
51
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, userUuid) => {
61
52
  try {
62
53
  const client = (0, client_1.getClient)();
63
- const result = yield client.v1.projectAccess.getProjectMemberAccess(projectUuid, userUuid);
54
+ const result = await client.v1.projectAccess.getProjectMemberAccess(projectUuid, userUuid);
64
55
  console.log(JSON.stringify(result, null, 2));
65
56
  }
66
57
  catch (error) {
67
58
  console.error('Error fetching project member access:', error instanceof Error ? error.message : String(error));
68
59
  process.exit(1);
69
60
  }
70
- })));
61
+ }));
71
62
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Project role assignments (v2) 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.registerProjectRoleAssignmentsCommand = registerProjectRoleAssignmentsCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -28,77 +19,77 @@ function registerProjectRoleAssignmentsCommand(program) {
28
19
  rolesCmd
29
20
  .command('list <projectUuid>')
30
21
  .description('List project role assignments')
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.v2.projectRoleAssignments.listAssignments(projectUuid);
25
+ const result = await client.v2.projectRoleAssignments.listAssignments(projectUuid);
35
26
  console.log(JSON.stringify(result, null, 2));
36
27
  }
37
28
  catch (error) {
38
29
  console.error('Error listing project role assignments:', error instanceof Error ? error.message : String(error));
39
30
  process.exit(1);
40
31
  }
41
- })));
32
+ }));
42
33
  const assignCmd = rolesCmd.command('assign').description('Assign role to user or group');
43
34
  assignCmd
44
35
  .command('user <projectUuid> <userUuid>')
45
36
  .description('Assign a role to a user in a project')
46
37
  .requiredOption('--role-id <roleId>', 'Role ID to assign')
47
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid, userUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
38
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (projectUuid, userUuid, cmd) => {
48
39
  const opts = cmd.opts();
49
40
  try {
50
41
  const client = (0, client_1.getClient)();
51
- const result = yield client.v2.projectRoleAssignments.upsertUserAssignment(projectUuid, userUuid, { roleId: opts.roleId });
42
+ const result = await client.v2.projectRoleAssignments.upsertUserAssignment(projectUuid, userUuid, { roleId: opts.roleId });
52
43
  console.log(JSON.stringify(result, null, 2));
53
44
  }
54
45
  catch (error) {
55
46
  console.error('Error assigning role to user:', error instanceof Error ? error.message : String(error));
56
47
  process.exit(1);
57
48
  }
58
- })));
49
+ }));
59
50
  assignCmd
60
51
  .command('group <projectUuid> <groupId>')
61
52
  .description('Assign a role to a group in a project')
62
53
  .requiredOption('--role-id <roleId>', 'Role ID to assign')
63
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid, groupId, cmd) => __awaiter(this, void 0, void 0, function* () {
54
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (projectUuid, groupId, cmd) => {
64
55
  const opts = cmd.opts();
65
56
  try {
66
57
  const client = (0, client_1.getClient)();
67
- const result = yield client.v2.projectRoleAssignments.upsertGroupAssignment(projectUuid, groupId, { roleId: opts.roleId });
58
+ const result = await client.v2.projectRoleAssignments.upsertGroupAssignment(projectUuid, groupId, { roleId: opts.roleId });
68
59
  console.log(JSON.stringify(result, null, 2));
69
60
  }
70
61
  catch (error) {
71
62
  console.error('Error assigning role to group:', error instanceof Error ? error.message : String(error));
72
63
  process.exit(1);
73
64
  }
74
- })));
65
+ }));
75
66
  const unassignCmd = rolesCmd.command('unassign').description('Remove role assignment');
76
67
  unassignCmd
77
68
  .command('user <projectUuid> <userUuid>')
78
69
  .description('Remove role assignment from a user')
79
- .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (projectUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
70
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (projectUuid, userUuid) => {
80
71
  try {
81
72
  const client = (0, client_1.getClient)();
82
- yield client.v2.projectRoleAssignments.deleteUserAssignment(projectUuid, userUuid);
73
+ await client.v2.projectRoleAssignments.deleteUserAssignment(projectUuid, userUuid);
83
74
  console.log(JSON.stringify({ ok: true }, null, 2));
84
75
  }
85
76
  catch (error) {
86
77
  console.error('Error removing user role assignment:', error instanceof Error ? error.message : String(error));
87
78
  process.exit(1);
88
79
  }
89
- })));
80
+ }));
90
81
  unassignCmd
91
82
  .command('group <projectUuid> <groupId>')
92
83
  .description('Remove role assignment from a group')
93
- .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (projectUuid, groupId) => __awaiter(this, void 0, void 0, function* () {
84
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (projectUuid, groupId) => {
94
85
  try {
95
86
  const client = (0, client_1.getClient)();
96
- yield client.v2.projectRoleAssignments.deleteGroupAssignment(projectUuid, groupId);
87
+ await client.v2.projectRoleAssignments.deleteGroupAssignment(projectUuid, groupId);
97
88
  console.log(JSON.stringify({ ok: true }, null, 2));
98
89
  }
99
90
  catch (error) {
100
91
  console.error('Error removing group role assignment:', error instanceof Error ? error.message : String(error));
101
92
  process.exit(1);
102
93
  }
103
- })));
94
+ }));
104
95
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Projects 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.registerProjectsCommand = registerProjectsCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -25,65 +16,81 @@ function registerProjectsCommand(program) {
25
16
  .command('get')
26
17
  .description('Get a project by UUID')
27
18
  .argument('<projectUuid>', 'Project UUID')
28
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
19
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
29
20
  try {
30
21
  if (!projectUuid) {
31
22
  console.error('Error: projectUuid is required');
32
23
  process.exit(1);
33
24
  }
34
25
  const client = (0, client_1.getClient)();
35
- const project = yield client.v1.projects.getProject(projectUuid);
26
+ const project = await client.v1.projects.getProject(projectUuid);
36
27
  console.log(JSON.stringify(project, null, 2));
37
28
  }
38
29
  catch (error) {
39
30
  console.error('Error fetching project:', error instanceof Error ? error.message : String(error));
40
31
  process.exit(1);
41
32
  }
42
- })));
33
+ }));
43
34
  projectsCmd
44
35
  .command('list')
45
36
  .description('List all projects in the current organization')
46
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
37
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async () => {
47
38
  try {
48
39
  const client = (0, client_1.getClient)();
49
- const projects = yield client.v1.projects.listProjects();
40
+ const projects = await client.v1.projects.listProjects();
50
41
  console.log(JSON.stringify(projects, null, 2));
51
42
  }
52
43
  catch (error) {
53
44
  console.error('Error listing projects:', error instanceof Error ? error.message : String(error));
54
45
  process.exit(1);
55
46
  }
56
- })));
47
+ }));
57
48
  const validateCmd = projectsCmd.command('validate').description('Project validation');
58
49
  validateCmd
59
50
  .command('run <projectUuid>')
60
51
  .description('Trigger project validation and get job ID')
61
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
52
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (projectUuid) => {
62
53
  try {
63
54
  const client = (0, client_1.getClient)();
64
- const result = yield client.v1.validation.validateProject(projectUuid);
55
+ const result = await client.v1.validation.validateProject(projectUuid);
65
56
  console.log(JSON.stringify(result, null, 2));
66
57
  }
67
58
  catch (error) {
68
59
  console.error('Error triggering validation:', error instanceof Error ? error.message : String(error));
69
60
  process.exit(1);
70
61
  }
71
- })));
62
+ }));
72
63
  validateCmd
73
64
  .command('results <projectUuid>')
74
- .description('Get latest validation results for a project')
75
- .option('--job-id <id>', 'Specific validation job ID')
76
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, options) => __awaiter(this, void 0, void 0, function* () {
65
+ .description('Get validation results for a project (v2 API, paginated)')
66
+ .option('--validation-id <id>', 'Specific validation result ID (number)')
67
+ .option('--page <number>', 'Page number (1-indexed)', (v) => parseInt(v, 10))
68
+ .option('--page-size <number>', 'Results per page', (v) => parseInt(v, 10))
69
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, options) => {
77
70
  try {
78
71
  const client = (0, client_1.getClient)();
79
- const result = yield client.v1.validation.getValidationResults(projectUuid, {
80
- jobId: options.jobId,
81
- });
82
- console.log(JSON.stringify(result, null, 2));
72
+ if (options.validationId) {
73
+ // Get specific validation result by ID
74
+ const validationId = parseInt(options.validationId, 10);
75
+ if (isNaN(validationId)) {
76
+ console.error('Error: validation-id must be a number');
77
+ process.exit(1);
78
+ }
79
+ const result = await client.v2.validation.getValidationResult(projectUuid, validationId);
80
+ console.log(JSON.stringify(result, null, 2));
81
+ }
82
+ else {
83
+ // List validation results (first page by default)
84
+ const result = await client.v2.validation.listValidationResults(projectUuid, {
85
+ page: options.page,
86
+ pageSize: options.pageSize,
87
+ });
88
+ console.log(JSON.stringify(result, null, 2));
89
+ }
83
90
  }
84
91
  catch (error) {
85
92
  console.error('Error fetching validation results:', error instanceof Error ? error.message : String(error));
86
93
  process.exit(1);
87
94
  }
88
- })));
95
+ }));
89
96
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Query 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.registerQueryCommand = registerQueryCommand;
16
7
  const fs_1 = require("fs");
@@ -20,36 +11,34 @@ const safety_1 = require("../utils/safety");
20
11
  /**
21
12
  * Reads JSON from stdin or a file.
22
13
  */
23
- function readJsonInput(filePath) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- if (filePath) {
26
- const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
27
- return JSON.parse(content);
14
+ async function readJsonInput(filePath) {
15
+ if (filePath) {
16
+ const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
17
+ return JSON.parse(content);
18
+ }
19
+ // Read from stdin
20
+ return new Promise((resolve, reject) => {
21
+ // Check if stdin is a TTY (interactive terminal)
22
+ if (process.stdin.isTTY) {
23
+ reject(new Error('No input provided. Use --file <path> or pipe JSON to stdin.'));
24
+ return;
28
25
  }
29
- // Read from stdin
30
- return new Promise((resolve, reject) => {
31
- // Check if stdin is a TTY (interactive terminal)
32
- if (process.stdin.isTTY) {
33
- reject(new Error('No input provided. Use --file <path> or pipe JSON to stdin.'));
34
- return;
26
+ const chunks = [];
27
+ process.stdin.setEncoding('utf8');
28
+ process.stdin.on('data', (chunk) => {
29
+ chunks.push(Buffer.from(chunk));
30
+ });
31
+ process.stdin.on('end', () => {
32
+ try {
33
+ const input = Buffer.concat(chunks).toString('utf-8');
34
+ resolve(JSON.parse(input));
35
35
  }
36
- const chunks = [];
37
- process.stdin.setEncoding('utf8');
38
- process.stdin.on('data', (chunk) => {
39
- chunks.push(Buffer.from(chunk));
40
- });
41
- process.stdin.on('end', () => {
42
- try {
43
- const input = Buffer.concat(chunks).toString('utf-8');
44
- resolve(JSON.parse(input));
45
- }
46
- catch (err) {
47
- reject(new Error(`Failed to parse JSON: ${err instanceof Error ? err.message : String(err)}`));
48
- }
49
- });
50
- process.stdin.on('error', (err) => {
51
- reject(err);
52
- });
36
+ catch (err) {
37
+ reject(new Error(`Failed to parse JSON: ${err instanceof Error ? err.message : String(err)}`));
38
+ }
39
+ });
40
+ process.stdin.on('error', (err) => {
41
+ reject(err);
53
42
  });
54
43
  });
55
44
  }
@@ -64,7 +53,7 @@ function registerQueryCommand(program) {
64
53
  .argument('<projectUuid>', 'Project UUID')
65
54
  .argument('<exploreId>', 'Explore ID')
66
55
  .option('--file <path>', 'Read metric query JSON from file (default: read from stdin)')
67
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, exploreId, options) => __awaiter(this, void 0, void 0, function* () {
56
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, exploreId, options) => {
68
57
  try {
69
58
  if (!projectUuid) {
70
59
  console.error('Error: projectUuid is required');
@@ -75,14 +64,14 @@ function registerQueryCommand(program) {
75
64
  process.exit(1);
76
65
  }
77
66
  // Read JSON input
78
- const body = (yield readJsonInput(options.file));
67
+ const body = (await readJsonInput(options.file));
79
68
  const client = (0, client_1.getClient)();
80
- const result = yield client.v1.query.compileQuery(projectUuid, exploreId, body);
69
+ const result = await client.v1.query.compileQuery(projectUuid, exploreId, body);
81
70
  console.log(JSON.stringify(result, null, 2));
82
71
  }
83
72
  catch (error) {
84
73
  console.error('Error compiling query:', error instanceof Error ? error.message : String(error));
85
74
  process.exit(1);
86
75
  }
87
- })));
76
+ }));
88
77
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Schedulers 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.registerSchedulersCommand = registerSchedulersCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -27,10 +18,10 @@ function registerSchedulersCommand(program) {
27
18
  .option('--search <query>', 'Search query')
28
19
  .option('--page <number>', 'Page number', (v) => parseInt(v, 10))
29
20
  .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* () {
21
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, options) => {
31
22
  try {
32
23
  const client = (0, client_1.getClient)();
33
- const result = yield client.v1.schedulers.listSchedulers(projectUuid, {
24
+ const result = await client.v1.schedulers.listSchedulers(projectUuid, {
34
25
  searchQuery: options.search,
35
26
  page: options.page,
36
27
  pageSize: options.pageSize,
@@ -41,19 +32,19 @@ function registerSchedulersCommand(program) {
41
32
  console.error('Error listing schedulers:', error instanceof Error ? error.message : String(error));
42
33
  process.exit(1);
43
34
  }
44
- })));
35
+ }));
45
36
  schedulersCmd
46
37
  .command('get <schedulerUuid>')
47
38
  .description('Get a scheduler by UUID')
48
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (schedulerUuid) => __awaiter(this, void 0, void 0, function* () {
39
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (schedulerUuid) => {
49
40
  try {
50
41
  const client = (0, client_1.getClient)();
51
- const result = yield client.v1.schedulers.getScheduler(schedulerUuid);
42
+ const result = await client.v1.schedulers.getScheduler(schedulerUuid);
52
43
  console.log(JSON.stringify(result, null, 2));
53
44
  }
54
45
  catch (error) {
55
46
  console.error('Error fetching scheduler:', error instanceof Error ? error.message : String(error));
56
47
  process.exit(1);
57
48
  }
58
- })));
49
+ }));
59
50
  }