@holistics/anfra-sdk 0.23.0 → 0.24.0-rc.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.
- package/dist/app.d.ts +3 -3
- package/dist/app.js +2 -2
- package/dist/{bootstrap-DULxuxqY.d.ts → bootstrap-OCA3RI1u.d.ts} +271 -234
- package/dist/build.d.ts +1 -1
- package/dist/{chunk-YVWJ3WCK.js → chunk-4BSARXRZ.js} +1 -1
- package/dist/{chunk-7I2HXY72.js → chunk-5JDJD4EF.js} +1 -1
- package/dist/{chunk-CLXZMA5D.js → chunk-HA3ZB3LG.js} +1 -1
- package/dist/{chunk-Q75JDXVL.js → chunk-KXILIAGR.js} +66 -1
- package/dist/{chunk-D3KOXXL2.js → chunk-OQ52YGQV.js} +1 -1
- package/dist/{chunk-2TTGSNHA.js → chunk-TPWCVL24.js} +5 -11
- package/dist/{chunk-D7DIJRAC.js → chunk-V6PRS5HV.js} +1 -1
- package/dist/{chunk-UWRQXPPG.js → chunk-XREEBDSR.js} +6 -12
- package/dist/common.d.ts +1 -1
- package/dist/{data-SZDYO55C.js → data-G6DCTXTJ.js} +24 -11
- package/dist/{declaration-GYV6OUR3.js → declaration-KB7ZHFDG.js} +7 -5
- package/dist/host.d.ts +17 -4
- package/dist/host.js +112 -9
- package/dist/{overview-M3OBCW35.js → overview-PHXDQW3C.js} +9 -8
- package/dist/{plugin-CG0mVS1X.d.ts → plugin-CZmRhV4r.d.ts} +36 -8
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +20 -12
- package/dist/{queries-BWKWZQMG.js → queries-77M6ZM74.js} +20 -13
- package/dist/{structure-JO4YZHKZ.js → structure-RX5MANTK.js} +5 -4
- package/dist/{tab-QPHE7YUQ.js → tab-B7ZRE5WY.js} +3 -3
- package/dist/testing.js +2 -2
- package/dist/{theme-C9Tuzqu7.d.ts → theme-CWkVSteW.d.ts} +69 -69
- package/package.json +1 -1
- package/dist/{chunk-33HI2ODM.js → chunk-KSE7HX53.js} +8 -8
package/dist/app.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as Sdk } from './bootstrap-
|
|
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-
|
|
1
|
+
import { S as Sdk } from './bootstrap-OCA3RI1u.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-OCA3RI1u.js';
|
|
3
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
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 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-
|
|
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-CWkVSteW.js';
|
|
7
7
|
|
|
8
8
|
declare const SANDBOX_GLOBAL = "Anfra";
|
|
9
9
|
/**
|
package/dist/app.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
createSdk,
|
|
23
23
|
installSandbox,
|
|
24
24
|
parseRef
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-KXILIAGR.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-
|
|
38
|
+
import "./chunk-OQ52YGQV.js";
|
|
39
39
|
import "./chunk-GPBYPSWK.js";
|
|
40
40
|
import {
|
|
41
41
|
DataAppError,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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,
|
|
3
|
-
import {
|
|
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, W as InspectedStructure, ae as QueryRequest, C as CallStamp, e as AppDeclaration, aE as WeekStartDay, j as BackendExportRequest, f as AppJson, R as InspectedApp, aC as User, as as SdkEnvironment } from './types-BiRAlSSk.js';
|
|
3
|
+
import { d as MenuTargetKind, c as MenuTarget, N as NodeTarget, R as RowsTarget, e as PluginInfo, k as ThemeScheme, m as ThemeTokens, i as Theme } from './theme-CWkVSteW.js';
|
|
4
4
|
|
|
5
5
|
interface NotificationTarget {
|
|
6
6
|
notifyChange(): void;
|
|
@@ -193,6 +193,16 @@ declare abstract class Control extends Observable {
|
|
|
193
193
|
* none is on the page yet; never throws.
|
|
194
194
|
*/
|
|
195
195
|
locate(): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Opens the host's panel at this control, as a reader asked to inspect it: wire it to your own
|
|
198
|
+
* button, badge or menu. `tab` names the panel's tab by its full id (`inspect.queries`); left out,
|
|
199
|
+
* or one the host doesn't show, the host picks its own (Queries, which shows what it filters unless it set another).
|
|
200
|
+
* Call it from a reader's click: without one it opens nothing and reports a problem. Resolves
|
|
201
|
+
* true when the panel opened.
|
|
202
|
+
*/
|
|
203
|
+
inspect(options?: {
|
|
204
|
+
tab?: string;
|
|
205
|
+
}): Promise<boolean>;
|
|
196
206
|
/** False once `remove()` took it out of its app. */
|
|
197
207
|
get isRemoved(): boolean;
|
|
198
208
|
/**
|
|
@@ -339,6 +349,8 @@ interface AppContext {
|
|
|
339
349
|
fetchPage(query: Query): Promise<void>;
|
|
340
350
|
/** Brings an entity's marked elements into view; false when none is on the page. */
|
|
341
351
|
locate(kind: LocateKind, name: string): boolean;
|
|
352
|
+
/** Asks the host to open its panel at an entity, on `tab` if it shows it; whether the panel opened. */
|
|
353
|
+
inspect(entity: 'query' | 'control', name: string, tab?: string): Promise<boolean>;
|
|
342
354
|
/** Opens the content menu on these rows of this query, for the event; whether one opens. */
|
|
343
355
|
menu(query: Query, event: Event, rows: readonly Row[], fields?: readonly string[], measure?: string): boolean;
|
|
344
356
|
}
|
|
@@ -520,6 +532,16 @@ declare class Query extends Observable {
|
|
|
520
532
|
abort(): void;
|
|
521
533
|
/** Fetches the next page and appends it. Rejects rather than swallowing, unlike `execute()`. */
|
|
522
534
|
fetchMore(): Promise<void>;
|
|
535
|
+
/**
|
|
536
|
+
* Opens the host's panel at this query, as a reader asked to inspect it: wire it to your own
|
|
537
|
+
* button, badge or menu. `tab` names the panel's tab by its full id (`inspect.queries`); left out,
|
|
538
|
+
* or one the host doesn't show, the host picks its own (Data, which shows its rows unless it set another).
|
|
539
|
+
* Call it from a reader's click: without one it opens nothing and reports a problem. Resolves
|
|
540
|
+
* true when the panel opened.
|
|
541
|
+
*/
|
|
542
|
+
inspect(options?: {
|
|
543
|
+
tab?: string;
|
|
544
|
+
}): Promise<boolean>;
|
|
523
545
|
/**
|
|
524
546
|
* Opens the menu on these rows of this query: the items plugins and the host offer for a point
|
|
525
547
|
* of data, such as "View underlying data". Call it from your chart's own right-click handler,
|
|
@@ -592,6 +614,246 @@ declare class Query extends Observable {
|
|
|
592
614
|
interface Query extends PluginMembers<'query'> {
|
|
593
615
|
}
|
|
594
616
|
|
|
617
|
+
declare const OVERLAY_ID = "anfra-overlay";
|
|
618
|
+
/**
|
|
619
|
+
* What the label says, in parts the overlay sets apart: the kind, the id or name, the author's
|
|
620
|
+
* label, a note such as "1 of 3", and the element's size.
|
|
621
|
+
*/
|
|
622
|
+
interface OverlayLabel {
|
|
623
|
+
kind: string;
|
|
624
|
+
name: string;
|
|
625
|
+
label?: string;
|
|
626
|
+
note?: string;
|
|
627
|
+
size?: string;
|
|
628
|
+
}
|
|
629
|
+
declare class Overlay {
|
|
630
|
+
private readonly doc;
|
|
631
|
+
private readonly root;
|
|
632
|
+
private shown;
|
|
633
|
+
private text;
|
|
634
|
+
private timer;
|
|
635
|
+
private readonly reposition;
|
|
636
|
+
constructor(doc: Document);
|
|
637
|
+
/** Show the overlay on these elements, labelled, until `hide()` or the next `show()`. */
|
|
638
|
+
show(elements: readonly Element[], text: OverlayLabel): void;
|
|
639
|
+
/** Show for a moment, then hide. */
|
|
640
|
+
flash(elements: readonly Element[], text: OverlayLabel, ms?: number): void;
|
|
641
|
+
hide(): void;
|
|
642
|
+
get visible(): boolean;
|
|
643
|
+
private clearTimer;
|
|
644
|
+
private draw;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* The structure: a Data App's semantic parts, declared by the definition on its own elements with
|
|
649
|
+
* `data-anfra-*` attributes and read from the running page. Optional and partial: anything
|
|
650
|
+
* unmarked is simply not in it. Built only while a host inspects, and never thrown over: a problem
|
|
651
|
+
* in the markup is reported on the node it concerns.
|
|
652
|
+
*/
|
|
653
|
+
|
|
654
|
+
declare const ATTR: {
|
|
655
|
+
readonly container: "data-anfra-container";
|
|
656
|
+
readonly block: "data-anfra-block";
|
|
657
|
+
readonly query: "data-anfra-query";
|
|
658
|
+
readonly control: "data-anfra-control";
|
|
659
|
+
readonly label: "data-anfra-label";
|
|
660
|
+
};
|
|
661
|
+
/** A `[app/]name` reference as a marker writes it. */
|
|
662
|
+
interface EntityRef {
|
|
663
|
+
app: number;
|
|
664
|
+
name: string;
|
|
665
|
+
}
|
|
666
|
+
/** Parse one token of a `data-anfra-query` or `data-anfra-control` attribute; undefined if malformed. */
|
|
667
|
+
declare function parseRef(token: string): EntityRef | undefined;
|
|
668
|
+
interface BuiltStructure extends InspectedStructure {
|
|
669
|
+
/** The marked element behind each node key, for highlighting and picking. */
|
|
670
|
+
elements: Map<string, Element>;
|
|
671
|
+
/** The node keys an element stands for: its own node, and one per entity it is marked with. */
|
|
672
|
+
keysOf: Map<Element, string[]>;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Read the structure off the document: one node per container or block, and one per entity a
|
|
676
|
+
* marked element names, placed under the nearest marked ancestor. Keys are index paths (`0.2.1`)
|
|
677
|
+
* so an unchanged tree keeps the same keys from one snapshot to the next.
|
|
678
|
+
*/
|
|
679
|
+
declare function buildStructure(doc: Document, apps: readonly App[]): BuiltStructure;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* The kernel's UI body: the menu, the modal and the popover plugins draw content UI with, in the
|
|
683
|
+
* plugin layer, on the host's `--anfra-*` tokens. Sent to a frame the first time it opens one
|
|
684
|
+
* (`anfra.body` for `anfra`), so a frame that never does carries none of it. The kernel hands it its
|
|
685
|
+
* shadow root, and keeps one open at a time. Also the annotations badge, and the list its popover
|
|
686
|
+
* shows (docs/designs/sdk-plugins.md, Annotations).
|
|
687
|
+
*/
|
|
688
|
+
|
|
689
|
+
/** Which side of its anchor a popover opens on. */
|
|
690
|
+
type PopoverSide = 'right' | 'left' | 'bottom' | 'top';
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Content UI, the kernel's side: the menu on a marked block (a right-click) or on a chart's point
|
|
694
|
+
* (`query.menu`), filled with plugins' frame items and the host's own; and the modal and popover a
|
|
695
|
+
* plugin's frame half opens. What draws them is the kernel's UI body, sent on first use, so a frame
|
|
696
|
+
* carries only the listener and the item list until someone opens one. One is open at a time.
|
|
697
|
+
*/
|
|
698
|
+
|
|
699
|
+
/** One entry a frame item shows for a target: what it runs, or why it can't. */
|
|
700
|
+
interface FrameMenuEntry {
|
|
701
|
+
label: string;
|
|
702
|
+
/** Why it can't run: shown, and the entry can't be picked. An entry with neither this nor `run` is left out. */
|
|
703
|
+
disabled?: string;
|
|
704
|
+
run?: () => unknown;
|
|
705
|
+
}
|
|
706
|
+
interface FrameMenuItemBase {
|
|
707
|
+
/** Under the plugin's name once added (`open` is `view-underlying-data.open`). */
|
|
708
|
+
id: string;
|
|
709
|
+
target: MenuTargetKind;
|
|
710
|
+
/**
|
|
711
|
+
* Whether it applies to this target; it shows when this is left out. Presentation only: frame code
|
|
712
|
+
* shares a realm with the definition and can enforce nothing, so a rule that must hold belongs on
|
|
713
|
+
* the host, in the calls the item makes.
|
|
714
|
+
*/
|
|
715
|
+
when?: (target: MenuTarget) => boolean;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* An entry a plugin's frame half adds to the menu, for one kind of target: one `label` that runs
|
|
719
|
+
* `run`, or the `entries` it shows for each target, decided as the menu opens (one per measure of a
|
|
720
|
+
* point, say, or one that can't run and says why; none leaves the item out).
|
|
721
|
+
*/
|
|
722
|
+
type FrameMenuItem = FrameMenuItemBase & ({
|
|
723
|
+
label: string;
|
|
724
|
+
run: (target: MenuTarget) => unknown;
|
|
725
|
+
entries?: never;
|
|
726
|
+
} | {
|
|
727
|
+
entries: (target: MenuTarget) => readonly FrameMenuEntry[];
|
|
728
|
+
label?: never;
|
|
729
|
+
run?: never;
|
|
730
|
+
});
|
|
731
|
+
/** The query a modal or popover is about: it closes when the query is removed. */
|
|
732
|
+
interface QueryAbout {
|
|
733
|
+
app: number;
|
|
734
|
+
query: string;
|
|
735
|
+
}
|
|
736
|
+
interface ModalInput {
|
|
737
|
+
title: string;
|
|
738
|
+
/** The query it shows something of, if any: removing the query closes it. */
|
|
739
|
+
about?: QueryAbout;
|
|
740
|
+
size?: 'sm' | 'md' | 'lg' | 'full';
|
|
741
|
+
/** Draw the content into its own shadow root, on the host's `--anfra-*` tokens; what it returns runs on close. */
|
|
742
|
+
mount: (root: ShadowRoot) => void | (() => void);
|
|
743
|
+
onClose?: () => void;
|
|
744
|
+
}
|
|
745
|
+
interface PopoverInput {
|
|
746
|
+
/** The query it shows something of, if any: removing the query closes it. */
|
|
747
|
+
about?: QueryAbout;
|
|
748
|
+
/** A node (a target's, kept in view as the page scrolls), or a point in the viewport. */
|
|
749
|
+
anchor: NodeTarget | {
|
|
750
|
+
x: number;
|
|
751
|
+
y: number;
|
|
752
|
+
};
|
|
753
|
+
/** The side of the anchor it opens on: `right` unless given; another when that one has no room. */
|
|
754
|
+
side?: PopoverSide;
|
|
755
|
+
mount: (root: ShadowRoot) => void | (() => void);
|
|
756
|
+
/** `outside`: a click anywhere else closes it. Unless asked, only Escape and its close button do. */
|
|
757
|
+
dismiss?: 'outside';
|
|
758
|
+
/** false: no close button, for content that draws its own (and calls `close`). */
|
|
759
|
+
closeButton?: boolean;
|
|
760
|
+
onClose?: () => void;
|
|
761
|
+
}
|
|
762
|
+
/** An open modal or popover. */
|
|
763
|
+
interface Opened {
|
|
764
|
+
close: () => void;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* The kernel, as a plugin's frame half sees it: the app model, the bridge under the plugin's name,
|
|
769
|
+
* a place in the plugin layer, and the ways to add API for the author. One per plugin, made by the
|
|
770
|
+
* bootstrap before the definition runs (docs/designs/sdk-plugins.md).
|
|
771
|
+
*/
|
|
772
|
+
|
|
773
|
+
declare const KERNEL_ERRORS: {
|
|
774
|
+
readonly DataAppError: typeof DataAppError;
|
|
775
|
+
readonly ValidationError: typeof ValidationError;
|
|
776
|
+
readonly invalidRequest: typeof invalidRequest;
|
|
777
|
+
readonly forbidden: typeof forbidden;
|
|
778
|
+
readonly connectionFailed: typeof connectionFailed;
|
|
779
|
+
readonly callFailed: typeof callFailed;
|
|
780
|
+
readonly fromHttpStatus: typeof fromHttpStatus;
|
|
781
|
+
readonly hasErrorCode: typeof hasErrorCode;
|
|
782
|
+
readonly isDataAppError: typeof isDataAppError;
|
|
783
|
+
};
|
|
784
|
+
interface FrameKernel {
|
|
785
|
+
/** The plugin's name: what its calls, events and API are named under. */
|
|
786
|
+
readonly plugin: string;
|
|
787
|
+
readonly window: Window;
|
|
788
|
+
/** The SDK instance the definition gets as `Anfra`: its apps, datasets and user. */
|
|
789
|
+
readonly sdk: Sdk;
|
|
790
|
+
/** The SDK's errors and the helpers that make them: reject with these, in the API's shape. */
|
|
791
|
+
readonly errors: typeof KERNEL_ERRORS;
|
|
792
|
+
/** The overlay every part of the SDK shows nodes with. */
|
|
793
|
+
readonly overlay: Overlay;
|
|
794
|
+
/** The page's structure as it is now. */
|
|
795
|
+
structure: () => BuiltStructure;
|
|
796
|
+
/**
|
|
797
|
+
* What a query runs with now, from its applied state: its dataset, its AQL, what reaches it
|
|
798
|
+
* (mapped controls, the selection, the reader's sort, date drills) and the timezone, as its own
|
|
799
|
+
* run and export are built. While a rerun is in flight, that is the rerun's request, not the one
|
|
800
|
+
* behind the result on screen. For a plugin that runs a variant of the query: it changes what it
|
|
801
|
+
* needs and sends it as `core.submitQuery`, through the pipeline like any query.
|
|
802
|
+
*/
|
|
803
|
+
queryRequest: (query: Query) => QueryRequest;
|
|
804
|
+
/**
|
|
805
|
+
* Make a host half's call, by its full name (`core.submitQuery`). `stamp` names the query the call
|
|
806
|
+
* is for, so the host shows it under that query (its request log). The kernel adds the query's id.
|
|
807
|
+
*/
|
|
808
|
+
call: <T = unknown>(name: string, request?: unknown, signal?: AbortSignal, stamp?: CallStamp) => Promise<T>;
|
|
809
|
+
/** Send the host one of this plugin's events, by its name under the plugin. */
|
|
810
|
+
emit: (name: string, payload?: unknown) => void;
|
|
811
|
+
/** Answer one of this plugin's calls made by the host, by its name under the plugin. */
|
|
812
|
+
handle: (name: string, handler: (request: any, signal: AbortSignal) => unknown) => void;
|
|
813
|
+
/** Listen to one of this plugin's events from the host, by its name under the plugin. */
|
|
814
|
+
on: (name: string, listener: (payload: any) => void) => void;
|
|
815
|
+
/** Each app the definition creates, and each already created. */
|
|
816
|
+
onApp: (listener: (app: App) => void) => void;
|
|
817
|
+
/** `Anfra.<plugin>`. */
|
|
818
|
+
provide: (api: unknown) => void;
|
|
819
|
+
/** `query.<plugin>` on every query, made once per query. */
|
|
820
|
+
provideOnQuery: (factory: (query: Query) => unknown) => void;
|
|
821
|
+
/** `control.<plugin>` on every control, made once per control. */
|
|
822
|
+
provideOnControl: (factory: (control: Control) => unknown) => void;
|
|
823
|
+
/** This plugin's shadow root in the plugin layer. */
|
|
824
|
+
layer: () => ShadowRoot;
|
|
825
|
+
/** The plugin's frame body, fetched and run on first use: what it exports. */
|
|
826
|
+
body: <T = unknown>() => Promise<T>;
|
|
827
|
+
/**
|
|
828
|
+
* Add an entry to the menu on a marked block (`target: 'node'`) or on a query's rows
|
|
829
|
+
* (`target: 'rows'`, opened by the definition's `query.menu`). The menu shows only once an entry
|
|
830
|
+
* exists, from a plugin or the host.
|
|
831
|
+
*/
|
|
832
|
+
menuItem: (item: FrameMenuItem) => void;
|
|
833
|
+
/** Open a modal over the page, drawn by the kernel; your content goes in its own shadow root. */
|
|
834
|
+
modal: (input: ModalInput) => Promise<Opened>;
|
|
835
|
+
/** Open a popover beside a node or a point, following it as the page scrolls. */
|
|
836
|
+
popover: (input: PopoverInput) => Promise<Opened>;
|
|
837
|
+
/**
|
|
838
|
+
* Set this plugin's annotations on a query, replacing its last set; `[]` clears it. `result` is
|
|
839
|
+
* the `query.result` they were computed from: when it is no longer the query's, nothing changes
|
|
840
|
+
* and this returns false. Throws on a malformed annotation; a rows anchor's row the result lacks
|
|
841
|
+
* is dropped quietly. They go when the query's result is replaced, or at once when the
|
|
842
|
+
* definition updates the query, so annotate each new result (`query.subscribe`).
|
|
843
|
+
*/
|
|
844
|
+
annotate: (query: Query, annotations: readonly AnnotationInput[], options: {
|
|
845
|
+
result: QueryResult;
|
|
846
|
+
}) => boolean;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/** What the frame asks the host to reveal. */
|
|
850
|
+
interface RevealRequest {
|
|
851
|
+
app: number;
|
|
852
|
+
entity: 'query' | 'control';
|
|
853
|
+
name: string;
|
|
854
|
+
tab?: string;
|
|
855
|
+
}
|
|
856
|
+
|
|
595
857
|
type Factory<T> = (entity: T) => unknown;
|
|
596
858
|
interface EntityExtensions<Q, C> {
|
|
597
859
|
query: Map<string, Factory<Q>>;
|
|
@@ -784,6 +1046,13 @@ declare class App extends Observable implements AppContext {
|
|
|
784
1046
|
* as long as someone is likely to be watching. See docs/adr/0007.
|
|
785
1047
|
*/
|
|
786
1048
|
toInspectJSON(): InspectedApp;
|
|
1049
|
+
/** @internal The frame's reveal, set by its bootstrap; absent outside a frame. */
|
|
1050
|
+
revealer?: (request: RevealRequest) => Promise<boolean>;
|
|
1051
|
+
/**
|
|
1052
|
+
* @internal Backs `query.inspect()` and `control.inspect()`: ask the host to open its panel at
|
|
1053
|
+
* the entity. False outside a frame.
|
|
1054
|
+
*/
|
|
1055
|
+
inspect(entity: 'query' | 'control', name: string, tab?: string): Promise<boolean>;
|
|
787
1056
|
/**
|
|
788
1057
|
* @internal This app's index among the frame's apps, which is how a marked element names it
|
|
789
1058
|
* (`data-anfra-query="1/revenue"`); 0 unless set by the instance that created it.
|
|
@@ -917,238 +1186,6 @@ interface Sdk extends PluginMembers<'anfra'> {
|
|
|
917
1186
|
}
|
|
918
1187
|
declare function createSdk(environment: SdkEnvironment): Sdk;
|
|
919
1188
|
|
|
920
|
-
declare const OVERLAY_ID = "anfra-overlay";
|
|
921
|
-
/**
|
|
922
|
-
* What the label says, in parts the overlay sets apart: the kind, the id or name, the author's
|
|
923
|
-
* label, a note such as "1 of 3", and the element's size.
|
|
924
|
-
*/
|
|
925
|
-
interface OverlayLabel {
|
|
926
|
-
kind: string;
|
|
927
|
-
name: string;
|
|
928
|
-
label?: string;
|
|
929
|
-
note?: string;
|
|
930
|
-
size?: string;
|
|
931
|
-
}
|
|
932
|
-
declare class Overlay {
|
|
933
|
-
private readonly doc;
|
|
934
|
-
private readonly root;
|
|
935
|
-
private shown;
|
|
936
|
-
private text;
|
|
937
|
-
private timer;
|
|
938
|
-
private readonly reposition;
|
|
939
|
-
constructor(doc: Document);
|
|
940
|
-
/** Show the overlay on these elements, labelled, until `hide()` or the next `show()`. */
|
|
941
|
-
show(elements: readonly Element[], text: OverlayLabel): void;
|
|
942
|
-
/** Show for a moment, then hide. */
|
|
943
|
-
flash(elements: readonly Element[], text: OverlayLabel, ms?: number): void;
|
|
944
|
-
hide(): void;
|
|
945
|
-
get visible(): boolean;
|
|
946
|
-
private clearTimer;
|
|
947
|
-
private draw;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/**
|
|
951
|
-
* The structure: a Data App's semantic parts, declared by the definition on its own elements with
|
|
952
|
-
* `data-anfra-*` attributes and read from the running page. Optional and partial: anything
|
|
953
|
-
* unmarked is simply not in it. Built only while a host inspects, and never thrown over: a problem
|
|
954
|
-
* in the markup is reported on the node it concerns.
|
|
955
|
-
*/
|
|
956
|
-
|
|
957
|
-
declare const ATTR: {
|
|
958
|
-
readonly container: "data-anfra-container";
|
|
959
|
-
readonly block: "data-anfra-block";
|
|
960
|
-
readonly query: "data-anfra-query";
|
|
961
|
-
readonly control: "data-anfra-control";
|
|
962
|
-
readonly label: "data-anfra-label";
|
|
963
|
-
};
|
|
964
|
-
/** A `[app/]name` reference as a marker writes it. */
|
|
965
|
-
interface EntityRef {
|
|
966
|
-
app: number;
|
|
967
|
-
name: string;
|
|
968
|
-
}
|
|
969
|
-
/** Parse one token of a `data-anfra-query` or `data-anfra-control` attribute; undefined if malformed. */
|
|
970
|
-
declare function parseRef(token: string): EntityRef | undefined;
|
|
971
|
-
interface BuiltStructure extends InspectedStructure {
|
|
972
|
-
/** The marked element behind each node key, for highlighting and picking. */
|
|
973
|
-
elements: Map<string, Element>;
|
|
974
|
-
/** The node keys an element stands for: its own node, and one per entity it is marked with. */
|
|
975
|
-
keysOf: Map<Element, string[]>;
|
|
976
|
-
}
|
|
977
|
-
/**
|
|
978
|
-
* Read the structure off the document: one node per container or block, and one per entity a
|
|
979
|
-
* marked element names, placed under the nearest marked ancestor. Keys are index paths (`0.2.1`)
|
|
980
|
-
* so an unchanged tree keeps the same keys from one snapshot to the next.
|
|
981
|
-
*/
|
|
982
|
-
declare function buildStructure(doc: Document, apps: readonly App[]): BuiltStructure;
|
|
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
|
-
|
|
992
|
-
/** Which side of its anchor a popover opens on. */
|
|
993
|
-
type PopoverSide = 'right' | 'left' | 'bottom' | 'top';
|
|
994
|
-
|
|
995
|
-
/**
|
|
996
|
-
* Content UI, the kernel's side: the menu on a marked block (a right-click) or on a chart's point
|
|
997
|
-
* (`query.menu`), filled with plugins' frame items and the host's own; and the modal and popover a
|
|
998
|
-
* plugin's frame half opens. What draws them is the kernel's UI body, sent on first use, so a frame
|
|
999
|
-
* carries only the listener and the item list until someone opens one. One is open at a time.
|
|
1000
|
-
*/
|
|
1001
|
-
|
|
1002
|
-
/** One entry a frame item shows for a target: what it runs, or why it can't. */
|
|
1003
|
-
interface FrameMenuEntry {
|
|
1004
|
-
label: string;
|
|
1005
|
-
/** Why it can't run: shown, and the entry can't be picked. An entry with neither this nor `run` is left out. */
|
|
1006
|
-
disabled?: string;
|
|
1007
|
-
run?: () => unknown;
|
|
1008
|
-
}
|
|
1009
|
-
interface FrameMenuItemBase {
|
|
1010
|
-
/** Under the plugin's name once added (`open` is `view-underlying-data.open`). */
|
|
1011
|
-
id: string;
|
|
1012
|
-
target: MenuTargetKind;
|
|
1013
|
-
/**
|
|
1014
|
-
* Whether it applies to this target; it shows when this is left out. Presentation only: frame code
|
|
1015
|
-
* shares a realm with the definition and can enforce nothing, so a rule that must hold belongs on
|
|
1016
|
-
* the host, in the calls the item makes.
|
|
1017
|
-
*/
|
|
1018
|
-
when?: (target: MenuTarget) => boolean;
|
|
1019
|
-
}
|
|
1020
|
-
/**
|
|
1021
|
-
* An entry a plugin's frame half adds to the menu, for one kind of target: one `label` that runs
|
|
1022
|
-
* `run`, or the `entries` it shows for each target, decided as the menu opens (one per measure of a
|
|
1023
|
-
* point, say, or one that can't run and says why; none leaves the item out).
|
|
1024
|
-
*/
|
|
1025
|
-
type FrameMenuItem = FrameMenuItemBase & ({
|
|
1026
|
-
label: string;
|
|
1027
|
-
run: (target: MenuTarget) => unknown;
|
|
1028
|
-
entries?: never;
|
|
1029
|
-
} | {
|
|
1030
|
-
entries: (target: MenuTarget) => readonly FrameMenuEntry[];
|
|
1031
|
-
label?: never;
|
|
1032
|
-
run?: never;
|
|
1033
|
-
});
|
|
1034
|
-
/** The query a modal or popover is about: it closes when the query is removed. */
|
|
1035
|
-
interface QueryAbout {
|
|
1036
|
-
app: number;
|
|
1037
|
-
query: string;
|
|
1038
|
-
}
|
|
1039
|
-
interface ModalInput {
|
|
1040
|
-
title: string;
|
|
1041
|
-
/** The query it shows something of, if any: removing the query closes it. */
|
|
1042
|
-
about?: QueryAbout;
|
|
1043
|
-
size?: 'sm' | 'md' | 'lg' | 'full';
|
|
1044
|
-
/** Draw the content into its own shadow root, on the host's `--anfra-*` tokens; what it returns runs on close. */
|
|
1045
|
-
mount: (root: ShadowRoot) => void | (() => void);
|
|
1046
|
-
onClose?: () => void;
|
|
1047
|
-
}
|
|
1048
|
-
interface PopoverInput {
|
|
1049
|
-
/** The query it shows something of, if any: removing the query closes it. */
|
|
1050
|
-
about?: QueryAbout;
|
|
1051
|
-
/** A node (a target's, kept in view as the page scrolls), or a point in the viewport. */
|
|
1052
|
-
anchor: NodeTarget | {
|
|
1053
|
-
x: number;
|
|
1054
|
-
y: number;
|
|
1055
|
-
};
|
|
1056
|
-
/** The side of the anchor it opens on: `right` unless given; another when that one has no room. */
|
|
1057
|
-
side?: PopoverSide;
|
|
1058
|
-
mount: (root: ShadowRoot) => void | (() => void);
|
|
1059
|
-
/** `outside`: a click anywhere else closes it. Unless asked, only Escape and its close button do. */
|
|
1060
|
-
dismiss?: 'outside';
|
|
1061
|
-
/** false: no close button, for content that draws its own (and calls `close`). */
|
|
1062
|
-
closeButton?: boolean;
|
|
1063
|
-
onClose?: () => void;
|
|
1064
|
-
}
|
|
1065
|
-
/** An open modal or popover. */
|
|
1066
|
-
interface Opened {
|
|
1067
|
-
close: () => void;
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
/**
|
|
1071
|
-
* The kernel, as a plugin's frame half sees it: the app model, the bridge under the plugin's name,
|
|
1072
|
-
* a place in the plugin layer, and the ways to add API for the author. One per plugin, made by the
|
|
1073
|
-
* bootstrap before the definition runs (docs/designs/sdk-plugins.md).
|
|
1074
|
-
*/
|
|
1075
|
-
|
|
1076
|
-
declare const KERNEL_ERRORS: {
|
|
1077
|
-
readonly DataAppError: typeof DataAppError;
|
|
1078
|
-
readonly ValidationError: typeof ValidationError;
|
|
1079
|
-
readonly invalidRequest: typeof invalidRequest;
|
|
1080
|
-
readonly forbidden: typeof forbidden;
|
|
1081
|
-
readonly connectionFailed: typeof connectionFailed;
|
|
1082
|
-
readonly callFailed: typeof callFailed;
|
|
1083
|
-
readonly fromHttpStatus: typeof fromHttpStatus;
|
|
1084
|
-
readonly hasErrorCode: typeof hasErrorCode;
|
|
1085
|
-
readonly isDataAppError: typeof isDataAppError;
|
|
1086
|
-
};
|
|
1087
|
-
interface FrameKernel {
|
|
1088
|
-
/** The plugin's name: what its calls, events and API are named under. */
|
|
1089
|
-
readonly plugin: string;
|
|
1090
|
-
readonly window: Window;
|
|
1091
|
-
/** The SDK instance the definition gets as `Anfra`: its apps, datasets and user. */
|
|
1092
|
-
readonly sdk: Sdk;
|
|
1093
|
-
/** The SDK's errors and the helpers that make them: reject with these, in the API's shape. */
|
|
1094
|
-
readonly errors: typeof KERNEL_ERRORS;
|
|
1095
|
-
/** The overlay every part of the SDK shows nodes with. */
|
|
1096
|
-
readonly overlay: Overlay;
|
|
1097
|
-
/** The page's structure as it is now. */
|
|
1098
|
-
structure: () => BuiltStructure;
|
|
1099
|
-
/**
|
|
1100
|
-
* What a query runs with now, from its applied state: its dataset, its AQL, what reaches it
|
|
1101
|
-
* (mapped controls, the selection, the reader's sort, date drills) and the timezone, as its own
|
|
1102
|
-
* run and export are built. While a rerun is in flight, that is the rerun's request, not the one
|
|
1103
|
-
* behind the result on screen. For a plugin that runs a variant of the query: it changes what it
|
|
1104
|
-
* needs and sends it as `core.submitQuery`, through the pipeline like any query.
|
|
1105
|
-
*/
|
|
1106
|
-
queryRequest: (query: Query) => QueryRequest;
|
|
1107
|
-
/**
|
|
1108
|
-
* Make a host half's call, by its full name (`core.submitQuery`). `stamp` names the query the call
|
|
1109
|
-
* is for, so the host shows it under that query (its request log). The kernel adds the query's id.
|
|
1110
|
-
*/
|
|
1111
|
-
call: <T = unknown>(name: string, request?: unknown, signal?: AbortSignal, stamp?: CallStamp) => Promise<T>;
|
|
1112
|
-
/** Send the host one of this plugin's events, by its name under the plugin. */
|
|
1113
|
-
emit: (name: string, payload?: unknown) => void;
|
|
1114
|
-
/** Answer one of this plugin's calls made by the host, by its name under the plugin. */
|
|
1115
|
-
handle: (name: string, handler: (request: any, signal: AbortSignal) => unknown) => void;
|
|
1116
|
-
/** Listen to one of this plugin's events from the host, by its name under the plugin. */
|
|
1117
|
-
on: (name: string, listener: (payload: any) => void) => void;
|
|
1118
|
-
/** Each app the definition creates, and each already created. */
|
|
1119
|
-
onApp: (listener: (app: App) => void) => void;
|
|
1120
|
-
/** `Anfra.<plugin>`. */
|
|
1121
|
-
provide: (api: unknown) => void;
|
|
1122
|
-
/** `query.<plugin>` on every query, made once per query. */
|
|
1123
|
-
provideOnQuery: (factory: (query: Query) => unknown) => void;
|
|
1124
|
-
/** `control.<plugin>` on every control, made once per control. */
|
|
1125
|
-
provideOnControl: (factory: (control: Control) => unknown) => void;
|
|
1126
|
-
/** This plugin's shadow root in the plugin layer. */
|
|
1127
|
-
layer: () => ShadowRoot;
|
|
1128
|
-
/** The plugin's frame body, fetched and run on first use: what it exports. */
|
|
1129
|
-
body: <T = unknown>() => Promise<T>;
|
|
1130
|
-
/**
|
|
1131
|
-
* Add an entry to the menu on a marked block (`target: 'node'`) or on a query's rows
|
|
1132
|
-
* (`target: 'rows'`, opened by the definition's `query.menu`). The menu shows only once an entry
|
|
1133
|
-
* exists, from a plugin or the host.
|
|
1134
|
-
*/
|
|
1135
|
-
menuItem: (item: FrameMenuItem) => void;
|
|
1136
|
-
/** Open a modal over the page, drawn by the kernel; your content goes in its own shadow root. */
|
|
1137
|
-
modal: (input: ModalInput) => Promise<Opened>;
|
|
1138
|
-
/** Open a popover beside a node or a point, following it as the page scrolls. */
|
|
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;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
1189
|
/** A plugin's frame setup, as the host's frame script hands it over: its name and its function. */
|
|
1153
1190
|
type PluginSetup = readonly [name: string, setup: ((kernel: FrameKernel) => void) | undefined];
|
|
1154
1191
|
/** Provision the SDK in `win` from its host, run the plugins' setups, and install it. Returns once `Anfra` exists. */
|
package/dist/build.d.ts
CHANGED