@holistics/anfra-sdk 0.20.0 → 0.21.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 +5 -0
- package/dist/api.d.ts +11 -8
- package/dist/api.js +45 -22
- package/dist/app.d.ts +5 -5
- package/dist/app.js +4 -3
- package/dist/{bootstrap-DHU2haC5.d.ts → bootstrap-BxBqFhgm.d.ts} +279 -27
- package/dist/build.d.ts +2 -2
- package/dist/{chunk-32566ZNE.js → chunk-2TTGSNHA.js} +1 -1
- package/dist/{chunk-H52PO7MP.js → chunk-33HI2ODM.js} +25 -0
- package/dist/chunk-4UEESYHH.js +32 -0
- package/dist/{chunk-4TXKXLWK.js → chunk-7I2HXY72.js} +1 -1
- package/dist/{chunk-KKSOTHP4.js → chunk-7NZOMBYE.js} +1 -1
- package/dist/{chunk-DITKCHFQ.js → chunk-CLXZMA5D.js} +1 -1
- package/dist/{chunk-GBXK7F2V.js → chunk-D7DIJRAC.js} +14 -1
- package/dist/{chunk-FTTVLHNN.js → chunk-E3Q3FRKQ.js} +1 -1
- package/dist/{chunk-SXKJQU7A.js → chunk-GPBYPSWK.js} +22 -36
- package/dist/{chunk-T5T76SAR.js → chunk-IHRNKDMO.js} +830 -265
- package/dist/{chunk-EIPHDMZ7.js → chunk-UWRQXPPG.js} +69 -24
- package/dist/common.d.ts +3 -3
- package/dist/{data-ESPFZ5IM.js → data-SZDYO55C.js} +7 -5
- package/dist/{declaration-RYRBX7PH.js → declaration-GYV6OUR3.js} +5 -3
- package/dist/{errors-189T_Mnc.d.ts → errors-DR05L6-y.d.ts} +1 -1
- package/dist/host.d.ts +2 -2
- package/dist/host.js +29 -6
- package/dist/{menu-Cam-hOdJ.d.ts → menu-CuTKq-dC.d.ts} +2 -1
- package/dist/{overview-AWPXJACF.js → overview-KOQJNG2Y.js} +28 -13
- package/dist/{plugin-rRd-zHGt.d.ts → plugin-BIcighnC.d.ts} +7 -2
- package/dist/plugins.d.ts +1 -7
- package/dist/plugins.js +53 -17
- package/dist/{queries-FWMX7H5Z.js → queries-BWKWZQMG.js} +70 -17
- package/dist/{structure-VFRJFC4C.js → structure-JO4YZHKZ.js} +5 -3
- package/dist/{tab-XL2HS5W4.js → tab-QPHE7YUQ.js} +3 -3
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +8 -7
- package/dist/{types-N0V9n38H.d.ts → types-C_-1rgj2.d.ts} +781 -123
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,11 @@ app.subscribe(() => render(byRegion.result));
|
|
|
47
47
|
await app.execute();
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
An app may change what it declared while it runs, as a chart or dashboard builder does: `update`
|
|
51
|
+
a query or a control in place (`byRegion.update({ aql })`), `remove()` one with its edges, or
|
|
52
|
+
`remove()` one edge (`mapControl` and `mapCrossFilter` return it). A name is an entity's identity
|
|
53
|
+
and never changes. Changes run at the next `app.execute()`, so several go out as one run.
|
|
54
|
+
|
|
50
55
|
Everything beyond queries comes from a **plugin** the host installed, which adds its API under its
|
|
51
56
|
own name (`query.export`, `Anfra.render`, `Anfra.lineage`). Where the host didn't install it, the
|
|
52
57
|
member isn't there: check `Anfra.plugins.has(name)` before using an optional one.
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from 'openapi-fetch';
|
|
2
|
-
import {
|
|
2
|
+
import { av as paths, au as components } from './types-C_-1rgj2.js';
|
|
3
3
|
import { DatasetDescriptor, Backend, BackendExportRequest, BackendQueryRequest } from './app.js';
|
|
4
4
|
import { DataAppError } from './app.js';
|
|
5
5
|
|
|
@@ -11,8 +11,8 @@ type CoreClient = Client<paths>;
|
|
|
11
11
|
*/
|
|
12
12
|
declare function coreClient(baseUrl: string, fetchImpl?: typeof fetch): CoreClient;
|
|
13
13
|
|
|
14
|
-
type
|
|
15
|
-
type
|
|
14
|
+
type QueryRequestParams = components['schemas']['QueryRequestParams'];
|
|
15
|
+
type QueryExportRequestParams = components['schemas']['QueryExportRequestParams'];
|
|
16
16
|
/** How many values a filter control is offered at most. */
|
|
17
17
|
declare const SUGGESTION_LIMIT = 100;
|
|
18
18
|
interface CoreApiBackendOptions {
|
|
@@ -22,10 +22,13 @@ interface CoreApiBackendOptions {
|
|
|
22
22
|
*/
|
|
23
23
|
datasets?: Record<string, DatasetDescriptor>;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The core.query request params a Backend request is: the AQL, its dataset and its input; and how
|
|
27
|
+
* it uses the query cache, when it asks for something other than the default.
|
|
28
|
+
*/
|
|
29
|
+
declare function toQueryRequestParams(request: BackendQueryRequest): QueryRequestParams;
|
|
30
|
+
/** The core.query.export request params an export request is: the query as a run sends it, every row, and the file. */
|
|
31
|
+
declare function toExportRequestParams(request: BackendExportRequest): QueryExportRequestParams;
|
|
29
32
|
/**
|
|
30
33
|
* A Backend over the core API: a Data App's queries as `core.query`, its field suggestions as one
|
|
31
34
|
* `core.query` too, its exports as `core.query.export`, and its lineage as `core.lineage`. The same on
|
|
@@ -77,5 +80,5 @@ interface ApiErrorBody {
|
|
|
77
80
|
*/
|
|
78
81
|
declare function toSdkError(status: number, body: ApiErrorBody | undefined): DataAppError;
|
|
79
82
|
|
|
80
|
-
export { SUGGESTION_LIMIT, components, coreApiBackend, coreClient, loadDatasets, paths, toDescriptor,
|
|
83
|
+
export { SUGGESTION_LIMIT, components, coreApiBackend, coreClient, loadDatasets, paths, toDescriptor, toExportRequestParams, toQueryRequestParams, toSdkError };
|
|
81
84
|
export type { ApiErrorBody, CoreApiBackendOptions, CoreClient, LoadedDatasets };
|
package/dist/api.js
CHANGED
|
@@ -91,22 +91,34 @@ var SUGGESTION_LIMIT = 100;
|
|
|
91
91
|
function isAbort(err) {
|
|
92
92
|
return err instanceof Error && err.name === "AbortError";
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function toQueryRequestParams(request) {
|
|
95
|
+
const cache = toCacheOptions(request);
|
|
96
|
+
return { query: request.aql, dataset: request.dataset, input: request.input, ...cache ? { cache } : {} };
|
|
97
|
+
}
|
|
98
|
+
function toCacheOptions({ cacheDuration, bustCache, minCachedAt }) {
|
|
99
|
+
if (!cacheDuration && !bustCache && !minCachedAt) return void 0;
|
|
95
100
|
return {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
input: request.input,
|
|
100
|
-
...request.pageSize !== void 0 ? { page: request.page ?? 1, page_size: request.pageSize } : {},
|
|
101
|
-
...request.timezone ? { timezone: request.timezone } : {}
|
|
101
|
+
...cacheDuration ? { duration: cacheDuration } : {},
|
|
102
|
+
...bustCache ? { refresh: true } : {},
|
|
103
|
+
...minCachedAt ? { min_cached_at: minCachedAt } : {}
|
|
102
104
|
};
|
|
103
105
|
}
|
|
104
|
-
function
|
|
106
|
+
function toCacheResult(cache) {
|
|
107
|
+
return {
|
|
108
|
+
hit: cache.hit,
|
|
109
|
+
...cache.cached_at ? { cachedAt: new Date(cache.cached_at) } : {},
|
|
110
|
+
...cache.expires_at ? { expiresAt: new Date(cache.expires_at) } : {},
|
|
111
|
+
...cache.key ? { key: cache.key } : {},
|
|
112
|
+
...cache.warning ? { warning: { code: cache.warning.code, message: cache.warning.message } } : {}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function toExportRequestParams(request) {
|
|
116
|
+
const cache = toCacheOptions(request);
|
|
105
117
|
return {
|
|
106
118
|
query: request.aql,
|
|
107
119
|
dataset: request.dataset,
|
|
108
120
|
input: request.input,
|
|
109
|
-
...
|
|
121
|
+
...cache ? { cache } : {},
|
|
110
122
|
// The server names its formats; one it does not know it refuses, with a message the author sees.
|
|
111
123
|
...request.format ? { format: request.format } : {},
|
|
112
124
|
...request.formatOptions ? { format_options: request.formatOptions } : {},
|
|
@@ -153,6 +165,7 @@ async function runQuery(client, body, signal) {
|
|
|
153
165
|
case "compiled":
|
|
154
166
|
result.sql = event.sql;
|
|
155
167
|
if (event.aql) result.aql = event.aql;
|
|
168
|
+
if (event.input) result.input = event.input;
|
|
156
169
|
break;
|
|
157
170
|
case "header":
|
|
158
171
|
result.columns = event.columns;
|
|
@@ -163,7 +176,9 @@ async function runQuery(client, body, signal) {
|
|
|
163
176
|
break;
|
|
164
177
|
case "summary":
|
|
165
178
|
result.has_more = event.has_more;
|
|
179
|
+
if (event.pivot) result.pivot = event.pivot;
|
|
166
180
|
result.timings = event.timings;
|
|
181
|
+
if (event.cache) result.cache = event.cache;
|
|
167
182
|
break;
|
|
168
183
|
}
|
|
169
184
|
});
|
|
@@ -177,25 +192,33 @@ function coreApiBackend(base, options = {}) {
|
|
|
177
192
|
const client = typeof base === "string" ? coreClient(base) : base;
|
|
178
193
|
return {
|
|
179
194
|
async submitQuery(request, signal) {
|
|
180
|
-
const data = await runQuery(client,
|
|
195
|
+
const data = await runQuery(client, toQueryRequestParams(request), signal);
|
|
181
196
|
const values = data.result.records;
|
|
197
|
+
const { pagination } = request.input;
|
|
198
|
+
const cache = data.cache ? toCacheResult(data.cache) : void 0;
|
|
182
199
|
return {
|
|
183
200
|
columns: toColumns(data.columns),
|
|
184
201
|
values,
|
|
185
202
|
meta: {
|
|
186
|
-
...
|
|
203
|
+
...pagination ? { page: pagination.page, pageSize: pagination.pageSize, hasMore: data.has_more } : {},
|
|
204
|
+
...data.pivot ? { pivot: { rows: data.pivot.rows, columns: data.pivot.columns } } : {},
|
|
187
205
|
numRows: values.length
|
|
188
206
|
},
|
|
189
207
|
debug: {
|
|
190
208
|
...data.aql ? { executedAql: data.aql } : {},
|
|
191
209
|
executedSql: data.sql,
|
|
192
|
-
fromCache: false,
|
|
210
|
+
fromCache: cache?.hit ?? false,
|
|
193
211
|
timings: {
|
|
194
212
|
steps: data.timings.steps.map((s) => ({ step: s.step, startMs: s.start_ms })),
|
|
195
213
|
endMs: data.timings.end_ms
|
|
196
214
|
},
|
|
197
|
-
|
|
198
|
-
|
|
215
|
+
// A hit's rows were read when they were cached, not now.
|
|
216
|
+
executedAt: cache?.hit && cache.cachedAt ? cache.cachedAt : /* @__PURE__ */ new Date(),
|
|
217
|
+
...cache ? { cache } : {}
|
|
218
|
+
},
|
|
219
|
+
// The input as it ran: the one sent, with the seeds the server generated for it. The rest
|
|
220
|
+
// the server answers with is what was sent, or its defaults, which a replay needn't send.
|
|
221
|
+
...data.input?.seeds ? { input: { ...request.input, seeds: data.input.seeds } } : {}
|
|
199
222
|
};
|
|
200
223
|
},
|
|
201
224
|
/**
|
|
@@ -216,22 +239,22 @@ function coreApiBackend(base, options = {}) {
|
|
|
216
239
|
dataset: request.dataset,
|
|
217
240
|
input: {
|
|
218
241
|
filters: q && field.type === "text" ? [{ field: ref, operator: "contains", values: [q] }] : [],
|
|
219
|
-
sorts: [{ field: "value", direction: "asc" }]
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
page_size: SUGGESTION_LIMIT
|
|
242
|
+
sorts: [{ field: "value", direction: "asc" }],
|
|
243
|
+
pagination: { page: 1, pageSize: SUGGESTION_LIMIT }
|
|
244
|
+
}
|
|
223
245
|
}, signal);
|
|
224
246
|
return data.result.records.map((row) => row[0]).filter((v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean");
|
|
225
247
|
},
|
|
226
248
|
/** An export as `core.query.export`: the server runs the query to completion, then answers its link. */
|
|
227
249
|
async exportQuery(request, signal) {
|
|
228
|
-
const link = await callCoreAPI(() => client.POST("/core.query.export", { body:
|
|
250
|
+
const link = await callCoreAPI(() => client.POST("/core.query.export", { body: toExportRequestParams(request), signal }));
|
|
229
251
|
return {
|
|
230
252
|
url: link.url,
|
|
231
253
|
filename: link.filename,
|
|
232
254
|
format: link.format,
|
|
233
255
|
rowCount: link.row_count,
|
|
234
|
-
expiresAt: new Date(link.expires_at)
|
|
256
|
+
expiresAt: new Date(link.expires_at),
|
|
257
|
+
...link.cache ? { cache: toCacheResult(link.cache) } : {}
|
|
235
258
|
};
|
|
236
259
|
},
|
|
237
260
|
/** Lineage as `core.lineage`, whose answer is the SDK's as it is. */
|
|
@@ -284,7 +307,7 @@ export {
|
|
|
284
307
|
coreClient,
|
|
285
308
|
loadDatasets,
|
|
286
309
|
toDescriptor,
|
|
287
|
-
|
|
288
|
-
|
|
310
|
+
toExportRequestParams,
|
|
311
|
+
toQueryRequestParams,
|
|
289
312
|
toSdkError
|
|
290
313
|
};
|
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-
|
|
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-
|
|
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
|
|
1
|
+
import { S as Sdk } from './bootstrap-BxBqFhgm.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-BxBqFhgm.js';
|
|
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-DR05L6-y.js';
|
|
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 CallStamp, l as ColumnMeta, m as Condition, n as ConditionValue, o as ControlMappingJson, p as CrossFilterJson, D as DatasetDescriptor, q as DateDrillDeclaration, r as DateGrain, s as DateTransformation, E as EntityKind, t as EntityRef, u as EntityUsage, v as ExecuteOptions, w as ExecuteSummary, x as ExportFormat, y as ExportFormatOptions, z as ExportOptions, F as ExportResult, G as FILTER_AGGREGATIONS, H as FieldLineage, I as FieldSuggestionsRequest, J as FilterAggregation, K as FilterDeclaration, L as FilterValueType, M as InspectedApp, N as InspectedControl, O as InspectedError, P as InspectedQuery, Q as InspectedSelection, R as InspectedStructure, S as LineageCard, T as LineageDiagram, U as LineageNode, V as LineageOptions, W as LineageResult, X as LineageTarget, Y as Listener, Z as LocateKind, _ as LocateTarget, $ as MappingJson, a0 as Operator, a1 as QueryCacheResult, a2 as QueryCacheSettings, a3 as QueryDebug, a4 as QueryDeclaration, a5 as QueryInput, a6 as QueryInputDefaults, a7 as QueryPagination, a8 as QueryPivot, a9 as QueryRequest, aa as QueryResult, ab as QuerySeeds, ac as QuerySort, ad as QueryStamp, ae as QueryState, af as QueryTimings, ag as RenderFormat, ah as RenderRequest, ai as Rendering, aj as Row, ak as SdkEnvironment, al as SdkFeatures, am as Selection, an as SelectionCondition, ao as SemanticType, ap as StructureKind, aq as StructureNode, ar as Unsubscribe, as as User, at as WeekStartDay } from './types-C_-1rgj2.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 TargetRect, h as Theme, i as ThemeInput, j as ThemeScheme, k as ThemeToken, l as ThemeTokens, m as checkTarget, n as designTheme, r as resolveTheme } from './menu-
|
|
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 TargetRect, h as Theme, i as ThemeInput, j as ThemeScheme, k as ThemeToken, l as ThemeTokens, m as checkTarget, n as designTheme, r as resolveTheme } from './menu-CuTKq-dC.js';
|
|
7
7
|
|
|
8
8
|
declare const SANDBOX_GLOBAL = "Anfra";
|
|
9
9
|
/**
|
package/dist/app.js
CHANGED
|
@@ -22,11 +22,11 @@ import {
|
|
|
22
22
|
createSdk,
|
|
23
23
|
installSandbox,
|
|
24
24
|
parseRef
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-IHRNKDMO.js";
|
|
26
26
|
import {
|
|
27
27
|
FILTER_AGGREGATIONS
|
|
28
28
|
} from "./chunk-XIUFHRZE.js";
|
|
29
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-4UEESYHH.js";
|
|
30
30
|
import {
|
|
31
31
|
DEFAULT_TOKENS,
|
|
32
32
|
DESIGN_TOKENS,
|
|
@@ -35,7 +35,8 @@ import {
|
|
|
35
35
|
designTheme,
|
|
36
36
|
resolveTheme
|
|
37
37
|
} from "./chunk-RXPNL7UR.js";
|
|
38
|
-
import "./chunk-
|
|
38
|
+
import "./chunk-E3Q3FRKQ.js";
|
|
39
|
+
import "./chunk-GPBYPSWK.js";
|
|
39
40
|
import {
|
|
40
41
|
DataAppError,
|
|
41
42
|
GENERIC_CODES,
|