@sisense/sdk-ai-core 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +51 -0
  2. package/dist/constants.d.ts +9 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/engines/chart-builder/chart-builder-engine.d.ts +14 -0
  5. package/dist/engines/chart-builder/chart-builder-engine.d.ts.map +1 -0
  6. package/dist/engines/chart-builder/chart-builder-service.d.ts +7 -0
  7. package/dist/engines/chart-builder/chart-builder-service.d.ts.map +1 -0
  8. package/dist/engines/chart-builder/create-chart/create-chart.d.ts +14 -0
  9. package/dist/engines/chart-builder/create-chart/create-chart.d.ts.map +1 -0
  10. package/dist/engines/chart-builder/create-chart/generate-chart-recommendations.d.ts +5 -0
  11. package/dist/engines/chart-builder/create-chart/generate-chart-recommendations.d.ts.map +1 -0
  12. package/dist/engines/chart-builder/create-chart/generate-chart-table.d.ts +3 -0
  13. package/dist/engines/chart-builder/create-chart/generate-chart-table.d.ts.map +1 -0
  14. package/dist/engines/chart-builder/types.d.ts +612 -0
  15. package/dist/engines/chart-builder/types.d.ts.map +1 -0
  16. package/dist/engines/chart-builder/update-chart/chart-options-schemas.d.ts +8629 -0
  17. package/dist/engines/chart-builder/update-chart/chart-options-schemas.d.ts.map +1 -0
  18. package/dist/engines/chart-builder/update-chart/schemas.d.ts +1136 -0
  19. package/dist/engines/chart-builder/update-chart/schemas.d.ts.map +1 -0
  20. package/dist/engines/chart-builder/update-chart/update-chart-data-options.d.ts +18 -0
  21. package/dist/engines/chart-builder/update-chart/update-chart-data-options.d.ts.map +1 -0
  22. package/dist/engines/chart-builder/update-chart/update-chart-style-options.d.ts +18 -0
  23. package/dist/engines/chart-builder/update-chart/update-chart-style-options.d.ts.map +1 -0
  24. package/dist/engines/chart-builder/update-chart/update-chart-title.d.ts +12 -0
  25. package/dist/engines/chart-builder/update-chart/update-chart-title.d.ts.map +1 -0
  26. package/dist/engines/chart-builder/update-chart/update-chart-type.d.ts +14 -0
  27. package/dist/engines/chart-builder/update-chart/update-chart-type.d.ts.map +1 -0
  28. package/dist/engines/index.d.ts +6 -0
  29. package/dist/engines/index.d.ts.map +1 -0
  30. package/dist/index.d.ts +18 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +5035 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/services/dashboards/dashboards-service.d.ts +47 -0
  35. package/dist/services/dashboards/dashboards-service.d.ts.map +1 -0
  36. package/dist/services/dashboards/fusion-dashboards-service.d.ts +71 -0
  37. package/dist/services/dashboards/fusion-dashboards-service.d.ts.map +1 -0
  38. package/dist/services/data-models/data-models-service.d.ts +6 -0
  39. package/dist/services/data-models/data-models-service.d.ts.map +1 -0
  40. package/dist/services/data-models/ecm-service.d.ts +497 -0
  41. package/dist/services/data-models/ecm-service.d.ts.map +1 -0
  42. package/dist/services/data-sources/data-sources-service.d.ts +41 -0
  43. package/dist/services/data-sources/data-sources-service.d.ts.map +1 -0
  44. package/dist/services/globals/globals-service.d.ts +2 -0
  45. package/dist/services/globals/globals-service.d.ts.map +1 -0
  46. package/dist/services/llm/llm-settings-service.d.ts +18 -0
  47. package/dist/services/llm/llm-settings-service.d.ts.map +1 -0
  48. package/dist/services/nlq/nlq-service.d.ts +33 -0
  49. package/dist/services/nlq/nlq-service.d.ts.map +1 -0
  50. package/dist/singleton-clients.d.ts +48 -0
  51. package/dist/singleton-clients.d.ts.map +1 -0
  52. package/dist/utils/chat-completion-utils.d.ts +55 -0
  53. package/dist/utils/chat-completion-utils.d.ts.map +1 -0
  54. package/dist/utils/http-client.d.ts +33 -0
  55. package/dist/utils/http-client.d.ts.map +1 -0
  56. package/dist/utils/id-utils.d.ts +9 -0
  57. package/dist/utils/id-utils.d.ts.map +1 -0
  58. package/dist/utils/openai-client.d.ts +11 -0
  59. package/dist/utils/openai-client.d.ts.map +1 -0
  60. package/dist/utils/proxy-utils.d.ts +5 -0
  61. package/dist/utils/proxy-utils.d.ts.map +1 -0
  62. package/dist/utils/utils.d.ts +12 -0
  63. package/dist/utils/utils.d.ts.map +1 -0
  64. package/dist/utils/zod-utils.d.ts +60 -0
  65. package/dist/utils/zod-utils.d.ts.map +1 -0
  66. package/package.json +62 -0
@@ -0,0 +1,41 @@
1
+ import { DataSourceField, JaqlDataSourceForDto } from '@sisense/sdk-data';
2
+ export declare const DATA_SOURCES_API_URL_PATH = "api/datasources";
3
+ export type DataSourceFieldWithDescription = DataSourceField & {
4
+ description?: string;
5
+ tableDescription?: string;
6
+ };
7
+ export type NormalizedDataSourceField = {
8
+ table: string;
9
+ column: string;
10
+ type: string;
11
+ level?: string;
12
+ expression: string;
13
+ description: string;
14
+ };
15
+ /**
16
+ * Get all data sources
17
+ */
18
+ export declare function getDataSources(): Promise<JaqlDataSourceForDto[]>;
19
+ /**
20
+ * Get a data source by title
21
+ */
22
+ export declare function getDataSourceByTitle(dataSourceTitle: string): Promise<JaqlDataSourceForDto | null>;
23
+ /**
24
+ * Get data source fields
25
+ */
26
+ export declare function getDataSourceFields(dataSourceTitle: string): Promise<DataSourceField[] | null>;
27
+ /**
28
+ * Get data source fields with descriptions from schema
29
+ */
30
+ export declare function getDataSourceFieldsWithDescriptions(dataSourceTitle: string): Promise<DataSourceFieldWithDescription[] | DataSourceField[]>;
31
+ /**
32
+ * Normalize data source fields (pure function - easily testable)
33
+ */
34
+ export declare function normalizeFields(fields: DataSourceFieldWithDescription[] | DataSourceField[]): NormalizedDataSourceField[];
35
+ /**
36
+ * Get normalized data source fields
37
+ * @param dataSourceTitle - The title of the data source
38
+ * @param getFieldsFn - Optional function to get fields (for testing)
39
+ */
40
+ export declare function getNormalizedDataSourceFields(dataSourceTitle: string, getFieldsFn?: (title: string) => Promise<DataSourceFieldWithDescription[] | DataSourceField[]>): Promise<NormalizedDataSourceField[]>;
41
+ //# sourceMappingURL=data-sources-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-sources-service.d.ts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AC,yBAAyB,EAAE,CAAC,CAGtC"}
@@ -0,0 +1,2 @@
1
+ export declare function loadGlobals(): Promise<unknown>;
2
+ //# sourceMappingURL=globals-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals-service.d.ts","sourceRoot":"","sources":["../../../src/services/globals/globals-service.ts"],"names":[],"mappings":"AAEA,wBAAsB,WAAW,qBAIhC"}
@@ -0,0 +1,18 @@
1
+ export interface LlmSettings {
2
+ aiAssistant: {
3
+ enabled: boolean;
4
+ };
5
+ llmServices: {
6
+ enabled: boolean;
7
+ };
8
+ llmTerms: {
9
+ accepted: boolean;
10
+ };
11
+ provider: string;
12
+ baseUrl: string;
13
+ model: string;
14
+ apiKey?: string;
15
+ }
16
+ export declare function getLlmSettings(): Promise<LlmSettings>;
17
+ export declare function updateLlmSettings(settings: LlmSettings): Promise<LlmSettings>;
18
+ //# sourceMappingURL=llm-settings-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-settings-service.d.ts","sourceRoot":"","sources":["../../../src/services/llm/llm-settings-service.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC3B,WAAW,EAAE;QACZ,OAAO,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,WAAW,EAAE;QACZ,OAAO,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,QAAQ,EAAE;QACT,QAAQ,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAID,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAS3D;AAED,wBAAsB,iBAAiB,CACtC,QAAQ,EAAE,WAAW,GACnB,OAAO,CAAC,WAAW,CAAC,CAwBtB"}
@@ -0,0 +1,33 @@
1
+ import { NlqResult, NlqResultChartType, QueryRecommendationResponse } from '@sisense/sdk-ui/ai';
2
+ import { DataSchemaContext, NlqResponseJSON } from '@sisense/sdk-ui/analytics-composer';
3
+ export interface GetNlqResultRequest {
4
+ text: string;
5
+ timezone?: string;
6
+ chartTypes: NlqResultChartType[];
7
+ }
8
+ export interface GetNlqResultLightRequest {
9
+ text: string;
10
+ timezone?: string;
11
+ }
12
+ export interface GetNlqV3ResultRequest {
13
+ text: string;
14
+ timezone?: string;
15
+ chartTypes?: NlqResultChartType[];
16
+ forceGeneration: boolean;
17
+ }
18
+ export interface NlqV3Result {
19
+ chartState: NlqResponseJSON;
20
+ dataSchema: DataSchemaContext;
21
+ clarification?: string;
22
+ timestamp: string;
23
+ }
24
+ export interface QueryRecommendationConfig {
25
+ numOfRecommendations: number;
26
+ userPrompt?: string;
27
+ }
28
+ export declare function getNlqResult(contextTitle: string, request: GetNlqResultRequest): Promise<NlqResult | null>;
29
+ export declare function getNlqResultLight(contextTitle: string, request: GetNlqResultLightRequest): Promise<NlqResult | null>;
30
+ export declare function getNlqV3Result(contextTitle: string, request: GetNlqV3ResultRequest): Promise<NlqV3Result | null>;
31
+ export declare function getQueryRecommendations(contextTitle: string, config: QueryRecommendationConfig): Promise<QueryRecommendationResponse | null>;
32
+ export declare function getQueryRecommendationsLight(contextTitle: string, config: QueryRecommendationConfig): Promise<QueryRecommendationResponse | null>;
33
+ //# sourceMappingURL=nlq-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nlq-service.d.ts","sourceRoot":"","sources":["../../../src/services/nlq/nlq-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,2BAA2B,EAC3B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,MAAM,oCAAoC,CAAC;AAE5C,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,kBAAkB,EAAE,CAAC;CAC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
3
+ import { AuthenticatorConfig } from './utils/http-client';
4
+ /**
5
+ * Set a pre-created HttpClient instance (similar to initializeSisenseServices)
6
+ * Useful when the consuming app already has an HttpClient instance
7
+ *
8
+ * @param httpClient - Pre-created HttpClient instance
9
+ */
10
+ export declare function initializeHttpClient(httpClient: HttpClient): void;
11
+ /**
12
+ * Get the shared HttpClient instance (lazy initialization)
13
+ *
14
+ * @returns The HttpClient instance
15
+ * @throws Error if client hasn't been initialized
16
+ */
17
+ export declare function getHttpClient(): HttpClient;
18
+ /**
19
+ * Reset the http client
20
+ * This function is useful when the consuming app needs to switch tenant or login to another user
21
+ */
22
+ export declare function resetHttpClient(): void;
23
+ /**
24
+ * Set a pre-created OpenAI client instance (similar to initializeSisenseServices)
25
+ * Useful when the consuming app already has an OpenAI client instance
26
+ *
27
+ * @param openAIClient - Pre-created OpenAI client instance
28
+ */
29
+ export declare function initializeOpenAIClient(openAIClient: OpenAI): void;
30
+ /**
31
+ * Get the shared OpenAI client instance (lazy initialization)
32
+ *
33
+ * @returns The OpenAI client instance
34
+ * @throws Error if client hasn't been initialized
35
+ */
36
+ export declare function getOpenAIClient(): OpenAI;
37
+ /**
38
+ * Reset the OpenAI client (useful for testing)
39
+ *
40
+ * Allows tests to clean up or reset the shared instance between test runs
41
+ */
42
+ export declare function resetOpenAIClient(): void;
43
+ /**
44
+ * Initialize the HttpClient and OpenAI client singletons
45
+ * @param authConfig - Authenticator configuration
46
+ */
47
+ export declare function initializeClients(authConfig: AuthenticatorConfig): void;
48
+ //# sourceMappingURL=singleton-clients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton-clients.d.ts","sourceRoot":"","sources":["../src/singleton-clients.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EACN,mBAAmB,EAEnB,MAAM,qBAAqB,CAAC;AAM7B;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAEjE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAO1C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAQD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAEjE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAOxC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,mBAAmB,GAAG,IAAI,CAQvE"}
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ import { OpenAI } from 'openai';
3
+ type StructuredCompletionParams<T> = {
4
+ systemPrompt: string;
5
+ userPrompt: string;
6
+ responseFormat: {
7
+ type: 'json_schema';
8
+ schema: z.ZodSchema<T>;
9
+ name: string;
10
+ } | {
11
+ type: 'json_object';
12
+ };
13
+ model?: string;
14
+ temperature?: number;
15
+ sessionId?: string | null;
16
+ openAIClient?: OpenAI;
17
+ };
18
+ /**
19
+ * Creates a structured completion using OpenAI with consistent configuration
20
+ * across all tools.
21
+ */
22
+ export declare function createStructuredCompletion<T>(params: StructuredCompletionParams<T>): Promise<T>;
23
+ type ToolsCompletionParams = {
24
+ systemPrompt: string;
25
+ userPrompt: string;
26
+ tools: any[];
27
+ model?: string;
28
+ temperature?: number;
29
+ toolChoice?: 'auto' | 'none' | {
30
+ type: 'function';
31
+ function: {
32
+ name: string;
33
+ };
34
+ };
35
+ openAIClient?: OpenAI;
36
+ };
37
+ type GenericMessage = {
38
+ role: string;
39
+ content?: string | any;
40
+ tool_call_id?: string;
41
+ [key: string]: any;
42
+ };
43
+ type ToolsCompletionResult = {
44
+ toolMessages: GenericMessage[];
45
+ assistantMessages: string[];
46
+ combinedMessage: string;
47
+ isError: boolean;
48
+ };
49
+ /**
50
+ * Creates a tools completion using OpenAI with streaming support.
51
+ * Returns captured messages and a combined message string ready for use.
52
+ */
53
+ export declare function createToolsCompletion(params: ToolsCompletionParams): Promise<ToolsCompletionResult>;
54
+ export {};
55
+ //# sourceMappingURL=chat-completion-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-completion-utils.d.ts","sourceRoot":"","sources":["../../src/utils/chat-completion-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIrC,KAAK,0BAA0B,CAAC,CAAC,IAAI;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EACX;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAC7D;QAAE,IAAI,EAAE,aAAa,CAAA;KAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,0BAA0B,CAAC,CAAC,EACjD,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,CAAC,CAAC,CA0DZ;AAED,KAAK,qBAAqB,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EACR,MAAM,GACN,MAAM,GACN;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF,KAAK,cAAc,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC5B,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,qBAAqB,CAC1C,MAAM,EAAE,qBAAqB,GAC3B,OAAO,CAAC,qBAAqB,CAAC,CA8HhC"}
@@ -0,0 +1,33 @@
1
+ import { Authenticator, HttpClient } from '@sisense/sdk-rest-client';
2
+ export type AuthenticatorConfig = {
3
+ url: string;
4
+ username?: string;
5
+ password?: string;
6
+ token?: string | null;
7
+ wat?: string | null;
8
+ ssoEnabled?: boolean;
9
+ enableSilentPreAuth?: boolean;
10
+ useFusionAuth?: boolean;
11
+ alternativeSsoHost?: string;
12
+ };
13
+ /**
14
+ * Factory function to create an HTTP client from an authenticator
15
+ * @param url - The URL to use for the HTTP client
16
+ * @param authenticator - The authenticator to use for the HTTP client
17
+ * @returns Configured HttpClient instance
18
+ */
19
+ export declare function createHttpClientFromAuthenticator(url: string, authenticator: Authenticator): HttpClient;
20
+ /**
21
+ * Factory function to create an HTTP client from an authenticator configuration
22
+ * @param config - Authenticator configuration
23
+ * @returns Configured HttpClient instance
24
+ */
25
+ export declare function createHttpClientFromConfig(config: AuthenticatorConfig): HttpClient;
26
+ /**
27
+ * Factory function to create a custom fetch function for OpenAI chat completions
28
+ * This fetch function applies authentication headers from the provided httpClient
29
+ * @param httpClient - The HTTP client instance to use for authentication
30
+ * @returns Custom fetch function
31
+ */
32
+ export declare function createCustomFetch(httpClient: HttpClient): (url: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
33
+ //# sourceMappingURL=http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/utils/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EAEb,UAAU,EACV,MAAM,0BAA0B,CAAC;AAKlC,MAAM,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAChD,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,aAAa,GAC1B,UAAU,CAYZ;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,mBAAmB,GACzB,UAAU,CAQZ;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,IAEtD,KAAK,WAAW,GAAG,GAAG,EACtB,OAAO,WAAW,KAChB,OAAO,CAAC,QAAQ,CAAC,CA0BpB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generate a nanoid with a hex alphabet
3
+ */
4
+ export declare const nanoidHex: (size?: number) => string;
5
+ /**
6
+ * Generate a nanoid with a hex alphabet that is a valid UUIDv4
7
+ */
8
+ export declare function nanoidUUIDv4(): string;
9
+ //# sourceMappingURL=id-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-utils.d.ts","sourceRoot":"","sources":["../../src/utils/id-utils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,SAAS,2BAAyC,CAAC;AAEhE;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAkBrC"}
@@ -0,0 +1,11 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ import { default as OpenAI } from 'openai';
3
+ /**
4
+ * Factory function to create an OpenAI client with custom configuration
5
+ * @param baseURL - The base URL for the OpenAI API endpoint
6
+ * @param fetchFn - Custom fetch function (e.g., with authentication headers)
7
+ * @returns Configured OpenAI client instance
8
+ */
9
+ export declare function createOpenAIClientHelper(baseURL: string, fetchFn: typeof fetch): OpenAI;
10
+ export declare function createOpenAIClient(httpClient: HttpClient): OpenAI;
11
+ //# sourceMappingURL=openai-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-client.d.ts","sourceRoot":"","sources":["../../src/utils/openai-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAM5B;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,KAAK,GACnB,MAAM,CAQR;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAGjE"}
@@ -0,0 +1,5 @@
1
+ export declare function getUrlWithProxy(url: string): string;
2
+ export declare function getAbsoluteUrlWithProxy(url: string): string;
3
+ export declare function getProxyPath(): string;
4
+ export declare function getTenantPrefix(): string;
5
+ //# sourceMappingURL=proxy-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy-utils.d.ts","sourceRoot":"","sources":["../../src/utils/proxy-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAInD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO3D;AAED,wBAAgB,YAAY,IAAI,MAAM,CAkBrC;AAED,wBAAgB,eAAe,WAkB9B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Utilities for sdk-ai-services
3
+ */
4
+ /**
5
+ * Normalize URL by ensuring it ends with a trailing slash
6
+ */
7
+ export declare function normalizeUrl(url: string): string;
8
+ /**
9
+ * Parse error to extract message
10
+ */
11
+ export declare const parseError: (error: Error | string | object) => any;
12
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,GAAG,MAAM,GAAG,MAAM,QAYxD,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod';
2
+ import { RunnableToolFunctionWithParse } from 'openai/lib/RunnableFunction';
3
+ /**
4
+ * Parse error from various types
5
+ */
6
+ export declare const parseError: (error: Error | string | object) => any;
7
+ /**
8
+ * Filter Zod schema properties using path-based filtering.
9
+ * Keeps properties in the keep list, all their descendants, and the path to reach them.
10
+ *
11
+ * Algorithm:
12
+ * - If property name is in keep list → keep it entirely (with all descendants)
13
+ * - If property is a container → check if it contains kept properties
14
+ * - If yes → keep container and recurse
15
+ * - If no → remove it
16
+ *
17
+ * @param schema - The Zod schema to filter
18
+ * @param propertiesToKeep - Array of property names to keep (with all their descendants)
19
+ * @returns A new filtered Zod schema
20
+ */
21
+ export declare const filterSchemaProperties: (schema: z.ZodTypeAny, propertiesToKeep: string[]) => z.ZodTypeAny;
22
+ /**
23
+ * Exclude specified properties from a Zod schema.
24
+ * Removes properties in the exclude list and all their descendants.
25
+ *
26
+ * Algorithm:
27
+ * - If property name is in exclude list → remove entirely (with all descendants)
28
+ * - Otherwise → keep and recurse to handle nested exclusions
29
+ *
30
+ * @param schema - The Zod schema to process
31
+ * @param propertiesToExclude - Array of property names to remove (with all their descendants)
32
+ * @returns A new filtered Zod schema
33
+ */
34
+ export declare const excludeSchemaProperties: (schema: z.ZodTypeAny, propertiesToExclude: string[]) => z.ZodTypeAny;
35
+ /**
36
+ * Convert a Zod schema to a readable type string representation
37
+ */
38
+ export declare const zodToReadableType: (schema: z.ZodTypeAny, depth?: number, propName?: string, isOptional?: boolean) => string;
39
+ /**
40
+ * Create a decoupled zodFunction that wraps Zod schemas for OpenAI tools.
41
+ *
42
+ * This is a pure function that does NOT depend on stores or session management.
43
+ * It only wraps the schema and delegates to the provided function with a generic context.
44
+ *
45
+ * @param config - Configuration for the tool
46
+ * @param config.schema - The Zod schema for parameters
47
+ * @param config.name - The function name
48
+ * @param config.description - The function description
49
+ * @param config.function - The function to execute (receives args and generic context)
50
+ * @param config.strict - Whether to use strict mode
51
+ * @returns A runnable tool function for OpenAI
52
+ */
53
+ export declare function zodFunction<T extends object, TContext = any>({ function: fn, schema, description, name, strict, }: {
54
+ function: (args: T, context: TContext) => Promise<object>;
55
+ schema: z.ZodSchema<T>;
56
+ description?: string;
57
+ name?: string;
58
+ strict?: boolean;
59
+ }): RunnableToolFunctionWithParse<T>;
60
+ //# sourceMappingURL=zod-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-utils.d.ts","sourceRoot":"","sources":["../../src/utils/zod-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAK5E;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,GAAG,MAAM,GAAG,MAAM,QAYxD,CAAC;AA8IF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GAClC,QAAQ,CAAC,CAAC,UAAU,EACpB,kBAAkB,MAAM,EAAE,KACxB,CAAC,CAAC,UAEJ,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GACnC,QAAQ,CAAC,CAAC,UAAU,EACpB,qBAAqB,MAAM,EAAE,KAC3B,CAAC,CAAC,UAEJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,CAAC,CAAC,UAAU,EACpB,cAAS,EACT,WAAW,MAAM,EACjB,aAAa,OAAO,KAClB,MAuDF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,GAAG,GAAG,EAAE,EAC7D,QAAQ,EAAE,EAAE,EACZ,MAAM,EACN,WAAgB,EAChB,IAAI,EACJ,MAAc,GACd,EAAE;IACF,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAkBnC"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@sisense/sdk-ai-core",
3
+ "version": "0.2.11",
4
+ "main": "./dist/index.js",
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "npx tsc -b tsconfig.lib.json && vite build",
17
+ "test": "vitest run src",
18
+ "test:watch": "vitest watch src",
19
+ "test:coverage": "vitest run --coverage src",
20
+ "test:e2e": "vitest run e2e",
21
+ "format:write": "prettier --write .",
22
+ "format:check": "prettier --check .",
23
+ "lint": "eslint ."
24
+ },
25
+ "dependencies": {
26
+ "@sisense/sdk-data": "^2.0.0",
27
+ "@sisense/sdk-rest-client": "^2.0.0",
28
+ "deepmerge": "^4.3.1",
29
+ "fast-deep-equal": "^3.1.3",
30
+ "nanoid": "^5.0.9",
31
+ "openai": "^4.86.1",
32
+ "tslib": "^2.8.1",
33
+ "zod": "^3.24.1",
34
+ "zod-to-json-schema": "^3.24.1"
35
+ },
36
+ "devDependencies": {
37
+ "@sisense/sdk-ui": "^2.0.0",
38
+ "@types/lodash-es": "^4.17.6",
39
+ "@types/node": "22.5.5",
40
+ "@vitest/coverage-v8": "^2.1.9",
41
+ "typescript": "^5.7.2",
42
+ "vite": "^5.4.11",
43
+ "vite-plugin-dts": "^4.2.1",
44
+ "vitest": "^2.1.9"
45
+ },
46
+ "peerDependencies": {
47
+ "@sisense/sdk-ui": "^2.0.0"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "@sisense/sdk-ui": {
51
+ "optional": false
52
+ }
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/sisense/sdk-ai-core.git"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/sisense/sdk-ai-core/issues"
60
+ },
61
+ "homepage": "https://github.com/sisense/sdk-ai-core#readme"
62
+ }