@elaraai/e3-ui-components 1.0.83 → 1.0.85
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 +113 -6
- package/dist/components/DataTaskPreview.d.ts +35 -1
- package/dist/components/DataTaskPreview.d.ts.map +1 -1
- package/dist/components/DatasetPreview.d.ts +16 -0
- package/dist/components/DatasetPreview.d.ts.map +1 -1
- package/dist/components/InputPreview.d.ts +12 -0
- package/dist/components/InputPreview.d.ts.map +1 -1
- package/dist/components/PagedDatasetPreview.d.ts +15 -0
- package/dist/components/PagedDatasetPreview.d.ts.map +1 -1
- package/dist/components/TaskLogs.d.ts +19 -0
- package/dist/components/TaskLogs.d.ts.map +1 -1
- package/dist/components/TaskPreview.d.ts +24 -0
- package/dist/components/TaskPreview.d.ts.map +1 -1
- package/dist/components/UITaskPreview.d.ts +4 -1
- package/dist/components/UITaskPreview.d.ts.map +1 -1
- package/dist/components/VirtualizedLogViewer.d.ts +29 -1
- package/dist/components/VirtualizedLogViewer.d.ts.map +1 -1
- package/dist/components/controlled-search.d.ts +22 -0
- package/dist/components/controlled-search.d.ts.map +1 -0
- package/dist/components/preview-controls.d.ts +73 -0
- package/dist/components/preview-controls.d.ts.map +1 -0
- package/dist/diff/index.d.ts.map +1 -1
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/hooks/executions.d.ts +17 -0
- package/dist/hooks/executions.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useDatasetValue.d.ts +19 -1
- package/dist/hooks/useDatasetValue.d.ts.map +1 -1
- package/dist/hooks/useTaskLogsHook.d.ts +67 -3
- package/dist/hooks/useTaskLogsHook.d.ts.map +1 -1
- package/dist/in-memory-call-7_3frW52.js +615 -0
- package/dist/in-memory-call-7_3frW52.js.map +1 -0
- package/dist/in-memory-call-_r5DJotS.cjs +614 -0
- package/dist/in-memory-call-_r5DJotS.cjs.map +1 -0
- package/dist/index.cjs +25860 -5731
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28383 -8253
- package/dist/index.js.map +1 -1
- package/dist/platform/bind-runtime.d.ts +18 -3
- package/dist/platform/bind-runtime.d.ts.map +1 -1
- package/dist/platform/dataset-hooks.d.ts +15 -3
- package/dist/platform/dataset-hooks.d.ts.map +1 -1
- package/dist/platform/dataset-store.d.ts +35 -7
- package/dist/platform/dataset-store.d.ts.map +1 -1
- package/dist/platform/e3-config.d.ts +26 -2
- package/dist/platform/e3-config.d.ts.map +1 -1
- package/dist/platform/func-runtime.d.ts +11 -5
- package/dist/platform/func-runtime.d.ts.map +1 -1
- package/dist/platform/index.d.ts +2 -2
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/paged-runtime.d.ts +46 -9
- package/dist/platform/paged-runtime.d.ts.map +1 -1
- package/dist/platform/record-runtime.d.ts +45 -7
- package/dist/platform/record-runtime.d.ts.map +1 -1
- package/dist/platform/recovery.d.ts +44 -0
- package/dist/platform/recovery.d.ts.map +1 -0
- package/dist/platform/staged-store.d.ts +16 -0
- package/dist/platform/staged-store.d.ts.map +1 -1
- package/dist/platform/tracked-channel.d.ts +12 -0
- package/dist/platform/tracked-channel.d.ts.map +1 -1
- package/dist/query/about.d.ts +50 -0
- package/dist/query/about.d.ts.map +1 -0
- package/dist/query/autocomplete.d.ts +112 -0
- package/dist/query/autocomplete.d.ts.map +1 -0
- package/dist/query/builder.d.ts +29 -0
- package/dist/query/builder.d.ts.map +1 -0
- package/dist/query/calls.d.ts +46 -0
- package/dist/query/calls.d.ts.map +1 -0
- package/dist/query/datasets-tab.d.ts +52 -0
- package/dist/query/datasets-tab.d.ts.map +1 -0
- package/dist/query/downloads.d.ts +29 -0
- package/dist/query/downloads.d.ts.map +1 -0
- package/dist/query/drops.d.ts +28 -0
- package/dist/query/drops.d.ts.map +1 -0
- package/dist/query/foot.d.ts +22 -0
- package/dist/query/foot.d.ts.map +1 -0
- package/dist/query/hooks.d.ts +265 -0
- package/dist/query/hooks.d.ts.map +1 -0
- package/dist/query/in-memory-call.d.ts +150 -0
- package/dist/query/in-memory-call.d.ts.map +1 -0
- package/dist/query/jq-editor.d.ts +34 -0
- package/dist/query/jq-editor.d.ts.map +1 -0
- package/dist/query/library-tab.d.ts +33 -0
- package/dist/query/library-tab.d.ts.map +1 -0
- package/dist/query/library.d.ts +20 -0
- package/dist/query/library.d.ts.map +1 -0
- package/dist/query/model/cards.d.ts +179 -0
- package/dist/query/model/cards.d.ts.map +1 -0
- package/dist/query/model/index.d.ts +19 -0
- package/dist/query/model/index.d.ts.map +1 -0
- package/dist/query/model/messages.d.ts +1253 -0
- package/dist/query/model/messages.d.ts.map +1 -0
- package/dist/query/model/refs.d.ts +92 -0
- package/dist/query/model/refs.d.ts.map +1 -0
- package/dist/query/model/slots.d.ts +213 -0
- package/dist/query/model/slots.d.ts.map +1 -0
- package/dist/query/model/summaries.d.ts +104 -0
- package/dist/query/model/summaries.d.ts.map +1 -0
- package/dist/query/model/words.d.ts +331 -0
- package/dist/query/model/words.d.ts.map +1 -0
- package/dist/query/one-shot.d.ts +266 -0
- package/dist/query/one-shot.d.ts.map +1 -0
- package/dist/query/open-query.d.ts +214 -0
- package/dist/query/open-query.d.ts.map +1 -0
- package/dist/query/parts.d.ts +115 -0
- package/dist/query/parts.d.ts.map +1 -0
- package/dist/query/plan-popover.d.ts +22 -0
- package/dist/query/plan-popover.d.ts.map +1 -0
- package/dist/query/plan.d.ts +353 -0
- package/dist/query/plan.d.ts.map +1 -0
- package/dist/query/query-east.d.ts +21 -0
- package/dist/query/query-east.d.ts.map +1 -0
- package/dist/query/query-tab.d.ts +21 -0
- package/dist/query/query-tab.d.ts.map +1 -0
- package/dist/query/results-table.d.ts +153 -0
- package/dist/query/results-table.d.ts.map +1 -0
- package/dist/query/results.d.ts +137 -0
- package/dist/query/results.d.ts.map +1 -0
- package/dist/query/run.d.ts +199 -0
- package/dist/query/run.d.ts.map +1 -0
- package/dist/query/save-popover.d.ts +29 -0
- package/dist/query/save-popover.d.ts.map +1 -0
- package/dist/query/session.d.ts +409 -0
- package/dist/query/session.d.ts.map +1 -0
- package/dist/query/shape-line.d.ts +21 -0
- package/dist/query/shape-line.d.ts.map +1 -0
- package/dist/query/source.d.ts +21 -0
- package/dist/query/source.d.ts.map +1 -0
- package/dist/query/status-line.d.ts +48 -0
- package/dist/query/status-line.d.ts.map +1 -0
- package/dist/query/step-card.d.ts +30 -0
- package/dist/query/step-card.d.ts.map +1 -0
- package/dist/query/steps/check.d.ts +162 -0
- package/dist/query/steps/check.d.ts.map +1 -0
- package/dist/query/steps/count.d.ts +49 -0
- package/dist/query/steps/count.d.ts.map +1 -0
- package/dist/query/steps/edit.d.ts +108 -0
- package/dist/query/steps/edit.d.ts.map +1 -0
- package/dist/query/steps/fields.d.ts +101 -0
- package/dist/query/steps/fields.d.ts.map +1 -0
- package/dist/query/steps/index.d.ts +22 -0
- package/dist/query/steps/index.d.ts.map +1 -0
- package/dist/query/steps/jq.d.ts +188 -0
- package/dist/query/steps/jq.d.ts.map +1 -0
- package/dist/query/steps/parse.d.ts +38 -0
- package/dist/query/steps/parse.d.ts.map +1 -0
- package/dist/query/steps/print.d.ts +195 -0
- package/dist/query/steps/print.d.ts.map +1 -0
- package/dist/query/steps/shape.d.ts +90 -0
- package/dist/query/steps/shape.d.ts.map +1 -0
- package/dist/query/steps/values.d.ts +85 -0
- package/dist/query/steps/values.d.ts.map +1 -0
- package/dist/query/toolbar.d.ts +56 -0
- package/dist/query/toolbar.d.ts.map +1 -0
- package/dist/query/use-query-editor.d.ts +153 -0
- package/dist/query/use-query-editor.d.ts.map +1 -0
- package/dist/query/use-query-session.d.ts +55 -0
- package/dist/query/use-query-session.d.ts.map +1 -0
- package/dist/query/words.d.ts +60 -0
- package/dist/query/words.d.ts.map +1 -0
- package/dist/query.cjs +16 -0
- package/dist/query.cjs.map +1 -0
- package/dist/query.js +16 -0
- package/dist/query.js.map +1 -0
- package/dist/shared/name-popover.d.ts +38 -0
- package/dist/shared/name-popover.d.ts.map +1 -0
- package/dist/studio/builder.d.ts +20 -0
- package/dist/studio/builder.d.ts.map +1 -0
- package/dist/studio/inspector.d.ts +18 -0
- package/dist/studio/inspector.d.ts.map +1 -0
- package/dist/studio/library.d.ts +20 -0
- package/dist/studio/library.d.ts.map +1 -0
- package/dist/studio/messages.d.ts +318 -0
- package/dist/studio/messages.d.ts.map +1 -0
- package/dist/studio/open-page.d.ts +13 -0
- package/dist/studio/open-page.d.ts.map +1 -0
- package/dist/studio/page.d.ts +61 -0
- package/dist/studio/page.d.ts.map +1 -0
- package/dist/studio/palette.d.ts +41 -0
- package/dist/studio/palette.d.ts.map +1 -0
- package/dist/studio/publish.d.ts +21 -0
- package/dist/studio/publish.d.ts.map +1 -0
- package/dist/studio/save-template.d.ts +18 -0
- package/dist/studio/save-template.d.ts.map +1 -0
- package/dist/studio/studio-east.d.ts +45 -0
- package/dist/studio/studio-east.d.ts.map +1 -0
- package/package.json +19 -14
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { CheckJqResult, JqPruning, JqRange, JqSplit, JqSplitCall, JqSplitStages, JqWholeReason } from '@elaraai/east';
|
|
2
|
+
import { ExecuteResult, SplitCallRequest } from '@elaraai/e3-types';
|
|
3
|
+
import { PreparedQuery, QueryOptions, QueryReading, QueryResult, QueryRoot } from './one-shot.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options for planning a run: a call's limits and runner, as a one-shot call's
|
|
6
|
+
* ({@link QueryOptions}), and the most a dataset may weigh and still be read
|
|
7
|
+
* by one call.
|
|
8
|
+
*/
|
|
9
|
+
export interface PlanOptions extends QueryOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The most a dataset may weigh, in stored bytes, and still be read by one
|
|
12
|
+
* call: e3's smallest piece, `PIECE_SIZES.min` (16 MiB), by default. A
|
|
13
|
+
* test against a server whose pieces are small sets it small too.
|
|
14
|
+
*/
|
|
15
|
+
readonly pieceBytes?: number;
|
|
16
|
+
}
|
|
17
|
+
/** What a data source weighs, as e3's status says: its stored bytes, and the rows of a stored collection. */
|
|
18
|
+
export interface SourceWeight {
|
|
19
|
+
/** What its value weighs in the store, in bytes — a collection's segments and its manifest; `undefined` when not known. */
|
|
20
|
+
readonly bytes: number | undefined;
|
|
21
|
+
/** How many elements a stored collection holds; `undefined` for a value that is not one, or when not known. */
|
|
22
|
+
readonly rows: number | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The programs a run plans from: the query, and what each kind of call runs
|
|
26
|
+
* of it.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* In the jq view all three are the jq. In the visual view a one-shot call runs
|
|
30
|
+
* the program that counts every stage's rows, and a split call runs the query
|
|
31
|
+
* itself — a rows result followed by `{counts: [length], result: .[:1000]}`,
|
|
32
|
+
* which the split runs once after the rows are joined — since a split run
|
|
33
|
+
* counts the source and the result only.
|
|
34
|
+
*/
|
|
35
|
+
export interface PlanPrograms {
|
|
36
|
+
/** The query as its author reads it: what the plan splits and explains. */
|
|
37
|
+
readonly query: string;
|
|
38
|
+
/** What a one-shot call runs: the query by default. */
|
|
39
|
+
readonly oneShot?: string;
|
|
40
|
+
/** What a split call runs: the query by default. */
|
|
41
|
+
readonly split?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Why a run reads its data in one call.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* - `whole`: the query runs as one unit, for east's reason (`JqWhole`).
|
|
48
|
+
* - `small`: it would split over a dataset that weighs no more than one piece.
|
|
49
|
+
* - `unweighed`: it would split over a dataset whose weight is not known.
|
|
50
|
+
* - `unsplit`: it would split, and the split call could not be made — what
|
|
51
|
+
* went wrong, so it shows rather than hides. `over` is `null` when the split
|
|
52
|
+
* itself failed.
|
|
53
|
+
*/
|
|
54
|
+
export type OneCallWhy = {
|
|
55
|
+
readonly kind: "whole";
|
|
56
|
+
readonly reason: JqWholeReason;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "small";
|
|
59
|
+
readonly over: string;
|
|
60
|
+
readonly bytes: number;
|
|
61
|
+
readonly pieceBytes: number;
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "unweighed";
|
|
64
|
+
readonly over: string;
|
|
65
|
+
} | {
|
|
66
|
+
readonly kind: "unsplit";
|
|
67
|
+
readonly over: string | null;
|
|
68
|
+
readonly message: string;
|
|
69
|
+
};
|
|
70
|
+
/** How a run reads its data, as its explanation says it. */
|
|
71
|
+
export type PlanPath =
|
|
72
|
+
/** One call, and why. */
|
|
73
|
+
{
|
|
74
|
+
readonly kind: "one_shot";
|
|
75
|
+
readonly why: OneCallWhy;
|
|
76
|
+
} | {
|
|
77
|
+
readonly kind: "split";
|
|
78
|
+
/** The dataset the pieces work through, by its data source's name. */
|
|
79
|
+
readonly over: string;
|
|
80
|
+
/** The dataset e3 cuts the pieces by, the heaviest of those partitioned: `over`, or one cut at the same keys with it. */
|
|
81
|
+
readonly heaviest: string;
|
|
82
|
+
/** What it weighs in the store, in bytes. */
|
|
83
|
+
readonly bytes: number;
|
|
84
|
+
/** The most a dataset may weigh and still be read by one call. */
|
|
85
|
+
readonly pieceBytes: number;
|
|
86
|
+
/** How the pieces' outputs combine: the split call's output kind. */
|
|
87
|
+
readonly output: JqSplitCall["output"]["kind"];
|
|
88
|
+
/** What runs where, as ranges of the query's text. */
|
|
89
|
+
readonly stages: JqSplitStages;
|
|
90
|
+
/** The data sources every piece reads whole. */
|
|
91
|
+
readonly broadcast: readonly string[];
|
|
92
|
+
/** The data sources partitioned with `over`, each piece holding the same keys of them (#942). */
|
|
93
|
+
readonly copartitioned: readonly string[];
|
|
94
|
+
/**
|
|
95
|
+
* A re-keyed join (#942): `over`'s rows re-keyed first by the join key,
|
|
96
|
+
* the jq of it, then joined with `name` cut at the same keys; `bytes`
|
|
97
|
+
* what the re-keyed rows are estimated to weigh, from `over`'s manifest.
|
|
98
|
+
* `null` when the join, if any, reads its other side whole.
|
|
99
|
+
*/
|
|
100
|
+
readonly rekey: {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly key: JqRange;
|
|
103
|
+
readonly bytes: number;
|
|
104
|
+
} | null;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* A plan's explanation, as data: the builder's words say it (`planWords`),
|
|
108
|
+
* beside the run's read-outs.
|
|
109
|
+
*/
|
|
110
|
+
export interface PlanExplanation {
|
|
111
|
+
/** The query's text: every range of the explanation is of it. */
|
|
112
|
+
readonly program: string;
|
|
113
|
+
/** The path, and why. */
|
|
114
|
+
readonly path: PlanPath;
|
|
115
|
+
/** The reads that skip what they don't need: a count from the index, a key seek, a stream that stops. */
|
|
116
|
+
readonly pruning: readonly JqPruning[];
|
|
117
|
+
}
|
|
118
|
+
/** A run's plan: the call it makes, what reading the call's answer needs, and its explanation. */
|
|
119
|
+
export type QueryPlan =
|
|
120
|
+
/** One one-shot call, which e3-api-client's `oneShotExecute` sends. */
|
|
121
|
+
{
|
|
122
|
+
readonly kind: "one_shot";
|
|
123
|
+
readonly prepared: PreparedQuery;
|
|
124
|
+
readonly explanation: PlanExplanation;
|
|
125
|
+
}
|
|
126
|
+
/** A split call, which e3-api-client's `splitCall` launches and polls; its answer is read as a one-shot call's. */
|
|
127
|
+
| {
|
|
128
|
+
readonly kind: "split";
|
|
129
|
+
readonly request: SplitCallRequest;
|
|
130
|
+
readonly reading: QueryReading;
|
|
131
|
+
readonly explanation: PlanExplanation;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A re-keyed join (#942): two split calls, the second over the first's
|
|
135
|
+
* output by its hash; the second's answer, with what the first read
|
|
136
|
+
* ({@link RekeyCalls.answer}), is read as a one-shot call's.
|
|
137
|
+
*/
|
|
138
|
+
| ({
|
|
139
|
+
readonly kind: "rekey";
|
|
140
|
+
readonly reading: QueryReading;
|
|
141
|
+
readonly explanation: PlanExplanation;
|
|
142
|
+
} & RekeyCalls);
|
|
143
|
+
/** A re-keyed join's two split calls ({@link rekeyCallRequests}), and how their answers make the run's. */
|
|
144
|
+
export interface RekeyCalls {
|
|
145
|
+
/** The re-key call: the dataset's rows, each under its join key, its output read by its hash, never inline. */
|
|
146
|
+
readonly first: SplitCallRequest;
|
|
147
|
+
/**
|
|
148
|
+
* The join call, over the re-key call's output.
|
|
149
|
+
*
|
|
150
|
+
* @param output - the hash of the re-key call's output, as its completed status gives it
|
|
151
|
+
* @returns the request
|
|
152
|
+
*/
|
|
153
|
+
join(output: string): SplitCallRequest;
|
|
154
|
+
/**
|
|
155
|
+
* The run's answer: the join call's, or the re-key call's when it gave no
|
|
156
|
+
* output to join, with every dataset the run read — the re-key call's
|
|
157
|
+
* dataset, pinned as it pinned it, then the join call's — in the order
|
|
158
|
+
* the reading's entries name them.
|
|
159
|
+
*
|
|
160
|
+
* @param first - the re-key call's result
|
|
161
|
+
* @param join - the join call's result; `undefined` when the re-key call gave no output
|
|
162
|
+
* @returns the run's answer
|
|
163
|
+
*/
|
|
164
|
+
answer(first: ExecuteResult, join: ExecuteResult | undefined): ExecuteResult;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A query checked and split, waiting to be weighed ({@link weighPlan}): the
|
|
168
|
+
* first half of a plan, which says which data source's weight decides it.
|
|
169
|
+
*/
|
|
170
|
+
export interface PlanDraft {
|
|
171
|
+
/** The data sources the query reads, in the order it first reads them: what a run says it reads. */
|
|
172
|
+
readonly reads: readonly string[];
|
|
173
|
+
/** The data source a split call would cut, whose weight decides the path; `undefined` when the query runs as one unit. */
|
|
174
|
+
readonly over: string | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* The data sources whose weights decide the path: `over`, those cut at the
|
|
177
|
+
* same keys with it, and the other side of a join it could re-key (#942);
|
|
178
|
+
* none when the query runs as one unit.
|
|
179
|
+
*/
|
|
180
|
+
readonly weighs: readonly string[];
|
|
181
|
+
/** The programs, each given. @internal */
|
|
182
|
+
readonly programs: Required<PlanPrograms>;
|
|
183
|
+
/** The root. @internal */
|
|
184
|
+
readonly root: QueryRoot;
|
|
185
|
+
/** The options. @internal */
|
|
186
|
+
readonly options: PlanOptions;
|
|
187
|
+
/** What the checker made of the query. @internal */
|
|
188
|
+
readonly checked: CheckJqResult;
|
|
189
|
+
/** How the query splits, or why it does not; or what went wrong splitting it. @internal */
|
|
190
|
+
readonly split: JqSplit | {
|
|
191
|
+
readonly kind: "failed";
|
|
192
|
+
readonly message: string;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Checks and splits a query: the first half of a plan, which says the data
|
|
197
|
+
* source whose weight decides the path ({@link PlanDraft.over}).
|
|
198
|
+
*
|
|
199
|
+
* @param programs - the query, and what each kind of call runs of it; a
|
|
200
|
+
* string is all three
|
|
201
|
+
* @param root - the root its data sources make
|
|
202
|
+
* @param options - a call's limits and runner, and `pieceBytes`
|
|
203
|
+
* @returns the draft; or, for a query that does not check, the `error` result
|
|
204
|
+
* a run of it gives, as {@link prepareQuery} gives it
|
|
205
|
+
* @throws {RangeError} When a limit, or `pieceBytes`, is not a whole number.
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* The query is checked once, against the whole root, as a one-shot call's is.
|
|
209
|
+
* A `many` query is split with the call's most outputs, so its final function
|
|
210
|
+
* keeps as many as the one-shot translation does, and one more. A split that
|
|
211
|
+
* fails — a gap in the splitter, never a mistake in the query — leaves the
|
|
212
|
+
* query one call, the failure in its explanation.
|
|
213
|
+
*/
|
|
214
|
+
export declare function draftPlan(programs: PlanPrograms | string, root: QueryRoot, options?: PlanOptions): {
|
|
215
|
+
draft: PlanDraft;
|
|
216
|
+
} | {
|
|
217
|
+
result: QueryResult;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Weighs a draft: the path, by what its datasets weigh, and the call it makes.
|
|
221
|
+
*
|
|
222
|
+
* @param draft - the query, checked and split ({@link draftPlan})
|
|
223
|
+
* @param weights - what the data sources whose weights decide the path
|
|
224
|
+
* weigh ({@link PlanDraft.weighs}), by name; one not given is not known
|
|
225
|
+
* @returns the plan; or, for a one-shot program that does not check, the
|
|
226
|
+
* `error` result a run of it gives
|
|
227
|
+
* @throws {TranslationError} When a checked program holds something the
|
|
228
|
+
* translator cannot express.
|
|
229
|
+
*
|
|
230
|
+
* @remarks
|
|
231
|
+
* A query that runs as one unit is one call. One that splits is a split call
|
|
232
|
+
* when the datasets it cuts weigh more than `pieceBytes` — the heaviest of
|
|
233
|
+
* them, which e3 cuts the pieces by, when others are cut at the same keys —
|
|
234
|
+
* and one call when they weigh no more, or a weight is not known. A join
|
|
235
|
+
* whose other side weighs more than `pieceBytes` too is re-keyed (#942),
|
|
236
|
+
* rather than read whole by every piece: both sides large and unaligned. A
|
|
237
|
+
* split call's request is built from the split program — in the visual view,
|
|
238
|
+
* the query wrapped to count its rows — which must split as the query does:
|
|
239
|
+
* over the same dataset, into the same output kind, cut at the same keys with
|
|
240
|
+
* the same datasets and re-keying the same join; one that cannot be built is
|
|
241
|
+
* one call, and its explanation says why.
|
|
242
|
+
*/
|
|
243
|
+
export declare function weighPlan(draft: PlanDraft, weights: ReadonlyMap<string, SourceWeight>): {
|
|
244
|
+
plan: QueryPlan;
|
|
245
|
+
} | {
|
|
246
|
+
result: QueryResult;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Plans a run: checks and splits the query, and weighs it — {@link draftPlan},
|
|
250
|
+
* then {@link weighPlan} with the weights of the datasets that decide it.
|
|
251
|
+
*
|
|
252
|
+
* @param programs - the query, and what each kind of call runs of it; a
|
|
253
|
+
* string is all three
|
|
254
|
+
* @param root - the root its data sources make
|
|
255
|
+
* @param weights - what each data source weighs, by name; one not given is
|
|
256
|
+
* not known
|
|
257
|
+
* @param options - a call's limits and runner, and `pieceBytes`
|
|
258
|
+
* @returns the plan: one call, a split call or a re-keyed join's two, what
|
|
259
|
+
* reading its answer needs, and its explanation; or, for a query that does
|
|
260
|
+
* not check, the `error` result a run of it gives
|
|
261
|
+
* @throws {RangeError} When a limit, or `pieceBytes`, is not a whole number.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* const planned = planQuery(".orders | group_by(.region) | map({region: .[0].region, revenue: map(.total) | add})",
|
|
266
|
+
* root, new Map([["orders", { bytes: 1.4e9, rows: 8_000_000 }]]));
|
|
267
|
+
* if ("result" in planned) return planned.result; // the checker's problems
|
|
268
|
+
* const plan = planned.plan;
|
|
269
|
+
* if (plan.kind === "split") {
|
|
270
|
+
* const { result } = await splitCall(url, repo, workspace, plan.request, { token });
|
|
271
|
+
* return queryResultOf(plan.reading, result);
|
|
272
|
+
* }
|
|
273
|
+
* if (plan.kind === "rekey") {
|
|
274
|
+
* const first = await splitCall(url, repo, workspace, plan.first, { token });
|
|
275
|
+
* const join = first.output === null ? undefined : (await splitCall(url, repo, workspace, plan.join(first.output), { token })).result;
|
|
276
|
+
* return queryResultOf(plan.reading, plan.answer(first.result, join));
|
|
277
|
+
* }
|
|
278
|
+
* return queryResultOf(plan.prepared, await oneShotExecute(url, repo, workspace, plan.prepared.request, { token }));
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export declare function planQuery(programs: PlanPrograms | string, root: QueryRoot, weights: ReadonlyMap<string, SourceWeight>, options?: PlanOptions): {
|
|
282
|
+
plan: QueryPlan;
|
|
283
|
+
} | {
|
|
284
|
+
result: QueryResult;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* The split call a query split over a dataset's pieces runs as: the request
|
|
288
|
+
* e3-api-client's `splitCall` (or `splitCallLaunch`, `splitCallExplain`)
|
|
289
|
+
* sends, exactly as the builder sends it.
|
|
290
|
+
*
|
|
291
|
+
* @param split - the query's split (`splitJq`), over a root's data sources
|
|
292
|
+
* @param root - the root: each data source the split reads is an argument at
|
|
293
|
+
* its path
|
|
294
|
+
* @param options - the call's limits and its runner, as a one-shot call's
|
|
295
|
+
* @returns the request
|
|
296
|
+
* @throws {RangeError} When a limit is not a whole number of at least 1.
|
|
297
|
+
* @throws {Error} When the split reads a root field no data source of the root is.
|
|
298
|
+
*
|
|
299
|
+
* @remarks
|
|
300
|
+
* - `bodyIr` is the piece program, and `then` the final function, when there
|
|
301
|
+
* is one: each `encodeEastIR(fn.toIR())`, as a one-shot call's body is.
|
|
302
|
+
* - `args` is one `dataset` argument per input of the split, in its order —
|
|
303
|
+
* the root fields the query reads, as the translation takes them — at its
|
|
304
|
+
* data source's path; the one the pieces are cut from, `over`, is
|
|
305
|
+
* partitioned with no `by`, so any key may start a piece, and so is each of
|
|
306
|
+
* `copartitioned`, which e3 cuts at the same keys (#942); every other
|
|
307
|
+
* argument reaches each piece whole.
|
|
308
|
+
* - `output` is the split's output kind: a dict's merge and a fold's combine
|
|
309
|
+
* encoded as the programs are, and a fold's zero as beast2 at its type.
|
|
310
|
+
* - `runner` is a one-shot call's (`QueryOptions`): east-c given no platform
|
|
311
|
+
* package, and no program calls a platform function, so a caller who may
|
|
312
|
+
* read the workspace may launch it.
|
|
313
|
+
* - `limits` are a one-shot call's: no time limit unless the options set one,
|
|
314
|
+
* so e3 gives the job the server's ceiling (ten minutes on a local server),
|
|
315
|
+
* as it gives a one-shot call that names none the server's default.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* const split = splitJq(checkJq(".orders | map(.total) | add", root.type, { root: true }));
|
|
320
|
+
* if (split.kind === "split") {
|
|
321
|
+
* const { result } = await splitCall(url, repo, workspace, splitCallRequest(split, root), { token });
|
|
322
|
+
* }
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
export declare function splitCallRequest(split: JqSplitCall, root: QueryRoot, options?: QueryOptions): SplitCallRequest;
|
|
326
|
+
/**
|
|
327
|
+
* A re-keyed join's two split calls (#942), as the planner sends them when
|
|
328
|
+
* both sides of a join weigh more than one piece.
|
|
329
|
+
*
|
|
330
|
+
* @param split - the query's split, whose `rekey` is the join
|
|
331
|
+
* @param root - the root
|
|
332
|
+
* @param options - the calls' limits and their runner, as a one-shot call's
|
|
333
|
+
* @returns the re-key call, the join call over its output, and how their
|
|
334
|
+
* answers make the run's ({@link RekeyCalls})
|
|
335
|
+
* @throws {Error} When the split re-keys no join, or reads a root field no
|
|
336
|
+
* data source of the root is.
|
|
337
|
+
*
|
|
338
|
+
* @remarks
|
|
339
|
+
* - **The re-key call** runs `rekey.piece()` over `over` partitioned, into a
|
|
340
|
+
* dict by the join key whose merge concatenates each key's rows in input
|
|
341
|
+
* order. Its output is read by its hash, so its answer is asked to be one
|
|
342
|
+
* byte at most: e3 answers `too_large` with the output's hash beside it.
|
|
343
|
+
* - **The join call** runs `rekey.joinPiece()` over the re-key call's output,
|
|
344
|
+
* an `object` argument by its hash, and the join's other side, both
|
|
345
|
+
* partitioned, so e3 cuts them at the same keys; every other argument
|
|
346
|
+
* reaches each piece whole. Its output kind is the split's, and its final
|
|
347
|
+
* function `rekey.joinThen()`.
|
|
348
|
+
* - **The answer** is the join call's, with the re-key call's dataset first in
|
|
349
|
+
* what the run read, as the re-key call pinned it; or the re-key call's own
|
|
350
|
+
* when it ended without an output.
|
|
351
|
+
*/
|
|
352
|
+
export declare function rekeyCallRequests(split: JqSplitCall, root: QueryRoot, options?: QueryOptions): RekeyCalls;
|
|
353
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/query/plan.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAEH,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAC3H,MAAM,eAAe,CAAC;AACvB,OAAO,EAAe,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,EAAE,SAAS,EAAE,OAAO,GAAE,YAAiB,GAAG,gBAAgB,CAclH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,YAAiB,GAAG,UAAU,CAqC7G"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TypeOf, ValueTypeOf } from '@elaraai/east';
|
|
2
|
+
import { Query } from '@elaraai/e3-ui/internal';
|
|
3
|
+
/** The JavaScript function an East function compiles to. */
|
|
4
|
+
type Compiled<F> = ValueTypeOf<TypeOf<F>>;
|
|
5
|
+
/** The query builder's compiled East — see the module docs. */
|
|
6
|
+
export interface QueryEast {
|
|
7
|
+
/** The patch a save commits: the entries it writes, by name. */
|
|
8
|
+
save: Compiled<typeof Query.save>;
|
|
9
|
+
/** What refused a write under a new name, or `none` when it committed. */
|
|
10
|
+
nameWriteRefusal: Compiled<typeof Query.nameWriteRefusal>;
|
|
11
|
+
/** Whether a saved query's data sources are bound here, and if not, why not. */
|
|
12
|
+
rootBound: Compiled<typeof Query.rootBound>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The query builder's East, compiled on first use.
|
|
16
|
+
*
|
|
17
|
+
* @returns The compiled functions
|
|
18
|
+
*/
|
|
19
|
+
export declare function queryEast(): QueryEast;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=query-east.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-east.d.ts","sourceRoot":"","sources":["../../src/query/query-east.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,4DAA4D;AAC5D,KAAK,QAAQ,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1C,+DAA+D;AAC/D,MAAM,WAAW,SAAS;IACtB,gEAAgE;IAChE,IAAI,EAAE,QAAQ,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,0EAA0E;IAC1E,gBAAgB,EAAE,QAAQ,CAAC,OAAO,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC1D,gFAAgF;IAChF,SAAS,EAAE,QAAQ,CAAC,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC;CAC/C;AAaD;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAGrC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PartStyles } from './parts.js';
|
|
2
|
+
import { QueryEditor } from './use-query-editor.js';
|
|
3
|
+
/** Props of {@link QueryTabPanel}. */
|
|
4
|
+
export interface QueryTabPanelProps {
|
|
5
|
+
/** Editing the open query: what the tab draws, and does. */
|
|
6
|
+
readonly editor: QueryEditor;
|
|
7
|
+
/** The parts' styles, and the words. */
|
|
8
|
+
readonly ps: PartStyles;
|
|
9
|
+
/** The workspace the data sources are read in, when the builder knows it. */
|
|
10
|
+
readonly workspace: string | undefined;
|
|
11
|
+
/** The step an issue the history item went to is on. */
|
|
12
|
+
readonly focus: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Renders the Query tab — see the module docs.
|
|
16
|
+
*
|
|
17
|
+
* @param props - The editor, the styles, the workspace and the focus ({@link QueryTabPanelProps})
|
|
18
|
+
* @returns The tab
|
|
19
|
+
*/
|
|
20
|
+
export declare const QueryTabPanel: import('react').NamedExoticComponent<QueryTabPanelProps>;
|
|
21
|
+
//# sourceMappingURL=query-tab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-tab.d.ts","sourceRoot":"","sources":["../../src/query/query-tab.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AA2BH,OAAO,KAAK,EAAE,UAAU,EAAU,MAAM,YAAY,CAAC;AAKrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,sCAAsC;AACtC,MAAM,WAAW,kBAAkB;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,0DAoDxB,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { EastType } from '@elaraai/east';
|
|
2
|
+
import { TableRootValue } from '@elaraai/east-ui-components';
|
|
3
|
+
import { QueryWords } from './model/words.js';
|
|
4
|
+
/**
|
|
5
|
+
* A run's result, decoded: its East type and its value.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The type is the one the run's self-describing beast2 answer carries: `T`
|
|
9
|
+
* for a query giving one value, `Option<T>` for none or one, `Array<T>` for
|
|
10
|
+
* many.
|
|
11
|
+
*
|
|
12
|
+
* @property type - The result's East type
|
|
13
|
+
* @property value - The decoded value, of that type
|
|
14
|
+
*/
|
|
15
|
+
export interface DecodedResult {
|
|
16
|
+
/** The result's East type: `T`, `Option<T>` or `Array<T>`, as the run gave it. */
|
|
17
|
+
readonly type: EastType;
|
|
18
|
+
/** The decoded value, of that type. */
|
|
19
|
+
readonly value: unknown;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A column of a result's rows.
|
|
23
|
+
*
|
|
24
|
+
* @property key - The key each row holds the column's value under
|
|
25
|
+
* @property type - The column's East type
|
|
26
|
+
* @property field - The field the column reads; `undefined` for the one column of a result that is not records
|
|
27
|
+
*/
|
|
28
|
+
export interface ResultColumn {
|
|
29
|
+
/** The key each row holds the column's value under: a record's field name, or `value`. */
|
|
30
|
+
readonly key: string;
|
|
31
|
+
/** The column's East type: the field's, or the type of the values a result that is not records gives. */
|
|
32
|
+
readonly type: EastType;
|
|
33
|
+
/**
|
|
34
|
+
* The field the column reads, whose name names a list's items in it
|
|
35
|
+
* (`3 lines`); `undefined` for the one `value` column of a result that is
|
|
36
|
+
* not records, whose lists' items are `items`.
|
|
37
|
+
*/
|
|
38
|
+
readonly field: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A result's rows, as the Table shows them and the CSV writes them.
|
|
42
|
+
*
|
|
43
|
+
* @property columns - The columns, in order
|
|
44
|
+
* @property rows - The rows, each a struct value keyed by column key
|
|
45
|
+
*/
|
|
46
|
+
export interface ResultRows {
|
|
47
|
+
/** The columns, in order: a record's fields, in declared order, or the one `value` column. */
|
|
48
|
+
readonly columns: readonly ResultColumn[];
|
|
49
|
+
/** The rows, each a struct value keyed by column key: a record itself, or `{ value }`. */
|
|
50
|
+
readonly rows: readonly unknown[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A result's rows and columns, as the Table shows them (`Query Editor
|
|
54
|
+
* Spec.md` §4.11).
|
|
55
|
+
*
|
|
56
|
+
* @param result - the decoded result: its type, and its value
|
|
57
|
+
* @returns the columns, in order, and the rows, each a struct value keyed by
|
|
58
|
+
* column key
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* - **Records.** An array or a set of records — a recursive element read as
|
|
62
|
+
* its node — is one row per element and one column per field, in declared
|
|
63
|
+
* order; a record is one row.
|
|
64
|
+
* - **An option.** `none` is no rows, with the columns its payload would
|
|
65
|
+
* give; `some` is its payload's rows.
|
|
66
|
+
* - **Anything else.** An array, a set or a vector of other values is one
|
|
67
|
+
* row per value — a vector's numbers or booleans, as East reads them out of
|
|
68
|
+
* it — and any other value one row, in one `value` column: each row is
|
|
69
|
+
* `{ value }`.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const { columns, rows } = resultRows({ type: ArrayType(Order), value: orders });
|
|
74
|
+
* // columns: customer_id, discount, id, lines, status, total — one row per order
|
|
75
|
+
*
|
|
76
|
+
* resultRows({ type: IntegerType, value: 40n });
|
|
77
|
+
* // columns: value — rows: [{ value: 40n }]
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function resultRows(result: DecodedResult): ResultRows;
|
|
81
|
+
/**
|
|
82
|
+
* The words a result's cell shows for a value the Table words rather than
|
|
83
|
+
* shows as itself (`Query Editor Spec.md` §4.11): a nested value summarised,
|
|
84
|
+
* and a missing one.
|
|
85
|
+
*
|
|
86
|
+
* @param type - the value's East type
|
|
87
|
+
* @param value - the value
|
|
88
|
+
* @param words - the words
|
|
89
|
+
* @param field - the field the value sits in, whose name names a list's
|
|
90
|
+
* items: a column's `field`; `undefined` for the one `value` column, whose
|
|
91
|
+
* lists' items are `items`
|
|
92
|
+
* @returns the words; `undefined` for a primitive value — Null, Boolean,
|
|
93
|
+
* Integer, Float, String, DateTime, Blob, under any options — which a cell
|
|
94
|
+
* holds as itself
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* - **Missing.** An option's `none` is the missing word, "—"; its `some` is
|
|
98
|
+
* its payload's words. A recursive value is its node's.
|
|
99
|
+
* - **A list** (an array, a set, a vector) is its size and its items, named
|
|
100
|
+
* after its field: "1 line", "3 lines"; "3 items" where no field names
|
|
101
|
+
* them. **A lookup table** is "1 entry", "8 entries"; **a grid** its shape,
|
|
102
|
+
* "3 × 4".
|
|
103
|
+
* - **A record** is up to its first three fields that are neither a
|
|
104
|
+
* collection nor a record, missing ones left out, joined " · ".
|
|
105
|
+
* - **A case** is its name; with a payload, "{case} · {payload}" — a record
|
|
106
|
+
* payload's every field, missing ones left out; a Null payload, the case
|
|
107
|
+
* alone. **A calculation** is "function".
|
|
108
|
+
* - **Inside a summary**, a number prints in the viewer's language through
|
|
109
|
+
* the words' formatters, exactly: an ID field's as written, a whole number
|
|
110
|
+
* grouped, any other with every digit (§9 — never rounded); a DateTime as
|
|
111
|
+
* its date and time, and a Boolean, a Null and a Blob as East prints them.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* cellText(ArrayType(Line), lines, words, "lines"); // "3 lines"
|
|
116
|
+
* cellText(Status, variant("shipped", { date }), words, "status"); // "shipped · Jun 1, 2026, 14:00"
|
|
117
|
+
* cellText(OptionType(FloatType), none, words, "discount"); // "—"
|
|
118
|
+
* cellText(FloatType, 1234.5, words, "total"); // undefined: the cell holds 1234.5
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function cellText(type: EastType, value: unknown, words: QueryWords, field: string | undefined): string | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* A run's result as the value east-ui-components' Table renderer shows
|
|
124
|
+
* (`EastChakraTable`, `Query Editor Spec.md` §4.11): its rows inline,
|
|
125
|
+
* virtualised, under a sticky header, filling the height of the box it is
|
|
126
|
+
* placed in.
|
|
127
|
+
*
|
|
128
|
+
* @param result - the decoded result: its type, and its value
|
|
129
|
+
* @param words - the words: the message table, and the viewer's formatters
|
|
130
|
+
* @returns the Table's value
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* - **Rows and columns** are {@link resultRows}': one column per field of a
|
|
134
|
+
* record, headed by its name as a person reads it (`customer ID`), or one
|
|
135
|
+
* `value` column, headed by the message table's word.
|
|
136
|
+
* - **A cell** holds a primitive value as itself, under its own tag — Null,
|
|
137
|
+
* Boolean, Integer, Float, String, DateTime, Blob; an option's present
|
|
138
|
+
* value is its payload. Every other value is a String cell of its words
|
|
139
|
+
* ({@link cellText}): "—" where it is missing, "3 lines" where it is nested.
|
|
140
|
+
* - **Printing** is the renderer's: no column declares a format, so a number
|
|
141
|
+
* prints every digit, never grouped — an ID as written, a total exact
|
|
142
|
+
* (§9) — and a column whose present values are numbers is a number column,
|
|
143
|
+
* right-aligned in tabular mono, its missing "—" with them.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```tsx
|
|
147
|
+
* const { type, value } = decodeBeast2(result.outcome.value.result);
|
|
148
|
+
* const table = resultTable({ type: fromEastTypeValue(type), value }, queryWords(useFormatters()));
|
|
149
|
+
* return <EastChakraTable value={table} storageKey="query-results" />;
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function resultTable(result: DecodedResult, words: QueryWords): TableRootValue;
|
|
153
|
+
//# sourceMappingURL=results-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results-table.d.ts","sourceRoot":"","sources":["../../src/query/results-table.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGa,KAAK,QAAQ,EAEhC,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAA2B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQ5E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IACzB,0FAA0F;IAC1F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yGAAyG;IACzG,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACvB,8FAA8F;IAC9F,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,0F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