@lightdash-tools/client 0.6.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 (237) hide show
  1. package/README.md +2 -2
  2. package/dist/agentops/apply-agent-change.d.ts +3 -0
  3. package/dist/agentops/apply-agent-change.js +63 -0
  4. package/dist/agentops/apply-bundle-diff.d.ts +13 -0
  5. package/dist/agentops/apply-bundle-diff.js +44 -0
  6. package/dist/agentops/apply-bundle-diff.test.d.ts +1 -0
  7. package/dist/agentops/apply-bundle-diff.test.js +397 -0
  8. package/dist/agentops/apply-context.d.ts +14 -0
  9. package/dist/agentops/apply-context.js +6 -0
  10. package/dist/agentops/apply-evaluation-change.d.ts +3 -0
  11. package/dist/agentops/apply-evaluation-change.js +78 -0
  12. package/dist/agentops/fetch-bundle-state.d.ts +6 -0
  13. package/dist/agentops/fetch-bundle-state.js +20 -0
  14. package/dist/agentops/fetch-bundle-state.test.d.ts +1 -0
  15. package/dist/agentops/fetch-bundle-state.test.js +44 -0
  16. package/dist/agentops/index.d.ts +3 -0
  17. package/dist/agentops/index.js +9 -0
  18. package/dist/agentops/resolve-evaluation-run.d.ts +15 -0
  19. package/dist/agentops/resolve-evaluation-run.js +48 -0
  20. package/dist/api/v1/ai-agents/admin.d.ts +16 -0
  21. package/dist/api/v1/ai-agents/admin.js +29 -0
  22. package/dist/api/v1/ai-agents/agents.d.ts +18 -0
  23. package/dist/api/v1/ai-agents/agents.js +31 -0
  24. package/dist/api/v1/ai-agents/artifacts.d.ts +26 -0
  25. package/dist/api/v1/ai-agents/artifacts.js +41 -0
  26. package/dist/api/v1/ai-agents/artifacts.test.d.ts +1 -0
  27. package/dist/api/v1/ai-agents/artifacts.test.js +69 -0
  28. package/dist/api/v1/ai-agents/discovery.d.ts +28 -0
  29. package/dist/api/v1/ai-agents/discovery.js +46 -0
  30. package/dist/api/v1/ai-agents/discovery.test.d.ts +1 -0
  31. package/dist/api/v1/ai-agents/discovery.test.js +90 -0
  32. package/dist/api/v1/ai-agents/evaluations.d.ts +39 -0
  33. package/dist/api/v1/ai-agents/evaluations.js +70 -0
  34. package/dist/api/v1/ai-agents/facade.d.ts +79 -0
  35. package/dist/api/v1/ai-agents/facade.js +193 -0
  36. package/dist/api/v1/ai-agents/feedback.d.ts +10 -0
  37. package/dist/api/v1/ai-agents/feedback.js +15 -0
  38. package/dist/api/v1/ai-agents/feedback.test.d.ts +1 -0
  39. package/dist/api/v1/ai-agents/feedback.test.js +23 -0
  40. package/dist/api/v1/ai-agents/index.d.ts +1 -0
  41. package/dist/api/v1/ai-agents/index.js +5 -0
  42. package/dist/api/v1/ai-agents/mcp-servers.d.ts +20 -0
  43. package/dist/api/v1/ai-agents/mcp-servers.js +35 -0
  44. package/dist/api/v1/ai-agents/mcp-servers.test.d.ts +1 -0
  45. package/dist/api/v1/ai-agents/mcp-servers.test.js +66 -0
  46. package/dist/api/v1/ai-agents/request-options.d.ts +12 -0
  47. package/dist/api/v1/ai-agents/request-options.js +20 -0
  48. package/dist/api/v1/ai-agents/sql-approval.d.ts +10 -0
  49. package/dist/api/v1/ai-agents/sql-approval.js +15 -0
  50. package/dist/api/v1/ai-agents/sql-approval.test.d.ts +1 -0
  51. package/dist/api/v1/ai-agents/sql-approval.test.js +25 -0
  52. package/dist/api/v1/ai-agents/threads.d.ts +56 -0
  53. package/dist/api/v1/ai-agents/threads.js +97 -0
  54. package/dist/api/v1/ai-agents/threads.test.d.ts +1 -0
  55. package/dist/api/v1/ai-agents/threads.test.js +39 -0
  56. package/dist/api/v1/ai-agents.test.js +172 -89
  57. package/dist/api/v1/analytics.d.ts +10 -0
  58. package/dist/api/v1/analytics.js +14 -0
  59. package/dist/api/v1/analytics.test.d.ts +4 -0
  60. package/dist/api/v1/analytics.test.js +27 -0
  61. package/dist/api/v1/charts.d.ts +5 -2
  62. package/dist/api/v1/charts.js +18 -30
  63. package/dist/api/v1/charts.test.js +19 -28
  64. package/dist/api/v1/dashboards.d.ts +11 -2
  65. package/dist/api/v1/dashboards.js +19 -14
  66. package/dist/api/v1/dashboards.test.js +54 -12
  67. package/dist/api/v1/explores.d.ts +4 -2
  68. package/dist/api/v1/explores.js +20 -29
  69. package/dist/api/v1/explores.test.js +31 -21
  70. package/dist/api/v1/groups.d.ts +1 -1
  71. package/dist/api/v1/groups.js +25 -51
  72. package/dist/api/v1/groups.test.js +15 -24
  73. package/dist/api/v1/metrics.d.ts +2 -2
  74. package/dist/api/v1/metrics.js +4 -17
  75. package/dist/api/v1/metrics.test.js +6 -15
  76. package/dist/api/v1/organizations.d.ts +1 -1
  77. package/dist/api/v1/organizations.js +2 -13
  78. package/dist/api/v1/organizations.test.js +3 -12
  79. package/dist/api/v1/project-access.d.ts +1 -1
  80. package/dist/api/v1/project-access.js +18 -45
  81. package/dist/api/v1/project-access.test.js +27 -36
  82. package/dist/api/v1/projects.d.ts +1 -1
  83. package/dist/api/v1/projects.js +6 -21
  84. package/dist/api/v1/projects.test.js +9 -18
  85. package/dist/api/v1/query.d.ts +5 -2
  86. package/dist/api/v1/query.js +8 -18
  87. package/dist/api/v1/query.test.js +6 -15
  88. package/dist/api/v1/schedulers.d.ts +2 -2
  89. package/dist/api/v1/schedulers.js +4 -17
  90. package/dist/api/v1/schedulers.test.js +6 -15
  91. package/dist/api/v1/spaces.d.ts +1 -1
  92. package/dist/api/v1/spaces.js +18 -45
  93. package/dist/api/v1/spaces.test.js +27 -36
  94. package/dist/api/v1/tags.d.ts +1 -1
  95. package/dist/api/v1/tags.js +4 -17
  96. package/dist/api/v1/tags.test.js +6 -15
  97. package/dist/api/v1/users.d.ts +3 -1
  98. package/dist/api/v1/users.js +22 -39
  99. package/dist/api/v1/users.test.js +44 -30
  100. package/dist/api/v1/validation.d.ts +5 -2
  101. package/dist/api/v1/validation.js +8 -18
  102. package/dist/api/v1/validation.test.js +6 -15
  103. package/dist/api/v2/content.d.ts +2 -2
  104. package/dist/api/v2/content.js +3 -14
  105. package/dist/api/v2/content.test.js +3 -12
  106. package/dist/api/v2/dashboards.d.ts +10 -0
  107. package/dist/api/v2/dashboards.js +14 -0
  108. package/dist/api/v2/dashboards.test.d.ts +4 -0
  109. package/dist/api/v2/dashboards.test.js +27 -0
  110. package/dist/api/v2/organization-roles.d.ts +1 -1
  111. package/dist/api/v2/organization-roles.js +21 -50
  112. package/dist/api/v2/organization-roles.test.js +33 -42
  113. package/dist/api/v2/project-role-assignments.d.ts +1 -1
  114. package/dist/api/v2/project-role-assignments.js +12 -33
  115. package/dist/api/v2/project-role-assignments.test.js +18 -27
  116. package/dist/api/v2/query.d.ts +1 -1
  117. package/dist/api/v2/query.js +10 -29
  118. package/dist/api/v2/query.test.js +15 -24
  119. package/dist/api/v2/validation.d.ts +28 -0
  120. package/dist/api/v2/validation.js +23 -0
  121. package/dist/client.d.ts +20 -14
  122. package/dist/client.js +22 -16
  123. package/dist/config.d.ts +35 -10
  124. package/dist/http/axios-client.d.ts +4 -4
  125. package/dist/http/http-client.d.ts +3 -3
  126. package/dist/http/http-client.js +19 -40
  127. package/dist/http/interceptors.d.ts +3 -3
  128. package/dist/http/interceptors.js +16 -3
  129. package/dist/http/rate-limiter.js +2 -13
  130. package/dist/http/rate-limiter.test.js +15 -24
  131. package/dist/index.d.ts +7 -2
  132. package/dist/index.js +12 -1
  133. package/dist/index.test.js +13 -5
  134. package/dist/pagination/fetch-all-pages.js +18 -29
  135. package/dist/pagination/fetch-all-pages.test.js +15 -24
  136. package/dist/types/api.d.ts +1 -1
  137. package/dist/utils/env.d.ts +11 -2
  138. package/dist/utils/env.js +41 -8
  139. package/dist/utils/env.test.js +14 -4
  140. package/dist/utils/logger.js +5 -4
  141. package/dist/utils/retry.js +17 -28
  142. package/dist/utils/retry.test.js +9 -18
  143. package/dist/utils/secret-string.test.d.ts +1 -0
  144. package/dist/utils/secret-string.test.js +25 -0
  145. package/package.json +12 -4
  146. package/src/agentops/apply-agent-change.ts +82 -0
  147. package/src/agentops/apply-bundle-diff.test.ts +453 -0
  148. package/src/agentops/apply-bundle-diff.ts +63 -0
  149. package/src/agentops/apply-context.ts +23 -0
  150. package/src/agentops/apply-evaluation-change.ts +125 -0
  151. package/src/agentops/fetch-bundle-state.test.ts +51 -0
  152. package/src/agentops/fetch-bundle-state.ts +33 -0
  153. package/src/agentops/index.ts +11 -0
  154. package/src/agentops/resolve-evaluation-run.ts +94 -0
  155. package/src/api/v1/ai-agents/admin.ts +41 -0
  156. package/src/api/v1/ai-agents/agents.ts +40 -0
  157. package/src/api/v1/ai-agents/artifacts.test.ts +84 -0
  158. package/src/api/v1/ai-agents/artifacts.ts +92 -0
  159. package/src/api/v1/ai-agents/discovery.test.ts +102 -0
  160. package/src/api/v1/ai-agents/discovery.ts +79 -0
  161. package/src/api/v1/ai-agents/evaluations.ts +152 -0
  162. package/src/api/v1/ai-agents/facade.ts +489 -0
  163. package/src/api/v1/ai-agents/feedback.test.ts +30 -0
  164. package/src/api/v1/ai-agents/feedback.ts +24 -0
  165. package/src/api/v1/ai-agents/index.ts +1 -0
  166. package/src/api/v1/ai-agents/mcp-servers.test.ts +81 -0
  167. package/src/api/v1/ai-agents/mcp-servers.ts +67 -0
  168. package/src/api/v1/ai-agents/request-options.ts +32 -0
  169. package/src/api/v1/ai-agents/sql-approval.test.ts +32 -0
  170. package/src/api/v1/ai-agents/sql-approval.ts +24 -0
  171. package/src/api/v1/ai-agents/threads.test.ts +55 -0
  172. package/src/api/v1/ai-agents/threads.ts +216 -0
  173. package/src/api/v1/ai-agents.test.ts +189 -13
  174. package/src/api/v1/analytics.test.ts +32 -0
  175. package/src/api/v1/analytics.ts +16 -0
  176. package/src/api/v1/charts.test.ts +8 -6
  177. package/src/api/v1/charts.ts +8 -4
  178. package/src/api/v1/dashboards.test.ts +57 -0
  179. package/src/api/v1/dashboards.ts +41 -2
  180. package/src/api/v1/explores.test.ts +22 -0
  181. package/src/api/v1/explores.ts +13 -2
  182. package/src/api/v1/groups.test.ts +2 -0
  183. package/src/api/v1/groups.ts +9 -7
  184. package/src/api/v1/metrics.test.ts +2 -0
  185. package/src/api/v1/metrics.ts +3 -2
  186. package/src/api/v1/organizations.test.ts +2 -0
  187. package/src/api/v1/organizations.ts +2 -1
  188. package/src/api/v1/project-access.test.ts +3 -1
  189. package/src/api/v1/project-access.ts +2 -1
  190. package/src/api/v1/projects.test.ts +2 -0
  191. package/src/api/v1/projects.ts +2 -1
  192. package/src/api/v1/query.test.ts +2 -0
  193. package/src/api/v1/query.ts +6 -2
  194. package/src/api/v1/schedulers.test.ts +2 -0
  195. package/src/api/v1/schedulers.ts +3 -2
  196. package/src/api/v1/spaces.test.ts +2 -0
  197. package/src/api/v1/spaces.ts +2 -1
  198. package/src/api/v1/tags.test.ts +2 -0
  199. package/src/api/v1/tags.ts +2 -1
  200. package/src/api/v1/users.test.ts +26 -0
  201. package/src/api/v1/users.ts +8 -2
  202. package/src/api/v1/validation.test.ts +2 -0
  203. package/src/api/v1/validation.ts +6 -2
  204. package/src/api/v2/content.test.ts +2 -0
  205. package/src/api/v2/content.ts +3 -2
  206. package/src/api/v2/dashboards.test.ts +32 -0
  207. package/src/api/v2/dashboards.ts +18 -0
  208. package/src/api/v2/organization-roles.test.ts +2 -0
  209. package/src/api/v2/organization-roles.ts +2 -1
  210. package/src/api/v2/project-role-assignments.test.ts +2 -0
  211. package/src/api/v2/project-role-assignments.ts +2 -1
  212. package/src/api/v2/query.test.ts +2 -0
  213. package/src/api/v2/query.ts +2 -1
  214. package/src/api/v2/validation.ts +48 -0
  215. package/src/client.test.ts +1 -0
  216. package/src/client.ts +27 -17
  217. package/src/config.ts +38 -10
  218. package/src/errors.test.ts +1 -0
  219. package/src/http/axios-client.ts +8 -5
  220. package/src/http/http-client.ts +8 -6
  221. package/src/http/interceptors.ts +23 -10
  222. package/src/http/rate-limiter.test.ts +1 -0
  223. package/src/http/rate-limiter.ts +3 -1
  224. package/src/index.test.ts +16 -7
  225. package/src/index.ts +16 -1
  226. package/src/pagination/fetch-all-pages.test.ts +2 -0
  227. package/src/types/api.ts +1 -1
  228. package/src/utils/env.test.ts +16 -4
  229. package/src/utils/env.ts +61 -10
  230. package/src/utils/logger.ts +6 -4
  231. package/src/utils/retry.test.ts +1 -0
  232. package/src/utils/retry.ts +2 -1
  233. package/src/utils/secret-string.test.ts +27 -0
  234. package/tsconfig.json +4 -2
  235. package/dist/api/v1/ai-agents.d.ts +0 -63
  236. package/dist/api/v1/ai-agents.js +0 -173
  237. package/src/api/v1/ai-agents.ts +0 -252
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { MetricsClient } from './metrics';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('MetricsClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Metrics API client.
3
3
  */
4
4
 
5
- import type { LightdashApi } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { LightdashApi } from '@lightdash-tools/common';
8
+
8
9
  /** Query params for listing metrics in catalog. */
9
10
  export interface ListMetricsParams {
10
11
  search?: string;
@@ -13,7 +14,7 @@ export interface ListMetricsParams {
13
14
  sort?: string;
14
15
  order?: 'asc' | 'desc';
15
16
  categories?: string[];
16
- categoriesFilterMode?: 'any' | 'all';
17
+ categoriesFilterMode?: 'all' | 'any';
17
18
  tables?: string[];
18
19
  ownerUserUuids?: string[];
19
20
  }
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { OrganizationsClient } from './organizations';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('OrganizationsClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Organizations API client.
3
3
  */
4
4
 
5
- import type { Organization } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { Organization } from '@lightdash-tools/common';
8
+
8
9
  export class OrganizationsClient extends BaseApiClient {
9
10
  /** Get the current user's organization. */
10
11
  async getCurrentOrganization(): Promise<Organization> {
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { ProjectAccessClient } from './project-access';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('ProjectAccessClient', () => {
@@ -85,7 +87,7 @@ describe('ProjectAccessClient', () => {
85
87
  const client = new ProjectAccessClient(mockHttp);
86
88
  const created = { groupUuid: 'g1', projectUuid: 'p1', role: 'viewer' };
87
89
  vi.mocked(mockHttp.post).mockResolvedValue(created);
88
- const body = { role: 'viewer' };
90
+ const body = { role: 'viewer' as const };
89
91
  const result = await client.addProjectAccessToGroup('g1', 'p1', body);
90
92
  expect(mockHttp.post).toHaveBeenCalledWith('/groups/g1/projects/p1', body);
91
93
  expect(result).toEqual(created);
@@ -2,9 +2,10 @@
2
2
  * Project access API client (project-level user and group access).
3
3
  */
4
4
 
5
- import type { LightdashApi } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { LightdashApi } from '@lightdash-tools/common';
8
+
8
9
  export class ProjectAccessClient extends BaseApiClient {
9
10
  /** List users with explicit project access. */
10
11
  async listProjectAccess(
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { ProjectsClient } from './projects';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('ProjectsClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Projects API client. Endpoints for project and project-scoped resources.
3
3
  */
4
4
 
5
- import type { Project, OrganizationProject, SpaceQuery } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { Project, OrganizationProject, SpaceQuery } from '@lightdash-tools/common';
8
+
8
9
  export class ProjectsClient extends BaseApiClient {
9
10
  /** Get a project by UUID. */
10
11
  async getProject(projectUuid: string): Promise<Project> {
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { QueryClient } from './query';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
  import type { MetricQueryRequest, CompileQueryRequest } from '@lightdash-tools/common';
5
7
 
@@ -2,16 +2,20 @@
2
2
  * Query API client. Run metric/SQL/underlying data queries.
3
3
  */
4
4
 
5
+ import { BaseApiClient } from '../base-client';
6
+
5
7
  import type {
6
8
  MetricQueryRequest,
7
9
  RunQueryResults,
8
10
  CompileQueryRequest,
9
11
  CompiledQueryResults,
10
12
  } from '@lightdash-tools/common';
11
- import { BaseApiClient } from '../base-client';
12
13
 
13
14
  export class QueryClient extends BaseApiClient {
14
- /** Run a metric query for an explore. */
15
+ /**
16
+ * Run a metric query for an explore.
17
+ * @deprecated This API endpoint is deprecated in Lightdash. Use v2 query API instead.
18
+ */
15
19
  async runQuery(
16
20
  projectUuid: string,
17
21
  exploreId: string,
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { SchedulersClient } from './schedulers';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('SchedulersClient', () => {
@@ -2,15 +2,16 @@
2
2
  * Schedulers API client.
3
3
  */
4
4
 
5
- import type { LightdashApi } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { LightdashApi } from '@lightdash-tools/common';
8
+
8
9
  /** Query params for listing schedulers. */
9
10
  export interface ListSchedulersParams {
10
11
  pageSize?: number;
11
12
  page?: number;
12
13
  searchQuery?: string;
13
- sortBy?: 'name' | 'createdAt';
14
+ sortBy?: 'createdAt' | 'name';
14
15
  sortDirection?: 'asc' | 'desc';
15
16
  createdByUserUuids?: string;
16
17
  formats?: string;
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { SpacesClient } from './spaces';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('SpacesClient', () => {
@@ -2,6 +2,8 @@
2
2
  * Spaces API client.
3
3
  */
4
4
 
5
+ import { BaseApiClient } from '../base-client';
6
+
5
7
  import type {
6
8
  LightdashApi,
7
9
  SpaceSummary,
@@ -10,7 +12,6 @@ import type {
10
12
  AddSpaceUserAccess,
11
13
  AddSpaceGroupAccess,
12
14
  } from '@lightdash-tools/common';
13
- import { BaseApiClient } from '../base-client';
14
15
 
15
16
  export class SpacesClient extends BaseApiClient {
16
17
  /** List spaces in a project. */
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { TagsClient } from './tags';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('TagsClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Tags API client.
3
3
  */
4
4
 
5
- import type { LightdashApi } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { LightdashApi } from '@lightdash-tools/common';
8
+
8
9
  export class TagsClient extends BaseApiClient {
9
10
  /** List tags in a project. */
10
11
  async listTags(projectUuid: string): Promise<LightdashApi.Tags.ApiGetTagsResponse> {
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { UsersClient } from './users';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('UsersClient', () => {
@@ -26,6 +28,30 @@ describe('UsersClient', () => {
26
28
  expect(result).toEqual(results);
27
29
  });
28
30
 
31
+ it('getAuthenticatedUser should call GET /user (resolved to /api/v1/user)', async () => {
32
+ const client = new UsersClient(mockHttp);
33
+ const user = {
34
+ userUuid: 'u1',
35
+ email: 'a@example.com',
36
+ firstName: 'A',
37
+ lastName: 'User',
38
+ userId: 1,
39
+ isTrackingAnonymized: false,
40
+ isMarketingOptedIn: false,
41
+ isSetupComplete: true,
42
+ isActive: true,
43
+ createdAt: '2026-01-01T00:00:00.000Z',
44
+ updatedAt: '2026-01-01T00:00:00.000Z',
45
+ timezone: null,
46
+ organizationUuid: 'org-1',
47
+ impersonation: null,
48
+ };
49
+ vi.mocked(mockHttp.get).mockResolvedValue(user);
50
+ const result = await client.getAuthenticatedUser();
51
+ expect(mockHttp.get).toHaveBeenCalledWith('/user');
52
+ expect(result).toEqual(user);
53
+ });
54
+
29
55
  it('getMemberByUuid should call GET /org/users/{userUuid}', async () => {
30
56
  const client = new UsersClient(mockHttp);
31
57
  const member = {
@@ -2,9 +2,10 @@
2
2
  * Users (organization members) API client.
3
3
  */
4
4
 
5
- import type { LightdashApi } from '@lightdash-tools/common';
6
- import { BaseApiClient } from '../base-client';
7
5
  import { fetchAllPages } from '../../pagination/fetch-all-pages';
6
+ import { BaseApiClient } from '../base-client';
7
+
8
+ import type { LightdashApi } from '@lightdash-tools/common';
8
9
 
9
10
  /** Query params for listing organization members. */
10
11
  export interface ListMembersParams {
@@ -73,4 +74,9 @@ export class UsersClient extends BaseApiClient {
73
74
  async deleteMember(userUuid: string): Promise<void> {
74
75
  await this.http.delete(`/org/user/${userUuid}`);
75
76
  }
77
+
78
+ /** Get the currently authenticated Lightdash user (`GET /api/v1/user`). */
79
+ async getAuthenticatedUser(): Promise<LightdashApi.Users.AuthenticatedUser> {
80
+ return this.http.get<LightdashApi.Users.AuthenticatedUser>('/user');
81
+ }
76
82
  }
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { ValidationClient } from './validation';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('ValidationClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Validation API client.
3
3
  */
4
4
 
5
- import type { LightdashApi } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { LightdashApi } from '@lightdash-tools/common';
8
+
8
9
  /** Query params for getting validation results. */
9
10
  export interface GetValidationResultsParams {
10
11
  fromSettings?: boolean;
@@ -19,7 +20,10 @@ export interface ValidateProjectBody {
19
20
  }
20
21
 
21
22
  export class ValidationClient extends BaseApiClient {
22
- /** Get validation results for a project. */
23
+ /**
24
+ * Get validation results for a project.
25
+ * @deprecated Use v2 validation API (ListValidationResults) instead.
26
+ */
23
27
  async getValidationResults(
24
28
  projectUuid: string,
25
29
  params?: GetValidationResultsParams,
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { ContentClient } from './content';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('ContentClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Content API client (v2).
3
3
  */
4
4
 
5
- import type { LightdashApi } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { LightdashApi } from '@lightdash-tools/common';
8
+
8
9
  /** Query params for searching content. */
9
10
  export interface SearchContentParams {
10
11
  projectUuids?: string[];
@@ -14,7 +15,7 @@ export interface SearchContentParams {
14
15
  pageSize?: number;
15
16
  page?: number;
16
17
  search?: string;
17
- sortBy?: 'name' | 'createdAt' | 'updatedAt' | 'lastViewedAt' | 'views';
18
+ sortBy?: LightdashApi.Content.ContentSortByColumns;
18
19
  sortDirection?: 'asc' | 'desc';
19
20
  }
20
21
 
@@ -0,0 +1,32 @@
1
+ /**
2
+ * V2 dashboards client unit tests.
3
+ */
4
+
5
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
6
+
7
+ import { DashboardsClientV2 } from './dashboards';
8
+
9
+ import type { HttpClient } from '../../http/http-client';
10
+
11
+ describe('DashboardsClientV2', () => {
12
+ let mockHttp: HttpClient;
13
+
14
+ beforeEach(() => {
15
+ mockHttp = {
16
+ get: vi.fn(),
17
+ post: vi.fn(),
18
+ put: vi.fn(),
19
+ patch: vi.fn(),
20
+ delete: vi.fn(),
21
+ } as unknown as HttpClient;
22
+ });
23
+
24
+ it('getDashboard calls GET /projects/{projectUuid}/dashboards/{id}', async () => {
25
+ const client = new DashboardsClientV2(mockHttp);
26
+ const mockResponse = { uuid: 'd1', name: 'Sales' };
27
+ vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
28
+ const result = await client.getDashboard('p1', 'd1');
29
+ expect(mockHttp.get).toHaveBeenCalledWith('/projects/p1/dashboards/d1');
30
+ expect(result).toEqual(mockResponse);
31
+ });
32
+ });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Dashboards API client (v2). Metadata reads only (no query execution).
3
+ */
4
+
5
+ import { BaseApiClient } from '../base-client';
6
+
7
+ import type { components } from '@lightdash-tools/common';
8
+
9
+ export type Dashboard = components['schemas']['Dashboard'];
10
+
11
+ export class DashboardsClientV2 extends BaseApiClient {
12
+ /** Get dashboard metadata by UUID or slug within a project. Does not run queries. */
13
+ async getDashboard(projectUuid: string, dashboardUuidOrSlug: string): Promise<Dashboard> {
14
+ return this.http.get<Dashboard>(
15
+ `/projects/${projectUuid}/dashboards/${encodeURIComponent(dashboardUuidOrSlug)}`,
16
+ );
17
+ }
18
+ }
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { OrganizationRolesClient } from './organization-roles';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('OrganizationRolesClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Organization roles API client (v2). Manage org-level roles and role assignments.
3
3
  */
4
4
 
5
- import type { components } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { components } from '@lightdash-tools/common';
8
+
8
9
  type CreateRole = components['schemas']['CreateRole'];
9
10
  type UpdateRole = components['schemas']['UpdateRole'];
10
11
  type AddScopesToRole = components['schemas']['AddScopesToRole'];
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { ProjectRoleAssignmentsClient } from './project-role-assignments';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('ProjectRoleAssignmentsClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Project role assignments API client (v2). Manage project-level role assignments for users and groups.
3
3
  */
4
4
 
5
- import type { components } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { components } from '@lightdash-tools/common';
8
+
8
9
  type RoleAssignment = components['schemas']['RoleAssignment'];
9
10
  type UpsertUserRoleAssignmentRequest = components['schemas']['UpsertUserRoleAssignmentRequest'];
10
11
  type UpdateRoleAssignmentRequest = components['schemas']['UpdateRoleAssignmentRequest'];
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { QueryClientV2 } from './query';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
  import type {
5
7
  ExecuteAsyncMetricQueryRequestParams,
@@ -2,6 +2,8 @@
2
2
  * Query API client for v2 endpoints. Run metric/SQL/underlying data queries using v2 API.
3
3
  */
4
4
 
5
+ import { BaseApiClient } from '../base-client';
6
+
5
7
  import type {
6
8
  ExecuteAsyncMetricQueryRequestParams,
7
9
  ExecuteAsyncSqlQueryRequestParams,
@@ -12,7 +14,6 @@ import type {
12
14
  ExecuteAsyncDashboardChartResults,
13
15
  ExecuteAsyncSqlQueryResults,
14
16
  } from '@lightdash-tools/common';
15
- import { BaseApiClient } from '../base-client';
16
17
 
17
18
  export class QueryClientV2 extends BaseApiClient {
18
19
  /** Run a metric query (v2 endpoint). */
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Validation API client (v2). Paginated validation results with search, filter, and sort support.
3
+ */
4
+
5
+ import { BaseApiClient } from '../base-client';
6
+
7
+ import type { components } from '@lightdash-tools/common';
8
+
9
+ /** Query params for listing validation results (v2). */
10
+ export interface ListValidationResultsParams {
11
+ page?: number;
12
+ pageSize?: number;
13
+ searchQuery?: string;
14
+ sortBy?: 'createdAt' | 'errorType' | 'name' | 'source';
15
+ sortDirection?: 'asc' | 'desc';
16
+ sourceTypes?: string;
17
+ errorTypes?: string;
18
+ includeChartConfigWarnings?: boolean;
19
+ fromSettings?: boolean;
20
+ }
21
+
22
+ export class ValidationClientV2 extends BaseApiClient {
23
+ /**
24
+ * List validation results for a project (v2 endpoint).
25
+ * Returns paginated results with search, filter, and sort support.
26
+ */
27
+ async listValidationResults(
28
+ projectUuid: string,
29
+ params?: ListValidationResultsParams,
30
+ ): Promise<components['schemas']['ApiPaginatedValidateResponse']> {
31
+ return this.http.get<components['schemas']['ApiPaginatedValidateResponse']>(
32
+ `/projects/${projectUuid}/validate`,
33
+ { params },
34
+ );
35
+ }
36
+
37
+ /**
38
+ * Get a single validation result by ID (v2 endpoint).
39
+ */
40
+ async getValidationResult(
41
+ projectUuid: string,
42
+ validationId: number,
43
+ ): Promise<components['schemas']['ApiSingleValidationResponse']> {
44
+ return this.http.get<components['schemas']['ApiSingleValidationResponse']>(
45
+ `/projects/${projectUuid}/validate/${validationId}`,
46
+ );
47
+ }
48
+ }
@@ -1,4 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { LightdashClient } from './client';
3
4
 
4
5
  describe('LightdashClient', () => {
package/src/client.ts CHANGED
@@ -2,30 +2,34 @@
2
2
  * Main Lightdash API client. Configuration can be explicit or loaded from environment variables.
3
3
  */
4
4
 
5
- import type { PartialLightdashClientConfig } from './config';
6
- import { mergeConfig } from './utils/env';
7
- import { createAxiosInstanceV1, createAxiosInstanceV2 } from './http/axios-client';
8
- import { RateLimiter } from './http/rate-limiter';
9
- import { HttpClient } from './http/http-client';
10
- import { ProjectsClient } from './api/v1/projects';
11
- import { OrganizationsClient } from './api/v1/organizations';
5
+ import { AiAgentsClient } from './api/v1/ai-agents';
6
+ import { AnalyticsClient } from './api/v1/analytics';
12
7
  import { ChartsClient } from './api/v1/charts';
13
8
  import { DashboardsClient } from './api/v1/dashboards';
14
- import { SpacesClient } from './api/v1/spaces';
15
- import { QueryClient } from './api/v1/query';
16
- import { QueryClientV2 } from './api/v2/query';
17
- import { OrganizationRolesClient } from './api/v2/organization-roles';
18
- import { ProjectRoleAssignmentsClient } from './api/v2/project-role-assignments';
19
- import { UsersClient } from './api/v1/users';
20
- import { GroupsClient } from './api/v1/groups';
21
- import { AiAgentsClient } from './api/v1/ai-agents';
22
- import { ProjectAccessClient } from './api/v1/project-access';
23
9
  import { ExploresClient } from './api/v1/explores';
24
- import { ValidationClient } from './api/v1/validation';
10
+ import { GroupsClient } from './api/v1/groups';
25
11
  import { MetricsClient } from './api/v1/metrics';
12
+ import { OrganizationsClient } from './api/v1/organizations';
13
+ import { ProjectAccessClient } from './api/v1/project-access';
14
+ import { ProjectsClient } from './api/v1/projects';
15
+ import { QueryClient } from './api/v1/query';
26
16
  import { SchedulersClient } from './api/v1/schedulers';
17
+ import { SpacesClient } from './api/v1/spaces';
27
18
  import { TagsClient } from './api/v1/tags';
19
+ import { UsersClient } from './api/v1/users';
20
+ import { ValidationClient } from './api/v1/validation';
28
21
  import { ContentClient } from './api/v2/content';
22
+ import { DashboardsClientV2 } from './api/v2/dashboards';
23
+ import { OrganizationRolesClient } from './api/v2/organization-roles';
24
+ import { ProjectRoleAssignmentsClient } from './api/v2/project-role-assignments';
25
+ import { QueryClientV2 } from './api/v2/query';
26
+ import { ValidationClientV2 } from './api/v2/validation';
27
+ import { createAxiosInstanceV1, createAxiosInstanceV2 } from './http/axios-client';
28
+ import { HttpClient } from './http/http-client';
29
+ import { RateLimiter } from './http/rate-limiter';
30
+ import { mergeConfig } from './utils/env';
31
+
32
+ import type { PartialLightdashClientConfig } from './config';
29
33
 
30
34
  /**
31
35
  * V1 API clients namespace. Contains all v1 API clients.
@@ -46,6 +50,7 @@ export class V1ApiClients {
46
50
  readonly metrics: MetricsClient;
47
51
  readonly schedulers: SchedulersClient;
48
52
  readonly tags: TagsClient;
53
+ readonly analytics: AnalyticsClient;
49
54
 
50
55
  constructor(http: HttpClient) {
51
56
  this.projects = new ProjectsClient(http);
@@ -63,6 +68,7 @@ export class V1ApiClients {
63
68
  this.metrics = new MetricsClient(http);
64
69
  this.schedulers = new SchedulersClient(http);
65
70
  this.tags = new TagsClient(http);
71
+ this.analytics = new AnalyticsClient(http);
66
72
  }
67
73
  }
68
74
 
@@ -74,12 +80,16 @@ export class V2ApiClients {
74
80
  readonly organizationRoles: OrganizationRolesClient;
75
81
  readonly projectRoleAssignments: ProjectRoleAssignmentsClient;
76
82
  readonly content: ContentClient;
83
+ readonly validation: ValidationClientV2;
84
+ readonly dashboards: DashboardsClientV2;
77
85
 
78
86
  constructor(http: HttpClient) {
79
87
  this.query = new QueryClientV2(http);
80
88
  this.organizationRoles = new OrganizationRolesClient(http);
81
89
  this.projectRoleAssignments = new ProjectRoleAssignmentsClient(http);
82
90
  this.content = new ContentClient(http);
91
+ this.validation = new ValidationClientV2(http);
92
+ this.dashboards = new DashboardsClientV2(http);
83
93
  }
84
94
  }
85
95