@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.
- package/README.md +2 -2
- package/dist/agentops/apply-agent-change.d.ts +3 -0
- package/dist/agentops/apply-agent-change.js +63 -0
- package/dist/agentops/apply-bundle-diff.d.ts +13 -0
- package/dist/agentops/apply-bundle-diff.js +44 -0
- package/dist/agentops/apply-bundle-diff.test.d.ts +1 -0
- package/dist/agentops/apply-bundle-diff.test.js +397 -0
- package/dist/agentops/apply-context.d.ts +14 -0
- package/dist/agentops/apply-context.js +6 -0
- package/dist/agentops/apply-evaluation-change.d.ts +3 -0
- package/dist/agentops/apply-evaluation-change.js +78 -0
- package/dist/agentops/fetch-bundle-state.d.ts +6 -0
- package/dist/agentops/fetch-bundle-state.js +20 -0
- package/dist/agentops/fetch-bundle-state.test.d.ts +1 -0
- package/dist/agentops/fetch-bundle-state.test.js +44 -0
- package/dist/agentops/index.d.ts +3 -0
- package/dist/agentops/index.js +9 -0
- package/dist/agentops/resolve-evaluation-run.d.ts +15 -0
- package/dist/agentops/resolve-evaluation-run.js +48 -0
- package/dist/api/v1/ai-agents/admin.d.ts +16 -0
- package/dist/api/v1/ai-agents/admin.js +29 -0
- package/dist/api/v1/ai-agents/agents.d.ts +18 -0
- package/dist/api/v1/ai-agents/agents.js +31 -0
- package/dist/api/v1/ai-agents/artifacts.d.ts +26 -0
- package/dist/api/v1/ai-agents/artifacts.js +41 -0
- package/dist/api/v1/ai-agents/artifacts.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/artifacts.test.js +69 -0
- package/dist/api/v1/ai-agents/discovery.d.ts +28 -0
- package/dist/api/v1/ai-agents/discovery.js +46 -0
- package/dist/api/v1/ai-agents/discovery.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/discovery.test.js +90 -0
- package/dist/api/v1/ai-agents/evaluations.d.ts +39 -0
- package/dist/api/v1/ai-agents/evaluations.js +70 -0
- package/dist/api/v1/ai-agents/facade.d.ts +79 -0
- package/dist/api/v1/ai-agents/facade.js +193 -0
- package/dist/api/v1/ai-agents/feedback.d.ts +10 -0
- package/dist/api/v1/ai-agents/feedback.js +15 -0
- package/dist/api/v1/ai-agents/feedback.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/feedback.test.js +23 -0
- package/dist/api/v1/ai-agents/index.d.ts +1 -0
- package/dist/api/v1/ai-agents/index.js +5 -0
- package/dist/api/v1/ai-agents/mcp-servers.d.ts +20 -0
- package/dist/api/v1/ai-agents/mcp-servers.js +35 -0
- package/dist/api/v1/ai-agents/mcp-servers.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/mcp-servers.test.js +66 -0
- package/dist/api/v1/ai-agents/request-options.d.ts +12 -0
- package/dist/api/v1/ai-agents/request-options.js +20 -0
- package/dist/api/v1/ai-agents/sql-approval.d.ts +10 -0
- package/dist/api/v1/ai-agents/sql-approval.js +15 -0
- package/dist/api/v1/ai-agents/sql-approval.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/sql-approval.test.js +25 -0
- package/dist/api/v1/ai-agents/threads.d.ts +56 -0
- package/dist/api/v1/ai-agents/threads.js +97 -0
- package/dist/api/v1/ai-agents/threads.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/threads.test.js +39 -0
- package/dist/api/v1/ai-agents.test.js +172 -89
- package/dist/api/v1/analytics.d.ts +10 -0
- package/dist/api/v1/analytics.js +14 -0
- package/dist/api/v1/analytics.test.d.ts +4 -0
- package/dist/api/v1/analytics.test.js +27 -0
- package/dist/api/v1/charts.d.ts +13 -2
- package/dist/api/v1/charts.js +26 -30
- package/dist/api/v1/charts.test.js +35 -28
- package/dist/api/v1/dashboards.d.ts +42 -2
- package/dist/api/v1/dashboards.js +39 -14
- package/dist/api/v1/dashboards.test.js +126 -12
- package/dist/api/v1/explores.d.ts +4 -2
- package/dist/api/v1/explores.js +20 -29
- package/dist/api/v1/explores.test.js +31 -21
- package/dist/api/v1/groups.d.ts +1 -1
- package/dist/api/v1/groups.js +25 -51
- package/dist/api/v1/groups.test.js +15 -24
- package/dist/api/v1/metrics.d.ts +2 -2
- package/dist/api/v1/metrics.js +4 -17
- package/dist/api/v1/metrics.test.js +6 -15
- package/dist/api/v1/organizations.d.ts +1 -1
- package/dist/api/v1/organizations.js +2 -13
- package/dist/api/v1/organizations.test.js +3 -12
- package/dist/api/v1/project-access.d.ts +1 -1
- package/dist/api/v1/project-access.js +18 -45
- package/dist/api/v1/project-access.test.js +27 -36
- package/dist/api/v1/projects.d.ts +1 -1
- package/dist/api/v1/projects.js +6 -21
- package/dist/api/v1/projects.test.js +9 -18
- package/dist/api/v1/query.d.ts +5 -2
- package/dist/api/v1/query.js +8 -18
- package/dist/api/v1/query.test.js +6 -15
- package/dist/api/v1/schedulers.d.ts +2 -2
- package/dist/api/v1/schedulers.js +4 -17
- package/dist/api/v1/schedulers.test.js +6 -15
- package/dist/api/v1/spaces.d.ts +1 -1
- package/dist/api/v1/spaces.js +18 -45
- package/dist/api/v1/spaces.test.js +27 -36
- package/dist/api/v1/tags.d.ts +1 -1
- package/dist/api/v1/tags.js +4 -17
- package/dist/api/v1/tags.test.js +6 -15
- package/dist/api/v1/users.d.ts +3 -1
- package/dist/api/v1/users.js +22 -39
- package/dist/api/v1/users.test.js +44 -30
- package/dist/api/v1/validation.d.ts +9 -2
- package/dist/api/v1/validation.js +16 -18
- package/dist/api/v1/validation.test.js +22 -15
- package/dist/api/v2/charts.d.ts +12 -0
- package/dist/api/v2/charts.js +18 -0
- package/dist/api/v2/charts.test.d.ts +4 -0
- package/dist/api/v2/charts.test.js +45 -0
- package/dist/api/v2/content.d.ts +20 -3
- package/dist/api/v2/content.js +18 -14
- package/dist/api/v2/content.test.js +44 -12
- package/dist/api/v2/dashboards.d.ts +16 -0
- package/dist/api/v2/dashboards.js +22 -0
- package/dist/api/v2/dashboards.test.d.ts +4 -0
- package/dist/api/v2/dashboards.test.js +61 -0
- package/dist/api/v2/organization-roles.d.ts +1 -1
- package/dist/api/v2/organization-roles.js +21 -50
- package/dist/api/v2/organization-roles.test.js +33 -42
- package/dist/api/v2/parameters.d.ts +20 -0
- package/dist/api/v2/parameters.js +22 -0
- package/dist/api/v2/parameters.test.d.ts +4 -0
- package/dist/api/v2/parameters.test.js +39 -0
- package/dist/api/v2/project-role-assignments.d.ts +1 -1
- package/dist/api/v2/project-role-assignments.js +12 -33
- package/dist/api/v2/project-role-assignments.test.js +18 -27
- package/dist/api/v2/query.d.ts +16 -1
- package/dist/api/v2/query.js +26 -29
- package/dist/api/v2/query.test.js +31 -24
- package/dist/api/v2/validation.d.ts +28 -0
- package/dist/api/v2/validation.js +23 -0
- package/dist/client.d.ts +24 -14
- package/dist/client.js +26 -16
- package/dist/client.test.js +2 -0
- package/dist/config.d.ts +35 -10
- package/dist/http/axios-client.d.ts +4 -4
- package/dist/http/http-client.d.ts +3 -14
- package/dist/http/http-client.js +20 -43
- package/dist/http/interceptors.d.ts +3 -3
- package/dist/http/interceptors.js +16 -3
- package/dist/http/rate-limiter.js +2 -13
- package/dist/http/rate-limiter.test.js +15 -24
- package/dist/http/unwrap-api-success.d.ts +26 -0
- package/dist/http/unwrap-api-success.js +25 -0
- package/dist/http/unwrap-api-success.test.d.ts +1 -0
- package/dist/http/unwrap-api-success.test.js +19 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.js +17 -1
- package/dist/index.test.js +13 -5
- package/dist/pagination/fetch-all-pages.js +18 -29
- package/dist/pagination/fetch-all-pages.test.js +15 -24
- package/dist/types/api.d.ts +1 -1
- package/dist/utils/env.d.ts +11 -2
- package/dist/utils/env.js +41 -8
- package/dist/utils/env.test.js +14 -4
- package/dist/utils/logger.js +5 -4
- package/dist/utils/retry.js +17 -28
- package/dist/utils/retry.test.js +9 -18
- package/dist/utils/secret-string.test.d.ts +1 -0
- package/dist/utils/secret-string.test.js +25 -0
- package/package.json +12 -4
- package/src/agentops/apply-agent-change.ts +82 -0
- package/src/agentops/apply-bundle-diff.test.ts +453 -0
- package/src/agentops/apply-bundle-diff.ts +63 -0
- package/src/agentops/apply-context.ts +23 -0
- package/src/agentops/apply-evaluation-change.ts +125 -0
- package/src/agentops/fetch-bundle-state.test.ts +51 -0
- package/src/agentops/fetch-bundle-state.ts +33 -0
- package/src/agentops/index.ts +11 -0
- package/src/agentops/resolve-evaluation-run.ts +94 -0
- package/src/api/v1/ai-agents/admin.ts +41 -0
- package/src/api/v1/ai-agents/agents.ts +40 -0
- package/src/api/v1/ai-agents/artifacts.test.ts +84 -0
- package/src/api/v1/ai-agents/artifacts.ts +92 -0
- package/src/api/v1/ai-agents/discovery.test.ts +102 -0
- package/src/api/v1/ai-agents/discovery.ts +79 -0
- package/src/api/v1/ai-agents/evaluations.ts +152 -0
- package/src/api/v1/ai-agents/facade.ts +489 -0
- package/src/api/v1/ai-agents/feedback.test.ts +30 -0
- package/src/api/v1/ai-agents/feedback.ts +24 -0
- package/src/api/v1/ai-agents/index.ts +1 -0
- package/src/api/v1/ai-agents/mcp-servers.test.ts +81 -0
- package/src/api/v1/ai-agents/mcp-servers.ts +67 -0
- package/src/api/v1/ai-agents/request-options.ts +32 -0
- package/src/api/v1/ai-agents/sql-approval.test.ts +32 -0
- package/src/api/v1/ai-agents/sql-approval.ts +24 -0
- package/src/api/v1/ai-agents/threads.test.ts +55 -0
- package/src/api/v1/ai-agents/threads.ts +216 -0
- package/src/api/v1/ai-agents.test.ts +189 -13
- package/src/api/v1/analytics.test.ts +32 -0
- package/src/api/v1/analytics.ts +16 -0
- package/src/api/v1/charts.test.ts +26 -6
- package/src/api/v1/charts.ts +25 -4
- package/src/api/v1/dashboards.test.ts +142 -0
- package/src/api/v1/dashboards.ts +127 -2
- package/src/api/v1/explores.test.ts +22 -0
- package/src/api/v1/explores.ts +13 -2
- package/src/api/v1/groups.test.ts +2 -0
- package/src/api/v1/groups.ts +9 -7
- package/src/api/v1/metrics.test.ts +2 -0
- package/src/api/v1/metrics.ts +3 -2
- package/src/api/v1/organizations.test.ts +2 -0
- package/src/api/v1/organizations.ts +2 -1
- package/src/api/v1/project-access.test.ts +3 -1
- package/src/api/v1/project-access.ts +2 -1
- package/src/api/v1/projects.test.ts +2 -0
- package/src/api/v1/projects.ts +2 -1
- package/src/api/v1/query.test.ts +2 -0
- package/src/api/v1/query.ts +6 -2
- package/src/api/v1/schedulers.test.ts +2 -0
- package/src/api/v1/schedulers.ts +3 -2
- package/src/api/v1/spaces.test.ts +2 -0
- package/src/api/v1/spaces.ts +2 -1
- package/src/api/v1/tags.test.ts +2 -0
- package/src/api/v1/tags.ts +2 -1
- package/src/api/v1/users.test.ts +26 -0
- package/src/api/v1/users.ts +8 -2
- package/src/api/v1/validation.test.ts +20 -0
- package/src/api/v1/validation.ts +26 -2
- package/src/api/v2/charts.test.ts +53 -0
- package/src/api/v2/charts.ts +23 -0
- package/src/api/v2/content.test.ts +47 -0
- package/src/api/v2/content.ts +37 -3
- package/src/api/v2/dashboards.test.ts +71 -0
- package/src/api/v2/dashboards.ts +40 -0
- package/src/api/v2/organization-roles.test.ts +2 -0
- package/src/api/v2/organization-roles.ts +2 -1
- package/src/api/v2/parameters.test.ts +45 -0
- package/src/api/v2/parameters.ts +38 -0
- package/src/api/v2/project-role-assignments.test.ts +2 -0
- package/src/api/v2/project-role-assignments.ts +2 -1
- package/src/api/v2/query.test.ts +20 -0
- package/src/api/v2/query.ts +55 -1
- package/src/api/v2/validation.ts +48 -0
- package/src/client.test.ts +3 -0
- package/src/client.ts +33 -17
- package/src/config.ts +38 -10
- package/src/errors.test.ts +1 -0
- package/src/http/axios-client.ts +8 -5
- package/src/http/http-client.ts +8 -21
- package/src/http/interceptors.ts +23 -10
- package/src/http/rate-limiter.test.ts +1 -0
- package/src/http/rate-limiter.ts +3 -1
- package/src/http/unwrap-api-success.test.ts +23 -0
- package/src/http/unwrap-api-success.ts +40 -0
- package/src/index.test.ts +16 -7
- package/src/index.ts +37 -2
- package/src/pagination/fetch-all-pages.test.ts +2 -0
- package/src/types/api.ts +1 -1
- package/src/utils/env.test.ts +16 -4
- package/src/utils/env.ts +61 -10
- package/src/utils/logger.ts +6 -4
- package/src/utils/retry.test.ts +1 -0
- package/src/utils/retry.ts +2 -1
- package/src/utils/secret-string.test.ts +27 -0
- package/tsconfig.json +4 -2
- package/dist/api/v1/ai-agents.d.ts +0 -63
- package/dist/api/v1/ai-agents.js +0 -173
- package/src/api/v1/ai-agents.ts +0 -252
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* V2 charts client unit tests.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const charts_1 = require("./charts");
|
|
8
|
+
(0, vitest_1.describe)('ChartsClientV2', () => {
|
|
9
|
+
let mockHttp;
|
|
10
|
+
(0, vitest_1.beforeEach)(() => {
|
|
11
|
+
mockHttp = {
|
|
12
|
+
get: vitest_1.vi.fn(),
|
|
13
|
+
post: vitest_1.vi.fn(),
|
|
14
|
+
put: vitest_1.vi.fn(),
|
|
15
|
+
patch: vitest_1.vi.fn(),
|
|
16
|
+
delete: vitest_1.vi.fn(),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.it)('getSavedChart calls GET /projects/{projectUuid}/saved/{id}', async () => {
|
|
20
|
+
const client = new charts_1.ChartsClientV2(mockHttp);
|
|
21
|
+
const mockResponse = { uuid: 'c1', name: 'Revenue' };
|
|
22
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
|
|
23
|
+
const result = await client.getSavedChart('p1', 'c1');
|
|
24
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/saved/c1');
|
|
25
|
+
(0, vitest_1.expect)(result).toEqual(mockResponse);
|
|
26
|
+
});
|
|
27
|
+
(0, vitest_1.it)('getSavedChart encodes slug path segments', async () => {
|
|
28
|
+
const client = new charts_1.ChartsClientV2(mockHttp);
|
|
29
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue({ uuid: 'c1' });
|
|
30
|
+
await client.getSavedChart('p1', 'my/chart');
|
|
31
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/saved/my%2Fchart');
|
|
32
|
+
});
|
|
33
|
+
(0, vitest_1.it)('deleteSavedChart calls DELETE /projects/{projectUuid}/saved/{id}', async () => {
|
|
34
|
+
const client = new charts_1.ChartsClientV2(mockHttp);
|
|
35
|
+
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
36
|
+
await client.deleteSavedChart('p1', 'c1');
|
|
37
|
+
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/p1/saved/c1');
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)('deleteSavedChart encodes slug path segments', async () => {
|
|
40
|
+
const client = new charts_1.ChartsClientV2(mockHttp);
|
|
41
|
+
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
42
|
+
await client.deleteSavedChart('p1', 'my/chart');
|
|
43
|
+
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/p1/saved/my%2Fchart');
|
|
44
|
+
});
|
|
45
|
+
});
|
package/dist/api/v2/content.d.ts
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content API client (v2).
|
|
3
3
|
*/
|
|
4
|
-
import type { LightdashApi } from '@lightdash-tools/common';
|
|
5
4
|
import { BaseApiClient } from '../base-client';
|
|
5
|
+
import type { components, LightdashApi } from '@lightdash-tools/common';
|
|
6
6
|
/** Query params for searching content. */
|
|
7
7
|
export interface SearchContentParams {
|
|
8
8
|
projectUuids?: string[];
|
|
9
9
|
spaceUuids?: string[];
|
|
10
|
+
/** Exact content UUID filter (OpenAPI List content `uuids`). */
|
|
11
|
+
uuids?: string[];
|
|
10
12
|
parentSpaceUuid?: string;
|
|
11
|
-
contentTypes?: ('chart' | 'dashboard' | 'space')[];
|
|
13
|
+
contentTypes?: ('chart' | 'dashboard' | 'data_app' | 'space')[];
|
|
12
14
|
pageSize?: number;
|
|
13
15
|
page?: number;
|
|
14
16
|
search?: string;
|
|
15
|
-
sortBy?:
|
|
17
|
+
sortBy?: LightdashApi.Content.ContentSortByColumns;
|
|
16
18
|
sortDirection?: 'asc' | 'desc';
|
|
17
19
|
}
|
|
20
|
+
/** Body for moving a single content item (chart, dashboard, or space) to another space. */
|
|
21
|
+
export type MoveContentBody = components['schemas']['ApiContentActionBody_ContentActionMove_'];
|
|
22
|
+
/** Body for moving multiple content items (charts, dashboards, spaces) to another space. */
|
|
23
|
+
export type BulkMoveContentBody = components['schemas']['ApiContentBulkActionBody_ContentActionMove_'];
|
|
24
|
+
/** Body for permanently deleting soft-deleted content (irrecoverable). */
|
|
25
|
+
export type PermanentlyDeleteContentBody = components['schemas']['ApiPermanentlyDeleteContentBody'];
|
|
18
26
|
export declare class ContentClient extends BaseApiClient {
|
|
19
27
|
/** Search project content (charts, dashboards, spaces). */
|
|
20
28
|
searchContent(params?: SearchContentParams): Promise<LightdashApi.Content.ApiContentResponse>;
|
|
29
|
+
/** Move a single content item (chart, dashboard, or space) to another space. */
|
|
30
|
+
moveContent(projectUuid: string, body: MoveContentBody): Promise<void>;
|
|
31
|
+
/** Move multiple content items (charts, dashboards, spaces) to another space in one call. */
|
|
32
|
+
bulkMoveContent(projectUuid: string, body: BulkMoveContentBody): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Permanently delete soft-deleted content (irrecoverable).
|
|
35
|
+
* Not exposed on MCP — use typed client only (ADR-0015).
|
|
36
|
+
*/
|
|
37
|
+
permanentlyDeleteContent(projectUuid: string, body: PermanentlyDeleteContentBody): Promise<void>;
|
|
21
38
|
}
|
package/dist/api/v2/content.js
CHANGED
|
@@ -2,26 +2,30 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Content API client (v2).
|
|
4
4
|
*/
|
|
5
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.ContentClient = void 0;
|
|
16
7
|
const base_client_1 = require("../base-client");
|
|
17
8
|
class ContentClient extends base_client_1.BaseApiClient {
|
|
18
9
|
/** Search project content (charts, dashboards, spaces). */
|
|
19
|
-
searchContent(params) {
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
params,
|
|
23
|
-
});
|
|
10
|
+
async searchContent(params) {
|
|
11
|
+
return this.http.get('/content', {
|
|
12
|
+
params,
|
|
24
13
|
});
|
|
25
14
|
}
|
|
15
|
+
/** Move a single content item (chart, dashboard, or space) to another space. */
|
|
16
|
+
async moveContent(projectUuid, body) {
|
|
17
|
+
await this.http.post(`/content/${projectUuid}/move`, body);
|
|
18
|
+
}
|
|
19
|
+
/** Move multiple content items (charts, dashboards, spaces) to another space in one call. */
|
|
20
|
+
async bulkMoveContent(projectUuid, body) {
|
|
21
|
+
await this.http.post(`/content/bulk-action/${projectUuid}/move`, body);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Permanently delete soft-deleted content (irrecoverable).
|
|
25
|
+
* Not exposed on MCP — use typed client only (ADR-0015).
|
|
26
|
+
*/
|
|
27
|
+
async permanentlyDeleteContent(projectUuid, body) {
|
|
28
|
+
await this.http.delete(`/content/${projectUuid}/permanent`, { data: body });
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
exports.ContentClient = ContentClient;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const vitest_1 = require("vitest");
|
|
13
4
|
const content_1 = require("./content");
|
|
@@ -22,14 +13,55 @@ const content_1 = require("./content");
|
|
|
22
13
|
delete: vitest_1.vi.fn(),
|
|
23
14
|
};
|
|
24
15
|
});
|
|
25
|
-
(0, vitest_1.it)('searchContent should call GET /content', () =>
|
|
16
|
+
(0, vitest_1.it)('searchContent should call GET /content', async () => {
|
|
26
17
|
const client = new content_1.ContentClient(mockHttp);
|
|
27
18
|
const mockResponse = { status: 'ok', results: [] };
|
|
28
19
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
|
|
29
|
-
const result =
|
|
20
|
+
const result = await client.searchContent({ search: 'test' });
|
|
30
21
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/content', {
|
|
31
22
|
params: { search: 'test' },
|
|
32
23
|
});
|
|
33
24
|
(0, vitest_1.expect)(result).toEqual(mockResponse);
|
|
34
|
-
})
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.it)('searchContent passes exact uuids filter', async () => {
|
|
27
|
+
const client = new content_1.ContentClient(mockHttp);
|
|
28
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue({ status: 'ok', results: [] });
|
|
29
|
+
await client.searchContent({
|
|
30
|
+
projectUuids: ['p1'],
|
|
31
|
+
uuids: ['c1'],
|
|
32
|
+
pageSize: 50,
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/content', {
|
|
35
|
+
params: { projectUuids: ['p1'], uuids: ['c1'], pageSize: 50 },
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
(0, vitest_1.it)('moveContent should call POST /content/{projectUuid}/move with body', async () => {
|
|
39
|
+
const client = new content_1.ContentClient(mockHttp);
|
|
40
|
+
const body = {
|
|
41
|
+
action: { type: 'move', targetSpaceUuid: 's2' },
|
|
42
|
+
item: { source: 'dbt_explore', contentType: 'chart', uuid: 'c1' },
|
|
43
|
+
};
|
|
44
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue({ status: 'ok' });
|
|
45
|
+
await client.moveContent('p1', body);
|
|
46
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/content/p1/move', body);
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.it)('bulkMoveContent should call POST /content/bulk-action/{projectUuid}/move with body', async () => {
|
|
49
|
+
const client = new content_1.ContentClient(mockHttp);
|
|
50
|
+
const body = {
|
|
51
|
+
action: { type: 'move', targetSpaceUuid: 's2' },
|
|
52
|
+
content: [{ source: 'dbt_explore', contentType: 'chart', uuid: 'c1' }],
|
|
53
|
+
};
|
|
54
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue({ status: 'ok' });
|
|
55
|
+
await client.bulkMoveContent('p1', body);
|
|
56
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/content/bulk-action/p1/move', body);
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.it)('permanentlyDeleteContent should call DELETE /content/{projectUuid}/permanent with body', async () => {
|
|
59
|
+
const client = new content_1.ContentClient(mockHttp);
|
|
60
|
+
const body = {
|
|
61
|
+
item: { contentType: 'chart', uuid: 'c1', source: 'dbt_explore' },
|
|
62
|
+
};
|
|
63
|
+
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue({ status: 'ok' });
|
|
64
|
+
await client.permanentlyDeleteContent('p1', body);
|
|
65
|
+
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/content/p1/permanent', { data: body });
|
|
66
|
+
});
|
|
35
67
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboards API client (v2). Metadata reads, updates, and soft-delete (no query execution).
|
|
3
|
+
*/
|
|
4
|
+
import { BaseApiClient } from '../base-client';
|
|
5
|
+
import type { components } from '@lightdash-tools/common';
|
|
6
|
+
export type Dashboard = components['schemas']['Dashboard'];
|
|
7
|
+
/** Request body for PATCH projects/{projectUuid}/dashboards/{dashboardUuidOrSlug}. */
|
|
8
|
+
export type UpdateDashboardBody = components['schemas']['UpdateDashboard'];
|
|
9
|
+
export declare class DashboardsClientV2 extends BaseApiClient {
|
|
10
|
+
/** Get dashboard metadata by UUID or slug within a project. Does not run queries. */
|
|
11
|
+
getDashboard(projectUuid: string, dashboardUuidOrSlug: string): Promise<Dashboard>;
|
|
12
|
+
/** Update a dashboard by UUID or slug within a project. */
|
|
13
|
+
updateDashboard(projectUuid: string, dashboardUuidOrSlug: string, body: UpdateDashboardBody): Promise<Dashboard>;
|
|
14
|
+
/** Soft-delete a dashboard by UUID or slug within a project. */
|
|
15
|
+
deleteDashboard(projectUuid: string, dashboardUuidOrSlug: string): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Dashboards API client (v2). Metadata reads, updates, and soft-delete (no query execution).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DashboardsClientV2 = void 0;
|
|
7
|
+
const base_client_1 = require("../base-client");
|
|
8
|
+
class DashboardsClientV2 extends base_client_1.BaseApiClient {
|
|
9
|
+
/** Get dashboard metadata by UUID or slug within a project. Does not run queries. */
|
|
10
|
+
async getDashboard(projectUuid, dashboardUuidOrSlug) {
|
|
11
|
+
return this.http.get(`/projects/${projectUuid}/dashboards/${encodeURIComponent(dashboardUuidOrSlug)}`);
|
|
12
|
+
}
|
|
13
|
+
/** Update a dashboard by UUID or slug within a project. */
|
|
14
|
+
async updateDashboard(projectUuid, dashboardUuidOrSlug, body) {
|
|
15
|
+
return this.http.patch(`/projects/${projectUuid}/dashboards/${encodeURIComponent(dashboardUuidOrSlug)}`, body);
|
|
16
|
+
}
|
|
17
|
+
/** Soft-delete a dashboard by UUID or slug within a project. */
|
|
18
|
+
async deleteDashboard(projectUuid, dashboardUuidOrSlug) {
|
|
19
|
+
await this.http.delete(`/projects/${projectUuid}/dashboards/${encodeURIComponent(dashboardUuidOrSlug)}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.DashboardsClientV2 = DashboardsClientV2;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* V2 dashboards client unit tests.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const dashboards_1 = require("./dashboards");
|
|
8
|
+
(0, vitest_1.describe)('DashboardsClientV2', () => {
|
|
9
|
+
let mockHttp;
|
|
10
|
+
(0, vitest_1.beforeEach)(() => {
|
|
11
|
+
mockHttp = {
|
|
12
|
+
get: vitest_1.vi.fn(),
|
|
13
|
+
post: vitest_1.vi.fn(),
|
|
14
|
+
put: vitest_1.vi.fn(),
|
|
15
|
+
patch: vitest_1.vi.fn(),
|
|
16
|
+
delete: vitest_1.vi.fn(),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.it)('getDashboard calls GET /projects/{projectUuid}/dashboards/{id}', async () => {
|
|
20
|
+
const client = new dashboards_1.DashboardsClientV2(mockHttp);
|
|
21
|
+
const mockResponse = { uuid: 'd1', name: 'Sales' };
|
|
22
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(mockResponse);
|
|
23
|
+
const result = await client.getDashboard('p1', 'd1');
|
|
24
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/dashboards/d1');
|
|
25
|
+
(0, vitest_1.expect)(result).toEqual(mockResponse);
|
|
26
|
+
});
|
|
27
|
+
(0, vitest_1.it)('getDashboard encodes slug in path', async () => {
|
|
28
|
+
const client = new dashboards_1.DashboardsClientV2(mockHttp);
|
|
29
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue({});
|
|
30
|
+
await client.getDashboard('p1', 'dash/slug');
|
|
31
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/dashboards/dash%2Fslug');
|
|
32
|
+
});
|
|
33
|
+
(0, vitest_1.it)('updateDashboard calls PATCH /projects/{projectUuid}/dashboards/{id} with body', async () => {
|
|
34
|
+
const client = new dashboards_1.DashboardsClientV2(mockHttp);
|
|
35
|
+
const body = { name: 'Renamed' };
|
|
36
|
+
const updated = { uuid: 'd1', name: 'Renamed' };
|
|
37
|
+
vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
38
|
+
const result = await client.updateDashboard('p1', 'd1', body);
|
|
39
|
+
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/projects/p1/dashboards/d1', body);
|
|
40
|
+
(0, vitest_1.expect)(result).toEqual(updated);
|
|
41
|
+
});
|
|
42
|
+
(0, vitest_1.it)('updateDashboard encodes slug in path', async () => {
|
|
43
|
+
const client = new dashboards_1.DashboardsClientV2(mockHttp);
|
|
44
|
+
const body = { name: 'Renamed' };
|
|
45
|
+
vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue({});
|
|
46
|
+
await client.updateDashboard('p1', 'dash/slug', body);
|
|
47
|
+
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/projects/p1/dashboards/dash%2Fslug', body);
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.it)('deleteDashboard calls DELETE /projects/{projectUuid}/dashboards/{id}', async () => {
|
|
50
|
+
const client = new dashboards_1.DashboardsClientV2(mockHttp);
|
|
51
|
+
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
52
|
+
await client.deleteDashboard('p1', 'd1');
|
|
53
|
+
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/p1/dashboards/d1');
|
|
54
|
+
});
|
|
55
|
+
(0, vitest_1.it)('deleteDashboard encodes slug in path', async () => {
|
|
56
|
+
const client = new dashboards_1.DashboardsClientV2(mockHttp);
|
|
57
|
+
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
58
|
+
await client.deleteDashboard('p1', 'dash/slug');
|
|
59
|
+
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/p1/dashboards/dash%2Fslug');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Organization roles API client (v2). Manage org-level roles and role assignments.
|
|
3
3
|
*/
|
|
4
|
-
import type { components } from '@lightdash-tools/common';
|
|
5
4
|
import { BaseApiClient } from '../base-client';
|
|
5
|
+
import type { components } from '@lightdash-tools/common';
|
|
6
6
|
type CreateRole = components['schemas']['CreateRole'];
|
|
7
7
|
type UpdateRole = components['schemas']['UpdateRole'];
|
|
8
8
|
type AddScopesToRole = components['schemas']['AddScopesToRole'];
|
|
@@ -2,80 +2,51 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Organization roles API client (v2). Manage org-level roles and role assignments.
|
|
4
4
|
*/
|
|
5
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.OrganizationRolesClient = void 0;
|
|
16
7
|
const base_client_1 = require("../base-client");
|
|
17
8
|
class OrganizationRolesClient extends base_client_1.BaseApiClient {
|
|
18
9
|
/** Get roles for an organization. */
|
|
19
|
-
getRoles(orgUuid, params) {
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
params,
|
|
23
|
-
});
|
|
10
|
+
async getRoles(orgUuid, params) {
|
|
11
|
+
return this.http.get(`/orgs/${orgUuid}/roles`, {
|
|
12
|
+
params,
|
|
24
13
|
});
|
|
25
14
|
}
|
|
26
15
|
/** Create a custom role in the organization. */
|
|
27
|
-
createRole(orgUuid, body) {
|
|
28
|
-
return
|
|
29
|
-
return this.http.post(`/orgs/${orgUuid}/roles`, body);
|
|
30
|
-
});
|
|
16
|
+
async createRole(orgUuid, body) {
|
|
17
|
+
return this.http.post(`/orgs/${orgUuid}/roles`, body);
|
|
31
18
|
}
|
|
32
19
|
/** Get a custom role by UUID. */
|
|
33
|
-
getRole(orgUuid, roleUuid) {
|
|
34
|
-
return
|
|
35
|
-
return this.http.get(`/orgs/${orgUuid}/roles/${roleUuid}`);
|
|
36
|
-
});
|
|
20
|
+
async getRole(orgUuid, roleUuid) {
|
|
21
|
+
return this.http.get(`/orgs/${orgUuid}/roles/${roleUuid}`);
|
|
37
22
|
}
|
|
38
23
|
/** Update a custom role. */
|
|
39
|
-
updateRole(orgUuid, roleUuid, body) {
|
|
40
|
-
return
|
|
41
|
-
return this.http.patch(`/orgs/${orgUuid}/roles/${roleUuid}`, body);
|
|
42
|
-
});
|
|
24
|
+
async updateRole(orgUuid, roleUuid, body) {
|
|
25
|
+
return this.http.patch(`/orgs/${orgUuid}/roles/${roleUuid}`, body);
|
|
43
26
|
}
|
|
44
27
|
/** Delete a custom role from the organization. */
|
|
45
|
-
deleteRole(orgUuid, roleUuid) {
|
|
46
|
-
|
|
47
|
-
yield this.http.delete(`/orgs/${orgUuid}/roles/${roleUuid}`);
|
|
48
|
-
});
|
|
28
|
+
async deleteRole(orgUuid, roleUuid) {
|
|
29
|
+
await this.http.delete(`/orgs/${orgUuid}/roles/${roleUuid}`);
|
|
49
30
|
}
|
|
50
31
|
/** Add scopes to a role. */
|
|
51
|
-
addScopesToRole(orgUuid, roleUuid, body) {
|
|
52
|
-
|
|
53
|
-
yield this.http.post(`/orgs/${orgUuid}/roles/${roleUuid}/scopes`, body);
|
|
54
|
-
});
|
|
32
|
+
async addScopesToRole(orgUuid, roleUuid, body) {
|
|
33
|
+
await this.http.post(`/orgs/${orgUuid}/roles/${roleUuid}/scopes`, body);
|
|
55
34
|
}
|
|
56
35
|
/** Remove a scope from a role. */
|
|
57
|
-
removeScopeFromRole(orgUuid, roleUuid, scopeName) {
|
|
58
|
-
|
|
59
|
-
yield this.http.delete(`/orgs/${orgUuid}/roles/${roleUuid}/scopes/${encodeURIComponent(scopeName)}`);
|
|
60
|
-
});
|
|
36
|
+
async removeScopeFromRole(orgUuid, roleUuid, scopeName) {
|
|
37
|
+
await this.http.delete(`/orgs/${orgUuid}/roles/${roleUuid}/scopes/${encodeURIComponent(scopeName)}`);
|
|
61
38
|
}
|
|
62
39
|
/** Duplicate a role. */
|
|
63
|
-
duplicateRole(orgUuid, roleId, body) {
|
|
64
|
-
return
|
|
65
|
-
return this.http.post(`/orgs/${orgUuid}/roles/${roleId}/duplicate`, body);
|
|
66
|
-
});
|
|
40
|
+
async duplicateRole(orgUuid, roleId, body) {
|
|
41
|
+
return this.http.post(`/orgs/${orgUuid}/roles/${roleId}/duplicate`, body);
|
|
67
42
|
}
|
|
68
43
|
/** List organization role assignments (system roles only). */
|
|
69
|
-
listRoleAssignments(orgUuid) {
|
|
70
|
-
return
|
|
71
|
-
return this.http.get(`/orgs/${orgUuid}/roles/assignments`);
|
|
72
|
-
});
|
|
44
|
+
async listRoleAssignments(orgUuid) {
|
|
45
|
+
return this.http.get(`/orgs/${orgUuid}/roles/assignments`);
|
|
73
46
|
}
|
|
74
47
|
/** Assign an organization role to a user. */
|
|
75
|
-
assignRoleToUser(orgUuid, userId, body) {
|
|
76
|
-
return
|
|
77
|
-
return this.http.post(`/orgs/${orgUuid}/roles/assignments/user/${userId}`, body);
|
|
78
|
-
});
|
|
48
|
+
async assignRoleToUser(orgUuid, userId, body) {
|
|
49
|
+
return this.http.post(`/orgs/${orgUuid}/roles/assignments/user/${userId}`, body);
|
|
79
50
|
}
|
|
80
51
|
}
|
|
81
52
|
exports.OrganizationRolesClient = OrganizationRolesClient;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const vitest_1 = require("vitest");
|
|
13
4
|
const organization_roles_1 = require("./organization-roles");
|
|
@@ -22,68 +13,68 @@ const organization_roles_1 = require("./organization-roles");
|
|
|
22
13
|
delete: vitest_1.vi.fn(),
|
|
23
14
|
};
|
|
24
15
|
});
|
|
25
|
-
(0, vitest_1.it)('getRoles should call GET /orgs/{orgUuid}/roles with optional params', () =>
|
|
16
|
+
(0, vitest_1.it)('getRoles should call GET /orgs/{orgUuid}/roles with optional params', async () => {
|
|
26
17
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
27
18
|
const results = [{ roleUuid: 'r1', name: 'Role 1' }];
|
|
28
19
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(results);
|
|
29
|
-
const result =
|
|
20
|
+
const result = await client.getRoles('org-1');
|
|
30
21
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/orgs/org-1/roles', {
|
|
31
22
|
params: undefined,
|
|
32
23
|
});
|
|
33
24
|
(0, vitest_1.expect)(result).toEqual(results);
|
|
34
|
-
})
|
|
35
|
-
(0, vitest_1.it)('getRoles with params should pass query params', () =>
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.it)('getRoles with params should pass query params', async () => {
|
|
36
27
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
37
28
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue([]);
|
|
38
|
-
|
|
29
|
+
await client.getRoles('org-1', { load: 'scopes', roleTypeFilter: 'custom' });
|
|
39
30
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/orgs/org-1/roles', {
|
|
40
31
|
params: { load: 'scopes', roleTypeFilter: 'custom' },
|
|
41
32
|
});
|
|
42
|
-
})
|
|
43
|
-
(0, vitest_1.it)('createRole should call POST /orgs/{orgUuid}/roles with body', () =>
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.it)('createRole should call POST /orgs/{orgUuid}/roles with body', async () => {
|
|
44
35
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
45
36
|
const body = { name: 'Editor', description: 'Can edit' };
|
|
46
37
|
const role = { roleUuid: 'r1', name: 'Editor' };
|
|
47
38
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(role);
|
|
48
|
-
const result =
|
|
39
|
+
const result = await client.createRole('org-1', body);
|
|
49
40
|
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/orgs/org-1/roles', body);
|
|
50
41
|
(0, vitest_1.expect)(result).toEqual(role);
|
|
51
|
-
})
|
|
52
|
-
(0, vitest_1.it)('getRole should call GET /orgs/{orgUuid}/roles/{roleUuid}', () =>
|
|
42
|
+
});
|
|
43
|
+
(0, vitest_1.it)('getRole should call GET /orgs/{orgUuid}/roles/{roleUuid}', async () => {
|
|
53
44
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
54
45
|
const role = { roleUuid: 'r1', name: 'Editor', scopes: [] };
|
|
55
46
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(role);
|
|
56
|
-
const result =
|
|
47
|
+
const result = await client.getRole('org-1', 'r1');
|
|
57
48
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/orgs/org-1/roles/r1');
|
|
58
49
|
(0, vitest_1.expect)(result).toEqual(role);
|
|
59
|
-
})
|
|
60
|
-
(0, vitest_1.it)('updateRole should call PATCH /orgs/{orgUuid}/roles/{roleUuid}', () =>
|
|
50
|
+
});
|
|
51
|
+
(0, vitest_1.it)('updateRole should call PATCH /orgs/{orgUuid}/roles/{roleUuid}', async () => {
|
|
61
52
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
62
53
|
const body = { name: 'Updated' };
|
|
63
54
|
vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue({ roleUuid: 'r1', name: 'Updated' });
|
|
64
|
-
|
|
55
|
+
await client.updateRole('org-1', 'r1', body);
|
|
65
56
|
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/orgs/org-1/roles/r1', body);
|
|
66
|
-
})
|
|
67
|
-
(0, vitest_1.it)('deleteRole should call DELETE /orgs/{orgUuid}/roles/{roleUuid}', () =>
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.it)('deleteRole should call DELETE /orgs/{orgUuid}/roles/{roleUuid}', async () => {
|
|
68
59
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
69
60
|
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
70
|
-
|
|
61
|
+
await client.deleteRole('org-1', 'r1');
|
|
71
62
|
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/orgs/org-1/roles/r1');
|
|
72
|
-
})
|
|
73
|
-
(0, vitest_1.it)('addScopesToRole should call POST .../scopes with body', () =>
|
|
63
|
+
});
|
|
64
|
+
(0, vitest_1.it)('addScopesToRole should call POST .../scopes with body', async () => {
|
|
74
65
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
75
66
|
const body = { scopeNames: ['project:read'] };
|
|
76
67
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(undefined);
|
|
77
|
-
|
|
68
|
+
await client.addScopesToRole('org-1', 'r1', body);
|
|
78
69
|
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/orgs/org-1/roles/r1/scopes', body);
|
|
79
|
-
})
|
|
80
|
-
(0, vitest_1.it)('removeScopeFromRole should call DELETE .../scopes/{scopeName}', () =>
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.it)('removeScopeFromRole should call DELETE .../scopes/{scopeName}', async () => {
|
|
81
72
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
82
73
|
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
83
|
-
|
|
74
|
+
await client.removeScopeFromRole('org-1', 'r1', 'project:read');
|
|
84
75
|
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/orgs/org-1/roles/r1/scopes/project%3Aread');
|
|
85
|
-
})
|
|
86
|
-
(0, vitest_1.it)('duplicateRole should call POST .../duplicate with body', () =>
|
|
76
|
+
});
|
|
77
|
+
(0, vitest_1.it)('duplicateRole should call POST .../duplicate with body', async () => {
|
|
87
78
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
88
79
|
const body = { name: 'Copy of Role' };
|
|
89
80
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue({
|
|
@@ -91,22 +82,22 @@ const organization_roles_1 = require("./organization-roles");
|
|
|
91
82
|
name: 'Copy of Role',
|
|
92
83
|
scopes: [],
|
|
93
84
|
});
|
|
94
|
-
|
|
85
|
+
await client.duplicateRole('org-1', 'r1', body);
|
|
95
86
|
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/orgs/org-1/roles/r1/duplicate', body);
|
|
96
|
-
})
|
|
97
|
-
(0, vitest_1.it)('listRoleAssignments should call GET /orgs/{orgUuid}/roles/assignments', () =>
|
|
87
|
+
});
|
|
88
|
+
(0, vitest_1.it)('listRoleAssignments should call GET /orgs/{orgUuid}/roles/assignments', async () => {
|
|
98
89
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
99
90
|
const assignments = [{ roleId: 'r1', roleName: 'Admin' }];
|
|
100
91
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(assignments);
|
|
101
|
-
const result =
|
|
92
|
+
const result = await client.listRoleAssignments('org-1');
|
|
102
93
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/orgs/org-1/roles/assignments');
|
|
103
94
|
(0, vitest_1.expect)(result).toEqual(assignments);
|
|
104
|
-
})
|
|
105
|
-
(0, vitest_1.it)('assignRoleToUser should call POST .../assignments/user/{userId}', () =>
|
|
95
|
+
});
|
|
96
|
+
(0, vitest_1.it)('assignRoleToUser should call POST .../assignments/user/{userId}', async () => {
|
|
106
97
|
const client = new organization_roles_1.OrganizationRolesClient(mockHttp);
|
|
107
98
|
const body = { roleId: 'r1' };
|
|
108
99
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue({ roleId: 'r1' });
|
|
109
|
-
|
|
100
|
+
await client.assignRoleToUser('org-1', 'user-1', body);
|
|
110
101
|
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/orgs/org-1/roles/assignments/user/user-1', body);
|
|
111
|
-
})
|
|
102
|
+
});
|
|
112
103
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project parameters API client (v2). Read-only.
|
|
3
|
+
*/
|
|
4
|
+
import { BaseApiClient } from '../base-client';
|
|
5
|
+
import type { components } from '@lightdash-tools/common';
|
|
6
|
+
export type ProjectParametersListResults = components['schemas']['ApiGetProjectParametersListResults'];
|
|
7
|
+
export type ProjectParameterDefinitions = components['schemas']['ApiGetProjectParametersResults'];
|
|
8
|
+
export type ListProjectParametersParams = {
|
|
9
|
+
search?: string;
|
|
10
|
+
sortBy?: 'name';
|
|
11
|
+
sortOrder?: 'asc' | 'desc';
|
|
12
|
+
page?: number;
|
|
13
|
+
pageSize?: number;
|
|
14
|
+
};
|
|
15
|
+
export declare class ParametersClientV2 extends BaseApiClient {
|
|
16
|
+
/** List project parameter definitions (paginated). */
|
|
17
|
+
listParameters(projectUuid: string, params?: ListProjectParametersParams): Promise<ProjectParametersListResults>;
|
|
18
|
+
/** Get project parameter definitions by name. */
|
|
19
|
+
getParameters(projectUuid: string, names?: string[]): Promise<ProjectParameterDefinitions>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Project parameters API client (v2). Read-only.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ParametersClientV2 = void 0;
|
|
7
|
+
const base_client_1 = require("../base-client");
|
|
8
|
+
class ParametersClientV2 extends base_client_1.BaseApiClient {
|
|
9
|
+
/** List project parameter definitions (paginated). */
|
|
10
|
+
async listParameters(projectUuid, params) {
|
|
11
|
+
return this.http.get(`/projects/${projectUuid}/parameters/list`, {
|
|
12
|
+
params,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Get project parameter definitions by name. */
|
|
16
|
+
async getParameters(projectUuid, names) {
|
|
17
|
+
return this.http.get(`/projects/${projectUuid}/parameters`, {
|
|
18
|
+
params: names !== undefined ? { names } : undefined,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ParametersClientV2 = ParametersClientV2;
|