@holistics/anfra-sdk 0.16.0 → 0.17.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 +2 -1
- package/dist/ambient.d.ts +2 -1
- package/dist/api.d.ts +11 -5
- package/dist/api.js +40 -30
- package/dist/app.d.ts +5 -5
- package/dist/app.js +22 -12
- package/dist/{bootstrap-hLhpijIb.d.ts → bootstrap-q1J7GUxa.d.ts} +55 -18
- package/dist/build.d.ts +2 -2
- package/dist/chunk-32566ZNE.js +1278 -0
- package/dist/{chunk-S6XLP6U4.js → chunk-3ZWUCECU.js} +45 -20
- package/dist/{chunk-THYCARLT.js → chunk-6GBHCW5E.js} +102 -30
- package/dist/{chunk-KFD6CHLI.js → chunk-ACKFOANJ.js} +2 -0
- package/dist/{chunk-CYZQ7ZTJ.js → chunk-C26OVN2S.js} +6 -1
- package/dist/{chunk-PTNYQOEY.js → chunk-EL7CAVZ3.js} +1 -1
- package/dist/{chunk-SKSKC747.js → chunk-J5BTCP6T.js} +1 -1
- package/dist/chunk-SWNVCTT6.js +161 -0
- package/dist/common.d.ts +3 -3
- package/dist/common.js +19 -9
- package/dist/{data-BGX3V42T.js → data-TDUQTG3P.js} +8 -6
- package/dist/{declaration-ZL5B676C.js → declaration-RJFU4ZLJ.js} +2 -2
- package/dist/errors-IhdhKO-6.d.ts +119 -0
- package/dist/host.d.ts +2 -2
- package/dist/host.js +17 -17
- package/dist/{menu-BFLb7dVq.d.ts → menu-CRAFaQ8s.d.ts} +21 -5
- package/dist/{overview-7YU7JW6Q.js → overview-RV2IV6PJ.js} +23 -23
- package/dist/{plugin-B7SpJLBm.d.ts → plugin-BdLabbah.d.ts} +2 -2
- package/dist/plugins.d.ts +11 -2
- package/dist/plugins.js +38 -21
- package/dist/{queries-QFN4DI25.js → queries-5TTPOB7R.js} +32 -30
- package/dist/{structure-Z2QK5MGH.js → structure-MTLCRTJ4.js} +11 -9
- package/dist/{tab-LSITVMKV.js → tab-XL2HS5W4.js} +20 -18
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +4 -4
- package/dist/{types-CKytl8ds.d.ts → types-C_i7V0DA.d.ts} +46 -14
- package/package.json +2 -1
- package/dist/chunk-F6B3EGFV.js +0 -750
- package/dist/chunk-KCTLO3CO.js +0 -41
- package/dist/errors-CKvqVaqU.d.ts +0 -30
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
DataAppError,
|
|
3
|
+
ValidationError,
|
|
4
|
+
callFailed,
|
|
5
|
+
contextOf,
|
|
6
|
+
isDataAppError,
|
|
7
|
+
toScope
|
|
8
|
+
} from "./chunk-SWNVCTT6.js";
|
|
7
9
|
|
|
8
10
|
// src/common/endpoint.ts
|
|
9
11
|
function abortError() {
|
|
@@ -14,23 +16,44 @@ function abortError() {
|
|
|
14
16
|
function isAbortError(err) {
|
|
15
17
|
return err?.name === "AbortError";
|
|
16
18
|
}
|
|
17
|
-
var
|
|
19
|
+
var DETAILED_CODES = /* @__PURE__ */ new Set([
|
|
20
|
+
"query_invalid",
|
|
21
|
+
"validation_failed",
|
|
22
|
+
"invalid_request",
|
|
23
|
+
"result_too_large",
|
|
24
|
+
"page_too_large"
|
|
25
|
+
]);
|
|
26
|
+
function crossing(name, e) {
|
|
27
|
+
const code = typeof e.code === "string" && e.code ? e.code : "call_failed";
|
|
28
|
+
const out = {
|
|
29
|
+
name,
|
|
30
|
+
code,
|
|
31
|
+
scope: toScope(e.scope),
|
|
32
|
+
message: typeof e.message === "string" && e.message ? e.message : "The call failed."
|
|
33
|
+
};
|
|
34
|
+
if (typeof e.status === "number") out.status = e.status;
|
|
35
|
+
if (e.details !== void 0 && DETAILED_CODES.has(code)) out.details = e.details;
|
|
36
|
+
const context = contextOf(e.context);
|
|
37
|
+
if (context) out.context = context;
|
|
38
|
+
if (typeof e.requestId === "string") out.requestId = e.requestId;
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
18
41
|
function toBridgeError(err) {
|
|
19
|
-
|
|
20
|
-
if (e instanceof Error && SDK_ERRORS.has(e.name)) return { name: e.name, message: e.message || "The call failed." };
|
|
21
|
-
return { name: "QueryError", message: "The call failed." };
|
|
42
|
+
return isDataAppError(err) ? crossing(err.name, err) : crossing("DataAppError", callFailed());
|
|
22
43
|
}
|
|
23
44
|
function fromBridgeError(error) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
if (!error || typeof error !== "object") return callFailed();
|
|
46
|
+
const e = crossing(error.name, error);
|
|
47
|
+
if (e.name === "ValidationError" && e.code === "declaration_invalid") return new ValidationError(e.message);
|
|
48
|
+
return new DataAppError({
|
|
49
|
+
code: e.code,
|
|
50
|
+
scope: e.scope,
|
|
51
|
+
message: e.message,
|
|
52
|
+
status: e.status,
|
|
53
|
+
details: e.details,
|
|
54
|
+
context: e.context,
|
|
55
|
+
requestId: e.requestId
|
|
56
|
+
});
|
|
34
57
|
}
|
|
35
58
|
function createEndpoint(post, handlers) {
|
|
36
59
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -43,7 +66,9 @@ function createEndpoint(post, handlers) {
|
|
|
43
66
|
if (!controller.signal.aborted) post({ type: "anfra:result", id, ok: true, result });
|
|
44
67
|
}).catch((err) => {
|
|
45
68
|
if (controller.signal.aborted || isAbortError(err)) return;
|
|
46
|
-
|
|
69
|
+
const error = toBridgeError(err);
|
|
70
|
+
if (!isDataAppError(err)) console.error(`anfra: '${name}' failed; the other side is told only that the call failed.`, err);
|
|
71
|
+
post({ type: "anfra:result", id, ok: false, error });
|
|
47
72
|
}).finally(() => {
|
|
48
73
|
if (inFlight.get(id) === controller) inFlight.delete(id);
|
|
49
74
|
});
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
eventShortcut,
|
|
7
7
|
isTyping,
|
|
8
8
|
normalizeShortcut
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3ZWUCECU.js";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_TOKENS,
|
|
12
12
|
PROVISION_ELEMENT_ID,
|
|
@@ -15,14 +15,18 @@ import {
|
|
|
15
15
|
} from "./chunk-RXPNL7UR.js";
|
|
16
16
|
import {
|
|
17
17
|
version
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-J5BTCP6T.js";
|
|
19
19
|
import {
|
|
20
20
|
DataAppError,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
ValidationError,
|
|
22
|
+
callFailed,
|
|
23
|
+
connectionFailed,
|
|
24
|
+
forbidden,
|
|
25
|
+
fromHttpStatus,
|
|
26
|
+
hasErrorCode,
|
|
27
|
+
invalidRequest,
|
|
28
|
+
isDataAppError
|
|
29
|
+
} from "./chunk-SWNVCTT6.js";
|
|
26
30
|
import {
|
|
27
31
|
__publicField
|
|
28
32
|
} from "./chunk-PKBMQBKP.js";
|
|
@@ -45,7 +49,13 @@ var Observable = class {
|
|
|
45
49
|
* entity's changes through one subscription. Subclasses call the protected `notify` instead.
|
|
46
50
|
*/
|
|
47
51
|
notifyChange() {
|
|
48
|
-
this.listeners.forEach((listener) =>
|
|
52
|
+
this.listeners.forEach((listener) => {
|
|
53
|
+
try {
|
|
54
|
+
listener();
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.error("anfra: a subscribe() listener threw; the queries carry on.", err);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
49
59
|
this.parent?.notifyChange();
|
|
50
60
|
}
|
|
51
61
|
notify() {
|
|
@@ -189,11 +199,12 @@ var Query = class extends Observable {
|
|
|
189
199
|
* Opens the menu on these rows of this query: the items plugins and the host offer for a point
|
|
190
200
|
* of data, such as "View underlying data". Call it from your chart's own right-click handler,
|
|
191
201
|
* with the event and the rows under the pointer, as for `select`; `fields` narrows the dimensions
|
|
192
|
-
* that take part
|
|
193
|
-
*
|
|
202
|
+
* that take part, and `measure` names the measure column the point shows (a chart's series), for
|
|
203
|
+
* items that are about one measure. Whether a menu opens: when one does, the event's default (the
|
|
204
|
+
* browser's menu) is prevented, and when none would (no plugin offers one), nothing happens.
|
|
194
205
|
*/
|
|
195
206
|
menu(event, rows, options = {}) {
|
|
196
|
-
return this.app.menu(this, event, Array.isArray(rows) ? rows : [rows], options.fields);
|
|
207
|
+
return this.app.menu(this, event, Array.isArray(rows) ? rows : [rows], options.fields, options.measure);
|
|
197
208
|
}
|
|
198
209
|
/**
|
|
199
210
|
* Cross-filters this query's targets by the rows the reader picked.
|
|
@@ -719,8 +730,25 @@ function installContentUi(kernel) {
|
|
|
719
730
|
}
|
|
720
731
|
if (!applies) continue;
|
|
721
732
|
const key = `frame:${item.full}:${target.kind}`;
|
|
722
|
-
|
|
723
|
-
|
|
733
|
+
if (!item.entries) {
|
|
734
|
+
entries.push({ id: key, label: item.label });
|
|
735
|
+
run.set(key, () => item.run(target));
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
let own = [];
|
|
739
|
+
try {
|
|
740
|
+
own = item.entries(target) ?? [];
|
|
741
|
+
} catch {
|
|
742
|
+
own = [];
|
|
743
|
+
}
|
|
744
|
+
own.forEach((entry, index) => {
|
|
745
|
+
if (typeof entry?.label !== "string") return;
|
|
746
|
+
const disabled = typeof entry.disabled === "string" && entry.disabled ? entry.disabled : void 0;
|
|
747
|
+
if (!disabled && typeof entry.run !== "function") return;
|
|
748
|
+
const entryKey = `${key}:${index}`;
|
|
749
|
+
entries.push({ id: entryKey, label: entry.label, ...disabled ? { disabled } : {} });
|
|
750
|
+
if (!disabled) run.set(entryKey, entry.run);
|
|
751
|
+
});
|
|
724
752
|
}
|
|
725
753
|
return { entries, run };
|
|
726
754
|
}
|
|
@@ -1442,9 +1470,12 @@ function superseded(query, controller) {
|
|
|
1442
1470
|
function inspectError(error) {
|
|
1443
1471
|
return {
|
|
1444
1472
|
name: error.name,
|
|
1473
|
+
code: error.code,
|
|
1474
|
+
scope: error.scope,
|
|
1445
1475
|
message: error.message,
|
|
1446
1476
|
...error.entity ? { entity: error.entity } : {},
|
|
1447
1477
|
...typeof error.status === "number" ? { status: error.status } : {},
|
|
1478
|
+
...error.requestId ? { requestId: error.requestId } : {},
|
|
1448
1479
|
...error.stack ? { stack: error.stack } : {}
|
|
1449
1480
|
};
|
|
1450
1481
|
}
|
|
@@ -1493,17 +1524,16 @@ function selectionKey(selection) {
|
|
|
1493
1524
|
expression: selection.expression
|
|
1494
1525
|
});
|
|
1495
1526
|
}
|
|
1496
|
-
function toDataAppError(err, entity) {
|
|
1497
|
-
if (err
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
return new QueryError(message, entity, err);
|
|
1527
|
+
function toDataAppError(err, entity, failed = "The query failed.") {
|
|
1528
|
+
if (isDataAppError(err)) return err.about(entity);
|
|
1529
|
+
console.error(`anfra: '${entity}' failed; the app is told only that it failed.`, err);
|
|
1530
|
+
return new DataAppError({
|
|
1531
|
+
code: "call_failed",
|
|
1532
|
+
scope: "server",
|
|
1533
|
+
message: failed,
|
|
1534
|
+
entity,
|
|
1535
|
+
cause: err
|
|
1536
|
+
});
|
|
1507
1537
|
}
|
|
1508
1538
|
var App = class extends Observable {
|
|
1509
1539
|
constructor(declaration, datasets, backend, features, extensions) {
|
|
@@ -1732,10 +1762,24 @@ var App = class extends Observable {
|
|
|
1732
1762
|
});
|
|
1733
1763
|
return byField;
|
|
1734
1764
|
}
|
|
1735
|
-
menu(query, event, rows, fields) {
|
|
1765
|
+
menu(query, event, rows, fields, measure) {
|
|
1736
1766
|
if (this._queries.get(query.name) !== query) {
|
|
1737
1767
|
throw new ValidationError(`Query '${query.name}' belongs to a different app.`, query.name);
|
|
1738
1768
|
}
|
|
1769
|
+
if (measure !== void 0) {
|
|
1770
|
+
const columns = query.result?.columns ?? [];
|
|
1771
|
+
const column = columns.find((candidate) => candidate.name === measure);
|
|
1772
|
+
if (!column?.isMeasure) {
|
|
1773
|
+
throw new ValidationError(
|
|
1774
|
+
column ? `Query '${query.name}' can't open a menu on '${measure}' as its measure: it is a dimension.` : withSuggestion(
|
|
1775
|
+
`Query '${query.name}' has no measure '${measure}' in its last result.`,
|
|
1776
|
+
measure,
|
|
1777
|
+
columns.filter((candidate) => candidate.isMeasure).map((candidate) => candidate.name)
|
|
1778
|
+
),
|
|
1779
|
+
query.name
|
|
1780
|
+
);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1739
1783
|
const derived = deriveSelection(query, rows, fields, this.drillTransformations(query));
|
|
1740
1784
|
return openRowsMenu(event, {
|
|
1741
1785
|
kind: "rows",
|
|
@@ -1743,10 +1787,29 @@ var App = class extends Observable {
|
|
|
1743
1787
|
query: query.name,
|
|
1744
1788
|
rows: [...rows],
|
|
1745
1789
|
fields: derived?.fields ? [...derived.fields] : [],
|
|
1790
|
+
...measure !== void 0 ? { measure } : {},
|
|
1746
1791
|
conditions: derived?.conditions ? [...derived.conditions] : [],
|
|
1747
1792
|
...derived?.expression ? { expression: derived.expression } : {}
|
|
1748
1793
|
});
|
|
1749
1794
|
}
|
|
1795
|
+
/**
|
|
1796
|
+
* @internal Backs the kernel's `queryRequest(query)`: what the query runs with now, from its applied
|
|
1797
|
+
* state, as `fetchPage` and `exportQuery` build theirs.
|
|
1798
|
+
*/
|
|
1799
|
+
requestFor(query) {
|
|
1800
|
+
if (this._queries.get(query.name) !== query) {
|
|
1801
|
+
throw new ValidationError(`Query '${query.name}' belongs to a different app.`, query.name);
|
|
1802
|
+
}
|
|
1803
|
+
return buildQuery(
|
|
1804
|
+
query,
|
|
1805
|
+
this.mappingsTo(query.name),
|
|
1806
|
+
{
|
|
1807
|
+
conditions: this.selectionConditionsFor(query.name, "applied"),
|
|
1808
|
+
expression: this.selectionExpressionFor(query.name, "applied")
|
|
1809
|
+
},
|
|
1810
|
+
{ timezone: this._timezone }
|
|
1811
|
+
);
|
|
1812
|
+
}
|
|
1750
1813
|
select(query, rows, fields) {
|
|
1751
1814
|
if (this._queries.get(query.name) !== query) {
|
|
1752
1815
|
throw new ValidationError(`Query '${query.name}' belongs to a different app.`, query.name);
|
|
@@ -1884,7 +1947,7 @@ var App = class extends Observable {
|
|
|
1884
1947
|
return await send(request, options.signal ?? new AbortController().signal);
|
|
1885
1948
|
} catch (err) {
|
|
1886
1949
|
if (isAbort(err)) throw err;
|
|
1887
|
-
throw
|
|
1950
|
+
throw toDataAppError(err, query.name, "The export failed.");
|
|
1888
1951
|
}
|
|
1889
1952
|
}
|
|
1890
1953
|
/* ----------------------------------------------------------------
|
|
@@ -2175,9 +2238,13 @@ var BODY_GLOBAL = "__anfraBodyExports";
|
|
|
2175
2238
|
var KERNEL_ERRORS = {
|
|
2176
2239
|
DataAppError,
|
|
2177
2240
|
ValidationError,
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2241
|
+
invalidRequest,
|
|
2242
|
+
forbidden,
|
|
2243
|
+
connectionFailed,
|
|
2244
|
+
callFailed,
|
|
2245
|
+
fromHttpStatus,
|
|
2246
|
+
hasErrorCode,
|
|
2247
|
+
isDataAppError
|
|
2181
2248
|
};
|
|
2182
2249
|
function runBody(win, code) {
|
|
2183
2250
|
const target = win;
|
|
@@ -2205,6 +2272,11 @@ function createKernel(plugin, shared, entities) {
|
|
|
2205
2272
|
return overlayFor(win.document);
|
|
2206
2273
|
},
|
|
2207
2274
|
structure: () => buildStructure(win.document, sdk.apps),
|
|
2275
|
+
queryRequest(query) {
|
|
2276
|
+
const app = sdk.apps.find((candidate) => candidate.queries[query?.name] === query);
|
|
2277
|
+
if (!app) throw new ValidationError(`Query '${String(query?.name)}' belongs to no app.`, query?.name);
|
|
2278
|
+
return app.requestFor(query);
|
|
2279
|
+
},
|
|
2208
2280
|
call: (name, request, signal) => endpoint.call(name, request ?? null, signal),
|
|
2209
2281
|
emit: (name, payload) => endpoint.emit(`${plugin}.${name}`, payload ?? null),
|
|
2210
2282
|
handle(name, handler) {
|
|
@@ -2396,7 +2468,7 @@ function bootstrap(win, setups = []) {
|
|
|
2396
2468
|
const endpoint = createEndpoint(post, {
|
|
2397
2469
|
answer: async (name, request, signal) => {
|
|
2398
2470
|
const handler = handlers.get(name);
|
|
2399
|
-
if (!handler) throw
|
|
2471
|
+
if (!handler) throw invalidRequest(`Nothing in this frame answers '${name}'.`);
|
|
2400
2472
|
return handler(request, signal);
|
|
2401
2473
|
},
|
|
2402
2474
|
event: (name, payload) => {
|
|
@@ -19,6 +19,7 @@ function checkTarget(value) {
|
|
|
19
19
|
if (!Array.isArray(value.fields) || !value.fields.every((field) => typeof field === "string")) return void 0;
|
|
20
20
|
if (!Array.isArray(value.conditions) || !value.conditions.every(isObject)) return void 0;
|
|
21
21
|
if (value.expression !== void 0 && typeof value.expression !== "string") return void 0;
|
|
22
|
+
if (value.measure !== void 0 && typeof value.measure !== "string") return void 0;
|
|
22
23
|
const node = value.node === void 0 ? void 0 : checkNode(value.node);
|
|
23
24
|
if (value.node !== void 0 && !node) return void 0;
|
|
24
25
|
return {
|
|
@@ -27,6 +28,7 @@ function checkTarget(value) {
|
|
|
27
28
|
query: value.query,
|
|
28
29
|
rows: value.rows,
|
|
29
30
|
fields: value.fields,
|
|
31
|
+
...value.measure !== void 0 ? { measure: value.measure } : {},
|
|
30
32
|
conditions: value.conditions,
|
|
31
33
|
...value.expression !== void 0 ? { expression: value.expression } : {},
|
|
32
34
|
...node ? { node } : {}
|
|
@@ -118,7 +118,7 @@ function createRequestLog({ limit = 200, previewRows = 20 } = {}) {
|
|
|
118
118
|
settle(id, {
|
|
119
119
|
status: context.signal.aborted ? "aborted" : "error",
|
|
120
120
|
durationMs: durationMs(),
|
|
121
|
-
error:
|
|
121
|
+
error: describeError(err)
|
|
122
122
|
});
|
|
123
123
|
throw err;
|
|
124
124
|
}
|
|
@@ -163,6 +163,11 @@ function attributeRequests(entries, apps) {
|
|
|
163
163
|
}
|
|
164
164
|
return { byQuery, other };
|
|
165
165
|
}
|
|
166
|
+
function describeError(err) {
|
|
167
|
+
if (!(err instanceof Error)) return String(err);
|
|
168
|
+
const { code } = err;
|
|
169
|
+
return `${typeof code === "string" ? code : err.name}: ${err.message}`;
|
|
170
|
+
}
|
|
166
171
|
|
|
167
172
|
// src/plugins/inspect/state.ts
|
|
168
173
|
var states = /* @__PURE__ */ new WeakMap();
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__publicField
|
|
3
|
+
} from "./chunk-PKBMQBKP.js";
|
|
4
|
+
|
|
5
|
+
// src/common/errors.ts
|
|
6
|
+
var GENERIC_CODES = {
|
|
7
|
+
query_invalid: "user",
|
|
8
|
+
query_failed: "user",
|
|
9
|
+
forbidden: "user",
|
|
10
|
+
unauthenticated: "user",
|
|
11
|
+
invalid_request: "client",
|
|
12
|
+
declaration_invalid: "client",
|
|
13
|
+
connection_failed: "server",
|
|
14
|
+
call_failed: "server",
|
|
15
|
+
internal_server_error: "server"
|
|
16
|
+
};
|
|
17
|
+
var DataAppError = class _DataAppError extends Error {
|
|
18
|
+
constructor(init) {
|
|
19
|
+
super(init.message);
|
|
20
|
+
/** What happened: a generic code, or the backend's own. */
|
|
21
|
+
__publicField(this, "code");
|
|
22
|
+
/** Who must act: `user` (the reader's input or state), `client` (the app), `server`. */
|
|
23
|
+
__publicField(this, "scope");
|
|
24
|
+
/** The HTTP status the backend answered, when it answered one. */
|
|
25
|
+
__publicField(this, "status");
|
|
26
|
+
/** Facts to act on, typed by code: a query's diagnostics, the fields at fault, a row limit. */
|
|
27
|
+
__publicField(this, "details");
|
|
28
|
+
/** The steps the failure happened in, outermost first. */
|
|
29
|
+
__publicField(this, "context");
|
|
30
|
+
/** The id of the server request that failed: the line to look for in its log. */
|
|
31
|
+
__publicField(this, "requestId");
|
|
32
|
+
/** The query, control or dataset that caused this. */
|
|
33
|
+
__publicField(this, "entity");
|
|
34
|
+
__publicField(this, "cause");
|
|
35
|
+
this.name = new.target.name;
|
|
36
|
+
this.code = init.code;
|
|
37
|
+
this.scope = init.scope;
|
|
38
|
+
if (init.status !== void 0) this.status = init.status;
|
|
39
|
+
if (init.details !== void 0) this.details = init.details;
|
|
40
|
+
if (init.context !== void 0) this.context = init.context;
|
|
41
|
+
if (init.requestId !== void 0) this.requestId = init.requestId;
|
|
42
|
+
if (init.entity !== void 0) this.entity = init.entity;
|
|
43
|
+
if (init.cause !== void 0) this.cause = init.cause;
|
|
44
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
45
|
+
}
|
|
46
|
+
/** This error, naming `entity`: the same failure, said of the query or control it concerns. */
|
|
47
|
+
about(entity) {
|
|
48
|
+
if (this.entity === entity) return this;
|
|
49
|
+
return new _DataAppError({ ...fieldsOf(this), entity });
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var ValidationError = class _ValidationError extends DataAppError {
|
|
53
|
+
constructor(message, entity) {
|
|
54
|
+
super({
|
|
55
|
+
code: "declaration_invalid",
|
|
56
|
+
scope: "client",
|
|
57
|
+
message,
|
|
58
|
+
entity
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
about(entity) {
|
|
62
|
+
return this.entity === entity ? this : new _ValidationError(this.message, entity);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
function isDataAppError(err) {
|
|
66
|
+
if (err instanceof DataAppError) return true;
|
|
67
|
+
const e = err;
|
|
68
|
+
return e instanceof Error && (e.name === "DataAppError" || e.name === "ValidationError") && typeof e.code === "string";
|
|
69
|
+
}
|
|
70
|
+
function hasErrorCode(err, code) {
|
|
71
|
+
return isDataAppError(err) && err.code === code;
|
|
72
|
+
}
|
|
73
|
+
function contextOf(context) {
|
|
74
|
+
if (!Array.isArray(context)) return void 0;
|
|
75
|
+
const entries = context.filter((c) => typeof c?.text === "string").map((c) => typeof c.step === "string" ? { step: c.step, text: c.text } : { text: c.text });
|
|
76
|
+
return entries.length ? entries : void 0;
|
|
77
|
+
}
|
|
78
|
+
function invalidRequest(message, entity) {
|
|
79
|
+
return new DataAppError({
|
|
80
|
+
code: "invalid_request",
|
|
81
|
+
scope: "client",
|
|
82
|
+
message,
|
|
83
|
+
entity
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function forbidden(message, entity) {
|
|
87
|
+
return new DataAppError({
|
|
88
|
+
code: "forbidden",
|
|
89
|
+
scope: "user",
|
|
90
|
+
message,
|
|
91
|
+
entity
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function connectionFailed(message, status) {
|
|
95
|
+
return new DataAppError({
|
|
96
|
+
code: "connection_failed",
|
|
97
|
+
scope: "server",
|
|
98
|
+
message,
|
|
99
|
+
status
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function callFailed(cause) {
|
|
103
|
+
return new DataAppError({
|
|
104
|
+
code: "call_failed",
|
|
105
|
+
scope: "server",
|
|
106
|
+
message: "The call failed.",
|
|
107
|
+
cause
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function fromHttpStatus(status, message, options = {}) {
|
|
111
|
+
const { refused = "invalid_request", requestId, entity } = options;
|
|
112
|
+
let code;
|
|
113
|
+
if (status === void 0 || status === 0) code = "connection_failed";
|
|
114
|
+
else if (status === 401) code = "unauthenticated";
|
|
115
|
+
else if (status === 403) code = "forbidden";
|
|
116
|
+
else if (status >= 400 && status < 500) code = refused;
|
|
117
|
+
else code = "internal_server_error";
|
|
118
|
+
return new DataAppError({
|
|
119
|
+
code,
|
|
120
|
+
scope: scopeOf(code, status),
|
|
121
|
+
message,
|
|
122
|
+
status: status || void 0,
|
|
123
|
+
requestId,
|
|
124
|
+
entity
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function scopeOf(code, status) {
|
|
128
|
+
if (code in GENERIC_CODES) return GENERIC_CODES[code];
|
|
129
|
+
return status !== void 0 && status >= 400 && status < 500 ? "user" : "server";
|
|
130
|
+
}
|
|
131
|
+
function toScope(scope) {
|
|
132
|
+
return scope === "user" || scope === "client" || scope === "server" ? scope : "server";
|
|
133
|
+
}
|
|
134
|
+
function fieldsOf(err) {
|
|
135
|
+
return {
|
|
136
|
+
code: err.code,
|
|
137
|
+
scope: err.scope,
|
|
138
|
+
message: err.message,
|
|
139
|
+
status: err.status,
|
|
140
|
+
details: err.details,
|
|
141
|
+
context: err.context,
|
|
142
|
+
requestId: err.requestId,
|
|
143
|
+
entity: err.entity,
|
|
144
|
+
cause: err.cause
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export {
|
|
149
|
+
GENERIC_CODES,
|
|
150
|
+
DataAppError,
|
|
151
|
+
ValidationError,
|
|
152
|
+
isDataAppError,
|
|
153
|
+
hasErrorCode,
|
|
154
|
+
contextOf,
|
|
155
|
+
invalidRequest,
|
|
156
|
+
forbidden,
|
|
157
|
+
connectionFailed,
|
|
158
|
+
callFailed,
|
|
159
|
+
fromHttpStatus,
|
|
160
|
+
toScope
|
|
161
|
+
};
|
package/dist/common.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { D as DataAppError,
|
|
2
|
-
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
|
|
3
|
-
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-
|
|
1
|
+
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-IhdhKO-6.js';
|
|
2
|
+
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 QueryRequest, a4 as QueryResult, a5 as QuerySort, a6 as QueryState, a7 as QueryTimings, a8 as RenderFormat, a9 as RenderRequest, aa as Rendering, ab as Row, ac as SdkEnvironment, ad as SdkFeatures, ae as Selection, af as SelectionCondition, ag as SemanticType, ah as StructureKind, ai as StructureNode, aj as Unsubscribe, ak as User } from './types-C_i7V0DA.js';
|
|
3
|
+
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-CRAFaQ8s.js';
|
package/dist/common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./chunk-UUKXJSE4.js";
|
|
2
2
|
import {
|
|
3
3
|
checkTarget
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ACKFOANJ.js";
|
|
5
5
|
import {
|
|
6
6
|
FILTER_AGGREGATIONS
|
|
7
7
|
} from "./chunk-XIUFHRZE.js";
|
|
@@ -15,24 +15,34 @@ import {
|
|
|
15
15
|
} from "./chunk-RXPNL7UR.js";
|
|
16
16
|
import {
|
|
17
17
|
DataAppError,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
GENERIC_CODES,
|
|
19
|
+
ValidationError,
|
|
20
|
+
callFailed,
|
|
21
|
+
connectionFailed,
|
|
22
|
+
forbidden,
|
|
23
|
+
fromHttpStatus,
|
|
24
|
+
hasErrorCode,
|
|
25
|
+
invalidRequest,
|
|
26
|
+
isDataAppError
|
|
27
|
+
} from "./chunk-SWNVCTT6.js";
|
|
23
28
|
import "./chunk-PKBMQBKP.js";
|
|
24
29
|
export {
|
|
25
30
|
DEFAULT_TOKENS,
|
|
26
31
|
DESIGN_TOKENS,
|
|
27
32
|
DataAppError,
|
|
28
33
|
FILTER_AGGREGATIONS,
|
|
34
|
+
GENERIC_CODES,
|
|
29
35
|
PROVISION_ELEMENT_ID,
|
|
30
|
-
PermissionError,
|
|
31
|
-
QueryError,
|
|
32
36
|
THEME_TOKENS,
|
|
33
|
-
TransportError,
|
|
34
37
|
ValidationError,
|
|
38
|
+
callFailed,
|
|
35
39
|
checkTarget,
|
|
40
|
+
connectionFailed,
|
|
36
41
|
designTheme,
|
|
42
|
+
forbidden,
|
|
43
|
+
fromHttpStatus,
|
|
44
|
+
hasErrorCode,
|
|
45
|
+
invalidRequest,
|
|
46
|
+
isDataAppError,
|
|
37
47
|
resolveTheme
|
|
38
48
|
};
|
|
@@ -9,10 +9,12 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
attributeRequests,
|
|
11
11
|
stateOf
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-C26OVN2S.js";
|
|
13
13
|
import {
|
|
14
|
+
badge,
|
|
14
15
|
collapsible,
|
|
15
16
|
columnIcon,
|
|
17
|
+
control,
|
|
16
18
|
drawTab,
|
|
17
19
|
filterIndicator,
|
|
18
20
|
flash,
|
|
@@ -23,7 +25,7 @@ import {
|
|
|
23
25
|
queryTrust,
|
|
24
26
|
table,
|
|
25
27
|
trustIndicator
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-32566ZNE.js";
|
|
27
29
|
import "./chunk-K633QHGO.js";
|
|
28
30
|
import {
|
|
29
31
|
entityNodeKey,
|
|
@@ -99,7 +101,7 @@ function dataTab(root, context) {
|
|
|
99
101
|
setSearch("");
|
|
100
102
|
}
|
|
101
103
|
});
|
|
102
|
-
const head = h(doc, "div", { class: "search-bar" }, h(doc, "label", { class: "search" }, icon(doc, "search"), input));
|
|
104
|
+
const head = h(doc, "div", { class: "search-bar" }, h(doc, "label", { class: "a-input search" }, icon(doc, "search"), input));
|
|
103
105
|
const setSearch = (text) => {
|
|
104
106
|
search = text;
|
|
105
107
|
input.value = text;
|
|
@@ -140,7 +142,7 @@ function dataTab(root, context) {
|
|
|
140
142
|
h(doc, "span", { "data-tip": returned.toLocaleString() }, formatAgo(returned)),
|
|
141
143
|
canExport && h(doc, "button", {
|
|
142
144
|
type: "button",
|
|
143
|
-
|
|
145
|
+
...control("row-action"),
|
|
144
146
|
"data-tip": "Download CSV",
|
|
145
147
|
"aria-label": "Download CSV",
|
|
146
148
|
"data-testid": "download-csv",
|
|
@@ -155,14 +157,14 @@ function dataTab(root, context) {
|
|
|
155
157
|
const active = [...declaredFilters(declaration?.aql), ...queryInputs(app, name)].filter(isActive);
|
|
156
158
|
return collapsible(doc, `table:${key}`, [
|
|
157
159
|
h(doc, "span", { class: "name" }, name),
|
|
158
|
-
query.state === "error" && h(doc, "span", {
|
|
160
|
+
query.state === "error" && h(doc, "span", { ...badge("error") }, "couldn't load"),
|
|
159
161
|
h(doc, "span", { class: "spacer" }),
|
|
160
162
|
filterIndicator(doc, active),
|
|
161
163
|
trustIndicator(doc, queryTrust(declaration, query)),
|
|
162
164
|
hasLineage && lineageButton(doc, panel, entityNodeKey(panel.snapshot?.structure?.nodes ?? [], "query", index, name)),
|
|
163
165
|
h(doc, "button", {
|
|
164
166
|
type: "button",
|
|
165
|
-
|
|
167
|
+
...control("row-action"),
|
|
166
168
|
"data-tip": "Query",
|
|
167
169
|
"aria-label": "Query",
|
|
168
170
|
"data-testid": "show-query",
|