@gooddata/sdk-ui-analytical-designer 11.69.0-alpha.2 → 11.69.0-alpha.4

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 (116) hide show
  1. package/NOTICE +47 -47
  2. package/esm/actions/data_actions.d.ts +2 -1
  3. package/esm/actions/data_actions.d.ts.map +1 -1
  4. package/esm/actions/data_actions.js +2 -2
  5. package/esm/backend.d.ts +15 -1
  6. package/esm/backend.d.ts.map +1 -1
  7. package/esm/backend.js +26 -2
  8. package/esm/components/DeleteReportDialog.d.ts.map +1 -1
  9. package/esm/components/DeleteReportDialog.js +12 -8
  10. package/esm/components/DeleteReportDialogUsageList.d.ts +2 -4
  11. package/esm/components/DeleteReportDialogUsageList.d.ts.map +1 -1
  12. package/esm/components/DeleteReportDialogUsageList.js +10 -7
  13. package/esm/components/InsightUsageOnDashboards.d.ts.map +1 -1
  14. package/esm/components/InsightUsageOnDashboards.js +16 -8
  15. package/esm/components/Report.d.ts +3 -1
  16. package/esm/components/Report.d.ts.map +1 -1
  17. package/esm/components/Report.js +13 -4
  18. package/esm/components/SaveReportFromKDDialog.js +1 -1
  19. package/esm/components/filterBar/dateFilter/PresetSection/supportedPresetsHook.d.ts +1 -0
  20. package/esm/components/filterBar/dateFilter/PresetSection/supportedPresetsHook.d.ts.map +1 -1
  21. package/esm/components/filterBar/dateFilter/PresetSection/supportedPresetsHook.js +1 -0
  22. package/esm/components/header/EditorActions.d.ts +1 -0
  23. package/esm/components/header/EditorActions.d.ts.map +1 -1
  24. package/esm/components/header/EditorActions.js +1 -0
  25. package/esm/components/header/OptionsMenu/useOptionsProps.d.ts +1 -0
  26. package/esm/components/header/OptionsMenu/useOptionsProps.d.ts.map +1 -1
  27. package/esm/components/header/OptionsMenu/useOptionsProps.js +1 -0
  28. package/esm/components/report/executionProgress/ExecutionProgressPanel.d.ts +12 -0
  29. package/esm/components/report/executionProgress/ExecutionProgressPanel.d.ts.map +1 -0
  30. package/esm/components/report/executionProgress/ExecutionProgressPanel.js +157 -0
  31. package/esm/components/report/executionProgress/ExecutionProgressSteps.d.ts +17 -0
  32. package/esm/components/report/executionProgress/ExecutionProgressSteps.d.ts.map +1 -0
  33. package/esm/components/report/executionProgress/ExecutionProgressSteps.js +122 -0
  34. package/esm/components/report/executionProgress/ExecutionStats.d.ts +10 -0
  35. package/esm/components/report/executionProgress/ExecutionStats.d.ts.map +1 -0
  36. package/esm/components/report/executionProgress/ExecutionStats.js +105 -0
  37. package/esm/components/report/executionProgress/timeline.d.ts +34 -0
  38. package/esm/components/report/executionProgress/timeline.d.ts.map +1 -0
  39. package/esm/components/report/executionProgress/timeline.js +51 -0
  40. package/esm/components/saveReportFromKD/InsightUsageOnDashboardsList.d.ts +2 -2
  41. package/esm/components/saveReportFromKD/InsightUsageOnDashboardsList.d.ts.map +1 -1
  42. package/esm/components/saveReportFromKD/InsightUsageOnDashboardsList.js +13 -6
  43. package/esm/models/metadata.d.ts +3 -0
  44. package/esm/models/metadata.d.ts.map +1 -1
  45. package/esm/models/metadata.js +3 -0
  46. package/esm/reducers/combined_root_reducer.d.ts +3 -0
  47. package/esm/reducers/combined_root_reducer.d.ts.map +1 -1
  48. package/esm/reducers/combined_root_reducer.js +2 -0
  49. package/esm/sagas/execute_report_sagas.d.ts +1 -0
  50. package/esm/sagas/execute_report_sagas.d.ts.map +1 -1
  51. package/esm/sagas/open_report_sagas.d.ts +3 -1
  52. package/esm/sagas/open_report_sagas.d.ts.map +1 -1
  53. package/esm/sagas/open_report_sagas.js +7 -2
  54. package/esm/sagas/sagas.d.ts.map +1 -1
  55. package/esm/sagas/sagas.js +4 -0
  56. package/esm/selectors/feature_flag_selector.d.ts +23 -2
  57. package/esm/selectors/feature_flag_selector.d.ts.map +1 -1
  58. package/esm/selectors/feature_flag_selector.js +2 -0
  59. package/esm/selectors/report_selector.js +1 -1
  60. package/esm/selectors/report_visualization_selector.d.ts +4 -0
  61. package/esm/selectors/report_visualization_selector.d.ts.map +1 -1
  62. package/esm/selectors/save_report_from_kd_dialog_selector.d.ts +10 -10
  63. package/esm/selectors/save_report_selector.d.ts +12 -12
  64. package/esm/selectors/save_report_selector.js +1 -1
  65. package/esm/services/buckets_service.d.ts +1 -0
  66. package/esm/services/buckets_service.d.ts.map +1 -1
  67. package/esm/store/execution_progress/execution_loading_view_model.d.ts +72 -0
  68. package/esm/store/execution_progress/execution_loading_view_model.d.ts.map +1 -0
  69. package/esm/store/execution_progress/execution_loading_view_model.js +122 -0
  70. package/esm/store/execution_progress/execution_progress_actions.d.ts +42 -0
  71. package/esm/store/execution_progress/execution_progress_actions.d.ts.map +1 -0
  72. package/esm/store/execution_progress/execution_progress_actions.js +19 -0
  73. package/esm/store/execution_progress/execution_progress_mock.d.ts +31 -0
  74. package/esm/store/execution_progress/execution_progress_mock.d.ts.map +1 -0
  75. package/esm/store/execution_progress/execution_progress_mock.js +458 -0
  76. package/esm/store/execution_progress/execution_progress_saga.d.ts +56 -0
  77. package/esm/store/execution_progress/execution_progress_saga.d.ts.map +1 -0
  78. package/esm/store/execution_progress/execution_progress_saga.js +226 -0
  79. package/esm/store/execution_progress/execution_progress_selectors.d.ts +66 -0
  80. package/esm/store/execution_progress/execution_progress_selectors.d.ts.map +1 -0
  81. package/esm/store/execution_progress/execution_progress_selectors.js +7 -0
  82. package/esm/store/execution_progress/execution_progress_slice.d.ts +4 -0
  83. package/esm/store/execution_progress/execution_progress_slice.d.ts.map +1 -0
  84. package/esm/store/execution_progress/execution_progress_slice.js +95 -0
  85. package/esm/store/execution_progress/execution_progress_state.d.ts +54 -0
  86. package/esm/store/execution_progress/execution_progress_state.d.ts.map +1 -0
  87. package/esm/store/execution_progress/execution_progress_state.js +12 -0
  88. package/esm/store/execution_progress/execution_progress_view_model.d.ts +136 -0
  89. package/esm/store/execution_progress/execution_progress_view_model.d.ts.map +1 -0
  90. package/esm/store/execution_progress/execution_progress_view_model.js +378 -0
  91. package/esm/store/execution_progress/execution_stats_view_model.d.ts +42 -0
  92. package/esm/store/execution_progress/execution_stats_view_model.d.ts.map +1 -0
  93. package/esm/store/execution_progress/execution_stats_view_model.js +51 -0
  94. package/esm/store/insight_usage/insight_usage_helpers.d.ts +13 -3
  95. package/esm/store/insight_usage/insight_usage_helpers.d.ts.map +1 -1
  96. package/esm/store/insight_usage/insight_usage_helpers.js +37 -1
  97. package/esm/store/insight_usage/insight_usage_selectors.d.ts +5 -6
  98. package/esm/store/insight_usage/insight_usage_selectors.d.ts.map +1 -1
  99. package/esm/store/insight_usage/insight_usage_selectors.js +5 -4
  100. package/esm/store/insight_usage/insight_usage_slice.d.ts.map +1 -1
  101. package/esm/store/insight_usage/insight_usage_slice.js +1 -0
  102. package/esm/store/insight_usage/insight_usage_state.d.ts +8 -0
  103. package/esm/store/insight_usage/insight_usage_state.d.ts.map +1 -1
  104. package/esm/store/types.d.ts +3 -0
  105. package/esm/store/types.d.ts.map +1 -1
  106. package/esm/translations/en-US.json +196 -0
  107. package/esm/utils/api.d.ts +6 -1
  108. package/esm/utils/api.d.ts.map +1 -1
  109. package/esm/utils/api.js +28 -0
  110. package/package.json +21 -21
  111. package/styles/css/execution_progress.css +486 -0
  112. package/styles/css/execution_progress.css.map +1 -0
  113. package/styles/css/main.css +485 -0
  114. package/styles/css/main.css.map +1 -1
  115. package/styles/scss/_ad_partials.scss +1 -0
  116. package/styles/scss/execution_progress.scss +547 -0
@@ -0,0 +1,378 @@
1
+ // (C) 2026 GoodData Corporation
2
+ const BLENDING_INPUT_ROLE = "blendingInput";
3
+ const STEP_ORDER = [
4
+ "preparing",
5
+ "sqlGeneration",
6
+ "federation",
7
+ "query",
8
+ "postprocessing",
9
+ ];
10
+ /**
11
+ * Builds the view model of the execution progress panel from the received progress events.
12
+ *
13
+ * The backend reports events per computation (resultId); the root computation is the one without
14
+ * a parent. The steps are derived from the whole computation tree:
15
+ *
16
+ * - Preparing — from the root start until the first later milestone.
17
+ * - Generating SQL — SQL_GENERATION_STARTED … SQL_GENERATION_FINISHED.
18
+ * - Data federation — the children with the `blendingInput` role, one entry per data source.
19
+ * - Querying — DATABASE_QUERY_REQUESTED … FINISHED of a non-federated computation.
20
+ * - Post-processing — POSTPROCESSING_STARTED … root FINISHED.
21
+ *
22
+ * A step without an explicit end is done once a later step started.
23
+ */
24
+ export function buildExecutionProgressViewModel(state) {
25
+ const base = {
26
+ source: state.source,
27
+ reportStartedAt: state.reportStartedAt ?? undefined,
28
+ reportFinishedAt: state.reportFinishedAt ?? undefined,
29
+ };
30
+ if (state.source === "browserCache") {
31
+ return {
32
+ ...base,
33
+ phase: state.reportFinishedAt === null ? "running" : "finished",
34
+ unavailable: false,
35
+ hasEvents: false,
36
+ cacheHit: false,
37
+ clockOffsetMs: 0,
38
+ steps: [],
39
+ };
40
+ }
41
+ const events = state.events.map((received) => received.event);
42
+ if (events.length === 0) {
43
+ return {
44
+ ...base,
45
+ phase: state.streamStatus === "idle" ? "finished" : "waiting",
46
+ unavailable: state.streamStatus === "failed" || state.streamStatus === "done",
47
+ hasEvents: false,
48
+ cacheHit: false,
49
+ clockOffsetMs: 0,
50
+ steps: [],
51
+ };
52
+ }
53
+ const clockOffsetMs = Math.min(...state.events.map(({ event, receivedAt }) => receivedAt - event.timestamp));
54
+ const byResult = groupByResult(events);
55
+ const rootResultId = events.find((event) => !event.parentResultId)?.resultId ?? events[0].resultId;
56
+ const rootEvents = byResult.get(rootResultId) ?? [];
57
+ const rootStarted = findEvent(rootEvents, "STARTED")?.timestamp ?? events[0].timestamp;
58
+ const rootFinished = findEvent(rootEvents, "FINISHED");
59
+ const failed = rootFinished?.status === "failure";
60
+ const finished = rootFinished !== undefined || state.streamStatus === "done";
61
+ const phase = failed ? "failed" : finished ? "finished" : "running";
62
+ const cacheHit = findEvent(rootEvents, "CACHE_HIT") !== undefined || rootFinished?.cacheHit === true;
63
+ const common = {
64
+ ...base,
65
+ phase,
66
+ unavailable: false,
67
+ hasEvents: true,
68
+ cacheHit,
69
+ startedAt: rootStarted,
70
+ finishedAt: rootFinished?.timestamp,
71
+ childrenRequestedAt: findEvent(rootEvents, "CHILDREN_REQUESTED")?.timestamp,
72
+ clockOffsetMs,
73
+ };
74
+ // the events received before a stream failure are kept, but no more will come
75
+ const commonWithStream = { ...common, unavailable: state.streamStatus === "failed" };
76
+ if (cacheHit) {
77
+ const profile = findEvent(rootEvents, "CACHE_HIT")?.profile ??
78
+ (rootFinished?.cacheHit ? rootFinished.profile : null);
79
+ const original = buildOriginalComputation(profile);
80
+ return original ? { ...commonWithStream, original, steps: [] } : { ...commonWithStream, steps: [] };
81
+ }
82
+ const drafts = buildStepDrafts(events, byResult, rootStarted, rootFinished, finished);
83
+ const steps = resolveStepStates(drafts, phase, rootFinished?.timestamp);
84
+ return { ...commonWithStream, steps };
85
+ }
86
+ const definedNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
87
+ export function buildOriginalComputation(profile) {
88
+ const sources = (profile?.sources ?? [])
89
+ .map((source) => ({
90
+ dataSourceId: source.dataSourceId ?? undefined,
91
+ dataSourceName: source.dataSourceName ?? undefined,
92
+ queryingMs: definedNumber(source.queryDurationMs) ?? definedNumber(source.totalDurationMs),
93
+ dbDurationMs: definedNumber(source.dbDurationMs),
94
+ totalDurationMs: definedNumber(source.totalDurationMs),
95
+ rows: definedNumber(source.rows),
96
+ }))
97
+ .sort((a, b) => (b.queryingMs ?? -1) - (a.queryingMs ?? -1));
98
+ const totalDurationMs = definedNumber(profile?.totalDurationMs);
99
+ if (sources.length === 0 && totalDurationMs === undefined) {
100
+ return undefined;
101
+ }
102
+ const durations = sources.flatMap((source) => source.queryingMs === undefined ? [] : [source.queryingMs]);
103
+ return {
104
+ computedAt: definedNumber(profile?.computedAt),
105
+ totalDurationMs,
106
+ totalApproximate: totalDurationMs !== undefined && !!profile?.finishedAtApprox,
107
+ sources,
108
+ originalTotalMs: totalDurationMs ?? (durations.length > 0 ? Math.max(...durations) : undefined),
109
+ originalTotalApproximate: totalDurationMs === undefined || !!profile?.finishedAtApprox,
110
+ };
111
+ }
112
+ function buildStepDrafts(events, byResult, rootStarted, rootFinished, finished) {
113
+ const children = collectChildren(events);
114
+ const blendingInputIds = [...children.values()]
115
+ .filter((child) => child.role === BLENDING_INPUT_ROLE)
116
+ .map((child) => child.resultId);
117
+ const isBlendingInput = (resultId) => blendingInputIds.includes(resultId);
118
+ // the request of the blending inputs: their parent's CHILDREN_REQUESTED, even when the role
119
+ // arrived only with a child's own events
120
+ const federationRequested = events.find((event) => event.type === "CHILDREN_REQUESTED" &&
121
+ (event.children ?? []).some((child) => isBlendingInput(child.resultId)));
122
+ const sqlStarts = events.filter((event) => event.type === "SQL_GENERATION_STARTED");
123
+ const sqlFinishes = events.filter((event) => event.type === "SQL_GENERATION_FINISHED");
124
+ const queryRequests = events.filter((event) => event.type === "DATABASE_QUERY_REQUESTED" && !isBlendingInput(event.resultId));
125
+ const postprocessing = events.filter((event) => event.type === "POSTPROCESSING_STARTED");
126
+ const drafts = [];
127
+ // the first milestone after the preparation, whichever comes first
128
+ const milestones = [
129
+ ...sqlStarts,
130
+ ...queryRequests,
131
+ ...postprocessing,
132
+ ...(federationRequested ? [federationRequested] : []),
133
+ ].map((event) => event.timestamp);
134
+ drafts.push({
135
+ kind: "preparing",
136
+ startedAt: rootStarted,
137
+ finishedAt: milestones.length > 0 ? Math.min(...milestones) : undefined,
138
+ });
139
+ if (sqlStarts.length > 0) {
140
+ const allFinished = sqlStarts.every((start) => sqlFinishes.some((end) => end.resultId === start.resultId));
141
+ drafts.push({
142
+ kind: "sqlGeneration",
143
+ startedAt: Math.min(...sqlStarts.map((event) => event.timestamp)),
144
+ finishedAt: allFinished ? Math.max(...sqlFinishes.map((event) => event.timestamp)) : undefined,
145
+ dataSourceId: sqlStarts.find((event) => event.dataSourceId)?.dataSourceId ?? undefined,
146
+ dataSourceName: sqlStarts.find((event) => event.dataSourceName)?.dataSourceName ?? undefined,
147
+ });
148
+ }
149
+ if (federationRequested) {
150
+ const sources = blendingInputIds.map((resultId) => buildSource(resultId, children.get(resultId), byResult.get(resultId) ?? []));
151
+ const allSettled = sources.length > 0 && sources.every((source) => source.finishedAt !== undefined);
152
+ drafts.push({
153
+ kind: "federation",
154
+ startedAt: federationRequested.timestamp,
155
+ finishedAt: allSettled ? Math.max(...sources.map((source) => source.finishedAt)) : undefined,
156
+ state: sources.some((source) => source.state === "failed") ? "failed" : undefined,
157
+ sources,
158
+ slowestSourceResultId: findSlowestSource(sources),
159
+ });
160
+ }
161
+ else if (queryRequests.length > 0) {
162
+ const queried = queryRequests.map((request) => buildSource(request.resultId, {
163
+ dataSourceId: request.dataSourceId ?? children.get(request.resultId)?.dataSourceId,
164
+ dataSourceName: request.dataSourceName ?? children.get(request.resultId)?.dataSourceName,
165
+ }, byResult.get(request.resultId) ?? []));
166
+ const named = queried.find((source) => source.dataSourceId);
167
+ const allSettled = queried.every((source) => source.finishedAt !== undefined);
168
+ drafts.push({
169
+ kind: "query",
170
+ startedAt: Math.min(...queryRequests.map((event) => event.timestamp)),
171
+ finishedAt: allSettled ? Math.max(...queried.map((source) => source.finishedAt)) : undefined,
172
+ state: queried.some((source) => source.state === "failed") ? "failed" : undefined,
173
+ dataSourceId: named?.dataSourceId,
174
+ dataSourceName: named?.dataSourceName,
175
+ queryBreakdown: queryRequests.length === 1
176
+ ? computeQueryBreakdown(byResult.get(queryRequests[0].resultId) ?? [])
177
+ : undefined,
178
+ });
179
+ }
180
+ else {
181
+ // a child served from the raw cache never queries its data source
182
+ const rawCacheHit = events.find((event) => event.type === "FINISHED" && event.parentResultId && event.cacheHit === true);
183
+ if (rawCacheHit) {
184
+ const childStarted = findEvent(byResult.get(rawCacheHit.resultId) ?? [], "STARTED");
185
+ drafts.push({
186
+ kind: "query",
187
+ startedAt: childStarted?.timestamp ?? rawCacheHit.timestamp,
188
+ finishedAt: rawCacheHit.timestamp,
189
+ cacheHit: true,
190
+ dataSourceId: rawCacheHit.dataSourceId ?? children.get(rawCacheHit.resultId)?.dataSourceId ?? undefined,
191
+ dataSourceName: rawCacheHit.dataSourceName ??
192
+ children.get(rawCacheHit.resultId)?.dataSourceName ??
193
+ undefined,
194
+ });
195
+ }
196
+ else if (!finished) {
197
+ drafts.push({ kind: "query", placeholder: true });
198
+ }
199
+ }
200
+ if (postprocessing.length > 0) {
201
+ drafts.push({
202
+ kind: "postprocessing",
203
+ startedAt: Math.min(...postprocessing.map((event) => event.timestamp)),
204
+ finishedAt: rootFinished?.timestamp,
205
+ postprocessingTypes: unique(postprocessing.map((event) => event.postprocessingType).filter((type) => !!type)),
206
+ });
207
+ }
208
+ else if (!finished) {
209
+ drafts.push({ kind: "postprocessing", placeholder: true });
210
+ }
211
+ return drafts.sort((a, b) => STEP_ORDER.indexOf(a.kind) - STEP_ORDER.indexOf(b.kind));
212
+ }
213
+ function resolveStepStates(drafts, phase, rootFinishedAt) {
214
+ return drafts.map((draft, index) => {
215
+ const { placeholder, ...step } = draft;
216
+ if (placeholder || step.startedAt === undefined) {
217
+ return { ...step, state: "pending" };
218
+ }
219
+ if (step.state === "failed") {
220
+ return { ...step, state: "failed" };
221
+ }
222
+ if (step.finishedAt !== undefined) {
223
+ return { ...step, state: "done" };
224
+ }
225
+ // a federation ends with its sources (or the root), not with a later step: the
226
+ // post-processing of a source that finished early must not settle the others
227
+ const sourcesUnsettled = step.sources?.some((source) => source.finishedAt === undefined) ?? false;
228
+ const nextStart = sourcesUnsettled
229
+ ? undefined
230
+ : drafts
231
+ .slice(index + 1)
232
+ .map((next) => next.startedAt)
233
+ .find((startedAt) => startedAt !== undefined);
234
+ if (nextStart !== undefined) {
235
+ return { ...step, state: "done", finishedAt: nextStart };
236
+ }
237
+ if (phase === "failed") {
238
+ return { ...step, state: "failed", finishedAt: rootFinishedAt };
239
+ }
240
+ if (phase === "finished") {
241
+ return { ...step, state: "done", finishedAt: rootFinishedAt };
242
+ }
243
+ return { ...step, state: "running" };
244
+ });
245
+ }
246
+ function buildSource(resultId, dataSource, events) {
247
+ const requested = findEvent(events, "DATABASE_QUERY_REQUESTED");
248
+ const started = findEvent(events, "STARTED");
249
+ const dbStarted = findEvent(events, "DATABASE_QUERY_STARTED");
250
+ const finished = findEvent(events, "FINISHED");
251
+ const startedAt = requested?.timestamp ?? started?.timestamp;
252
+ const state = finished
253
+ ? finished.status === "failure"
254
+ ? "failed"
255
+ : "done"
256
+ : startedAt === undefined
257
+ ? "pending"
258
+ : "running";
259
+ return {
260
+ resultId,
261
+ dataSourceId: dataSource?.dataSourceId ?? events.find((event) => event.dataSourceId)?.dataSourceId ?? undefined,
262
+ dataSourceName: dataSource?.dataSourceName ??
263
+ events.find((event) => event.dataSourceName)?.dataSourceName ??
264
+ undefined,
265
+ state,
266
+ startedAt,
267
+ finishedAt: finished?.timestamp,
268
+ queuedMs: computeQueuedMs(requested, dbStarted, finished),
269
+ cacheHit: finished?.cacheHit === true,
270
+ };
271
+ }
272
+ /**
273
+ * The wait between the query request and the data source starting it. Only meaningful when it is
274
+ * a real part of the query: positive and shorter than the whole request → finish span.
275
+ */
276
+ function computeQueuedMs(requested, dbStarted, finished) {
277
+ if (!requested || !dbStarted) {
278
+ return undefined;
279
+ }
280
+ const queuedMs = dbStarted.timestamp - requested.timestamp;
281
+ const totalMs = finished ? finished.timestamp - requested.timestamp : undefined;
282
+ if (queuedMs <= 0 || (totalMs !== undefined && queuedMs >= totalMs)) {
283
+ return undefined;
284
+ }
285
+ return queuedMs;
286
+ }
287
+ const timingOf = (event, key) => {
288
+ const value = event.timing?.[key];
289
+ return typeof value === "number" ? definedNumber(value) : undefined;
290
+ };
291
+ /**
292
+ * Where the time of a finished query went, from the FINISHED timing (or the late milestone events):
293
+ * waiting = query start − request, database = streaming start − query start, transfer = finish −
294
+ * streaming start. Undefined until the query finished, for a raw cache hit, or when a milestone is
295
+ * missing or out of order.
296
+ */
297
+ function computeQueryBreakdown(events) {
298
+ const finished = findEvent(events, "FINISHED");
299
+ if (!finished || finished.cacheHit === true || finished.status === "failure") {
300
+ return undefined;
301
+ }
302
+ const requested = timingOf(finished, "databaseQueryRequested") ??
303
+ findEvent(events, "DATABASE_QUERY_REQUESTED")?.timestamp;
304
+ const queryStarted = timingOf(finished, "databaseQueryStarted") ?? findEvent(events, "DATABASE_QUERY_STARTED")?.timestamp;
305
+ const streamingStarted = timingOf(finished, "databaseQueryResultsStreamingStarted") ??
306
+ findEvent(events, "DATABASE_QUERY_RESULT_STREAMING_STARTED")?.timestamp;
307
+ const end = finished.timestamp;
308
+ if (requested === undefined || queryStarted === undefined || streamingStarted === undefined) {
309
+ return undefined;
310
+ }
311
+ if (!(requested <= queryStarted && queryStarted <= streamingStarted && streamingStarted <= end)) {
312
+ return undefined;
313
+ }
314
+ return {
315
+ waitingMs: queryStarted - requested,
316
+ databaseMs: streamingStarted - queryStarted,
317
+ transferMs: end - streamingStarted,
318
+ };
319
+ }
320
+ /**
321
+ * While sources run, the one waited on is the running one that started first (it has been running
322
+ * the longest). Once all settled, the one with the longest duration.
323
+ */
324
+ function findSlowestSource(sources) {
325
+ const running = sources.filter((source) => source.state === "running" && source.startedAt !== undefined);
326
+ if (running.length > 0) {
327
+ return running.reduce((slowest, source) => source.startedAt < slowest.startedAt ? source : slowest).resultId;
328
+ }
329
+ const settled = sources.filter((source) => source.startedAt !== undefined && source.finishedAt !== undefined);
330
+ if (settled.length === 0) {
331
+ return undefined;
332
+ }
333
+ return settled.reduce((slowest, source) => source.finishedAt - source.startedAt > slowest.finishedAt - slowest.startedAt ? source : slowest).resultId;
334
+ }
335
+ function collectChildren(events) {
336
+ const children = new Map();
337
+ events.forEach((event) => {
338
+ const merge = (resultId, info) => {
339
+ const known = children.get(resultId);
340
+ children.set(resultId, {
341
+ resultId,
342
+ role: known?.role ?? info.role ?? undefined,
343
+ dataSourceId: known?.dataSourceId ?? info.dataSourceId ?? undefined,
344
+ dataSourceName: known?.dataSourceName ?? info.dataSourceName ?? undefined,
345
+ });
346
+ };
347
+ (event.children ?? []).forEach((child) => merge(child.resultId, child));
348
+ // a child's own events may carry its role and data source as well
349
+ if (event.parentResultId) {
350
+ merge(event.resultId, event);
351
+ }
352
+ });
353
+ return children;
354
+ }
355
+ function groupByResult(events) {
356
+ const byResult = new Map();
357
+ events.forEach((event) => {
358
+ const list = byResult.get(event.resultId) ?? [];
359
+ list.push(event);
360
+ byResult.set(event.resultId, list);
361
+ });
362
+ return byResult;
363
+ }
364
+ function findEvent(events, type) {
365
+ return events.find((event) => event.type === type);
366
+ }
367
+ function unique(values) {
368
+ return [...new Set(values)];
369
+ }
370
+ export function computeCacheSaving(original, thisLoadMs) {
371
+ if (original.originalTotalMs !== undefined && thisLoadMs !== undefined) {
372
+ const savedMs = original.originalTotalMs - thisLoadMs;
373
+ if (savedMs > 0) {
374
+ return { kind: "time", savedMs, approximate: original.originalTotalApproximate };
375
+ }
376
+ }
377
+ return { kind: "queries", count: Math.max(original.sources.length, 1) };
378
+ }
@@ -0,0 +1,42 @@
1
+ import { type IExecutionProgressState } from "./execution_progress_state.js";
2
+ import { type ExecutionCacheSaving, type IExecutionProgressOriginalViewModel, type IExecutionProgressViewModel } from "./execution_progress_view_model.js";
3
+ /**
4
+ * How the result of the last report execution was loaded:
5
+ *
6
+ * - `fresh` — computed by the backend, querying the data sources.
7
+ * - `cacheHit` — served from the backend result cache.
8
+ * - `browserCache` — served from the client-side execution cache, no request sent.
9
+ * - `unknown` — no progress arrived for the execution.
10
+ */
11
+ export type ExecutionStatsLoadKind = "fresh" | "cacheHit" | "browserCache" | "unknown";
12
+ /**
13
+ * - `missing` — the backend stored no statistics for the result (e.g. cached before they existed).
14
+ * - `unavailable` — the result is not known, nothing can be loaded.
15
+ */
16
+ export type ExecutionStatsOriginalStatus = "idle" | "loading" | "loaded" | "missing" | "failed" | "unavailable";
17
+ export interface IExecutionStatsViewModel {
18
+ /** a settled report execution exists to show the stats of */
19
+ available: boolean;
20
+ reportExecutionId?: string;
21
+ load: ExecutionStatsLoadKind;
22
+ failed: boolean;
23
+ /** how long this load took: server time of the root computation, else the client one */
24
+ totalMs?: number;
25
+ /** the steps of this load, as the progress panel showed them */
26
+ progress: IExecutionProgressViewModel;
27
+ /** how the result was originally computed; not for a fresh load, which is its own original */
28
+ showsOriginal: boolean;
29
+ original: {
30
+ status: ExecutionStatsOriginalStatus;
31
+ computation?: IExecutionProgressOriginalViewModel;
32
+ };
33
+ /** on a cache hit with the original computation known: what the cache saved */
34
+ saved?: ExecutionCacheSaving;
35
+ }
36
+ /**
37
+ * Builds the execution stats of the last settled report execution: how this load went (from the
38
+ * progress events kept until the next execution starts) and how the result was originally computed
39
+ * (from the profile stored with the result, loaded lazily).
40
+ */
41
+ export declare function buildExecutionStatsViewModel(state: IExecutionProgressState, progress?: IExecutionProgressViewModel): IExecutionStatsViewModel;
42
+ //# sourceMappingURL=execution_stats_view_model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution_stats_view_model.d.ts","sourceRoot":"","sources":["../../../src/store/execution_progress/execution_stats_view_model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACH,KAAK,oBAAoB,EACzB,KAAK,mCAAmC,EACxC,KAAK,2BAA2B,EAInC,MAAM,oCAAoC,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,CAAC;AAEvF;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAClC,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,aAAa,CAAC;AAEpB,MAAM,WAAW,wBAAwB;IACrC,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,sBAAsB,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,QAAQ,EAAE,2BAA2B,CAAC;IACtC,8FAA8F;IAC9F,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE;QACN,MAAM,EAAE,4BAA4B,CAAC;QACrC,WAAW,CAAC,EAAE,mCAAmC,CAAC;KACrD,CAAC;IACF,+EAA+E;IAC/E,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CACxC,KAAK,EAAE,uBAAuB,EAC9B,QAAQ,GAAE,2BAAoE,GAC/E,wBAAwB,CAuC1B"}
@@ -0,0 +1,51 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { buildExecutionProgressViewModel, buildOriginalComputation, computeCacheSaving, } from "./execution_progress_view_model.js";
3
+ /**
4
+ * Builds the execution stats of the last settled report execution: how this load went (from the
5
+ * progress events kept until the next execution starts) and how the result was originally computed
6
+ * (from the profile stored with the result, loaded lazily).
7
+ */
8
+ export function buildExecutionStatsViewModel(state, progress = buildExecutionProgressViewModel(state)) {
9
+ const available = state.reportExecutionId !== null && state.reportFinishedAt !== null;
10
+ const load = state.source === "browserCache"
11
+ ? "browserCache"
12
+ : progress.cacheHit
13
+ ? "cacheHit"
14
+ : progress.hasEvents
15
+ ? "fresh"
16
+ : "unknown";
17
+ const reportSpan = state.reportStartedAt !== null && state.reportFinishedAt !== null
18
+ ? state.reportFinishedAt - state.reportStartedAt
19
+ : undefined;
20
+ const serverSpan = progress.startedAt !== undefined && progress.finishedAt !== undefined
21
+ ? progress.finishedAt - progress.startedAt
22
+ : undefined;
23
+ const totalMs = load === "fresh" || load === "cacheHit" ? (serverSpan ?? reportSpan) : reportSpan;
24
+ const original = buildOriginal(state, progress);
25
+ const saved = load === "cacheHit" && original.computation
26
+ ? computeCacheSaving(original.computation, totalMs)
27
+ : undefined;
28
+ return {
29
+ available,
30
+ reportExecutionId: state.reportExecutionId ?? undefined,
31
+ load,
32
+ failed: progress.phase === "failed",
33
+ totalMs,
34
+ progress,
35
+ showsOriginal: load !== "fresh",
36
+ original,
37
+ ...(saved ? { saved } : {}),
38
+ };
39
+ }
40
+ function buildOriginal(state, progress) {
41
+ const { status, profile } = state.storedProfile;
42
+ if (status === "loaded") {
43
+ const computation = buildOriginalComputation(profile);
44
+ return computation ? { status: "loaded", computation } : { status: "missing" };
45
+ }
46
+ // a cache hit already told how the result was computed, no need to wait for the metadata
47
+ if (progress.original) {
48
+ return { status: "loaded", computation: progress.original };
49
+ }
50
+ return { status };
51
+ }
@@ -1,7 +1,17 @@
1
- import { type IListedDashboard, type IMetadataObject } from "@gooddata/sdk-model";
2
- import { type IInsightUsageInDocumentItem, type IInsightUsageOnDashboard, type IInsightUsageOnDashboardItem } from "./insight_usage_state.js";
1
+ import { type IPublisherDocumentSummaryV2 } from "@gooddata/sdk-backend-spi";
2
+ import { type IListedDashboard, type IMetadataObject, type IWorkspacePermissions } from "@gooddata/sdk-model";
3
+ import { type IInsightUsageInDocuments, type IInsightUsageOnDashboard, type IInsightUsageOnDashboardItem } from "./insight_usage_state.js";
3
4
  export declare const sortDashboards: (dashboards: IInsightUsageOnDashboardItem[], sourceDashboardId: string) => IInsightUsageOnDashboardItem[];
4
5
  export declare const getInsightUsageOnDashboards: (referencedDashboards: IMetadataObject[], allUserDashboards: IListedDashboard[]) => IInsightUsageOnDashboard;
5
- export declare const getInsightUsageInDocuments: (referencedDocuments: IMetadataObject[]) => IInsightUsageInDocumentItem[];
6
+ export declare const canSeeAllDocuments: (permissions: IWorkspacePermissions | null) => boolean;
7
+ /**
8
+ * Whether Publisher shows the user a document. A user who may create documents sees all of them. Anyone
9
+ * else sees only the ones they can still edit: their own, unless inherited from a parent workspace.
10
+ * Unknown permissions show the document, as Publisher does.
11
+ */
12
+ export declare const isDocumentShown: (document: Pick<IPublisherDocumentSummaryV2, "isLocked" | "createdBy">, userLogin: string | undefined, permissions: IWorkspacePermissions | null) => boolean;
13
+ export declare const getAccessibleDocumentIds: (documents: IPublisherDocumentSummaryV2[], userLogin: string | undefined, permissions: IWorkspacePermissions | null) => string[];
14
+ export declare const getInsightUsageInDocuments: (referencedDocuments: IMetadataObject[], accessibleDocumentIds: string[]) => IInsightUsageInDocuments;
6
15
  export declare const EMPTY_INSIGHT_USAGE_ON_DASHBOARDS: IInsightUsageOnDashboard;
16
+ export declare const EMPTY_INSIGHT_USAGE_IN_DOCUMENTS: IInsightUsageInDocuments;
7
17
  //# sourceMappingURL=insight_usage_helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"insight_usage_helpers.d.ts","sourceRoot":"","sources":["../../../src/store/insight_usage/insight_usage_helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGlF,OAAO,EACH,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACpC,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,cAAc,eAAgB,4BAA4B,EAAE,qBAAqB,MAAM,mCAO9F,CAAC;AAQP,eAAO,MAAM,2BAA2B,yBACd,eAAe,EAAE,qBACpB,gBAAgB,EAAE,KACtC,wBAeF,CAAC;AAEF,eAAO,MAAM,0BAA0B,wBACd,eAAe,EAAE,KACvC,2BAA2B,EAIzB,CAAC;AAEN,eAAO,MAAM,iCAAiC,EAAE,wBAK/C,CAAC"}
1
+ {"version":3,"file":"insight_usage_helpers.d.ts","sourceRoot":"","sources":["../../../src/store/insight_usage/insight_usage_helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAE7B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACH,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACpC,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,cAAc,eAAgB,4BAA4B,EAAE,qBAAqB,MAAM,mCAO9F,CAAC;AAQP,eAAO,MAAM,2BAA2B,yBACd,eAAe,EAAE,qBACpB,gBAAgB,EAAE,KACtC,wBAeF,CAAC;AAEF,eAAO,MAAM,kBAAkB,gBAAiB,qBAAqB,GAAG,IAAI,KAAG,OAC9B,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,eAAe,aACd,IAAI,CAAC,2BAA2B,EAAE,UAAU,GAAG,WAAW,CAAC,aAC1D,MAAM,GAAG,SAAS,eAChB,qBAAqB,GAAG,IAAI,KAC1C,OAWF,CAAC;AAEF,eAAO,MAAM,wBAAwB,cACtB,2BAA2B,EAAE,aAC7B,MAAM,GAAG,SAAS,eAChB,qBAAqB,GAAG,IAAI,KAC1C,MAAM,EAG+C,CAAC;AAEzD,eAAO,MAAM,0BAA0B,wBACd,eAAe,EAAE,yBACf,MAAM,EAAE,KAChC,wBASF,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,wBAK/C,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,wBAI9C,CAAC"}
@@ -1,4 +1,5 @@
1
1
  // (C) 2020-2026 GoodData Corporation
2
+ import { objRefToString, } from "@gooddata/sdk-model";
2
3
  import { _sortBy } from "@gooddata/util";
3
4
  export const sortDashboards = (dashboards, sourceDashboardId) => _sortBy(dashboards, (dashboardMeta) => {
4
5
  // source dashboard should be placed on the top
@@ -21,10 +22,45 @@ export const getInsightUsageOnDashboards = (referencedDashboards, allUserDashboa
21
22
  allDashboardsCount,
22
23
  };
23
24
  };
24
- export const getInsightUsageInDocuments = (referencedDocuments) => _sortBy(referencedDocuments.map(({ id, title }) => ({ id, title })), (item) => item.title.trim().toLowerCase());
25
+ export const canSeeAllDocuments = (permissions) => !permissions || permissions.canCreateDocument;
26
+ /**
27
+ * Whether Publisher shows the user a document. A user who may create documents sees all of them. Anyone
28
+ * else sees only the ones they can still edit: their own, unless inherited from a parent workspace.
29
+ * Unknown permissions show the document, as Publisher does.
30
+ */
31
+ export const isDocumentShown = (document, userLogin, permissions) => {
32
+ if (canSeeAllDocuments(permissions)) {
33
+ return true;
34
+ }
35
+ if (document.isLocked) {
36
+ return false;
37
+ }
38
+ if (permissions.canManageProject) {
39
+ return true;
40
+ }
41
+ return userLogin !== undefined && document.createdBy?.login === userLogin;
42
+ };
43
+ export const getAccessibleDocumentIds = (documents, userLogin, permissions) => documents
44
+ .filter((document) => isDocumentShown(document, userLogin, permissions))
45
+ .map((document) => objRefToString(document.ref));
46
+ export const getInsightUsageInDocuments = (referencedDocuments, accessibleDocumentIds) => {
47
+ const accessibleDocuments = referencedDocuments
48
+ .filter(({ id }) => accessibleDocumentIds.includes(id))
49
+ .map(({ id, title }) => ({ id, title }));
50
+ return {
51
+ accessibleDocuments: _sortBy(accessibleDocuments, (item) => item.title.trim().toLowerCase()),
52
+ inaccessibleDocumentsCount: referencedDocuments.length - accessibleDocuments.length,
53
+ allDocumentsCount: referencedDocuments.length,
54
+ };
55
+ };
25
56
  export const EMPTY_INSIGHT_USAGE_ON_DASHBOARDS = {
26
57
  accessibleDashboards: [],
27
58
  allDashboards: [],
28
59
  inaccessibleDashboardsCount: 0,
29
60
  allDashboardsCount: 0,
30
61
  };
62
+ export const EMPTY_INSIGHT_USAGE_IN_DOCUMENTS = {
63
+ accessibleDocuments: [],
64
+ inaccessibleDocumentsCount: 0,
65
+ allDocumentsCount: 0,
66
+ };
@@ -1,6 +1,5 @@
1
1
  import { getSourceDashboardId } from "../../selectors/route_selector.js";
2
2
  import { type IAppState } from "../types.js";
3
- import { type IInsightUsageInDocumentItem } from "./insight_usage_state.js";
4
3
  /** The domain's single input selector. */
5
4
  export declare const getInsightUsageState: (state: IAppState) => import("./insight_usage_state.js").IInsightUsageState;
6
5
  /**
@@ -29,19 +28,19 @@ export declare const getInsightUsageOnDashboardsSelector: ((state: IAppState) =>
29
28
  memoize: typeof import("reselect").weakMapMemoize;
30
29
  argsMemoize: typeof import("reselect").weakMapMemoize;
31
30
  };
32
- /** The Publisher documents that show the insight, sorted by title. */
33
- export declare const getInsightUsageInDocumentsSelector: ((state: IAppState) => IInsightUsageInDocumentItem[]) & {
31
+ /** The Publisher documents that show the insight: the ones the user may open, sorted by title, and a count of the rest. */
32
+ export declare const getInsightUsageInDocumentsSelector: ((state: IAppState) => import("./insight_usage_state.js").IInsightUsageInDocuments) & {
34
33
  clearCache: () => void;
35
34
  resultsCount: () => number;
36
35
  resetResultsCount: () => void;
37
36
  } & {
38
- resultFunc: (resultFuncArgs_0: import("./insight_usage_state.js").IInsightUsageState) => IInsightUsageInDocumentItem[];
39
- memoizedResultFunc: ((resultFuncArgs_0: import("./insight_usage_state.js").IInsightUsageState) => IInsightUsageInDocumentItem[]) & {
37
+ resultFunc: (resultFuncArgs_0: import("./insight_usage_state.js").IInsightUsageState) => import("./insight_usage_state.js").IInsightUsageInDocuments;
38
+ memoizedResultFunc: ((resultFuncArgs_0: import("./insight_usage_state.js").IInsightUsageState) => import("./insight_usage_state.js").IInsightUsageInDocuments) & {
40
39
  clearCache: () => void;
41
40
  resultsCount: () => number;
42
41
  resetResultsCount: () => void;
43
42
  };
44
- lastResult: () => IInsightUsageInDocumentItem[];
43
+ lastResult: () => import("./insight_usage_state.js").IInsightUsageInDocuments;
45
44
  dependencies: [typeof getInsightUsageState];
46
45
  recomputations: () => number;
47
46
  resetRecomputations: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"insight_usage_selectors.d.ts","sourceRoot":"","sources":["../../../src/store/insight_usage/insight_usage_selectors.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7C,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E,0CAA0C;AAC1C,eAAO,MAAM,oBAAoB,UAAW,SAAS,0DAAyC,CAAC;AAE/F;;;;GAIG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;CAiB/C,CAAC;AAIF,sEAAsE;AACtE,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;CAE9C,CAAC"}
1
+ {"version":3,"file":"insight_usage_selectors.d.ts","sourceRoot":"","sources":["../../../src/store/insight_usage/insight_usage_selectors.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAU7C,0CAA0C;AAC1C,eAAO,MAAM,oBAAoB,UAAW,SAAS,0DAAyC,CAAC;AAE/F;;;;GAIG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;CAiB/C,CAAC;AAEF,2HAA2H;AAC3H,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;CAI9C,CAAC"}
@@ -3,7 +3,7 @@ import { createSelector } from "@reduxjs/toolkit";
3
3
  // The mount path comes straight from constants/state_paths, never from the domain's own
4
4
  // reducer module (4.4 delivery note — that direction closes an import cycle).
5
5
  import { getSourceDashboardId } from "../../selectors/route_selector.js";
6
- import { EMPTY_INSIGHT_USAGE_ON_DASHBOARDS, getInsightUsageInDocuments, getInsightUsageOnDashboards, sortDashboards, } from "./insight_usage_helpers.js";
6
+ import { EMPTY_INSIGHT_USAGE_IN_DOCUMENTS, EMPTY_INSIGHT_USAGE_ON_DASHBOARDS, getInsightUsageInDocuments, getInsightUsageOnDashboards, sortDashboards, } from "./insight_usage_helpers.js";
7
7
  /** The domain's single input selector. */
8
8
  export const getInsightUsageState = (state) => state.data.insightUsagesOnDashboards;
9
9
  /**
@@ -22,6 +22,7 @@ export const getInsightUsageOnDashboardsSelector = createSelector(getInsightUsag
22
22
  accessibleDashboards: sortDashboards(insightUsageOnDashboard.accessibleDashboards, sourceDashboardId),
23
23
  };
24
24
  });
25
- const NO_DOCUMENTS = [];
26
- /** The Publisher documents that show the insight, sorted by title. */
27
- export const getInsightUsageInDocumentsSelector = createSelector(getInsightUsageState, (usage) => usage ? getInsightUsageInDocuments(usage.referencedDocuments) : NO_DOCUMENTS);
25
+ /** The Publisher documents that show the insight: the ones the user may open, sorted by title, and a count of the rest. */
26
+ export const getInsightUsageInDocumentsSelector = createSelector(getInsightUsageState, (usage) => usage
27
+ ? getInsightUsageInDocuments(usage.referencedDocuments, usage.accessibleDocumentIds)
28
+ : EMPTY_INSIGHT_USAGE_IN_DOCUMENTS);
@@ -1 +1 @@
1
- {"version":3,"file":"insight_usage_slice.d.ts","sourceRoot":"","sources":["../../../src/store/insight_usage/insight_usage_slice.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AAKrC,OAAO,EAAE,KAAK,kBAAkB,EAA4B,MAAM,0BAA0B,CAAC;AAoB7F,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,kBAAkB,CAA6B,CAAC"}
1
+ {"version":3,"file":"insight_usage_slice.d.ts","sourceRoot":"","sources":["../../../src/store/insight_usage/insight_usage_slice.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AAKrC,OAAO,EAAE,KAAK,kBAAkB,EAA4B,MAAM,0BAA0B,CAAC;AAqB7F,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,kBAAkB,CAA6B,CAAC"}
@@ -13,6 +13,7 @@ const insightUsageSlice = createSlice({
13
13
  referencedDashboards: action.payload.usages,
14
14
  allUserDashboards: action.payload.dashboards,
15
15
  referencedDocuments: action.payload.documents,
16
+ accessibleDocumentIds: action.payload.accessibleDocumentIds,
16
17
  }))
17
18
  // null rather than an absent key; every reader treats the two the same
18
19
  .addCase(resetInsightUsageOnDashboards, () => insightUsageInitialState)
@@ -16,6 +16,8 @@ export interface IInsightUsage {
16
16
  referencedDashboards: IMetadataObject[];
17
17
  /** Publisher documents that show the insight. */
18
18
  referencedDocuments: IMetadataObject[];
19
+ /** Ids of the referenced documents the user may open. */
20
+ accessibleDocumentIds: string[];
19
21
  }
20
22
  /**
21
23
  * The DERIVED, dialog-facing shape — `insight_usage_selectors.ts` computes it from
@@ -36,4 +38,10 @@ export interface IInsightUsageInDocumentItem {
36
38
  title: string;
37
39
  id: string;
38
40
  }
41
+ /** Derived like {@link IInsightUsageOnDashboard}: the documents the user may open, and how many they may not. */
42
+ export interface IInsightUsageInDocuments {
43
+ accessibleDocuments: IInsightUsageInDocumentItem[];
44
+ inaccessibleDocumentsCount: number;
45
+ allDocumentsCount: number;
46
+ }
39
47
  //# sourceMappingURL=insight_usage_state.d.ts.map