@lightdash-tools/cli 0.6.0 → 0.8.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 (110) hide show
  1. package/README.md +8 -4
  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.d.ts +1 -2
  46. package/dist/commands/schema.js +24 -97
  47. package/dist/commands/schema.test.js +80 -15
  48. package/dist/commands/space-access.js +12 -21
  49. package/dist/commands/spaces.js +6 -15
  50. package/dist/commands/tags.js +6 -15
  51. package/dist/commands/users.js +23 -41
  52. package/dist/index.js +18 -16
  53. package/dist/index.test.js +9 -9
  54. package/dist/utils/cli-params.d.ts +4 -0
  55. package/dist/utils/cli-params.js +15 -0
  56. package/dist/utils/cli-params.test.d.ts +1 -0
  57. package/dist/utils/cli-params.test.js +12 -0
  58. package/dist/utils/file-input.d.ts +30 -0
  59. package/dist/utils/file-input.js +77 -0
  60. package/dist/utils/file-input.test.d.ts +1 -0
  61. package/dist/utils/file-input.test.js +68 -0
  62. package/dist/utils/safety.d.ts +5 -0
  63. package/dist/utils/safety.js +97 -109
  64. package/dist/utils/safety.test.js +135 -33
  65. package/package.json +14 -5
  66. package/src/commands/agentops/apply.ts +77 -0
  67. package/src/commands/agentops/bundle-schema.ts +20 -0
  68. package/src/commands/agentops/drift.ts +63 -0
  69. package/src/commands/agentops/evaluate-gate.ts +128 -0
  70. package/src/commands/agentops/gate-schema.ts +20 -0
  71. package/src/commands/agentops/plan.ts +55 -0
  72. package/src/commands/agentops/state.ts +5 -0
  73. package/src/commands/agentops.test.ts +454 -0
  74. package/src/commands/agentops.ts +28 -0
  75. package/src/commands/agents-crud.ts +193 -0
  76. package/src/commands/agents-discovery.test.ts +16 -0
  77. package/src/commands/agents-discovery.ts +180 -0
  78. package/src/commands/agents-evals.ts +353 -0
  79. package/src/commands/agents-threads.ts +116 -0
  80. package/src/commands/agents.ts +9 -493
  81. package/src/commands/ai-agents.ts +37 -28
  82. package/src/commands/charts.ts +6 -3
  83. package/src/commands/content.ts +3 -1
  84. package/src/commands/dashboards.ts +3 -1
  85. package/src/commands/explores.ts +3 -1
  86. package/src/commands/groups.ts +33 -33
  87. package/src/commands/metrics.ts +3 -1
  88. package/src/commands/organization-roles.ts +3 -1
  89. package/src/commands/organization.ts +3 -1
  90. package/src/commands/project-access.ts +3 -1
  91. package/src/commands/project-role-assignments.ts +3 -1
  92. package/src/commands/projects.ts +44 -18
  93. package/src/commands/query.ts +4 -1
  94. package/src/commands/schedulers.ts +3 -1
  95. package/src/commands/schema.test.ts +95 -16
  96. package/src/commands/schema.ts +42 -99
  97. package/src/commands/space-access.ts +3 -1
  98. package/src/commands/spaces.ts +3 -1
  99. package/src/commands/tags.ts +3 -1
  100. package/src/commands/users.ts +29 -25
  101. package/src/index.test.ts +10 -9
  102. package/src/index.ts +19 -16
  103. package/src/utils/cli-params.test.ts +13 -0
  104. package/src/utils/cli-params.ts +12 -0
  105. package/src/utils/client.test.ts +1 -0
  106. package/src/utils/file-input.test.ts +91 -0
  107. package/src/utils/file-input.ts +83 -0
  108. package/src/utils/safety.test.ts +158 -2
  109. package/src/utils/safety.ts +27 -20
  110. package/tsconfig.json +2 -1
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Charts (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.registerChartsCommand = registerChartsCommand;
16
7
  const fs_1 = require("fs");
@@ -20,34 +11,32 @@ const safety_1 = require("../utils/safety");
20
11
  /**
21
12
  * Reads JSON from stdin or a file (for chart-as-code upsert body).
22
13
  */
23
- function readChartJsonInput(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 readChartJsonInput(filePath) {
15
+ if (filePath) {
16
+ const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
17
+ return JSON.parse(content);
18
+ }
19
+ return new Promise((resolve, reject) => {
20
+ if (process.stdin.isTTY) {
21
+ reject(new Error('No input provided. Use --file <path> or pipe JSON to stdin.'));
22
+ return;
28
23
  }
29
- return new Promise((resolve, reject) => {
30
- if (process.stdin.isTTY) {
31
- reject(new Error('No input provided. Use --file <path> or pipe JSON to stdin.'));
32
- return;
24
+ const chunks = [];
25
+ process.stdin.setEncoding('utf8');
26
+ process.stdin.on('data', (chunk) => {
27
+ chunks.push(Buffer.from(chunk));
28
+ });
29
+ process.stdin.on('end', () => {
30
+ try {
31
+ const input = Buffer.concat(chunks).toString('utf-8');
32
+ resolve(JSON.parse(input));
33
33
  }
34
- const chunks = [];
35
- process.stdin.setEncoding('utf8');
36
- process.stdin.on('data', (chunk) => {
37
- chunks.push(Buffer.from(chunk));
38
- });
39
- process.stdin.on('end', () => {
40
- try {
41
- const input = Buffer.concat(chunks).toString('utf-8');
42
- resolve(JSON.parse(input));
43
- }
44
- catch (err) {
45
- reject(new Error(`Failed to parse JSON: ${err instanceof Error ? err.message : String(err)}`));
46
- }
47
- });
48
- process.stdin.on('error', (err) => {
49
- reject(err);
50
- });
34
+ catch (err) {
35
+ reject(new Error(`Failed to parse JSON: ${err instanceof Error ? err.message : String(err)}`));
36
+ }
37
+ });
38
+ process.stdin.on('error', (err) => {
39
+ reject(err);
51
40
  });
52
41
  });
53
42
  }
@@ -64,18 +53,18 @@ function registerChartsCommand(program) {
64
53
  .description('List project charts and charts-as-code operations (v1)');
65
54
  chartsCmd
66
55
  .command('list <projectUuid>')
67
- .description('List charts in a project')
68
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
56
+ .description('List charts in a project (using charts-as-code API)')
57
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
69
58
  try {
70
59
  const client = (0, client_1.getClient)();
71
- const result = yield client.v1.charts.listCharts(projectUuid);
60
+ const result = await client.v1.charts.getChartsAsCode(projectUuid);
72
61
  console.log(JSON.stringify(result, null, 2));
73
62
  }
74
63
  catch (error) {
75
64
  console.error('Error listing charts:', error instanceof Error ? error.message : String(error));
76
65
  process.exit(1);
77
66
  }
78
- })));
67
+ }));
79
68
  const codeCmd = chartsCmd
80
69
  .command('code')
81
70
  .description('Charts as code (get list, upsert by slug)');
@@ -85,10 +74,10 @@ function registerChartsCommand(program) {
85
74
  .option('--ids <ids...>', 'Filter by chart IDs (slugs)')
86
75
  .option('--offset <number>', 'Pagination offset', (v) => parseInt(v, 10))
87
76
  .option('--language-map', 'Include language map in response')
88
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, options) => __awaiter(this, void 0, void 0, function* () {
77
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, options) => {
89
78
  try {
90
79
  const client = (0, client_1.getClient)();
91
- const result = yield client.v1.charts.getChartsAsCode(projectUuid, {
80
+ const result = await client.v1.charts.getChartsAsCode(projectUuid, {
92
81
  ids: options.ids,
93
82
  offset: options.offset,
94
83
  languageMap: options.languageMap,
@@ -99,21 +88,21 @@ function registerChartsCommand(program) {
99
88
  console.error('Error getting charts as code:', error instanceof Error ? error.message : String(error));
100
89
  process.exit(1);
101
90
  }
102
- })));
91
+ }));
103
92
  codeCmd
104
93
  .command('upsert <projectUuid> <slug>')
105
94
  .description('Upsert a chart from code (body from --file or stdin)')
106
95
  .option('--file <path>', 'Read chart JSON from file (default: stdin)')
107
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid, slug, options) => __awaiter(this, void 0, void 0, function* () {
96
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (projectUuid, slug, options) => {
108
97
  try {
109
- const body = yield readChartJsonInput(options.file);
98
+ const body = await readChartJsonInput(options.file);
110
99
  const client = (0, client_1.getClient)();
111
- const result = yield client.v1.charts.upsertChartAsCode(projectUuid, slug, body);
100
+ const result = await client.v1.charts.upsertChartAsCode(projectUuid, slug, body);
112
101
  console.log(JSON.stringify(result, null, 2));
113
102
  }
114
103
  catch (error) {
115
104
  console.error('Error upserting chart as code:', error instanceof Error ? error.message : String(error));
116
105
  process.exit(1);
117
106
  }
118
- })));
107
+ }));
119
108
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Content 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.registerContentCommand = registerContentCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -28,10 +19,10 @@ function registerContentCommand(program) {
28
19
  .option('--type <types...>', 'Filter by content types (chart, dashboard, space)')
29
20
  .option('--page <number>', 'Page number', (v) => parseInt(v, 10))
30
21
  .option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
31
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (query, options) => __awaiter(this, void 0, void 0, function* () {
22
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (query, options) => {
32
23
  try {
33
24
  const client = (0, client_1.getClient)();
34
- const result = yield client.v2.content.searchContent({
25
+ const result = await client.v2.content.searchContent({
35
26
  search: query,
36
27
  projectUuids: options.projects,
37
28
  contentTypes: options.type,
@@ -44,5 +35,5 @@ function registerContentCommand(program) {
44
35
  console.error('Error searching content:', error instanceof Error ? error.message : String(error));
45
36
  process.exit(1);
46
37
  }
47
- })));
38
+ }));
48
39
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Dashboards (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.registerDashboardsCommand = registerDashboardsCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -30,15 +21,15 @@ function registerDashboardsCommand(program) {
30
21
  dashboardsCmd
31
22
  .command('list <projectUuid>')
32
23
  .description('List dashboards in a project')
33
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
24
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
34
25
  try {
35
26
  const client = (0, client_1.getClient)();
36
- const result = yield client.v1.dashboards.listDashboards(projectUuid);
27
+ const result = await client.v1.dashboards.listDashboards(projectUuid);
37
28
  console.log(JSON.stringify(result, null, 2));
38
29
  }
39
30
  catch (error) {
40
31
  console.error('Error listing dashboards:', error instanceof Error ? error.message : String(error));
41
32
  process.exit(1);
42
33
  }
43
- })));
34
+ }));
44
35
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Explores (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.registerExploresCommand = registerExploresCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -30,57 +21,57 @@ function registerExploresCommand(program) {
30
21
  exploresCmd
31
22
  .command('list <projectUuid>')
32
23
  .description('List explores in a project')
33
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
24
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
34
25
  try {
35
26
  const client = (0, client_1.getClient)();
36
- const result = yield client.v1.explores.listExplores(projectUuid);
27
+ const result = await client.v1.explores.listExplores(projectUuid);
37
28
  console.log(JSON.stringify(result, null, 2));
38
29
  }
39
30
  catch (error) {
40
31
  console.error('Error listing explores:', error instanceof Error ? error.message : String(error));
41
32
  process.exit(1);
42
33
  }
43
- })));
34
+ }));
44
35
  exploresCmd
45
36
  .command('get <projectUuid> <exploreId>')
46
37
  .description('Get an explore by ID')
47
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, exploreId) => __awaiter(this, void 0, void 0, function* () {
38
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, exploreId) => {
48
39
  try {
49
40
  const client = (0, client_1.getClient)();
50
- const result = yield client.v1.explores.getExplore(projectUuid, exploreId);
41
+ const result = await client.v1.explores.getExplore(projectUuid, exploreId);
51
42
  console.log(JSON.stringify(result, null, 2));
52
43
  }
53
44
  catch (error) {
54
45
  console.error('Error fetching explore:', error instanceof Error ? error.message : String(error));
55
46
  process.exit(1);
56
47
  }
57
- })));
48
+ }));
58
49
  exploresCmd
59
50
  .command('dimensions <projectUuid> <exploreId>')
60
51
  .description('List dimensions for an explore')
61
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, exploreId) => __awaiter(this, void 0, void 0, function* () {
52
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, exploreId) => {
62
53
  try {
63
54
  const client = (0, client_1.getClient)();
64
- const result = yield client.v1.explores.listDimensions(projectUuid, exploreId);
55
+ const result = await client.v1.explores.listDimensions(projectUuid, exploreId);
65
56
  console.log(JSON.stringify(result, null, 2));
66
57
  }
67
58
  catch (error) {
68
59
  console.error('Error listing dimensions:', error instanceof Error ? error.message : String(error));
69
60
  process.exit(1);
70
61
  }
71
- })));
62
+ }));
72
63
  exploresCmd
73
64
  .command('lineage <projectUuid> <exploreId> <fieldId>')
74
65
  .description('Get lineage for a field in an explore')
75
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, exploreId, fieldId) => __awaiter(this, void 0, void 0, function* () {
66
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, exploreId, fieldId) => {
76
67
  try {
77
68
  const client = (0, client_1.getClient)();
78
- const result = yield client.v1.explores.getFieldLineage(projectUuid, exploreId, fieldId);
69
+ const result = await client.v1.explores.getFieldLineage(projectUuid, exploreId, fieldId);
79
70
  console.log(JSON.stringify(result, null, 2));
80
71
  }
81
72
  catch (error) {
82
73
  console.error('Error fetching lineage:', error instanceof Error ? error.message : String(error));
83
74
  process.exit(1);
84
75
  }
85
- })));
76
+ }));
86
77
  }
@@ -2,20 +2,25 @@
2
2
  /**
3
3
  * Groups 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.registerGroupsCommand = registerGroupsCommand;
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 listGroups(client, options) {
12
+ const shared = {
13
+ searchQuery: options.search,
14
+ includeMembers: options.includeMembers,
15
+ };
16
+ if (options.all) {
17
+ const list = await client.v1.groups.listAllGroups((0, cli_params_1.pickDefined)(shared));
18
+ console.log(JSON.stringify(list, null, 2));
19
+ return;
20
+ }
21
+ const result = await client.v1.groups.listGroups((0, cli_params_1.pickDefined)(Object.assign({ page: options.page, pageSize: options.pageSize }, shared)));
22
+ console.log(JSON.stringify(result, null, 2));
23
+ }
19
24
  /**
20
25
  * Registers the groups command and its subcommands.
21
26
  * Uses client.v1.groups (typed client) per ADR-0010.
@@ -30,73 +35,49 @@ function registerGroupsCommand(program) {
30
35
  .option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
31
36
  .option('--search <query>', 'Search query')
32
37
  .option('--include-members <number>', 'Include members (0 or 1)', (v) => parseInt(v, 10))
33
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const options = this.opts();
36
- try {
37
- const client = (0, client_1.getClient)();
38
- if (options.all) {
39
- const listParams = {};
40
- if (options.search != null)
41
- listParams.searchQuery = options.search;
42
- if (options.includeMembers != null)
43
- listParams.includeMembers = options.includeMembers;
44
- const list = yield client.v1.groups.listAllGroups(Object.keys(listParams).length > 0 ? listParams : undefined);
45
- console.log(JSON.stringify(list, null, 2));
46
- }
47
- else {
48
- const params = {};
49
- if (options.page != null)
50
- params.page = options.page;
51
- if (options.pageSize != null)
52
- params.pageSize = options.pageSize;
53
- if (options.search != null)
54
- params.searchQuery = options.search;
55
- if (options.includeMembers != null)
56
- params.includeMembers = options.includeMembers;
57
- const result = yield client.v1.groups.listGroups(Object.keys(params).length > 0 ? params : undefined);
58
- console.log(JSON.stringify(result, null, 2));
59
- }
60
- }
61
- catch (error) {
62
- console.error('Error listing groups:', error instanceof Error ? error.message : String(error));
63
- process.exit(1);
64
- }
65
- });
38
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async function () {
39
+ const options = this.opts();
40
+ try {
41
+ await listGroups((0, client_1.getClient)(), options);
42
+ }
43
+ catch (error) {
44
+ console.error('Error listing groups:', error instanceof Error ? error.message : String(error));
45
+ process.exit(1);
46
+ }
66
47
  }));
67
48
  groupsCmd
68
49
  .command('get <groupUuid>')
69
50
  .description('Get a group by UUID')
70
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (groupUuid) => __awaiter(this, void 0, void 0, function* () {
51
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (groupUuid) => {
71
52
  try {
72
53
  const client = (0, client_1.getClient)();
73
- const group = yield client.v1.groups.getGroup(groupUuid);
54
+ const group = await client.v1.groups.getGroup(groupUuid);
74
55
  console.log(JSON.stringify(group, null, 2));
75
56
  }
76
57
  catch (error) {
77
58
  console.error('Error fetching group:', error instanceof Error ? error.message : String(error));
78
59
  process.exit(1);
79
60
  }
80
- })));
61
+ }));
81
62
  groupsCmd
82
63
  .command('create <name>')
83
64
  .description('Create a new group')
84
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (name) => __awaiter(this, void 0, void 0, function* () {
65
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (name) => {
85
66
  try {
86
67
  const client = (0, client_1.getClient)();
87
- const group = yield client.v1.groups.createGroup({ name });
68
+ const group = await client.v1.groups.createGroup({ name });
88
69
  console.log(JSON.stringify(group, null, 2));
89
70
  }
90
71
  catch (error) {
91
72
  console.error('Error creating group:', error instanceof Error ? error.message : String(error));
92
73
  process.exit(1);
93
74
  }
94
- })));
75
+ }));
95
76
  groupsCmd
96
77
  .command('update <groupUuid>')
97
78
  .description('Update a group')
98
79
  .option('--name <name>', 'New name for the group')
99
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (groupUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
80
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (groupUuid, cmd) => {
100
81
  const options = cmd.opts();
101
82
  if (!options.name) {
102
83
  console.error('Error: --name is required for update');
@@ -104,69 +85,69 @@ function registerGroupsCommand(program) {
104
85
  }
105
86
  try {
106
87
  const client = (0, client_1.getClient)();
107
- const group = yield client.v1.groups.updateGroup(groupUuid, { name: options.name });
88
+ const group = await client.v1.groups.updateGroup(groupUuid, { name: options.name });
108
89
  console.log(JSON.stringify(group, null, 2));
109
90
  }
110
91
  catch (error) {
111
92
  console.error('Error updating group:', error instanceof Error ? error.message : String(error));
112
93
  process.exit(1);
113
94
  }
114
- })));
95
+ }));
115
96
  groupsCmd
116
97
  .command('delete <groupUuid>')
117
98
  .description('Delete a group')
118
- .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (groupUuid) => __awaiter(this, void 0, void 0, function* () {
99
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (groupUuid) => {
119
100
  try {
120
101
  const client = (0, client_1.getClient)();
121
- yield client.v1.groups.deleteGroup(groupUuid);
102
+ await client.v1.groups.deleteGroup(groupUuid);
122
103
  console.error(`Group ${groupUuid} deleted successfully`);
123
104
  }
124
105
  catch (error) {
125
106
  console.error('Error deleting group:', error instanceof Error ? error.message : String(error));
126
107
  process.exit(1);
127
108
  }
128
- })));
109
+ }));
129
110
  const membersCmd = groupsCmd.command('members').description('Manage group members');
130
111
  membersCmd
131
112
  .command('list <groupUuid>')
132
113
  .description('List members of a group')
133
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (groupUuid) => __awaiter(this, void 0, void 0, function* () {
114
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (groupUuid) => {
134
115
  try {
135
116
  const client = (0, client_1.getClient)();
136
- const members = yield client.v1.groups.getGroupMembers(groupUuid);
117
+ const members = await client.v1.groups.getGroupMembers(groupUuid);
137
118
  console.log(JSON.stringify(members, null, 2));
138
119
  }
139
120
  catch (error) {
140
121
  console.error('Error listing group members:', error instanceof Error ? error.message : String(error));
141
122
  process.exit(1);
142
123
  }
143
- })));
124
+ }));
144
125
  membersCmd
145
126
  .command('add <groupUuid> <userUuid>')
146
127
  .description('Add a user to a group')
147
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (groupUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
128
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (groupUuid, userUuid) => {
148
129
  try {
149
130
  const client = (0, client_1.getClient)();
150
- yield client.v1.groups.addUserToGroup(groupUuid, userUuid);
131
+ await client.v1.groups.addUserToGroup(groupUuid, userUuid);
151
132
  console.error(`User ${userUuid} added to group ${groupUuid} successfully`);
152
133
  }
153
134
  catch (error) {
154
135
  console.error('Error adding user to group:', error instanceof Error ? error.message : String(error));
155
136
  process.exit(1);
156
137
  }
157
- })));
138
+ }));
158
139
  membersCmd
159
140
  .command('remove <groupUuid> <userUuid>')
160
141
  .description('Remove a user from a group')
161
- .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (groupUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
142
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (groupUuid, userUuid) => {
162
143
  try {
163
144
  const client = (0, client_1.getClient)();
164
- yield client.v1.groups.removeUserFromGroup(groupUuid, userUuid);
145
+ await client.v1.groups.removeUserFromGroup(groupUuid, userUuid);
165
146
  console.error(`User ${userUuid} removed from group ${groupUuid} successfully`);
166
147
  }
167
148
  catch (error) {
168
149
  console.error('Error removing user from group:', error instanceof Error ? error.message : String(error));
169
150
  process.exit(1);
170
151
  }
171
- })));
152
+ }));
172
153
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Metrics 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.registerMetricsCommand = registerMetricsCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -27,10 +18,10 @@ function registerMetricsCommand(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.metrics.listMetrics(projectUuid, {
24
+ const result = await client.v1.metrics.listMetrics(projectUuid, {
34
25
  search: options.search,
35
26
  page: options.page,
36
27
  pageSize: options.pageSize,
@@ -41,19 +32,19 @@ function registerMetricsCommand(program) {
41
32
  console.error('Error listing metrics:', error instanceof Error ? error.message : String(error));
42
33
  process.exit(1);
43
34
  }
44
- })));
35
+ }));
45
36
  metricsCmd
46
37
  .command('get <projectUuid> <tableName> <metricName>')
47
38
  .description('Get a metric by table and name')
48
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, tableName, metricName) => __awaiter(this, void 0, void 0, function* () {
39
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, tableName, metricName) => {
49
40
  try {
50
41
  const client = (0, client_1.getClient)();
51
- const result = yield client.v1.metrics.getMetric(projectUuid, tableName, metricName);
42
+ const result = await client.v1.metrics.getMetric(projectUuid, tableName, metricName);
52
43
  console.log(JSON.stringify(result, null, 2));
53
44
  }
54
45
  catch (error) {
55
46
  console.error('Error fetching metric:', error instanceof Error ? error.message : String(error));
56
47
  process.exit(1);
57
48
  }
58
- })));
49
+ }));
59
50
  }