@holistics/anfra-sdk 0.10.2 → 0.11.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/README.md +78 -18
- package/dist/api.d.ts +1 -1
- package/dist/api.js +2 -1
- package/dist/app.d.ts +11 -551
- package/dist/app.js +30 -2194
- package/dist/bootstrap-B7r0ggJN.d.ts +694 -0
- package/dist/bridge-Byq62yS8.d.ts +72 -0
- package/dist/build.d.ts +20 -0
- package/dist/build.js +36 -0
- package/dist/chunk-52LXBYQM.js +0 -0
- package/dist/chunk-ADWBOQW2.js +106 -0
- package/dist/chunk-BL7SPVAS.js +2020 -0
- package/dist/chunk-ENWRS6AT.js +6 -0
- package/dist/{chunk-KBXITYQK.js → chunk-KCTLO3CO.js} +3 -4
- package/dist/chunk-PKBMQBKP.js +7 -0
- package/dist/chunk-TQ7S5DRE.js +24 -0
- package/dist/common.d.ts +2 -2
- package/dist/common.js +4 -2
- package/dist/host.d.ts +52 -63
- package/dist/host.js +229 -221
- package/dist/plugin-C5cihcQD.d.ts +131 -0
- package/dist/plugins.d.ts +52 -0
- package/dist/plugins.js +233 -0
- package/dist/testing.d.ts +47 -0
- package/dist/testing.js +104 -0
- package/dist/{types-DznT0m7F.d.ts → types-BTyDyld7.d.ts} +9 -24
- package/package.json +22 -2
- package/dist/bridge-DUKdREoK.d.ts +0 -133
- /package/dist/{chunk-H4XI4B7G.js → chunk-XIUFHRZE.js} +0 -0
|
@@ -1647,27 +1647,9 @@ interface User {
|
|
|
1647
1647
|
* condition still reaches the server, which ignores it and answers at the declared grain. Every
|
|
1648
1648
|
* request succeeds and the grain silently never changes.
|
|
1649
1649
|
*/
|
|
1650
|
+
/** Server-side capabilities the app model must know of, which a host may turn off. */
|
|
1650
1651
|
interface SdkFeatures {
|
|
1651
1652
|
dateDrill?: boolean;
|
|
1652
|
-
/**
|
|
1653
|
-
* Whether the host can export a query's result (`query.export()`): its Backend has
|
|
1654
|
-
* `exportQuery`. `mountDataApp` says so for every frame; `createSdk` reads it off the Backend
|
|
1655
|
-
* when the host does not. An author shows an export button when this and
|
|
1656
|
-
* `user.permissions.canExportData` are both true.
|
|
1657
|
-
*/
|
|
1658
|
-
export?: boolean;
|
|
1659
|
-
/**
|
|
1660
|
-
* Whether `Anfra.render()` can save a rendering here: the host turned it on
|
|
1661
|
-
* (`mountDataApp({ render: true })`). An author shows a render button when this and
|
|
1662
|
-
* `user.permissions.canExportData` are both true.
|
|
1663
|
-
*/
|
|
1664
|
-
render?: boolean;
|
|
1665
|
-
/**
|
|
1666
|
-
* Whether `Anfra.lineage()` can trace fields here: the host's Backend has `lineage`.
|
|
1667
|
-
* `mountDataApp` says so for every frame; `createSdk` reads it off the Backend when the host
|
|
1668
|
-
* does not.
|
|
1669
|
-
*/
|
|
1670
|
-
lineage?: boolean;
|
|
1671
1653
|
}
|
|
1672
1654
|
interface SdkEnvironment {
|
|
1673
1655
|
datasets: Record<string, DatasetDescriptor>;
|
|
@@ -1676,8 +1658,11 @@ interface SdkEnvironment {
|
|
|
1676
1658
|
backend: Backend;
|
|
1677
1659
|
/** Absent means the host did not say, and nothing is blocked; only an explicit `false` throws. */
|
|
1678
1660
|
features?: SdkFeatures;
|
|
1679
|
-
/**
|
|
1680
|
-
|
|
1661
|
+
/** The plugins the host installed (`Anfra.plugins`). None unless given. */
|
|
1662
|
+
plugins?: readonly {
|
|
1663
|
+
name: string;
|
|
1664
|
+
version: string;
|
|
1665
|
+
}[];
|
|
1681
1666
|
}
|
|
1682
1667
|
/** A rendering's file format. A PDF is one page the size of the rendering. */
|
|
1683
1668
|
type RenderFormat = 'png' | 'pdf';
|
|
@@ -2225,12 +2210,12 @@ interface Backend {
|
|
|
2225
2210
|
fieldSuggestions(request: FieldSuggestionsRequest, signal: AbortSignal): Promise<ConditionValue[]>;
|
|
2226
2211
|
/**
|
|
2227
2212
|
* Export a query's whole result as a file, and answer its link once the file is ready. Optional:
|
|
2228
|
-
*
|
|
2213
|
+
* the `export` plugin needs it.
|
|
2229
2214
|
*/
|
|
2230
2215
|
exportQuery?(request: BackendExportRequest, signal: AbortSignal): Promise<ExportResult>;
|
|
2231
2216
|
/**
|
|
2232
|
-
* Trace fields through the catalog: what each is built from. Optional:
|
|
2233
|
-
* it
|
|
2217
|
+
* Trace fields through the catalog: what each is built from. Optional: the `lineage` plugin
|
|
2218
|
+
* needs it.
|
|
2234
2219
|
*/
|
|
2235
2220
|
lineage?(request: BackendLineageRequest, signal: AbortSignal): Promise<LineageResult>;
|
|
2236
2221
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holistics/anfra-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Data Apps on anfra: the authoring layer (app), what hosts one (host), the core API client (api), and their shared contract (common)",
|
|
3
|
+
"version": "0.11.0",
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
@@ -26,6 +26,18 @@
|
|
|
26
26
|
"types": "./dist/api.d.ts",
|
|
27
27
|
"import": "./dist/api.js"
|
|
28
28
|
},
|
|
29
|
+
"./plugins": {
|
|
30
|
+
"types": "./dist/plugins.d.ts",
|
|
31
|
+
"import": "./dist/plugins.js"
|
|
32
|
+
},
|
|
33
|
+
"./testing": {
|
|
34
|
+
"types": "./dist/testing.d.ts",
|
|
35
|
+
"import": "./dist/testing.js"
|
|
36
|
+
},
|
|
37
|
+
"./build": {
|
|
38
|
+
"types": "./dist/build.d.ts",
|
|
39
|
+
"import": "./dist/build.js"
|
|
40
|
+
},
|
|
29
41
|
"./ambient": {
|
|
30
42
|
"types": "./dist/ambient.d.ts"
|
|
31
43
|
}
|
|
@@ -60,5 +72,13 @@
|
|
|
60
72
|
},
|
|
61
73
|
"dependencies": {
|
|
62
74
|
"openapi-fetch": "^0.17.0"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"esbuild": ">=0.20"
|
|
78
|
+
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"esbuild": {
|
|
81
|
+
"optional": true
|
|
82
|
+
}
|
|
63
83
|
}
|
|
64
84
|
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { i as BackendQueryRequest, H as FieldSuggestionsRequest, h as BackendLineageRequest, f as BackendExportRequest, a8 as Rendering, L as InspectedApp, Q as InspectedStructure, Z as LocateTarget, a7 as RenderRequest, D as DatasetDescriptor, ai as User, ab as SdkFeatures } from './types-DznT0m7F.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; every call it
|
|
6
|
-
* makes to its Backend crosses here, and the host answers it.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* What a frame may ask its host: the Backend's methods, and the two a rendering needs (the
|
|
11
|
-
* renderer's code, and saving a file). The bridge serves these and nothing else.
|
|
12
|
-
*/
|
|
13
|
-
type BridgeMethod = 'submitQuery' | 'fieldSuggestions' | 'exportQuery' | 'lineage' | 'renderer' | 'saveFile';
|
|
14
|
-
/** A file the frame made, for the host to save for the reader: the frame cannot download. */
|
|
15
|
-
interface SaveFileRequest {
|
|
16
|
-
blob: Blob;
|
|
17
|
-
filename: string;
|
|
18
|
-
}
|
|
19
|
-
/** What the host provisions a frame with, as JSON in `<script type="application/json" id="anfra-provision">`. */
|
|
20
|
-
interface Provision {
|
|
21
|
-
datasets: Record<string, DatasetDescriptor>;
|
|
22
|
-
user: User;
|
|
23
|
-
/** What the host can do beyond queries: exports, rendering. Absent from a host older than this field. */
|
|
24
|
-
features?: SdkFeatures;
|
|
25
|
-
/** The host page's origin: where the frame posts, so nothing else can read its messages. */
|
|
26
|
-
hostOrigin: string;
|
|
27
|
-
}
|
|
28
|
-
declare const PROVISION_ELEMENT_ID = "anfra-provision";
|
|
29
|
-
/** Frame → host. */
|
|
30
|
-
type FrameMessage = {
|
|
31
|
-
type: 'anfra:ready';
|
|
32
|
-
} | {
|
|
33
|
-
type: 'anfra:request';
|
|
34
|
-
id: number;
|
|
35
|
-
method: 'submitQuery';
|
|
36
|
-
request: BackendQueryRequest;
|
|
37
|
-
} | {
|
|
38
|
-
type: 'anfra:request';
|
|
39
|
-
id: number;
|
|
40
|
-
method: 'fieldSuggestions';
|
|
41
|
-
request: FieldSuggestionsRequest;
|
|
42
|
-
} | {
|
|
43
|
-
type: 'anfra:request';
|
|
44
|
-
id: number;
|
|
45
|
-
method: 'lineage';
|
|
46
|
-
request: BackendLineageRequest;
|
|
47
|
-
}
|
|
48
|
-
/** The host makes the file, starts saving it for the reader, then answers its link. */
|
|
49
|
-
| {
|
|
50
|
-
type: 'anfra:request';
|
|
51
|
-
id: number;
|
|
52
|
-
method: 'exportQuery';
|
|
53
|
-
request: BackendExportRequest;
|
|
54
|
-
}
|
|
55
|
-
/** The renderer's code, asked for on the frame's first rendering; answered as a string. */
|
|
56
|
-
| {
|
|
57
|
-
type: 'anfra:request';
|
|
58
|
-
id: number;
|
|
59
|
-
method: 'renderer';
|
|
60
|
-
request: null;
|
|
61
|
-
} | {
|
|
62
|
-
type: 'anfra:request';
|
|
63
|
-
id: number;
|
|
64
|
-
method: 'saveFile';
|
|
65
|
-
request: SaveFileRequest;
|
|
66
|
-
}
|
|
67
|
-
/** The answer to the host's `anfra:render`, by its id. */
|
|
68
|
-
| {
|
|
69
|
-
type: 'anfra:rendered';
|
|
70
|
-
id: number;
|
|
71
|
-
ok: true;
|
|
72
|
-
result: Rendering;
|
|
73
|
-
} | {
|
|
74
|
-
type: 'anfra:rendered';
|
|
75
|
-
id: number;
|
|
76
|
-
ok: false;
|
|
77
|
-
error: BridgeError;
|
|
78
|
-
} | {
|
|
79
|
-
type: 'anfra:cancel';
|
|
80
|
-
id: number;
|
|
81
|
-
} | {
|
|
82
|
-
type: 'anfra:inspect';
|
|
83
|
-
apps: InspectedApp[];
|
|
84
|
-
structure: InspectedStructure;
|
|
85
|
-
}
|
|
86
|
-
/** In pick mode, the reader chose a node, or left the mode (null, on Escape). */
|
|
87
|
-
| {
|
|
88
|
-
type: 'anfra:picked';
|
|
89
|
-
node: string | null;
|
|
90
|
-
};
|
|
91
|
-
/** An error as it crosses the bridge: the SDK's error class by name, and its message. */
|
|
92
|
-
interface BridgeError {
|
|
93
|
-
name: string;
|
|
94
|
-
message: string;
|
|
95
|
-
}
|
|
96
|
-
/** Host → frame. */
|
|
97
|
-
type HostMessage = {
|
|
98
|
-
type: 'anfra:response';
|
|
99
|
-
id: number;
|
|
100
|
-
ok: true;
|
|
101
|
-
result: unknown;
|
|
102
|
-
} | {
|
|
103
|
-
type: 'anfra:response';
|
|
104
|
-
id: number;
|
|
105
|
-
ok: false;
|
|
106
|
-
error: BridgeError;
|
|
107
|
-
} | {
|
|
108
|
-
type: 'anfra:inspect-watch';
|
|
109
|
-
open: boolean;
|
|
110
|
-
}
|
|
111
|
-
/** Show a node on the page (its key in the last snapshot), or nothing. The frame answers nothing. */
|
|
112
|
-
| {
|
|
113
|
-
type: 'anfra:highlight';
|
|
114
|
-
node: string | null;
|
|
115
|
-
}
|
|
116
|
-
/** Scroll a node or an entity into view and hold the highlight on it. */
|
|
117
|
-
| {
|
|
118
|
-
type: 'anfra:locate';
|
|
119
|
-
target: LocateTarget;
|
|
120
|
-
}
|
|
121
|
-
/** Start or stop pick mode. */
|
|
122
|
-
| {
|
|
123
|
-
type: 'anfra:pick-watch';
|
|
124
|
-
on: boolean;
|
|
125
|
-
}
|
|
126
|
-
/** Render the app or one node, once its queries settle, and save it; the frame answers `anfra:rendered`. */
|
|
127
|
-
| {
|
|
128
|
-
type: 'anfra:render';
|
|
129
|
-
id: number;
|
|
130
|
-
request: RenderRequest;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export { type BridgeError as B, type FrameMessage as F, type HostMessage as H, PROVISION_ELEMENT_ID as P, type BridgeMethod as a, type Provision as b };
|
|
File without changes
|