@holistics/anfra-sdk 0.10.2 → 0.11.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.
@@ -51,7 +51,12 @@ interface paths {
51
51
  };
52
52
  get?: never;
53
53
  put?: never;
54
- /** Run a query: its rows, and the SQL that produced them */
54
+ /**
55
+ * Run a query: its rows, and the SQL that produced them
56
+ * @description Answers one page of rows: page_size's, or without it the first 10000, with has_more saying whether there may be more.
57
+ * Ask the query for what you need (aggregate, filter, a limit: directive) rather than paging through rows; for every row of a large result, export it.
58
+ * Over HTTP, a request that accepts application/x-ndjson is answered as the query runs: its phase, its SQL, its columns, then its rows in batches — every row without page_size, up to the server's maximum.
59
+ */
55
60
  post: operations["core.query"];
56
61
  delete?: never;
57
62
  options?: never;
@@ -407,6 +412,19 @@ interface components {
407
412
  /** @constant */
408
413
  status: 400;
409
414
  };
415
+ /** @description The page is larger than this server answers at once. */
416
+ ErrorBodyPageTooLarge: {
417
+ /** @constant */
418
+ code: "page_too_large";
419
+ context?: components["schemas"]["ContextEntry"][];
420
+ details?: components["schemas"]["PageLimit"];
421
+ message: string;
422
+ request_id: string;
423
+ /** @constant */
424
+ scope: "user";
425
+ /** @constant */
426
+ status: 422;
427
+ };
410
428
  /** @description The query failed to run on its data source. */
411
429
  ErrorBodyQueryFailed: {
412
430
  /** @constant */
@@ -415,9 +433,9 @@ interface components {
415
433
  message: string;
416
434
  request_id: string;
417
435
  /** @constant */
418
- scope: "server";
436
+ scope: "user";
419
437
  /** @constant */
420
- status: 502;
438
+ status: 422;
421
439
  };
422
440
  /** @description The query is invalid. */
423
441
  ErrorBodyQueryInvalid: {
@@ -432,6 +450,19 @@ interface components {
432
450
  /** @constant */
433
451
  status: 422;
434
452
  };
453
+ /** @description The query's result is larger than this server allows. */
454
+ ErrorBodyResultTooLarge: {
455
+ /** @constant */
456
+ code: "result_too_large";
457
+ context?: components["schemas"]["ContextEntry"][];
458
+ details?: components["schemas"]["ResultLimit"];
459
+ message: string;
460
+ request_id: string;
461
+ /** @constant */
462
+ scope: "user";
463
+ /** @constant */
464
+ status: 422;
465
+ };
435
466
  /** @description A sidecar is unavailable. */
436
467
  ErrorBodySidecarUnavailable: {
437
468
  /** @constant */
@@ -550,6 +581,20 @@ interface components {
550
581
  parent: string;
551
582
  };
552
583
  NoInput: Record<string, never>;
584
+ PageLimit: {
585
+ /** Format: int64 */
586
+ max_bytes: number;
587
+ };
588
+ QueryCompiled: {
589
+ /** @description the AQL that runs: the query with its Query Input applied; absent for a SQL query */
590
+ aql?: string;
591
+ sql: string;
592
+ /**
593
+ * @description discriminator enum property added by openapi-typescript
594
+ * @enum {string}
595
+ */
596
+ type: "compiled";
597
+ };
553
598
  QueryCondition: {
554
599
  /** @description an AQL condition */
555
600
  expr: string;
@@ -572,6 +617,16 @@ interface components {
572
617
  /** @description the operator's values, by the field's type: a number as a string in JSON's number syntax, such as "9007199254740993" (a JSON number is refused, since it may have lost digits before it was sent); true or false; a date or text as a string. Empty for an operator that takes none */
573
618
  values: unknown[];
574
619
  };
620
+ QueryHeader: {
621
+ /** @description one per field, in order */
622
+ columns: components["schemas"]["Column"][];
623
+ fields: string[];
624
+ /**
625
+ * @description discriminator enum property added by openapi-typescript
626
+ * @enum {string}
627
+ */
628
+ type: "header";
629
+ };
575
630
  QueryInput: {
576
631
  /** @description the data source a SQL query runs against */
577
632
  data_source?: string;
@@ -586,13 +641,26 @@ interface components {
586
641
  /** @description the query */
587
642
  query: string;
588
643
  };
644
+ QueryRecords: {
645
+ /** @description one array per row, its values in fields' order, written as a page's records are */
646
+ records: unknown[][];
647
+ /**
648
+ * @description discriminator enum property added by openapi-typescript
649
+ * @enum {string}
650
+ */
651
+ type: "rows";
652
+ };
589
653
  QueryResult: {
590
654
  /** @description the AQL that ran: the query with its Query Input applied; absent for a SQL query */
591
655
  aql?: string;
592
656
  /** @description one per field of result, in order */
593
657
  columns: components["schemas"]["Column"][];
658
+ /** @description there may be rows after this page: ask for the next page, or stream the query (without page_size) for every row */
659
+ has_more: boolean;
594
660
  result: components["schemas"]["QueryRows"];
595
661
  sql: string;
662
+ /** @description the query's steps: compiling_query, for AQL; canal-query's own (connecting_to_dw, executing_query, fetching_query_result, and their children, as <parent>.<child>); retrying_query, the wait before canal-query attempts the query again */
663
+ timings: components["schemas"]["Timings"];
596
664
  };
597
665
  QueryRows: {
598
666
  fields: string[];
@@ -636,6 +704,24 @@ interface components {
636
704
  /** @description a result column's name */
637
705
  field: string;
638
706
  };
707
+ QuerySummary: {
708
+ /**
709
+ * Format: int64
710
+ * @description the bytes the warehouse read to run the query, where it reports them (BigQuery, Athena)
711
+ */
712
+ bytes_scanned?: number;
713
+ /** @description a page that may not be the last: there may be rows after it. Without page_size, every row was sent, and this is false */
714
+ has_more: boolean;
715
+ /** Format: int64 */
716
+ row_count: number;
717
+ /** @description the query's steps: compiling_query, for AQL; canal-query's own (connecting_to_dw, executing_query, fetching_query_result, and their children, as <parent>.<child>); retrying_query, the wait before canal-query attempts the query again */
718
+ timings: components["schemas"]["Timings"];
719
+ /**
720
+ * @description discriminator enum property added by openapi-typescript
721
+ * @enum {string}
722
+ */
723
+ type: "summary";
724
+ };
639
725
  QueryTransforms: {
640
726
  /** @description AQL conditions ANDed with the query's own filters */
641
727
  conditions?: components["schemas"]["QueryCondition"][];
@@ -650,6 +736,15 @@ interface components {
650
736
  diagnostics: components["schemas"]["AQLDiagnostic"][];
651
737
  valid: boolean;
652
738
  };
739
+ QueryWarehouse: {
740
+ /** @description the warehouse's own id of the query; for Postgres, the process id of the backend running it */
741
+ id: string;
742
+ /**
743
+ * @description discriminator enum property added by openapi-typescript
744
+ * @enum {string}
745
+ */
746
+ type: "warehouse_query";
747
+ };
653
748
  RepoValidation: {
654
749
  diagnostics: components["schemas"]["CompileError"][];
655
750
  reports: components["schemas"]["ValidationReport"][];
@@ -667,6 +762,22 @@ interface components {
667
762
  /** Format: int64 */
668
763
  line?: number;
669
764
  };
765
+ Response: {
766
+ code: string;
767
+ context?: components["schemas"]["ContextEntry"][];
768
+ details?: unknown;
769
+ message: string;
770
+ request_id: string;
771
+ scope: string;
772
+ /** Format: int64 */
773
+ status?: number;
774
+ };
775
+ ResultLimit: {
776
+ /** Format: int64 */
777
+ max_bytes?: number;
778
+ /** Format: int64 */
779
+ max_rows?: number;
780
+ };
670
781
  SearchInput: {
671
782
  /** @description search query */
672
783
  query?: string[];
@@ -756,6 +867,63 @@ interface components {
756
867
  /** @enum {string} */
757
868
  state: "healthy" | "degraded" | "not_running";
758
869
  };
870
+ StreamEnd: {
871
+ error?: components["schemas"]["Response"];
872
+ /** @enum {string} */
873
+ status: "succeeded" | "failed";
874
+ /**
875
+ * @description discriminator enum property added by openapi-typescript
876
+ * @enum {string}
877
+ */
878
+ type: "end";
879
+ };
880
+ StreamPing: {
881
+ /**
882
+ * @description discriminator enum property added by openapi-typescript
883
+ * @enum {string}
884
+ */
885
+ type: "ping";
886
+ };
887
+ StreamStart: {
888
+ /** @description the run's id, on a host that keeps a record of runs */
889
+ id?: string;
890
+ /**
891
+ * @description discriminator enum property added by openapi-typescript
892
+ * @enum {string}
893
+ */
894
+ type: "start";
895
+ };
896
+ StreamStatus: {
897
+ phase: string;
898
+ /**
899
+ * Format: int64
900
+ * @description while queued: how many runs are ahead of this one, 0 being next; absent otherwise
901
+ */
902
+ position?: number;
903
+ /**
904
+ * @description discriminator enum property added by openapi-typescript
905
+ * @enum {string}
906
+ */
907
+ type: "status";
908
+ };
909
+ TimedStep: {
910
+ /**
911
+ * Format: int64
912
+ * @description when it started, in ms since the run started
913
+ */
914
+ start_ms: number;
915
+ /** @description the step's name, as what ran names it; a child step as <parent>.<child>, within its parent */
916
+ step: string;
917
+ };
918
+ Timings: {
919
+ /**
920
+ * Format: int64
921
+ * @description when the run ended, in ms since it started: its total time, and where its last steps end
922
+ */
923
+ end_ms: number;
924
+ /** @description each step as it started, in order; a step run again is here again */
925
+ steps: components["schemas"]["TimedStep"][];
926
+ };
759
927
  UpdateInfo: {
760
928
  available: boolean;
761
929
  latest: string;
@@ -950,6 +1118,7 @@ interface operations {
950
1118
  };
951
1119
  content: {
952
1120
  "application/json": components["schemas"]["QueryResult"];
1121
+ "application/x-ndjson": components["schemas"]["QueryCompiled"] | components["schemas"]["QueryWarehouse"] | components["schemas"]["QueryHeader"] | components["schemas"]["QueryRecords"] | components["schemas"]["QuerySummary"] | components["schemas"]["StreamStart"] | components["schemas"]["StreamStatus"] | components["schemas"]["StreamEnd"] | components["schemas"]["StreamPing"];
953
1122
  };
954
1123
  };
955
1124
  /** @description invalid_request */
@@ -963,14 +1132,14 @@ interface operations {
963
1132
  };
964
1133
  };
965
1134
  };
966
- /** @description validation_failed, query_invalid */
1135
+ /** @description validation_failed, query_invalid, query_failed, result_too_large, page_too_large */
967
1136
  422: {
968
1137
  headers: {
969
1138
  [name: string]: unknown;
970
1139
  };
971
1140
  content: {
972
1141
  "application/json": {
973
- error: components["schemas"]["ErrorBodyValidationFailed"] | components["schemas"]["ErrorBodyQueryInvalid"];
1142
+ error: components["schemas"]["ErrorBodyValidationFailed"] | components["schemas"]["ErrorBodyQueryInvalid"] | components["schemas"]["ErrorBodyQueryFailed"] | components["schemas"]["ErrorBodyResultTooLarge"] | components["schemas"]["ErrorBodyPageTooLarge"];
974
1143
  };
975
1144
  };
976
1145
  };
@@ -985,17 +1154,6 @@ interface operations {
985
1154
  };
986
1155
  };
987
1156
  };
988
- /** @description query_failed */
989
- 502: {
990
- headers: {
991
- [name: string]: unknown;
992
- };
993
- content: {
994
- "application/json": {
995
- error: components["schemas"]["ErrorBodyQueryFailed"];
996
- };
997
- };
998
- };
999
1157
  /** @description sidecar_unavailable */
1000
1158
  503: {
1001
1159
  headers: {
@@ -1110,14 +1268,14 @@ interface operations {
1110
1268
  };
1111
1269
  };
1112
1270
  };
1113
- /** @description validation_failed, query_invalid */
1271
+ /** @description validation_failed, query_invalid, query_failed */
1114
1272
  422: {
1115
1273
  headers: {
1116
1274
  [name: string]: unknown;
1117
1275
  };
1118
1276
  content: {
1119
1277
  "application/json": {
1120
- error: components["schemas"]["ErrorBodyValidationFailed"] | components["schemas"]["ErrorBodyQueryInvalid"];
1278
+ error: components["schemas"]["ErrorBodyValidationFailed"] | components["schemas"]["ErrorBodyQueryInvalid"] | components["schemas"]["ErrorBodyQueryFailed"];
1121
1279
  };
1122
1280
  };
1123
1281
  };
@@ -1143,17 +1301,6 @@ interface operations {
1143
1301
  };
1144
1302
  };
1145
1303
  };
1146
- /** @description query_failed */
1147
- 502: {
1148
- headers: {
1149
- [name: string]: unknown;
1150
- };
1151
- content: {
1152
- "application/json": {
1153
- error: components["schemas"]["ErrorBodyQueryFailed"];
1154
- };
1155
- };
1156
- };
1157
1304
  /** @description sidecar_unavailable */
1158
1305
  503: {
1159
1306
  headers: {
@@ -1647,27 +1794,9 @@ interface User {
1647
1794
  * condition still reaches the server, which ignores it and answers at the declared grain. Every
1648
1795
  * request succeeds and the grain silently never changes.
1649
1796
  */
1797
+ /** Server-side capabilities the app model must know of, which a host may turn off. */
1650
1798
  interface SdkFeatures {
1651
1799
  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
1800
  }
1672
1801
  interface SdkEnvironment {
1673
1802
  datasets: Record<string, DatasetDescriptor>;
@@ -1676,8 +1805,11 @@ interface SdkEnvironment {
1676
1805
  backend: Backend;
1677
1806
  /** Absent means the host did not say, and nothing is blocked; only an explicit `false` throws. */
1678
1807
  features?: SdkFeatures;
1679
- /** Draws and saves a rendering: given by the frame bootstrap, which can reach the page and the host. */
1680
- render?: (request: RenderRequest) => Promise<Rendering>;
1808
+ /** The plugins the host installed (`Anfra.plugins`). None unless given. */
1809
+ plugins?: readonly {
1810
+ name: string;
1811
+ version: string;
1812
+ }[];
1681
1813
  }
1682
1814
  /** A rendering's file format. A PDF is one page the size of the rendering. */
1683
1815
  type RenderFormat = 'png' | 'pdf';
@@ -1857,6 +1989,22 @@ interface QueryDebug {
1857
1989
  executedSql?: string;
1858
1990
  fromCache: boolean;
1859
1991
  executedAt?: Date;
1992
+ /** How the run's time went, where the server reports it. */
1993
+ timings?: QueryTimings;
1994
+ }
1995
+ /**
1996
+ * When each step of a query's run started, in order, in milliseconds since the run started; and
1997
+ * when it ended. A step ends where the next step at its level or above starts — a child step,
1998
+ * `executing_query.poll_query`, is within its parent — or at `endMs`. A step run again after a
1999
+ * retry is listed again. Steps: `compiling_query`; canal-query's `connecting_to_dw`,
2000
+ * `executing_query`, `fetching_query_result` and their children; `retrying_query`.
2001
+ */
2002
+ interface QueryTimings {
2003
+ steps: {
2004
+ step: string;
2005
+ startMs: number;
2006
+ }[];
2007
+ endMs: number;
1860
2008
  }
1861
2009
  interface QueryResult {
1862
2010
  columns: ColumnMeta[];
@@ -1867,6 +2015,12 @@ interface QueryResult {
1867
2015
  /** Present only for a query that declares a `pageSize`. */
1868
2016
  pageSize?: number;
1869
2017
  numRows: number;
2018
+ /**
2019
+ * For a query that declares a `pageSize`: whether rows may follow this page, as its backend
2020
+ * knows it. Absent when the backend does not say; `query.hasMore` then takes a full page to
2021
+ * mean more may follow.
2022
+ */
2023
+ hasMore?: boolean;
1870
2024
  };
1871
2025
  debug?: QueryDebug;
1872
2026
  }
@@ -2127,6 +2281,8 @@ interface BackendQueryResult {
2127
2281
  page?: number;
2128
2282
  pageSize?: number;
2129
2283
  numRows?: number;
2284
+ /** For a paged query: whether rows may follow this page. Omit it when not known. */
2285
+ hasMore?: boolean;
2130
2286
  };
2131
2287
  debug?: QueryDebug;
2132
2288
  }
@@ -2225,14 +2381,14 @@ interface Backend {
2225
2381
  fieldSuggestions(request: FieldSuggestionsRequest, signal: AbortSignal): Promise<ConditionValue[]>;
2226
2382
  /**
2227
2383
  * Export a query's whole result as a file, and answer its link once the file is ready. Optional:
2228
- * a host that cannot export leaves it out, and `query.export()` rejects with a `TransportError`.
2384
+ * the `export` plugin needs it.
2229
2385
  */
2230
2386
  exportQuery?(request: BackendExportRequest, signal: AbortSignal): Promise<ExportResult>;
2231
2387
  /**
2232
- * Trace fields through the catalog: what each is built from. Optional: a host that cannot leaves
2233
- * it out, and `Anfra.lineage()` rejects with a `TransportError`.
2388
+ * Trace fields through the catalog: what each is built from. Optional: the `lineage` plugin
2389
+ * needs it.
2234
2390
  */
2235
2391
  lineage?(request: BackendLineageRequest, signal: AbortSignal): Promise<LineageResult>;
2236
2392
  }
2237
2393
 
2238
- export { type Operator as $, type Aggregation as A, type Backend as B, type ColumnMeta as C, type DatasetDescriptor as D, type EntityKind as E, FILTER_AGGREGATIONS as F, type FieldLineage as G, type FieldSuggestionsRequest as H, type FilterAggregation as I, type FilterDeclaration as J, type FilterValueType as K, type InspectedApp as L, type InspectedControl as M, type InspectedError as N, type InspectedQuery as O, type InspectedSelection as P, type InspectedStructure as Q, type LineageCard as R, type LineageDiagram as S, type LineageNode as T, type LineageOptions as U, type LineageResult as V, type LineageTarget as W, type Listener as X, type LocateKind as Y, type LocateTarget as Z, type MappingJson as _, type AppDeclaration as a, type QueryDebug as a0, type QueryDeclaration as a1, type QueryInput as a2, type QueryResult as a3, type QuerySort as a4, type QueryState as a5, type RenderFormat as a6, type RenderRequest as a7, type Rendering as a8, type Row as a9, type SdkEnvironment as aa, type SdkFeatures as ab, type Selection as ac, type SelectionCondition as ad, type SemanticType as ae, type StructureKind as af, type StructureNode as ag, type Unsubscribe as ah, type User as ai, type paths as aj, type components as ak, type AppJson as b, type ArrowType as c, type BackendCondition as d, type BackendDateDrill as e, type BackendExportRequest as f, type BackendFilter as g, type BackendLineageRequest as h, type BackendQueryRequest as i, type BackendQueryResult as j, type BackendSort as k, type Condition as l, type ConditionValue as m, type ControlMappingJson as n, type CrossFilterJson as o, type DateDrillDeclaration as p, type DateGrain as q, type DateTransformation as r, type EntityRef as s, type EntityUsage as t, type ExecuteOptions as u, type ExecuteSummary as v, type ExportFormat as w, type ExportFormatOptions as x, type ExportOptions as y, type ExportResult as z };
2394
+ export { type Operator as $, type Aggregation as A, type Backend as B, type ColumnMeta as C, type DatasetDescriptor as D, type EntityKind as E, FILTER_AGGREGATIONS as F, type FieldLineage as G, type FieldSuggestionsRequest as H, type FilterAggregation as I, type FilterDeclaration as J, type FilterValueType as K, type InspectedApp as L, type InspectedControl as M, type InspectedError as N, type InspectedQuery as O, type InspectedSelection as P, type InspectedStructure as Q, type LineageCard as R, type LineageDiagram as S, type LineageNode as T, type LineageOptions as U, type LineageResult as V, type LineageTarget as W, type Listener as X, type LocateKind as Y, type LocateTarget as Z, type MappingJson as _, type AppDeclaration as a, type QueryDebug as a0, type QueryDeclaration as a1, type QueryInput as a2, type QueryResult as a3, type QuerySort as a4, type QueryState as a5, type QueryTimings as a6, type RenderFormat as a7, type RenderRequest as a8, type Rendering as a9, type Row as aa, type SdkEnvironment as ab, type SdkFeatures as ac, type Selection as ad, type SelectionCondition as ae, type SemanticType as af, type StructureKind as ag, type StructureNode as ah, type Unsubscribe as ai, type User as aj, type paths as ak, type components as al, type AppJson as b, type ArrowType as c, type BackendCondition as d, type BackendDateDrill as e, type BackendExportRequest as f, type BackendFilter as g, type BackendLineageRequest as h, type BackendQueryRequest as i, type BackendQueryResult as j, type BackendSort as k, type Condition as l, type ConditionValue as m, type ControlMappingJson as n, type CrossFilterJson as o, type DateDrillDeclaration as p, type DateGrain as q, type DateTransformation as r, type EntityRef as s, type EntityUsage as t, type ExecuteOptions as u, type ExecuteSummary as v, type ExportFormat as w, type ExportFormatOptions as x, type ExportOptions as y, type ExportResult as z };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@holistics/anfra-sdk",
3
- "version": "0.10.2",
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.1",
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