@lightdash-tools/client 0.1.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/LICENSE +201 -0
- package/README.md +144 -0
- package/dist/api/base-client.d.ts +13 -0
- package/dist/api/base-client.js +17 -0
- package/dist/api/v1/ai-agents.d.ts +17 -0
- package/dist/api/v1/ai-agents.js +47 -0
- package/dist/api/v1/ai-agents.test.d.ts +1 -0
- package/dist/api/v1/ai-agents.test.js +77 -0
- package/dist/api/v1/charts.d.ts +18 -0
- package/dist/api/v1/charts.js +45 -0
- package/dist/api/v1/charts.test.d.ts +1 -0
- package/dist/api/v1/charts.test.js +106 -0
- package/dist/api/v1/dashboards.d.ts +9 -0
- package/dist/api/v1/dashboards.js +25 -0
- package/dist/api/v1/dashboards.test.d.ts +1 -0
- package/dist/api/v1/dashboards.test.js +33 -0
- package/dist/api/v1/explores.d.ts +11 -0
- package/dist/api/v1/explores.js +31 -0
- package/dist/api/v1/explores.test.d.ts +1 -0
- package/dist/api/v1/explores.test.js +46 -0
- package/dist/api/v1/groups.d.ts +42 -0
- package/dist/api/v1/groups.js +81 -0
- package/dist/api/v1/groups.test.d.ts +1 -0
- package/dist/api/v1/groups.test.js +107 -0
- package/dist/api/v1/organizations.d.ts +9 -0
- package/dist/api/v1/organizations.js +25 -0
- package/dist/api/v1/organizations.test.d.ts +1 -0
- package/dist/api/v1/organizations.test.js +33 -0
- package/dist/api/v1/project-access.d.ts +40 -0
- package/dist/api/v1/project-access.js +88 -0
- package/dist/api/v1/project-access.test.d.ts +1 -0
- package/dist/api/v1/project-access.test.js +109 -0
- package/dist/api/v1/projects.d.ts +13 -0
- package/dist/api/v1/projects.js +37 -0
- package/dist/api/v1/projects.test.d.ts +1 -0
- package/dist/api/v1/projects.test.js +49 -0
- package/dist/api/v1/query.d.ts +11 -0
- package/dist/api/v1/query.js +31 -0
- package/dist/api/v1/query.test.d.ts +1 -0
- package/dist/api/v1/query.test.js +51 -0
- package/dist/api/v1/spaces.d.ts +25 -0
- package/dist/api/v1/spaces.js +73 -0
- package/dist/api/v1/spaces.test.d.ts +1 -0
- package/dist/api/v1/spaces.test.js +91 -0
- package/dist/api/v1/users.d.ts +35 -0
- package/dist/api/v1/users.js +66 -0
- package/dist/api/v1/users.test.d.ts +1 -0
- package/dist/api/v1/users.test.js +122 -0
- package/dist/api/v2/organization-roles.d.ts +45 -0
- package/dist/api/v2/organization-roles.js +81 -0
- package/dist/api/v2/organization-roles.test.d.ts +1 -0
- package/dist/api/v2/organization-roles.test.js +112 -0
- package/dist/api/v2/project-role-assignments.d.ts +23 -0
- package/dist/api/v2/project-role-assignments.js +55 -0
- package/dist/api/v2/project-role-assignments.test.d.ts +1 -0
- package/dist/api/v2/project-role-assignments.test.js +66 -0
- package/dist/api/v2/query.d.ts +17 -0
- package/dist/api/v2/query.js +49 -0
- package/dist/api/v2/query.test.d.ts +1 -0
- package/dist/api/v2/query.test.js +78 -0
- package/dist/client.d.ts +118 -0
- package/dist/client.js +113 -0
- package/dist/client.test.d.ts +1 -0
- package/dist/client.test.js +94 -0
- package/dist/config.d.ts +83 -0
- package/dist/config.js +22 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.js +46 -0
- package/dist/errors.test.d.ts +1 -0
- package/dist/errors.test.js +29 -0
- package/dist/http/axios-client.d.ts +22 -0
- package/dist/http/axios-client.js +51 -0
- package/dist/http/http-client.d.ts +33 -0
- package/dist/http/http-client.js +69 -0
- package/dist/http/interceptors.d.ts +13 -0
- package/dist/http/interceptors.js +82 -0
- package/dist/http/rate-limiter.d.ts +23 -0
- package/dist/http/rate-limiter.js +60 -0
- package/dist/http/rate-limiter.test.d.ts +1 -0
- package/dist/http/rate-limiter.test.js +40 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +41 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +65 -0
- package/dist/pagination/fetch-all-pages.d.ts +15 -0
- package/dist/pagination/fetch-all-pages.js +41 -0
- package/dist/pagination/fetch-all-pages.test.d.ts +1 -0
- package/dist/pagination/fetch-all-pages.test.js +70 -0
- package/dist/pagination/types.d.ts +14 -0
- package/dist/pagination/types.js +6 -0
- package/dist/types/api.d.ts +22 -0
- package/dist/types/api.js +8 -0
- package/dist/utils/env.d.ts +20 -0
- package/dist/utils/env.js +59 -0
- package/dist/utils/env.test.d.ts +1 -0
- package/dist/utils/env.test.js +73 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.js +20 -0
- package/dist/utils/retry.d.ts +14 -0
- package/dist/utils/retry.js +67 -0
- package/dist/utils/retry.test.d.ts +1 -0
- package/dist/utils/retry.test.js +53 -0
- package/package.json +21 -0
- package/src/api/base-client.ts +14 -0
- package/src/api/v1/ai-agents.test.ts +74 -0
- package/src/api/v1/ai-agents.ts +41 -0
- package/src/api/v1/charts.test.ts +103 -0
- package/src/api/v1/charts.ts +51 -0
- package/src/api/v1/dashboards.test.ts +26 -0
- package/src/api/v1/dashboards.ts +15 -0
- package/src/api/v1/explores.test.ts +40 -0
- package/src/api/v1/explores.ts +18 -0
- package/src/api/v1/groups.test.ts +108 -0
- package/src/api/v1/groups.ts +100 -0
- package/src/api/v1/organizations.test.ts +26 -0
- package/src/api/v1/organizations.ts +13 -0
- package/src/api/v1/project-access.test.ts +110 -0
- package/src/api/v1/project-access.ts +102 -0
- package/src/api/v1/projects.test.ts +44 -0
- package/src/api/v1/projects.ts +23 -0
- package/src/api/v1/query.test.ts +46 -0
- package/src/api/v1/query.ts +37 -0
- package/src/api/v1/spaces.test.ts +92 -0
- package/src/api/v1/spaces.ts +83 -0
- package/src/api/v1/users.test.ts +125 -0
- package/src/api/v1/users.ts +76 -0
- package/src/api/v2/organization-roles.test.ts +115 -0
- package/src/api/v2/organization-roles.ts +90 -0
- package/src/api/v2/project-role-assignments.test.ts +75 -0
- package/src/api/v2/project-role-assignments.ts +63 -0
- package/src/api/v2/query.test.ts +81 -0
- package/src/api/v2/query.ts +69 -0
- package/src/client.test.ts +105 -0
- package/src/client.ts +182 -0
- package/src/config.ts +113 -0
- package/src/errors.test.ts +45 -0
- package/src/errors.ts +67 -0
- package/src/http/axios-client.ts +59 -0
- package/src/http/http-client.ts +79 -0
- package/src/http/interceptors.ts +110 -0
- package/src/http/rate-limiter.test.ts +34 -0
- package/src/http/rate-limiter.ts +54 -0
- package/src/index.test.ts +91 -0
- package/src/index.ts +41 -0
- package/src/pagination/fetch-all-pages.test.ts +75 -0
- package/src/pagination/fetch-all-pages.ts +39 -0
- package/src/pagination/types.ts +16 -0
- package/src/types/api.ts +28 -0
- package/src/utils/env.test.ts +88 -0
- package/src/utils/env.ts +69 -0
- package/src/utils/logger.ts +21 -0
- package/src/utils/retry.test.ts +49 -0
- package/src/utils/retry.ts +60 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,70 @@
|
|
|
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 fetch_all_pages_1 = require("./fetch-all-pages");
|
|
14
|
+
(0, vitest_1.describe)('fetchAllPages', () => {
|
|
15
|
+
(0, vitest_1.it)('returns concatenated data from multiple pages', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const fetchPage = vitest_1.vi
|
|
17
|
+
.fn()
|
|
18
|
+
.mockResolvedValueOnce({
|
|
19
|
+
data: [{ id: 1 }, { id: 2 }],
|
|
20
|
+
pagination: { page: 1, pageSize: 2, totalResults: 6, totalPageCount: 3 },
|
|
21
|
+
})
|
|
22
|
+
.mockResolvedValueOnce({
|
|
23
|
+
data: [{ id: 3 }, { id: 4 }],
|
|
24
|
+
pagination: { page: 2, pageSize: 2, totalResults: 6, totalPageCount: 3 },
|
|
25
|
+
})
|
|
26
|
+
.mockResolvedValueOnce({
|
|
27
|
+
data: [{ id: 5 }, { id: 6 }],
|
|
28
|
+
pagination: { page: 3, pageSize: 2, totalResults: 6, totalPageCount: 3 },
|
|
29
|
+
});
|
|
30
|
+
const result = yield (0, fetch_all_pages_1.fetchAllPages)({ fetchPage, pageSize: 2 });
|
|
31
|
+
(0, vitest_1.expect)(result).toHaveLength(6);
|
|
32
|
+
(0, vitest_1.expect)(result).toEqual([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }, { id: 6 }]);
|
|
33
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenCalledTimes(3);
|
|
34
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenNthCalledWith(1, 1, 2);
|
|
35
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenNthCalledWith(2, 2, 2);
|
|
36
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenNthCalledWith(3, 3, 2);
|
|
37
|
+
}));
|
|
38
|
+
(0, vitest_1.it)('returns single page when no pagination', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const fetchPage = vitest_1.vi.fn().mockResolvedValueOnce({
|
|
40
|
+
data: [{ x: 'a' }],
|
|
41
|
+
});
|
|
42
|
+
const result = yield (0, fetch_all_pages_1.fetchAllPages)({ fetchPage });
|
|
43
|
+
(0, vitest_1.expect)(result).toEqual([{ x: 'a' }]);
|
|
44
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenCalledTimes(1);
|
|
45
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenCalledWith(1, 100);
|
|
46
|
+
}));
|
|
47
|
+
(0, vitest_1.it)('returns single page when totalPageCount is 1', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
const fetchPage = vitest_1.vi.fn().mockResolvedValueOnce({
|
|
49
|
+
data: [{ a: 1 }],
|
|
50
|
+
pagination: { page: 1, pageSize: 10, totalResults: 1, totalPageCount: 1 },
|
|
51
|
+
});
|
|
52
|
+
const result = yield (0, fetch_all_pages_1.fetchAllPages)({ fetchPage, pageSize: 10 });
|
|
53
|
+
(0, vitest_1.expect)(result).toEqual([{ a: 1 }]);
|
|
54
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenCalledTimes(1);
|
|
55
|
+
}));
|
|
56
|
+
(0, vitest_1.it)('returns empty array when first page has no data and no pagination', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const fetchPage = vitest_1.vi.fn().mockResolvedValueOnce({ data: [] });
|
|
58
|
+
const result = yield (0, fetch_all_pages_1.fetchAllPages)({ fetchPage });
|
|
59
|
+
(0, vitest_1.expect)(result).toEqual([]);
|
|
60
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenCalledTimes(1);
|
|
61
|
+
}));
|
|
62
|
+
(0, vitest_1.it)('uses default page size when not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
const fetchPage = vitest_1.vi.fn().mockResolvedValueOnce({
|
|
64
|
+
data: [],
|
|
65
|
+
pagination: { page: 1, pageSize: 100, totalResults: 0, totalPageCount: 1 },
|
|
66
|
+
});
|
|
67
|
+
yield (0, fetch_all_pages_1.fetchAllPages)({ fetchPage });
|
|
68
|
+
(0, vitest_1.expect)(fetchPage).toHaveBeenCalledWith(1, 100);
|
|
69
|
+
}));
|
|
70
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal type for one page of Knex-paginated API results.
|
|
3
|
+
* Matches the shape returned by list endpoints (e.g. /org/users, /org/groups).
|
|
4
|
+
*/
|
|
5
|
+
export interface KnexPagePagination {
|
|
6
|
+
page: number;
|
|
7
|
+
pageSize: number;
|
|
8
|
+
totalResults: number;
|
|
9
|
+
totalPageCount: number;
|
|
10
|
+
}
|
|
11
|
+
export interface KnexPage<T> {
|
|
12
|
+
data: T[];
|
|
13
|
+
pagination?: KnexPagePagination;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper types for Lightdash API. Re-exports generated OpenAPI types and adds response helpers.
|
|
3
|
+
*
|
|
4
|
+
* Note: Domain models (Project, Organization, etc.) are available from @lightdash-tools/common.
|
|
5
|
+
* Use this module for advanced types (paths, components, operations) or response helpers.
|
|
6
|
+
*/
|
|
7
|
+
import type { components } from '@lightdash-tools/common';
|
|
8
|
+
export type { paths, components, operations } from '@lightdash-tools/common';
|
|
9
|
+
/** API error schema from OpenAPI. */
|
|
10
|
+
export type ApiError = components['schemas']['ApiErrorPayload'];
|
|
11
|
+
/** Successful API response wrapper (status ok + results). */
|
|
12
|
+
export interface ApiResponseOk<T> {
|
|
13
|
+
status: 'ok';
|
|
14
|
+
results: T;
|
|
15
|
+
}
|
|
16
|
+
/** Failed API response wrapper (status error + error). */
|
|
17
|
+
export interface ApiResponseError {
|
|
18
|
+
status: 'error';
|
|
19
|
+
error: ApiError['error'];
|
|
20
|
+
}
|
|
21
|
+
/** Discriminated union for API response body. */
|
|
22
|
+
export type ApiResponseBody<T> = ApiResponseOk<T> | ApiResponseError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Helper types for Lightdash API. Re-exports generated OpenAPI types and adds response helpers.
|
|
4
|
+
*
|
|
5
|
+
* Note: Domain models (Project, Organization, etc.) are available from @lightdash-tools/common.
|
|
6
|
+
* Use this module for advanced types (paths, components, operations) or response helpers.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable loading for Lightdash client configuration.
|
|
3
|
+
* Supports LIGHTDASH_API_KEY, LIGHTDASH_URL, LIGHTDASH_PROXY_AUTHORIZATION.
|
|
4
|
+
* Priority: explicit config > environment variables > no default for required fields.
|
|
5
|
+
*/
|
|
6
|
+
import type { LightdashClientConfig, PartialLightdashClientConfig } from '../config';
|
|
7
|
+
/** Environment variable names (aligned with Lightdash CLI). */
|
|
8
|
+
export declare const ENV_LIGHTDASH_API_KEY = "LIGHTDASH_API_KEY";
|
|
9
|
+
export declare const ENV_LIGHTDASH_URL = "LIGHTDASH_URL";
|
|
10
|
+
export declare const ENV_LIGHTDASH_PROXY_AUTHORIZATION = "LIGHTDASH_PROXY_AUTHORIZATION";
|
|
11
|
+
/**
|
|
12
|
+
* Reads configuration from environment variables.
|
|
13
|
+
* Returns only the fields that are set in the environment.
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadConfigFromEnv(): PartialLightdashClientConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Merges explicit config with environment-derived config.
|
|
18
|
+
* Explicit config takes priority over environment variables.
|
|
19
|
+
*/
|
|
20
|
+
export declare function mergeConfig(explicit: PartialLightdashClientConfig | undefined): LightdashClientConfig;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Environment variable loading for Lightdash client configuration.
|
|
4
|
+
* Supports LIGHTDASH_API_KEY, LIGHTDASH_URL, LIGHTDASH_PROXY_AUTHORIZATION.
|
|
5
|
+
* Priority: explicit config > environment variables > no default for required fields.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ENV_LIGHTDASH_PROXY_AUTHORIZATION = exports.ENV_LIGHTDASH_URL = exports.ENV_LIGHTDASH_API_KEY = void 0;
|
|
9
|
+
exports.loadConfigFromEnv = loadConfigFromEnv;
|
|
10
|
+
exports.mergeConfig = mergeConfig;
|
|
11
|
+
/** Environment variable names (aligned with Lightdash CLI). */
|
|
12
|
+
exports.ENV_LIGHTDASH_API_KEY = 'LIGHTDASH_API_KEY';
|
|
13
|
+
exports.ENV_LIGHTDASH_URL = 'LIGHTDASH_URL';
|
|
14
|
+
exports.ENV_LIGHTDASH_PROXY_AUTHORIZATION = 'LIGHTDASH_PROXY_AUTHORIZATION';
|
|
15
|
+
/**
|
|
16
|
+
* Reads configuration from environment variables.
|
|
17
|
+
* Returns only the fields that are set in the environment.
|
|
18
|
+
*/
|
|
19
|
+
function loadConfigFromEnv() {
|
|
20
|
+
const env = typeof process !== 'undefined' ? process.env : {};
|
|
21
|
+
const out = {};
|
|
22
|
+
const apiKey = env[exports.ENV_LIGHTDASH_API_KEY];
|
|
23
|
+
if (apiKey !== undefined && apiKey !== '') {
|
|
24
|
+
out.personalAccessToken = apiKey;
|
|
25
|
+
}
|
|
26
|
+
const url = env[exports.ENV_LIGHTDASH_URL];
|
|
27
|
+
if (url !== undefined && url !== '') {
|
|
28
|
+
out.baseUrl = url.replace(/\/$/, '');
|
|
29
|
+
}
|
|
30
|
+
const proxyAuth = env[exports.ENV_LIGHTDASH_PROXY_AUTHORIZATION];
|
|
31
|
+
if (proxyAuth !== undefined && proxyAuth !== '') {
|
|
32
|
+
out.proxyAuthorization = proxyAuth;
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Merges explicit config with environment-derived config.
|
|
38
|
+
* Explicit config takes priority over environment variables.
|
|
39
|
+
*/
|
|
40
|
+
function mergeConfig(explicit) {
|
|
41
|
+
var _a, _b, _c, _d, _e;
|
|
42
|
+
const fromEnv = loadConfigFromEnv();
|
|
43
|
+
const baseUrl = (_b = (_a = explicit === null || explicit === void 0 ? void 0 : explicit.baseUrl) !== null && _a !== void 0 ? _a : fromEnv.baseUrl) !== null && _b !== void 0 ? _b : '';
|
|
44
|
+
const personalAccessToken = (_d = (_c = explicit === null || explicit === void 0 ? void 0 : explicit.personalAccessToken) !== null && _c !== void 0 ? _c : fromEnv.personalAccessToken) !== null && _d !== void 0 ? _d : '';
|
|
45
|
+
if (!baseUrl || !personalAccessToken) {
|
|
46
|
+
throw new Error('Lightdash client requires baseUrl and personalAccessToken. ' +
|
|
47
|
+
'Set them in config or via LIGHTDASH_URL and LIGHTDASH_API_KEY.');
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
baseUrl,
|
|
51
|
+
personalAccessToken,
|
|
52
|
+
proxyAuthorization: (_e = explicit === null || explicit === void 0 ? void 0 : explicit.proxyAuthorization) !== null && _e !== void 0 ? _e : fromEnv.proxyAuthorization,
|
|
53
|
+
rateLimit: explicit === null || explicit === void 0 ? void 0 : explicit.rateLimit,
|
|
54
|
+
timeout: explicit === null || explicit === void 0 ? void 0 : explicit.timeout,
|
|
55
|
+
retry: explicit === null || explicit === void 0 ? void 0 : explicit.retry,
|
|
56
|
+
logger: explicit === null || explicit === void 0 ? void 0 : explicit.logger,
|
|
57
|
+
observability: explicit === null || explicit === void 0 ? void 0 : explicit.observability,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const env_1 = require("./env");
|
|
5
|
+
const originalEnv = Object.assign({}, process.env);
|
|
6
|
+
(0, vitest_1.beforeEach)(() => {
|
|
7
|
+
delete process.env[env_1.ENV_LIGHTDASH_API_KEY];
|
|
8
|
+
delete process.env[env_1.ENV_LIGHTDASH_URL];
|
|
9
|
+
delete process.env[env_1.ENV_LIGHTDASH_PROXY_AUTHORIZATION];
|
|
10
|
+
});
|
|
11
|
+
(0, vitest_1.afterEach)(() => {
|
|
12
|
+
process.env = Object.assign({}, originalEnv);
|
|
13
|
+
});
|
|
14
|
+
(0, vitest_1.describe)('loadConfigFromEnv', () => {
|
|
15
|
+
(0, vitest_1.it)('should read LIGHTDASH_API_KEY', () => {
|
|
16
|
+
process.env[env_1.ENV_LIGHTDASH_API_KEY] = 'my-token';
|
|
17
|
+
const config = (0, env_1.loadConfigFromEnv)();
|
|
18
|
+
(0, vitest_1.expect)(config.personalAccessToken).toBe('my-token');
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.it)('should read LIGHTDASH_URL', () => {
|
|
21
|
+
process.env[env_1.ENV_LIGHTDASH_URL] = 'https://app.lightdash.cloud';
|
|
22
|
+
const config = (0, env_1.loadConfigFromEnv)();
|
|
23
|
+
(0, vitest_1.expect)(config.baseUrl).toBe('https://app.lightdash.cloud');
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.it)('should strip trailing slash from LIGHTDASH_URL in mergeConfig', () => {
|
|
26
|
+
process.env[env_1.ENV_LIGHTDASH_URL] = 'https://app.lightdash.cloud/';
|
|
27
|
+
const merged = (0, env_1.mergeConfig)({ personalAccessToken: 't' });
|
|
28
|
+
(0, vitest_1.expect)(merged.baseUrl).toBe('https://app.lightdash.cloud');
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.it)('should read LIGHTDASH_PROXY_AUTHORIZATION', () => {
|
|
31
|
+
process.env[env_1.ENV_LIGHTDASH_PROXY_AUTHORIZATION] = 'Bearer proxy-token';
|
|
32
|
+
const config = (0, env_1.loadConfigFromEnv)();
|
|
33
|
+
(0, vitest_1.expect)(config.proxyAuthorization).toBe('Bearer proxy-token');
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.it)('should not set keys for empty env values', () => {
|
|
36
|
+
process.env[env_1.ENV_LIGHTDASH_API_KEY] = '';
|
|
37
|
+
const config = (0, env_1.loadConfigFromEnv)();
|
|
38
|
+
(0, vitest_1.expect)(config.personalAccessToken).toBeUndefined();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.describe)('mergeConfig', () => {
|
|
42
|
+
(0, vitest_1.it)('should prefer explicit config over env', () => {
|
|
43
|
+
process.env[env_1.ENV_LIGHTDASH_URL] = 'https://env.example.com';
|
|
44
|
+
process.env[env_1.ENV_LIGHTDASH_API_KEY] = 'env-token';
|
|
45
|
+
const merged = (0, env_1.mergeConfig)({
|
|
46
|
+
baseUrl: 'https://explicit.example.com',
|
|
47
|
+
personalAccessToken: 'explicit-token',
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.expect)(merged.baseUrl).toBe('https://explicit.example.com');
|
|
50
|
+
(0, vitest_1.expect)(merged.personalAccessToken).toBe('explicit-token');
|
|
51
|
+
});
|
|
52
|
+
(0, vitest_1.it)('should use env when explicit config omits a field', () => {
|
|
53
|
+
process.env[env_1.ENV_LIGHTDASH_URL] = 'https://env.example.com';
|
|
54
|
+
process.env[env_1.ENV_LIGHTDASH_API_KEY] = 'env-token';
|
|
55
|
+
const merged = (0, env_1.mergeConfig)({ baseUrl: 'https://explicit.example.com' });
|
|
56
|
+
(0, vitest_1.expect)(merged.baseUrl).toBe('https://explicit.example.com');
|
|
57
|
+
(0, vitest_1.expect)(merged.personalAccessToken).toBe('env-token');
|
|
58
|
+
});
|
|
59
|
+
(0, vitest_1.it)('should throw when baseUrl and personalAccessToken cannot be resolved', () => {
|
|
60
|
+
(0, vitest_1.expect)(() => (0, env_1.mergeConfig)(undefined)).toThrow(/baseUrl and personalAccessToken/);
|
|
61
|
+
(0, vitest_1.expect)(() => (0, env_1.mergeConfig)({})).toThrow();
|
|
62
|
+
});
|
|
63
|
+
(0, vitest_1.it)('should preserve observability when provided in explicit config', () => {
|
|
64
|
+
var _a;
|
|
65
|
+
const onRequestComplete = vitest_1.vi.fn();
|
|
66
|
+
const merged = (0, env_1.mergeConfig)({
|
|
67
|
+
baseUrl: 'https://app.lightdash.cloud',
|
|
68
|
+
personalAccessToken: 'test-token',
|
|
69
|
+
observability: { onRequestComplete },
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.expect)((_a = merged.observability) === null || _a === void 0 ? void 0 : _a.onRequestComplete).toBe(onRequestComplete);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utilities. Optional logger can be passed in client config.
|
|
3
|
+
*/
|
|
4
|
+
import type { Logger } from '../config';
|
|
5
|
+
/** No-op logger for when logging is disabled. */
|
|
6
|
+
export declare const noopLogger: Logger;
|
|
7
|
+
/** Console-based logger. */
|
|
8
|
+
export declare const consoleLogger: Logger;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logging utilities. Optional logger can be passed in client config.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.consoleLogger = exports.noopLogger = void 0;
|
|
7
|
+
/** No-op logger for when logging is disabled. */
|
|
8
|
+
exports.noopLogger = {
|
|
9
|
+
debug: () => { },
|
|
10
|
+
info: () => { },
|
|
11
|
+
warn: () => { },
|
|
12
|
+
error: () => { },
|
|
13
|
+
};
|
|
14
|
+
/** Console-based logger. */
|
|
15
|
+
exports.consoleLogger = {
|
|
16
|
+
debug: (...args) => console.debug('[Lightdash]', ...args),
|
|
17
|
+
info: (...args) => console.info('[Lightdash]', ...args),
|
|
18
|
+
warn: (...args) => console.warn('[Lightdash]', ...args),
|
|
19
|
+
error: (...args) => console.error('[Lightdash]', ...args),
|
|
20
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry logic with exponential backoff for transient failures.
|
|
3
|
+
* Retries on 5xx and network errors; no retry for 4xx (except 429 handled by rate limiter).
|
|
4
|
+
*/
|
|
5
|
+
import type { RetryConfig } from '../config';
|
|
6
|
+
export type RetryOptions = RetryConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Determines if an error is retryable (5xx or network/ECONNRESET/timeout).
|
|
9
|
+
*/
|
|
10
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Executes an async function with exponential backoff retries.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Retry logic with exponential backoff for transient failures.
|
|
4
|
+
* Retries on 5xx and network errors; no retry for 4xx (except 429 handled by rate limiter).
|
|
5
|
+
*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.isRetryableError = isRetryableError;
|
|
17
|
+
exports.withRetry = withRetry;
|
|
18
|
+
const config_1 = require("../config");
|
|
19
|
+
function delay(ms) {
|
|
20
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Determines if an error is retryable (5xx or network/ECONNRESET/timeout).
|
|
24
|
+
*/
|
|
25
|
+
function isRetryableError(error) {
|
|
26
|
+
if (error && typeof error === 'object' && 'response' in error) {
|
|
27
|
+
const res = error.response;
|
|
28
|
+
if (res && typeof res.status === 'number') {
|
|
29
|
+
return res.status >= 500;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (error instanceof Error) {
|
|
33
|
+
const msg = error.message.toLowerCase();
|
|
34
|
+
const code = error.code;
|
|
35
|
+
return (msg.includes('econnreset') ||
|
|
36
|
+
msg.includes('etimedout') ||
|
|
37
|
+
msg.includes('network') ||
|
|
38
|
+
code === 'ECONNRESET' ||
|
|
39
|
+
code === 'ETIMEDOUT');
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Executes an async function with exponential backoff retries.
|
|
45
|
+
*/
|
|
46
|
+
function withRetry(fn_1) {
|
|
47
|
+
return __awaiter(this, arguments, void 0, function* (fn, options = {}) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const maxRetries = (_a = options.maxRetries) !== null && _a !== void 0 ? _a : config_1.DEFAULT_RETRY.maxRetries;
|
|
50
|
+
const retryDelay = (_b = options.retryDelay) !== null && _b !== void 0 ? _b : config_1.DEFAULT_RETRY.retryDelay;
|
|
51
|
+
let lastError;
|
|
52
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
53
|
+
try {
|
|
54
|
+
return yield fn();
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
lastError = err;
|
|
58
|
+
if (attempt === maxRetries || !isRetryableError(err)) {
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
const wait = retryDelay * Math.pow(2, attempt);
|
|
62
|
+
yield delay(wait);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw lastError;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
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 retry_1 = require("./retry");
|
|
14
|
+
(0, vitest_1.describe)('isRetryableError', () => {
|
|
15
|
+
(0, vitest_1.it)('should return true for 5xx response', () => {
|
|
16
|
+
(0, vitest_1.expect)((0, retry_1.isRetryableError)({ response: { status: 500 } })).toBe(true);
|
|
17
|
+
(0, vitest_1.expect)((0, retry_1.isRetryableError)({ response: { status: 503 } })).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.it)('should return false for 4xx response', () => {
|
|
20
|
+
(0, vitest_1.expect)((0, retry_1.isRetryableError)({ response: { status: 400 } })).toBe(false);
|
|
21
|
+
(0, vitest_1.expect)((0, retry_1.isRetryableError)({ response: { status: 404 } })).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
(0, vitest_1.it)('should return true for network-like errors', () => {
|
|
24
|
+
(0, vitest_1.expect)((0, retry_1.isRetryableError)(new Error('ECONNRESET'))).toBe(true);
|
|
25
|
+
(0, vitest_1.expect)((0, retry_1.isRetryableError)(new Error('ETIMEDOUT'))).toBe(true);
|
|
26
|
+
(0, vitest_1.expect)((0, retry_1.isRetryableError)(Object.assign(new Error('x'), { code: 'ECONNRESET' }))).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
(0, vitest_1.it)('should return false for generic Error', () => {
|
|
29
|
+
(0, vitest_1.expect)((0, retry_1.isRetryableError)(new Error('something else'))).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
(0, vitest_1.describe)('withRetry', () => {
|
|
33
|
+
(0, vitest_1.it)('should return result on first success', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const fn = vitest_1.vi.fn().mockResolvedValue(42);
|
|
35
|
+
const result = yield (0, retry_1.withRetry)(fn);
|
|
36
|
+
(0, vitest_1.expect)(result).toBe(42);
|
|
37
|
+
(0, vitest_1.expect)(fn).toHaveBeenCalledTimes(1);
|
|
38
|
+
}));
|
|
39
|
+
(0, vitest_1.it)('should retry on retryable error then succeed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const fn = vitest_1.vi
|
|
41
|
+
.fn()
|
|
42
|
+
.mockRejectedValueOnce(Object.assign(new Error('ECONNRESET'), { code: 'ECONNRESET' }))
|
|
43
|
+
.mockResolvedValueOnce('ok');
|
|
44
|
+
const result = yield (0, retry_1.withRetry)(fn, { maxRetries: 2, retryDelay: 1 });
|
|
45
|
+
(0, vitest_1.expect)(result).toBe('ok');
|
|
46
|
+
(0, vitest_1.expect)(fn).toHaveBeenCalledTimes(2);
|
|
47
|
+
}));
|
|
48
|
+
(0, vitest_1.it)('should not retry on non-retryable error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const fn = vitest_1.vi.fn().mockRejectedValue({ response: { status: 400 } });
|
|
50
|
+
yield (0, vitest_1.expect)((0, retry_1.withRetry)(fn)).rejects.toMatchObject({ response: { status: 400 } });
|
|
51
|
+
(0, vitest_1.expect)(fn).toHaveBeenCalledTimes(1);
|
|
52
|
+
}));
|
|
53
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lightdash-tools/client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Client library for Lightdash AI.",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"author": "",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"axios": "^1.13.5",
|
|
12
|
+
"bottleneck": "^2.19.5",
|
|
13
|
+
"@lightdash-tools/common": "0.1.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^25.2.3"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base pattern for API area clients. Each area (projects, organizations, charts, etc.)
|
|
3
|
+
* receives the shared HttpClient and implements typed methods for its endpoints.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { HttpClient } from '../http/http-client';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Base for API area clients. Subclasses receive the shared HTTP client
|
|
10
|
+
* and implement methods that call this.http.get/post/put/patch/delete with typed paths and responses.
|
|
11
|
+
*/
|
|
12
|
+
export abstract class BaseApiClient {
|
|
13
|
+
constructor(protected readonly http: HttpClient) {}
|
|
14
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { AiAgentsClient } from './ai-agents';
|
|
3
|
+
import type { HttpClient } from '../../http/http-client';
|
|
4
|
+
|
|
5
|
+
describe('AiAgentsClient', () => {
|
|
6
|
+
let mockHttp: HttpClient;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
mockHttp = {
|
|
10
|
+
get: vi.fn(),
|
|
11
|
+
post: vi.fn(),
|
|
12
|
+
put: vi.fn(),
|
|
13
|
+
patch: vi.fn(),
|
|
14
|
+
delete: vi.fn(),
|
|
15
|
+
} as unknown as HttpClient;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('getAdminThreads should call GET /aiAgents/admin/threads with optional params', async () => {
|
|
19
|
+
const client = new AiAgentsClient(mockHttp);
|
|
20
|
+
const results = { data: [], pagination: { totalResults: 0, totalPageCount: 0 } };
|
|
21
|
+
vi.mocked(mockHttp.get).mockResolvedValue(results);
|
|
22
|
+
const result = await client.getAdminThreads({
|
|
23
|
+
page: 1,
|
|
24
|
+
pageSize: 20,
|
|
25
|
+
sortField: 'createdAt',
|
|
26
|
+
sortDirection: 'desc',
|
|
27
|
+
});
|
|
28
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/aiAgents/admin/threads', {
|
|
29
|
+
params: { page: 1, pageSize: 20, sortField: 'createdAt', sortDirection: 'desc' },
|
|
30
|
+
});
|
|
31
|
+
expect(result).toEqual(results);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('getAdminThreads without params should call GET with no params', async () => {
|
|
35
|
+
const client = new AiAgentsClient(mockHttp);
|
|
36
|
+
const results = { data: [], pagination: { totalResults: 0, totalPageCount: 0 } };
|
|
37
|
+
vi.mocked(mockHttp.get).mockResolvedValue(results);
|
|
38
|
+
await client.getAdminThreads();
|
|
39
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/aiAgents/admin/threads', { params: undefined });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('listAdminAgents should call GET /aiAgents/admin/agents', async () => {
|
|
43
|
+
const client = new AiAgentsClient(mockHttp);
|
|
44
|
+
const list = [{ uuid: 'a1', name: 'Agent 1', description: null }];
|
|
45
|
+
vi.mocked(mockHttp.get).mockResolvedValue(list);
|
|
46
|
+
const result = await client.listAdminAgents();
|
|
47
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/aiAgents/admin/agents');
|
|
48
|
+
expect(result).toEqual(list);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('getAiOrganizationSettings should call GET /aiAgents/admin/settings', async () => {
|
|
52
|
+
const client = new AiAgentsClient(mockHttp);
|
|
53
|
+
const settings = {
|
|
54
|
+
aiAgentsVisible: true,
|
|
55
|
+
organizationUuid: 'org1',
|
|
56
|
+
isTrial: false,
|
|
57
|
+
isCopilotEnabled: false,
|
|
58
|
+
};
|
|
59
|
+
vi.mocked(mockHttp.get).mockResolvedValue(settings);
|
|
60
|
+
const result = await client.getAiOrganizationSettings();
|
|
61
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/aiAgents/admin/settings');
|
|
62
|
+
expect(result).toEqual(settings);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('updateAiOrganizationSettings should call PATCH /aiAgents/admin/settings with body', async () => {
|
|
66
|
+
const client = new AiAgentsClient(mockHttp);
|
|
67
|
+
const body = { aiAgentsVisible: false };
|
|
68
|
+
const updated = { aiAgentsVisible: false, organizationUuid: 'org1' };
|
|
69
|
+
vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
70
|
+
const result = await client.updateAiOrganizationSettings(body);
|
|
71
|
+
expect(mockHttp.patch).toHaveBeenCalledWith('/aiAgents/admin/settings', body);
|
|
72
|
+
expect(result).toEqual(updated);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI agents API client. Admin endpoints for listing agents, threads, and managing org AI settings.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
AiAgentSummary,
|
|
7
|
+
AiAgentsAdminThreadsResult,
|
|
8
|
+
GetAdminThreadsParams,
|
|
9
|
+
GetAiOrganizationSettingsResult,
|
|
10
|
+
UpdateAiOrganizationSettings,
|
|
11
|
+
UpdateAiOrganizationSettingsResult,
|
|
12
|
+
} from '@lightdash-tools/common';
|
|
13
|
+
import { BaseApiClient } from '../base-client';
|
|
14
|
+
|
|
15
|
+
export class AiAgentsClient extends BaseApiClient {
|
|
16
|
+
/**
|
|
17
|
+
* List all AI agent threads (admin). Supports pagination and filters.
|
|
18
|
+
*/
|
|
19
|
+
async getAdminThreads(params?: GetAdminThreadsParams): Promise<AiAgentsAdminThreadsResult> {
|
|
20
|
+
return this.http.get<AiAgentsAdminThreadsResult>('/aiAgents/admin/threads', {
|
|
21
|
+
params,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** List all AI agents (admin). */
|
|
26
|
+
async listAdminAgents(): Promise<AiAgentSummary[]> {
|
|
27
|
+
return this.http.get<AiAgentSummary[]>('/aiAgents/admin/agents');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Get AI organization settings. */
|
|
31
|
+
async getAiOrganizationSettings(): Promise<GetAiOrganizationSettingsResult> {
|
|
32
|
+
return this.http.get<GetAiOrganizationSettingsResult>('/aiAgents/admin/settings');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Update AI organization settings. */
|
|
36
|
+
async updateAiOrganizationSettings(
|
|
37
|
+
body: UpdateAiOrganizationSettings,
|
|
38
|
+
): Promise<UpdateAiOrganizationSettingsResult> {
|
|
39
|
+
return this.http.patch<UpdateAiOrganizationSettingsResult>('/aiAgents/admin/settings', body);
|
|
40
|
+
}
|
|
41
|
+
}
|