@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
package/src/utils/env.ts
CHANGED
|
@@ -4,14 +4,49 @@
|
|
|
4
4
|
* Priority: explicit config > environment variables > no default for required fields.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { LightdashClientConfig, PartialLightdashClientConfig } from '../config';
|
|
8
7
|
import { SecretString } from './secret-string';
|
|
9
8
|
|
|
9
|
+
import type {
|
|
10
|
+
LightdashAuthConfig,
|
|
11
|
+
PartialLightdashClientConfig,
|
|
12
|
+
ResolvedLightdashClientConfig,
|
|
13
|
+
} from '../config';
|
|
14
|
+
|
|
10
15
|
/** Environment variable names (aligned with Lightdash CLI). */
|
|
11
16
|
export const ENV_LIGHTDASH_API_KEY = 'LIGHTDASH_API_KEY';
|
|
12
17
|
export const ENV_LIGHTDASH_URL = 'LIGHTDASH_URL';
|
|
13
18
|
export const ENV_LIGHTDASH_PROXY_AUTHORIZATION = 'LIGHTDASH_PROXY_AUTHORIZATION';
|
|
14
19
|
|
|
20
|
+
function toSecretString(value: SecretString | string): SecretString {
|
|
21
|
+
return typeof value === 'string' ? new SecretString(value) : value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function normalizeAuthConfig(
|
|
25
|
+
auth: NonNullable<PartialLightdashClientConfig['auth']>,
|
|
26
|
+
): LightdashAuthConfig {
|
|
27
|
+
const token = toSecretString(auth.token);
|
|
28
|
+
if (auth.type === 'bearer') {
|
|
29
|
+
return { type: 'bearer', token };
|
|
30
|
+
}
|
|
31
|
+
return { type: 'api-key', token };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function resolveAuthConfig(
|
|
35
|
+
explicit: PartialLightdashClientConfig | undefined,
|
|
36
|
+
fromEnv: PartialLightdashClientConfig,
|
|
37
|
+
): LightdashAuthConfig {
|
|
38
|
+
if (explicit?.auth) {
|
|
39
|
+
return normalizeAuthConfig(explicit.auth);
|
|
40
|
+
}
|
|
41
|
+
const pat = explicit?.personalAccessToken ?? fromEnv.personalAccessToken;
|
|
42
|
+
if (pat) {
|
|
43
|
+
return { type: 'api-key', token: toSecretString(pat) };
|
|
44
|
+
}
|
|
45
|
+
throw new Error(
|
|
46
|
+
'Lightdash client requires auth credentials. Set auth, personalAccessToken, or LIGHTDASH_API_KEY.',
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
15
50
|
/**
|
|
16
51
|
* Reads configuration from environment variables.
|
|
17
52
|
* Returns only the fields that are set in the environment.
|
|
@@ -38,30 +73,46 @@ export function loadConfigFromEnv(): PartialLightdashClientConfig {
|
|
|
38
73
|
return out;
|
|
39
74
|
}
|
|
40
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Builds a bearer-token client config for OAuth access tokens.
|
|
78
|
+
*/
|
|
79
|
+
export function createBearerConfig(options: {
|
|
80
|
+
baseUrl: string;
|
|
81
|
+
accessToken: SecretString | string;
|
|
82
|
+
proxyAuthorization?: SecretString | string;
|
|
83
|
+
}): PartialLightdashClientConfig {
|
|
84
|
+
return {
|
|
85
|
+
baseUrl: options.baseUrl.replace(/\/$/, ''),
|
|
86
|
+
auth: { type: 'bearer', token: options.accessToken },
|
|
87
|
+
proxyAuthorization: options.proxyAuthorization,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
41
91
|
/**
|
|
42
92
|
* Merges explicit config with environment-derived config.
|
|
43
93
|
* Explicit config takes priority over environment variables.
|
|
44
94
|
*/
|
|
45
95
|
export function mergeConfig(
|
|
46
96
|
explicit: PartialLightdashClientConfig | undefined,
|
|
47
|
-
):
|
|
97
|
+
): ResolvedLightdashClientConfig {
|
|
48
98
|
const fromEnv = loadConfigFromEnv();
|
|
49
99
|
|
|
50
100
|
const baseUrl = explicit?.baseUrl ?? fromEnv.baseUrl ?? '';
|
|
51
|
-
const pat = explicit?.personalAccessToken ?? fromEnv.personalAccessToken ?? '';
|
|
52
101
|
const proxyAuth = explicit?.proxyAuthorization ?? fromEnv.proxyAuthorization;
|
|
53
102
|
|
|
54
|
-
if (!baseUrl
|
|
55
|
-
throw new Error(
|
|
56
|
-
'Lightdash client requires baseUrl and personalAccessToken. ' +
|
|
57
|
-
'Set them in config or via LIGHTDASH_URL and LIGHTDASH_API_KEY.',
|
|
58
|
-
);
|
|
103
|
+
if (!baseUrl) {
|
|
104
|
+
throw new Error('Lightdash client requires baseUrl. Set it in config or via LIGHTDASH_URL.');
|
|
59
105
|
}
|
|
60
106
|
|
|
107
|
+
const auth = resolveAuthConfig(explicit, fromEnv);
|
|
108
|
+
const personalAccessToken = auth.type === 'api-key' ? auth.token : explicit?.personalAccessToken;
|
|
109
|
+
|
|
61
110
|
return {
|
|
62
111
|
baseUrl,
|
|
63
|
-
|
|
64
|
-
|
|
112
|
+
auth,
|
|
113
|
+
personalAccessToken:
|
|
114
|
+
personalAccessToken !== undefined ? toSecretString(personalAccessToken) : undefined,
|
|
115
|
+
proxyAuthorization: proxyAuth !== undefined ? toSecretString(proxyAuth) : undefined,
|
|
65
116
|
rateLimit: explicit?.rateLimit,
|
|
66
117
|
timeout: explicit?.timeout,
|
|
67
118
|
retry: explicit?.retry,
|
package/src/utils/logger.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type { Logger } from '../config';
|
|
6
6
|
|
|
7
|
+
const LOG_PREFIX = '[Lightdash]';
|
|
8
|
+
|
|
7
9
|
/** No-op logger for when logging is disabled. */
|
|
8
10
|
export const noopLogger: Logger = {
|
|
9
11
|
debug: () => {},
|
|
@@ -14,8 +16,8 @@ export const noopLogger: Logger = {
|
|
|
14
16
|
|
|
15
17
|
/** Console-based logger. */
|
|
16
18
|
export const consoleLogger: Logger = {
|
|
17
|
-
debug: (...args) => console.debug(
|
|
18
|
-
info: (...args) => console.info(
|
|
19
|
-
warn: (...args) => console.warn(
|
|
20
|
-
error: (...args) => console.error(
|
|
19
|
+
debug: (...args) => console.debug(LOG_PREFIX, ...args),
|
|
20
|
+
info: (...args) => console.info(LOG_PREFIX, ...args),
|
|
21
|
+
warn: (...args) => console.warn(LOG_PREFIX, ...args),
|
|
22
|
+
error: (...args) => console.error(LOG_PREFIX, ...args),
|
|
21
23
|
};
|
package/src/utils/retry.test.ts
CHANGED
package/src/utils/retry.ts
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* Retries on 5xx and network errors; no retry for 4xx (except 429 handled by rate limiter).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { RetryConfig } from '../config';
|
|
7
6
|
import { DEFAULT_RETRY } from '../config';
|
|
8
7
|
|
|
8
|
+
import type { RetryConfig } from '../config';
|
|
9
|
+
|
|
9
10
|
export type RetryOptions = RetryConfig;
|
|
10
11
|
|
|
11
12
|
function delay(ms: number): Promise<void> {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import util from 'node:util';
|
|
2
|
+
|
|
3
|
+
import { describe, it, expect } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import { SecretString } from './secret-string';
|
|
6
|
+
|
|
7
|
+
describe('SecretString', () => {
|
|
8
|
+
const secret = new SecretString('my-secret-token');
|
|
9
|
+
|
|
10
|
+
it('toString() masks the value', () => {
|
|
11
|
+
expect(secret.toString()).toBe('**********');
|
|
12
|
+
expect(String(secret)).toBe('**********');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('toJSON() masks the value', () => {
|
|
16
|
+
expect(secret.toJSON()).toBe('**********');
|
|
17
|
+
expect(JSON.stringify({ token: secret })).toBe('{"token":"**********"}');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('custom inspect masks the value', () => {
|
|
21
|
+
expect(util.inspect(secret)).toBe('SecretString(**********)');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('expose() returns the underlying value', () => {
|
|
25
|
+
expect(secret.expose()).toBe('my-secret-token');
|
|
26
|
+
});
|
|
27
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "es2017",
|
|
4
4
|
"module": "commonjs",
|
|
5
5
|
"declaration": true,
|
|
6
6
|
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
7
8
|
"strict": true,
|
|
8
9
|
"esModuleInterop": true,
|
|
9
10
|
"skipLibCheck": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"types": ["node"]
|
|
11
13
|
},
|
|
12
14
|
"include": ["src"]
|
|
13
15
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI agents API client.
|
|
3
|
-
*
|
|
4
|
-
* Admin endpoints → /api/v1/aiAgents/admin/...
|
|
5
|
-
* Project-scoped → /api/v1/projects/{projectUuid}/aiAgents/...
|
|
6
|
-
*/
|
|
7
|
-
import type { AiAgentSummary, AiAgentsAdminThreadsResult, GetAdminThreadsParams, GetAiOrganizationSettingsResult, UpdateAiOrganizationSettings, UpdateAiOrganizationSettingsResult, AiAgent, CreateAiAgent, UpdateAiAgent, AiAgentThreadSummary, AiAgentThread, CreateAgentThreadBody, GenerateAgentThreadBody, GenerateAgentThreadResult, CreateEvaluationBody, CreateEvaluationResult, UpdateEvaluationBody, AppendEvaluationBody, AiAgentEvaluationSummary, AiAgentEvaluation, AiAgentEvaluationRunSummary, AiAgentEvaluationRun } from '@lightdash-tools/common';
|
|
8
|
-
import { BaseApiClient } from '../base-client';
|
|
9
|
-
export declare class AiAgentsClient extends BaseApiClient {
|
|
10
|
-
/** List all AI agent threads across the org (admin). Supports pagination and filters. */
|
|
11
|
-
getAdminThreads(params?: GetAdminThreadsParams): Promise<AiAgentsAdminThreadsResult>;
|
|
12
|
-
/** List all AI agents across the org (admin). */
|
|
13
|
-
listAdminAgents(): Promise<AiAgentSummary[]>;
|
|
14
|
-
/** Get AI organization settings. */
|
|
15
|
-
getAiOrganizationSettings(): Promise<GetAiOrganizationSettingsResult>;
|
|
16
|
-
/** Update AI organization settings. */
|
|
17
|
-
updateAiOrganizationSettings(body: UpdateAiOrganizationSettings): Promise<UpdateAiOrganizationSettingsResult>;
|
|
18
|
-
/** List all agents in a project (GET /projects/{projectUuid}/aiAgents). */
|
|
19
|
-
listAgents(projectUuid: string): Promise<AiAgentSummary[]>;
|
|
20
|
-
/** Get a single agent by UUID (GET /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
21
|
-
getAgent(projectUuid: string, agentUuid: string): Promise<AiAgent>;
|
|
22
|
-
/** Create a new agent in a project (POST /projects/{projectUuid}/aiAgents). */
|
|
23
|
-
createAgent(projectUuid: string, body: CreateAiAgent): Promise<AiAgent>;
|
|
24
|
-
/** Update an existing agent (PATCH /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
25
|
-
updateAgent(projectUuid: string, agentUuid: string, body: UpdateAiAgent): Promise<AiAgent>;
|
|
26
|
-
/** Delete an agent (DELETE /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
27
|
-
deleteAgent(projectUuid: string, agentUuid: string): Promise<void>;
|
|
28
|
-
/** List all threads for an agent (GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads). */
|
|
29
|
-
listAgentThreads(projectUuid: string, agentUuid: string): Promise<AiAgentThreadSummary[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Create a new thread (POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads).
|
|
32
|
-
* Pass `prompt` in the body to trigger an immediate generation.
|
|
33
|
-
*/
|
|
34
|
-
createAgentThread(projectUuid: string, agentUuid: string, body?: CreateAgentThreadBody): Promise<AiAgentThreadSummary>;
|
|
35
|
-
/** Get a thread with its messages (GET …/threads/{threadUuid}). */
|
|
36
|
-
getAgentThread(projectUuid: string, agentUuid: string, threadUuid: string): Promise<AiAgentThread>;
|
|
37
|
-
/**
|
|
38
|
-
* Generate a response in a thread (POST …/threads/{threadUuid}/generate).
|
|
39
|
-
* Use this to send a prompt and receive the agent's reply.
|
|
40
|
-
*/
|
|
41
|
-
generateAgentThreadResponse(projectUuid: string, agentUuid: string, threadUuid: string, body: GenerateAgentThreadBody): Promise<GenerateAgentThreadResult>;
|
|
42
|
-
/** List all evaluations for an agent (GET …/{agentUuid}/evaluations). */
|
|
43
|
-
listEvaluations(projectUuid: string, agentUuid: string): Promise<AiAgentEvaluationSummary[]>;
|
|
44
|
-
/** Create a new evaluation (POST …/{agentUuid}/evaluations). */
|
|
45
|
-
createEvaluation(projectUuid: string, agentUuid: string, body: CreateEvaluationBody): Promise<CreateEvaluationResult>;
|
|
46
|
-
/** Get a full evaluation with prompts (GET …/evaluations/{evalUuid}). */
|
|
47
|
-
getEvaluation(projectUuid: string, agentUuid: string, evalUuid: string): Promise<AiAgentEvaluation>;
|
|
48
|
-
/** Update an evaluation's title, description, or prompts (PATCH …/evaluations/{evalUuid}). */
|
|
49
|
-
updateEvaluation(projectUuid: string, agentUuid: string, evalUuid: string, body: UpdateEvaluationBody): Promise<AiAgentEvaluation>;
|
|
50
|
-
/** Append additional prompts to an existing evaluation (POST …/evaluations/{evalUuid}/append). */
|
|
51
|
-
appendToEvaluation(projectUuid: string, agentUuid: string, evalUuid: string, body: AppendEvaluationBody): Promise<void>;
|
|
52
|
-
/** Delete an evaluation (DELETE …/evaluations/{evalUuid}). */
|
|
53
|
-
deleteEvaluation(projectUuid: string, agentUuid: string, evalUuid: string): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Trigger a new evaluation run (POST …/evaluations/{evalUuid}/run).
|
|
56
|
-
* Returns a run summary with the new runUuid and initial status.
|
|
57
|
-
*/
|
|
58
|
-
runEvaluation(projectUuid: string, agentUuid: string, evalUuid: string): Promise<AiAgentEvaluationRunSummary>;
|
|
59
|
-
/** List all runs for an evaluation (GET …/evaluations/{evalUuid}/runs). */
|
|
60
|
-
listEvaluationRuns(projectUuid: string, agentUuid: string, evalUuid: string): Promise<AiAgentEvaluationRunSummary[]>;
|
|
61
|
-
/** Get detailed results of a specific run (GET …/evaluations/{evalUuid}/runs/{runUuid}). */
|
|
62
|
-
getEvaluationRunResults(projectUuid: string, agentUuid: string, evalUuid: string, runUuid: string): Promise<AiAgentEvaluationRun>;
|
|
63
|
-
}
|
package/dist/api/v1/ai-agents.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* AI agents API client.
|
|
4
|
-
*
|
|
5
|
-
* Admin endpoints → /api/v1/aiAgents/admin/...
|
|
6
|
-
* Project-scoped → /api/v1/projects/{projectUuid}/aiAgents/...
|
|
7
|
-
*/
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.AiAgentsClient = void 0;
|
|
19
|
-
const base_client_1 = require("../base-client");
|
|
20
|
-
class AiAgentsClient extends base_client_1.BaseApiClient {
|
|
21
|
-
// ─── Admin: threads ──────────────────────────────────────────────────────────
|
|
22
|
-
/** List all AI agent threads across the org (admin). Supports pagination and filters. */
|
|
23
|
-
getAdminThreads(params) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
return this.http.get('/aiAgents/admin/threads', {
|
|
26
|
-
params,
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
// ─── Admin: agents ───────────────────────────────────────────────────────────
|
|
31
|
-
/** List all AI agents across the org (admin). */
|
|
32
|
-
listAdminAgents() {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
return this.http.get('/aiAgents/admin/agents');
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
// ─── Admin: settings ─────────────────────────────────────────────────────────
|
|
38
|
-
/** Get AI organization settings. */
|
|
39
|
-
getAiOrganizationSettings() {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
return this.http.get('/aiAgents/admin/settings');
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/** Update AI organization settings. */
|
|
45
|
-
updateAiOrganizationSettings(body) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return this.http.patch('/aiAgents/admin/settings', body);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
// ─── Project-scoped: agent CRUD ──────────────────────────────────────────────
|
|
51
|
-
/** List all agents in a project (GET /projects/{projectUuid}/aiAgents). */
|
|
52
|
-
listAgents(projectUuid) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
return this.http.get(`/projects/${projectUuid}/aiAgents`);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/** Get a single agent by UUID (GET /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
58
|
-
getAgent(projectUuid, agentUuid) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}`);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/** Create a new agent in a project (POST /projects/{projectUuid}/aiAgents). */
|
|
64
|
-
createAgent(projectUuid, body) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
return this.http.post(`/projects/${projectUuid}/aiAgents`, body);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/** Update an existing agent (PATCH /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
70
|
-
updateAgent(projectUuid, agentUuid, body) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
return this.http.patch(`/projects/${projectUuid}/aiAgents/${agentUuid}`, body);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/** Delete an agent (DELETE /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
76
|
-
deleteAgent(projectUuid, agentUuid) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
yield this.http.delete(`/projects/${projectUuid}/aiAgents/${agentUuid}`);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
// ─── Project-scoped: threads ─────────────────────────────────────────────────
|
|
82
|
-
/** List all threads for an agent (GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads). */
|
|
83
|
-
listAgentThreads(projectUuid, agentUuid) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads`);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Create a new thread (POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads).
|
|
90
|
-
* Pass `prompt` in the body to trigger an immediate generation.
|
|
91
|
-
*/
|
|
92
|
-
createAgentThread(projectUuid, agentUuid, body) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads`, body !== null && body !== void 0 ? body : {});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
/** Get a thread with its messages (GET …/threads/{threadUuid}). */
|
|
98
|
-
getAgentThread(projectUuid, agentUuid, threadUuid) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}`);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Generate a response in a thread (POST …/threads/{threadUuid}/generate).
|
|
105
|
-
* Use this to send a prompt and receive the agent's reply.
|
|
106
|
-
*/
|
|
107
|
-
generateAgentThreadResponse(projectUuid, agentUuid, threadUuid, body) {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}/generate`, body);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
// ─── Project-scoped: evaluations ─────────────────────────────────────────────
|
|
113
|
-
/** List all evaluations for an agent (GET …/{agentUuid}/evaluations). */
|
|
114
|
-
listEvaluations(projectUuid, agentUuid) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations`);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
/** Create a new evaluation (POST …/{agentUuid}/evaluations). */
|
|
120
|
-
createEvaluation(projectUuid, agentUuid, body) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations`, body);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/** Get a full evaluation with prompts (GET …/evaluations/{evalUuid}). */
|
|
126
|
-
getEvaluation(projectUuid, agentUuid, evalUuid) {
|
|
127
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
/** Update an evaluation's title, description, or prompts (PATCH …/evaluations/{evalUuid}). */
|
|
132
|
-
updateEvaluation(projectUuid, agentUuid, evalUuid, body) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
return this.http.patch(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`, body);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
/** Append additional prompts to an existing evaluation (POST …/evaluations/{evalUuid}/append). */
|
|
138
|
-
appendToEvaluation(projectUuid, agentUuid, evalUuid, body) {
|
|
139
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
yield this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/append`, body);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
/** Delete an evaluation (DELETE …/evaluations/{evalUuid}). */
|
|
144
|
-
deleteEvaluation(projectUuid, agentUuid, evalUuid) {
|
|
145
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
yield this.http.delete(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
// ─── Project-scoped: evaluation runs ─────────────────────────────────────────
|
|
150
|
-
/**
|
|
151
|
-
* Trigger a new evaluation run (POST …/evaluations/{evalUuid}/run).
|
|
152
|
-
* Returns a run summary with the new runUuid and initial status.
|
|
153
|
-
*/
|
|
154
|
-
runEvaluation(projectUuid, agentUuid, evalUuid) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/run`, {});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
/** List all runs for an evaluation (GET …/evaluations/{evalUuid}/runs). */
|
|
160
|
-
listEvaluationRuns(projectUuid, agentUuid, evalUuid) {
|
|
161
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const response = yield this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/runs`);
|
|
163
|
-
return response.data.runs;
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
/** Get detailed results of a specific run (GET …/evaluations/{evalUuid}/runs/{runUuid}). */
|
|
167
|
-
getEvaluationRunResults(projectUuid, agentUuid, evalUuid, runUuid) {
|
|
168
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/runs/${runUuid}`);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
exports.AiAgentsClient = AiAgentsClient;
|