@holistics/anfra-sdk 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Client } from 'openapi-fetch';
2
- import { av as paths, au as components } from './types-C_-1rgj2.js';
2
+ import { aG as paths, aF as components } from './types-BiRAlSSk.js';
3
3
  import { DatasetDescriptor, Backend, BackendExportRequest, BackendQueryRequest } from './app.js';
4
4
  import { DataAppError } from './app.js';
5
5
 
package/dist/api.js CHANGED
@@ -288,6 +288,14 @@ function toDescriptor(dataset) {
288
288
  name: metric.name,
289
289
  ...metric.label ? { label: metric.label } : {},
290
290
  type: metric.type
291
+ })),
292
+ relationships: (dataset.relationships ?? []).map((relationship) => ({
293
+ ...relationship.name ? { name: relationship.name } : {},
294
+ from: relationship.from,
295
+ to: relationship.to,
296
+ type: relationship.type,
297
+ active: relationship.active,
298
+ direction: relationship.direction
291
299
  }))
292
300
  };
293
301
  }
package/dist/app.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { S as Sdk } from './bootstrap-BxBqFhgm.js';
2
- export { A as AnfraPlugins, a as App, C as Control, b as CrossFilter, D as DateDrillControl, c as DeprecatedFeatures, E as Edge, F as Filter, d as FrameKernel, e as FrameMenuEntry, f as FrameMenuItem, I as InstalledPlugins, M as Mapping, g as ModalInput, O as OVERLAY_ID, h as Opened, i as PluginApi, j as PluginMembers, k as PluginName, P as PluginSetup, l as PopoverInput, m as PopoverSide, Q as Query, n as STRUCTURE_ATTRIBUTES, V as VERSION, o as bootstrap, p as buildStructure, q as createSdk, r as parseRef } from './bootstrap-BxBqFhgm.js';
3
- export { A as ApiErrorCode, D as DataAppError, a as DataAppErrorInit, E as ErrorCode, b as ErrorContextEntry, c as ErrorDetails, d as ErrorScope, F as FromHttpStatusOptions, G as GENERIC_CODES, e as GenericCode, V as ValidationError, f as callFailed, g as connectionFailed, h as forbidden, i as fromHttpStatus, j as hasErrorCode, k as invalidRequest, l as isDataAppError } from './errors-DR05L6-y.js';
4
- export { A as Aggregation, a as AppDeclaration, b as AppJson, c as ArrowType, B as Backend, d as BackendCondition, e as BackendDateDrill, f as BackendExportRequest, g as BackendFilter, h as BackendLineageRequest, i as BackendQueryRequest, j as BackendQueryResult, k as BackendSort, C as CallStamp, l as ColumnMeta, m as Condition, n as ConditionValue, o as ControlMappingJson, p as CrossFilterJson, D as DatasetDescriptor, q as DateDrillDeclaration, r as DateGrain, s as DateTransformation, E as EntityKind, t as EntityRef, u as EntityUsage, v as ExecuteOptions, w as ExecuteSummary, x as ExportFormat, y as ExportFormatOptions, z as ExportOptions, F as ExportResult, G as FILTER_AGGREGATIONS, H as FieldLineage, I as FieldSuggestionsRequest, J as FilterAggregation, K as FilterDeclaration, L as FilterValueType, M as InspectedApp, N as InspectedControl, O as InspectedError, P as InspectedQuery, Q as InspectedSelection, R as InspectedStructure, S as LineageCard, T as LineageDiagram, U as LineageNode, V as LineageOptions, W as LineageResult, X as LineageTarget, Y as Listener, Z as LocateKind, _ as LocateTarget, $ as MappingJson, a0 as Operator, a1 as QueryCacheResult, a2 as QueryCacheSettings, a3 as QueryDebug, a4 as QueryDeclaration, a5 as QueryInput, a6 as QueryInputDefaults, a7 as QueryPagination, a8 as QueryPivot, a9 as QueryRequest, aa as QueryResult, ab as QuerySeeds, ac as QuerySort, ad as QueryStamp, ae as QueryState, af as QueryTimings, ag as RenderFormat, ah as RenderRequest, ai as Rendering, aj as Row, ak as SdkEnvironment, al as SdkFeatures, am as Selection, an as SelectionCondition, ao as SemanticType, ap as StructureKind, aq as StructureNode, ar as Unsubscribe, as as User, at as WeekStartDay } from './types-C_-1rgj2.js';
1
+ import { S as Sdk } from './bootstrap-DULxuxqY.js';
2
+ export { A as AnfraPlugins, a as App, C as Control, b as CrossFilter, D as DateDrillControl, c as DeprecatedFeatures, E as Edge, F as Filter, d as FrameKernel, e as FrameMenuEntry, f as FrameMenuItem, I as InstalledPlugins, M as Mapping, g as ModalInput, O as OVERLAY_ID, h as Opened, i as PluginApi, j as PluginMembers, k as PluginName, P as PluginSetup, l as PopoverInput, m as PopoverSide, Q as Query, n as STRUCTURE_ATTRIBUTES, V as VERSION, o as bootstrap, p as buildStructure, q as createSdk, r as parseRef } from './bootstrap-DULxuxqY.js';
3
+ export { A as ApiErrorCode, D as DataAppError, a as DataAppErrorInit, E as ErrorCode, b as ErrorContextEntry, c as ErrorDetails, d as ErrorScope, F as FromHttpStatusOptions, G as GENERIC_CODES, e as GenericCode, V as ValidationError, f as callFailed, g as connectionFailed, h as forbidden, i as fromHttpStatus, j as hasErrorCode, k as invalidRequest, l as isDataAppError } from './errors-CWaxgIdV.js';
4
+ export { A as Aggregation, a as Annotation, b as AnnotationInput, c as AnnotationKind, d as AnnotationSeverity, e as AppDeclaration, f as AppJson, g as ArrowType, B as Backend, h as BackendCondition, i as BackendDateDrill, j as BackendExportRequest, k as BackendFilter, l as BackendLineageRequest, m as BackendQueryRequest, n as BackendQueryResult, o as BackendSort, C as CallStamp, p as ColumnMeta, q as Condition, r as ConditionValue, s as ControlMappingJson, t as CrossFilterJson, D as DatasetDescriptor, u as DatasetRelationship, v as DateDrillDeclaration, w as DateGrain, x as DateTransformation, E as EntityKind, y as EntityRef, z as EntityUsage, F as ExecuteOptions, G as ExecuteSummary, H as ExportFormat, I as ExportFormatOptions, J as ExportOptions, K as ExportResult, L as FILTER_AGGREGATIONS, M as FieldLineage, N as FieldSuggestionsRequest, O as FilterAggregation, P as FilterDeclaration, Q as FilterValueType, R as InspectedApp, S as InspectedControl, T as InspectedError, U as InspectedQuery, V as InspectedSelection, W as InspectedStructure, X as LineageCard, Y as LineageDiagram, Z as LineageNode, _ as LineageOptions, $ as LineageResult, a0 as LineageTarget, a1 as Listener, a2 as LocateKind, a3 as LocateTarget, a4 as MappingJson, a5 as Operator, a6 as QueryCacheResult, a7 as QueryCacheSettings, a8 as QueryDebug, a9 as QueryDeclaration, aa as QueryInput, ab as QueryInputDefaults, ac as QueryPagination, ad as QueryPivot, ae as QueryRequest, af as QueryResult, ag as QuerySeeds, ah as QuerySort, ai as QueryStamp, aj as QueryState, ak as QueryTimings, al as RangeAnchor, am as RenderFormat, an as RenderRequest, ao as Rendering, ap as ResolvedRowsAnchor, aq as Row, ar as RowsAnchor, as as SdkEnvironment, at as SdkFeatures, au as Selection, av as SelectionCondition, aw as SemanticType, ax as SeriesAnchor, ay as SeriesPoint, az as StructureKind, aA as StructureNode, aB as Unsubscribe, aC as User, aD as ValueAnchor, aE as WeekStartDay } from './types-BiRAlSSk.js';
5
5
  export { A as AppConsoleEvent, a as AppErrorEvent, b as AppErrorKind } from './runtimeErrors-gswksjDk.js';
6
- export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetRect, h as Theme, i as ThemeInput, j as ThemeScheme, k as ThemeToken, l as ThemeTokens, m as checkTarget, n as designTheme, r as resolveTheme } from './menu-CuTKq-dC.js';
6
+ export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetPoint, h as TargetRect, i as Theme, j as ThemeInput, k as ThemeScheme, l as ThemeToken, m as ThemeTokens, n as checkTarget, o as designTheme, r as resolveTheme } from './theme-C9Tuzqu7.js';
7
7
 
8
8
  declare const SANDBOX_GLOBAL = "Anfra";
9
9
  /**
package/dist/app.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./chunk-UUKXJSE4.js";
2
2
  import {
3
3
  checkTarget
4
- } from "./chunk-ACKFOANJ.js";
4
+ } from "./chunk-DWQUIHUX.js";
5
5
  import {
6
6
  ATTR,
7
7
  App,
@@ -22,7 +22,7 @@ import {
22
22
  createSdk,
23
23
  installSandbox,
24
24
  parseRef
25
- } from "./chunk-IHRNKDMO.js";
25
+ } from "./chunk-Q75JDXVL.js";
26
26
  import {
27
27
  FILTER_AGGREGATIONS
28
28
  } from "./chunk-XIUFHRZE.js";
@@ -35,7 +35,7 @@ import {
35
35
  designTheme,
36
36
  resolveTheme
37
37
  } from "./chunk-RXPNL7UR.js";
38
- import "./chunk-E3Q3FRKQ.js";
38
+ import "./chunk-D3KOXXL2.js";
39
39
  import "./chunk-GPBYPSWK.js";
40
40
  import {
41
41
  DataAppError,
@@ -1,6 +1,6 @@
1
- import { D as DataAppError, V as ValidationError, k as invalidRequest, h as forbidden, g as connectionFailed, f as callFailed, i as fromHttpStatus, j as hasErrorCode, l as isDataAppError } from './errors-DR05L6-y.js';
2
- import { Y as Listener, ar as Unsubscribe, D as DatasetDescriptor, z as ExportOptions, F as ExportResult, ah as RenderRequest, ai as Rendering, X as LineageTarget, V as LineageOptions, W as LineageResult, E as EntityKind, m as Condition, K as FilterDeclaration, B as Backend, L as FilterValueType, n as ConditionValue, q as DateDrillDeclaration, r as DateGrain, J as FilterAggregation, p as CrossFilterJson, o as ControlMappingJson, a6 as QueryInputDefaults, al as SdkFeatures, am as Selection, an as SelectionCondition, aj as Row, v as ExecuteOptions, w as ExecuteSummary, Z as LocateKind, a5 as QueryInput, a4 as QueryDeclaration, a2 as QueryCacheSettings, ac as QuerySort, ae as QueryState, aa as QueryResult, a as AppDeclaration, at as WeekStartDay, a9 as QueryRequest, f as BackendExportRequest, C as CallStamp, b as AppJson, M as InspectedApp, as as User, ak as SdkEnvironment, R as InspectedStructure } from './types-C_-1rgj2.js';
3
- import { e as PluginInfo, j as ThemeScheme, l as ThemeTokens, h as Theme, d as MenuTargetKind, c as MenuTarget, N as NodeTarget } from './menu-CuTKq-dC.js';
1
+ import { D as DataAppError, V as ValidationError, k as invalidRequest, h as forbidden, g as connectionFailed, f as callFailed, i as fromHttpStatus, j as hasErrorCode, l as isDataAppError } from './errors-CWaxgIdV.js';
2
+ import { a1 as Listener, aB as Unsubscribe, D as DatasetDescriptor, J as ExportOptions, K as ExportResult, an as RenderRequest, ao as Rendering, a0 as LineageTarget, _ as LineageOptions, $ as LineageResult, E as EntityKind, q as Condition, P as FilterDeclaration, B as Backend, Q as FilterValueType, r as ConditionValue, v as DateDrillDeclaration, w as DateGrain, O as FilterAggregation, t as CrossFilterJson, s as ControlMappingJson, ab as QueryInputDefaults, at as SdkFeatures, au as Selection, av as SelectionCondition, aq as Row, F as ExecuteOptions, G as ExecuteSummary, a2 as LocateKind, aa as QueryInput, a9 as QueryDeclaration, a7 as QueryCacheSettings, ah as QuerySort, aj as QueryState, af as QueryResult, a as Annotation, b as AnnotationInput, e as AppDeclaration, aE as WeekStartDay, ae as QueryRequest, j as BackendExportRequest, C as CallStamp, f as AppJson, R as InspectedApp, aC as User, as as SdkEnvironment, W as InspectedStructure } from './types-BiRAlSSk.js';
3
+ import { R as RowsTarget, e as PluginInfo, k as ThemeScheme, m as ThemeTokens, i as Theme, d as MenuTargetKind, c as MenuTarget, N as NodeTarget } from './theme-C9Tuzqu7.js';
4
4
 
5
5
  interface NotificationTarget {
6
6
  notifyChange(): void;
@@ -418,6 +418,15 @@ declare class Query extends Observable {
418
418
  runningSignature?: string;
419
419
  /** The signature of its last run, when that run failed. */
420
420
  private failedSignature?;
421
+ /** Each plugin's annotations on the current result, by plugin, in the order they were first set. */
422
+ private annotationSets;
423
+ /**
424
+ * The results that are the current one: the last run's, and each that a page extended it into, so
425
+ * annotations computed before a `fetchMore` still land.
426
+ */
427
+ private currentResults;
428
+ /** `annotations` as last read, until a set or the result changes. */
429
+ private resolvedAnnotations?;
421
430
  constructor(name: string, app: AppContext & Observable, declaration: QueryDeclaration, id: number);
422
431
  /** What it was declared with, or last updated to. */
423
432
  get declaration(): QueryDeclaration;
@@ -427,7 +436,8 @@ declare class Query extends Observable {
427
436
  get isRemoved(): boolean;
428
437
  /**
429
438
  * Swaps what this query is: its dataset, its AQL, its page size, its cache, checked as `createQuery` checks
430
- * them. Its name, its edges and its result stay; the result until the rerun replaces it. Runs
439
+ * them. Its name, its edges and its result stay; the result until the rerun replaces it, but its
440
+ * annotations go at once, and plugins can't annotate that result any more. Runs
431
441
  * nothing: the query is dirty, and the next `app.execute()` reruns it, so several edits go out
432
442
  * as one run. Back to the first page. A run or page in flight is aborted, and `fetchMore` does
433
443
  * nothing until the rerun. A new AQL or dataset clears the sort (unless `sort` is given) and a
@@ -547,6 +557,18 @@ declare class Query extends Observable {
547
557
  * `app.selection.rows` still holds what the author passed, verbatim.
548
558
  */
549
559
  get selectedRows(): readonly Row[];
560
+ /**
561
+ * What plugins say about this query's current result, every plugin's merged: draw the kinds your
562
+ * chart declares in `data-anfra-annotations`, by `index` for a rows anchor. Each has its plugin
563
+ * and a stable `key`. A change notifies through `subscribe`; they go when the result is replaced.
564
+ */
565
+ get annotations(): readonly Annotation[];
566
+ /** @internal Whether `result` is this query's current result, or one a page has since extended. */
567
+ isCurrentResult(result: QueryResult): boolean;
568
+ /** @internal `kernel.annotate`'s, checked by then: replace one plugin's set, `[]` clearing it. */
569
+ setAnnotations(plugin: string, annotations: readonly AnnotationInput[]): void;
570
+ /** Every plugin's annotations go, with the result they were about. */
571
+ private clearAnnotations;
550
572
  /** @internal */
551
573
  markExecuting(): void;
552
574
  /** @internal The cache duration it runs with: its own, or its app's default. Absent: the backend's default. */
@@ -696,6 +718,11 @@ declare class App extends Observable implements AppContext {
696
718
  */
697
719
  private drillTransformations;
698
720
  menu(query: Query, event: Event, rows: readonly Row[], fields?: readonly string[], measure?: string): boolean;
721
+ /**
722
+ * @internal What a menu on these rows of the query is about: their conditions, derived as a
723
+ * cross-filter's, and the annotations plugins set on them (on `measure`'s, when given).
724
+ */
725
+ rowsTarget(query: Query, rows: readonly Row[], fields?: readonly string[], measure?: string): RowsTarget;
699
726
  /**
700
727
  * @internal Backs the kernel's `queryRequest(query)`: what the query runs with now, from its applied
701
728
  * state, as `fetchPage` and `exportQuery` build theirs.
@@ -954,6 +981,14 @@ interface BuiltStructure extends InspectedStructure {
954
981
  */
955
982
  declare function buildStructure(doc: Document, apps: readonly App[]): BuiltStructure;
956
983
 
984
+ /**
985
+ * The kernel's UI body: the menu, the modal and the popover plugins draw content UI with, in the
986
+ * plugin layer, on the host's `--anfra-*` tokens. Sent to a frame the first time it opens one
987
+ * (`anfra.body` for `anfra`), so a frame that never does carries none of it. The kernel hands it its
988
+ * shadow root, and keeps one open at a time. Also the annotations badge, and the list its popover
989
+ * shows (docs/designs/sdk-plugins.md, Annotations).
990
+ */
991
+
957
992
  /** Which side of its anchor a popover opens on. */
958
993
  type PopoverSide = 'right' | 'left' | 'bottom' | 'top';
959
994
 
@@ -1102,6 +1137,16 @@ interface FrameKernel {
1102
1137
  modal: (input: ModalInput) => Promise<Opened>;
1103
1138
  /** Open a popover beside a node or a point, following it as the page scrolls. */
1104
1139
  popover: (input: PopoverInput) => Promise<Opened>;
1140
+ /**
1141
+ * Set this plugin's annotations on a query, replacing its last set; `[]` clears it. `result` is
1142
+ * the `query.result` they were computed from: when it is no longer the query's, nothing changes
1143
+ * and this returns false. Throws on a malformed annotation; a rows anchor's row the result lacks
1144
+ * is dropped quietly. They go when the query's result is replaced, or at once when the
1145
+ * definition updates the query, so annotate each new result (`query.subscribe`).
1146
+ */
1147
+ annotate: (query: Query, annotations: readonly AnnotationInput[], options: {
1148
+ result: QueryResult;
1149
+ }) => boolean;
1105
1150
  }
1106
1151
 
1107
1152
  /** A plugin's frame setup, as the host's frame script hands it over: its name and its function. */
package/dist/build.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FrameHalf } from './host.js';
2
- import './types-C_-1rgj2.js';
3
- import './menu-CuTKq-dC.js';
2
+ import './types-BiRAlSSk.js';
3
+ import './theme-C9Tuzqu7.js';
4
4
 
5
5
  /**
6
6
  * @holistics/anfra-sdk/build: building an SDK plugin's frame half into the script source a host
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.21.0";
2
+ var version = "0.23.0";
3
3
 
4
4
  export {
5
5
  version
@@ -1,6 +1,7 @@
1
1
  // src/common/menu.ts
2
2
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
3
  var isRect = (value) => isObject(value) && ["x", "y", "width", "height"].every((key) => typeof value[key] === "number");
4
+ var isPoint = (value) => isObject(value) && Number.isFinite(value.x) && Number.isFinite(value.y);
4
5
  var isNode = (value) => isObject(value) && typeof value.key === "string" && typeof value.kind === "string" && Array.isArray(value.problems) && Array.isArray(value.children);
5
6
  function checkNode(value) {
6
7
  if (!isObject(value) || value.kind !== "node" || !isNode(value.node) || !Array.isArray(value.ancestors) || !value.ancestors.every(isNode) || !isRect(value.rect)) return void 0;
@@ -22,6 +23,7 @@ function checkTarget(value) {
22
23
  if (value.measure !== void 0 && typeof value.measure !== "string") return void 0;
23
24
  const node = value.node === void 0 ? void 0 : checkNode(value.node);
24
25
  if (value.node !== void 0 && !node) return void 0;
26
+ if (value.at !== void 0 && !isPoint(value.at)) return void 0;
25
27
  return {
26
28
  kind: "rows",
27
29
  app: value.app,
@@ -31,7 +33,8 @@ function checkTarget(value) {
31
33
  ...value.measure !== void 0 ? { measure: value.measure } : {},
32
34
  conditions: value.conditions,
33
35
  ...value.expression !== void 0 ? { expression: value.expression } : {},
34
- ...node ? { node } : {}
36
+ ...node ? { node } : {},
37
+ ...value.at !== void 0 ? { at: { x: value.at.x, y: value.at.y } } : {}
35
38
  };
36
39
  }
37
40