@finos/legend-application-query 13.8.43 → 13.8.45

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 (45) hide show
  1. package/lib/__lib__/LegendQueryAgentChatTelemetryHelper.d.ts +33 -0
  2. package/lib/__lib__/LegendQueryAgentChatTelemetryHelper.d.ts.map +1 -0
  3. package/lib/__lib__/LegendQueryAgentChatTelemetryHelper.js +45 -0
  4. package/lib/__lib__/LegendQueryAgentChatTelemetryHelper.js.map +1 -0
  5. package/lib/__lib__/LegendQueryEvent.d.ts +2 -0
  6. package/lib/__lib__/LegendQueryEvent.d.ts.map +1 -1
  7. package/lib/__lib__/LegendQueryEvent.js +2 -0
  8. package/lib/__lib__/LegendQueryEvent.js.map +1 -1
  9. package/lib/__lib__/LegendQueryTelemetryHelper.d.ts +1 -1
  10. package/lib/__lib__/LegendQueryTelemetryHelper.d.ts.map +1 -1
  11. package/lib/application/LegendQueryApplicationConfig.d.ts +3 -1
  12. package/lib/application/LegendQueryApplicationConfig.d.ts.map +1 -1
  13. package/lib/application/LegendQueryApplicationConfig.js +6 -1
  14. package/lib/application/LegendQueryApplicationConfig.js.map +1 -1
  15. package/lib/components/QueryEditor.d.ts.map +1 -1
  16. package/lib/components/QueryEditor.js +33 -9
  17. package/lib/components/QueryEditor.js.map +1 -1
  18. package/lib/components/data-space/DataSpaceQuerySetup.d.ts.map +1 -1
  19. package/lib/components/data-space/DataSpaceQuerySetup.js +1 -0
  20. package/lib/components/data-space/DataSpaceQuerySetup.js.map +1 -1
  21. package/lib/components/data-space/LegendQueryDataSpaceQueryBuilder.d.ts.map +1 -1
  22. package/lib/components/data-space/LegendQueryDataSpaceQueryBuilder.js +2 -0
  23. package/lib/components/data-space/LegendQueryDataSpaceQueryBuilder.js.map +1 -1
  24. package/lib/index.css +2 -2
  25. package/lib/index.css.map +1 -1
  26. package/lib/index.d.ts +2 -0
  27. package/lib/index.d.ts.map +1 -1
  28. package/lib/index.js +2 -0
  29. package/lib/index.js.map +1 -1
  30. package/lib/light-mode.css +1 -1
  31. package/lib/package.json +1 -1
  32. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  33. package/lib/stores/QueryEditorStore.js +4 -0
  34. package/lib/stores/QueryEditorStore.js.map +1 -1
  35. package/package.json +11 -11
  36. package/src/__lib__/LegendQueryAgentChatTelemetryHelper.ts +67 -0
  37. package/src/__lib__/LegendQueryEvent.ts +2 -0
  38. package/src/__lib__/LegendQueryTelemetryHelper.ts +1 -1
  39. package/src/application/LegendQueryApplicationConfig.ts +11 -2
  40. package/src/components/QueryEditor.tsx +61 -6
  41. package/src/components/data-space/DataSpaceQuerySetup.tsx +1 -0
  42. package/src/components/data-space/LegendQueryDataSpaceQueryBuilder.tsx +2 -0
  43. package/src/index.ts +2 -0
  44. package/src/stores/QueryEditorStore.ts +5 -0
  45. package/tsconfig.json +1 -0
@@ -23,6 +23,8 @@ export enum LEGEND_QUERY_APP_EVENT {
23
23
  UPDATE_QUERY__SUCCESS = 'query-editor.update-query.success',
24
24
  RENAME_QUERY__SUCCESS = 'query-editor.rename.query.success',
25
25
  INITIALIZE_QUERY_STATE__SUCCESS = 'query-editor.initialize-query-state.success',
26
+ LEGENDAI_QUERY_AGENT_CHAT__OPENED = 'query-editor.legendai-query-agent-chat.opened',
27
+ LEGENDAI_QUERY_AGENT_CHAT__QUERY_LOADED = 'query-editor.legendai-query-agent-chat.query-loaded',
26
28
  LEGENDAI_QUERY_SUGGEST__LAUNCH = 'query-editor.legendai-query-suggest.launch',
27
29
  LEGENDAI_QUERY_SUGGEST__APPLY = 'query-editor.legendai-query-suggest.apply',
28
30
  LEGENDAI_QUERY_SUGGEST__DISCARD = 'query-editor.legendai-query-suggest.discard',
@@ -30,7 +30,7 @@ type Query_TelemetryData = {
30
30
  groupId: string;
31
31
  artifactId: string;
32
32
  };
33
- };
33
+ } & Record<string, unknown>;
34
34
 
35
35
  type QueryGraphInitialization_TelemetryData = Query_TelemetryData & {
36
36
  graph: GraphInitializationReport;
@@ -161,7 +161,8 @@ export interface LegendQueryApplicationConfigurationData
161
161
  url: string;
162
162
  };
163
163
  legendAI?: {
164
- url: string;
164
+ url?: string;
165
+ agentURL?: string;
165
166
  };
166
167
  }
167
168
 
@@ -178,6 +179,7 @@ export class LegendQueryApplicationConfig extends LegendApplicationConfig {
178
179
  readonly marketplaceProductionParallelUrl?: string;
179
180
  readonly lakehouseContractUrl?: string;
180
181
  readonly legendAIUrl?: string;
182
+ readonly legendAIAgentUrl?: string;
181
183
  readonly studioInstances: LegendStudioApplicationInstanceConfigurationData[] =
182
184
  [];
183
185
 
@@ -266,13 +268,20 @@ export class LegendQueryApplicationConfig extends LegendApplicationConfig {
266
268
  );
267
269
  }
268
270
 
269
- // legend AI
271
+ // legend AI (AI-assisted features such as query title/description suggester)
270
272
  if (input.configData.legendAI?.url) {
271
273
  this.legendAIUrl = LegendApplicationConfig.resolveAbsoluteUrl(
272
274
  input.configData.legendAI.url,
273
275
  );
274
276
  }
275
277
 
278
+ // legend AI agent chat
279
+ if (input.configData.legendAI?.agentURL) {
280
+ this.legendAIAgentUrl = LegendApplicationConfig.resolveAbsoluteUrl(
281
+ input.configData.legendAI.agentURL,
282
+ );
283
+ }
284
+
276
285
  // options
277
286
  this.options = LegendQueryApplicationCoreOptions.create(
278
287
  input.configData.extensions?.core ?? {},
@@ -43,6 +43,7 @@ import {
43
43
  MoonIcon,
44
44
  SunIcon,
45
45
  SparkleIcon,
46
+ RobotIcon,
46
47
  } from '@finos/legend-art';
47
48
  import { observer } from 'mobx-react-lite';
48
49
  import { useEffect, useMemo, useRef, useState } from 'react';
@@ -57,7 +58,7 @@ import {
57
58
  generateExistingQueryEditorRoute,
58
59
  } from '../__lib__/LegendQueryNavigation.js';
59
60
  import { ExistingQueryEditorStore } from '../stores/QueryEditorStore.js';
60
- import { LegendQueryTelemetryHelper } from '../__lib__/LegendQueryTelemetryHelper.js';
61
+ import { LegendQueryAgentChatTelemetryHelper } from '../__lib__/LegendQueryAgentChatTelemetryHelper.js';
61
62
  import {
62
63
  LEGEND_APPLICATION_COLOR_THEME,
63
64
  ReleaseLogManager,
@@ -186,7 +187,7 @@ const CreateQueryDialog = observer(() => {
186
187
  if (!aiSuggester || !editorStore.queryBuilderState || !legendAIUrl) {
187
188
  return;
188
189
  }
189
- LegendQueryTelemetryHelper.logEvent_QueryAISuggestLaunched(
190
+ LegendQueryAgentChatTelemetryHelper.logEvent_QueryAISuggestLaunched(
190
191
  applicationStore.telemetryService,
191
192
  );
192
193
  setIsSuggestingWithAI(true);
@@ -199,7 +200,7 @@ const CreateQueryDialog = observer(() => {
199
200
  setAISuggestion(suggestion);
200
201
  } catch (error) {
201
202
  assertErrorThrown(error);
202
- LegendQueryTelemetryHelper.logEvent_QueryAISuggestFailure(
203
+ LegendQueryAgentChatTelemetryHelper.logEvent_QueryAISuggestFailure(
203
204
  applicationStore.telemetryService,
204
205
  error.message,
205
206
  );
@@ -224,7 +225,7 @@ const CreateQueryDialog = observer(() => {
224
225
  if (!aiSuggestion) {
225
226
  return;
226
227
  }
227
- LegendQueryTelemetryHelper.logEvent_QueryAISuggestApplied(
228
+ LegendQueryAgentChatTelemetryHelper.logEvent_QueryAISuggestApplied(
228
229
  applicationStore.telemetryService,
229
230
  );
230
231
  createQueryState.setQueryName(aiSuggestion.title);
@@ -232,7 +233,7 @@ const CreateQueryDialog = observer(() => {
232
233
  setAISuggestion(undefined);
233
234
  };
234
235
  const discardAISuggestion = (): void => {
235
- LegendQueryTelemetryHelper.logEvent_QueryAISuggestDiscarded(
236
+ LegendQueryAgentChatTelemetryHelper.logEvent_QueryAISuggestDiscarded(
236
237
  applicationStore.telemetryService,
237
238
  );
238
239
  setAISuggestion(undefined);
@@ -519,7 +520,7 @@ const RenameQueryDialog = observer(
519
520
  setAISuggestion(suggestion);
520
521
  } catch (error) {
521
522
  assertErrorThrown(error);
522
- LegendQueryTelemetryHelper.logEvent_QueryAISuggestFailure(
523
+ LegendQueryAgentChatTelemetryHelper.logEvent_QueryAISuggestFailure(
523
524
  applicationStore.telemetryService,
524
525
  error.message,
525
526
  );
@@ -1093,6 +1094,20 @@ export const QueryEditor = observer(() => {
1093
1094
  );
1094
1095
  };
1095
1096
 
1097
+ const toggleAgentChat = (): void => {
1098
+ const qbState = editorStore.queryBuilderState;
1099
+ if (!qbState) {
1100
+ return;
1101
+ }
1102
+ const nextOpened = !qbState.isAgentChatOpened;
1103
+ if (nextOpened) {
1104
+ LegendQueryAgentChatTelemetryHelper.logEvent_QueryAgentChatOpened(
1105
+ applicationStore.telemetryService,
1106
+ );
1107
+ }
1108
+ qbState.setIsAgentChatOpened(nextOpened);
1109
+ };
1110
+
1096
1111
  // open the query version history (same viewer used by the query loader)
1097
1112
  const showQueryHistory = (): void => {
1098
1113
  if (editorStore instanceof ExistingQueryEditorStore) {
@@ -1165,6 +1180,46 @@ export const QueryEditor = observer(() => {
1165
1180
  </div>
1166
1181
  </div>
1167
1182
  <div className="query-editor__header__action__content">
1183
+ {!isLoadingEditor &&
1184
+ !editorStore.queryBuilderState?.config
1185
+ ?.TEMPORARY__disableQueryBuilderAgentChat &&
1186
+ editorStore.queryBuilderState?.canBuildQuery && (
1187
+ <button
1188
+ title={
1189
+ editorStore.queryBuilderState.isAgentChatOpened
1190
+ ? 'Close Legend AI Agent Chat'
1191
+ : 'Open Legend AI Agent Chat'
1192
+ }
1193
+ onClick={toggleAgentChat}
1194
+ className={clsx(
1195
+ 'query-editor__header__action query-editor__header__action__theme-toggler',
1196
+ {
1197
+ 'query-editor__header__action--toggled':
1198
+ editorStore.queryBuilderState.isAgentChatOpened,
1199
+ },
1200
+ )}
1201
+ >
1202
+ <div
1203
+ className={
1204
+ applicationStore.layoutService
1205
+ .TEMPORARY__isLightColorThemeEnabled
1206
+ ? 'query-editor__header__action__chat__label--light'
1207
+ : 'query-editor__header__action__chat__label--dark'
1208
+ }
1209
+ >
1210
+ Legend AI
1211
+ </div>
1212
+ <RobotIcon
1213
+ className={clsx(
1214
+ 'query-editor__header__action__chat__icon',
1215
+ applicationStore.layoutService
1216
+ .TEMPORARY__isLightColorThemeEnabled
1217
+ ? 'query-editor__header__action__chat__label--light'
1218
+ : 'query-editor__header__action__chat__label--dark',
1219
+ )}
1220
+ />
1221
+ </button>
1222
+ )}
1168
1223
  <button
1169
1224
  title="Toggle light/dark mode"
1170
1225
  onClick={TEMPORARY__toggleLightDarkMode}
@@ -87,6 +87,7 @@ const DataProductQuerySetupSetupPanelContent = observer(
87
87
  const onDataSpaceOptionChange = (
88
88
  option: DataSpaceOption | DataProductOption | null,
89
89
  ): void => {
90
+ queryBuilderState.queryAgentChatState?.abort();
90
91
  const value = option?.value;
91
92
  if (value instanceof ResolvedDataSpaceEntityWithOrigin) {
92
93
  queryBuilderState.changeHandlers.onDataSpaceChange(value);
@@ -112,10 +112,12 @@ const LegendQueryDataSpaceQueryBuilderSetupPanelContent = observer(
112
112
  }
113
113
  const value = option.value;
114
114
  if (value instanceof ResolvedDataSpaceEntityWithOrigin) {
115
+ queryBuilderState.queryAgentChatState?.abort();
115
116
  queryBuilderState
116
117
  .onDataSpaceChange(value)
117
118
  .catch(queryBuilderState.applicationStore.alertUnhandledError);
118
119
  } else if (value instanceof DepotEntityWithOrigin) {
120
+ queryBuilderState.queryAgentChatState?.abort();
119
121
  queryBuilderState.onDataProductChange(value);
120
122
  }
121
123
  };
package/src/index.ts CHANGED
@@ -21,6 +21,8 @@ export * from './application/LegendQueryPluginManager.js';
21
21
 
22
22
  export * from './__lib__/LegendQueryEvent.js';
23
23
  export * from './__lib__/LegendQueryEventHelper.js';
24
+ export { LegendQueryTelemetryHelper } from './__lib__/LegendQueryTelemetryHelper.js';
25
+ export { LegendQueryAgentChatTelemetryHelper } from './__lib__/LegendQueryAgentChatTelemetryHelper.js';
24
26
  export {
25
27
  generateExistingQueryEditorRoute,
26
28
  generateServiceQueryCreatorRoute,
@@ -280,6 +280,7 @@ export class QueryCreatorState {
280
280
  artifactId: query.artifactId,
281
281
  versionId: query.versionId,
282
282
  },
283
+ ...queryBuilderState.getExtraTelemetryMetadata(),
283
284
  },
284
285
  );
285
286
  queryBuilderState.changeDetectionState.initialize(rawLambda);
@@ -1764,6 +1765,7 @@ export class ExistingQueryUpdateState {
1764
1765
  artifactId: query.artifactId,
1765
1766
  versionId: query.versionId,
1766
1767
  },
1768
+ ...queryBuilderState.getExtraTelemetryMetadata(),
1767
1769
  },
1768
1770
  );
1769
1771
  config.onQueryUpdate?.(updatedQuery);
@@ -1800,6 +1802,8 @@ export class ExistingQueryUpdateState {
1800
1802
  `Successfully updated query!`,
1801
1803
  );
1802
1804
 
1805
+ const extraTelemetryMetadata =
1806
+ this.editorStore.queryBuilderState?.getExtraTelemetryMetadata() ?? {};
1803
1807
  LegendQueryTelemetryHelper.logEvent_UpdateQuerySucceeded(
1804
1808
  this.editorStore.applicationStore.telemetryService,
1805
1809
  {
@@ -1810,6 +1814,7 @@ export class ExistingQueryUpdateState {
1810
1814
  artifactId: updatedQuery.artifactId,
1811
1815
  versionId: updatedQuery.versionId,
1812
1816
  },
1817
+ ...extraTelemetryMetadata,
1813
1818
  },
1814
1819
  );
1815
1820
  } catch (error) {
package/tsconfig.json CHANGED
@@ -54,6 +54,7 @@
54
54
  "./src/index.ts",
55
55
  "./src/__lib__/DSL_DataSpace_LegendQueryDocumentation.ts",
56
56
  "./src/__lib__/DSL_DataSpace_LegendQueryNavigation.ts",
57
+ "./src/__lib__/LegendQueryAgentChatTelemetryHelper.ts",
57
58
  "./src/__lib__/LegendQueryApplicationNavigationContext.ts",
58
59
  "./src/__lib__/LegendQueryEvent.ts",
59
60
  "./src/__lib__/LegendQueryEventHelper.ts",