@lightdash-tools/client 0.1.2 → 0.2.1

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 (43) hide show
  1. package/README.md +14 -1
  2. package/dist/api/v1/explores.d.ts +4 -0
  3. package/dist/api/v1/explores.js +19 -0
  4. package/dist/api/v1/explores.test.js +32 -0
  5. package/dist/api/v1/metrics.d.ts +23 -0
  6. package/dist/api/v1/metrics.js +31 -0
  7. package/dist/api/v1/metrics.test.d.ts +1 -0
  8. package/dist/api/v1/metrics.test.js +43 -0
  9. package/dist/api/v1/schedulers.d.ts +25 -0
  10. package/dist/api/v1/schedulers.js +31 -0
  11. package/dist/api/v1/schedulers.test.d.ts +1 -0
  12. package/dist/api/v1/schedulers.test.js +43 -0
  13. package/dist/api/v1/tags.d.ts +11 -0
  14. package/dist/api/v1/tags.js +31 -0
  15. package/dist/api/v1/tags.test.d.ts +1 -0
  16. package/dist/api/v1/tags.test.js +41 -0
  17. package/dist/api/v1/validation.d.ts +22 -0
  18. package/dist/api/v1/validation.js +31 -0
  19. package/dist/api/v1/validation.test.d.ts +1 -0
  20. package/dist/api/v1/validation.test.js +43 -0
  21. package/dist/api/v2/content.d.ts +21 -0
  22. package/dist/api/v2/content.js +27 -0
  23. package/dist/api/v2/content.test.d.ts +1 -0
  24. package/dist/api/v2/content.test.js +35 -0
  25. package/dist/client.d.ts +30 -0
  26. package/dist/client.js +15 -0
  27. package/dist/index.d.ts +9 -0
  28. package/dist/index.js +11 -1
  29. package/package.json +2 -2
  30. package/src/api/v1/explores.test.ts +34 -0
  31. package/src/api/v1/explores.ts +20 -1
  32. package/src/api/v1/metrics.test.ts +37 -0
  33. package/src/api/v1/metrics.ts +43 -0
  34. package/src/api/v1/schedulers.test.ts +37 -0
  35. package/src/api/v1/schedulers.ts +43 -0
  36. package/src/api/v1/tags.test.ts +35 -0
  37. package/src/api/v1/tags.ts +20 -0
  38. package/src/api/v1/validation.test.ts +37 -0
  39. package/src/api/v1/validation.ts +43 -0
  40. package/src/api/v2/content.test.ts +28 -0
  41. package/src/api/v2/content.ts +30 -0
  42. package/src/client.ts +40 -0
  43. package/src/index.ts +9 -0
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @lightdash-tools/client
1
+ # [@lightdash-tools/client](https://www.npmjs.com/package/@lightdash-tools/client) <!-- markdown-link-check-disable-line -->
2
2
 
3
3
  HTTP client for the [Lightdash API](https://docs.lightdash.com/api-reference/v1/introduction) with centralized rate limiting, async calls, and TypeScript types generated from the OpenAPI spec.
4
4
 
@@ -89,6 +89,8 @@ const client = new LightdashClient({
89
89
 
90
90
  ## API areas
91
91
 
92
+ ### V1 API
93
+
92
94
  - `client.v1.projects` – get project, list projects, list charts
93
95
  - `client.v1.organizations` – get current organization
94
96
  - `client.v1.explores` – list explores, get explore
@@ -100,6 +102,17 @@ const client = new LightdashClient({
100
102
  - `client.v1.users` – list/get/update/delete organization members
101
103
  - `client.v1.groups` – list/create/update groups
102
104
  - `client.v1.aiAgents` – list AI agents (admin), list threads (admin), get/update AI organization settings
105
+ - `client.v1.metrics` – list metrics in data catalog
106
+ - `client.v1.schedulers` – list/get/create/update/delete scheduled deliveries
107
+ - `client.v1.tags` – list/create/update/delete tags
108
+ - `client.v1.validation` – list/get/delete validation errors
109
+
110
+ ### V2 API (Experimental)
111
+
112
+ - `client.v2.content` – search for charts, dashboards, and spaces across projects
113
+ - `client.v2.query` – execute async metric/SQL/saved chart queries
114
+ - `client.v2.organizationRoles` – list organization roles and their permissions
115
+ - `client.v2.projectRoleAssignments` – list/grant/revoke project role assignments for users and groups
103
116
 
104
117
  Deprecated top-level aliases (`client.projects`, `client.organizations`, etc.) are still available but will be removed in a future major version.
105
118
 
@@ -8,4 +8,8 @@ export declare class ExploresClient extends BaseApiClient {
8
8
  listExplores(projectUuid: string): Promise<ApiExploresResults>;
9
9
  /** Get a specific explore by ID. */
10
10
  getExplore(projectUuid: string, exploreId: string): Promise<ApiExploreResults>;
11
+ /** List dimensions for a specific explore. */
12
+ listDimensions(projectUuid: string, exploreId: string): Promise<unknown[]>;
13
+ /** Get lineage for a specific field in an explore. */
14
+ getFieldLineage(projectUuid: string, exploreId: string, fieldId: string): Promise<unknown>;
11
15
  }
@@ -27,5 +27,24 @@ class ExploresClient extends base_client_1.BaseApiClient {
27
27
  return this.http.get(`/projects/${projectUuid}/explores/${exploreId}`);
28
28
  });
29
29
  }
30
+ /** List dimensions for a specific explore. */
31
+ listDimensions(projectUuid, exploreId) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const explore = yield this.getExplore(projectUuid, exploreId);
34
+ return Object.values(explore.tables).flatMap((table) => Object.values(table.dimensions));
35
+ });
36
+ }
37
+ /** Get lineage for a specific field in an explore. */
38
+ getFieldLineage(projectUuid, exploreId, fieldId) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const explore = yield this.getExplore(projectUuid, exploreId);
41
+ for (const table of Object.values(explore.tables)) {
42
+ if (table.dimensions[fieldId] || table.metrics[fieldId]) {
43
+ return table.lineageGraph;
44
+ }
45
+ }
46
+ return null;
47
+ });
48
+ }
30
49
  }
31
50
  exports.ExploresClient = ExploresClient;
@@ -43,4 +43,36 @@ const explores_1 = require("./explores");
43
43
  (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/explores/e1');
44
44
  (0, vitest_1.expect)(result).toEqual(explore);
45
45
  }));
46
+ (0, vitest_1.it)('listDimensions should extract dimensions from explore', () => __awaiter(void 0, void 0, void 0, function* () {
47
+ const client = new explores_1.ExploresClient(mockHttp);
48
+ const explore = {
49
+ tables: {
50
+ t1: {
51
+ dimensions: {
52
+ d1: { name: 'd1' },
53
+ },
54
+ },
55
+ },
56
+ };
57
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(explore);
58
+ const result = yield client.listDimensions('p1', 'e1');
59
+ (0, vitest_1.expect)(result).toEqual([{ name: 'd1' }]);
60
+ }));
61
+ (0, vitest_1.it)('getFieldLineage should extract lineage from explore', () => __awaiter(void 0, void 0, void 0, function* () {
62
+ const client = new explores_1.ExploresClient(mockHttp);
63
+ const explore = {
64
+ tables: {
65
+ t1: {
66
+ dimensions: {
67
+ d1: { name: 'd1' },
68
+ },
69
+ metrics: {},
70
+ lineageGraph: { upstream: [] },
71
+ },
72
+ },
73
+ };
74
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(explore);
75
+ const result = yield client.getFieldLineage('p1', 'e1', 'd1');
76
+ (0, vitest_1.expect)(result).toEqual({ upstream: [] });
77
+ }));
46
78
  });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Metrics API client.
3
+ */
4
+ import type { LightdashApi } from '@lightdash-tools/common';
5
+ import { BaseApiClient } from '../base-client';
6
+ /** Query params for listing metrics in catalog. */
7
+ export interface ListMetricsParams {
8
+ search?: string;
9
+ page?: number;
10
+ pageSize?: number;
11
+ sort?: string;
12
+ order?: 'asc' | 'desc';
13
+ categories?: string[];
14
+ categoriesFilterMode?: 'any' | 'all';
15
+ tables?: string[];
16
+ ownerUserUuids?: string[];
17
+ }
18
+ export declare class MetricsClient extends BaseApiClient {
19
+ /** List metrics in a project data catalog. */
20
+ listMetrics(projectUuid: string, params?: ListMetricsParams): Promise<LightdashApi.Metrics.ApiMetricsCatalog>;
21
+ /** Get a metric by table and name. */
22
+ getMetric(projectUuid: string, tableName: string, metricName: string): Promise<LightdashApi.Metrics.ApiGetMetricResponse>;
23
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Metrics API client.
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MetricsClient = void 0;
16
+ const base_client_1 = require("../base-client");
17
+ class MetricsClient extends base_client_1.BaseApiClient {
18
+ /** List metrics in a project data catalog. */
19
+ listMetrics(projectUuid, params) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return this.http.get(`/projects/${projectUuid}/dataCatalog/metrics`, { params });
22
+ });
23
+ }
24
+ /** Get a metric by table and name. */
25
+ getMetric(projectUuid, tableName, metricName) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return this.http.get(`/projects/${projectUuid}/dataCatalog/metrics/${tableName}/${metricName}`);
28
+ });
29
+ }
30
+ }
31
+ exports.MetricsClient = MetricsClient;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const vitest_1 = require("vitest");
13
+ const metrics_1 = require("./metrics");
14
+ (0, vitest_1.describe)('MetricsClient', () => {
15
+ let mockHttp;
16
+ (0, vitest_1.beforeEach)(() => {
17
+ mockHttp = {
18
+ get: vitest_1.vi.fn(),
19
+ post: vitest_1.vi.fn(),
20
+ put: vitest_1.vi.fn(),
21
+ patch: vitest_1.vi.fn(),
22
+ delete: vitest_1.vi.fn(),
23
+ };
24
+ });
25
+ (0, vitest_1.it)('listMetrics should call GET /projects/{projectUuid}/dataCatalog/metrics', () => __awaiter(void 0, void 0, void 0, function* () {
26
+ const client = new metrics_1.MetricsClient(mockHttp);
27
+ const mockResponse = { status: 'ok', results: [] };
28
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
29
+ const result = yield client.listMetrics('p1', { search: 'test' });
30
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/dataCatalog/metrics', {
31
+ params: { search: 'test' },
32
+ });
33
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
34
+ }));
35
+ (0, vitest_1.it)('getMetric should call GET /projects/{projectUuid}/dataCatalog/metrics/{tableName}/{metricName}', () => __awaiter(void 0, void 0, void 0, function* () {
36
+ const client = new metrics_1.MetricsClient(mockHttp);
37
+ const mockResponse = { status: 'ok', results: {} };
38
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
39
+ const result = yield client.getMetric('p1', 't1', 'm1');
40
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/dataCatalog/metrics/t1/m1');
41
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
42
+ }));
43
+ });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Schedulers API client.
3
+ */
4
+ import type { LightdashApi } from '@lightdash-tools/common';
5
+ import { BaseApiClient } from '../base-client';
6
+ /** Query params for listing schedulers. */
7
+ export interface ListSchedulersParams {
8
+ pageSize?: number;
9
+ page?: number;
10
+ searchQuery?: string;
11
+ sortBy?: 'name' | 'createdAt';
12
+ sortDirection?: 'asc' | 'desc';
13
+ createdByUserUuids?: string;
14
+ formats?: string;
15
+ resourceType?: 'chart' | 'dashboard';
16
+ resourceUuids?: string;
17
+ destinations?: string;
18
+ includeLatestRun?: boolean;
19
+ }
20
+ export declare class SchedulersClient extends BaseApiClient {
21
+ /** List schedulers in a project. */
22
+ listSchedulers(projectUuid: string, params?: ListSchedulersParams): Promise<LightdashApi.Schedulers.ApiSchedulersResponse>;
23
+ /** Get a scheduler by UUID. */
24
+ getScheduler(schedulerUuid: string): Promise<LightdashApi.Schedulers.ApiSchedulerAndTargetsResponse>;
25
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Schedulers API client.
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SchedulersClient = void 0;
16
+ const base_client_1 = require("../base-client");
17
+ class SchedulersClient extends base_client_1.BaseApiClient {
18
+ /** List schedulers in a project. */
19
+ listSchedulers(projectUuid, params) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return this.http.get(`/schedulers/${projectUuid}/list`, { params });
22
+ });
23
+ }
24
+ /** Get a scheduler by UUID. */
25
+ getScheduler(schedulerUuid) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return this.http.get(`/schedulers/${schedulerUuid}`);
28
+ });
29
+ }
30
+ }
31
+ exports.SchedulersClient = SchedulersClient;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const vitest_1 = require("vitest");
13
+ const schedulers_1 = require("./schedulers");
14
+ (0, vitest_1.describe)('SchedulersClient', () => {
15
+ let mockHttp;
16
+ (0, vitest_1.beforeEach)(() => {
17
+ mockHttp = {
18
+ get: vitest_1.vi.fn(),
19
+ post: vitest_1.vi.fn(),
20
+ put: vitest_1.vi.fn(),
21
+ patch: vitest_1.vi.fn(),
22
+ delete: vitest_1.vi.fn(),
23
+ };
24
+ });
25
+ (0, vitest_1.it)('listSchedulers should call GET /schedulers/{projectUuid}/list', () => __awaiter(void 0, void 0, void 0, function* () {
26
+ const client = new schedulers_1.SchedulersClient(mockHttp);
27
+ const mockResponse = { status: 'ok', results: [] };
28
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
29
+ const result = yield client.listSchedulers('p1', { page: 1 });
30
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/schedulers/p1/list', {
31
+ params: { page: 1 },
32
+ });
33
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
34
+ }));
35
+ (0, vitest_1.it)('getScheduler should call GET /schedulers/{schedulerUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
36
+ const client = new schedulers_1.SchedulersClient(mockHttp);
37
+ const mockResponse = { status: 'ok', results: {} };
38
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
39
+ const result = yield client.getScheduler('s1');
40
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/schedulers/s1');
41
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
42
+ }));
43
+ });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tags API client.
3
+ */
4
+ import type { LightdashApi } from '@lightdash-tools/common';
5
+ import { BaseApiClient } from '../base-client';
6
+ export declare class TagsClient extends BaseApiClient {
7
+ /** List tags in a project. */
8
+ listTags(projectUuid: string): Promise<LightdashApi.Tags.ApiGetTagsResponse>;
9
+ /** Get a tag by UUID. */
10
+ getTag(projectUuid: string, tagUuid: string): Promise<LightdashApi.Tags.ApiGetTagResponse>;
11
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Tags API client.
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TagsClient = void 0;
16
+ const base_client_1 = require("../base-client");
17
+ class TagsClient extends base_client_1.BaseApiClient {
18
+ /** List tags in a project. */
19
+ listTags(projectUuid) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return this.http.get(`/projects/${projectUuid}/tags`);
22
+ });
23
+ }
24
+ /** Get a tag by UUID. */
25
+ getTag(projectUuid, tagUuid) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return this.http.get(`/projects/${projectUuid}/tags/${tagUuid}`);
28
+ });
29
+ }
30
+ }
31
+ exports.TagsClient = TagsClient;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const vitest_1 = require("vitest");
13
+ const tags_1 = require("./tags");
14
+ (0, vitest_1.describe)('TagsClient', () => {
15
+ let mockHttp;
16
+ (0, vitest_1.beforeEach)(() => {
17
+ mockHttp = {
18
+ get: vitest_1.vi.fn(),
19
+ post: vitest_1.vi.fn(),
20
+ put: vitest_1.vi.fn(),
21
+ patch: vitest_1.vi.fn(),
22
+ delete: vitest_1.vi.fn(),
23
+ };
24
+ });
25
+ (0, vitest_1.it)('listTags should call GET /projects/{projectUuid}/tags', () => __awaiter(void 0, void 0, void 0, function* () {
26
+ const client = new tags_1.TagsClient(mockHttp);
27
+ const mockResponse = { status: 'ok', results: [] };
28
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
29
+ const result = yield client.listTags('p1');
30
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/tags');
31
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
32
+ }));
33
+ (0, vitest_1.it)('getTag should call GET /projects/{projectUuid}/tags/{tagUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
34
+ const client = new tags_1.TagsClient(mockHttp);
35
+ const mockResponse = { status: 'ok', results: {} };
36
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
37
+ const result = yield client.getTag('p1', 't1');
38
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/tags/t1');
39
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
40
+ }));
41
+ });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Validation API client.
3
+ */
4
+ import type { LightdashApi } from '@lightdash-tools/common';
5
+ import { BaseApiClient } from '../base-client';
6
+ /** Query params for getting validation results. */
7
+ export interface GetValidationResultsParams {
8
+ fromSettings?: boolean;
9
+ jobId?: string;
10
+ }
11
+ /** Body for triggering project validation. */
12
+ export interface ValidateProjectBody {
13
+ validationTargets?: LightdashApi.Validation.ValidationTarget[];
14
+ explores?: unknown[];
15
+ onlyValidateExploresInArgs?: boolean;
16
+ }
17
+ export declare class ValidationClient extends BaseApiClient {
18
+ /** Get validation results for a project. */
19
+ getValidationResults(projectUuid: string, params?: GetValidationResultsParams): Promise<LightdashApi.Validation.ApiValidateResponse>;
20
+ /** Validate content inside a project. Starts a validation job and returns the job ID. */
21
+ validateProject(projectUuid: string, body?: ValidateProjectBody): Promise<LightdashApi.Validation.ApiJobScheduledResponse>;
22
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Validation API client.
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ValidationClient = void 0;
16
+ const base_client_1 = require("../base-client");
17
+ class ValidationClient extends base_client_1.BaseApiClient {
18
+ /** Get validation results for a project. */
19
+ getValidationResults(projectUuid, params) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return this.http.get(`/projects/${projectUuid}/validate`, { params });
22
+ });
23
+ }
24
+ /** Validate content inside a project. Starts a validation job and returns the job ID. */
25
+ validateProject(projectUuid, body) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return this.http.post(`/projects/${projectUuid}/validate`, body);
28
+ });
29
+ }
30
+ }
31
+ exports.ValidationClient = ValidationClient;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const vitest_1 = require("vitest");
13
+ const validation_1 = require("./validation");
14
+ (0, vitest_1.describe)('ValidationClient', () => {
15
+ let mockHttp;
16
+ (0, vitest_1.beforeEach)(() => {
17
+ mockHttp = {
18
+ get: vitest_1.vi.fn(),
19
+ post: vitest_1.vi.fn(),
20
+ put: vitest_1.vi.fn(),
21
+ patch: vitest_1.vi.fn(),
22
+ delete: vitest_1.vi.fn(),
23
+ };
24
+ });
25
+ (0, vitest_1.it)('getValidationResults should call GET /projects/{projectUuid}/validate', () => __awaiter(void 0, void 0, void 0, function* () {
26
+ const client = new validation_1.ValidationClient(mockHttp);
27
+ const mockResponse = { status: 'ok', results: [] };
28
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
29
+ const result = yield client.getValidationResults('p1', { jobId: 'j1' });
30
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/validate', {
31
+ params: { jobId: 'j1' },
32
+ });
33
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
34
+ }));
35
+ (0, vitest_1.it)('validateProject should call POST /projects/{projectUuid}/validate', () => __awaiter(void 0, void 0, void 0, function* () {
36
+ const client = new validation_1.ValidationClient(mockHttp);
37
+ const mockResponse = { status: 'ok', results: { jobId: 'j1' } };
38
+ vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(mockResponse);
39
+ const result = yield client.validateProject('p1');
40
+ (0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/p1/validate', undefined);
41
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
42
+ }));
43
+ });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Content API client (v2).
3
+ */
4
+ import type { LightdashApi } from '@lightdash-tools/common';
5
+ import { BaseApiClient } from '../base-client';
6
+ /** Query params for searching content. */
7
+ export interface SearchContentParams {
8
+ projectUuids?: string[];
9
+ spaceUuids?: string[];
10
+ parentSpaceUuid?: string;
11
+ contentTypes?: ('chart' | 'dashboard' | 'space')[];
12
+ pageSize?: number;
13
+ page?: number;
14
+ search?: string;
15
+ sortBy?: 'name' | 'createdAt' | 'updatedAt' | 'lastViewedAt' | 'views';
16
+ sortDirection?: 'asc' | 'desc';
17
+ }
18
+ export declare class ContentClient extends BaseApiClient {
19
+ /** Search project content (charts, dashboards, spaces). */
20
+ searchContent(params?: SearchContentParams): Promise<LightdashApi.Content.ApiContentResponse>;
21
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * Content API client (v2).
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ContentClient = void 0;
16
+ const base_client_1 = require("../base-client");
17
+ class ContentClient extends base_client_1.BaseApiClient {
18
+ /** Search project content (charts, dashboards, spaces). */
19
+ searchContent(params) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return this.http.get('/content', {
22
+ params,
23
+ });
24
+ });
25
+ }
26
+ }
27
+ exports.ContentClient = ContentClient;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const vitest_1 = require("vitest");
13
+ const content_1 = require("./content");
14
+ (0, vitest_1.describe)('ContentClient', () => {
15
+ let mockHttp;
16
+ (0, vitest_1.beforeEach)(() => {
17
+ mockHttp = {
18
+ get: vitest_1.vi.fn(),
19
+ post: vitest_1.vi.fn(),
20
+ put: vitest_1.vi.fn(),
21
+ patch: vitest_1.vi.fn(),
22
+ delete: vitest_1.vi.fn(),
23
+ };
24
+ });
25
+ (0, vitest_1.it)('searchContent should call GET /content', () => __awaiter(void 0, void 0, void 0, function* () {
26
+ const client = new content_1.ContentClient(mockHttp);
27
+ const mockResponse = { status: 'ok', results: [] };
28
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
29
+ const result = yield client.searchContent({ search: 'test' });
30
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/content', {
31
+ params: { search: 'test' },
32
+ });
33
+ (0, vitest_1.expect)(result).toEqual(mockResponse);
34
+ }));
35
+ });