@sisense/sdk-ai-core 0.15.1 → 0.60.1

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 (169) hide show
  1. package/dist/__vite-browser-external-l0sNRNKZ.js +1 -0
  2. package/dist/constants.d.ts +36 -0
  3. package/dist/engines/atomic-handle-args.d.ts +45 -0
  4. package/dist/engines/atomic-tool-requirements.d.ts +38 -0
  5. package/dist/engines/author-pulse/actions/create.d.ts +9 -0
  6. package/dist/engines/author-pulse/actions/define.d.ts +9 -0
  7. package/dist/engines/author-pulse/actions/load-existing.d.ts +9 -0
  8. package/dist/engines/author-pulse/actions/redefine.d.ts +9 -0
  9. package/dist/engines/author-pulse/actions/set-receive-notifications.d.ts +8 -0
  10. package/dist/engines/author-pulse/actions/update-spec.d.ts +11 -0
  11. package/dist/engines/author-pulse/actions/update-workflow.d.ts +9 -0
  12. package/dist/engines/author-pulse/atomic-adapter.d.ts +10 -0
  13. package/dist/engines/author-pulse/atomic-tools.d.ts +362 -0
  14. package/dist/engines/author-pulse/author-pulse-engine.d.ts +21 -0
  15. package/dist/engines/author-pulse/index.d.ts +9 -0
  16. package/dist/engines/author-pulse/shared/adjustment-error.d.ts +15 -0
  17. package/dist/engines/author-pulse/shared/assemble-create-workflow-payload.d.ts +36 -0
  18. package/dist/engines/author-pulse/shared/assert-agentic-workflow.d.ts +12 -0
  19. package/dist/engines/author-pulse/shared/compile-query-from-prompt.d.ts +95 -0
  20. package/dist/engines/author-pulse/shared/decision-spec-validation.d.ts +84 -0
  21. package/dist/engines/author-pulse/shared/notification-urls.d.ts +52 -0
  22. package/dist/engines/author-pulse/shared/pulse-knowledge.d.ts +36 -0
  23. package/dist/engines/author-pulse/shared/pulse-signature.d.ts +39 -0
  24. package/dist/engines/author-pulse/shared/resolve-frequency.d.ts +18 -0
  25. package/dist/engines/author-pulse/shared/staging.d.ts +65 -0
  26. package/dist/engines/author-pulse/shared/workflow-ownership.d.ts +14 -0
  27. package/dist/engines/author-pulse/types.d.ts +1385 -0
  28. package/dist/engines/build-chart/atomic-adapter.d.ts +20 -0
  29. package/dist/engines/build-chart/atomic-tools.d.ts +214 -0
  30. package/dist/engines/build-chart/build-chart-engine.d.ts +1 -1
  31. package/dist/engines/build-chart/chart-tool-name.d.ts +3 -0
  32. package/dist/engines/build-chart/create-chart/assemble-chart-widget.d.ts +1 -1
  33. package/dist/engines/build-chart/create-chart/chart-json-axes-mapping.d.ts +1 -1
  34. package/dist/engines/build-chart/create-chart/create-chart.d.ts +1 -1
  35. package/dist/engines/build-chart/create-chart/derive-chart-title.d.ts +7 -0
  36. package/dist/engines/build-chart/create-chart/generate-chart-recommendations.d.ts +2 -2
  37. package/dist/engines/build-chart/create-chart/resolve-chart-query.d.ts +4 -0
  38. package/dist/engines/build-chart/shared/normalize-cartesian-axes-mapping.d.ts +1 -1
  39. package/dist/engines/build-chart/shared/sync-chart-state-measure-flags.d.ts +3 -0
  40. package/dist/engines/build-chart/types.d.ts +49 -19
  41. package/dist/engines/build-chart/update-chart/apply-prior-chart-style.d.ts +8 -5
  42. package/dist/engines/build-chart/update-chart/chart-options-schemas.d.ts +18 -18
  43. package/dist/engines/build-chart/update-chart/schemas.d.ts +2 -2
  44. package/dist/engines/build-chart/update-chart/update-chart-data-options.d.ts +7 -2
  45. package/dist/engines/build-chart/update-chart/update-chart-query.d.ts +1 -1
  46. package/dist/engines/build-chart/update-chart/update-chart-style-options.d.ts +7 -2
  47. package/dist/engines/build-chart/update-chart/update-chart-title.d.ts +1 -1
  48. package/dist/engines/build-chart/update-chart/update-chart-type.d.ts +7 -2
  49. package/dist/engines/build-csv-model/build-csv-model-engine.d.ts +1 -1
  50. package/dist/engines/build-csv-model/types.d.ts +1 -1
  51. package/dist/engines/build-dashboard/add-dashboard-narration.d.ts +50 -0
  52. package/dist/engines/build-dashboard/add-dashboard-widgets.d.ts +1 -1
  53. package/dist/engines/build-dashboard/atomic-adapter.d.ts +21 -0
  54. package/dist/engines/build-dashboard/atomic-tools.d.ts +231 -0
  55. package/dist/engines/build-dashboard/build-dashboard-engine.d.ts +1 -1
  56. package/dist/engines/build-dashboard/build-dashboard-service.d.ts +2 -1
  57. package/dist/engines/build-dashboard/create-dashboard.d.ts +3 -4
  58. package/dist/engines/build-dashboard/dashboard-filters/manipulate-dashboard-filters.d.ts +2 -1
  59. package/dist/engines/build-dashboard/dashboard-filters/translate-filters.d.ts +17 -1
  60. package/dist/engines/build-dashboard/index.d.ts +2 -0
  61. package/dist/engines/build-dashboard/layout/place-widget.d.ts +53 -0
  62. package/dist/engines/build-dashboard/load-existing-fusion-dashboard.d.ts +1 -1
  63. package/dist/engines/build-dashboard/remove-dashboard-widgets.d.ts +4 -0
  64. package/dist/engines/build-dashboard/resolve-chart-widgets.d.ts +16 -0
  65. package/dist/engines/build-dashboard/types.d.ts +180 -18
  66. package/dist/engines/build-data-model/build-data-model-engine.d.ts +1 -1
  67. package/dist/engines/build-data-model/types.d.ts +1 -1
  68. package/dist/engines/build-query/build-query-engine.d.ts +33 -5
  69. package/dist/engines/build-query/index.d.ts +1 -1
  70. package/dist/engines/build-query/types.d.ts +216 -3
  71. package/dist/engines/build-status/build-status-engine.d.ts +8 -0
  72. package/dist/engines/build-status/builds-client.d.ts +44 -0
  73. package/dist/engines/build-status/index.d.ts +2 -0
  74. package/dist/engines/build-status/types.d.ts +177 -0
  75. package/dist/engines/datamodel-graph/data-model-map-text.d.ts +28 -0
  76. package/dist/engines/datamodel-graph/datamodel-graph-engine.d.ts +31 -0
  77. package/dist/engines/datamodel-graph/index.d.ts +4 -0
  78. package/dist/engines/datamodel-graph/summaries.d.ts +97 -0
  79. package/dist/engines/datamodel-graph/test-fixtures.d.ts +42 -0
  80. package/dist/engines/datamodel-graph/types.d.ts +190 -0
  81. package/dist/engines/evaluate-pulse/evaluate-pulse-engine.d.ts +10 -0
  82. package/dist/engines/evaluate-pulse/index.d.ts +2 -0
  83. package/dist/engines/evaluate-pulse/types.d.ts +85 -0
  84. package/dist/engines/get-dashboard-narration/get-dashboard-narration-engine.d.ts +23 -0
  85. package/dist/engines/get-dashboard-narration/index.d.ts +2 -0
  86. package/dist/engines/get-dashboard-narration/types.d.ts +64 -0
  87. package/dist/engines/get-dashboards/get-dashboards-engine.d.ts +1 -1
  88. package/dist/engines/get-dashboards/types.d.ts +16 -4
  89. package/dist/engines/get-data-preview/get-data-preview-engine.d.ts +18 -0
  90. package/dist/engines/get-data-preview/index.d.ts +2 -0
  91. package/dist/engines/get-data-preview/types.d.ts +35 -0
  92. package/dist/engines/get-data-source-fields/get-data-source-fields-engine.d.ts +12 -6
  93. package/dist/engines/get-data-source-fields/index.d.ts +1 -0
  94. package/dist/engines/get-data-source-fields/model-relations.d.ts +38 -0
  95. package/dist/engines/get-data-source-fields/types.d.ts +53 -3
  96. package/dist/engines/get-data-sources/get-data-sources-engine.d.ts +1 -1
  97. package/dist/engines/get-data-sources/types.d.ts +2 -2
  98. package/dist/engines/index.d.ts +17 -0
  99. package/dist/engines/inspect-pulse/atomic-adapter.d.ts +8 -0
  100. package/dist/engines/inspect-pulse/atomic-tools.d.ts +60 -0
  101. package/dist/engines/inspect-pulse/index.d.ts +4 -0
  102. package/dist/engines/inspect-pulse/inspect-pulse-engine.d.ts +7 -0
  103. package/dist/engines/inspect-pulse/types.d.ts +209 -0
  104. package/dist/engines/manage-perspectives/manage-perspectives-engine.d.ts +5 -1
  105. package/dist/engines/manage-perspectives/types.d.ts +13 -8
  106. package/dist/engines/pulse-tool-words.d.ts +62 -0
  107. package/dist/engines/recommend-queries/recommend-queries-engine.d.ts +1 -1
  108. package/dist/engines/recommend-queries/types.d.ts +1 -1
  109. package/dist/engines/shared/existing-answer-cascade.d.ts +52 -0
  110. package/dist/engines/shared/get-filters-json-for-llm-summary.d.ts +2 -2
  111. package/dist/engines/shared/nlq-query-helpers.d.ts +2 -2
  112. package/dist/engines/shared/project-dashboard-json.d.ts +151 -0
  113. package/dist/engines/shared/project-widget-json.d.ts +67 -0
  114. package/dist/engines/shared/projection-helpers.d.ts +19 -0
  115. package/dist/engines/shared/redact-data-models-closed-to-ai.d.ts +55 -0
  116. package/dist/engines/shared/redact-hidden-columns-from-ai.d.ts +55 -0
  117. package/dist/index.d.ts +21 -0
  118. package/dist/index.js +56879 -27530
  119. package/dist/services/ai-access/ai-access-service.d.ts +68 -0
  120. package/dist/services/dashboards/dashboards-service.d.ts +9 -3
  121. package/dist/services/dashboards/fusion-dashboards-service.d.ts +34 -4
  122. package/dist/services/data-sources/data-sources-service.d.ts +149 -5
  123. package/dist/services/data-sources/find-data-source-by-title.d.ts +8 -0
  124. package/dist/services/datamodel-graph/datamodel-graph-service.d.ts +457 -0
  125. package/dist/services/existing-answer/existing-answer-query-service.d.ts +31 -0
  126. package/dist/services/formulas/formulas-service.d.ts +19 -0
  127. package/dist/services/hide-from-ai/hide-from-ai.d.ts +31 -0
  128. package/dist/services/knowledge-graph/knowledge-graph-service.d.ts +96 -0
  129. package/dist/services/llm/llm-consumption-service.d.ts +7 -2
  130. package/dist/services/llm/llm-models-service.d.ts +10 -2
  131. package/dist/services/llm/llm-settings-service.d.ts +73 -0
  132. package/dist/services/nlq/nlq-preview-dataset.d.ts +34 -0
  133. package/dist/services/nlq/nlq-service.d.ts +138 -3
  134. package/dist/services/pulse/evaluate-pulse-client.d.ts +78 -0
  135. package/dist/services/pulse/pulse-alerts-service.d.ts +264 -0
  136. package/dist/services/pulse/pulse-events-service.d.ts +217 -0
  137. package/dist/services/semantic-search/semantic-search-service.d.ts +43 -0
  138. package/dist/services/tool-store/tool-store-service.d.ts +32 -0
  139. package/dist/services/users-groups-service.d.ts +37 -0
  140. package/dist/skills/index.d.ts +127 -0
  141. package/dist/tool-availability/controlled-tools.d.ts +56 -0
  142. package/dist/tool-availability/index.d.ts +4 -0
  143. package/dist/tool-availability/offer-tools.d.ts +44 -0
  144. package/dist/tool-availability/resolve-tool-availability.d.ts +68 -0
  145. package/dist/tool-availability/withdrawn-text.d.ts +33 -0
  146. package/dist/tool-catalog/catalog.d.ts +387 -0
  147. package/dist/tool-catalog/index.d.ts +3 -0
  148. package/dist/tool-catalog/manifest.d.ts +5 -0
  149. package/dist/tool-catalog/prototype-lookup.d.ts +10 -0
  150. package/dist/tool-catalog/types.d.ts +67 -0
  151. package/dist/tools.manifest.json +826 -0
  152. package/dist/utils/chat-stream-errors.d.ts +42 -0
  153. package/dist/utils/create-custom-fetch.d.ts +19 -1
  154. package/dist/utils/create-stream-completion.d.ts +84 -6
  155. package/dist/utils/create-structured-completion.d.ts +29 -2
  156. package/dist/utils/create-tools-completion.d.ts +9 -0
  157. package/dist/utils/deferred-tools.d.ts +45 -0
  158. package/dist/utils/dev-debug.d.ts +5 -0
  159. package/dist/utils/generate-suggestions.d.ts +32 -0
  160. package/dist/utils/http-client.d.ts +3 -1
  161. package/dist/utils/llm-call-observer.d.ts +83 -0
  162. package/dist/utils/llm-client.d.ts +11 -1
  163. package/dist/utils/llm-model-override.d.ts +41 -0
  164. package/dist/utils/quoted-text.d.ts +6 -0
  165. package/dist/utils/server-error-body.d.ts +23 -0
  166. package/dist/utils/text-tokens.d.ts +35 -0
  167. package/dist/utils/user-action-tracking.d.ts +48 -5
  168. package/dist/utils/zod-utils.d.ts +9 -1
  169. package/package.json +28 -18
@@ -0,0 +1,457 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ export declare const DATAMODEL_GRAPH_SEARCH_DEFAULT_LIMIT = 10;
3
+ export interface DmAnalysisHint {
4
+ kind: string;
5
+ text: string;
6
+ columns?: string[];
7
+ }
8
+ export type DmVerifiedMatchKind = 'same' | 'similar';
9
+ export interface DmQuerySummary {
10
+ measures: {
11
+ title: string;
12
+ agg?: string;
13
+ }[];
14
+ breakdowns: {
15
+ column: string;
16
+ level?: string;
17
+ }[];
18
+ filters: {
19
+ column: string;
20
+ kind: string;
21
+ }[];
22
+ }
23
+ /** A question the route matched to a verified answer (parsed from `verifiedMatches`). */
24
+ export interface DmVerifiedMatch {
25
+ id: string;
26
+ question: string;
27
+ datamodel_title: string;
28
+ area_id: string | null;
29
+ score: number;
30
+ match: DmVerifiedMatchKind;
31
+ query_summary?: DmQuerySummary;
32
+ }
33
+ /** `VerifiedAnswerOut` of the contract. */
34
+ export interface DmVerifiedAnswer {
35
+ id: string;
36
+ question: string;
37
+ query_summary: DmQuerySummary;
38
+ ask_count: number;
39
+ stale: boolean;
40
+ }
41
+ export interface DmVerifiedAnswerDetail extends DmVerifiedAnswer {
42
+ question_id: string;
43
+ csdk_title: string | null;
44
+ csdk_json: string;
45
+ }
46
+ export interface DmTermCondition {
47
+ column: string;
48
+ kind: string;
49
+ rule: string;
50
+ }
51
+ export interface DmTermRef {
52
+ id: string;
53
+ title: string;
54
+ }
55
+ export interface DmTermGrounding {
56
+ tables: string[];
57
+ formulas: string[];
58
+ conditions: DmTermCondition[];
59
+ widgets: DmTermRef[];
60
+ verified_answers: DmTermRef[];
61
+ }
62
+ export interface DmTableBusinessUsage {
63
+ business_names?: string[];
64
+ synonyms?: string[];
65
+ definition?: string | null;
66
+ }
67
+ export type DmLearnedSource = 'widgets' | 'verified';
68
+ export interface DmLearnedEntity {
69
+ name: string;
70
+ source: DmLearnedSource;
71
+ }
72
+ export declare const isLearnedSource: (value: unknown) => value is DmLearnedSource;
73
+ export interface DmSubjectAreaCard {
74
+ id: string;
75
+ name: string;
76
+ summary: string;
77
+ fact_tables: string[];
78
+ tables: string[];
79
+ entities: string[];
80
+ formulas: string[];
81
+ analysis_hints: DmAnalysisHint[];
82
+ /** Verified layer only (absent when off): number of verified answers in the area. */
83
+ verified_answer_count?: number;
84
+ /** Term layer only: table -> business names folded onto it. */
85
+ business_names?: Record<string, string[]>;
86
+ /** Term layer only: terms learned from widgets or verified answers. */
87
+ learned_entities?: DmLearnedEntity[];
88
+ }
89
+ export interface DmSubjectAreaList {
90
+ datamodel: string;
91
+ over_cluster_limit: boolean;
92
+ /**
93
+ * false: the map has no AI content (basic subject areas, no business terms). Absent from
94
+ * older servers (read as refined).
95
+ */
96
+ refined?: boolean;
97
+ recommendation: string | null;
98
+ subject_areas: DmSubjectAreaCard[];
99
+ }
100
+ /**
101
+ * An unrefined model whose basic map has too many subject areas to list: the areas can only
102
+ * be picked by ranking, never read in full.
103
+ */
104
+ export declare function rankedSelectionOnly(list: Partial<DmSubjectAreaList> | null | undefined): boolean;
105
+ /** One join step; `from`/`to` are `Table.column`, cardinality oriented along the step. */
106
+ export interface DmJoinStep {
107
+ relation: string;
108
+ from: string;
109
+ to: string;
110
+ cardinality: string;
111
+ /** Area-detail joins only: the business labels of the join. */
112
+ labels?: string[];
113
+ }
114
+ export interface DmColumn {
115
+ name: string;
116
+ type: string;
117
+ description: string;
118
+ }
119
+ export interface DmTable extends DmTableBusinessUsage {
120
+ name: string;
121
+ role: string;
122
+ description: string;
123
+ row_count: number | null;
124
+ columns: DmColumn[];
125
+ }
126
+ export interface DmEntitySummary {
127
+ name: string;
128
+ definition: string;
129
+ synonyms: string[];
130
+ tables: string[];
131
+ }
132
+ export interface DmFormula {
133
+ title: string;
134
+ description: string;
135
+ ai_context: string;
136
+ compose_code: string;
137
+ used_columns: string[];
138
+ measures_entity: string | null;
139
+ /** Set when the measured term is folded: `measures_entity` is then null and this names its table. */
140
+ measures_table?: string | null;
141
+ subject_areas?: string[];
142
+ /** Widget layer only (absent when off): `DmFormula.formula_kind`. */
143
+ kind?: DmFormulaKind;
144
+ /** Widget layer only: every title the formula is shown under. */
145
+ titles?: string[];
146
+ /** Widget layer only: widgets that use it (server-capped). */
147
+ widgets?: DmWidgetRef[];
148
+ /** Pulse layer only (absent when off): the alerts watching this formula. */
149
+ watched?: DmWatched;
150
+ /** Verified layer only: verified answers that use this formula. */
151
+ verified_answers?: DmVerifiedAnswer[];
152
+ }
153
+ export interface DmSubjectArea {
154
+ id: string;
155
+ name: string;
156
+ summary: string;
157
+ tables: DmTable[];
158
+ joins: DmJoinStep[];
159
+ entities: DmEntitySummary[];
160
+ formulas: DmFormula[];
161
+ analysis_hints: DmAnalysisHint[];
162
+ /** Widget layer only: analysis patterns from existing dashboards (server-capped). */
163
+ patterns?: DmAnalysisPattern[];
164
+ /** Pulse layer only (absent when off): watched metrics in the area (server-capped). */
165
+ kpis?: DmKpi[];
166
+ /** Verified layer only: the area's verified answers (server-capped, most-asked first, never stale). */
167
+ verified_answers?: DmVerifiedAnswer[];
168
+ /** Term layer only: terms learned from widgets or verified answers. */
169
+ learned_entities?: DmLearnedEntity[];
170
+ }
171
+ export interface DmSearchHit extends DmTableBusinessUsage {
172
+ type: string;
173
+ name: string;
174
+ /** Set for column hits only. */
175
+ table?: string;
176
+ matched_on: string;
177
+ snippet: string;
178
+ subject_areas: string[];
179
+ score: number;
180
+ /** Cosine similarity (3 dp) when meaning-based matching contributed to this hit. */
181
+ similarity?: number;
182
+ /** Widget layer only: set on widget and dashboard hits. */
183
+ kind?: DmSearchHitKind;
184
+ widget_oid?: string;
185
+ dashboard_oid?: string;
186
+ dashboard_title?: string;
187
+ /** Widget layer only: number of visible copies of the widget, present only when > 1. */
188
+ copy_count?: number;
189
+ /** Pulse layer only (absent when off): set on a watched formula or plain-aggregate column hit. */
190
+ kpi?: boolean;
191
+ alert_count?: number;
192
+ /** Verified layer only: set on a `verified_answer` hit. */
193
+ id?: string;
194
+ question?: string;
195
+ /** A learned `entity` hit carries its source (only meaningful when `isLearnedSource`). */
196
+ source?: string;
197
+ }
198
+ export interface DmSearchResult {
199
+ query: string;
200
+ hits: DmSearchHit[];
201
+ }
202
+ export interface DmCompareAt {
203
+ table: string;
204
+ keys: string[];
205
+ joined_from: string[];
206
+ }
207
+ export type DmRelatedEntity = {
208
+ /** A related folded term carries `table` in place of `entity`. */
209
+ entity?: string;
210
+ table?: string;
211
+ relation: string;
212
+ kind: 'join';
213
+ join_path: DmJoinStep[];
214
+ } | {
215
+ entity?: string;
216
+ table?: string;
217
+ relation: string;
218
+ kind: 'comparison';
219
+ compare_at: DmCompareAt[];
220
+ note: string;
221
+ };
222
+ export interface DmEntity {
223
+ name: string;
224
+ definition: string;
225
+ synonyms: string[];
226
+ tables: ({
227
+ name: string;
228
+ role: string | null;
229
+ } & DmTableBusinessUsage)[];
230
+ related: DmRelatedEntity[];
231
+ measured_by: string[];
232
+ subject_areas: string[];
233
+ /** Widget layer only (absent when off). Lists are server-capped. */
234
+ widgets?: DmWidgetRef[];
235
+ widget_formulas?: DmWidgetFormulaRef[];
236
+ widget_synonyms?: string[];
237
+ widget_definition_note?: string | null;
238
+ /** Pulse layer only (absent when off): watched metrics linked to the entity (server-capped). */
239
+ kpis?: DmKpi[];
240
+ /** Term layer only: what the term is built from. */
241
+ grounded_in?: DmTermGrounding;
242
+ /** A learned term only when `isLearnedSource`. */
243
+ source?: string;
244
+ verified_synonyms?: string[];
245
+ verified_definition_note?: string | null;
246
+ }
247
+ export interface DmJoinPath {
248
+ from: string;
249
+ to: string;
250
+ connected: boolean;
251
+ path: DmJoinStep[];
252
+ tables: string[];
253
+ facts_on_path: string[];
254
+ fan_out_risk: boolean;
255
+ note: string;
256
+ comparable_at?: DmCompareAt[];
257
+ }
258
+ export type DmFormulaKind = 'shared' | 'widget' | 'pulse' | 'verified';
259
+ /** Pulse layer: one watch signature of a metric (Appendix `WatchOut`). Range is null for event and filtered watches. */
260
+ export interface DmWatch {
261
+ threshold_kind: string;
262
+ direction: string;
263
+ period: string;
264
+ baseline: string | null;
265
+ filtered_by: string[];
266
+ alert_count: number;
267
+ min: number | null;
268
+ max: number | null;
269
+ median: number | null;
270
+ /**
271
+ * True when a numeric range exists but is withheld because fewer than 3 alerts share this
272
+ * signature (min/max/median are null then). Absent means false.
273
+ */
274
+ range_hidden?: boolean;
275
+ }
276
+ /** Pulse layer: the alerts watching one metric (Appendix `WatchedOut`; `watches` server-capped). */
277
+ export interface DmWatched {
278
+ alert_count: number;
279
+ watches: DmWatch[];
280
+ }
281
+ export type DmKpiKind = DmFormulaKind | 'column';
282
+ /** Pulse layer: a watched metric (Appendix `KpiOut`). A column KPI has `column` (`Table.column`) and `agg`. */
283
+ export interface DmKpi {
284
+ title: string;
285
+ kind: DmKpiKind;
286
+ column: string | null;
287
+ agg: string | null;
288
+ watched: DmWatched;
289
+ }
290
+ export type DmSearchHitKind = 'widget' | 'dashboard' | 'verified_answer' | 'entity';
291
+ /** `WidgetRef` of the contract. */
292
+ export interface DmWidgetRef {
293
+ widget_oid: string;
294
+ title: string;
295
+ widget_type: string;
296
+ dashboard_oid: string;
297
+ dashboard_title: string;
298
+ /** Number of visible copies of this widget, present only when > 1. */
299
+ copy_count?: number;
300
+ }
301
+ /** Another visible copy of a widget, on another dashboard. */
302
+ export interface DmWidgetCopy {
303
+ widget_oid: string;
304
+ dashboard_oid: string;
305
+ dashboard_title: string;
306
+ }
307
+ export interface DmWidgetFormulaRef {
308
+ title: string;
309
+ kind: DmFormulaKind;
310
+ }
311
+ /**
312
+ * One analysis pattern of a subject area. knowledge-graph computes `widget_count` over the
313
+ * dashboards the asking user can see; ai-integration never recomputes it and only drops a
314
+ * pattern whose `example` is outside those dashboards. No per-dashboard counts are sent.
315
+ */
316
+ export interface DmAnalysisPattern {
317
+ measure: string;
318
+ breakdowns: string[];
319
+ filters: string[];
320
+ widget_count: number;
321
+ example: DmWidgetRef | null;
322
+ }
323
+ export interface DmWidgetFilter {
324
+ column: string;
325
+ kind: string;
326
+ values: string[];
327
+ }
328
+ /** `GET …/widgets/{widgetOid}`: one widget's resolved pattern. */
329
+ export interface DmWidgetDetail {
330
+ widget: DmWidgetRef;
331
+ measures: string[];
332
+ breakdowns: string[];
333
+ filters: DmWidgetFilter[];
334
+ entities: string[];
335
+ subject_areas: string[];
336
+ /** Other visible copies of the widget (optional key). */
337
+ copies?: DmWidgetCopy[];
338
+ }
339
+ /**
340
+ * Every read resolves to one of three outcomes; only transport failures and 403 throw.
341
+ * `not_ready` (200 body, or a thrown 404 when the flag was switched off mid-session)
342
+ * means "no map: read the plain fields instead" (the engines do); `not_found` carries the closest names from the
343
+ * 200 `not_found` body ai-integration sends for unknown names. A `not_ready` with reason
344
+ * `ai_access_off` means the model is closed to the Analytics Assistant: on that surface the
345
+ * engines refuse it (DataModelAiAccessDeniedError) instead of reading its plain fields; on any
346
+ * other surface it is a plain `not_ready` (the plain fields check that surface's own setting).
347
+ */
348
+ export type DatamodelGraphOutcome<T> = {
349
+ status: 'ok';
350
+ data: T;
351
+ } | {
352
+ status: 'not_ready';
353
+ message: string;
354
+ reason?: DatamodelGraphNotReadyReason;
355
+ } | {
356
+ status: 'not_found';
357
+ kind?: string;
358
+ name?: string;
359
+ suggestions: string[];
360
+ message?: string;
361
+ };
362
+ /**
363
+ * The one `not_ready` reason the client acts on: the data model's per-model "Available for
364
+ * Analytics Assistant" setting is off (SNS-134426). Any other reason is dropped.
365
+ */
366
+ export declare const AI_ACCESS_OFF_REASON = "ai_access_off";
367
+ export type DatamodelGraphNotReadyReason = typeof AI_ACCESS_OFF_REASON;
368
+ /** Whether a map read answered that the data model is closed to AI. */
369
+ export declare function isAiAccessOffOutcome(outcome: {
370
+ status: string;
371
+ }): boolean;
372
+ /** 403 from ai-integration: the user cannot read this data source. Non-disclosing by design. */
373
+ export declare class DatamodelGraphAccessError extends Error {
374
+ constructor();
375
+ }
376
+ export interface DataModelGraphConfig {
377
+ enabled: boolean;
378
+ /** ai-integration's `dataModelGraphWidgetsEnabled`; never true while `enabled` is false. */
379
+ widgetsEnabled: boolean;
380
+ /** ai-integration's `dataModelGraphPulseEnabled`; never true while `enabled` is false. */
381
+ pulseEnabled: boolean;
382
+ }
383
+ /**
384
+ * Every data model map switch from one call. A server without the route (404)
385
+ * is all off; every other failure is rethrown so the caller can fail closed.
386
+ */
387
+ export declare function getDataModelGraphConfig(httpClient?: HttpClient): Promise<DataModelGraphConfig>;
388
+ export declare function fetchDataModelSubjectAreas(dataSourceTitle: string, httpClient?: HttpClient, abortSignal?: AbortSignal): Promise<DatamodelGraphOutcome<DmSubjectAreaList>>;
389
+ export declare function fetchDataModelSubjectArea(dataSourceTitle: string, subjectAreaId: string, httpClient?: HttpClient, abortSignal?: AbortSignal, toolName?: string): Promise<DatamodelGraphOutcome<DmSubjectArea>>;
390
+ export declare function searchDataModelGraph(dataSourceTitle: string, query: string, limit?: number, httpClient?: HttpClient, abortSignal?: AbortSignal, toolName?: string): Promise<DatamodelGraphOutcome<DmSearchResult>>;
391
+ export declare function fetchDataModelEntity(dataSourceTitle: string, name: string, httpClient?: HttpClient, abortSignal?: AbortSignal): Promise<DatamodelGraphOutcome<DmEntity>>;
392
+ export declare function fetchDataModelFormula(dataSourceTitle: string, formulaTitle: string, httpClient?: HttpClient, abortSignal?: AbortSignal, toolName?: string): Promise<DatamodelGraphOutcome<DmFormula>>;
393
+ export declare function fetchDataModelJoinPath(dataSourceTitle: string, from: string, to: string, httpClient?: HttpClient, abortSignal?: AbortSignal): Promise<DatamodelGraphOutcome<DmJoinPath>>;
394
+ /**
395
+ * One existing widget's resolved pattern (widget layer). ai-integration answers a 200
396
+ * `not_found` for an unknown id and for a widget on a dashboard the user cannot open,
397
+ * and `not_ready` (or a thrown 404) when the widget layer is off or not built.
398
+ */
399
+ export declare function fetchDataModelWidget(dataSourceTitle: string, widgetOid: string, httpClient?: HttpClient, abortSignal?: AbortSignal): Promise<DatamodelGraphOutcome<DmWidgetDetail>>;
400
+ export declare const ROUTE_CONFIDENCES: readonly ["confident", "close", "no_match", "unavailable"];
401
+ export type DmRouteConfidence = (typeof ROUTE_CONFIDENCES)[number];
402
+ /**
403
+ * Why a candidate matched: a name (entity, synonym, formula, table, widget, area, title),
404
+ * and, for a concept-based route, which of the asked concepts it matched.
405
+ */
406
+ export interface DmRouteReason {
407
+ concept?: string;
408
+ kind: string;
409
+ name: string;
410
+ }
411
+ export interface DmRouteCandidate {
412
+ datamodel_title: string;
413
+ /** Null for a model without a map yet (ai-integration's title fallback). */
414
+ subject_area_id: string | null;
415
+ subject_area_name: string | null;
416
+ score: number;
417
+ /** False while the model's map is structure-only. */
418
+ refined: boolean;
419
+ reasons: DmRouteReason[];
420
+ }
421
+ export interface DmRouteAnswer {
422
+ confidence: DmRouteConfidence;
423
+ candidates: DmRouteCandidate[];
424
+ /** The data model the user named, when none they can access matched it (routing then searched all). */
425
+ datamodel_not_found?: string;
426
+ /** Verified layer: questions matching a verified answer; set only when non-empty. */
427
+ verifiedMatches?: DmVerifiedMatch[];
428
+ }
429
+ /** Any body that is not a known answer is `unavailable`, so the caller falls back. */
430
+ export declare function parseRouteAnswer(body: unknown): DmRouteAnswer;
431
+ /** What the route is asked; empty values are not sent. */
432
+ export interface DmRouteRequest {
433
+ /** The business concepts the question is about; the server matches each one separately. */
434
+ concepts?: readonly string[];
435
+ /** The question, as context; without concepts the server ranks by its text. */
436
+ question?: string;
437
+ /** The open dashboard's data model titles; ranked first. */
438
+ preferredDatamodels?: readonly string[];
439
+ /** The data model the user named; ai-integration restricts routing to it. */
440
+ datamodel?: string;
441
+ /** Maximum number of candidates. */
442
+ limit?: number;
443
+ /** The user's exact message; the server answers `verifiedMatches` only when it is sent. */
444
+ userQuestion?: string;
445
+ }
446
+ /**
447
+ * Which data models and subject areas a question's concepts belong to. Never rejects: a
448
+ * 404 (map off), any other failure, or an unreadable body is `unavailable`.
449
+ */
450
+ export declare function routeDataModelQuestion({ concepts, question, preferredDatamodels, datamodel, limit, userQuestion, }: DmRouteRequest, httpClient?: HttpClient, abortSignal?: AbortSignal): Promise<DmRouteAnswer>;
451
+ /**
452
+ * One verified answer's detail. `null` means it cannot be used: unknown or withdrawn (a
453
+ * thrown 404, or the 200 `not_found` body ai-integration sends for an unknown, withdrawn
454
+ * or stale answer), the map or its layer not ready or closed to AI (`not_ready` body), or
455
+ * an unreadable body. A 403 throws `DatamodelGraphAccessError`; anything else is rethrown.
456
+ */
457
+ export declare function fetchVerifiedAnswer(dataSourceTitle: string, answerId: string, httpClient?: HttpClient, toolName?: string, abortSignal?: AbortSignal): Promise<DmVerifiedAnswerDetail | null>;
@@ -0,0 +1,31 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ import { DataSchemaContext, QueryJSON } from '@sisense/sdk-ui/analytics-composer';
3
+ export interface ExistingAnswerQueryState extends QueryJSON {
4
+ title?: string;
5
+ }
6
+ export interface ExistingAnswerQueryStateResponse {
7
+ queryState: ExistingAnswerQueryState;
8
+ dataSchema: DataSchemaContext;
9
+ chartType?: string;
10
+ }
11
+ /**
12
+ * Client for ai-integration's widget-JAQL-to-CSDK reconstruction endpoint. Given a widget the
13
+ * existing-answer cascade already matched (see engines/shared/existing-answer-cascade.ts), fetches
14
+ * a real query state (plus the data schema needed to render it) reconstructed from that widget's
15
+ * live JAQL — so `buildQuery` can hand it to `buildChart` as a "verbatim reuse" query instead of
16
+ * only linking to the widget. May reject (e.g. the widget's JAQL couldn't be translated) — callers
17
+ * should treat a rejection as "fall back to the link card," never surface it as a hard error.
18
+ */
19
+ export declare function fetchExistingAnswerQueryState(widgetId: string, dashboardId: string, httpClient?: HttpClient,
20
+ /** Sent as `x-tool-name`: the tool this call is made for. */
21
+ toolName?: string): Promise<ExistingAnswerQueryStateResponse>;
22
+ /**
23
+ * Client for ai-integration's plain datasource-schema endpoint — the same `DataSchemaContext`
24
+ * shape `fetchExistingAnswerQueryState` returns alongside a widget's reconstructed queryState, but
25
+ * for a datasource on its own, no widget involved. Used to reconstruct a feedback-verified KG
26
+ * match's already-captured `csdkJson` into a chart: that JSON is already QueryJSON-shaped (usable
27
+ * directly as `queryState`), so only the schema half needs fetching.
28
+ */
29
+ export declare function fetchDataSchemaForDatasource(datasourceTitle: string, httpClient?: HttpClient,
30
+ /** Sent as `x-tool-name`: the tool this call is made for. */
31
+ toolName?: string): Promise<DataSchemaContext>;
@@ -1,6 +1,25 @@
1
1
  import { CalculatedMeasure } from '@sisense/sdk-data';
2
2
  import { HttpClient } from '@sisense/sdk-rest-client';
3
3
  export declare const FORMULAS_API_URL_PATH = "api/v1/formulas";
4
+ /**
5
+ * Shared formulas plus the designer-authored AI context keyed by formula title.
6
+ * `aiContext` is a facet on the raw formula (the "when to use this formula" guidance)
7
+ * that {@link translateSharedFormulas} drops, so we capture it here before translation.
8
+ */
9
+ export type SharedFormulas = {
10
+ measures: CalculatedMeasure[];
11
+ /** Formula title → designer aiContext, only for formulas that have one. */
12
+ aiContextByTitle: Record<string, string>;
13
+ };
14
+ /**
15
+ * Fetch all shared formulas for a data source, returning both the translated
16
+ * CalculatedMeasure array and the per-formula designer aiContext (keyed by title).
17
+ *
18
+ * @param dataSourceTitle - Data source title in the Sisense instance
19
+ * @param httpClient - Optional HTTP client; uses singleton if not provided
20
+ * @throws Error if the request fails (caller decides whether to soft-fail)
21
+ */
22
+ export declare function getSharedFormulas(dataSourceTitle: string, httpClient?: HttpClient): Promise<SharedFormulas>;
4
23
  /**
5
24
  * Fetch all shared formulas for a data source from the Sisense instance.
6
25
  * Returns them as CSDK CalculatedMeasure array.
@@ -0,0 +1,31 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ /**
3
+ * Hide from AI (SNS-135153).
4
+ *
5
+ * model-graphql leaves out tables, columns and data models tagged `hide_from_ai` on a perspective
6
+ * when the request carries `availableFor=genai`. Every AI caller sends the same value, whichever
7
+ * assistant surface it serves — unlike the AI access flag, which differs per surface.
8
+ */
9
+ export declare const AI_AVAILABLE_FOR = "genai";
10
+ /**
11
+ * Adds `availableFor=genai` to a model-graphql or be-services REST path (aifields). Older servers
12
+ * ignore the parameter.
13
+ */
14
+ export declare function withAiAvailableFor(url: string): string;
15
+ /** A GraphQL operation sent with the `availableFor` argument, and the same one without it. */
16
+ export type AiGraphQlOperation = {
17
+ operationName: string;
18
+ /** Declares `$availableFor: String` and passes it to the field. */
19
+ query: string;
20
+ /** The same operation without the argument, for servers older than SNS-135153. */
21
+ legacyQuery: string;
22
+ variables: Record<string, unknown>;
23
+ };
24
+ /**
25
+ * Posts a GraphQL operation with `availableFor=genai`. A server older than SNS-135153 rejects the
26
+ * unknown argument with 400 and does not filter anything, so the operation is sent again without
27
+ * it: nothing ran on the first attempt, and that server has nothing to leave out.
28
+ */
29
+ export declare function postAiGraphQl<T>(httpClient: HttpClient, url: string, operation: AiGraphQlOperation, options: {
30
+ headers: Record<string, string>;
31
+ }): Promise<T | undefined>;
@@ -0,0 +1,96 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ import { WidgetSearchResultPermission } from '../semantic-search/semantic-search-service';
3
+ export interface KgSimilarQuestionsRequest {
4
+ /** Original verbatim user question. */
5
+ questionText: string;
6
+ /** Optional datasource scoping — restricts KG results to this datasource when provided. */
7
+ dataSourceTitle?: string;
8
+ limit?: number;
9
+ }
10
+ /**
11
+ * A real widget/dashboard the KG resolved a similar question's JAQL fields against — pre-permission
12
+ * -checked and metadata-resolved server-side (ai-integration), same shape as widget-search results so
13
+ * the cascade can treat both sources uniformly.
14
+ */
15
+ export interface KgVerifiedWidgetRef {
16
+ widgetId: string;
17
+ dashboardId: string;
18
+ title?: string;
19
+ dashboardTitle?: string;
20
+ url?: string;
21
+ permission?: WidgetSearchResultPermission;
22
+ }
23
+ export interface KgVerifiedWidget {
24
+ verified: boolean;
25
+ widgets: KgVerifiedWidgetRef[];
26
+ matchedQueryUid: string | null;
27
+ /** Set when `verified` is false — e.g. "no_common_query", "no_widget_backed_query", "error". */
28
+ reason: string | null;
29
+ }
30
+ export interface KgSimilarQuestionResult {
31
+ questionId: string;
32
+ questionText: string;
33
+ datasourceFullname: string;
34
+ nodeTypeCount: number;
35
+ userCount: number;
36
+ positiveFeedbackCount: number;
37
+ negativeFeedbackCount: number;
38
+ /**
39
+ * Real cosine similarity (0-1) between the question embeddings, or null if it couldn't be
40
+ * computed. KG's own lookup has no built-in cutoff — callers must threshold on this themselves.
41
+ */
42
+ similarityScore: number | null;
43
+ verifiedWidget: KgVerifiedWidget;
44
+ /**
45
+ * The captured CSDK query (QueryJSON-shaped: `{dimensions, measures, filters, title}`), present
46
+ * only on a feedback-verified match (`verifiedWidget.reason === 'feedback_verified'`) — there's
47
+ * no widget to reconstruct a chart from, but the question's own resolved query was captured at
48
+ * ask-time and can be used directly as `queryState`.
49
+ */
50
+ csdkJson?: string;
51
+ }
52
+ /**
53
+ * Client for ai-integration's KG similar-question endpoint (proxies knowledge-graph's
54
+ * `/v1/nlq/similar`). Used by the existing-answer cascade (see
55
+ * engines/shared/existing-answer-cascade.ts) as the highest-trust source — a match here means a
56
+ * real, human-built widget's query JAQL fields cover every field this past question resolved to
57
+ * (see `verifiedWidget.verified`), not just text similarity.
58
+ *
59
+ * NOTE: the wire response is expected in camelCase, matching widget-search's convention — this is
60
+ * NOT a raw pass-through of knowledge-graph's snake_case Dgraph response (question_id,
61
+ * verified_widget, etc). ai-integration's controller reshapes it (see
62
+ * `knowledgeGraph.controller.v2.js`'s `getSimilarQuestions`), the same way
63
+ * `dashboardSemanticSearch.service.js` already reshapes its own vector-DB results before returning.
64
+ */
65
+ export declare function findSimilarQuestions(request: KgSimilarQuestionsRequest, httpClient?: HttpClient, abortSignal?: AbortSignal,
66
+ /** Sent as `x-tool-name`: the tool this call is made for. */
67
+ toolName?: string): Promise<KgSimilarQuestionResult[]>;
68
+ /**
69
+ * Tells KG that the existing-answer cascade just served an answer from `questionId`, so the ask is
70
+ * counted (SNS-132590).
71
+ *
72
+ * A cascade hit short-circuits before NLQ generation and therefore before capture, which hangs off
73
+ * the generation path — so a question's ask count used to freeze the moment it became verified,
74
+ * and that is the count the kg-insights Popular ranking and Knowledge Gaps analysis sort on. The
75
+ * better the cascade worked, the more wrong those numbers got.
76
+ *
77
+ * Fire-and-forget by contract: never throws — synchronously or asynchronously — never awaited on
78
+ * the cascade's hot path, and the server answers 200 even when it recorded nothing. Counting an ask
79
+ * is worth losing; an answer the user already has must never fail because a counter did.
80
+ *
81
+ * The whole body is guarded, not just the returned promise. `getHttpClient()` **throws** when no
82
+ * singleton has been initialized, and `context.httpClient` is optional on `BuildQueryContext`, so a
83
+ * host that doesn't thread a client would otherwise take that throw straight out of
84
+ * `buildQueryEngine` — failing a `buildQuery` call that had already successfully found a verified
85
+ * answer, which is the exact outcome this function is written to make impossible. `post()` is inside
86
+ * the same guard because a malformed client can throw before it ever returns a promise.
87
+ *
88
+ * The server increments only; it does not re-run capture. Re-capturing here would rewrite
89
+ * `question_embedding` on every hit, which drops the most-asked questions out of the vector index
90
+ * (SNS-132425) — the exact questions this is meant to measure.
91
+ */
92
+ export declare function recordCascadeAsk(questionId: string, httpClient?: HttpClient,
93
+ /** Sent as `x-tool-name`: the tool this call is made for. */
94
+ toolName?: string,
95
+ /** The user's question in their own phrasing, stored with the ask. */
96
+ userQuestion?: string): void;
@@ -1,16 +1,21 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
1
2
  export declare class QuotaExceededError extends Error {
2
3
  constructor(message?: string);
3
4
  }
4
5
  /**
5
6
  * Captures consumption of LLM tokens.
6
7
  * @param requestOptions - Optional request options (e.g. from withTrackingHeaders()) for user-action tracking headers.
8
+ * @param client - The client to post through. Defaults to the global one; a multi-tenant server
9
+ * must pass the session's own client (SNS-135386).
7
10
  * @returns The capture UUID if successful, undefined otherwise.
8
11
  */
9
- export declare function captureConsumption(requestOptions?: RequestInit): Promise<string | undefined>;
12
+ export declare function captureConsumption(requestOptions?: RequestInit, client?: HttpClient): Promise<string | undefined>;
10
13
  /**
11
14
  * Reports consumption of LLM tokens to the backend.
12
15
  * Fire-and-forget: failures are non-critical and are silently ignored.
13
16
  * @param quotaId - The capture UUID from captureConsumption.
14
17
  * @param requestOptions - Optional request options (e.g. from withTrackingHeaders()) for user-action tracking headers.
18
+ * @param client - The client to post through. Defaults to the global one; a multi-tenant server
19
+ * must pass the session's own client (SNS-135386).
15
20
  */
16
- export declare function reportConsumption(quotaId: string, requestOptions?: RequestInit): void;
21
+ export declare function reportConsumption(quotaId: string, requestOptions?: RequestInit, client?: HttpClient): void;