@nongt/visql 0.0.0-stage → 0.3.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.
Files changed (186) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +916 -2
  3. package/dist/PipelineEditor-DNZkDSaY.js +10042 -0
  4. package/dist/calendarDate-CYlr9TvX.js +43 -0
  5. package/dist/core-api-CBN6rAQG.js +1052 -0
  6. package/dist/core.js +80 -0
  7. package/dist/fixtures.js +7 -0
  8. package/dist/index.js +145 -0
  9. package/dist/issueLocation-Cw5sttQL.js +3183 -0
  10. package/dist/mui-date-pickers.js +117 -0
  11. package/dist/mui.js +510 -0
  12. package/dist/schema-z95dxLxu.js +839 -0
  13. package/dist/sql-import.js +1366 -0
  14. package/dist/style.css +1 -0
  15. package/dist/tokens-BTaVMSOx.js +95 -0
  16. package/dist/types/adapters/mui/MuiDatePicker.d.ts +12 -0
  17. package/dist/types/adapters/mui/MuiDateTimePicker.d.ts +10 -0
  18. package/dist/types/adapters/mui/MuiListInput.d.ts +9 -0
  19. package/dist/types/adapters/mui/MuiTimePicker.d.ts +10 -0
  20. package/dist/types/adapters/mui/QueryBuilder.d.ts +12 -0
  21. package/dist/types/adapters/mui/components.d.ts +16 -0
  22. package/dist/types/adapters/mui/index.d.ts +6 -0
  23. package/dist/types/adapters/mui/muiPickers.d.ts +6 -0
  24. package/dist/types/adapters/mui/pickerStyles.d.ts +28 -0
  25. package/dist/types/adapters/mui/theme.d.ts +11 -0
  26. package/dist/types/core/BetweenOnTextContext.d.ts +11 -0
  27. package/dist/types/core/DialectContext.d.ts +10 -0
  28. package/dist/types/core/DrillDownContext.d.ts +22 -0
  29. package/dist/types/core/ExistsContext.d.ts +29 -0
  30. package/dist/types/core/FlowDirectionContext.d.ts +8 -0
  31. package/dist/types/core/FlowOrientationContext.d.ts +6 -0
  32. package/dist/types/core/FunctionsContext.d.ts +25 -0
  33. package/dist/types/core/GroupKeysContext.d.ts +18 -0
  34. package/dist/types/core/MeasureLockContext.d.ts +12 -0
  35. package/dist/types/core/ReadOnlyContext.d.ts +6 -0
  36. package/dist/types/core/SchemaContext.d.ts +8 -0
  37. package/dist/types/core/SubqueryContext.d.ts +16 -0
  38. package/dist/types/core/UnionBranchContext.d.ts +6 -0
  39. package/dist/types/core/ValueInputContext.d.ts +24 -0
  40. package/dist/types/core/absolutePath.d.ts +57 -0
  41. package/dist/types/core/ast.d.ts +154 -0
  42. package/dist/types/core/astChildren.d.ts +4 -0
  43. package/dist/types/core/astEqual.d.ts +4 -0
  44. package/dist/types/core/astMap.d.ts +21 -0
  45. package/dist/types/core/calendarDate.d.ts +21 -0
  46. package/dist/types/core/columnFormats.d.ts +23 -0
  47. package/dist/types/core/components/BoolPicker.d.ts +8 -0
  48. package/dist/types/core/components/NumberInput.d.ts +8 -0
  49. package/dist/types/core/components/ReadOnlyPart.d.ts +10 -0
  50. package/dist/types/core/components/TextInput.d.ts +8 -0
  51. package/dist/types/core/components/expression/BinaryView.d.ts +10 -0
  52. package/dist/types/core/components/expression/ExprSummary.d.ts +12 -0
  53. package/dist/types/core/components/expression/ExpressionTypeSelector.d.ts +35 -0
  54. package/dist/types/core/components/expression/ExpressionView.d.ts +30 -0
  55. package/dist/types/core/components/expression/FieldView.d.ts +15 -0
  56. package/dist/types/core/components/expression/FormulaPeek.d.ts +14 -0
  57. package/dist/types/core/components/expression/FunctionArgInput.d.ts +22 -0
  58. package/dist/types/core/components/expression/FunctionView.d.ts +7 -0
  59. package/dist/types/core/components/expression/ListView.d.ts +20 -0
  60. package/dist/types/core/components/expression/LiteralView.d.ts +23 -0
  61. package/dist/types/core/components/expression/LogicalView.d.ts +9 -0
  62. package/dist/types/core/components/expression/MeasureMenu.d.ts +21 -0
  63. package/dist/types/core/components/expression/ParamView.d.ts +13 -0
  64. package/dist/types/core/components/expression/RelativeDateView.d.ts +15 -0
  65. package/dist/types/core/components/expression/SubqueryView.d.ts +8 -0
  66. package/dist/types/core/components/expression/formulaClasses.d.ts +8 -0
  67. package/dist/types/core/components/flow/CaseBranchFlowNode.d.ts +5 -0
  68. package/dist/types/core/components/flow/CaseElseFlowNode.d.ts +5 -0
  69. package/dist/types/core/components/flow/CaseFlowNode.d.ts +5 -0
  70. package/dist/types/core/components/flow/ConditionFlowNode.d.ts +5 -0
  71. package/dist/types/core/components/flow/CreateConditionFlowNode.d.ts +14 -0
  72. package/dist/types/core/components/flow/CreateHavingFlowNode.d.ts +11 -0
  73. package/dist/types/core/components/flow/DistinctToggle.d.ts +10 -0
  74. package/dist/types/core/components/flow/ExistsFlowNode.d.ts +9 -0
  75. package/dist/types/core/components/flow/FromFlowNode.d.ts +110 -0
  76. package/dist/types/core/components/flow/FunctionArgFlowNode.d.ts +5 -0
  77. package/dist/types/core/components/flow/FunctionCallFlowNode.d.ts +5 -0
  78. package/dist/types/core/components/flow/FunctionSortKeys.d.ts +10 -0
  79. package/dist/types/core/components/flow/GroupBgNode.d.ts +14 -0
  80. package/dist/types/core/components/flow/GroupByFlowNode.d.ts +29 -0
  81. package/dist/types/core/components/flow/IfElseFlowNode.d.ts +5 -0
  82. package/dist/types/core/components/flow/IfFlowNode.d.ts +5 -0
  83. package/dist/types/core/components/flow/IfThenFlowNode.d.ts +5 -0
  84. package/dist/types/core/components/flow/LeafConditionFrame.d.ts +19 -0
  85. package/dist/types/core/components/flow/LogicalFlowNode.d.ts +5 -0
  86. package/dist/types/core/components/flow/MoveTooltip.d.ts +19 -0
  87. package/dist/types/core/components/flow/NotFlowNode.d.ts +5 -0
  88. package/dist/types/core/components/flow/OrderByFlowNode.d.ts +32 -0
  89. package/dist/types/core/components/flow/SectionLabelFlowNode.d.ts +7 -0
  90. package/dist/types/core/components/flow/SelectFlowNode.d.ts +49 -0
  91. package/dist/types/core/components/flow/SharedQueriesFlowNode.d.ts +39 -0
  92. package/dist/types/core/components/flow/SummaryPill.d.ts +12 -0
  93. package/dist/types/core/components/flow/WarningNote.d.ts +9 -0
  94. package/dist/types/core/components/flow/chainSides.d.ts +18 -0
  95. package/dist/types/core/components/flow/dragContext.d.ts +12 -0
  96. package/dist/types/core/components/flow/moveTooltipHysteresis.d.ts +18 -0
  97. package/dist/types/core/components/flow/useRowDrag.d.ts +34 -0
  98. package/dist/types/core/components/flow/useRowReorderFlip.d.ts +30 -0
  99. package/dist/types/core/derivedTables.d.ts +98 -0
  100. package/dist/types/core/distinctSort.d.ts +7 -0
  101. package/dist/types/core/drillPath.d.ts +11 -0
  102. package/dist/types/core/exists.d.ts +7 -0
  103. package/dist/types/core/existsMenu.d.ts +61 -0
  104. package/dist/types/core/expressionFlow.d.ts +428 -0
  105. package/dist/types/core/fanOut.d.ts +58 -0
  106. package/dist/types/core/findParts.d.ts +19 -0
  107. package/dist/types/core/flowTrees.d.ts +20 -0
  108. package/dist/types/core/focusKey.d.ts +10 -0
  109. package/dist/types/core/formula.d.ts +24 -0
  110. package/dist/types/core/formulaPeek.d.ts +16 -0
  111. package/dist/types/core/functionRegistry.d.ts +117 -0
  112. package/dist/types/core/grouping.d.ts +58 -0
  113. package/dist/types/core/history.d.ts +25 -0
  114. package/dist/types/core/i18n/defaultMessages.d.ts +367 -0
  115. package/dist/types/core/i18n/messages.d.ts +273 -0
  116. package/dist/types/core/i18n/relativeDateWords.d.ts +3 -0
  117. package/dist/types/core/id.d.ts +5 -0
  118. package/dist/types/core/issueAnchor.d.ts +29 -0
  119. package/dist/types/core/issueLocation.d.ts +105 -0
  120. package/dist/types/core/limits.d.ts +17 -0
  121. package/dist/types/core/measures.d.ts +51 -0
  122. package/dist/types/core/params.d.ts +30 -0
  123. package/dist/types/core/pipelineAnchor.d.ts +118 -0
  124. package/dist/types/core/pipelineFlow.d.ts +271 -0
  125. package/dist/types/core/queryAst.d.ts +201 -0
  126. package/dist/types/core/queryHelpers.d.ts +113 -0
  127. package/dist/types/core/queryValidation.d.ts +206 -0
  128. package/dist/types/core/relativeDates.d.ts +11 -0
  129. package/dist/types/core/resolveNames.d.ts +17 -0
  130. package/dist/types/core/rowRange.d.ts +3 -0
  131. package/dist/types/core/schema.d.ts +119 -0
  132. package/dist/types/core/scopeQuery.d.ts +45 -0
  133. package/dist/types/core/selectColumns.d.ts +23 -0
  134. package/dist/types/core/settleQuery.d.ts +11 -0
  135. package/dist/types/core/sharedQueries.d.ts +66 -0
  136. package/dist/types/core/sqlGen.d.ts +102 -0
  137. package/dist/types/core/sqlOffsets.d.ts +5 -0
  138. package/dist/types/core/sqlSpans.d.ts +33 -0
  139. package/dist/types/core/storedQuery.d.ts +43 -0
  140. package/dist/types/core/summarize.d.ts +3 -0
  141. package/dist/types/core/theme/tokens.d.ts +74 -0
  142. package/dist/types/core/ui/UIContext.d.ts +6 -0
  143. package/dist/types/core/ui/index.d.ts +12 -0
  144. package/dist/types/core/ui/types.d.ts +264 -0
  145. package/dist/types/core/unionTables.d.ts +121 -0
  146. package/dist/types/core/useValueTypes.d.ts +12 -0
  147. package/dist/types/core/valueTypes.d.ts +54 -0
  148. package/dist/types/core-api.d.ts +20 -0
  149. package/dist/types/features/queryEditor/ExpressionFlowCanvas.d.ts +10 -0
  150. package/dist/types/features/queryEditor/FindBox.d.ts +12 -0
  151. package/dist/types/features/queryEditor/FlowCanvas.d.ts +96 -0
  152. package/dist/types/features/queryEditor/FocusPulse.d.ts +10 -0
  153. package/dist/types/features/queryEditor/IssuesButton.d.ts +16 -0
  154. package/dist/types/features/queryEditor/PipelineEditor.d.ts +210 -0
  155. package/dist/types/features/queryEditor/QueryOutline.d.ts +16 -0
  156. package/dist/types/features/queryEditor/ResultsPanel.d.ts +11 -0
  157. package/dist/types/features/queryEditor/RunButton.d.ts +11 -0
  158. package/dist/types/features/queryEditor/SubFlowPanel.d.ts +24 -0
  159. package/dist/types/features/queryEditor/UndoRedoToast.d.ts +6 -0
  160. package/dist/types/features/queryEditor/canvasPositioning.d.ts +81 -0
  161. package/dist/types/features/queryEditor/findKeys.d.ts +3 -0
  162. package/dist/types/features/queryEditor/flowDragUtils.d.ts +16 -0
  163. package/dist/types/features/queryEditor/focusContext.d.ts +24 -0
  164. package/dist/types/features/queryEditor/hoveredPart.d.ts +32 -0
  165. package/dist/types/features/queryEditor/issueFocusParts.d.ts +9 -0
  166. package/dist/types/features/queryEditor/issueLocationText.d.ts +7 -0
  167. package/dist/types/features/queryEditor/issueText.d.ts +11 -0
  168. package/dist/types/features/queryEditor/outlineSections.d.ts +23 -0
  169. package/dist/types/features/queryEditor/run.d.ts +36 -0
  170. package/dist/types/features/queryEditor/sectionLabels.d.ts +15 -0
  171. package/dist/types/features/queryEditor/treeScopeContext.d.ts +14 -0
  172. package/dist/types/features/queryEditor/useRemeasureOnDirectionChange.d.ts +7 -0
  173. package/dist/types/features/queryEditor/useRevealNewNodes.d.ts +35 -0
  174. package/dist/types/features/queryEditor/withTreeScope.d.ts +10 -0
  175. package/dist/types/fixtures.d.ts +44 -0
  176. package/dist/types/index.d.ts +13 -0
  177. package/dist/types/mui-date-pickers.d.ts +3 -0
  178. package/dist/types/mui.d.ts +2 -0
  179. package/dist/types/sql-import.d.ts +3 -0
  180. package/dist/types/sqlImport/context.d.ts +71 -0
  181. package/dist/types/sqlImport/expressions.d.ts +11 -0
  182. package/dist/types/sqlImport/importSql.d.ts +28 -0
  183. package/dist/types/sqlImport/parse.d.ts +6 -0
  184. package/dist/types/sqlImport/syntax.d.ts +245 -0
  185. package/dist/types/sqlImport/tokenize.d.ts +26 -0
  186. package/package.json +164 -3
@@ -0,0 +1,154 @@
1
+ import type { DerivedQuery, JoinClause, TableFrom } from './queryAst.js';
2
+ export declare const binaryOperators: readonly ["=", "!=", "<", "<=", ">", ">=", "LIKE", "IN", "BETWEEN", "REGEXP", "IS NULL", "IS NOT NULL"];
3
+ export type BinaryOperator = typeof binaryOperators[number];
4
+ /** The operators that take no right-hand side. */
5
+ export declare const unaryOperators: readonly ["IS NULL", "IS NOT NULL"];
6
+ export declare function isUnaryOperator(operator: BinaryOperator | undefined): boolean;
7
+ export type LogicalOperator = 'AND' | 'OR';
8
+ /** A value's type (issue 130, see valueTypes.ts). `integer` is a whole
9
+ * number, `number` any. A `date` is a calendar day and a `dateTime` a day
10
+ * and a time, both as calendarDate.ts holds them; a `time` is a time of
11
+ * day, stored as `HH:MM:SS` text. */
12
+ export type ValueType = 'text' | 'integer' | 'number' | 'date' | 'dateTime' | 'time' | 'boolean';
13
+ export type LiteralValue = string | number | bigint | boolean | null | Date;
14
+ export type ExpressionNode = LiteralNode | FieldNode | FunctionCallNode | BinaryNode | LogicalNode | NotNode | IfNode | CaseNode | ParamNode | ExistsNode | SubqueryNode | ListNode;
15
+ /** A named value supplied by the application when the SQL is generated —
16
+ * `astToParameterizedSql(query, dialect, { values: { [name]: … } })` —
17
+ * never by the user. Code (typically a backend) adds it, e.g. a tenant or
18
+ * user id condition; the editor shows it read-only. `name` is a plain
19
+ * identifier. */
20
+ export interface ParamNode extends Record<string, unknown> {
21
+ type: 'param';
22
+ name: string;
23
+ /** A date relative to when the query runs, as the report's author meant
24
+ * it (issue 140): "30 days ago", "the start of last month". The query
25
+ * only records it; the application computes the value — "today" in its
26
+ * user's time zone, its first day of the week — and gives it like any
27
+ * other param's (queryParams lists it). */
28
+ relative?: RelativeDate;
29
+ }
30
+ /** A date relative to when the query runs (see ParamNode's `relative`). */
31
+ export interface RelativeDate {
32
+ unit: 'day' | 'week' | 'month' | 'year';
33
+ /** Units from the run date: negative is earlier, 0 this one. */
34
+ offset: number;
35
+ /** The first or last day of that unit (week, month or year). Without it,
36
+ * the same point in it: `{ unit: 'week', offset: -1 }` is 7 days ago. */
37
+ anchor?: 'start' | 'end';
38
+ }
39
+ export interface LiteralNode extends Record<string, unknown> {
40
+ type: 'literal';
41
+ value: LiteralValue;
42
+ /** With `value: ''`: the empty text, meant as such, written `''`. A `''`
43
+ * without it is a value not filled in yet — what a blank input comes out
44
+ * as: validateQuery reports it as incomplete, and the SQL has `??`, like
45
+ * a field with no column. */
46
+ empty?: boolean;
47
+ /** The value's type when its value doesn't say:
48
+ * - picked for a value with nothing typed to compare it with (value
49
+ * against value, issue 130) — what its input is, blank or not; unused
50
+ * (and dropped) when what it's compared with has a type. The editor
51
+ * picks text, number, date or yes/no.
52
+ * - on NULL, a NULL of that type (issue 121): a union's placeholder for
53
+ * a value only some branches have, written typed (sqlGen). */
54
+ as?: ValueType;
55
+ }
56
+ export interface FieldNode extends Record<string, unknown> {
57
+ type: 'field';
58
+ table?: string;
59
+ column?: string;
60
+ }
61
+ /** A SELECT column's formula used again in HAVING or a sort key, picked
62
+ * by the column's name: the column's id (see selectColumns.ts). */
63
+ interface ColumnCopy {
64
+ fromSelect?: string;
65
+ }
66
+ export interface FunctionCallNode extends Record<string, unknown>, ColumnCopy {
67
+ type: 'function';
68
+ name: string;
69
+ args: ExpressionNode[];
70
+ /** An aggregate over distinct values only: `COUNT(DISTINCT x)`. */
71
+ distinct?: boolean;
72
+ /** The order an aggregate takes its values in (issue 164): STRING_AGG's
73
+ * text lists them so. Only STRING_AGG takes one. */
74
+ orderBy?: FunctionSortKey[];
75
+ }
76
+ /** One key of a function call's `orderBy`. */
77
+ export interface FunctionSortKey {
78
+ expression: ExpressionNode;
79
+ direction: 'asc' | 'desc';
80
+ }
81
+ export interface BinaryNode extends Record<string, unknown>, ColumnCopy {
82
+ type: 'binary';
83
+ operator?: BinaryOperator;
84
+ left: ExpressionNode;
85
+ /** Absent exactly when `operator` is IS NULL / IS NOT NULL. */
86
+ right?: ExpressionNode;
87
+ }
88
+ export interface LogicalNode extends Record<string, unknown> {
89
+ type: 'logical';
90
+ operator: LogicalOperator;
91
+ operands: ExpressionNode[];
92
+ }
93
+ export interface NotNode extends Record<string, unknown> {
94
+ type: 'not';
95
+ operand: ExpressionNode;
96
+ }
97
+ export interface IfNode extends Record<string, unknown>, ColumnCopy {
98
+ type: 'if';
99
+ condition?: ExpressionNode;
100
+ then?: ExpressionNode;
101
+ else?: ExpressionNode;
102
+ }
103
+ /** The rows an EXISTS looks for: a query of its own, without SELECT (SQL
104
+ * needs none: `SELECT 1`). Its tables are its own; one the outer query
105
+ * also names needs an alias. Its base is a table. */
106
+ export interface ExistsQuery {
107
+ from: TableFrom;
108
+ joins: JoinClause[];
109
+ /** Conditions on those rows, naming its own tables only. Absent: any. */
110
+ where?: ExpressionNode;
111
+ }
112
+ /** EXISTS (SELECT 1 FROM … WHERE <link> AND <where>): whether the outer
113
+ * row has related rows. A condition, never a value. NOT EXISTS is a `not`
114
+ * around it. See docs/design/exists-conditions.md. */
115
+ export interface ExistsNode extends Record<string, unknown> {
116
+ type: 'exists';
117
+ query: ExistsQuery;
118
+ /** How a related row matches the outer one: equalities between the
119
+ * subquery's tables and the outer query's (from the schema's relations),
120
+ * kept apart from `query.where`, the conditions a user writes. */
121
+ link: ExpressionNode;
122
+ }
123
+ /** `x IN (SELECT …)` (issue 122): the right side of IN, a query of its own
124
+ * selecting exactly one column. Not linked to the query around it: its
125
+ * tables are its own, as a derived table's are. NOT IN is a `not` around
126
+ * the IN. Its `id` is a QueryPath step (see derivedTables.ts), so the
127
+ * editor opens it like a sub query in FROM. Opaque to walks over the
128
+ * expression around it (astChildren): what's inside is another query's.
129
+ * See docs/design/exists-conditions.md. */
130
+ export interface SubqueryNode extends Record<string, unknown> {
131
+ type: 'subquery';
132
+ id: string;
133
+ query: DerivedQuery;
134
+ }
135
+ /** `x IN (a, b, c)` (issue 130): the right side of IN, its values one
136
+ * item each — literals in the editor, each with the input of what it's
137
+ * compared with; params and other values from code. IN's other right side
138
+ * is a sub query. Also BETWEEN's right side (issue 169): its two bounds,
139
+ * low then high (`x BETWEEN low AND high`, both included). NOT BETWEEN is
140
+ * a `not` around one, as NOT IN is. */
141
+ export interface ListNode extends Record<string, unknown> {
142
+ type: 'list';
143
+ items: ExpressionNode[];
144
+ }
145
+ export interface CaseNode extends Record<string, unknown>, ColumnCopy {
146
+ type: 'case';
147
+ subject?: ExpressionNode;
148
+ branches: {
149
+ when: ExpressionNode;
150
+ then: ExpressionNode;
151
+ }[];
152
+ else?: ExpressionNode;
153
+ }
154
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { ExpressionNode } from './ast.js';
2
+ /** The expressions directly under `node` — what a walk over an expression
3
+ * tree visits next. */
4
+ export default function astChildren(node: ExpressionNode): ExpressionNode[];
@@ -0,0 +1,4 @@
1
+ /** Structural equality for AST values: same keys (undefined ones ignored,
2
+ * in any order), same values, dates by time — so two expressions built
3
+ * separately compare equal when they say the same thing. */
4
+ export default function astEqual(a: unknown, b: unknown): boolean;
@@ -0,0 +1,21 @@
1
+ import type { ExpressionNode } from './ast.js';
2
+ import { type DerivedQuery, type QueryBody } from './queryAst.js';
3
+ /** `node` with `child` applied to each expression directly under it (see
4
+ * astChildren) — the rest of it kept. An EXISTS's children are its link,
5
+ * its conditions and its joins' ON conditions. */
6
+ export declare function mapChildren(node: ExpressionNode, child: (node: ExpressionNode) => ExpressionNode): ExpressionNode;
7
+ /** `node` rebuilt with `leaf` applied to every node that has no children
8
+ * (fields, literals, params, …) — the rest of the tree's shape kept. */
9
+ export declare function mapLeaves(node: ExpressionNode, leaf: (node: ExpressionNode) => ExpressionNode): ExpressionNode;
10
+ /** A query's own expression trees: WHERE, each join's ON, SELECT, GROUP
11
+ * BY, HAVING, ORDER BY — not its derived tables'. */
12
+ export declare function queryTrees(query: QueryBody): ExpressionNode[];
13
+ /** `query` with `tree` applied to every expression tree in it (WHERE, ON,
14
+ * SELECT, GROUP BY, HAVING, ORDER BY). A derived table's query is mapped
15
+ * by `derived` — by default the same way, all the way down — each branch
16
+ * of a union on its own; so is each shared query's (issue 194), on the
17
+ * whole query. */
18
+ export declare function mapQueryTrees<Q extends QueryBody>(query: Q, tree: (node: ExpressionNode) => ExpressionNode, derived?: (query: DerivedQuery) => DerivedQuery): Q;
19
+ /** `query` with `leaf` applied to every leaf of every expression in it,
20
+ * derived tables' included. */
21
+ export declare function mapQueryLeaves<Q extends QueryBody>(query: Q, leaf: (node: ExpressionNode) => ExpressionNode): Q;
@@ -0,0 +1,21 @@
1
+ /** The calendar day `year`-`month`-`day` (month 1–12), as the AST holds it. */
2
+ export declare function calendarDay(year: number, month: number, day: number): Date;
3
+ /** The day `date` holds, as `YYYY-MM-DD`. */
4
+ export declare function isoDay(date: Date): string;
5
+ /** The day `YYYY-MM-DD` names (a date input's value), or undefined for
6
+ * anything else. */
7
+ export declare function fromIsoDay(text: string): Date | undefined;
8
+ /** Whether `date` is a whole day, no time of day. */
9
+ export declare function isWholeDay(date: Date): boolean;
10
+ /** `date` as SQL writes it, without a zone: `YYYY-MM-DD` for a whole day,
11
+ * else `YYYY-MM-DD HH:MM:SS` (with `.mmm` when it has milliseconds). */
12
+ export declare function sqlDateText(date: Date): string;
13
+ /** A date and time as a `datetime-local` input's value: `YYYY-MM-DDTHH:MM`
14
+ * from its UTC fields. */
15
+ export declare function isoDateTime(date: Date): string;
16
+ /** The date and time `YYYY-MM-DDTHH:MM[:SS]` names (a `datetime-local`
17
+ * input's value), or undefined for anything else. */
18
+ export declare function fromIsoDateTime(text: string): Date | undefined;
19
+ /** A time of day `HH:MM[:SS]` as stored, `HH:MM:SS` — or undefined for
20
+ * anything else. */
21
+ export declare function timeOfDay(text: string): string | undefined;
@@ -0,0 +1,23 @@
1
+ import type { LiteralValue } from './ast.js';
2
+ import { type QueryPipeline } from './queryAst.js';
3
+ import { type DatabaseSchema } from './schema.js';
4
+ /** `value` written in `format`: `YYYY` the year, `MM` the month, `DD` the
5
+ * day, `HH` the hour (00–23), `mm` the minute, `ss` the second; anything
6
+ * else as it is (`'YYYY-MM-DD'`, `'HH:mm'`, `'DD/MM/YYYY'`). A Date by its
7
+ * UTC fields (a calendar day or a wall-clock time); a time of day from
8
+ * its `HH:MM[:SS]` text; a day (and time) from `YYYY-MM-DD[ HH:MM[:SS]]`
9
+ * text. Anything else (a number, NULL, text that's neither) as it is. */
10
+ export declare function formatColumnValue(value: LiteralValue, format: string): LiteralValue;
11
+ /** What a column with a `format` gets from the query: the SQL text of each
12
+ * value compared with it, and the formats of params compared with one
13
+ * (their values come later: astToParameterizedSql's `values`). */
14
+ export interface ColumnFormatted {
15
+ query: QueryPipeline;
16
+ params: Map<string, string>;
17
+ }
18
+ /** `query` with every value compared with a column that has a `format`
19
+ * written in it (formatColumnValue): a literal on the other side of a
20
+ * comparison, or each of IN's values. A param there is noted with the
21
+ * format instead. Fields are found by the names the query uses (an alias
22
+ * for a table under one), in each query's own scope. */
23
+ export declare function formatColumnValues(query: QueryPipeline, schema: DatabaseSchema): ColumnFormatted;
@@ -0,0 +1,8 @@
1
+ interface Props {
2
+ className?: string;
3
+ grouped?: boolean;
4
+ value?: boolean;
5
+ onChange?: (value?: boolean) => void;
6
+ }
7
+ declare const BoolPicker: ({ className, grouped, value, onChange, }: Props) => import("react/jsx-runtime").JSX.Element;
8
+ export default BoolPicker;
@@ -0,0 +1,8 @@
1
+ interface Props {
2
+ className?: string;
3
+ grouped?: boolean;
4
+ value?: number;
5
+ onChange?: (value?: string) => void;
6
+ }
7
+ declare const NumberInput: ({ className, grouped, value, onChange, }: Props) => import("react/jsx-runtime").JSX.Element;
8
+ export default NumberInput;
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ /** `children`, read-only when `readOnly`: inputs disabled (ReadOnlyContext)
3
+ * and edit buttons hidden (.qb-read-only, see queryBuilder.css) — for a
4
+ * part of a canvas, like a measure's parts that follow the report. The
5
+ * wrapper takes no box of its own (display: contents). */
6
+ declare const ReadOnlyPart: ({ readOnly, children }: {
7
+ readOnly: boolean;
8
+ children: ReactNode;
9
+ }) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
10
+ export default ReadOnlyPart;
@@ -0,0 +1,8 @@
1
+ interface Props {
2
+ className?: string;
3
+ grouped?: boolean;
4
+ value?: string;
5
+ onChange?: (value?: string) => void;
6
+ }
7
+ declare const TextInput: ({ className, grouped, value, onChange, }: Props) => import("react/jsx-runtime").JSX.Element;
8
+ export default TextInput;
@@ -0,0 +1,10 @@
1
+ import { type BinaryNode, type ExpressionNode } from '../../ast.js';
2
+ import type { AbsolutePath } from '../../absolutePath.js';
3
+ interface Props {
4
+ className?: string;
5
+ binary: BinaryNode;
6
+ onChange?: (exp?: ExpressionNode) => void;
7
+ path?: AbsolutePath;
8
+ }
9
+ declare const BinaryView: ({ className, binary, onChange, path, }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export default BinaryView;
@@ -0,0 +1,12 @@
1
+ import type { ExpressionNode } from '../../ast.js';
2
+ interface Props {
3
+ expression: ExpressionNode;
4
+ /** The whole of it as the browser's own tooltip — not where a peek
5
+ * shows it (FormulaPeek). Default true. */
6
+ titled?: boolean;
7
+ }
8
+ /** A collapsed expression, as a formula that reads like it: columns by
9
+ * their labels, `ROUND(Total Price, 2)`, a CASE by its outcomes (see
10
+ * formula.ts). */
11
+ declare const ExprSummary: ({ expression, titled }: Props) => import("react/jsx-runtime").JSX.Element;
12
+ export default ExprSummary;
@@ -0,0 +1,35 @@
1
+ import type { ExpressionNode } from '../../ast.js';
2
+ import { type MeasureChoice } from './MeasureMenu.js';
3
+ interface Props {
4
+ expression: ExpressionNode;
5
+ onChange?: (exp: ExpressionNode) => void;
6
+ /** Types not to offer here — e.g. a plain value as an ORDER BY key, where
7
+ * it means nothing (and `ORDER BY 1` would mean "the first column"). */
8
+ exclude?: readonly ('field' | 'literal' | 'param' | 'function' | 'if' | 'case')[];
9
+ /** Only a label, as in read-only mode: no menu, can't be clicked. For a
10
+ * type chosen elsewhere, e.g. the call at the top of a function's
11
+ * sub-canvas. */
12
+ fixed?: boolean;
13
+ /** A SELECT column's: a measure from another table, offered last. */
14
+ measure?: MeasureChoice;
15
+ /** IN's value (issue 122), when the editor offers it: a sub query, its
16
+ * canvas opened to make it (see SubqueryScope's `create`). */
17
+ subquery?: {
18
+ onCreate: () => void;
19
+ };
20
+ /** IN's right side (issue 130): its values (a list) are offered as its
21
+ * value, and a sub query when `subquery` is given — nothing else. */
22
+ inValues?: boolean;
23
+ /** "Relative date" offered (issue 140): a value compared with a date. */
24
+ relativeDate?: boolean;
25
+ /** NULL offered ("Empty"): where a value goes and isn't compared — a
26
+ * SELECT column, a function's argument, IF/CASE's results. Never in a
27
+ * comparison: `x = NULL` is never true (IS NULL is its operator). */
28
+ allowNull?: boolean;
29
+ /** A value with nothing typed to compare it with (issue 130): "Value" is
30
+ * offered as its types — Text, Number, Date, Yes/No — and the badge says
31
+ * which it is. */
32
+ pickTypes?: boolean;
33
+ }
34
+ declare const ExpressionTypeSelector: ({ expression, onChange, exclude, fixed: fixedProp, measure, subquery, pickTypes, inValues, allowNull, relativeDate, }: Props) => import("react/jsx-runtime").JSX.Element;
35
+ export default ExpressionTypeSelector;
@@ -0,0 +1,30 @@
1
+ import type { ExpressionNode, ValueType } from '../../ast.js';
2
+ import { type AbsolutePath } from '../../absolutePath.js';
3
+ import type { Table, TableColumn } from '../../schema.js';
4
+ export interface ExpressionViewProps extends Record<string, unknown> {
5
+ className?: string;
6
+ expression: ExpressionNode;
7
+ onChange?: (exp?: ExpressionNode) => void;
8
+ /** This slot's path, relative to the current canvas's own root. Composed with
9
+ * DrillDownContext's basePath to form the absolute path a drill pushes. Slots
10
+ * that can't resolve one (dead/legacy render paths) simply can't drill. */
11
+ path?: AbsolutePath;
12
+ /** Label shown in the breadcrumb when drilling into this slot. */
13
+ slotLabel?: string;
14
+ /** When true, always render inline even if DrillDownContext is available. */
15
+ noDrill?: boolean;
16
+ /** When true, renders as right-cap of an input-group (rounded-r, no left border). */
17
+ grouped?: boolean;
18
+ /** The column a value in this slot is compared against (see LiteralView). */
19
+ column?: {
20
+ table: Table;
21
+ column: TableColumn;
22
+ };
23
+ /** The type a value in this slot is (see LiteralView), when it's known. */
24
+ valueType?: ValueType;
25
+ /** Whether a text value here may be marked as the empty text (see
26
+ * LiteralView). Default true. */
27
+ allowEmpty?: boolean;
28
+ }
29
+ declare const ExpressionView: ({ expression, onChange, path, slotLabel, noDrill, grouped, column, allowEmpty, valueType, }: ExpressionViewProps) => import("react/jsx-runtime").JSX.Element;
30
+ export default ExpressionView;
@@ -0,0 +1,15 @@
1
+ import type { ExpressionNode, FieldNode } from '../../ast.js';
2
+ import { type DatabaseColumnType } from '../../schema.js';
3
+ interface Props {
4
+ className?: string;
5
+ grouped?: boolean;
6
+ field: FieldNode;
7
+ onChange?: (exp?: ExpressionNode) => void;
8
+ /** When set, only columns with a matching type are shown. */
9
+ typeFilter?: DatabaseColumnType[];
10
+ /** The slot holds a copy of this SELECT column's formula (see
11
+ * selectColumns.ts), shown as that column. */
12
+ columnRef?: string;
13
+ }
14
+ declare const FieldView: ({ className, grouped, field, onChange, typeFilter, columnRef, }: Props) => import("react/jsx-runtime").JSX.Element;
15
+ export default FieldView;
@@ -0,0 +1,14 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { AbsolutePath } from '../../absolutePath.js';
3
+ import type { ExpressionNode } from '../../ast.js';
4
+ interface Props {
5
+ expression: ExpressionNode;
6
+ /** What the card says of it (the chip's own label). */
7
+ label: string;
8
+ /** A part was picked: its path in the expression. */
9
+ onGo: (part: AbsolutePath) => void;
10
+ /** The chip. */
11
+ children: ReactNode;
12
+ }
13
+ declare const FormulaPeek: ({ expression, label, onGo, children, }: Props) => import("react/jsx-runtime").JSX.Element;
14
+ export default FormulaPeek;
@@ -0,0 +1,22 @@
1
+ import type { ExpressionNode } from '../../ast.js';
2
+ import type { AbsolutePath } from '../../absolutePath.js';
3
+ import { type ArgDef } from '../../functionRegistry.js';
4
+ interface Props {
5
+ argDef: ArgDef;
6
+ value: ExpressionNode;
7
+ onChange?: (exp: ExpressionNode) => void;
8
+ /** Forwarded to ExpressionView so a complex arg value can drill down. */
9
+ path?: AbsolutePath;
10
+ /** Passed to ExpressionView as slotLabel for drill-down breadcrumbs. */
11
+ slotLabel?: string;
12
+ }
13
+ /**
14
+ * Renders a single function argument input based on its ArgDef.kind:
15
+ *
16
+ * unit → Select dropdown of unit choices (DAY, MONTH …)
17
+ * type-name → Autocomplete for SQL type names (INTEGER, VARCHAR …)
18
+ * fixed-text → a text box (STRING_AGG's separator)
19
+ * otherwise → ExpressionTypeSelector + ExpressionView (with field-type filtering)
20
+ */
21
+ declare const FunctionArgInput: ({ argDef, value, onChange, path, slotLabel, }: Props) => import("react/jsx-runtime").JSX.Element;
22
+ export default FunctionArgInput;
@@ -0,0 +1,7 @@
1
+ import type { ExpressionNode, FunctionCallNode } from '../../ast.js';
2
+ interface Props {
3
+ fn: FunctionCallNode;
4
+ onChange?: (exp?: ExpressionNode) => void;
5
+ }
6
+ declare const FunctionView: ({ fn, onChange }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ export default FunctionView;
@@ -0,0 +1,20 @@
1
+ import type { ExpressionNode, ListNode, ValueType } from '../../ast.js';
2
+ import type { Table, TableColumn } from '../../schema.js';
3
+ interface Props {
4
+ list: ListNode;
5
+ onChange?: (exp?: ExpressionNode) => void;
6
+ /** What its values are: what IN compares with, when that's known. */
7
+ valueType?: ValueType;
8
+ /** The column IN compares with, when known: its options, a host's input. */
9
+ column?: {
10
+ table: Table;
11
+ column: TableColumn;
12
+ };
13
+ /** After a type badge: joined to it on the left. */
14
+ grouped?: boolean;
15
+ }
16
+ /** IN's values (issue 130): the kit's ListInput when it has one — else a
17
+ * chip each, then an input of their type to add one (below), as with a
18
+ * host's own input for the column (renderValueInput). */
19
+ declare const ListView: (props: Props) => import("react/jsx-runtime").JSX.Element;
20
+ export default ListView;
@@ -0,0 +1,23 @@
1
+ import type { ExpressionNode, LiteralNode, ValueType } from '../../ast.js';
2
+ import type { Table, TableColumn } from '../../schema.js';
3
+ interface Props {
4
+ className?: string;
5
+ grouped?: boolean;
6
+ /** What this value is (issue 130): what it's compared with, when that's
7
+ * known — else its own type (see literalValueType). Picks the input. */
8
+ valueType?: ValueType;
9
+ literal: LiteralNode;
10
+ onChange?: (exp?: ExpressionNode) => void;
11
+ /** The column this value is compared against, when known — enables the
12
+ * host's custom input (renderValueInput) and option dropdowns. */
13
+ column?: {
14
+ table: Table;
15
+ column: TableColumn;
16
+ };
17
+ /** Whether a text value here may be marked as the empty text (the
18
+ * toggle next to it). Off where `''` means nothing, e.g. after IN or
19
+ * LIKE. Default true. */
20
+ allowEmpty?: boolean;
21
+ }
22
+ declare const LiteralView: ({ className, grouped, valueType, literal, onChange, column, allowEmpty, }: Props) => import("react/jsx-runtime").JSX.Element;
23
+ export default LiteralView;
@@ -0,0 +1,9 @@
1
+ import type { ExpressionNode, LogicalNode } from '../../ast.js';
2
+ interface Props {
3
+ className?: string;
4
+ logical: LogicalNode;
5
+ onChange?: (exp?: ExpressionNode) => void;
6
+ renderSubComponent?: (name: string, component: React.ReactNode) => React.ReactNode;
7
+ }
8
+ declare const LogicalView: ({ className, logical, onChange, renderSubComponent, }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export default LogicalView;
@@ -0,0 +1,21 @@
1
+ import type { ExpressionNode } from '../../ast.js';
2
+ import type { MeasureFact } from '../../measures.js';
3
+ /** A SELECT column's way to a measure from another table (see measures.ts):
4
+ * whether the query is grouped (a measure is per group), its facts —
5
+ * worked out only once asked for — and what picking one adds. */
6
+ export interface MeasureChoice {
7
+ grouped: boolean;
8
+ facts: () => MeasureFact[];
9
+ onAdd: (table: string, value: ExpressionNode) => void;
10
+ }
11
+ interface Props {
12
+ anchor: HTMLElement;
13
+ choice: MeasureChoice;
14
+ onClose: () => void;
15
+ }
16
+ /** The steps after "Measure from…", where the type menu was: the table —
17
+ * each one that can't be a measure here greyed out, saying why — then
18
+ * what to sum up of it (its rows counted, or an aggregate of a number
19
+ * column). */
20
+ declare const MeasureMenu: ({ anchor, choice, onClose }: Props) => import("react/jsx-runtime").JSX.Element;
21
+ export default MeasureMenu;
@@ -0,0 +1,13 @@
1
+ import type { ExpressionNode, ParamNode } from '../../ast.js';
2
+ interface Props {
3
+ param: ParamNode;
4
+ onChange?: (exp?: ExpressionNode) => void;
5
+ /** Visually joined to the type badge on its left. */
6
+ grouped?: boolean;
7
+ }
8
+ /** A named param (`{ type: 'param', name }`): a value given when the query
9
+ * is run (astToParameterizedSql's / astToSql's `values`), not stored in
10
+ * it. Its name is edited here — kept to letters, digits and `_`, since it
11
+ * goes into the SQL as `:name` — and shown as `:name` in read-only mode. */
12
+ declare const ParamView: ({ param, onChange, grouped }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ export default ParamView;
@@ -0,0 +1,15 @@
1
+ import type { ExpressionNode, ParamNode, RelativeDate } from '../../ast.js';
2
+ interface Props {
3
+ param: ParamNode & {
4
+ relative: RelativeDate;
5
+ };
6
+ onChange?: (exp?: ExpressionNode) => void;
7
+ grouped?: boolean;
8
+ }
9
+ /** A relative date (issue 140): a param recording what the report's author
10
+ * means — "30 days ago", "the start of last month" — whose value the
11
+ * application gives when the query runs. Picked from presets, or made
12
+ * ("Custom…") as a number, a unit, a direction and a day of that unit.
13
+ * Its param name follows its meaning (relativeParamName). */
14
+ declare const RelativeDateView: ({ param, onChange, grouped }: Props) => import("react/jsx-runtime").JSX.Element;
15
+ export default RelativeDateView;
@@ -0,0 +1,8 @@
1
+ import type { SubqueryNode } from '../../ast.js';
2
+ /** IN's sub query on the canvas: what it selects, from where, and a button
3
+ * that opens its canvas (also read-only, to look at) — the one a sub
4
+ * query in FROM has. */
5
+ declare const SubqueryView: ({ node }: {
6
+ node: SubqueryNode;
7
+ }) => import("react/jsx-runtime").JSX.Element;
8
+ export default SubqueryView;
@@ -0,0 +1,8 @@
1
+ import type { FormulaRole } from '../../formula.js';
2
+ /** Each part of a formula coloured by its role (issue 131). */
3
+ declare const FORMULA_CLASSES: Record<FormulaRole, string>;
4
+ /** The same, on a panel of the canvas (the outline, issue 131) rather than
5
+ * in a field card: in the canvas's colours, as its nodes draw these. A
6
+ * param keeps its pill, as ParamView draws it. */
7
+ export declare const PANEL_FORMULA_CLASSES: Record<FormulaRole, string>;
8
+ export default FORMULA_CLASSES;
@@ -0,0 +1,5 @@
1
+ import { type Node, type NodeProps } from '@xyflow/react';
2
+ import type { CaseBranchNodeData } from '../../expressionFlow.js';
3
+ type CaseBranchFlowNodeType = Node<CaseBranchNodeData>;
4
+ declare const CaseBranchFlowNode: ({ data }: NodeProps<CaseBranchFlowNodeType>) => import("react/jsx-runtime").JSX.Element;
5
+ export default CaseBranchFlowNode;
@@ -0,0 +1,5 @@
1
+ import { type Node, type NodeProps } from '@xyflow/react';
2
+ import type { CaseElseNodeData } from '../../expressionFlow.js';
3
+ type CaseElseFlowNodeType = Node<CaseElseNodeData>;
4
+ declare const CaseElseFlowNode: ({ data }: NodeProps<CaseElseFlowNodeType>) => import("react/jsx-runtime").JSX.Element;
5
+ export default CaseElseFlowNode;
@@ -0,0 +1,5 @@
1
+ import { type Node, type NodeProps } from '@xyflow/react';
2
+ import type { CaseNodeData } from '../../expressionFlow.js';
3
+ type CaseFlowNodeType = Node<CaseNodeData>;
4
+ declare const CaseFlowNode: ({ data }: NodeProps<CaseFlowNodeType>) => import("react/jsx-runtime").JSX.Element;
5
+ export default CaseFlowNode;
@@ -0,0 +1,5 @@
1
+ import type { Node, NodeProps } from '@xyflow/react';
2
+ import type { ConditionNodeData } from '../../expressionFlow.js';
3
+ type ConditionFlowNodeType = Node<ConditionNodeData>;
4
+ declare const ConditionFlowNode: ({ id, data }: NodeProps<ConditionFlowNodeType>) => import("react/jsx-runtime").JSX.Element;
5
+ export default ConditionFlowNode;
@@ -0,0 +1,14 @@
1
+ import { type Node, type NodeProps } from '@xyflow/react';
2
+ import type { FlowDirection } from '../../expressionFlow.js';
3
+ export interface CreateConditionFlowNodeData extends Record<string, unknown> {
4
+ onCreateCondition: () => void;
5
+ direction: FlowDirection;
6
+ }
7
+ type CreateConditionFlowNodeType = Node<CreateConditionFlowNodeData>;
8
+ /** The "+" create-condition button, as its own ReactFlow node connected to
9
+ * FROM by an edge (see FlowCanvas.tsx's `mainPipeline` prop) — stands in for
10
+ * the WHERE root until one exists, at which point FlowCanvas swaps this node
11
+ * out for the real WHERE tree instead. Not user-draggable as a whole node —
12
+ * see where it's constructed in FlowCanvas.tsx. */
13
+ declare const CreateConditionFlowNode: ({ data }: NodeProps<CreateConditionFlowNodeType>) => import("react/jsx-runtime").JSX.Element;
14
+ export default CreateConditionFlowNode;
@@ -0,0 +1,11 @@
1
+ import { type Node, type NodeProps } from '@xyflow/react';
2
+ export interface CreateHavingFlowNodeData extends Record<string, unknown> {
3
+ onCreateHaving: () => void;
4
+ }
5
+ type CreateHavingFlowNodeType = Node<CreateHavingFlowNodeData>;
6
+ /** The "+" that starts HAVING: hangs off Group Rows where HAVING's tree
7
+ * will (see FlowCanvas), its edge coming into its top, and gives way to
8
+ * the tree once there is one — like the "+" that stands in for WHERE's
9
+ * root. Never shown in read-only mode. */
10
+ declare const CreateHavingFlowNode: ({ data }: NodeProps<CreateHavingFlowNodeType>) => import("react/jsx-runtime").JSX.Element;
11
+ export default CreateHavingFlowNode;
@@ -0,0 +1,10 @@
1
+ /** "Leave out duplicate rows", a checkbox-style toggle: SELECT's DISTINCT,
2
+ * and a free-form union's UNION (issue 153) — one look for both. No
3
+ * tooltip: one would replace the label as its accessible name.
4
+ * `className` places it. */
5
+ declare const DistinctToggle: ({ on, onToggle, className }: {
6
+ on: boolean;
7
+ onToggle: () => void;
8
+ className?: string;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ export default DistinctToggle;