@ahoo-wang/wow-view-engine 10.0.0-alpha.7 → 10.0.0-beta.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.
- package/dist/{actions-BWlediub.js → actions-ClYpI7gy.js} +2806 -2793
- package/dist/actions-ClYpI7gy.js.map +1 -0
- package/dist/{export-BCADqfu6.js → export-D1udIJPm.js} +2 -2
- package/dist/{export-BCADqfu6.js.map → export-D1udIJPm.js.map} +1 -1
- package/dist/index.js +139 -139
- package/dist/index.js.map +1 -1
- package/dist/react/actionRunner.d.ts +8 -0
- package/dist/react/actionRunner.d.ts.map +1 -1
- package/dist/react/useRecordActions.d.ts +2 -0
- package/dist/react/useRecordActions.d.ts.map +1 -1
- package/dist/react/useSaveCommands.d.ts +6 -0
- package/dist/react/useSaveCommands.d.ts.map +1 -1
- package/dist/{react-D1wSQhlr.js → react-Cqk337ck.js} +1353 -1347
- package/dist/react-Cqk337ck.js.map +1 -0
- package/dist/react.js +1 -1
- package/dist/runtime/actions.d.ts +23 -0
- package/dist/runtime/actions.d.ts.map +1 -1
- package/dist/runtime/failure/failures.d.ts.map +1 -1
- package/dist/runtime/failure/issueReport.d.ts.map +1 -1
- package/dist/runtime/permissions.d.ts.map +1 -1
- package/dist/runtime/resources.d.ts +4 -1
- package/dist/runtime/resources.d.ts.map +1 -1
- package/dist/runtime/viewEngine.d.ts +7 -1
- package/dist/runtime/viewEngine.d.ts.map +1 -1
- package/dist/store/MemoryViewStore.d.ts +8 -0
- package/dist/store/MemoryViewStore.d.ts.map +1 -1
- package/dist/store/ViewStore.d.ts +16 -0
- package/dist/store/ViewStore.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/testing.js +112 -112
- package/dist/testing.js.map +1 -1
- package/dist/ui/actions/ActionButtons.d.ts.map +1 -1
- package/dist/ui/actions/ActionDialog.d.ts.map +1 -1
- package/dist/ui/actions/ActionSurface.d.ts +6 -0
- package/dist/ui/actions/ActionSurface.d.ts.map +1 -1
- package/dist/ui/dashboard/DashboardPanelCard.d.ts.map +1 -1
- package/dist/ui/dashboard/OpensNumber.d.ts +17 -0
- package/dist/ui/dashboard/OpensNumber.d.ts.map +1 -0
- package/dist/ui/kit/popups.d.ts.map +1 -1
- package/dist/ui/messages/dashboard.d.ts +1 -0
- package/dist/ui/messages/dashboard.d.ts.map +1 -1
- package/dist/ui/messages/definition.d.ts +1 -0
- package/dist/ui/messages/definition.d.ts.map +1 -1
- package/dist/ui/messages/en.d.ts +3 -0
- package/dist/ui/messages/en.d.ts.map +1 -1
- package/dist/ui/messages/scope.d.ts +1 -0
- package/dist/ui/messages/scope.d.ts.map +1 -1
- package/dist/ui/messages/zh-CN.d.ts.map +1 -1
- package/dist/ui/record/RecordDetail.d.ts +7 -1
- package/dist/ui/record/RecordDetail.d.ts.map +1 -1
- package/dist/ui/workbench/MoreViewActions.d.ts.map +1 -1
- package/dist/ui/workbench/RecordParts.d.ts.map +1 -1
- package/dist/ui/workbench/SaveActions.d.ts.map +1 -1
- package/dist/ui/workbench/SaveAsDialog.d.ts +7 -1
- package/dist/ui/workbench/SaveAsDialog.d.ts.map +1 -1
- package/dist/ui/workbench/ViewEngineProvider.d.ts.map +1 -1
- package/dist/ui/workbench/WriteOutcome.d.ts.map +1 -1
- package/dist/ui/workbench/address.d.ts +4 -2
- package/dist/ui/workbench/address.d.ts.map +1 -1
- package/dist/ui.js +5372 -5299
- package/dist/ui.js.map +1 -1
- package/dist/{viewRuntimeTypes-BCdG5xRp.js → viewRuntimeTypes-D08oR6Ke.js} +670 -655
- package/dist/viewRuntimeTypes-D08oR6Ke.js.map +1 -0
- package/package.json +3 -3
- package/dist/actions-BWlediub.js.map +0 -1
- package/dist/react-D1wSQhlr.js.map +0 -1
- package/dist/viewRuntimeTypes-BCdG5xRp.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fr as e } from "./actions-ClYpI7gy.js";
|
|
2
2
|
var t = "\r\n", n = /["\r\n,]/, r = /^[=+\-@\t\r]/, i = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
3
3
|
function a(t, n, r, i = {}) {
|
|
4
4
|
return o(n.map((e) => e.label), t.map((t) => n.map((n) => {
|
|
@@ -26,4 +26,4 @@ function c(e, t) {
|
|
|
26
26
|
}
|
|
27
27
|
export { o as n, a as t };
|
|
28
28
|
|
|
29
|
-
//# sourceMappingURL=export-
|
|
29
|
+
//# sourceMappingURL=export-D1udIJPm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-
|
|
1
|
+
{"version":3,"file":"export-D1udIJPm.js","names":["RecordData","recordValue","ExportColumn","field","label","ExportFormat","value","column","C","CSV_BOM","CRLF","MUST_QUOTE","FORMULA_START","PLAIN_NUMBER","CsvOptions","neutralizeFormulas","CsvCell","text","serializeCsv","rows","columns","format","options","writeCsv","map","row","header","neutralize","cell","csvField","lines","push","line","join","written","String","evaluable","test","split","recordValue","CRLF","MUST_QUOTE","FORMULA_START","PLAIN_NUMBER","serializeCsv","writeCsv","columns","column","rows","value","row","format","options","neutralize","field","csvField","cell","lines","header","label","line","written","text","evaluable"],"sources":["../src/record/export.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RecordData } from '../model/index.js';\nimport { recordValue } from './project.js';\n\n/** The least an export needs of a column: where to read it, what to call it. */\nexport interface ExportColumn {\n /** A Wow query path, read the way a cell reads it. */\n field: string;\n /** What the header row calls this column. */\n label: string;\n}\n\n/**\n * How one value is written.\n *\n * It is injected rather than decided here, because how a value *reads* is the\n * UI's answer — an enum by its label, a time in the surface's zone, a number\n * in its field's format — and this layer has no catalogue, no locale and no\n * renderers. The column rides along with the value, so one formatter serves\n * every column of the table.\n */\nexport type ExportFormat<C extends ExportColumn = ExportColumn> = (\n value: unknown,\n column: C,\n) => string;\n\n/**\n * The byte order mark Excel needs to read a UTF-8 CSV as UTF-8.\n *\n * Without it Excel on Windows reads the file in the machine's ANSI code page\n * and every Chinese name in it arrives as mojibake — which is most of what\n * these exports carry.\n */\nexport const CSV_BOM = '';\n\n/** RFC 4180 ends every record with CRLF, the last one included. */\nconst CRLF = '\\r\\n';\n\n/** The characters that oblige a field to be quoted, the quote included. */\nconst MUST_QUOTE = /[\"\\r\\n,]/;\n\n/**\n * What a spreadsheet may read a cell as a formula by: its first character\n * (OWASP, CSV Injection). `=`, `+`, `-` and `@` start a formula or a\n * function; a tab or a carriage return in front hides one from a reader who\n * trims.\n */\nconst FORMULA_START = /^[=+\\-@\\t\\r]/;\n\n/**\n * A text that is a number and nothing else: a sign, digits, one decimal\n * point, an exponent. No separators, no currency, no spaces — nothing a\n * spreadsheet could read as more than one number.\n */\nconst PLAIN_NUMBER = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?$/;\n\n/** How a CSV is written. */\nexport interface CsvOptions {\n /**\n * Whether a cell a spreadsheet could evaluate is written with an\n * apostrophe in front, so it opens as the text it is. On unless set to\n * `false`.\n *\n * A file leaves the page: it is opened in Excel, often by someone other\n * than whoever exported it, and a value somebody typed into a text field\n * — `=HYPERLINK(…)`, `=cmd|' /C calc'!A0` — would run there as a formula\n * (OWASP, CSV Injection). So every cell whose text starts with `=`, `+`,\n * `-`, `@`, a tab or a carriage return gets a leading `'`, the header's\n * labels included, since a definition names them.\n *\n * Two kinds of cell are left alone, because a spreadsheet reads them as a\n * number and never as a formula: one whose value was a number (a negative\n * amount, however its field formats it — `-1,204.50`, `-$12.00`), and one\n * whose text is a plain number (`-12.5` held by a text field). Prefixing\n * either would only make the file differ from the screen.\n *\n * Turn it off only where the file never reaches a spreadsheet — a\n * pipeline that reads the CSV back as data and wants the text as stored.\n */\n neutralizeFormulas?: boolean;\n}\n\n/** One cell of a file: the value it was read from, and the text it reads as. */\nexport interface CsvCell {\n /** What the row held; only its type is looked at: a number is never a formula. */\n value: unknown;\n /** The text written, before any escaping. */\n text: string;\n}\n\n/**\n * The rows as a CSV, RFC 4180 with a BOM in front.\n *\n * The header is the labels of the columns handed over, in the order they are\n * handed over — which is the projected order of the visible columns, so the\n * file carries the table's columns rather than the definition's fields.\n *\n * Nothing here looks at what a value *means*: `format` has already decided\n * that, and what is left is writing it (`writeCsv`) — the escaping, and the\n * formulas neutralized unless `options` says otherwise (`CsvOptions`).\n */\nexport function serializeCsv<C extends ExportColumn>(\n rows: readonly RecordData[],\n columns: readonly C[],\n format: ExportFormat<C>,\n options: CsvOptions = {},\n): string {\n return writeCsv(\n columns.map(column => column.label),\n rows.map(row =>\n columns.map(column => {\n const value = recordValue(row, column.field);\n return { value, text: format(value, column) };\n }),\n ),\n options,\n );\n}\n\n/**\n * Cells already read, as a CSV: the one writer every export goes through —\n * a record view's rows (`serializeCsv`) and an analysis's groups alike — so\n * the escaping and the formula rule (`CsvOptions.neutralizeFormulas`) are\n * one rule rather than one per export.\n */\nexport function writeCsv(\n header: readonly string[],\n rows: readonly (readonly CsvCell[])[],\n options: CsvOptions = {},\n): string {\n const neutralize = options.neutralizeFormulas !== false;\n const field = (cell: CsvCell) => csvField(cell, neutralize);\n const lines = [header.map(label => field({ value: label, text: label }))];\n for (const row of rows) lines.push(row.map(field));\n return `${CSV_BOM}${lines.map(line => line.join(',')).join(CRLF)}${CRLF}`;\n}\n\n/**\n * One field: neutralized where a spreadsheet could evaluate it, then quoted\n * where it has to be.\n *\n * The text is typed as a string, but it comes from a function a host may\n * have written, so it is coerced rather than trusted: `null` written into\n * the file as the word `null` is a value the table never showed.\n */\nfunction csvField({ value, text }: CsvCell, neutralize: boolean): string {\n let written = typeof text === 'string' ? text : String(text ?? '');\n if (neutralize && evaluable(value, written)) written = `'${written}`;\n return MUST_QUOTE.test(written)\n ? `\"${written.split('\"').join('\"\"')}\"`\n : written;\n}\n\n/** Whether a spreadsheet opening this cell could evaluate it (`CsvOptions`). */\nfunction evaluable(value: unknown, text: string): boolean {\n if (typeof value === 'number' || typeof value === 'bigint') return false;\n return FORMULA_START.test(text) && !PLAIN_NUMBER.test(text);\n}\n"],"mappings":";AAgDA,IAAMU,IAAO,QAGPC,IAAa,YAQbC,IAAgB,gBAOhBC,IAAe;AA+CrB,SAAgBK,EACdC,GACAC,GACAC,GACAC,IAAsB,CAAC,GACf;CACR,OAAOC,EACLH,EAAQI,KAAIjB,MAAUA,EAAOH,KAAK,GAClCe,EAAKK,KAAIC,MACPL,EAAQI,KAAIjB,MAAU;EACpB,IAAMD,IAAQL,EAAYwB,GAAKlB,EAAOJ,KAAK;EAC3C,OAAO;GAAEG;GAAOW,MAAMI,EAAOf,GAAOC,CAAM;EAAE;CAC9C,CAAC,CACH,GACAe,CACF;AACF;AAQA,SAAgBC,EACdG,GACAP,GACAG,IAAsB,CAAC,GACf;CACR,IAAMK,IAAaL,EAAQP,uBAAuB,IAC5CZ,KAASyB,MAAkBC,EAASD,GAAMD,CAAU,GACpDG,IAAQ,CAACJ,EAAOF,KAAIpB,MAASD,EAAM;EAAEG,OAAOF;EAAOa,MAAMb;CAAM,CAAC,CAAC,CAAC;CACxE,KAAK,IAAMqB,KAAON,GAAMW,EAAMC,KAAKN,EAAID,IAAIrB,CAAK,CAAC;CACjD,OAAO,IAAa2B,EAAMN,KAAIQ,MAAQA,EAAKC,KAAK,GAAG,CAAC,CAAC,CAACA,KAAKvB,CAAI,IAAIA;AACrE;AAUA,SAASmB,EAAS,EAAEvB,UAAOW,WAAiBU,GAA6B;CACvE,IAAIO,IAAU,OAAOjB,KAAS,WAAWA,IAAOkB,OAAOlB,KAAQ,EAAE;CAEjE,OADIU,KAAcS,EAAU9B,GAAO4B,CAAO,MAAGA,IAAU,IAAIA,MACpDvB,EAAW0B,KAAKH,CAAO,IAC1B,IAAIA,EAAQI,MAAM,IAAG,CAAC,CAACL,KAAK,MAAI,EAAC,KACjCC;AACN;AAGA,SAASE,EAAU9B,GAAgBW,GAAuB;CAExD,OADI,OAAOX,KAAU,YAAY,OAAOA,KAAU,WAAiB,KAC5DM,EAAcyB,KAAKpB,CAAI,KAAK,CAACJ,EAAawB,KAAKpB,CAAI;AAC5D"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as e, $a as t, Aa as n,
|
|
2
|
-
import { H as I, J as L, K as _e, L as ve, i as ye, l as be, n as xe, nt as Se, o as Ce, q as we, r as Te, rt as Ee, s as De, t as Oe, z as ke } from "./viewRuntimeTypes-
|
|
3
|
-
import { t as Ae } from "./export-
|
|
1
|
+
import { $ as e, $a as t, Aa as n, D as r, E as i, Fa as a, Ga as o, Gr as s, Ha as c, Jr as l, Ka as u, Mo as d, Na as f, O as p, On as m, Oo as h, Pr as g, Q as _, Qa as v, Ra as y, So as b, To as x, Ua as S, Va as ee, Xa as te, Xi as C, Ya as w, Z as ne, Zr as re, bo as ie, ci as ae, cn as oe, eo as T, et as E, hi as se, ho as ce, ht as le, ja as ue, k as de, kr as fe, lo as pe, na as me, no as he, qr as ge, rn as D, s as O, so as k, to as A, tt as j, w as M, wo as N, xi as P, za as F } from "./actions-ClYpI7gy.js";
|
|
2
|
+
import { H as I, J as L, K as _e, L as ve, i as ye, l as be, n as xe, nt as Se, o as Ce, q as we, r as Te, rt as Ee, s as De, t as Oe, z as ke } from "./viewRuntimeTypes-D08oR6Ke.js";
|
|
3
|
+
import { t as Ae } from "./export-D1udIJPm.js";
|
|
4
4
|
import { TimeUnit as je } from "@ahoo-wang/wow-client/dsl";
|
|
5
5
|
// src/runtime/define/analysis.ts
|
|
6
6
|
function Me(e, t) {
|
|
@@ -26,82 +26,82 @@ function Me(e, t) {
|
|
|
26
26
|
return r;
|
|
27
27
|
}
|
|
28
28
|
function Ne(e, t, n, r) {
|
|
29
|
-
if (e) return
|
|
29
|
+
if (e) return _(e, t.map((e) => e.field), n, (e, t) => r.push(e === null ? f("definition.analysis.wider", ["analysis"], { what: t }, "warning") : f("definition.field.analysis-wider", ["analysis"], {
|
|
30
30
|
field: e,
|
|
31
31
|
what: t
|
|
32
32
|
}, "warning")));
|
|
33
33
|
}
|
|
34
34
|
// src/runtime/define/fields.ts
|
|
35
|
-
var R = (e, t, n = "error") =>
|
|
35
|
+
var R = (e, t, n = "error") => f(e, ["fields"], t, n);
|
|
36
36
|
function z(e, t, n) {
|
|
37
37
|
return Object.entries(e).flatMap(([e, r]) => {
|
|
38
38
|
let i = Pe(e, typeof r == "string" ? { label: r } : r, t, n);
|
|
39
39
|
return i ? [i] : [];
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function Pe(t, n, r
|
|
43
|
-
let { descriptor:
|
|
44
|
-
if (
|
|
45
|
-
let
|
|
46
|
-
if (!
|
|
47
|
-
let
|
|
48
|
-
if (
|
|
49
|
-
let
|
|
50
|
-
name:
|
|
51
|
-
label: Be(
|
|
52
|
-
kind:
|
|
53
|
-
},
|
|
54
|
-
kind:
|
|
55
|
-
remote:
|
|
56
|
-
}),
|
|
57
|
-
if (
|
|
58
|
-
let e = Ve(
|
|
59
|
-
for (let
|
|
60
|
-
field:
|
|
61
|
-
operator:
|
|
42
|
+
function Pe(e, t, n, r) {
|
|
43
|
+
let { descriptor: i, findings: a } = r, o = n === void 0 ? e : `${n}.${e}`;
|
|
44
|
+
if (t.search) return Fe(e, t, n, r);
|
|
45
|
+
let s = E(i, o, n);
|
|
46
|
+
if (!s) return a.push(R("definition.field.undescribed", { field: o })), null;
|
|
47
|
+
let c = Ie(i, s.canonical ?? o, n), l = t.kind ?? ze(c, s, t);
|
|
48
|
+
if (l === null) return a.push(R("definition.field.kind-unknown", { field: o })), null;
|
|
49
|
+
let u = {
|
|
50
|
+
name: e,
|
|
51
|
+
label: Be(t, c, o, a),
|
|
52
|
+
kind: l
|
|
53
|
+
}, d = s.comparable !== !1, f = d && (r.paging === "cursor" ? s.sort.cursor : s.sort.paged), p = me({
|
|
54
|
+
kind: l,
|
|
55
|
+
remote: t.more?.remote
|
|
56
|
+
}), m = f && n === void 0 && !p;
|
|
57
|
+
if (t.sortable === !0 && !f && a.push(R("definition.field.sort-wider", { field: o }, "warning")), f && (t.sortable ?? m) && (u.sortable = !0), t.operators) {
|
|
58
|
+
let e = Ve(i, s, o);
|
|
59
|
+
for (let n of t.operators) e.has(n) || a.push(R("definition.field.operator-wider", {
|
|
60
|
+
field: o,
|
|
61
|
+
operator: n
|
|
62
62
|
}, "warning"));
|
|
63
|
-
|
|
64
|
-
} else
|
|
65
|
-
if (
|
|
66
|
-
let e =
|
|
67
|
-
for (let
|
|
68
|
-
field:
|
|
69
|
-
fn:
|
|
63
|
+
u.operators = t.operators;
|
|
64
|
+
} else d || (u.operators = []);
|
|
65
|
+
if (t.summary) {
|
|
66
|
+
let e = s.aggregate?.functions ?? [];
|
|
67
|
+
for (let n of t.summary) n !== ce.COUNT && !e.includes(n) && a.push(R("definition.field.summary-wider", {
|
|
68
|
+
field: o,
|
|
69
|
+
fn: n
|
|
70
70
|
}, "warning"));
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
let
|
|
76
|
-
|
|
77
|
-
field:
|
|
78
|
-
message:
|
|
79
|
-
}, "warning")),
|
|
80
|
-
let
|
|
81
|
-
return
|
|
82
|
-
field:
|
|
83
|
-
described:
|
|
84
|
-
spec:
|
|
85
|
-
sensitive:
|
|
86
|
-
...
|
|
71
|
+
u.summary = t.summary;
|
|
72
|
+
}
|
|
73
|
+
let h = He(t, s, o, a);
|
|
74
|
+
h && (u.options = h);
|
|
75
|
+
let g = Re(s);
|
|
76
|
+
g && C.includes(l) && (u.temporal = g), s.deprecated && (t.deprecated || a.push(R("definition.field.deprecated", {
|
|
77
|
+
field: o,
|
|
78
|
+
message: s.deprecated.message ?? ""
|
|
79
|
+
}, "warning")), u.deprecated = t.deprecated ?? s.deprecated);
|
|
80
|
+
let _;
|
|
81
|
+
return t.elements && (i.elements.some((e) => e.path === o) || a.push(R("definition.field.not-elements", { field: o })), _ = z(t.elements, o, r), u.elements = _.map((e) => e.field)), t.elementTitle !== void 0 && (u.elementTitle = t.elementTitle), t.cell !== void 0 && (u.cell = t.cell), t.timePrecision !== void 0 && (u.timePrecision = t.timePrecision), Object.assign(u, t.more), {
|
|
82
|
+
field: u,
|
|
83
|
+
described: s,
|
|
84
|
+
spec: t,
|
|
85
|
+
sensitive: s.sensitive === !0,
|
|
86
|
+
..._ ? { children: _ } : {}
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
function Fe(t, n, r
|
|
90
|
-
let
|
|
91
|
-
for (let
|
|
92
|
-
let
|
|
93
|
-
|
|
89
|
+
function Fe(e, t, n, r) {
|
|
90
|
+
let i = t.search ?? { fields: [] };
|
|
91
|
+
for (let e of i.fields) {
|
|
92
|
+
let t = n === void 0 ? e : `${n}.${e}`;
|
|
93
|
+
E(r.descriptor, t, n) || r.findings.push(R("definition.field.undescribed", { field: t }));
|
|
94
94
|
}
|
|
95
|
-
let
|
|
96
|
-
name:
|
|
97
|
-
label:
|
|
95
|
+
let a = {
|
|
96
|
+
name: e,
|
|
97
|
+
label: t.label ?? e,
|
|
98
98
|
kind: "search",
|
|
99
|
-
searchFields:
|
|
99
|
+
searchFields: i.fields
|
|
100
100
|
};
|
|
101
|
-
return
|
|
102
|
-
field:
|
|
101
|
+
return i.mode && (a.searchMode = i.mode), {
|
|
102
|
+
field: a,
|
|
103
103
|
described: null,
|
|
104
|
-
spec:
|
|
104
|
+
spec: t,
|
|
105
105
|
sensitive: !1
|
|
106
106
|
};
|
|
107
107
|
}
|
|
@@ -113,7 +113,7 @@ function Ie(e, t, n) {
|
|
|
113
113
|
if (a?.element === n) return a.values.flatMap((e) => e.fields).find((e) => e.path === i || (e.aliases ?? []).includes(i));
|
|
114
114
|
}
|
|
115
115
|
function Le(e, t) {
|
|
116
|
-
let n =
|
|
116
|
+
let n = j(e, t), r = n[0];
|
|
117
117
|
if (r) return {
|
|
118
118
|
types: [...new Set(n.flatMap((e) => e.types))],
|
|
119
119
|
kind: r.kind
|
|
@@ -121,26 +121,26 @@ function Le(e, t) {
|
|
|
121
121
|
}
|
|
122
122
|
function Re(e) {
|
|
123
123
|
let t = e.semantic;
|
|
124
|
-
if (t?.type ===
|
|
125
|
-
if (t?.type ===
|
|
124
|
+
if (t?.type === N.TEMPORAL_DATE) return { type: "date" };
|
|
125
|
+
if (t?.type === N.TEMPORAL_EPOCH && t.timeUnit === je.SECONDS) return {
|
|
126
126
|
type: "epoch",
|
|
127
|
-
timeUnit:
|
|
127
|
+
timeUnit: h.SECONDS
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
function ze(e, t, n) {
|
|
131
131
|
if (n.elements) return "elementMatch";
|
|
132
|
-
if (!t.enum && e?.types?.length === 1 && e.types[0] ===
|
|
132
|
+
if (!t.enum && e?.types?.length === 1 && e.types[0] === x.BOOLEAN) return "boolean";
|
|
133
133
|
if (t.enum || n.options) return "enum";
|
|
134
134
|
let r = t.semantic?.type;
|
|
135
|
-
if (r ===
|
|
136
|
-
if (r ===
|
|
135
|
+
if (r === N.TEMPORAL_DATE) return "date";
|
|
136
|
+
if (r === N.TEMPORAL_EPOCH || r === N.TEMPORAL_FORMATTED) return "datetime";
|
|
137
137
|
let i = e?.types ?? [];
|
|
138
138
|
if (i.length !== 1) return null;
|
|
139
139
|
switch (i[0]) {
|
|
140
|
-
case
|
|
141
|
-
case
|
|
142
|
-
case
|
|
143
|
-
case
|
|
140
|
+
case x.BOOLEAN: return "boolean";
|
|
141
|
+
case x.INTEGER:
|
|
142
|
+
case x.DECIMAL: return "number";
|
|
143
|
+
case x.STRING: return "string";
|
|
144
144
|
default: return null;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -149,7 +149,7 @@ function Be(e, t, n, r) {
|
|
|
149
149
|
}
|
|
150
150
|
function Ve(e, t, n) {
|
|
151
151
|
let r = new Set(t.operators);
|
|
152
|
-
return e.elements.some((e) => e.path === n && e.filter) && r.add(
|
|
152
|
+
return e.elements.some((e) => e.path === n && e.filter) && r.add(ie.ELEMENT_MATCH), r;
|
|
153
153
|
}
|
|
154
154
|
function He(e, t, n, r) {
|
|
155
155
|
let i = Ue(e.options), a = t.enum;
|
|
@@ -181,31 +181,31 @@ function B(e, t) {
|
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
183
|
// src/runtime/define/defineView.ts
|
|
184
|
-
function V(
|
|
185
|
-
let
|
|
186
|
-
descriptor:
|
|
187
|
-
paging:
|
|
188
|
-
findings:
|
|
189
|
-
}),
|
|
190
|
-
id:
|
|
191
|
-
title:
|
|
184
|
+
function V(t, n, r = {}) {
|
|
185
|
+
let i = [], a = We(n, t, i), o = z(n.fields, void 0, {
|
|
186
|
+
descriptor: t,
|
|
187
|
+
paging: a?.paging ?? "paged",
|
|
188
|
+
findings: i
|
|
189
|
+
}), s = {
|
|
190
|
+
id: n.id,
|
|
191
|
+
title: n.title,
|
|
192
192
|
kind: "data",
|
|
193
|
-
source:
|
|
194
|
-
fields:
|
|
193
|
+
source: n.source,
|
|
194
|
+
fields: o.map((e) => e.field)
|
|
195
195
|
};
|
|
196
|
-
|
|
197
|
-
let
|
|
198
|
-
|
|
199
|
-
let
|
|
200
|
-
return
|
|
201
|
-
version:
|
|
202
|
-
findings:
|
|
196
|
+
n.recordNoun !== void 0 && (s.recordNoun = n.recordNoun), n.fieldGroups && (s.fieldGroups = n.fieldGroups), a && (s.record = a);
|
|
197
|
+
let c = Me(n.analysis, o), u = Ne(c, o, t, i);
|
|
198
|
+
u && e(u) && (s.analysis = u), n.timeField !== void 0 && (s.timeField = n.timeField), n.views && (s.views = n.views);
|
|
199
|
+
let d = o.flatMap(({ field: e, spec: t, described: n }) => n && t.sortable !== !1 ? [e.name] : []), f = H(o);
|
|
200
|
+
return s.fields = U(s.fields, ne(s, t, r.kinds ?? l).definition.fields, new Set(f)), s.described = {
|
|
201
|
+
version: t.version,
|
|
202
|
+
findings: i,
|
|
203
203
|
open: {
|
|
204
|
-
sort:
|
|
205
|
-
operators:
|
|
206
|
-
...
|
|
204
|
+
sort: d,
|
|
205
|
+
operators: f,
|
|
206
|
+
...c ? { analysis: c } : {}
|
|
207
207
|
}
|
|
208
|
-
},
|
|
208
|
+
}, s;
|
|
209
209
|
}
|
|
210
210
|
function H(e, t) {
|
|
211
211
|
return e.flatMap(({ field: e, spec: n, children: r }) => {
|
|
@@ -226,13 +226,13 @@ function U(e, t, n, r) {
|
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
228
|
var W = {
|
|
229
|
-
[
|
|
230
|
-
[
|
|
229
|
+
[b.PAGED]: "paged",
|
|
230
|
+
[b.CURSOR]: "cursor"
|
|
231
231
|
};
|
|
232
232
|
function We(e, t, n) {
|
|
233
233
|
if (e.record === !1) return;
|
|
234
234
|
let r = e.record ?? {}, i = t.record.paging.flatMap((e) => W[e] ? [W[e]] : []), a = r.paging ?? (i.includes("paged") ? "paged" : "cursor");
|
|
235
|
-
return i.includes(a) || n.push(
|
|
235
|
+
return i.includes(a) || n.push(f("definition.record.paging-wider", ["record", "paging"], { paging: a }, "warning")), {
|
|
236
236
|
...r,
|
|
237
237
|
rowKey: r.rowKey ?? t.record.identity,
|
|
238
238
|
paging: a,
|
|
@@ -444,7 +444,7 @@ function q() {
|
|
|
444
444
|
// src/store/MemoryViewStore.ts
|
|
445
445
|
var Ze = 100, Qe = class {
|
|
446
446
|
constructor(e = {}) {
|
|
447
|
-
this.instances = /* @__PURE__ */ new Map(), this.preferences = /* @__PURE__ */ new Map(), this.outcomes = /* @__PURE__ */ new Map(), this.preferenceOutcomes = /* @__PURE__ */ new Map(), this.sequence = 0, e.permissions && (this.permissions = e.permissions), this.pageSize = e.pageSize ?? Ze, this.snapshot = e.snapshot;
|
|
447
|
+
this.instances = /* @__PURE__ */ new Map(), this.preferences = /* @__PURE__ */ new Map(), this.outcomes = /* @__PURE__ */ new Map(), this.preferenceOutcomes = /* @__PURE__ */ new Map(), this.sequence = 0, e.permissions && (this.permissions = e.permissions), e.local && (this.local = !0), this.pageSize = e.pageSize ?? Ze, this.snapshot = e.snapshot;
|
|
448
448
|
let t = e.snapshot?.load();
|
|
449
449
|
this.restore({
|
|
450
450
|
instances: t?.instances ?? e.instances ?? [],
|
|
@@ -452,7 +452,7 @@ var Ze = 100, Qe = class {
|
|
|
452
452
|
}), e.snapshot?.subscribe?.(() => this.reload());
|
|
453
453
|
}
|
|
454
454
|
list(e, t = {}) {
|
|
455
|
-
let n = [...this.instances.values()].filter((t) => t.definitionId === e).map(
|
|
455
|
+
let n = [...this.instances.values()].filter((t) => t.definitionId === e).map(he).sort((e, t) => Y[e.scope] - Y[t.scope]), r = t.cursor ? Number(t.cursor) : 0, i = r + this.pageSize;
|
|
456
456
|
return Promise.resolve({
|
|
457
457
|
items: n.slice(r, i),
|
|
458
458
|
nextCursor: i < n.length ? String(i) : null
|
|
@@ -460,29 +460,29 @@ var Ze = 100, Qe = class {
|
|
|
460
460
|
}
|
|
461
461
|
get(e) {
|
|
462
462
|
let t = this.instances.get(e);
|
|
463
|
-
return t ? Promise.resolve($(t)) : Promise.reject(new
|
|
463
|
+
return t ? Promise.resolve($(t)) : Promise.reject(new S("NOT_FOUND", `No such view: ${e}`));
|
|
464
464
|
}
|
|
465
|
-
create(e,
|
|
466
|
-
let
|
|
467
|
-
if (
|
|
468
|
-
let
|
|
469
|
-
if (
|
|
465
|
+
create(e, t) {
|
|
466
|
+
let n = this.outcomes.get(t.requestId);
|
|
467
|
+
if (n) return Promise.resolve($(n));
|
|
468
|
+
let r = Z(e.title) ?? Q(e.config);
|
|
469
|
+
if (r) return Promise.reject(r);
|
|
470
470
|
this.reload();
|
|
471
|
-
let
|
|
471
|
+
let i;
|
|
472
472
|
do
|
|
473
|
-
this.sequence += 1,
|
|
474
|
-
while (this.instances.has(
|
|
475
|
-
if (
|
|
476
|
-
let
|
|
477
|
-
delete
|
|
478
|
-
let
|
|
479
|
-
...
|
|
473
|
+
this.sequence += 1, i = `${e.definitionId}-${this.sequence}`;
|
|
474
|
+
while (this.instances.has(i));
|
|
475
|
+
if (k(i)) return Promise.reject(new S("INVALID", `Reserved id namespace: ${i}`));
|
|
476
|
+
let a = $(e);
|
|
477
|
+
delete a.stored;
|
|
478
|
+
let o = {
|
|
479
|
+
...a,
|
|
480
480
|
title: e.title.trim(),
|
|
481
|
-
id:
|
|
481
|
+
id: i,
|
|
482
482
|
revision: "1",
|
|
483
|
-
...
|
|
483
|
+
...T(e.scope) ? { stored: !0 } : {}
|
|
484
484
|
};
|
|
485
|
-
return this.instances.set(
|
|
485
|
+
return this.instances.set(i, o), this.commit(t, o, () => this.instances.delete(i));
|
|
486
486
|
}
|
|
487
487
|
save(e, t, n, r) {
|
|
488
488
|
return this.update(e, n, r, (e) => ({
|
|
@@ -496,17 +496,17 @@ var Ze = 100, Qe = class {
|
|
|
496
496
|
title: t.trim()
|
|
497
497
|
}), Z(t));
|
|
498
498
|
}
|
|
499
|
-
changeAudience(e, n, r
|
|
500
|
-
return this.update(e,
|
|
501
|
-
if (
|
|
502
|
-
if (
|
|
503
|
-
if (
|
|
499
|
+
changeAudience(e, t, n, r) {
|
|
500
|
+
return this.update(e, n, r, (n) => {
|
|
501
|
+
if (T(n.scope)) return new S("FORBIDDEN", "System views stay system");
|
|
502
|
+
if (v(n.scope) === t) return null;
|
|
503
|
+
if (t === "personal") {
|
|
504
504
|
let t = this.sharedBoardsShowing(e);
|
|
505
|
-
if (t.length > 0) return new
|
|
505
|
+
if (t.length > 0) return new S("INVALID", `Shared dashboards show view ${e}: ${t.join(", ")}`, { boards: t });
|
|
506
506
|
}
|
|
507
507
|
return {
|
|
508
|
-
...
|
|
509
|
-
scope:
|
|
508
|
+
...n,
|
|
509
|
+
scope: t
|
|
510
510
|
};
|
|
511
511
|
});
|
|
512
512
|
}
|
|
@@ -514,8 +514,8 @@ var Ze = 100, Qe = class {
|
|
|
514
514
|
if (this.outcomes.has(n.requestId)) return Promise.resolve();
|
|
515
515
|
this.reload();
|
|
516
516
|
let r = this.instances.get(e);
|
|
517
|
-
if (!r) return Promise.reject(new
|
|
518
|
-
if (J(r)) return Promise.reject(new
|
|
517
|
+
if (!r) return Promise.reject(new S("NOT_FOUND", `No such view: ${e}`));
|
|
518
|
+
if (J(r)) return Promise.reject(new S("FORBIDDEN", "System views are read-only"));
|
|
519
519
|
let i = this.expect(r, t);
|
|
520
520
|
if (i) return Promise.reject(i);
|
|
521
521
|
this.instances.delete(e);
|
|
@@ -530,7 +530,7 @@ var Ze = 100, Qe = class {
|
|
|
530
530
|
if (r) return Promise.resolve(r);
|
|
531
531
|
this.reload();
|
|
532
532
|
let i = this.preferences.get(e), a = i ?? q();
|
|
533
|
-
if (a.revision !== t.revision) return Promise.reject(new
|
|
533
|
+
if (a.revision !== t.revision) return Promise.reject(new S("CONFLICT", `Preferences for ${e} changed`, { preferences: a }));
|
|
534
534
|
let o = {
|
|
535
535
|
...t,
|
|
536
536
|
revision: X(a.revision)
|
|
@@ -545,12 +545,12 @@ var Ze = 100, Qe = class {
|
|
|
545
545
|
if (i) return Promise.reject(i);
|
|
546
546
|
this.reload();
|
|
547
547
|
let o = this.instances.get(e);
|
|
548
|
-
if (!o) return Promise.reject(new
|
|
549
|
-
if (J(o)) return Promise.reject(new
|
|
548
|
+
if (!o) return Promise.reject(new S("NOT_FOUND", `No such view: ${e}`));
|
|
549
|
+
if (J(o)) return Promise.reject(new S("FORBIDDEN", "System views are read-only"));
|
|
550
550
|
let s = this.expect(o, t);
|
|
551
551
|
if (s) return Promise.reject(s);
|
|
552
552
|
let c = r(o);
|
|
553
|
-
if (c instanceof
|
|
553
|
+
if (c instanceof S) return Promise.reject(c);
|
|
554
554
|
if (c === null) return this.outcomes.set(n.requestId, o), Promise.resolve($(o));
|
|
555
555
|
let l = {
|
|
556
556
|
...c,
|
|
@@ -562,14 +562,14 @@ var Ze = 100, Qe = class {
|
|
|
562
562
|
let t = [];
|
|
563
563
|
for (let n of this.instances.values()) {
|
|
564
564
|
let { config: r } = n;
|
|
565
|
-
if (r.kind !== "dashboard" ||
|
|
565
|
+
if (r.kind !== "dashboard" || v(n.scope) !== "shared") continue;
|
|
566
566
|
let i = r.panels;
|
|
567
567
|
Array.isArray(i) && i.some((t) => $e(t, e)) && t.push(n.title);
|
|
568
568
|
}
|
|
569
569
|
return t;
|
|
570
570
|
}
|
|
571
571
|
expect(e, t) {
|
|
572
|
-
return e.revision === t ? void 0 : new
|
|
572
|
+
return e.revision === t ? void 0 : new S("CONFLICT", `View ${e.id} moved to revision ${e.revision}`, { instance: e });
|
|
573
573
|
}
|
|
574
574
|
commit(e, t, n) {
|
|
575
575
|
let r = this.persist(n);
|
|
@@ -583,7 +583,7 @@ var Ze = 100, Qe = class {
|
|
|
583
583
|
});
|
|
584
584
|
return;
|
|
585
585
|
} catch (t) {
|
|
586
|
-
return e(), new
|
|
586
|
+
return e(), new S("UNAVAILABLE", `The view store could not keep this write: ${et(t)}`, { storage: !0 });
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
589
|
reload() {
|
|
@@ -602,7 +602,7 @@ function $e(e, t) {
|
|
|
602
602
|
return r === void 0 && n === t || i === t || typeof a == "object" && !!a && a.instanceId === t;
|
|
603
603
|
}
|
|
604
604
|
function J(e) {
|
|
605
|
-
return
|
|
605
|
+
return T(e.scope) && e.stored !== !0;
|
|
606
606
|
}
|
|
607
607
|
var Y = {
|
|
608
608
|
system: 0,
|
|
@@ -613,15 +613,15 @@ function X(e) {
|
|
|
613
613
|
return /^(0|[1-9]\d{0,14})$/.test(e) ? String(Number(e) + 1) : "1";
|
|
614
614
|
}
|
|
615
615
|
function Z(e) {
|
|
616
|
-
switch (
|
|
617
|
-
case "empty": return new
|
|
618
|
-
case "too-long": return new
|
|
616
|
+
switch (A(e)) {
|
|
617
|
+
case "empty": return new S("INVALID", "A view's title must not be blank.");
|
|
618
|
+
case "too-long": return new S("INVALID", "A view's title is longer than 120 characters.");
|
|
619
619
|
default: return;
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
function Q(e) {
|
|
623
|
-
let
|
|
624
|
-
return
|
|
623
|
+
let n = t(e);
|
|
624
|
+
return n > 245760 ? new S("INVALID", `A view's config is ${n} bytes; the limit is ${w}.`) : void 0;
|
|
625
625
|
}
|
|
626
626
|
function et(e) {
|
|
627
627
|
if (typeof e == "object" && e) {
|
|
@@ -633,6 +633,6 @@ function et(e) {
|
|
|
633
633
|
function $(e) {
|
|
634
634
|
return structuredClone(e);
|
|
635
635
|
}
|
|
636
|
-
export {
|
|
636
|
+
export { ge as BUILTIN_FIELD_KINDS, d as CHART_TYPES, we as DEFAULT_MISSING_KEY, u as DEFAULT_RUNTIME_LIMITS, Ge as DatasetResources, n as EDITOR_INPUTS, De as ExportCancelledError, w as MAX_VIEW_CONFIG_BYTES, te as MAX_VIEW_TITLE_LENGTH, Qe as MemoryViewStore, ve as ReferenceLabelTimeoutError, c as VIEW_STORE_ERROR_CODES, i as ViewCommandError, ye as ViewEngine, S as ViewStoreError, r as ViewWriteError, O as actions, l as builtinFieldKinds, m as compileAnalysis, P as compileFilter, s as compileRecord, ue as createFieldKindRegistry, L as defaultAnalysisConfig, Ee as defaultRecordConfig, ke as defaultRuntimeEnvironment, G as defineDataset, V as defineView, _e as emptyDashboardConfig, q as emptyPreferences, Se as fitChartSlots, Oe as hasAsked, xe as hasResult, I as inRows, Te as isAnalysisRuntime, se as isDateTimeFilterValue, be as isExportCancelledError, Ce as isRecordRuntime, k as isSystemInstanceId, p as isViewCommandError, o as isViewStoreError, de as isViewWriteError, f as issue, Ke as localStorageSnapshot, oe as projectAnalysis, g as projectRecord, ae as resolveDateTimeRange, Ae as serializeCsv, pe as systemInstanceId, y as text, F as textKeyOf, D as validateAnalysis, le as validateDashboard, M as validateDefinition, re as validateFilter, fe as validateRecord, a as withFieldKinds, ee as withText };
|
|
637
637
|
|
|
638
638
|
//# sourceMappingURL=index.js.map
|