@sisense/sdk-ai-core 0.15.1 → 0.17.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/dist/constants.d.ts +1 -0
- package/dist/engines/build-chart/types.d.ts +11 -0
- package/dist/engines/get-data-source-fields/types.d.ts +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12333 -10357
- package/dist/services/data-sources/data-sources-service.d.ts +20 -5
- package/dist/services/llm/llm-models-service.d.ts +10 -2
- package/dist/services/llm/llm-settings-service.d.ts +29 -0
- package/dist/utils/llm-model-override.d.ts +41 -0
- package/package.json +6 -5
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { DataSourceField, JaqlDataSourceForDto } from '@sisense/sdk-data';
|
|
2
2
|
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
3
3
|
export declare const DATA_SOURCES_API_URL_PATH = "api/datasources";
|
|
4
|
+
/**
|
|
5
|
+
* Mirrors CSDK {@link DisplayNameConfig} from `@sisense/sdk-query-client/dispatcher`
|
|
6
|
+
* without re-exporting that package (keeps consumer `.d.ts` portable).
|
|
7
|
+
*/
|
|
8
|
+
export type DisplayNameConfig = {
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
useNewSearchByDisplayNameApi?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type GetDataSourceFieldsOptions = {
|
|
13
|
+
httpClient?: HttpClient;
|
|
14
|
+
displayNameConfig?: DisplayNameConfig;
|
|
15
|
+
};
|
|
4
16
|
export type DataSourceFieldWithDescription = DataSourceField & {
|
|
5
17
|
description?: string;
|
|
6
18
|
tableDescription?: string;
|
|
@@ -26,17 +38,19 @@ export type DataSourceWithStatus = JaqlDataSourceForDto & {
|
|
|
26
38
|
};
|
|
27
39
|
export declare function getDataSources(httpClient?: HttpClient): Promise<DataSourceWithStatus[]>;
|
|
28
40
|
/**
|
|
29
|
-
* Get a data source by title
|
|
41
|
+
* Get a data source by title in a viewer-safe way (list + local filter).
|
|
42
|
+
* Prefer this over GET api/datasources/{title}, which requires manage/viewschema.
|
|
30
43
|
*/
|
|
31
44
|
export declare function getDataSourceByTitle(dataSourceTitle: string, httpClient?: HttpClient): Promise<JaqlDataSourceForDto | null>;
|
|
32
45
|
/**
|
|
33
|
-
* Get data source fields
|
|
46
|
+
* Get data source fields via CSDK QueryApiDispatcher.
|
|
47
|
+
* Omit displayNameConfig (or leave flags false) → viewer-safe fields/search.
|
|
34
48
|
*/
|
|
35
|
-
export declare function getDataSourceFields(dataSourceTitle: string,
|
|
49
|
+
export declare function getDataSourceFields(dataSourceTitle: string, options?: GetDataSourceFieldsOptions): Promise<DataSourceField[] | null>;
|
|
36
50
|
/**
|
|
37
51
|
* Get data source fields with descriptions from schema
|
|
38
52
|
*/
|
|
39
|
-
export declare function getDataSourceFieldsWithDescriptions(dataSourceTitle: string,
|
|
53
|
+
export declare function getDataSourceFieldsWithDescriptions(dataSourceTitle: string, options?: GetDataSourceFieldsOptions): Promise<DataSourceFieldWithDescription[] | DataSourceField[]>;
|
|
40
54
|
/**
|
|
41
55
|
* Normalize data source fields (pure function - easily testable)
|
|
42
56
|
*/
|
|
@@ -45,5 +59,6 @@ export declare function normalizeFields(fields: DataSourceFieldWithDescription[]
|
|
|
45
59
|
* Get normalized data source fields
|
|
46
60
|
* @param dataSourceTitle - The title of the data source
|
|
47
61
|
* @param getFieldsFn - Optional function to get fields (for testing)
|
|
62
|
+
* @param options - Optional httpClient and displayNameConfig
|
|
48
63
|
*/
|
|
49
|
-
export declare function getNormalizedDataSourceFields(dataSourceTitle: string, getFieldsFn?: (title: string,
|
|
64
|
+
export declare function getNormalizedDataSourceFields(dataSourceTitle: string, getFieldsFn?: (title: string, options?: GetDataSourceFieldsOptions) => Promise<DataSourceFieldWithDescription[] | DataSourceField[]>, options?: GetDataSourceFieldsOptions): Promise<NormalizedDataSourceField[]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
2
|
+
/** POST api/v2/ai/llm/models body. */
|
|
2
3
|
export interface LlmModelPayload {
|
|
3
4
|
name: string;
|
|
4
5
|
provider: string;
|
|
@@ -6,9 +7,16 @@ export interface LlmModelPayload {
|
|
|
6
7
|
region?: string;
|
|
7
8
|
config: Record<string, unknown>;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
/** Item of GET api/v2/ai/llm/models — no config (write-only). */
|
|
11
|
+
export interface LlmModel {
|
|
10
12
|
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
model: string;
|
|
15
|
+
provider: string;
|
|
16
|
+
scope?: string;
|
|
11
17
|
}
|
|
12
18
|
export declare function getActiveLlmModels(httpClient?: HttpClient): Promise<LlmModel[]>;
|
|
13
19
|
export declare function deleteLlmModel(id: string, httpClient?: HttpClient): Promise<void>;
|
|
14
|
-
export declare function registerLlmModel(payload: LlmModelPayload, testConnection?: boolean, httpClient?: HttpClient): Promise<
|
|
20
|
+
export declare function registerLlmModel(payload: LlmModelPayload, testConnection?: boolean, httpClient?: HttpClient): Promise<{
|
|
21
|
+
id: string;
|
|
22
|
+
}>;
|
|
@@ -13,5 +13,34 @@ export interface LlmSettings {
|
|
|
13
13
|
model: string;
|
|
14
14
|
apiKey?: string;
|
|
15
15
|
}
|
|
16
|
+
/** AI terms & conditions accepted status (`api/v2/settings/ai/terms`). */
|
|
17
|
+
export interface AiTerms {
|
|
18
|
+
accepted: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* AI settings slice (`api/v2/settings/ai`) — the tenant-level AI configuration that is
|
|
22
|
+
* separate from the LLM provider config (`.../ai/llm`). Forward-compatible: only the
|
|
23
|
+
* fields we consume are typed; the endpoint returns more (narration, etc.).
|
|
24
|
+
*
|
|
25
|
+
* Note: unlike {@link LlmSettings}, this slice carries NO provider credentials, so
|
|
26
|
+
* reading/writing it never touches the LLM `apiKey`.
|
|
27
|
+
*/
|
|
28
|
+
export interface AiSettings {
|
|
29
|
+
aiAssistant?: {
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
16
33
|
export declare function getLlmSettings(): Promise<LlmSettings>;
|
|
34
|
+
export declare function getAiTerms(): Promise<AiTerms>;
|
|
35
|
+
/** Updates the AI terms & conditions accepted status (admins only). */
|
|
36
|
+
export declare function setAiTerms(accepted: boolean): Promise<void>;
|
|
37
|
+
/** Reads the AI settings slice (`api/v2/settings/ai`) — no LLM credentials involved. */
|
|
38
|
+
export declare function getAiSettings(): Promise<AiSettings>;
|
|
39
|
+
/**
|
|
40
|
+
* Enables or disables the AI assistant via a partial PATCH to the AI-settings slice
|
|
41
|
+
* (`api/v2/settings/ai`, admins only). Sends ONLY the `aiAssistant.enabled` field, so
|
|
42
|
+
* it never round-trips the LLM provider config (provider/baseUrl/apiKey), which lives
|
|
43
|
+
* on `api/v2/settings/ai/llm` and must not be clobbered.
|
|
44
|
+
*/
|
|
45
|
+
export declare function setAiAssistantEnabled(enabled: boolean): Promise<void>;
|
|
17
46
|
export declare function updateLlmSettings(settings: LlmSettings): Promise<LlmSettings>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-request LLM model override (test/debug only).
|
|
3
|
+
*
|
|
4
|
+
* Holds the model identifier sent as the `x-llm-model-override` header on every
|
|
5
|
+
* LLM-bound request. Kept separate from user-action tracking on purpose: tracking
|
|
6
|
+
* headers are observability (traceparent, quota, attribution), while the override
|
|
7
|
+
* is request routing — mirroring ai-integration's own header taxonomy, where
|
|
8
|
+
* `llmModelOverrideHeader` lives outside the tracking group and is consumed by the
|
|
9
|
+
* LLM resolution funnel instead of the tracing pipeline.
|
|
10
|
+
*
|
|
11
|
+
* The state is PROCESS-GLOBAL (module singleton): the last `setLlmModelOverride`
|
|
12
|
+
* wins for every subsequent request in the process. Test suites that need different
|
|
13
|
+
* overrides must run sequentially, each setting its model in `beforeAll` and
|
|
14
|
+
* clearing it in `afterAll` (see `describeForEachModel` in the e2e utils) — vitest's
|
|
15
|
+
* per-file `forks` isolation resets the state between test files.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Sets a per-request LLM model override (test/debug only) carried on every subsequent
|
|
19
|
+
* LLM request as the `x-llm-model-override` header — both tool-loop completion calls
|
|
20
|
+
* (via the custom fetch) and REST calls built with `withTrackingHeaders`.
|
|
21
|
+
*
|
|
22
|
+
* ai-integration honors the header only when the `ai.featureFlags.llmOverride`
|
|
23
|
+
* base-config flag is ON and the caller is an admin; the model must already be
|
|
24
|
+
* registered (see `registerLlmModel`) and is referenced by its llm-gw `model`
|
|
25
|
+
* identifier.
|
|
26
|
+
*
|
|
27
|
+
* The override is session-scoped: it survives `startUserAction`/`endUserAction`
|
|
28
|
+
* cycles. Pass `null` to clear it (the header is then omitted entirely — required for
|
|
29
|
+
* cross-origin browser embeds, where an empty custom header still triggers a CORS
|
|
30
|
+
* preflight that Sisense does not allow).
|
|
31
|
+
* @param modelName - Registered llm-gw model identifier to force, or `null` to clear
|
|
32
|
+
*/
|
|
33
|
+
export declare function setLlmModelOverride(modelName: string | null): void;
|
|
34
|
+
/** Returns the current override model identifier, or `null` when none is set. */
|
|
35
|
+
export declare function getLlmModelOverride(): string | null;
|
|
36
|
+
/**
|
|
37
|
+
* The `x-llm-model-override` header entry for outgoing LLM-bound requests, as a
|
|
38
|
+
* spreadable fragment. Returns `{}` when unset so egress points omit the header —
|
|
39
|
+
* browsers treat any custom header (even empty) as non-simple and CORS-preflight it.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getLlmModelOverrideHeader(): Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sisense/sdk-ai-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@faker-js/faker": "^9.9.0",
|
|
27
27
|
"@ai-sdk/openai": "^3.0.64",
|
|
28
|
-
"@sisense/sdk-data": "^2.
|
|
29
|
-
"@sisense/sdk-
|
|
28
|
+
"@sisense/sdk-data": "^2.32.0",
|
|
29
|
+
"@sisense/sdk-query-client": "^2.32.0",
|
|
30
|
+
"@sisense/sdk-rest-client": "^2.32.0",
|
|
30
31
|
"ai": "^6.0.188",
|
|
31
32
|
"deepmerge": "^4.3.1",
|
|
32
33
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"zod-to-json-schema": "^3.25.2"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@sisense/sdk-ui": "^2.
|
|
43
|
+
"@sisense/sdk-ui": "^2.32.0",
|
|
43
44
|
"@types/lodash-es": "^4.17.12",
|
|
44
45
|
"@types/node": "^22.19.17",
|
|
45
46
|
"@vitest/coverage-v8": "^4.1.0",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"vitest": "~4.1.7"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
|
-
"@sisense/sdk-ui": "^2.
|
|
53
|
+
"@sisense/sdk-ui": "^2.32.0"
|
|
53
54
|
},
|
|
54
55
|
"peerDependenciesMeta": {
|
|
55
56
|
"@sisense/sdk-ui": {
|