@holistics/anfra-sdk 0.13.5 → 0.14.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/README.md +1 -1
- package/dist/app.d.ts +4 -3
- package/dist/app.js +17 -7
- package/dist/{bootstrap-BbsNvZ8s.d.ts → bootstrap-MhTSkiA1.d.ts} +96 -3
- package/dist/build.d.ts +2 -0
- package/dist/chunk-A3LNZMT6.js +10 -0
- package/dist/chunk-CYZQ7ZTJ.js +237 -0
- package/dist/chunk-DITKCHFQ.js +166 -0
- package/dist/chunk-F6MRA7J4.js +65 -0
- package/dist/chunk-GBXK7F2V.js +431 -0
- package/dist/chunk-GOUDXWG4.js +750 -0
- package/dist/chunk-GV7SVWEK.js +84 -0
- package/dist/chunk-H52PO7MP.js +105 -0
- package/dist/chunk-HI3ZAXJK.js +8 -0
- package/dist/{chunk-KI5CAVAR.js → chunk-HRV45ULB.js} +477 -25
- package/dist/chunk-K633QHGO.js +51 -0
- package/dist/chunk-KFD6CHLI.js +38 -0
- package/dist/{chunk-OJ5WIKWE.js → chunk-Q46CZIEK.js} +1 -1
- package/dist/{chunk-ADWBOQW2.js → chunk-S6XLP6U4.js} +31 -1
- package/dist/{chunk-TQ7S5DRE.js → chunk-WI5VJ2Z6.js} +1 -1
- package/dist/common.d.ts +1 -1
- package/dist/common.js +14 -4
- package/dist/data-UCCW2VWH.js +233 -0
- package/dist/declaration-GVDOGQY6.js +218 -0
- package/dist/host.d.ts +42 -4
- package/dist/host.js +412 -9
- package/dist/menu-CdGVKc4_.d.ts +151 -0
- package/dist/overview-XXND2V5V.js +358 -0
- package/dist/plugin-BmIDirTx.d.ts +303 -0
- package/dist/plugins.d.ts +6 -8
- package/dist/plugins.js +98 -69
- package/dist/queries-2OHKMTPC.js +661 -0
- package/dist/structure-WRDUXHD4.js +256 -0
- package/dist/tab-HMQOITVM.js +932 -0
- package/dist/testing.js +4 -4
- package/package.json +1 -1
- package/dist/bridge-WC7GliCH.d.ts +0 -73
- package/dist/chunk-33B2D4U5.js +0 -6
- package/dist/plugin-056-SKwd.d.ts +0 -132
- /package/dist/{chunk-52LXBYQM.js → chunk-UUKXJSE4.js} +0 -0
package/README.md
CHANGED
|
@@ -124,7 +124,7 @@ const host = createHost({ // one per page
|
|
|
124
124
|
plugins: [
|
|
125
125
|
corePlugin(backend), // required: runs the queries
|
|
126
126
|
exportPlugin(backend), // query.export()
|
|
127
|
-
lineagePlugin(backend), // Anfra.lineage()
|
|
127
|
+
lineagePlugin(backend), // Anfra.lineage(), and the panel's Lineage tab
|
|
128
128
|
renderPlugin(), // Anfra.render(): the host saves PNGs and PDFs the frame makes
|
|
129
129
|
inspectPlugin(), // what an inspect panel needs
|
|
130
130
|
],
|
package/dist/app.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, I as InstalledPlugins, M as Mapping, O as OVERLAY_ID,
|
|
1
|
+
import { S as Sdk } from './bootstrap-MhTSkiA1.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 FrameMenuItem, I as InstalledPlugins, M as Mapping, f as ModalInput, O as OVERLAY_ID, g as Opened, h as PluginApi, i as PluginMembers, j as PluginName, P as PluginSetup, k as PopoverInput, l as PopoverSide, Q as Query, m as STRUCTURE_ATTRIBUTES, V as VERSION, n as bootstrap, o as buildStructure, p as createSdk, q as parseRef } from './bootstrap-MhTSkiA1.js';
|
|
3
3
|
export { D as DataAppError, P as PermissionError, Q as QueryError, T as TransportError, V as ValidationError } from './errors-CKvqVaqU.js';
|
|
4
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 ColumnMeta, l as Condition, m as ConditionValue, n as ControlMappingJson, o as CrossFilterJson, D as DatasetDescriptor, p as DateDrillDeclaration, q as DateGrain, r as DateTransformation, E as EntityKind, s as EntityRef, t as EntityUsage, u as ExecuteOptions, v as ExecuteSummary, w as ExportFormat, x as ExportFormatOptions, y as ExportOptions, z as ExportResult, F as FILTER_AGGREGATIONS, G as FieldLineage, H as FieldSuggestionsRequest, I as FilterAggregation, J as FilterDeclaration, K as FilterValueType, L as InspectedApp, M as InspectedControl, N as InspectedError, O as InspectedQuery, P as InspectedSelection, Q as InspectedStructure, R as LineageCard, S as LineageDiagram, T as LineageNode, U as LineageOptions, V as LineageResult, W as LineageTarget, X as Listener, Y as LocateKind, Z as LocateTarget, _ as MappingJson, $ as Operator, a0 as QueryDebug, a1 as QueryDeclaration, a2 as QueryInput, a3 as QueryResult, a4 as QuerySort, a5 as QueryState, a6 as QueryTimings, a7 as RenderFormat, a8 as RenderRequest, a9 as Rendering, aa as Row, ab as SdkEnvironment, ac as SdkFeatures, ad as Selection, ae as SelectionCondition, af as SemanticType, ag as StructureKind, ah as StructureNode, ai as Unsubscribe, aj as User } from './types-CWNv6N0y.js';
|
|
5
|
-
export { B as BridgeError, a as BridgeMessage, F as FrameMessage, H as HostMessage, P as PROVISION_ELEMENT_ID,
|
|
5
|
+
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, b as MenuTarget, c as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, d as PluginInfo, e as Provision, R as RowsTarget, T as THEME_TOKENS, f as TargetRect, g as Theme, h as ThemeInput, i as ThemeScheme, j as ThemeToken, k as ThemeTokens, l as checkTarget, r as resolveTheme } from './menu-CdGVKc4_.js';
|
|
6
6
|
|
|
7
7
|
declare const SANDBOX_GLOBAL = "Anfra";
|
|
8
8
|
/**
|
|
@@ -23,6 +23,7 @@ declare function installSandbox(sdk: Sdk, target?: Record<string, unknown>): ()
|
|
|
23
23
|
* document, holding one shadow root per part (the kernel's, each plugin's), so the page's styles
|
|
24
24
|
* don't reach in and theirs don't reach out. A rendering never draws it.
|
|
25
25
|
*/
|
|
26
|
+
|
|
26
27
|
declare const LAYER_ATTRIBUTE = "data-anfra-layer";
|
|
27
28
|
|
|
28
29
|
export { LAYER_ATTRIBUTE, SANDBOX_GLOBAL, Sdk, installSandbox };
|
package/dist/app.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-UUKXJSE4.js";
|
|
2
|
+
import {
|
|
3
|
+
checkTarget
|
|
4
|
+
} from "./chunk-KFD6CHLI.js";
|
|
2
5
|
import {
|
|
3
6
|
ATTR,
|
|
4
7
|
App,
|
|
@@ -19,15 +22,18 @@ import {
|
|
|
19
22
|
createSdk,
|
|
20
23
|
installSandbox,
|
|
21
24
|
parseRef
|
|
22
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-HRV45ULB.js";
|
|
23
26
|
import {
|
|
24
27
|
FILTER_AGGREGATIONS
|
|
25
28
|
} from "./chunk-XIUFHRZE.js";
|
|
26
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-S6XLP6U4.js";
|
|
27
30
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
DEFAULT_TOKENS,
|
|
32
|
+
PROVISION_ELEMENT_ID,
|
|
33
|
+
THEME_TOKENS,
|
|
34
|
+
resolveTheme
|
|
35
|
+
} from "./chunk-F6MRA7J4.js";
|
|
36
|
+
import "./chunk-Q46CZIEK.js";
|
|
31
37
|
import {
|
|
32
38
|
DataAppError,
|
|
33
39
|
PermissionError,
|
|
@@ -40,6 +46,7 @@ export {
|
|
|
40
46
|
App,
|
|
41
47
|
Control,
|
|
42
48
|
CrossFilter,
|
|
49
|
+
DEFAULT_TOKENS,
|
|
43
50
|
DataAppError,
|
|
44
51
|
DateDrillControl,
|
|
45
52
|
FILTER_AGGREGATIONS,
|
|
@@ -55,12 +62,15 @@ export {
|
|
|
55
62
|
SANDBOX_GLOBAL,
|
|
56
63
|
ATTR as STRUCTURE_ATTRIBUTES,
|
|
57
64
|
Sdk,
|
|
65
|
+
THEME_TOKENS,
|
|
58
66
|
TransportError,
|
|
59
67
|
VERSION,
|
|
60
68
|
ValidationError,
|
|
61
69
|
bootstrap,
|
|
62
70
|
buildStructure,
|
|
71
|
+
checkTarget,
|
|
63
72
|
createSdk,
|
|
64
73
|
installSandbox,
|
|
65
|
-
parseRef
|
|
74
|
+
parseRef,
|
|
75
|
+
resolveTheme
|
|
66
76
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as DataAppError, V as ValidationError, Q as QueryError, P as PermissionError, T as TransportError } from './errors-CKvqVaqU.js';
|
|
2
2
|
import { X as Listener, ai as Unsubscribe, D as DatasetDescriptor, y as ExportOptions, z as ExportResult, a8 as RenderRequest, a9 as Rendering, W as LineageTarget, U as LineageOptions, V as LineageResult, E as EntityKind, l as Condition, J as FilterDeclaration, K as FilterValueType, B as Backend, m as ConditionValue, p as DateDrillDeclaration, q as DateGrain, I as FilterAggregation, n as ControlMappingJson, o as CrossFilterJson, ac as SdkFeatures, ad as Selection, ae as SelectionCondition, aa as Row, Y as LocateKind, a1 as QueryDeclaration, a5 as QueryState, a3 as QueryResult, a4 as QuerySort, a as AppDeclaration, u as ExecuteOptions, v as ExecuteSummary, f as BackendExportRequest, b as AppJson, L as InspectedApp, aj as User, ab as SdkEnvironment, Q as InspectedStructure } from './types-CWNv6N0y.js';
|
|
3
|
-
import {
|
|
3
|
+
import { d as PluginInfo, i as ThemeScheme, k as ThemeTokens, g as Theme, c as MenuTargetKind, b as MenuTarget, N as NodeTarget } from './menu-CdGVKc4_.js';
|
|
4
4
|
|
|
5
5
|
interface NotificationTarget {
|
|
6
6
|
notifyChange(): void;
|
|
@@ -258,6 +258,8 @@ interface AppContext {
|
|
|
258
258
|
fetchPage(query: Query): Promise<void>;
|
|
259
259
|
/** Brings an entity's marked elements into view; false when none is on the page. */
|
|
260
260
|
locate(kind: LocateKind, name: string): boolean;
|
|
261
|
+
/** Opens the content menu on these rows of this query, for the event; whether one opens. */
|
|
262
|
+
menu(query: Query, event: Event, rows: readonly Row[], fields?: readonly string[]): boolean;
|
|
261
263
|
}
|
|
262
264
|
|
|
263
265
|
declare class Query extends Observable {
|
|
@@ -324,6 +326,16 @@ declare class Query extends Observable {
|
|
|
324
326
|
abort(): void;
|
|
325
327
|
/** Fetches the next page and appends it. Rejects rather than swallowing, unlike `execute()`. */
|
|
326
328
|
fetchMore(): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Opens the menu on these rows of this query: the items plugins and the host offer for a point
|
|
331
|
+
* of data, such as "View underlying data". Call it from your chart's own right-click handler,
|
|
332
|
+
* with the event and the rows under the pointer, as for `select`; `fields` narrows the dimensions
|
|
333
|
+
* that take part. Whether a menu opens: when one does, the event's default (the browser's menu)
|
|
334
|
+
* is prevented, and when none would (no plugin offers one), nothing happens.
|
|
335
|
+
*/
|
|
336
|
+
menu(event: Event, rows: Row | readonly Row[], options?: {
|
|
337
|
+
fields?: readonly string[];
|
|
338
|
+
}): boolean;
|
|
327
339
|
/**
|
|
328
340
|
* Cross-filters this query's targets by the rows the reader picked.
|
|
329
341
|
*
|
|
@@ -453,6 +465,7 @@ declare class App extends Observable implements AppContext {
|
|
|
453
465
|
* rebucketed anything yet, so the rows they are clicking still belong to the applied grain.
|
|
454
466
|
*/
|
|
455
467
|
private drillTransformations;
|
|
468
|
+
menu(query: Query, event: Event, rows: readonly Row[], fields?: readonly string[]): boolean;
|
|
456
469
|
select(query: Query, rows: readonly Row[], fields?: readonly string[]): void;
|
|
457
470
|
/** True when a control or the selection has changed since the queries reading it last ran. */
|
|
458
471
|
get hasChanges(): boolean;
|
|
@@ -514,6 +527,23 @@ declare class App extends Observable implements AppContext {
|
|
|
514
527
|
private assertAcyclic;
|
|
515
528
|
}
|
|
516
529
|
|
|
530
|
+
/**
|
|
531
|
+
* The host's theme, as `Anfra.theme`: its scheme and tokens, for a definition that wants to follow
|
|
532
|
+
* its host's light or dark mode. Nothing is applied to the page unasked: read them, or use the
|
|
533
|
+
* `--anfra-*` names in your own CSS after setting them yourself.
|
|
534
|
+
*/
|
|
535
|
+
declare class HostTheme {
|
|
536
|
+
private current;
|
|
537
|
+
private readonly listeners;
|
|
538
|
+
/** `light` or `dark`; `light` until the host says. */
|
|
539
|
+
get scheme(): ThemeScheme;
|
|
540
|
+
/** Every token by name (`color-bg`, `font`): each is the CSS custom property `--anfra-<name>`. */
|
|
541
|
+
get tokens(): Readonly<ThemeTokens>;
|
|
542
|
+
/** Each time the host's theme changes. Returns the function that stops listening. */
|
|
543
|
+
subscribe(listener: (theme: Theme) => void): () => void;
|
|
544
|
+
/** @internal The kernel's, on the host's word. */
|
|
545
|
+
set(theme: Theme): void;
|
|
546
|
+
}
|
|
517
547
|
/** The plugins a host installed, as `Anfra.plugins`. */
|
|
518
548
|
declare class InstalledPlugins {
|
|
519
549
|
/** Each plugin's name and version, in the order the host installed them. */
|
|
@@ -574,6 +604,8 @@ declare class Sdk {
|
|
|
574
604
|
* before using an optional one.
|
|
575
605
|
*/
|
|
576
606
|
readonly plugins: InstalledPlugins;
|
|
607
|
+
/** The host's theme: `light` or `dark`, and its tokens. */
|
|
608
|
+
readonly theme: HostTheme;
|
|
577
609
|
/** The kernel's gates (`dateDrill`), as the environment gave them. */
|
|
578
610
|
private readonly gates;
|
|
579
611
|
private deprecatedFeatures?;
|
|
@@ -669,6 +701,57 @@ interface BuiltStructure extends InspectedStructure {
|
|
|
669
701
|
*/
|
|
670
702
|
declare function buildStructure(doc: Document, apps: readonly App[]): BuiltStructure;
|
|
671
703
|
|
|
704
|
+
/** Which side of its anchor a popover opens on. */
|
|
705
|
+
type PopoverSide = 'right' | 'left' | 'bottom' | 'top';
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Content UI, the kernel's side: the menu on a marked block (a right-click) or on a chart's point
|
|
709
|
+
* (`query.menu`), filled with plugins' frame items and the host's own; and the modal and popover a
|
|
710
|
+
* plugin's frame half opens. What draws them is the kernel's UI body, sent on first use, so a frame
|
|
711
|
+
* carries only the listener and the item list until someone opens one. One is open at a time.
|
|
712
|
+
*/
|
|
713
|
+
|
|
714
|
+
/** An entry a plugin's frame half adds to the menu, for one kind of target. */
|
|
715
|
+
interface FrameMenuItem {
|
|
716
|
+
/** Under the plugin's name once added (`underlying` is `explore.underlying`). */
|
|
717
|
+
id: string;
|
|
718
|
+
label: string;
|
|
719
|
+
target: MenuTargetKind;
|
|
720
|
+
/**
|
|
721
|
+
* Whether it applies to this target; it shows when this is left out. Presentation only: frame code
|
|
722
|
+
* shares a realm with the definition and can enforce nothing, so a rule that must hold belongs on
|
|
723
|
+
* the host, in the calls the item makes.
|
|
724
|
+
*/
|
|
725
|
+
when?: (target: MenuTarget) => boolean;
|
|
726
|
+
run: (target: MenuTarget) => unknown;
|
|
727
|
+
}
|
|
728
|
+
interface ModalInput {
|
|
729
|
+
title: string;
|
|
730
|
+
size?: 'sm' | 'md' | 'lg' | 'full';
|
|
731
|
+
/** Draw the content into its own shadow root, on the host's `--anfra-*` tokens; what it returns runs on close. */
|
|
732
|
+
mount: (root: ShadowRoot) => void | (() => void);
|
|
733
|
+
onClose?: () => void;
|
|
734
|
+
}
|
|
735
|
+
interface PopoverInput {
|
|
736
|
+
/** A node (a target's, kept in view as the page scrolls), or a point in the viewport. */
|
|
737
|
+
anchor: NodeTarget | {
|
|
738
|
+
x: number;
|
|
739
|
+
y: number;
|
|
740
|
+
};
|
|
741
|
+
/** The side of the anchor it opens on: `right` unless given; another when that one has no room. */
|
|
742
|
+
side?: PopoverSide;
|
|
743
|
+
mount: (root: ShadowRoot) => void | (() => void);
|
|
744
|
+
/** `outside`: a click anywhere else closes it. Unless asked, only Escape and its close button do. */
|
|
745
|
+
dismiss?: 'outside';
|
|
746
|
+
/** false: no close button, for content that draws its own (and calls `close`). */
|
|
747
|
+
closeButton?: boolean;
|
|
748
|
+
onClose?: () => void;
|
|
749
|
+
}
|
|
750
|
+
/** An open modal or popover. */
|
|
751
|
+
interface Opened {
|
|
752
|
+
close: () => void;
|
|
753
|
+
}
|
|
754
|
+
|
|
672
755
|
/**
|
|
673
756
|
* The kernel, as a plugin's frame half sees it: the app model, the bridge under the plugin's name,
|
|
674
757
|
* a place in the plugin layer, and the ways to add API for the author. One per plugin, made by the
|
|
@@ -714,6 +797,16 @@ interface FrameKernel {
|
|
|
714
797
|
layer: () => ShadowRoot;
|
|
715
798
|
/** The plugin's frame body, fetched and run on first use: what it exports. */
|
|
716
799
|
body: <T = unknown>() => Promise<T>;
|
|
800
|
+
/**
|
|
801
|
+
* Add an entry to the menu on a marked block (`target: 'node'`) or on a query's rows
|
|
802
|
+
* (`target: 'rows'`, opened by the definition's `query.menu`). The menu shows only once an entry
|
|
803
|
+
* exists, from a plugin or the host.
|
|
804
|
+
*/
|
|
805
|
+
menuItem: (item: FrameMenuItem) => void;
|
|
806
|
+
/** Open a modal over the page, drawn by the kernel; your content goes in its own shadow root. */
|
|
807
|
+
modal: (input: ModalInput) => Promise<Opened>;
|
|
808
|
+
/** Open a popover beside a node or a point, following it as the page scrolls. */
|
|
809
|
+
popover: (input: PopoverInput) => Promise<Opened>;
|
|
717
810
|
}
|
|
718
811
|
|
|
719
812
|
/** A plugin's frame setup, as the host's frame script hands it over: its name and its function. */
|
|
@@ -721,5 +814,5 @@ type PluginSetup = readonly [name: string, setup: ((kernel: FrameKernel) => void
|
|
|
721
814
|
/** Provision the SDK in `win` from its host, run the plugins' setups, and install it. Returns once `Anfra` exists. */
|
|
722
815
|
declare function bootstrap(win: Window, setups?: readonly PluginSetup[]): void;
|
|
723
816
|
|
|
724
|
-
export { Control as C, DateDrillControl as D, Filter as F, InstalledPlugins as I, Mapping as M, OVERLAY_ID as O, Query as Q, Sdk as S, VERSION as V, App as a, CrossFilter as b, ATTR as
|
|
725
|
-
export type { AnfraPlugins as A, Edge as E, PluginSetup as P, DeprecatedFeatures as c, FrameKernel as d,
|
|
817
|
+
export { Control as C, DateDrillControl as D, Filter as F, InstalledPlugins as I, Mapping as M, OVERLAY_ID as O, Query as Q, Sdk as S, VERSION as V, App as a, CrossFilter as b, ATTR as m, bootstrap as n, buildStructure as o, createSdk as p, parseRef as q };
|
|
818
|
+
export type { AnfraPlugins as A, Edge as E, PluginSetup as P, DeprecatedFeatures as c, FrameKernel as d, FrameMenuItem as e, ModalInput as f, Opened as g, PluginApi as h, PluginMembers as i, PluginName as j, PopoverInput as k, PopoverSide as l };
|
package/dist/build.d.ts
CHANGED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DATA_TAB,
|
|
3
|
+
DECLARATION_TAB,
|
|
4
|
+
QUERIES_TAB,
|
|
5
|
+
STRUCTURE_TAB
|
|
6
|
+
} from "./chunk-H52PO7MP.js";
|
|
7
|
+
|
|
8
|
+
// src/plugins/inspect/model/requests.ts
|
|
9
|
+
function describe(call, request) {
|
|
10
|
+
switch (call) {
|
|
11
|
+
case "core.submitQuery": {
|
|
12
|
+
const r = request;
|
|
13
|
+
return {
|
|
14
|
+
dataset: r.dataset,
|
|
15
|
+
aql: r.aql,
|
|
16
|
+
input: r.input,
|
|
17
|
+
page: r.page,
|
|
18
|
+
pageSize: r.pageSize,
|
|
19
|
+
timezone: r.timezone,
|
|
20
|
+
bustCache: r.bustCache
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
case "core.fieldSuggestions": {
|
|
24
|
+
const r = request;
|
|
25
|
+
return { dataset: r.dataset, field: `${r.model}.${r.field}`, q: r.q };
|
|
26
|
+
}
|
|
27
|
+
case "export.query": {
|
|
28
|
+
const r = request;
|
|
29
|
+
return {
|
|
30
|
+
dataset: r.dataset,
|
|
31
|
+
aql: r.aql,
|
|
32
|
+
input: r.input,
|
|
33
|
+
timezone: r.timezone,
|
|
34
|
+
format: r.format,
|
|
35
|
+
formatOptions: r.formatOptions,
|
|
36
|
+
filename: r.filename
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
case "lineage.trace": {
|
|
40
|
+
const r = request;
|
|
41
|
+
return { targets: r.targets.map((t) => `${t.parent}.${t.child}`) };
|
|
42
|
+
}
|
|
43
|
+
case "render.save":
|
|
44
|
+
return { filename: request?.filename };
|
|
45
|
+
default:
|
|
46
|
+
return { request };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function summarize(call, result, previewRows) {
|
|
50
|
+
switch (call) {
|
|
51
|
+
case "core.submitQuery": {
|
|
52
|
+
const r = result;
|
|
53
|
+
return {
|
|
54
|
+
fromCache: r.debug?.fromCache,
|
|
55
|
+
numRows: r.meta?.numRows ?? r.values.length,
|
|
56
|
+
columns: r.columns.map((column) => column.name),
|
|
57
|
+
preview: r.values.slice(0, previewRows)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
case "core.fieldSuggestions":
|
|
61
|
+
return { numRows: result.length };
|
|
62
|
+
case "export.query":
|
|
63
|
+
return { numRows: result.rowCount };
|
|
64
|
+
case "lineage.trace":
|
|
65
|
+
return { numRows: result.results.length };
|
|
66
|
+
default:
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
var callerOf = (context) => context.caller.kind === "plugin" ? `plugin ${context.caller.plugin}` : context.caller.kind;
|
|
71
|
+
function createRequestLog({ limit = 200, previewRows = 20 } = {}) {
|
|
72
|
+
let entries = [];
|
|
73
|
+
let nextId = 1;
|
|
74
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
75
|
+
const changed = () => {
|
|
76
|
+
for (const listener of listeners) {
|
|
77
|
+
try {
|
|
78
|
+
listener();
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error(err);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const add = (entry) => {
|
|
85
|
+
entries = [...entries.slice(Math.max(0, entries.length - limit + 1)), entry];
|
|
86
|
+
changed();
|
|
87
|
+
};
|
|
88
|
+
const settle = (id, patch) => {
|
|
89
|
+
entries = entries.map((entry) => entry.id === id ? { ...entry, ...patch } : entry);
|
|
90
|
+
changed();
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
async record(request, context, next) {
|
|
94
|
+
if (context.origin.kind === "host") return next();
|
|
95
|
+
const id = nextId++;
|
|
96
|
+
const started = performance.now();
|
|
97
|
+
let details = {};
|
|
98
|
+
try {
|
|
99
|
+
details = describe(context.name, request);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
console.error(err);
|
|
102
|
+
}
|
|
103
|
+
add({
|
|
104
|
+
...details,
|
|
105
|
+
id,
|
|
106
|
+
call: context.name,
|
|
107
|
+
caller: callerOf(context),
|
|
108
|
+
// A copy: the host keeps adding the middleware after this one.
|
|
109
|
+
...context.trace.length > 1 && { trace: context.trace.slice(0, -1) },
|
|
110
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
111
|
+
status: "pending"
|
|
112
|
+
});
|
|
113
|
+
const durationMs = () => Math.round(performance.now() - started);
|
|
114
|
+
let result;
|
|
115
|
+
try {
|
|
116
|
+
result = await next();
|
|
117
|
+
} catch (err) {
|
|
118
|
+
settle(id, {
|
|
119
|
+
status: context.signal.aborted ? "aborted" : "error",
|
|
120
|
+
durationMs: durationMs(),
|
|
121
|
+
error: err instanceof Error ? `${err.name}: ${err.message}` : String(err)
|
|
122
|
+
});
|
|
123
|
+
throw err;
|
|
124
|
+
}
|
|
125
|
+
let summary = {};
|
|
126
|
+
try {
|
|
127
|
+
summary = summarize(context.name, result, previewRows);
|
|
128
|
+
} catch (err) {
|
|
129
|
+
console.error(err);
|
|
130
|
+
}
|
|
131
|
+
settle(id, { status: "ok", durationMs: durationMs(), ...summary });
|
|
132
|
+
return result;
|
|
133
|
+
},
|
|
134
|
+
log: {
|
|
135
|
+
entries: () => entries,
|
|
136
|
+
subscribe(listener) {
|
|
137
|
+
listeners.add(listener);
|
|
138
|
+
return () => listeners.delete(listener);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function queriesOf(entry, apps) {
|
|
144
|
+
if (entry.call !== "core.submitQuery" && entry.call !== "export.query") return [];
|
|
145
|
+
return apps.flatMap(
|
|
146
|
+
(app, index) => Object.entries(app.declaration.queries).filter(([, q]) => q.dataset === entry.dataset && q.aql === entry.aql).map(([name]) => ({ app: index, name }))
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
function attributeRequests(entries, apps) {
|
|
150
|
+
const byQuery = /* @__PURE__ */ new Map();
|
|
151
|
+
const other = [];
|
|
152
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
153
|
+
const entry = entries[i];
|
|
154
|
+
const refs = entry.aql && entry.dataset ? queriesOf({ ...entry, dataset: entry.dataset, aql: entry.aql }, apps) : [];
|
|
155
|
+
if (refs.length === 0) other.push(entry);
|
|
156
|
+
for (const ref of refs) {
|
|
157
|
+
const key = `${ref.app}/${ref.name}`;
|
|
158
|
+
const item = { entry, shared: refs.length > 1 };
|
|
159
|
+
const list = byQuery.get(key);
|
|
160
|
+
if (list) list.push(item);
|
|
161
|
+
else byQuery.set(key, [item]);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return { byQuery, other };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/plugins/inspect/state.ts
|
|
168
|
+
var states = /* @__PURE__ */ new WeakMap();
|
|
169
|
+
function stateOf(mount) {
|
|
170
|
+
let state = states.get(mount);
|
|
171
|
+
if (!state) {
|
|
172
|
+
state = createState();
|
|
173
|
+
states.set(mount, state);
|
|
174
|
+
}
|
|
175
|
+
return state;
|
|
176
|
+
}
|
|
177
|
+
function dropState(mount) {
|
|
178
|
+
states.delete(mount);
|
|
179
|
+
}
|
|
180
|
+
function createState() {
|
|
181
|
+
const recorder = createRequestLog();
|
|
182
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
183
|
+
const changed = () => listeners.forEach((listener) => {
|
|
184
|
+
try {
|
|
185
|
+
listener();
|
|
186
|
+
} catch {
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
let nonce = 0;
|
|
190
|
+
const state = {
|
|
191
|
+
requests: recorder.log,
|
|
192
|
+
record: recorder.record,
|
|
193
|
+
queries: { search: "", filter: "all", open: /* @__PURE__ */ new Set(), closed: /* @__PURE__ */ new Set() },
|
|
194
|
+
data: { open: /* @__PURE__ */ new Set() },
|
|
195
|
+
revealed: void 0,
|
|
196
|
+
reveal(panel, target) {
|
|
197
|
+
state.revealed = { target, nonce: ++nonce };
|
|
198
|
+
if ("node" in target) {
|
|
199
|
+
panel.show(STRUCTURE_TAB, target.node);
|
|
200
|
+
} else if ("entity" in target) {
|
|
201
|
+
const key = `${target.entity}:${target.app}/${target.name}`;
|
|
202
|
+
state.queries.open.add(key);
|
|
203
|
+
state.queries.closed.delete(`${target.app}:${target.entity === "query" ? "queries" : "controls"}`);
|
|
204
|
+
state.queries.search = "";
|
|
205
|
+
state.queries.filter = "all";
|
|
206
|
+
panel.show(QUERIES_TAB);
|
|
207
|
+
} else if ("table" in target) {
|
|
208
|
+
state.data.open.add(`${target.app}/${target.table}`);
|
|
209
|
+
panel.show(DATA_TAB);
|
|
210
|
+
} else if ("check" in target) {
|
|
211
|
+
panel.show(DECLARATION_TAB);
|
|
212
|
+
} else {
|
|
213
|
+
if (target.tab === QUERIES_TAB) {
|
|
214
|
+
state.queries.search = "";
|
|
215
|
+
state.queries.filter = target.filter ?? "all";
|
|
216
|
+
}
|
|
217
|
+
panel.show(target.tab);
|
|
218
|
+
}
|
|
219
|
+
changed();
|
|
220
|
+
},
|
|
221
|
+
subscribe(listener) {
|
|
222
|
+
listeners.add(listener);
|
|
223
|
+
return () => {
|
|
224
|
+
listeners.delete(listener);
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
recorder.log.subscribe(changed);
|
|
229
|
+
return state;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export {
|
|
233
|
+
queriesOf,
|
|
234
|
+
attributeRequests,
|
|
235
|
+
stateOf,
|
|
236
|
+
dropState
|
|
237
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
controlMappings,
|
|
3
|
+
crossFilters
|
|
4
|
+
} from "./chunk-K633QHGO.js";
|
|
5
|
+
import {
|
|
6
|
+
formatCondition
|
|
7
|
+
} from "./chunk-H52PO7MP.js";
|
|
8
|
+
|
|
9
|
+
// src/plugins/inspect/model/inputs.ts
|
|
10
|
+
var MANUAL_TYPES = {
|
|
11
|
+
string: "text",
|
|
12
|
+
number: "number",
|
|
13
|
+
date: "date",
|
|
14
|
+
boolean: "truefalse"
|
|
15
|
+
};
|
|
16
|
+
function controlType(declared, condition) {
|
|
17
|
+
if (declared && MANUAL_TYPES[declared]) return MANUAL_TYPES[declared];
|
|
18
|
+
const value = condition?.values?.[0];
|
|
19
|
+
if (typeof value === "number") return "number";
|
|
20
|
+
if (typeof value === "boolean") return "truefalse";
|
|
21
|
+
if (value instanceof Date) return "datetime";
|
|
22
|
+
return typeof value === "string" ? "text" : void 0;
|
|
23
|
+
}
|
|
24
|
+
var mappingField = (m) => m.aggregation ? `${m.aggregation}(${m.field})` : m.field;
|
|
25
|
+
var conditionText = (condition) => condition?.values?.length ? formatCondition(condition) : "not set";
|
|
26
|
+
var selectionText = (selection) => selection ? selection.conditions.map((condition) => `${condition.field} ${formatCondition(condition)}`).join("; ") || selection.expression || `${selection.rowCount} rows` : "no selection";
|
|
27
|
+
function queryInputs(app, query) {
|
|
28
|
+
const controls = controlMappings(app).filter((m) => m.to.name === query).map((m) => {
|
|
29
|
+
const control = app.controls[m.from.name];
|
|
30
|
+
const value = conditionText(control?.appliedCondition);
|
|
31
|
+
const current = conditionText(control?.condition);
|
|
32
|
+
return {
|
|
33
|
+
kind: "control",
|
|
34
|
+
source: m.from.name,
|
|
35
|
+
self: false,
|
|
36
|
+
field: mappingField(m),
|
|
37
|
+
type: controlType(
|
|
38
|
+
app.declaration.filters[m.from.name]?.type,
|
|
39
|
+
control?.appliedCondition ?? control?.condition
|
|
40
|
+
),
|
|
41
|
+
value,
|
|
42
|
+
pending: control?.isDirty && current !== value ? current : void 0
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
const crosses = crossFilters(app).filter((c) => c.to.name === query).map((c) => {
|
|
46
|
+
const from = (selection) => selection?.source === c.from.name ? selection : void 0;
|
|
47
|
+
const applied = from(app.appliedSelection);
|
|
48
|
+
const current = from(app.selection);
|
|
49
|
+
const value = selectionText(applied);
|
|
50
|
+
const next = selectionText(current);
|
|
51
|
+
return {
|
|
52
|
+
kind: "crossFilter",
|
|
53
|
+
source: c.from.name,
|
|
54
|
+
self: c.from.name === query,
|
|
55
|
+
field: (applied ?? current)?.fields.join(", ") || "\u2014",
|
|
56
|
+
value,
|
|
57
|
+
pending: next !== value ? next : void 0
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
return [...controls, ...crosses];
|
|
61
|
+
}
|
|
62
|
+
function controlTargets(app, control) {
|
|
63
|
+
return controlMappings(app).filter((m) => m.from.name === control).map((m) => ({ query: m.to.name, field: mappingField(m) }));
|
|
64
|
+
}
|
|
65
|
+
function crossFilterTargets(app, query) {
|
|
66
|
+
return crossFilters(app).filter((c) => c.from.name === query).map((c) => ({ query: c.to.name, self: c.to.name === query }));
|
|
67
|
+
}
|
|
68
|
+
function withoutComments(text) {
|
|
69
|
+
let out = "";
|
|
70
|
+
let quote;
|
|
71
|
+
for (let i = 0; i < text.length; i++) {
|
|
72
|
+
const ch = text[i] ?? "";
|
|
73
|
+
if (quote) {
|
|
74
|
+
out += ch;
|
|
75
|
+
if (ch === "\\") out += text[++i] ?? "";
|
|
76
|
+
else if (ch === quote) quote = void 0;
|
|
77
|
+
} else if (ch === '"' || ch === "'" || ch === "`") {
|
|
78
|
+
quote = ch;
|
|
79
|
+
out += ch;
|
|
80
|
+
} else if (ch === "/" && text[i + 1] === "/") {
|
|
81
|
+
while (i < text.length && text[i] !== "\n") i++;
|
|
82
|
+
i--;
|
|
83
|
+
} else if (ch === "/" && text[i + 1] === "*") {
|
|
84
|
+
const end = text.indexOf("*/", i + 2);
|
|
85
|
+
i = end < 0 ? text.length : end + 1;
|
|
86
|
+
out += " ";
|
|
87
|
+
} else out += ch;
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
function blockAt(text, open) {
|
|
92
|
+
let depth = 0;
|
|
93
|
+
let quote;
|
|
94
|
+
for (let i = open; i < text.length; i++) {
|
|
95
|
+
const ch = text[i] ?? "";
|
|
96
|
+
if (quote) {
|
|
97
|
+
if (ch === "\\") i++;
|
|
98
|
+
else if (ch === quote) quote = void 0;
|
|
99
|
+
} else if (ch === '"' || ch === "'" || ch === "`") quote = ch;
|
|
100
|
+
else if (ch === "{") depth++;
|
|
101
|
+
else if (ch === "}" && --depth === 0) return text.slice(open + 1, i);
|
|
102
|
+
}
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
function splitEntries(block) {
|
|
106
|
+
const entries = [];
|
|
107
|
+
let depth = 0;
|
|
108
|
+
let quote;
|
|
109
|
+
let current = "";
|
|
110
|
+
for (let i = 0; i < block.length; i++) {
|
|
111
|
+
const ch = block[i] ?? "";
|
|
112
|
+
if (quote) {
|
|
113
|
+
if (ch === "\\") {
|
|
114
|
+
current += ch + (block[++i] ?? "");
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (ch === quote) quote = void 0;
|
|
118
|
+
} else if (ch === '"' || ch === "'" || ch === "`") quote = ch;
|
|
119
|
+
else if ("({[".includes(ch)) depth++;
|
|
120
|
+
else if (")}]".includes(ch)) depth--;
|
|
121
|
+
else if ((ch === ";" || ch === "\n") && depth <= 0) {
|
|
122
|
+
entries.push(current);
|
|
123
|
+
current = "";
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
current += ch;
|
|
127
|
+
}
|
|
128
|
+
entries.push(current);
|
|
129
|
+
return entries.map((entry) => entry.trim()).filter(Boolean);
|
|
130
|
+
}
|
|
131
|
+
function literalType(operand) {
|
|
132
|
+
if (/^["'`]/.test(operand)) return "text";
|
|
133
|
+
if (/^-?\d/.test(operand)) return "number";
|
|
134
|
+
if (operand.startsWith("@")) return "date";
|
|
135
|
+
return /^(true|false)\b/.test(operand) ? "truefalse" : void 0;
|
|
136
|
+
}
|
|
137
|
+
var CONDITION = /^(.*?)\s+(==|!=|>=|<=|>|<|not in|in|is not|is|like|not like|matches|not matches)\s+(.+)$/s;
|
|
138
|
+
function declaredFilters(source) {
|
|
139
|
+
const aql = source && withoutComments(source);
|
|
140
|
+
const at = aql?.search(/\bfilters\s*\{/);
|
|
141
|
+
if (!aql || at === void 0 || at < 0) return [];
|
|
142
|
+
const block = blockAt(aql, aql.indexOf("{", at));
|
|
143
|
+
if (block === void 0) return [];
|
|
144
|
+
return splitEntries(block).map((entry) => {
|
|
145
|
+
const text = entry.replace(/\s+/g, " ");
|
|
146
|
+
const match = CONDITION.exec(text);
|
|
147
|
+
const operand = match?.[3]?.replace(/^[[(]\s*/, "");
|
|
148
|
+
return {
|
|
149
|
+
type: operand ? literalType(operand) : void 0,
|
|
150
|
+
kind: "declared",
|
|
151
|
+
source: "query",
|
|
152
|
+
self: true,
|
|
153
|
+
field: match?.[1] ?? text,
|
|
154
|
+
value: match ? `${match[2]} ${match[3]}` : "\u2014"
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
var isActive = (input) => input.kind === "declared" || input.value !== "not set" && input.value !== "no selection";
|
|
159
|
+
|
|
160
|
+
export {
|
|
161
|
+
queryInputs,
|
|
162
|
+
controlTargets,
|
|
163
|
+
crossFilterTargets,
|
|
164
|
+
declaredFilters,
|
|
165
|
+
isActive
|
|
166
|
+
};
|