@sisense/sdk-ui-angular 2.9.0 → 2.10.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.
@@ -87,13 +87,13 @@ const AI_CONTEXT_CONFIG_TOKEN = new InjectionToken('AI Context Config');
87
87
  let AiService = class AiService {
88
88
  constructor(sisenseContextService, aiContextConfig) {
89
89
  this.sisenseContextService = sisenseContextService;
90
- this.apiPromise = this.sisenseContextService
91
- .getApp()
92
- .then((app) => new ChatRestApi(app.httpClient, aiContextConfig?.volatile));
90
+ this.aiContextConfig = aiContextConfig;
93
91
  }
94
92
  /** @internal */
95
93
  getApi() {
96
- return this.apiPromise;
94
+ return this.sisenseContextService
95
+ .getApp()
96
+ .then((app) => new ChatRestApi(app.httpClient, this.aiContextConfig?.volatile));
97
97
  }
98
98
  /**
99
99
  * Fetches an analysis of the provided query using natural language generation (NLG).
@@ -1 +1 @@
1
- {"version":3,"file":"sisense-sdk-ui-angular-ai.mjs","sources":["../../src/ai/lib/component-wrapper-helpers/context-connectors.ts","../../src/ai/lib/component-wrapper-helpers/template.ts","../../src/ai/lib/services/ai.service.ts","../../src/ai/lib/components/chatbot.component.ts","../../src/ai/lib/components/get-nlg-insights.component.ts","../../src/ai/lib/sdk-ai.module.ts","../../src/ai/lib/sdk-ui-core-exports.ts","../../src/ai/public-api.ts","../../src/ai/sisense-sdk-ui-angular-ai.ts"],"sourcesContent":["import { ContextConnector, DataObserver } from '@sisense/sdk-ui-preact';\nimport { CustomAiContextProvider, CustomAiContextProviderProps } from '@sisense/sdk-ui-preact/ai';\n\nimport { AiService } from '../services/ai.service';\n\n/**\n * Creates AI context connector\n *\n * @param aiService - The AI service\n * @internal\n */\nexport const createAiContextConnector = (\n aiService: AiService,\n): ContextConnector<CustomAiContextProviderProps> => {\n const propsObserver = new DataObserver<CustomAiContextProviderProps>();\n\n aiService\n .getApi()\n .then((api) =>\n propsObserver.setValue({\n context: {\n api,\n },\n }),\n )\n .catch((error) =>\n propsObserver.setValue({\n error,\n }),\n );\n\n return {\n propsObserver,\n providerComponent: CustomAiContextProvider,\n };\n};\n","export const rootId = 'preact';\nexport const template = `\n <div #${rootId} class=\"csdk-full-size-container\"></div>\n`;\nexport const styles = [\n `.csdk-full-size-container {\n width: 100%;\n height: 100%;\n }`,\n];\n","import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { SisenseContextService, TrackableService, WidgetProps } from '@sisense/sdk-ui-angular';\nimport {\n AiContextProviderProps,\n ChatRestApi,\n DEFAULT_RECOMMENDATIONS_COUNT,\n GetNlgInsightsResponse,\n GetNlqResultParams,\n GetQueryRecommendationsParams,\n prepareGetNlgInsightsPayload,\n prepareGetNlqResultPayload,\n QueryRecommendation as QueryRecommendationPreact,\n UseGetNlgInsightsParams,\n widgetComposer,\n} from '@sisense/sdk-ui-preact/ai';\n\nexport interface AiContextConfig extends Omit<AiContextProviderProps, 'children'> {}\nexport interface GetNlgInsightsParams extends Omit<UseGetNlgInsightsParams, 'enabled'> {}\n\n/**\n * {@inheritDoc @sisense/sdk-ui!QueryRecommendation}\n */\nexport interface QueryRecommendation extends Omit<QueryRecommendationPreact, 'widgetProps'> {\n /**\n * {@inheritDoc @sisense/sdk-ui!QueryRecommendation.widgetProps}\n */\n widgetProps?: WidgetProps;\n}\n\n/**\n * Token used to inject {@link AiContextConfig} into your application.\n *\n * @example\n * Example of importing {@link SdkAiModule} and injecting {@link AiContextConfig} into your application,\n * along with importing dependency {@link SdkUiModule} and injecting {@link SisenseContextConfig} to connect to a Sisense instance:\n *\n * ```ts\n * import { SdkUiModule, SisenseContextConfig } from '@sisense/sdk-ui-angular';\n * import { SdkAiModule, AI_CONTEXT_CONFIG_TOKEN, AiContextConfig } from '@sisense/sdk-ui-angular/ai';\n *\n * const AI_CONTEXT_CONFIG: AiContextConfig = {\n * volatile: true,\n * };\n * const SISENSE_CONTEXT_CONFIG: SisenseContextConfig = {\n * url: \"<instance url>\", // replace with the URL of your Sisense instance\n * token: \"<api token>\", // replace with the API token of your user account\n * defaultDataSource: DM.DataSource,\n * };\n *\n * @NgModule({\n * imports: [\n * BrowserModule,\n * SdkUiModule,\n * SdkAiModule,\n * ],\n * declarations: [AppComponent],\n * providers: [\n * { provide: AI_CONTEXT_CONFIG_TOKEN, useValue: AI_CONTEXT_CONFIG },\n * { provide: SISENSE_CONTEXT_CONFIG_TOKEN, useValue: SISENSE_CONTEXT_CONFIG },\n * ],\n * bootstrap: [AppComponent],\n * })\n * ```\n * @group Generative AI\n */\nexport const AI_CONTEXT_CONFIG_TOKEN = new InjectionToken<AiContextConfig>('AI Context Config');\n\n/**\n * Service for working with Sisense Fusion Generative AI.\n *\n * @group Generative AI\n */\n@Injectable({\n providedIn: 'root',\n})\n@TrackableService<AiService>(['getNlgInsights', 'getQueryRecommendations'])\nexport class AiService {\n private apiPromise: Promise<ChatRestApi>;\n\n constructor(\n private sisenseContextService: SisenseContextService,\n @Optional() @Inject(AI_CONTEXT_CONFIG_TOKEN) aiContextConfig?: AiContextConfig,\n ) {\n this.apiPromise = this.sisenseContextService\n .getApp()\n .then((app) => new ChatRestApi(app.httpClient, aiContextConfig?.volatile));\n }\n\n /** @internal */\n getApi(): Promise<ChatRestApi> {\n return this.apiPromise;\n }\n\n /**\n * Fetches an analysis of the provided query using natural language generation (NLG).\n * Specifying NLG parameters is similar to providing parameters to the {@link QueryService.executeQuery} service method, using dimensions, measures, and filters.\n *\n * @param params - Parameters for getting NLG insights\n * @returns NLG insights text summary\n */\n async getNlgInsights(params: GetNlgInsightsParams): Promise<string | undefined> {\n const api = await this.getApi();\n const payload = prepareGetNlgInsightsPayload(params);\n return api.ai\n .getNlgInsights(payload)\n .then((response?: GetNlgInsightsResponse) => response?.data?.answer);\n }\n\n /**\n * Fetches recommended questions for a data model or perspective.\n *\n * @param params - Parameters for recommendations\n * @returns An array of objects, each containing recommended question text and its corresponding `widgetProps`\n * @beta\n */\n async getQueryRecommendations(\n params: GetQueryRecommendationsParams,\n ): Promise<QueryRecommendation[]> {\n const api = await this.getApi();\n const { contextTitle, count, enableAxisTitlesInWidgetProps, customPrompt } = params;\n const recCount = count ?? DEFAULT_RECOMMENDATIONS_COUNT;\n\n const rawRecommendations =\n (await api.ai.getQueryRecommendations(contextTitle, {\n numOfRecommendations: recCount,\n ...(customPrompt ? { userPrompt: customPrompt } : undefined),\n })) || [];\n\n return rawRecommendations.map(\n (recommendation: QueryRecommendationPreact) =>\n ({\n ...recommendation,\n widgetProps: recommendation.jaql\n ? widgetComposer.toWidgetProps(recommendation, {\n useCustomizedStyleOptions: enableAxisTitlesInWidgetProps,\n })\n : undefined,\n } as QueryRecommendation),\n );\n }\n\n /**\n * Executes a natural language query (NLQ) against a data model or perspective\n *\n * @param params - NLQ query parameters\n * @returns The result as WidgetProps\n * @beta\n */\n async getNlqResult(params: GetNlqResultParams): Promise<WidgetProps | undefined> {\n const { contextTitle, request } = prepareGetNlqResultPayload(params);\n const api = await this.getApi();\n\n const data = await api?.ai.getNlqResult(contextTitle, request);\n\n return data\n ? (widgetComposer.toWidgetProps(data, {\n useCustomizedStyleOptions: params.enableAxisTitlesInWidgetProps || false,\n }) as WidgetProps)\n : undefined;\n }\n}\n","import {\n AfterViewInit,\n Component,\n ElementRef,\n Input,\n OnChanges,\n OnDestroy,\n ViewChild,\n} from '@angular/core';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n createSisenseContextConnector,\n createThemeContextConnector,\n SisenseContextService,\n ThemeService,\n} from '@sisense/sdk-ui-angular';\nimport { ComponentAdapter } from '@sisense/sdk-ui-preact';\nimport {\n Chatbot as ChatbotPreact,\n type ChatbotProps as ChatbotPropsPreact,\n} from '@sisense/sdk-ui-preact/ai';\n\nimport { createAiContextConnector, rootId, styles, template } from '../component-wrapper-helpers';\nimport { AiService } from '../services/ai.service';\n\n/**\n * Props of the {@link ChatbotComponent}.\n */\nexport interface ChatbotProps extends ChatbotPropsPreact {}\n\n/**\n * An Angular component that renders a chatbot with data topic selection.\n *\n * @example\n * An example of using the `ChatbotComponent`:\n *\n * ```html\n<!--Component HTML template in example.component.html-->\n<csdk-chatbot\n [width]=\"chatbot.width\"\n [height]=\"chatbot.height\"\n [config]=\"chatbot.config\"\n/>\n * ```\n *\n * ```ts\n// Component behavior in example.component.ts\nimport { Component } from '@angular/core';\n\n@Component({\n selector: 'example',\n templateUrl: './example.component.html',\n styleUrls: ['./example.component.scss'],\n})\nexport class ExampleComponent {\n chatbot = {\n width: '500px',\n height: '700px',\n config: {\n numOfRecommendations: 5,\n },\n };\n}\n * ```\n *\n * <img src=\"media://angular-chatbot-example.png\" width=\"500px\" />\n * @group Generative AI\n */\n@Component({\n selector: 'csdk-chatbot',\n template,\n styles,\n})\nexport class ChatbotComponent implements AfterViewInit, OnChanges, OnDestroy {\n /**\n * @internal\n */\n @ViewChild(rootId)\n preactRef!: ElementRef<HTMLDivElement>;\n\n /**\n * {@inheritDoc @sisense/sdk-ui!ChatbotProps.width}\n */\n @Input()\n width: ChatbotProps['width'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!ChatbotProps.height}\n */\n @Input()\n height: ChatbotProps['height'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!ChatbotProps.config}\n */\n @Input()\n config: ChatbotProps['config'];\n\n private componentAdapter: ComponentAdapter<typeof ChatbotPreact>;\n\n /**\n * Constructor for the `ChatbotComponent`.\n *\n * @param sisenseContextService - Sisense context service\n * @param themeService - Theme service\n * @param aiService - AI service\n */\n constructor(\n /**\n * Sisense context service\n *\n * @category Constructor\n */\n public sisenseContextService: SisenseContextService,\n /**\n * Theme service\n *\n * @category Constructor\n */\n public themeService: ThemeService,\n /**\n * AI service\n *\n * @category Constructor\n */\n public aiService: AiService,\n ) {\n this.componentAdapter = new ComponentAdapter(ChatbotPreact, [\n createSisenseContextConnector(this.sisenseContextService),\n createThemeContextConnector(this.themeService),\n createAiContextConnector(this.aiService),\n ]);\n }\n\n /**\n * @internal\n */\n ngAfterViewInit() {\n this.componentAdapter.render(this.preactRef.nativeElement, this.getPreactComponentProps());\n }\n\n /**\n * @internal\n */\n ngOnChanges() {\n if (this.preactRef) {\n this.componentAdapter.render(this.preactRef.nativeElement, this.getPreactComponentProps());\n }\n }\n\n private getPreactComponentProps(): ChatbotPropsPreact {\n return {\n width: this.width,\n height: this.height,\n config: this.config,\n };\n }\n\n /**\n * @internal\n */\n ngOnDestroy() {\n this.componentAdapter.destroy();\n }\n}\n","import {\n AfterViewInit,\n Component,\n ElementRef,\n Input,\n OnChanges,\n OnDestroy,\n ViewChild,\n} from '@angular/core';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n createSisenseContextConnector,\n createThemeContextConnector,\n SisenseContextService,\n ThemeService,\n} from '@sisense/sdk-ui-angular';\nimport { ComponentAdapter } from '@sisense/sdk-ui-preact';\nimport {\n GetNlgInsights as GetNlgInsightsPreact,\n type GetNlgInsightsProps as GetNlgInsightsPropsPreact,\n} from '@sisense/sdk-ui-preact/ai';\n\nimport { createAiContextConnector, rootId, styles, template } from '../component-wrapper-helpers';\nimport { AiService } from '../services/ai.service';\n\n/**\n * Props of the {@link GetNlgInsightsComponent}.\n */\nexport interface GetNlgInsightsProps extends GetNlgInsightsPropsPreact {}\n\n/**\n * An Angular component that fetches and displays a collapsible analysis of the provided query using natural language generation (NLG).\n * Specifying NLG parameters is similar to providing parameters to the {@link QueryService.executeQuery} service method, using dimensions, measures, and filters.\n *\n * @example\n * An example of using the `GetNlgInsightsComponent`:\n *\n * ```html\n<!--Component HTML template in example.component.html-->\n<csdk-get-nlg-insights\n [dataSource]=\"nlgParams.dataSource\"\n [dimensions]=\"nlgParams.dimensions\"\n [measures]=\"nlgParams.measures\"\n/>\n * ```\n *\n * ```ts\n// Component behavior in example.component.ts\nimport { Component } from '@angular/core';\nimport { measureFactory } from '@sisense/sdk-data';\nimport * as DM from '../../assets/sample-healthcare-model';\n\n@Component({\n selector: 'example',\n templateUrl: './example.component.html',\n styleUrls: ['./example.component.scss'],\n})\nexport class ExampleComponent {\n nlgParams = {\n dataSource: DM.DataSource.title,\n dimensions: [DM.Divisions.Divison_name],\n measures: [measureFactory.sum(DM.Admissions.Cost_of_admission)],\n };\n}\n * ```\n *\n * <img src=\"media://angular-get-nlg-insights-example.png\" width=\"700px\" />\n * @group Generative AI\n */\n@Component({\n selector: 'csdk-get-nlg-insights',\n template,\n styles,\n})\nexport class GetNlgInsightsComponent implements AfterViewInit, OnChanges, OnDestroy {\n /**\n * @internal\n */\n @ViewChild(rootId)\n preactRef!: ElementRef<HTMLDivElement>;\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.dataSource}\n */\n @Input()\n dataSource!: GetNlgInsightsProps['dataSource'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.dimensions}\n */\n @Input()\n dimensions: GetNlgInsightsProps['dimensions'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.measures}\n */\n @Input()\n measures: GetNlgInsightsProps['measures'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.filters}\n */\n @Input()\n filters: GetNlgInsightsProps['filters'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.verbosity}\n */\n @Input()\n verbosity: GetNlgInsightsProps['verbosity'];\n\n private componentAdapter: ComponentAdapter<typeof GetNlgInsightsPreact>;\n\n /**\n * Constructor for the `GetNlgInsightsProps`.\n *\n * @param sisenseContextService - Sisense context service\n * @param themeService - Theme service\n * @param aiService - AI service\n */\n constructor(\n /**\n * Sisense context service\n *\n * @category Constructor\n */\n public sisenseContextService: SisenseContextService,\n /**\n * Theme service\n *\n * @category Constructor\n */\n public themeService: ThemeService,\n /**\n * AI service\n *\n * @category Constructor\n */\n public aiService: AiService,\n ) {\n this.componentAdapter = new ComponentAdapter(GetNlgInsightsPreact, [\n createSisenseContextConnector(this.sisenseContextService),\n createThemeContextConnector(this.themeService),\n createAiContextConnector(this.aiService),\n ]);\n }\n\n /**\n * @internal\n */\n ngAfterViewInit() {\n this.componentAdapter.render(this.preactRef.nativeElement, this.getPreactComponentProps());\n }\n\n /**\n * @internal\n */\n ngOnChanges() {\n if (this.preactRef) {\n this.componentAdapter.render(this.preactRef.nativeElement, this.getPreactComponentProps());\n }\n }\n\n private getPreactComponentProps(): GetNlgInsightsPropsPreact {\n return {\n dataSource: this.dataSource,\n dimensions: this.dimensions,\n measures: this.measures,\n filters: this.filters,\n verbosity: this.verbosity,\n };\n }\n\n /**\n * @internal\n */\n ngOnDestroy() {\n this.componentAdapter.destroy();\n }\n}\n","/* eslint-disable import/no-extraneous-dependencies */\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { SdkUiModule } from '@sisense/sdk-ui-angular';\n\nimport { ChatbotComponent, GetNlgInsightsComponent } from './components';\n\n/**\n * SDK AI Module, which is a container for generative AI components and services.\n *\n * @example\n * Example of importing {@link SdkAiModule} and injecting {@link AiContextConfig} into your application,\n * along with importing dependency {@link SdkUiModule} and injecting {@link SisenseContextConfig} to connect to a Sisense instance:\n *\n * ```ts\n * import { SdkUiModule, SisenseContextConfig } from '@sisense/sdk-ui-angular';\n * import { SdkAiModule, AI_CONTEXT_CONFIG_TOKEN, AiContextConfig } from '@sisense/sdk-ui-angular/ai';\n *\n * const AI_CONTEXT_CONFIG: AiContextConfig = {\n * volatile: true,\n * };\n * const SISENSE_CONTEXT_CONFIG: SisenseContextConfig = {\n * url: \"<instance url>\", // replace with the URL of your Sisense instance\n * token: \"<api token>\", // replace with the API token of your user account\n * defaultDataSource: DM.DataSource,\n * };\n *\n * @NgModule({\n * imports: [\n * BrowserModule,\n * SdkUiModule,\n * SdkAiModule,\n * ],\n * declarations: [AppComponent],\n * providers: [\n * { provide: AI_CONTEXT_CONFIG_TOKEN, useValue: AI_CONTEXT_CONFIG },\n * { provide: SISENSE_CONTEXT_CONFIG_TOKEN, useValue: SISENSE_CONTEXT_CONFIG },\n * ],\n * bootstrap: [AppComponent],\n * })\n * ```\n * @group Generative AI\n */\n@NgModule({\n declarations: [ChatbotComponent, GetNlgInsightsComponent],\n imports: [CommonModule, SdkUiModule],\n exports: [ChatbotComponent, GetNlgInsightsComponent],\n providers: [],\n})\nexport class SdkAiModule {\n constructor() {\n console.log('SdkAiModule loaded');\n }\n}\n","// This file re-exports common types/utils from @sisense/sdk-ui-preact/ai\n\n// Re-exports types from @sisense/sdk-ui-preact/ai\nexport type {\n ChatConfig,\n GetNlqResultParams,\n GetQueryRecommendationsParams,\n} from '@sisense/sdk-ui-preact/ai';\n","/**\n * Public API Surface of @sisense/sdk-ui-angular/ai\n */\n\nexport * from './lib/components';\nexport * from './lib/sdk-ai.module';\nexport * from './lib/sdk-ui-core-exports';\nexport * from './lib/services';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["ChatbotPreact","i2.AiService","GetNlgInsightsPreact"],"mappings":";;;;;;;;;AAKA;;;;;AAKG;AACI,MAAM,wBAAwB,GAAG,CACtC,SAAoB,KAC8B;AAClD,IAAA,MAAM,aAAa,GAAG,IAAI,YAAY,EAAgC,CAAC;IAEvE,SAAS;AACN,SAAA,MAAM,EAAE;SACR,IAAI,CAAC,CAAC,GAAG,KACR,aAAa,CAAC,QAAQ,CAAC;AACrB,QAAA,OAAO,EAAE;YACP,GAAG;AACJ,SAAA;AACF,KAAA,CAAC,CACH;SACA,KAAK,CAAC,CAAC,KAAK,KACX,aAAa,CAAC,QAAQ,CAAC;QACrB,KAAK;AACN,KAAA,CAAC,CACH,CAAC;IAEJ,OAAO;QACL,aAAa;AACb,QAAA,iBAAiB,EAAE,uBAAuB;KAC3C,CAAC;AACJ,CAAC;;ACnCM,MAAM,MAAM,GAAG,QAAQ,CAAC;AACxB,MAAM,QAAQ,GAAG,CAAA;YACZ,MAAM,CAAA;CACjB,CAAC;AACK,MAAM,MAAM,GAAG;AACpB,IAAA,CAAA;;;AAGI,KAAA,CAAA;CACL;;AC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AA;sBADT,KAAK;gBAON,UAAU,EAAA,CAAA;sBADT,KAAK;gBAON,QAAQ,EAAA,CAAA;sBADP,KAAK;gBAON,OAAO,EAAA,CAAA;sBADN,KAAK;gBAON,SAAS,EAAA,CAAA;sBADR,KAAK;;;AC5GR;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;MAOU,WAAW,CAAA;AACtB,IAAA,WAAA,GAAA;AACE,QAAA,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;KACnC;;yGAHU,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;0GAAX,WAAW,EAAA,YAAA,EAAA,CALP,gBAAgB,EAAE,uBAAuB,CAAA,EAAA,OAAA,EAAA,CAC9C,YAAY,EAAE,WAAW,CAAA,EAAA,OAAA,EAAA,CACzB,gBAAgB,EAAE,uBAAuB,CAAA,EAAA,CAAA,CAAA;0GAGxC,WAAW,EAAA,OAAA,EAAA,CAJZ,YAAY,EAAE,WAAW,CAAA,EAAA,CAAA,CAAA;4FAIxB,WAAW,EAAA,UAAA,EAAA,CAAA;kBANvB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;AACzD,oBAAA,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC;AACpC,oBAAA,OAAO,EAAE,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;AACpD,oBAAA,SAAS,EAAE,EAAE;AACd,iBAAA,CAAA;;;AChDD;;ACAA;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"sisense-sdk-ui-angular-ai.mjs","sources":["../../src/ai/lib/component-wrapper-helpers/context-connectors.ts","../../src/ai/lib/component-wrapper-helpers/template.ts","../../src/ai/lib/services/ai.service.ts","../../src/ai/lib/components/chatbot.component.ts","../../src/ai/lib/components/get-nlg-insights.component.ts","../../src/ai/lib/sdk-ai.module.ts","../../src/ai/lib/sdk-ui-core-exports.ts","../../src/ai/public-api.ts","../../src/ai/sisense-sdk-ui-angular-ai.ts"],"sourcesContent":["import { ContextConnector, DataObserver } from '@sisense/sdk-ui-preact';\nimport { CustomAiContextProvider, CustomAiContextProviderProps } from '@sisense/sdk-ui-preact/ai';\n\nimport { AiService } from '../services/ai.service';\n\n/**\n * Creates AI context connector\n *\n * @param aiService - The AI service\n * @internal\n */\nexport const createAiContextConnector = (\n aiService: AiService,\n): ContextConnector<CustomAiContextProviderProps> => {\n const propsObserver = new DataObserver<CustomAiContextProviderProps>();\n\n aiService\n .getApi()\n .then((api) =>\n propsObserver.setValue({\n context: {\n api,\n },\n }),\n )\n .catch((error) =>\n propsObserver.setValue({\n error,\n }),\n );\n\n return {\n propsObserver,\n providerComponent: CustomAiContextProvider,\n };\n};\n","export const rootId = 'preact';\nexport const template = `\n <div #${rootId} class=\"csdk-full-size-container\"></div>\n`;\nexport const styles = [\n `.csdk-full-size-container {\n width: 100%;\n height: 100%;\n }`,\n];\n","import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { SisenseContextService, TrackableService, WidgetProps } from '@sisense/sdk-ui-angular';\nimport {\n AiContextProviderProps,\n ChatRestApi,\n DEFAULT_RECOMMENDATIONS_COUNT,\n GetNlgInsightsResponse,\n GetNlqResultParams,\n GetQueryRecommendationsParams,\n prepareGetNlgInsightsPayload,\n prepareGetNlqResultPayload,\n QueryRecommendation as QueryRecommendationPreact,\n UseGetNlgInsightsParams,\n widgetComposer,\n} from '@sisense/sdk-ui-preact/ai';\n\nexport interface AiContextConfig extends Omit<AiContextProviderProps, 'children'> {}\nexport interface GetNlgInsightsParams extends Omit<UseGetNlgInsightsParams, 'enabled'> {}\n\n/**\n * {@inheritDoc @sisense/sdk-ui!QueryRecommendation}\n */\nexport interface QueryRecommendation extends Omit<QueryRecommendationPreact, 'widgetProps'> {\n /**\n * {@inheritDoc @sisense/sdk-ui!QueryRecommendation.widgetProps}\n */\n widgetProps?: WidgetProps;\n}\n\n/**\n * Token used to inject {@link AiContextConfig} into your application.\n *\n * @example\n * Example of importing {@link SdkAiModule} and injecting {@link AiContextConfig} into your application,\n * along with importing dependency {@link SdkUiModule} and injecting {@link SisenseContextConfig} to connect to a Sisense instance:\n *\n * ```ts\n * import { SdkUiModule, SisenseContextConfig } from '@sisense/sdk-ui-angular';\n * import { SdkAiModule, AI_CONTEXT_CONFIG_TOKEN, AiContextConfig } from '@sisense/sdk-ui-angular/ai';\n *\n * const AI_CONTEXT_CONFIG: AiContextConfig = {\n * volatile: true,\n * };\n * const SISENSE_CONTEXT_CONFIG: SisenseContextConfig = {\n * url: \"<instance url>\", // replace with the URL of your Sisense instance\n * token: \"<api token>\", // replace with the API token of your user account\n * defaultDataSource: DM.DataSource,\n * };\n *\n * @NgModule({\n * imports: [\n * BrowserModule,\n * SdkUiModule,\n * SdkAiModule,\n * ],\n * declarations: [AppComponent],\n * providers: [\n * { provide: AI_CONTEXT_CONFIG_TOKEN, useValue: AI_CONTEXT_CONFIG },\n * { provide: SISENSE_CONTEXT_CONFIG_TOKEN, useValue: SISENSE_CONTEXT_CONFIG },\n * ],\n * bootstrap: [AppComponent],\n * })\n * ```\n * @group Generative AI\n */\nexport const AI_CONTEXT_CONFIG_TOKEN = new InjectionToken<AiContextConfig>('AI Context Config');\n\n/**\n * Service for working with Sisense Fusion Generative AI.\n *\n * @group Generative AI\n */\n@Injectable({\n providedIn: 'root',\n})\n@TrackableService<AiService>(['getNlgInsights', 'getQueryRecommendations'])\nexport class AiService {\n constructor(\n private sisenseContextService: SisenseContextService,\n @Optional() @Inject(AI_CONTEXT_CONFIG_TOKEN) private aiContextConfig?: AiContextConfig,\n ) {}\n\n /** @internal */\n getApi(): Promise<ChatRestApi> {\n return this.sisenseContextService\n .getApp()\n .then((app) => new ChatRestApi(app.httpClient, this.aiContextConfig?.volatile));\n }\n\n /**\n * Fetches an analysis of the provided query using natural language generation (NLG).\n * Specifying NLG parameters is similar to providing parameters to the {@link QueryService.executeQuery} service method, using dimensions, measures, and filters.\n *\n * @param params - Parameters for getting NLG insights\n * @returns NLG insights text summary\n */\n async getNlgInsights(params: GetNlgInsightsParams): Promise<string | undefined> {\n const api = await this.getApi();\n const payload = prepareGetNlgInsightsPayload(params);\n return api.ai\n .getNlgInsights(payload)\n .then((response?: GetNlgInsightsResponse) => response?.data?.answer);\n }\n\n /**\n * Fetches recommended questions for a data model or perspective.\n *\n * @param params - Parameters for recommendations\n * @returns An array of objects, each containing recommended question text and its corresponding `widgetProps`\n * @beta\n */\n async getQueryRecommendations(\n params: GetQueryRecommendationsParams,\n ): Promise<QueryRecommendation[]> {\n const api = await this.getApi();\n const { contextTitle, count, enableAxisTitlesInWidgetProps, customPrompt } = params;\n const recCount = count ?? DEFAULT_RECOMMENDATIONS_COUNT;\n\n const rawRecommendations =\n (await api.ai.getQueryRecommendations(contextTitle, {\n numOfRecommendations: recCount,\n ...(customPrompt ? { userPrompt: customPrompt } : undefined),\n })) || [];\n\n return rawRecommendations.map(\n (recommendation: QueryRecommendationPreact) =>\n ({\n ...recommendation,\n widgetProps: recommendation.jaql\n ? widgetComposer.toWidgetProps(recommendation, {\n useCustomizedStyleOptions: enableAxisTitlesInWidgetProps,\n })\n : undefined,\n } as QueryRecommendation),\n );\n }\n\n /**\n * Executes a natural language query (NLQ) against a data model or perspective\n *\n * @param params - NLQ query parameters\n * @returns The result as WidgetProps\n * @beta\n */\n async getNlqResult(params: GetNlqResultParams): Promise<WidgetProps | undefined> {\n const { contextTitle, request } = prepareGetNlqResultPayload(params);\n const api = await this.getApi();\n\n const data = await api?.ai.getNlqResult(contextTitle, request);\n\n return data\n ? (widgetComposer.toWidgetProps(data, {\n useCustomizedStyleOptions: params.enableAxisTitlesInWidgetProps || false,\n }) as WidgetProps)\n : undefined;\n }\n}\n","import {\n AfterViewInit,\n Component,\n ElementRef,\n Input,\n OnChanges,\n OnDestroy,\n ViewChild,\n} from '@angular/core';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n createSisenseContextConnector,\n createThemeContextConnector,\n SisenseContextService,\n ThemeService,\n} from '@sisense/sdk-ui-angular';\nimport { ComponentAdapter } from '@sisense/sdk-ui-preact';\nimport {\n Chatbot as ChatbotPreact,\n type ChatbotProps as ChatbotPropsPreact,\n} from '@sisense/sdk-ui-preact/ai';\n\nimport { createAiContextConnector, rootId, styles, template } from '../component-wrapper-helpers';\nimport { AiService } from '../services/ai.service';\n\n/**\n * Props of the {@link ChatbotComponent}.\n */\nexport interface ChatbotProps extends ChatbotPropsPreact {}\n\n/**\n * An Angular component that renders a chatbot with data topic selection.\n *\n * @example\n * An example of using the `ChatbotComponent`:\n *\n * ```html\n<!--Component HTML template in example.component.html-->\n<csdk-chatbot\n [width]=\"chatbot.width\"\n [height]=\"chatbot.height\"\n [config]=\"chatbot.config\"\n/>\n * ```\n *\n * ```ts\n// Component behavior in example.component.ts\nimport { Component } from '@angular/core';\n\n@Component({\n selector: 'example',\n templateUrl: './example.component.html',\n styleUrls: ['./example.component.scss'],\n})\nexport class ExampleComponent {\n chatbot = {\n width: '500px',\n height: '700px',\n config: {\n numOfRecommendations: 5,\n },\n };\n}\n * ```\n *\n * <img src=\"media://angular-chatbot-example.png\" width=\"500px\" />\n * @group Generative AI\n */\n@Component({\n selector: 'csdk-chatbot',\n template,\n styles,\n})\nexport class ChatbotComponent implements AfterViewInit, OnChanges, OnDestroy {\n /**\n * @internal\n */\n @ViewChild(rootId)\n preactRef!: ElementRef<HTMLDivElement>;\n\n /**\n * {@inheritDoc @sisense/sdk-ui!ChatbotProps.width}\n */\n @Input()\n width: ChatbotProps['width'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!ChatbotProps.height}\n */\n @Input()\n height: ChatbotProps['height'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!ChatbotProps.config}\n */\n @Input()\n config: ChatbotProps['config'];\n\n private componentAdapter: ComponentAdapter<typeof ChatbotPreact>;\n\n /**\n * Constructor for the `ChatbotComponent`.\n *\n * @param sisenseContextService - Sisense context service\n * @param themeService - Theme service\n * @param aiService - AI service\n */\n constructor(\n /**\n * Sisense context service\n *\n * @category Constructor\n */\n public sisenseContextService: SisenseContextService,\n /**\n * Theme service\n *\n * @category Constructor\n */\n public themeService: ThemeService,\n /**\n * AI service\n *\n * @category Constructor\n */\n public aiService: AiService,\n ) {\n this.componentAdapter = new ComponentAdapter(ChatbotPreact, [\n createSisenseContextConnector(this.sisenseContextService),\n createThemeContextConnector(this.themeService),\n createAiContextConnector(this.aiService),\n ]);\n }\n\n /**\n * @internal\n */\n ngAfterViewInit() {\n this.componentAdapter.render(this.preactRef.nativeElement, this.getPreactComponentProps());\n }\n\n /**\n * @internal\n */\n ngOnChanges() {\n if (this.preactRef) {\n this.componentAdapter.render(this.preactRef.nativeElement, this.getPreactComponentProps());\n }\n }\n\n private getPreactComponentProps(): ChatbotPropsPreact {\n return {\n width: this.width,\n height: this.height,\n config: this.config,\n };\n }\n\n /**\n * @internal\n */\n ngOnDestroy() {\n this.componentAdapter.destroy();\n }\n}\n","import {\n AfterViewInit,\n Component,\n ElementRef,\n Input,\n OnChanges,\n OnDestroy,\n ViewChild,\n} from '@angular/core';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n createSisenseContextConnector,\n createThemeContextConnector,\n SisenseContextService,\n ThemeService,\n} from '@sisense/sdk-ui-angular';\nimport { ComponentAdapter } from '@sisense/sdk-ui-preact';\nimport {\n GetNlgInsights as GetNlgInsightsPreact,\n type GetNlgInsightsProps as GetNlgInsightsPropsPreact,\n} from '@sisense/sdk-ui-preact/ai';\n\nimport { createAiContextConnector, rootId, styles, template } from '../component-wrapper-helpers';\nimport { AiService } from '../services/ai.service';\n\n/**\n * Props of the {@link GetNlgInsightsComponent}.\n */\nexport interface GetNlgInsightsProps extends GetNlgInsightsPropsPreact {}\n\n/**\n * An Angular component that fetches and displays a collapsible analysis of the provided query using natural language generation (NLG).\n * Specifying NLG parameters is similar to providing parameters to the {@link QueryService.executeQuery} service method, using dimensions, measures, and filters.\n *\n * @example\n * An example of using the `GetNlgInsightsComponent`:\n *\n * ```html\n<!--Component HTML template in example.component.html-->\n<csdk-get-nlg-insights\n [dataSource]=\"nlgParams.dataSource\"\n [dimensions]=\"nlgParams.dimensions\"\n [measures]=\"nlgParams.measures\"\n/>\n * ```\n *\n * ```ts\n// Component behavior in example.component.ts\nimport { Component } from '@angular/core';\nimport { measureFactory } from '@sisense/sdk-data';\nimport * as DM from '../../assets/sample-healthcare-model';\n\n@Component({\n selector: 'example',\n templateUrl: './example.component.html',\n styleUrls: ['./example.component.scss'],\n})\nexport class ExampleComponent {\n nlgParams = {\n dataSource: DM.DataSource.title,\n dimensions: [DM.Divisions.Divison_name],\n measures: [measureFactory.sum(DM.Admissions.Cost_of_admission)],\n };\n}\n * ```\n *\n * <img src=\"media://angular-get-nlg-insights-example.png\" width=\"700px\" />\n * @group Generative AI\n */\n@Component({\n selector: 'csdk-get-nlg-insights',\n template,\n styles,\n})\nexport class GetNlgInsightsComponent implements AfterViewInit, OnChanges, OnDestroy {\n /**\n * @internal\n */\n @ViewChild(rootId)\n preactRef!: ElementRef<HTMLDivElement>;\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.dataSource}\n */\n @Input()\n dataSource!: GetNlgInsightsProps['dataSource'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.dimensions}\n */\n @Input()\n dimensions: GetNlgInsightsProps['dimensions'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.measures}\n */\n @Input()\n measures: GetNlgInsightsProps['measures'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.filters}\n */\n @Input()\n filters: GetNlgInsightsProps['filters'];\n\n /**\n * {@inheritDoc @sisense/sdk-ui!GetNlgInsightsProps.verbosity}\n */\n @Input()\n verbosity: GetNlgInsightsProps['verbosity'];\n\n private componentAdapter: ComponentAdapter<typeof GetNlgInsightsPreact>;\n\n /**\n * Constructor for the `GetNlgInsightsProps`.\n *\n * @param sisenseContextService - Sisense context service\n * @param themeService - Theme service\n * @param aiService - AI service\n */\n constructor(\n /**\n * Sisense context service\n *\n * @category Constructor\n */\n public sisenseContextService: SisenseContextService,\n /**\n * Theme service\n *\n * @category Constructor\n */\n public themeService: ThemeService,\n /**\n * AI service\n *\n * @category Constructor\n */\n public aiService: AiService,\n ) {\n this.componentAdapter = new ComponentAdapter(GetNlgInsightsPreact, [\n createSisenseContextConnector(this.sisenseContextService),\n createThemeContextConnector(this.themeService),\n createAiContextConnector(this.aiService),\n ]);\n }\n\n /**\n * @internal\n */\n ngAfterViewInit() {\n this.componentAdapter.render(this.preactRef.nativeElement, this.getPreactComponentProps());\n }\n\n /**\n * @internal\n */\n ngOnChanges() {\n if (this.preactRef) {\n this.componentAdapter.render(this.preactRef.nativeElement, this.getPreactComponentProps());\n }\n }\n\n private getPreactComponentProps(): GetNlgInsightsPropsPreact {\n return {\n dataSource: this.dataSource,\n dimensions: this.dimensions,\n measures: this.measures,\n filters: this.filters,\n verbosity: this.verbosity,\n };\n }\n\n /**\n * @internal\n */\n ngOnDestroy() {\n this.componentAdapter.destroy();\n }\n}\n","/* eslint-disable import/no-extraneous-dependencies */\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { SdkUiModule } from '@sisense/sdk-ui-angular';\n\nimport { ChatbotComponent, GetNlgInsightsComponent } from './components';\n\n/**\n * SDK AI Module, which is a container for generative AI components and services.\n *\n * @example\n * Example of importing {@link SdkAiModule} and injecting {@link AiContextConfig} into your application,\n * along with importing dependency {@link SdkUiModule} and injecting {@link SisenseContextConfig} to connect to a Sisense instance:\n *\n * ```ts\n * import { SdkUiModule, SisenseContextConfig } from '@sisense/sdk-ui-angular';\n * import { SdkAiModule, AI_CONTEXT_CONFIG_TOKEN, AiContextConfig } from '@sisense/sdk-ui-angular/ai';\n *\n * const AI_CONTEXT_CONFIG: AiContextConfig = {\n * volatile: true,\n * };\n * const SISENSE_CONTEXT_CONFIG: SisenseContextConfig = {\n * url: \"<instance url>\", // replace with the URL of your Sisense instance\n * token: \"<api token>\", // replace with the API token of your user account\n * defaultDataSource: DM.DataSource,\n * };\n *\n * @NgModule({\n * imports: [\n * BrowserModule,\n * SdkUiModule,\n * SdkAiModule,\n * ],\n * declarations: [AppComponent],\n * providers: [\n * { provide: AI_CONTEXT_CONFIG_TOKEN, useValue: AI_CONTEXT_CONFIG },\n * { provide: SISENSE_CONTEXT_CONFIG_TOKEN, useValue: SISENSE_CONTEXT_CONFIG },\n * ],\n * bootstrap: [AppComponent],\n * })\n * ```\n * @group Generative AI\n */\n@NgModule({\n declarations: [ChatbotComponent, GetNlgInsightsComponent],\n imports: [CommonModule, SdkUiModule],\n exports: [ChatbotComponent, GetNlgInsightsComponent],\n providers: [],\n})\nexport class SdkAiModule {\n constructor() {\n console.log('SdkAiModule loaded');\n }\n}\n","// This file re-exports common types/utils from @sisense/sdk-ui-preact/ai\n\n// Re-exports types from @sisense/sdk-ui-preact/ai\nexport type {\n ChatConfig,\n GetNlqResultParams,\n GetQueryRecommendationsParams,\n} from '@sisense/sdk-ui-preact/ai';\n","/**\n * Public API Surface of @sisense/sdk-ui-angular/ai\n */\n\nexport * from './lib/components';\nexport * from './lib/sdk-ai.module';\nexport * from './lib/sdk-ui-core-exports';\nexport * from './lib/services';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["ChatbotPreact","i2.AiService","GetNlgInsightsPreact"],"mappings":";;;;;;;;;AAKA;;;;;AAKG;AACI,MAAM,wBAAwB,GAAG,CACtC,SAAoB,KAC8B;AAClD,IAAA,MAAM,aAAa,GAAG,IAAI,YAAY,EAAgC,CAAC;IAEvE,SAAS;AACN,SAAA,MAAM,EAAE;SACR,IAAI,CAAC,CAAC,GAAG,KACR,aAAa,CAAC,QAAQ,C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AgB,EAAE,uBAAuB,CAAC;AACzD,oBAAA,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC;AACpC,oBAAA,OAAO,EAAE,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;AACpD,oBAAA,SAAS,EAAE,EAAE;AACd,iBAAA,CAAA;;;AChDD;;ACAA;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Inject, createComponent, NgModule, Optional, EventEmitter, Component, ViewChild, Input, Output } from '@angular/core';
2
+ import { InjectionToken, Injectable, Optional, Inject, createComponent, NgModule, EventEmitter, Component, ViewChild, Input, Output } from '@angular/core';
3
3
  import { DataObserver, CustomThemeProvider, CustomSisenseContextProvider, CustomWidgetsProviderAdapter, createClientApplication, createWrapperElement, getDashboardModel, getDashboardModels, HookAdapter, useComposedDashboardInternal, createHookApiFacade, useGetFilterMembers, getHierarchyModels, executeQuery, executeQueryByWidgetId, executePivotQuery, useExecuteCsvQueryInternal, useExecuteCustomWidgetQueryInternal, getWidgetModel, getDefaultThemeSettings, getThemeSettingsByOid, ComponentAdapter, Chart, PivotTable, Table, ContextMenu, Dashboard, DashboardById, DrilldownBreadcrumbs, CriteriaFilterTile, DateRangeFilterTile, FilterTile, FiltersPanel, MemberFilterTile, RelativeDateFilterTile, ChartWidget, DrilldownWidget, createWrapperElementHandler, createComponentRenderer, PivotTableWidget, TableWidget, Widget, WidgetById, dashboardModelTranslator as dashboardModelTranslator$1, dashboardHelpers as dashboardHelpers$1, widgetModelTranslator as widgetModelTranslator$1 } from '@sisense/sdk-ui-preact';
4
4
  export { boxWhiskerProcessResult, extractDimensionsAndMeasures } from '@sisense/sdk-ui-preact';
5
+ import { ReplaySubject, firstValueFrom, concat, of, BehaviorSubject, skip } from 'rxjs';
5
6
  import { __decorate } from 'tslib';
6
- import { BehaviorSubject } from 'rxjs';
7
7
  import merge from 'ts-deepmerge';
8
8
  import { trackProductEvent } from '@sisense/sdk-tracking';
9
9
  import { getFilterListAndRelationsJaql } from '@sisense/sdk-data';
@@ -38,16 +38,10 @@ const createThemeContextConnector = (themeService) => {
38
38
  providerComponent: CustomThemeProvider,
39
39
  };
40
40
  };
41
- /**
42
- * Creates Sisense context connector
43
- *
44
- * @param sisenseContextService - The Sisense context service
45
- * @internal
46
- */
47
- const createSisenseContextConnector = (sisenseContextService) => {
48
- const { showRuntimeErrors, appConfig } = sisenseContextService.getConfig();
49
- const defaultSisenseContext = {
50
- isInitialized: true,
41
+ function getBaseSisenseContext(sisenseContextService) {
42
+ const { showRuntimeErrors, appConfig } = sisenseContextService.getConfig() ?? {};
43
+ return {
44
+ isInitialized: sisenseContextService.isInitialized,
51
45
  tracking: {
52
46
  // if tracking is configured in appConfig, use it
53
47
  // if none is set, default to true
@@ -58,20 +52,38 @@ const createSisenseContextConnector = (sisenseContextService) => {
58
52
  showErrorBox: showRuntimeErrors ?? true,
59
53
  },
60
54
  };
55
+ }
56
+ /**
57
+ * Creates Sisense context connector
58
+ *
59
+ * @param sisenseContextService - The Sisense context service
60
+ * @internal
61
+ */
62
+ const createSisenseContextConnector = (sisenseContextService) => {
61
63
  const propsObserver = new DataObserver({
62
- context: defaultSisenseContext,
64
+ context: getBaseSisenseContext(sisenseContextService),
63
65
  });
64
- sisenseContextService
65
- .getApp()
66
- .then((app) => propsObserver.setValue({
67
- context: {
68
- ...defaultSisenseContext,
69
- app,
66
+ sisenseContextService.getApp$().subscribe({
67
+ next: ({ app, error }) => {
68
+ if (error) {
69
+ propsObserver.setValue({
70
+ error,
71
+ });
72
+ return;
73
+ }
74
+ propsObserver.setValue({
75
+ context: {
76
+ ...getBaseSisenseContext(sisenseContextService),
77
+ app,
78
+ },
79
+ });
80
+ },
81
+ error: (error) => {
82
+ propsObserver.setValue({
83
+ error,
84
+ });
70
85
  },
71
- }))
72
- .catch((error) => propsObserver.setValue({
73
- error,
74
- }));
86
+ });
75
87
  return {
76
88
  propsObserver,
77
89
  providerComponent: CustomSisenseContextProvider,
@@ -154,28 +166,112 @@ const styles = [
154
166
  */
155
167
  const SISENSE_CONTEXT_CONFIG_TOKEN = new InjectionToken('Props for connecting to Sisense instance');
156
168
  /**
157
- * Service for working with Sisense Fusion context.
169
+ * Service for managing Sisense Fusion context and client application lifecycle.
170
+ *
171
+ * This service provides a centralized way to configure and manage the connection to a Sisense instance within Angular applications.
158
172
  *
159
173
  * @group Contexts
160
174
  */
161
175
  class SisenseContextService {
162
176
  constructor(sisenseContextConfig) {
163
- this.appPromise = createClientApplication(sisenseContextConfig);
164
- const { showRuntimeErrors } = sisenseContextConfig;
165
- this.config = {
166
- ...sisenseContextConfig,
167
- showRuntimeErrors: showRuntimeErrors ?? true,
168
- };
177
+ /**
178
+ * Flag indicating whether the service has been initialized with configuration.
179
+ *
180
+ * @internal
181
+ */
182
+ this.isInitialized = false;
183
+ // The buffer size of 1 ensures only the most recent state is cached.
184
+ this.app$ = new ReplaySubject(1);
185
+ if (sisenseContextConfig) {
186
+ // Auto-configure if config is provided via DI
187
+ void this.setConfig(sisenseContextConfig);
188
+ }
169
189
  }
170
- /** @internal */
171
- getApp() {
172
- return this.appPromise;
190
+ /**
191
+ * Retrieves the initialized Sisense client application.
192
+ *
193
+ * This method provides access to the client application instance.
194
+ * It waits for the latest state from the reactive stream and either returns
195
+ * the application or throws the error if initialization failed.
196
+ *
197
+ * @returns Promise that resolves to the ClientApplication instance
198
+ * @throws {Error} When the service is not initialized or when application creation failed
199
+ *
200
+ * @internal
201
+ */
202
+ async getApp() {
203
+ if (!this.isInitialized) {
204
+ throw new Error('Sisense context is not initialized');
205
+ }
206
+ const { app, error } = await firstValueFrom(this.app$);
207
+ if (error) {
208
+ throw error;
209
+ }
210
+ return app;
173
211
  }
212
+ /**
213
+ * Provides reactive access to the Sisense application state.
214
+ *
215
+ * This method returns an Observable that emits the current application state
216
+ * and all subsequent state changes. It's the preferred way to reactively
217
+ * handle application lifecycle events in Angular components.
218
+ *
219
+ * If the service is not initialized, it immediately emits an error state
220
+ * followed by any future state changes once initialization occurs.
221
+ *
222
+ * @returns Observable stream of AppState changes
223
+ *
224
+ * @internal
225
+ */
226
+ getApp$() {
227
+ if (!this.isInitialized) {
228
+ return concat(of({ error: new Error('Sisense context is not initialized') }), this.app$);
229
+ }
230
+ return this.app$;
231
+ }
232
+ /**
233
+ * Retrieves the current {@link SisenseContextConfig} configuration object.
234
+ *
235
+ * @returns The current configuration object, or undefined if not yet configured
236
+ */
174
237
  getConfig() {
175
238
  return this.config;
176
239
  }
240
+ /**
241
+ * Configures and initializes the Sisense context with the provided settings.
242
+ *
243
+ * This method allows to establish a connection to a Sisense instance.
244
+ * It could be used as runtime alternative to {@link SISENSE_CONTEXT_CONFIG_TOKEN} based configuration.
245
+ *
246
+ * @param config - Configuration object
247
+ * @returns Promise that resolves when configuration is complete (success or failure)
248
+ *
249
+ * @example
250
+ * Basic configuration:
251
+ * ```ts
252
+ * await SisenseContextService.setConfig({
253
+ * url: 'https://your-sisense-instance.com',
254
+ * token: 'your-api-token',
255
+ * defaultDataSource: 'Sample ECommerce'
256
+ * });
257
+ * ```
258
+ */
259
+ async setConfig(config) {
260
+ this.config = {
261
+ ...config,
262
+ showRuntimeErrors: config.showRuntimeErrors ?? true,
263
+ };
264
+ this.isInitialized = true;
265
+ try {
266
+ const app = await createClientApplication(this.config);
267
+ this.app$.next({ app });
268
+ }
269
+ catch (error) {
270
+ this.app$.next({ error: error });
271
+ }
272
+ }
177
273
  }
178
- SisenseContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SisenseContextService, deps: [{ token: SISENSE_CONTEXT_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
274
+ SisenseContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SisenseContextService, deps: [{ token: SISENSE_CONTEXT_CONFIG_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
179
275
  SisenseContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SisenseContextService, providedIn: 'root' });
180
276
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SisenseContextService, decorators: [{
181
277
  type: Injectable,
@@ -183,11 +279,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
183
279
  providedIn: 'root',
184
280
  }]
185
281
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
282
+ type: Optional
283
+ }, {
186
284
  type: Inject,
187
285
  args: [SISENSE_CONTEXT_CONFIG_TOKEN]
188
286
  }] }]; } });
189
287
 
190
- var packageVersion = '2.9.0';
288
+ var packageVersion = '2.10.0';
191
289
 
192
290
  /**
193
291
  * Service for rendering components dynamically.
@@ -847,6 +945,18 @@ let ThemeService = class ThemeService {
847
945
  this.initializationPromise = Promise.resolve();
848
946
  this.themeSettings$ = new BehaviorSubject(getDefaultThemeSettings());
849
947
  this.initializationPromise = this.initThemeSettings(themeConfig?.theme);
948
+ this.sisenseContextService
949
+ .getApp$()
950
+ // Skip current app value
951
+ .pipe(skip(1))
952
+ // Subscribe to new app values
953
+ .subscribe({
954
+ next: ({ app }) => {
955
+ if (app) {
956
+ this.initializationPromise = this.applyThemeSettings(app.settings.serverThemeSettings);
957
+ }
958
+ },
959
+ });
850
960
  }
851
961
  async initThemeSettings(theme) {
852
962
  const app = await this.sisenseContextService.getApp();
@@ -5112,7 +5222,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
5112
5222
  * is used to render a widget created in a Sisense Fusion instance.
5113
5223
  *
5114
5224
  * To learn more about using Sisense Fusion Widgets in Compose SDK, see
5115
- * [Sisense Fusion Widgets](https://sisense.dev/guides/sdk/guides/charts/guide-fusion-widgets.html).
5225
+ * [Sisense Fusion Widgets](https://developer.sisense.com/guides/sdk/guides/charts/guide-fusion-widgets.html).
5116
5226
  *
5117
5227
  * @example
5118
5228
  * ```html