@holistics/anfra-sdk 0.13.5 → 0.14.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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/app.d.ts +4 -3
  3. package/dist/app.js +17 -7
  4. package/dist/{bootstrap-BbsNvZ8s.d.ts → bootstrap-MhTSkiA1.d.ts} +96 -3
  5. package/dist/build.d.ts +2 -0
  6. package/dist/chunk-7IHICYVH.js +10 -0
  7. package/dist/chunk-CYZQ7ZTJ.js +237 -0
  8. package/dist/chunk-DITKCHFQ.js +166 -0
  9. package/dist/chunk-F6MRA7J4.js +65 -0
  10. package/dist/chunk-GBXK7F2V.js +431 -0
  11. package/dist/chunk-GOUDXWG4.js +750 -0
  12. package/dist/chunk-GV7SVWEK.js +84 -0
  13. package/dist/chunk-H52PO7MP.js +105 -0
  14. package/dist/chunk-HI3ZAXJK.js +8 -0
  15. package/dist/{chunk-KI5CAVAR.js → chunk-HZEECB6R.js} +477 -25
  16. package/dist/chunk-K633QHGO.js +51 -0
  17. package/dist/chunk-KFD6CHLI.js +38 -0
  18. package/dist/{chunk-OJ5WIKWE.js → chunk-NOFPRSSI.js} +1 -1
  19. package/dist/{chunk-ADWBOQW2.js → chunk-S6XLP6U4.js} +31 -1
  20. package/dist/{chunk-TQ7S5DRE.js → chunk-WI5VJ2Z6.js} +1 -1
  21. package/dist/common.d.ts +1 -1
  22. package/dist/common.js +14 -4
  23. package/dist/data-UCCW2VWH.js +233 -0
  24. package/dist/declaration-GVDOGQY6.js +218 -0
  25. package/dist/host.d.ts +42 -4
  26. package/dist/host.js +412 -9
  27. package/dist/menu-CdGVKc4_.d.ts +151 -0
  28. package/dist/overview-3DNXEQNY.js +358 -0
  29. package/dist/plugin-BmIDirTx.d.ts +303 -0
  30. package/dist/plugins.d.ts +6 -8
  31. package/dist/plugins.js +98 -69
  32. package/dist/queries-2OHKMTPC.js +661 -0
  33. package/dist/structure-WRDUXHD4.js +256 -0
  34. package/dist/tab-HMQOITVM.js +932 -0
  35. package/dist/testing.js +4 -4
  36. package/package.json +1 -1
  37. package/dist/bridge-WC7GliCH.d.ts +0 -73
  38. package/dist/chunk-33B2D4U5.js +0 -6
  39. package/dist/plugin-056-SKwd.d.ts +0 -132
  40. /package/dist/{chunk-52LXBYQM.js → chunk-UUKXJSE4.js} +0 -0
package/dist/testing.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  bootstrap
3
- } from "./chunk-KI5CAVAR.js";
3
+ } from "./chunk-HZEECB6R.js";
4
4
  import "./chunk-XIUFHRZE.js";
5
5
  import {
6
6
  createEndpoint
7
- } from "./chunk-ADWBOQW2.js";
7
+ } from "./chunk-S6XLP6U4.js";
8
8
  import {
9
9
  PROVISION_ELEMENT_ID
10
- } from "./chunk-33B2D4U5.js";
11
- import "./chunk-OJ5WIKWE.js";
10
+ } from "./chunk-F6MRA7J4.js";
11
+ import "./chunk-NOFPRSSI.js";
12
12
  import "./chunk-KCTLO3CO.js";
13
13
  import "./chunk-PKBMQBKP.js";
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holistics/anfra-sdk",
3
- "version": "0.13.5",
3
+ "version": "0.14.0",
4
4
  "description": "Data Apps on anfra: the authoring layer (app), what hosts one (host), anfra's plugins (plugins), the core API client (api), and their shared contract (common)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,73 +0,0 @@
1
- import { D as DatasetDescriptor, aj as User } from './types-CWNv6N0y.js';
2
-
3
- /**
4
- * The bridge: the postMessage protocol between a Data App's frame (`app`'s bootstrap) and the
5
- * page hosting it (`host`). The frame has an opaque origin and no access to the API: everything it
6
- * reaches crosses here, as a plugin's calls and events (docs/designs/sdk-plugins.md).
7
- *
8
- * Both sides speak the same messages. A call is answered by its `id`, which each side counts on
9
- * its own: a result answers a call the other side made.
10
- */
11
-
12
- /** A plugin a host installed, as a frame sees it (`Anfra.plugins`). */
13
- interface PluginInfo {
14
- name: string;
15
- version: string;
16
- }
17
- /** What the host provisions a frame with, as JSON in `<script type="application/json" id="anfra-provision">`. */
18
- interface Provision {
19
- datasets: Record<string, DatasetDescriptor>;
20
- user: User;
21
- /** Every plugin the host installed, whether or not it has a frame half. */
22
- plugins: PluginInfo[];
23
- /** The host page's origin: where the frame posts, so nothing else can read its messages. */
24
- hostOrigin: string;
25
- }
26
- declare const PROVISION_ELEMENT_ID = "anfra-provision";
27
- /** An error as it crosses the bridge: the SDK's error class by name, and its message. */
28
- interface BridgeError {
29
- name: string;
30
- message: string;
31
- }
32
- type BridgeMessage =
33
- /** Frame → host: the frame's kernel is running (once per load of its document). */
34
- {
35
- type: 'anfra:ready';
36
- }
37
- /** A plugin call, `<plugin>.<name>`, answered by an `anfra:result` with the same id. */
38
- | {
39
- type: 'anfra:call';
40
- id: number;
41
- name: string;
42
- request: unknown;
43
- } | {
44
- type: 'anfra:result';
45
- id: number;
46
- ok: true;
47
- result: unknown;
48
- } | {
49
- type: 'anfra:result';
50
- id: number;
51
- ok: false;
52
- error: BridgeError;
53
- }
54
- /** The caller gave up on its call: stop it. Nothing answers. */
55
- | {
56
- type: 'anfra:cancel';
57
- id: number;
58
- }
59
- /** A bridge event, `<plugin>.<name>`. Nothing answers. */
60
- | {
61
- type: 'anfra:event';
62
- name: string;
63
- payload: unknown;
64
- };
65
- /** Frame → host. */
66
- type FrameMessage = BridgeMessage;
67
- /** Host → frame. */
68
- type HostMessage = Exclude<BridgeMessage, {
69
- type: 'anfra:ready';
70
- }>;
71
-
72
- export { PROVISION_ELEMENT_ID as P };
73
- export type { BridgeError as B, FrameMessage as F, HostMessage as H, BridgeMessage as a, PluginInfo as b, Provision as c };
@@ -1,6 +0,0 @@
1
- // src/common/bridge.ts
2
- var PROVISION_ELEMENT_ID = "anfra-provision";
3
-
4
- export {
5
- PROVISION_ELEMENT_ID
6
- };
@@ -1,132 +0,0 @@
1
- /**
2
- * What a plugin is, the host's side: a name, a version, the plugins it needs, a host half that
3
- * answers its calls, and the frame half's code. See docs/designs/sdk-plugins.md.
4
- */
5
- /** Who made a call. Middleware and handlers can tell the definition's calls from a plugin's. */
6
- type Caller =
7
- /** The Data App's frame: its definition, or a plugin's frame half there. */
8
- {
9
- kind: 'frame';
10
- }
11
- /** The host page's own code, through `Host.call` or `MountedDataApp.call`. */
12
- | {
13
- kind: 'host';
14
- }
15
- /** Another plugin's host half, by its name. */
16
- | {
17
- kind: 'plugin';
18
- plugin: string;
19
- };
20
- interface CallOptions {
21
- signal?: AbortSignal;
22
- }
23
- /** One call, as its handler and each middleware see it. */
24
- interface CallContext {
25
- /** The call's full name, `<plugin>.<name>`. */
26
- readonly name: string;
27
- readonly caller: Caller;
28
- /**
29
- * Who led to this call, outermost first, ending with `caller`: a query an agent plugin runs for
30
- * the frame's prompt is `[frame, plugin agent]`. Decide by it, or by `origin`, what a call started
31
- * by the frame may do, since a plugin's call made for the frame has the plugin as its `caller`.
32
- */
33
- readonly chain: readonly Caller[];
34
- /** Who started the chain: the frame, or the host (`chain[0]`). */
35
- readonly origin: Caller;
36
- /** Aborts when the caller cancels. */
37
- readonly signal: AbortSignal;
38
- /** The frame the call is about: the one that made it, or the one the host named. */
39
- readonly mount?: MountContext;
40
- /** The middleware the call has passed through so far, by name, outermost first. */
41
- readonly trace: readonly string[];
42
- }
43
- interface HandlerCallOptions extends CallOptions {
44
- /**
45
- * Hold the call to what this chain's origin may call: started by the frame, it is refused unless
46
- * the frame could make it itself. For a handler that forwards a call, or a request, the frame
47
- * chose, so the plugin can't be made to make a host-only call for it.
48
- */
49
- asOrigin?: boolean;
50
- }
51
- /** What a plugin's handler gets: the call, and a way to make calls of its own as that plugin. */
52
- interface HandlerContext extends CallContext {
53
- /**
54
- * Make another plugin's call, through the same pipeline, as this plugin, about the same frame. It
55
- * carries this call's chain, with this plugin added.
56
- */
57
- call: <T = unknown>(name: string, request?: unknown, options?: HandlerCallOptions) => Promise<T>;
58
- }
59
- type CallHandler = (request: any, context: HandlerContext) => unknown;
60
- interface CallDefinition {
61
- handler: CallHandler;
62
- /** Whether a frame may make this call. Off unless true: a call is the host's until its plugin says. */
63
- frame?: boolean;
64
- }
65
- /**
66
- * Code around calls, chosen by name: `*`, `<plugin>.*`, or one call's full name. It may change the
67
- * request, answer in place of the plugin (not calling `next`), refuse the call (throwing), or change
68
- * the answer. Every call passes through it, whoever made it. A plugin's middleware is as powerful as
69
- * the host's: it sees and may change every call on the page, not only its plugin's.
70
- */
71
- interface Middleware {
72
- /** Names the middleware in a call's trace, and orders it among middleware of the same stage. */
73
- name: string;
74
- match: string | readonly string[];
75
- /** Lower runs first (outermost). 0 unless given. Ties are ordered by name, never by registration. */
76
- stage?: number;
77
- handle: (request: unknown, context: CallContext, next: (request?: unknown) => Promise<unknown>) => unknown;
78
- }
79
- /** One mounted frame, as a plugin's host half sees it. */
80
- interface MountContext {
81
- readonly id: number;
82
- readonly frame: HTMLIFrameElement;
83
- /** The host page's document, where the frame is. */
84
- readonly document: Document;
85
- /** Make a call a frame half answers, in this frame. */
86
- call: <T = unknown>(name: string, request?: unknown, options?: CallOptions) => Promise<T>;
87
- /** Send this frame an event. */
88
- emit: (name: string, payload?: unknown) => void;
89
- /** Listen to this frame's events, by full name. Returns the function that stops listening. */
90
- on: (name: string, listener: (payload: any) => void) => () => void;
91
- /** Each time the frame's document (re)loads and its kernel runs. */
92
- onReady: (listener: () => void) => () => void;
93
- }
94
- /**
95
- * Checks one of a frame's events before the host hears it: what it returns is what listeners get,
96
- * and `undefined` drops the event. A frame's events are as untrusted as its calls.
97
- */
98
- type EventCheck = (payload: unknown, mount: MountContext) => unknown;
99
- interface HostHalf {
100
- /** The calls this plugin answers, by their name under the plugin (`submitQuery`, not `core.submitQuery`). */
101
- calls?: Record<string, CallHandler | CallDefinition>;
102
- /**
103
- * The events a frame may send under this plugin's name (`snapshot`, not `inspect.snapshot`), each
104
- * with its check. An event no installed plugin declares never reaches the host.
105
- */
106
- events?: Record<string, EventCheck>;
107
- /** Middleware this plugin puts around calls, its own or others'. */
108
- middleware?: readonly Middleware[];
109
- /** Each time a frame is mounted. What it returns runs when the frame is unmounted. */
110
- mount?: (mount: MountContext) => void | (() => void);
111
- }
112
- /** A frame half: code the host provisions into the frame, as script source (docs/designs/sdk-plugins.md). */
113
- interface FrameHalf {
114
- /** Runs before the definition, once per document: registers the plugin's API. */
115
- setup: string;
116
- /** Loaded on first use, through the kernel. */
117
- body?: string;
118
- }
119
- interface Plugin {
120
- /** Lowercase letters, digits and dashes, starting with a letter. Names its calls, events and API. */
121
- name: string;
122
- version: string;
123
- /** Plugins this one needs; installing it without them fails. */
124
- requires?: readonly string[];
125
- host?: HostHalf;
126
- frame?: FrameHalf;
127
- }
128
- /** A plugin, checked (`checkPlugin`). A host checks every plugin it installs anyway. */
129
- declare function definePlugin<P extends Plugin>(plugin: P): P;
130
-
131
- export { definePlugin as h };
132
- export type { CallOptions as C, EventCheck as E, FrameHalf as F, HandlerCallOptions as H, Middleware as M, Plugin as P, CallContext as a, CallDefinition as b, CallHandler as c, Caller as d, HandlerContext as e, HostHalf as f, MountContext as g };
File without changes