@lightdash-tools/client 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 (256) 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 +13 -2
  62. package/dist/api/v1/charts.js +26 -30
  63. package/dist/api/v1/charts.test.js +35 -28
  64. package/dist/api/v1/dashboards.d.ts +42 -2
  65. package/dist/api/v1/dashboards.js +39 -14
  66. package/dist/api/v1/dashboards.test.js +126 -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 +9 -2
  101. package/dist/api/v1/validation.js +16 -18
  102. package/dist/api/v1/validation.test.js +22 -15
  103. package/dist/api/v2/charts.d.ts +12 -0
  104. package/dist/api/v2/charts.js +18 -0
  105. package/dist/api/v2/charts.test.d.ts +4 -0
  106. package/dist/api/v2/charts.test.js +45 -0
  107. package/dist/api/v2/content.d.ts +20 -3
  108. package/dist/api/v2/content.js +18 -14
  109. package/dist/api/v2/content.test.js +44 -12
  110. package/dist/api/v2/dashboards.d.ts +16 -0
  111. package/dist/api/v2/dashboards.js +22 -0
  112. package/dist/api/v2/dashboards.test.d.ts +4 -0
  113. package/dist/api/v2/dashboards.test.js +61 -0
  114. package/dist/api/v2/organization-roles.d.ts +1 -1
  115. package/dist/api/v2/organization-roles.js +21 -50
  116. package/dist/api/v2/organization-roles.test.js +33 -42
  117. package/dist/api/v2/parameters.d.ts +20 -0
  118. package/dist/api/v2/parameters.js +22 -0
  119. package/dist/api/v2/parameters.test.d.ts +4 -0
  120. package/dist/api/v2/parameters.test.js +39 -0
  121. package/dist/api/v2/project-role-assignments.d.ts +1 -1
  122. package/dist/api/v2/project-role-assignments.js +12 -33
  123. package/dist/api/v2/project-role-assignments.test.js +18 -27
  124. package/dist/api/v2/query.d.ts +16 -1
  125. package/dist/api/v2/query.js +26 -29
  126. package/dist/api/v2/query.test.js +31 -24
  127. package/dist/api/v2/validation.d.ts +28 -0
  128. package/dist/api/v2/validation.js +23 -0
  129. package/dist/client.d.ts +24 -14
  130. package/dist/client.js +26 -16
  131. package/dist/client.test.js +2 -0
  132. package/dist/config.d.ts +35 -10
  133. package/dist/http/axios-client.d.ts +4 -4
  134. package/dist/http/http-client.d.ts +3 -14
  135. package/dist/http/http-client.js +20 -43
  136. package/dist/http/interceptors.d.ts +3 -3
  137. package/dist/http/interceptors.js +16 -3
  138. package/dist/http/rate-limiter.js +2 -13
  139. package/dist/http/rate-limiter.test.js +15 -24
  140. package/dist/http/unwrap-api-success.d.ts +26 -0
  141. package/dist/http/unwrap-api-success.js +25 -0
  142. package/dist/http/unwrap-api-success.test.d.ts +1 -0
  143. package/dist/http/unwrap-api-success.test.js +19 -0
  144. package/dist/index.d.ts +13 -3
  145. package/dist/index.js +17 -1
  146. package/dist/index.test.js +13 -5
  147. package/dist/pagination/fetch-all-pages.js +18 -29
  148. package/dist/pagination/fetch-all-pages.test.js +15 -24
  149. package/dist/types/api.d.ts +1 -1
  150. package/dist/utils/env.d.ts +11 -2
  151. package/dist/utils/env.js +41 -8
  152. package/dist/utils/env.test.js +14 -4
  153. package/dist/utils/logger.js +5 -4
  154. package/dist/utils/retry.js +17 -28
  155. package/dist/utils/retry.test.js +9 -18
  156. package/dist/utils/secret-string.test.d.ts +1 -0
  157. package/dist/utils/secret-string.test.js +25 -0
  158. package/package.json +12 -4
  159. package/src/agentops/apply-agent-change.ts +82 -0
  160. package/src/agentops/apply-bundle-diff.test.ts +453 -0
  161. package/src/agentops/apply-bundle-diff.ts +63 -0
  162. package/src/agentops/apply-context.ts +23 -0
  163. package/src/agentops/apply-evaluation-change.ts +125 -0
  164. package/src/agentops/fetch-bundle-state.test.ts +51 -0
  165. package/src/agentops/fetch-bundle-state.ts +33 -0
  166. package/src/agentops/index.ts +11 -0
  167. package/src/agentops/resolve-evaluation-run.ts +94 -0
  168. package/src/api/v1/ai-agents/admin.ts +41 -0
  169. package/src/api/v1/ai-agents/agents.ts +40 -0
  170. package/src/api/v1/ai-agents/artifacts.test.ts +84 -0
  171. package/src/api/v1/ai-agents/artifacts.ts +92 -0
  172. package/src/api/v1/ai-agents/discovery.test.ts +102 -0
  173. package/src/api/v1/ai-agents/discovery.ts +79 -0
  174. package/src/api/v1/ai-agents/evaluations.ts +152 -0
  175. package/src/api/v1/ai-agents/facade.ts +489 -0
  176. package/src/api/v1/ai-agents/feedback.test.ts +30 -0
  177. package/src/api/v1/ai-agents/feedback.ts +24 -0
  178. package/src/api/v1/ai-agents/index.ts +1 -0
  179. package/src/api/v1/ai-agents/mcp-servers.test.ts +81 -0
  180. package/src/api/v1/ai-agents/mcp-servers.ts +67 -0
  181. package/src/api/v1/ai-agents/request-options.ts +32 -0
  182. package/src/api/v1/ai-agents/sql-approval.test.ts +32 -0
  183. package/src/api/v1/ai-agents/sql-approval.ts +24 -0
  184. package/src/api/v1/ai-agents/threads.test.ts +55 -0
  185. package/src/api/v1/ai-agents/threads.ts +216 -0
  186. package/src/api/v1/ai-agents.test.ts +189 -13
  187. package/src/api/v1/analytics.test.ts +32 -0
  188. package/src/api/v1/analytics.ts +16 -0
  189. package/src/api/v1/charts.test.ts +26 -6
  190. package/src/api/v1/charts.ts +25 -4
  191. package/src/api/v1/dashboards.test.ts +142 -0
  192. package/src/api/v1/dashboards.ts +127 -2
  193. package/src/api/v1/explores.test.ts +22 -0
  194. package/src/api/v1/explores.ts +13 -2
  195. package/src/api/v1/groups.test.ts +2 -0
  196. package/src/api/v1/groups.ts +9 -7
  197. package/src/api/v1/metrics.test.ts +2 -0
  198. package/src/api/v1/metrics.ts +3 -2
  199. package/src/api/v1/organizations.test.ts +2 -0
  200. package/src/api/v1/organizations.ts +2 -1
  201. package/src/api/v1/project-access.test.ts +3 -1
  202. package/src/api/v1/project-access.ts +2 -1
  203. package/src/api/v1/projects.test.ts +2 -0
  204. package/src/api/v1/projects.ts +2 -1
  205. package/src/api/v1/query.test.ts +2 -0
  206. package/src/api/v1/query.ts +6 -2
  207. package/src/api/v1/schedulers.test.ts +2 -0
  208. package/src/api/v1/schedulers.ts +3 -2
  209. package/src/api/v1/spaces.test.ts +2 -0
  210. package/src/api/v1/spaces.ts +2 -1
  211. package/src/api/v1/tags.test.ts +2 -0
  212. package/src/api/v1/tags.ts +2 -1
  213. package/src/api/v1/users.test.ts +26 -0
  214. package/src/api/v1/users.ts +8 -2
  215. package/src/api/v1/validation.test.ts +20 -0
  216. package/src/api/v1/validation.ts +26 -2
  217. package/src/api/v2/charts.test.ts +53 -0
  218. package/src/api/v2/charts.ts +23 -0
  219. package/src/api/v2/content.test.ts +47 -0
  220. package/src/api/v2/content.ts +37 -3
  221. package/src/api/v2/dashboards.test.ts +71 -0
  222. package/src/api/v2/dashboards.ts +40 -0
  223. package/src/api/v2/organization-roles.test.ts +2 -0
  224. package/src/api/v2/organization-roles.ts +2 -1
  225. package/src/api/v2/parameters.test.ts +45 -0
  226. package/src/api/v2/parameters.ts +38 -0
  227. package/src/api/v2/project-role-assignments.test.ts +2 -0
  228. package/src/api/v2/project-role-assignments.ts +2 -1
  229. package/src/api/v2/query.test.ts +20 -0
  230. package/src/api/v2/query.ts +55 -1
  231. package/src/api/v2/validation.ts +48 -0
  232. package/src/client.test.ts +3 -0
  233. package/src/client.ts +33 -17
  234. package/src/config.ts +38 -10
  235. package/src/errors.test.ts +1 -0
  236. package/src/http/axios-client.ts +8 -5
  237. package/src/http/http-client.ts +8 -21
  238. package/src/http/interceptors.ts +23 -10
  239. package/src/http/rate-limiter.test.ts +1 -0
  240. package/src/http/rate-limiter.ts +3 -1
  241. package/src/http/unwrap-api-success.test.ts +23 -0
  242. package/src/http/unwrap-api-success.ts +40 -0
  243. package/src/index.test.ts +16 -7
  244. package/src/index.ts +37 -2
  245. package/src/pagination/fetch-all-pages.test.ts +2 -0
  246. package/src/types/api.ts +1 -1
  247. package/src/utils/env.test.ts +16 -4
  248. package/src/utils/env.ts +61 -10
  249. package/src/utils/logger.ts +6 -4
  250. package/src/utils/retry.test.ts +1 -0
  251. package/src/utils/retry.ts +2 -1
  252. package/src/utils/secret-string.test.ts +27 -0
  253. package/tsconfig.json +4 -2
  254. package/dist/api/v1/ai-agents.d.ts +0 -63
  255. package/dist/api/v1/ai-agents.js +0 -173
  256. package/src/api/v1/ai-agents.ts +0 -252
@@ -1,10 +1,55 @@
1
1
  /**
2
- * Dashboards API client.
2
+ * Dashboards API client. Endpoints for project dashboards and dashboard-as-code operations.
3
3
  */
4
4
 
5
- import type { DashboardBasicDetailsWithTileTypes } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type {
8
+ DashboardBasicDetailsWithTileTypes,
9
+ DashboardAsCodeListResults,
10
+ DashboardAsCodeUpsertResults,
11
+ UpsertDashboardAsCodeBody,
12
+ components,
13
+ } from '@lightdash-tools/common';
14
+
15
+ export interface GetDashboardsAsCodeOptions {
16
+ ids?: string[];
17
+ offset?: number;
18
+ languageMap?: boolean;
19
+ }
20
+
21
+ /** Request body for POST projects/{projectUuid}/dashboards (create dashboard, or duplicate via query param). */
22
+ export type CreateDashboardBody =
23
+ components['schemas']['CreateDashboard'] | components['schemas']['DuplicateDashboardParams'];
24
+
25
+ /** Options for createDashboard. */
26
+ export interface CreateDashboardOptions {
27
+ /** UUID of an existing dashboard to duplicate from. When set, body should be DuplicateDashboardParams. */
28
+ duplicateFrom?: string;
29
+ }
30
+
31
+ /** Result of POST projects/{projectUuid}/dashboards (create dashboard). */
32
+ export type CreateDashboardResult = components['schemas']['ApiCreateDashboardResponse']['results'];
33
+
34
+ /** Results of GET dashboards/{dashboardUuidOrSlug}/history (dashboard version history). */
35
+ export type DashboardHistoryResults =
36
+ components['schemas']['ApiGetDashboardHistoryResponse']['results'];
37
+
38
+ /** Results of GET dashboards/{dashboardUuidOrSlug}/version/{versionUuid} (a single dashboard version). */
39
+ export type DashboardVersionResults =
40
+ components['schemas']['ApiGetDashboardVersionResponse']['results'];
41
+
42
+ /** Results of GET dashboards/{dashboardUuidOrSlug}/promoteDiff. */
43
+ export type DashboardPromoteDiffResults = components['schemas']['PromotionChanges'];
44
+
45
+ /** Results of POST dashboards/{dashboardUuidOrSlug}/promote. */
46
+ export type PromoteDashboardResult = components['schemas']['DashboardDAO'];
47
+
48
+ /** Optional query for promote / promoteDiff when a slug exists in multiple projects. */
49
+ export interface DashboardPromoteOptions {
50
+ projectUuid?: string;
51
+ }
52
+
8
53
  export class DashboardsClient extends BaseApiClient {
9
54
  /** List dashboards in a project. */
10
55
  async listDashboards(projectUuid: string): Promise<DashboardBasicDetailsWithTileTypes[]> {
@@ -12,4 +57,84 @@ export class DashboardsClient extends BaseApiClient {
12
57
  `/projects/${projectUuid}/dashboards`,
13
58
  );
14
59
  }
60
+
61
+ /** Get dashboards in code representation (for dashboards-as-code workflows). */
62
+ async getDashboardsAsCode(
63
+ projectUuid: string,
64
+ options?: GetDashboardsAsCodeOptions,
65
+ ): Promise<DashboardAsCodeListResults> {
66
+ const params: Record<string, unknown> = {};
67
+ if (options?.ids?.length) params.ids = options.ids;
68
+ if (options?.offset != null) params.offset = options.offset;
69
+ if (options?.languageMap != null) params.languageMap = options.languageMap;
70
+ return this.http.get<DashboardAsCodeListResults>(
71
+ `/projects/${projectUuid}/code/dashboards`,
72
+ Object.keys(params).length ? { params } : undefined,
73
+ );
74
+ }
75
+
76
+ /** Upsert a dashboard from code representation (create or update by slug). */
77
+ async upsertDashboardAsCode(
78
+ projectUuid: string,
79
+ slug: string,
80
+ body: UpsertDashboardAsCodeBody,
81
+ ): Promise<DashboardAsCodeUpsertResults> {
82
+ return this.http.post<DashboardAsCodeUpsertResults>(
83
+ `/projects/${projectUuid}/code/dashboards/${encodeURIComponent(slug)}`,
84
+ body,
85
+ );
86
+ }
87
+
88
+ /** Create a new dashboard in a project, or duplicate an existing one via `duplicateFrom`. */
89
+ async createDashboard(
90
+ projectUuid: string,
91
+ body: CreateDashboardBody,
92
+ options?: CreateDashboardOptions,
93
+ ): Promise<CreateDashboardResult> {
94
+ return this.http.post<CreateDashboardResult>(
95
+ `/projects/${projectUuid}/dashboards`,
96
+ body,
97
+ options?.duplicateFrom ? { params: { duplicateFrom: options.duplicateFrom } } : undefined,
98
+ );
99
+ }
100
+
101
+ /** Get dashboard version history from the last 30 days. */
102
+ async getDashboardHistory(dashboardUuidOrSlug: string): Promise<DashboardHistoryResults> {
103
+ return this.http.get<DashboardHistoryResults>(
104
+ `/dashboards/${encodeURIComponent(dashboardUuidOrSlug)}/history`,
105
+ );
106
+ }
107
+
108
+ /** Get a single dashboard version by UUID. */
109
+ async getDashboardVersion(
110
+ dashboardUuidOrSlug: string,
111
+ versionUuid: string,
112
+ ): Promise<DashboardVersionResults> {
113
+ return this.http.get<DashboardVersionResults>(
114
+ `/dashboards/${encodeURIComponent(dashboardUuidOrSlug)}/version/${versionUuid}`,
115
+ );
116
+ }
117
+
118
+ /** Get promotion diff for a dashboard against its configured upstream project. */
119
+ async getDashboardPromoteDiff(
120
+ dashboardUuidOrSlug: string,
121
+ options?: DashboardPromoteOptions,
122
+ ): Promise<DashboardPromoteDiffResults> {
123
+ return this.http.get<DashboardPromoteDiffResults>(
124
+ `/dashboards/${encodeURIComponent(dashboardUuidOrSlug)}/promoteDiff`,
125
+ options?.projectUuid ? { params: { projectUuid: options.projectUuid } } : undefined,
126
+ );
127
+ }
128
+
129
+ /** Promote a dashboard (and nested charts) to its configured upstream project. */
130
+ async promoteDashboard(
131
+ dashboardUuidOrSlug: string,
132
+ options?: DashboardPromoteOptions,
133
+ ): Promise<PromoteDashboardResult> {
134
+ return this.http.post<PromoteDashboardResult>(
135
+ `/dashboards/${encodeURIComponent(dashboardUuidOrSlug)}/promote`,
136
+ undefined,
137
+ options?.projectUuid ? { params: { projectUuid: options.projectUuid } } : undefined,
138
+ );
139
+ }
15
140
  }
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { ExploresClient } from './explores';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('ExploresClient', () => {
@@ -59,6 +61,7 @@ describe('ExploresClient', () => {
59
61
  const explore = {
60
62
  tables: {
61
63
  t1: {
64
+ name: 't1',
62
65
  dimensions: {
63
66
  d1: { name: 'd1' },
64
67
  },
@@ -71,4 +74,23 @@ describe('ExploresClient', () => {
71
74
  const result = await client.getFieldLineage('p1', 'e1', 'd1');
72
75
  expect(result).toEqual({ upstream: [] });
73
76
  });
77
+
78
+ it('getFieldLineage should resolve {table}_{name} fieldIds', async () => {
79
+ const client = new ExploresClient(mockHttp);
80
+ const explore = {
81
+ tables: {
82
+ t1: {
83
+ name: 't1',
84
+ dimensions: {
85
+ d1: { name: 'd1' },
86
+ },
87
+ metrics: {},
88
+ lineageGraph: { upstream: ['x'] },
89
+ },
90
+ },
91
+ };
92
+ vi.mocked(mockHttp.get).mockResolvedValue(explore);
93
+ const result = await client.getFieldLineage('p1', 'e1', 't1_d1');
94
+ expect(result).toEqual({ upstream: ['x'] });
95
+ });
74
96
  });
@@ -2,9 +2,12 @@
2
2
  * Explores API client (v1).
3
3
  */
4
4
 
5
- import type { ApiExploresResults, ApiExploreResults, LightdashApi } from '@lightdash-tools/common';
6
5
  import { BaseApiClient } from '../base-client';
7
6
 
7
+ import type { ApiExploresResults, ApiExploreResults, LightdashApi } from '@lightdash-tools/common';
8
+
9
+ type CompiledDimension = LightdashApi.Explores.CompiledTable['dimensions'][string];
10
+
8
11
  export class ExploresClient extends BaseApiClient {
9
12
  /** List all explores for a project. */
10
13
  async listExplores(projectUuid: string): Promise<ApiExploresResults> {
@@ -17,7 +20,7 @@ export class ExploresClient extends BaseApiClient {
17
20
  }
18
21
 
19
22
  /** List dimensions for a specific explore. */
20
- async listDimensions(projectUuid: string, exploreId: string): Promise<unknown[]> {
23
+ async listDimensions(projectUuid: string, exploreId: string): Promise<CompiledDimension[]> {
21
24
  const explore = await this.getExplore(projectUuid, exploreId);
22
25
  return Object.values(explore.tables).flatMap((table: LightdashApi.Explores.CompiledTable) =>
23
26
  Object.values(table.dimensions),
@@ -28,9 +31,17 @@ export class ExploresClient extends BaseApiClient {
28
31
  async getFieldLineage(projectUuid: string, exploreId: string, fieldId: string): Promise<unknown> {
29
32
  const explore = await this.getExplore(projectUuid, exploreId);
30
33
  for (const table of Object.values(explore.tables) as LightdashApi.Explores.CompiledTable[]) {
34
+ // Table maps are keyed by short field name; also accept `{table}_{name}` fieldIds.
31
35
  if (table.dimensions[fieldId] || table.metrics[fieldId]) {
32
36
  return table.lineageGraph;
33
37
  }
38
+ const prefix = `${table.name}_`;
39
+ if (fieldId.startsWith(prefix)) {
40
+ const shortName = fieldId.slice(prefix.length);
41
+ if (table.dimensions[shortName] || table.metrics[shortName]) {
42
+ return table.lineageGraph;
43
+ }
44
+ }
34
45
  }
35
46
  return null;
36
47
  }
@@ -1,5 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
2
3
  import { GroupsClient } from './groups';
4
+
3
5
  import type { HttpClient } from '../../http/http-client';
4
6
 
5
7
  describe('GroupsClient', () => {
@@ -2,9 +2,10 @@
2
2
  * Groups 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 groups. */
10
11
  export interface ListGroupsParams {
@@ -24,13 +25,14 @@ export interface GetGroupParams {
24
25
  }
25
26
 
26
27
  export type GroupOrGroupWithMembers =
27
- | LightdashApi.Groups.Group
28
- | LightdashApi.Groups.GroupWithMembers;
28
+ LightdashApi.Groups.Group | LightdashApi.Groups.GroupWithMembers;
29
+
30
+ const ORG_GROUPS_PATH = '/org/groups';
29
31
 
30
32
  export class GroupsClient extends BaseApiClient {
31
33
  /** List one page of groups (use listAllGroups for all pages). */
32
34
  async listGroups(params?: ListGroupsParams): Promise<LightdashApi.Groups.GroupListResult> {
33
- return this.http.get<LightdashApi.Groups.GroupListResult>('/org/groups', {
35
+ return this.http.get<LightdashApi.Groups.GroupListResult>(ORG_GROUPS_PATH, {
34
36
  params,
35
37
  });
36
38
  }
@@ -42,7 +44,7 @@ export class GroupsClient extends BaseApiClient {
42
44
  ): Promise<GroupOrGroupWithMembers[]> {
43
45
  return fetchAllPages<GroupOrGroupWithMembers>({
44
46
  fetchPage: (page, pageSize) =>
45
- this.http.get<LightdashApi.Groups.GroupListResult>('/org/groups', {
47
+ this.http.get<LightdashApi.Groups.GroupListResult>(ORG_GROUPS_PATH, {
46
48
  params: { ...params, page, pageSize },
47
49
  }),
48
50
  pageSize: options?.pageSize,
@@ -53,7 +55,7 @@ export class GroupsClient extends BaseApiClient {
53
55
  async createGroup(
54
56
  body: LightdashApi.Groups.CreateGroup,
55
57
  ): Promise<LightdashApi.Groups.GroupWithMembers> {
56
- return this.http.post<LightdashApi.Groups.GroupWithMembers>('/org/groups', body);
58
+ return this.http.post<LightdashApi.Groups.GroupWithMembers>(ORG_GROUPS_PATH, body);
57
59
  }
58
60
 
59
61
  /** Get a group by UUID. */
@@ -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', () => {
@@ -34,4 +36,22 @@ describe('ValidationClient', () => {
34
36
  expect(mockHttp.post).toHaveBeenCalledWith('/projects/p1/validate', undefined);
35
37
  expect(result).toEqual(mockResponse);
36
38
  });
39
+
40
+ it('validateChart should call POST /projects/{projectUuid}/validate/chart/{chartUuid}', async () => {
41
+ const client = new ValidationClient(mockHttp);
42
+ const mockResponse = { errors: [] };
43
+ vi.mocked(mockHttp.post).mockResolvedValue(mockResponse);
44
+ const result = await client.validateChart('p1', 'c1');
45
+ expect(mockHttp.post).toHaveBeenCalledWith('/projects/p1/validate/chart/c1');
46
+ expect(result).toEqual(mockResponse);
47
+ });
48
+
49
+ it('validateDashboard should call POST /projects/{projectUuid}/validate/dashboard/{dashboardUuid}', async () => {
50
+ const client = new ValidationClient(mockHttp);
51
+ const mockResponse = { errors: [] };
52
+ vi.mocked(mockHttp.post).mockResolvedValue(mockResponse);
53
+ const result = await client.validateDashboard('p1', 'd1');
54
+ expect(mockHttp.post).toHaveBeenCalledWith('/projects/p1/validate/dashboard/d1');
55
+ expect(result).toEqual(mockResponse);
56
+ });
37
57
  });
@@ -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 { components, 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,
@@ -40,4 +44,24 @@ export class ValidationClient extends BaseApiClient {
40
44
  body,
41
45
  );
42
46
  }
47
+
48
+ /** Validate a single chart's fields against its underlying explore/table. */
49
+ async validateChart(
50
+ projectUuid: string,
51
+ chartUuid: string,
52
+ ): Promise<components['schemas']['ApiChartValidationResponse']['results']> {
53
+ return this.http.post<components['schemas']['ApiChartValidationResponse']['results']>(
54
+ `/projects/${projectUuid}/validate/chart/${chartUuid}`,
55
+ );
56
+ }
57
+
58
+ /** Validate a single dashboard's fields against its underlying explores/tables. */
59
+ async validateDashboard(
60
+ projectUuid: string,
61
+ dashboardUuid: string,
62
+ ): Promise<components['schemas']['ApiDashboardValidationResponse']['results']> {
63
+ return this.http.post<components['schemas']['ApiDashboardValidationResponse']['results']>(
64
+ `/projects/${projectUuid}/validate/dashboard/${dashboardUuid}`,
65
+ );
66
+ }
43
67
  }