@nongt/visql 0.8.0 → 0.10.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 (48) hide show
  1. package/README.md +23 -360
  2. package/dist/{MuiTimePicker-BjywwrRm.js → MuiTimePicker-DRqT6ByZ.js} +1 -1
  3. package/dist/PipelineEditor-Ch_i6OAc.js +10537 -0
  4. package/dist/core.js +339 -78
  5. package/dist/explain.js +356 -0
  6. package/dist/index.js +119 -100
  7. package/dist/issueLocation-Y1iaP_Cs.js +1108 -0
  8. package/dist/mui-date-pickers-host.js +1 -1
  9. package/dist/mui-date-pickers.js +1 -1
  10. package/dist/mui.js +95 -84
  11. package/dist/params-kc6eNrpu.js +2223 -0
  12. package/dist/{schema-DFC26AhZ.js → schema-KDJ1rpG5.js} +334 -271
  13. package/dist/sql-import.js +1 -1
  14. package/dist/sqlGen-Crgheqys.js +903 -0
  15. package/dist/style.css +1 -1
  16. package/dist/tokens-DV5rTGMj.js +171 -0
  17. package/dist/types/core/components/flow/NodeActionFrame.d.ts +20 -0
  18. package/dist/types/core/components/flow/useNodeActions.d.ts +18 -0
  19. package/dist/types/core/existsMenu.d.ts +4 -3
  20. package/dist/types/core/i18n/defaultMessages.d.ts +15 -0
  21. package/dist/types/core/i18n/messages.d.ts +11 -0
  22. package/dist/types/core/pipelineFlow.d.ts +1 -1
  23. package/dist/types/core/planFindings.d.ts +27 -0
  24. package/dist/types/core/queryHelpers.d.ts +1 -1
  25. package/dist/types/core/schema.d.ts +68 -24
  26. package/dist/types/core/scopeQuery.d.ts +2 -2
  27. package/dist/types/core/theme/appearance.d.ts +27 -0
  28. package/dist/types/core/theme/looks.d.ts +14 -0
  29. package/dist/types/core/theme/tokens.d.ts +9 -1
  30. package/dist/types/core-api.d.ts +2 -1
  31. package/dist/types/explain/explainQuery.d.ts +59 -0
  32. package/dist/types/explain/mySqlPlan.d.ts +4 -0
  33. package/dist/types/explain/planPlaces.d.ts +27 -0
  34. package/dist/types/explain/postgresPlan.d.ts +4 -0
  35. package/dist/types/explain/sqlServerPlan.d.ts +4 -0
  36. package/dist/types/explain/xml.d.ts +7 -0
  37. package/dist/types/explain.d.ts +2 -0
  38. package/dist/types/features/queryEditor/CanvasBackground.d.ts +2 -0
  39. package/dist/types/features/queryEditor/ExplainButton.d.ts +13 -0
  40. package/dist/types/features/queryEditor/IssuesButton.d.ts +14 -6
  41. package/dist/types/features/queryEditor/PipelineEditor.d.ts +15 -0
  42. package/dist/types/features/queryEditor/planText.d.ts +8 -0
  43. package/dist/types/index.d.ts +2 -0
  44. package/package.json +14 -1
  45. package/dist/PipelineEditor-DtT1TPgd.js +0 -10214
  46. package/dist/core-api-jaQDPXVK.js +0 -1171
  47. package/dist/issueLocation-DEIwB1DW.js +0 -3290
  48. package/dist/tokens-BTaVMSOx.js +0 -95
@@ -16,6 +16,12 @@ export interface Table {
16
16
  description?: string;
17
17
  /** Anything the host's own code needs about the table. Never read here. */
18
18
  meta?: unknown;
19
+ /** false: joined only as the table asked for, never as a step on the way
20
+ * to another, and never the table a new join is tied to while the query
21
+ * has another to tie it to. For a table every other one references only
22
+ * to be scoped by (a tenant, a store): `a → tenant → b` pairs every `a`
23
+ * with every `b` of the same tenant. Default true. */
24
+ passThrough?: boolean;
19
25
  }
20
26
  export interface TableColumn {
21
27
  name: string;
@@ -103,34 +109,72 @@ export declare function relationsForTable(schema: DatabaseSchema, tableName: str
103
109
  * (`fromTable`), so callers never need to know which side is "many". When
104
110
  * several keys connect the same two tables, the first declared wins. */
105
111
  export declare function findRelation(schema: DatabaseSchema, tableA: string, tableB: string): Relation | undefined;
106
- /** Shortest chain of tables connecting `target` to any of `existingTables`
107
- * through the relation graph (walked in both directions), as the tables that
108
- * would need to be added — in join order, intermediates first, ending with
109
- * `target` itself. e.g. from [sale_transaction] to product_category that's
110
- * [product, product_category]: product_category has no relation to
111
- * sale_transaction directly, only through product. Breadth-first from every
112
- * existing table at once (seeded in `existingTables` order, neighbours in
113
- * `relations` order), so the result is deterministic and never longer than
114
- * needed. Returns [] when `target` is already present, undefined when
115
- * nothing connects it. */
116
- export declare function findJoinPath(schema: DatabaseSchema, existingTables: string[], target: string): string[] | undefined;
117
- /** Every table the relation graph (walked in both directions) reaches from
118
- * `existingTables`, them included — what findJoinPath finds a path to,
119
- * for all tables in one walk. */
120
- export declare function reachableTables(schema: DatabaseSchema, existingTables: string[]): Set<string>;
112
+ /** How findJoinPath and reachableTables may walk the relations. */
113
+ export interface JoinPathOptions {
114
+ /** Walk any path. By default a path never takes a one-to-many step
115
+ * (down: from a relation's `toTable` to its `fromTable`) after a
116
+ * many-to-one step (up), counting how the query's own tables were
117
+ * reached: `hours → employee → punch` pairs each hours row with every
118
+ * punch of its employee, on any day. A path is up only, or down and then
119
+ * up. scopeQuery walks any path: a rule can go up to a tenant and down to
120
+ * who may see it. */
121
+ anyShape?: boolean;
122
+ /** reachableTables: tables neither reached nor walked through. */
123
+ skip?: ReadonlySet<string>;
124
+ }
125
+ /** findJoinPath's path, with the table of the query it starts from. */
126
+ export declare function joinRoute(schema: DatabaseSchema, existingTables: string[], target: string, options?: JoinPathOptions): {
127
+ start: string;
128
+ tables: string[];
129
+ } | undefined;
130
+ /** The chain of tables connecting `target` to any of `existingTables`
131
+ * through the relation graph (walked in both directions), as the tables
132
+ * that would need to be added, in join order, intermediates first, ending
133
+ * with `target` itself. e.g. from [sale_transaction] to product_category
134
+ * that's [product, product_category]: product_category has no relation to
135
+ * sale_transaction directly, only through product.
136
+ *
137
+ * Of all the chains, the one with the fewest fan-out steps, then the
138
+ * fewest steps (issue 6). A fan-out step walks a relation from its `toTable`
139
+ * to its `fromTable`, one row to many, which repeats the rows before it.
140
+ * None comes after a step the other way, unless `options.anyShape`
141
+ * (JoinPathOptions). Ties go the way a breadth-first walk would: seeded in
142
+ * `existingTables` order, neighbours in `relations` order, so the result
143
+ * is deterministic. A table with `passThrough: false` is never a step (see
144
+ * startsOf for where it may start). Returns [] when `target` is already
145
+ * present, undefined when nothing connects it. */
146
+ export declare function findJoinPath(schema: DatabaseSchema, existingTables: string[], target: string, options?: JoinPathOptions): string[] | undefined;
147
+ /** Every table the relation graph reaches from `existingTables`, them
148
+ * included: what findJoinPath finds a path to, for all tables in one walk.
149
+ * A table with `passThrough: false` is reached, but nothing past it. */
150
+ export declare function reachableTables(schema: DatabaseSchema, existingTables: string[], options?: JoinPathOptions): Set<string>;
121
151
  export interface JoinSuggestion {
122
152
  joinType: JoinType;
123
153
  on: ExpressionNode;
124
154
  }
125
- /** Suggests a join type + ON condition for adding `newTable` alongside the tables
126
- * already in the pipeline, using the relation graph. Tries each existing table in
127
- * order (base table first, then join-insertion order) — first relation found wins,
128
- * so the result is deterministic. `joinType` defaults to 'left' when the relation's
129
- * FK column (`fromColumn`) is nullable (e.g. sale_transaction.promotion_id — an INNER
130
- * join there would silently drop unpromoted sales) and 'inner' otherwise, read
131
- * directly off the column's own `nullable` flag rather than hardcoded per-relation.
132
- * Returns undefined if no relation connects `newTable` to anything already present. */
133
- export declare function suggestJoin(schema: DatabaseSchema, existingTables: string[], newTable: string): JoinSuggestion | undefined;
155
+ export interface SuggestJoinOptions {
156
+ /** The table before `newTable` on its join path (joinRoute): the join is
157
+ * tied to it, when they're related, rather than to the first table of
158
+ * the query that is. */
159
+ after?: string;
160
+ /** The query's tables on the optional side of a LEFT or FULL join. A
161
+ * join tied to one of them is LEFT too, whatever its key: an INNER join
162
+ * there would drop the rows the LEFT join kept. */
163
+ leftJoined?: string[];
164
+ }
165
+ /** Suggests a join type + ON condition for adding `newTable` alongside the
166
+ * tables already in the pipeline, using the relation graph. Tied to
167
+ * `options.after` when it's related; else tries each existing table in
168
+ * order (base table first, then join-insertion order) and the first
169
+ * relation found wins, so the result is deterministic. A table with
170
+ * `passThrough: false` is tried only for itself, or when the query has no
171
+ * other table (startsOf). `joinType` is 'left' when the relation's FK
172
+ * column (`fromColumn`) is nullable (e.g. sale_transaction.promotion_id:
173
+ * an INNER join there would silently drop unpromoted sales) or the table
174
+ * it's tied to is in `options.leftJoined`, and 'inner' otherwise. Returns
175
+ * undefined if no relation connects `newTable` to anything already
176
+ * present. */
177
+ export declare function suggestJoin(schema: DatabaseSchema, existingTables: string[], newTable: string, options?: SuggestJoinOptions): JoinSuggestion | undefined;
134
178
  export type SchemaIssueKind = 'duplicateTable' | 'duplicateColumn' | 'unknownTable' | 'unknownColumn' | 'duplicateRelation' | 'invalidFormat';
135
179
  export interface SchemaIssue {
136
180
  kind: SchemaIssueKind;
@@ -4,10 +4,10 @@ import { type DatabaseSchema } from './schema.js';
4
4
  /** What must be scoped, and how. */
5
5
  export interface ScopeRule {
6
6
  /** The schema tables that must be scoped (e.g. every fact carrying a
7
- * facility), by name. */
7
+ * branch), by name. */
8
8
  requires: (table: string) => boolean;
9
9
  /** The condition, naming tables every scoped table reaches through the
10
- * relations (the facility dimension, say) — params rather than values. */
10
+ * relations (the branch dimension, say) — params rather than values. */
11
11
  condition: ExpressionNode;
12
12
  }
13
13
  /** A query body that reads a table needing scope but can't reach the
@@ -0,0 +1,27 @@
1
+ import type { DefaultEdgeOptions } from '@xyflow/react';
2
+ /** The parts of the editor's look that aren't colours or sizes (those are
3
+ * theme tokens): what has to reach React Flow as a prop, or changes how
4
+ * the editor behaves. */
5
+ export interface Appearance {
6
+ /** The edges' shape, on every canvas. */
7
+ edges: 'smoothstep' | 'bezier' | 'step' | 'straight';
8
+ /** The canvas's pattern. */
9
+ background: 'lines' | 'dots' | 'cross' | 'none';
10
+ /** The pattern's spacing, in px. */
11
+ backgroundGap: number;
12
+ /** A group's backdrop: a box around its conditions, or a bar on its
13
+ * leading edge. */
14
+ groupFrame: 'box' | 'bar';
15
+ /** A node's buttons: in a toolbar above it while it's pointed at
16
+ * (selected, on a touch screen), and a row's while it's pointed at; or
17
+ * always beside them. */
18
+ actions: 'hover' | 'always';
19
+ }
20
+ /** CHARCOAL's (looks.ts). */
21
+ export declare const DEFAULT_APPEARANCE: Appearance;
22
+ declare const AppearanceContext: import("react").Context<Appearance>;
23
+ export declare function useAppearance(): Appearance;
24
+ export default AppearanceContext;
25
+ /** The edge shape asked for, as React Flow's `defaultEdgeOptions` (its
26
+ * bezier is called 'default'). */
27
+ export declare function useEdgeOptions(): DefaultEdgeOptions;
@@ -0,0 +1,14 @@
1
+ import { type Appearance } from './appearance.js';
2
+ import { type QueryBuilderTheme } from './tokens.js';
3
+ /** A whole look, colours and the rest: `<QueryBuilder {...NAVY} />`. A host
4
+ * makes its own the same way. */
5
+ export interface Look {
6
+ theme: QueryBuilderTheme;
7
+ appearance: Appearance;
8
+ }
9
+ /** The default: charcoal panels, white field cards, curved edges on dots,
10
+ * buttons beside each node. */
11
+ export declare const CHARCOAL: Look;
12
+ /** Navy panels, dark field cards and mint; smooth-step edges on a line grid,
13
+ * groups as a bar, and a node's buttons in a toolbar shown on hover. */
14
+ export declare const NAVY: Look;
@@ -1,6 +1,7 @@
1
1
  /** Every color the editor draws with, named by role rather than by hue so a
2
2
  * host can recolor the editor freely (a light theme is just different
3
- * values for the same roles). The defaults reproduce the original dark look.
3
+ * values for the same roles), and a few shapes (radii, the edges' width).
4
+ * The defaults are CHARCOAL's (looks.ts).
4
5
  *
5
6
  * Each token becomes a CSS custom property on the editor root — `canvasBg`
6
7
  * → `--qb-canvas-bg` — which components use through Tailwind utilities
@@ -39,6 +40,7 @@ export declare const DEFAULT_THEME: {
39
40
  fieldTextMuted: string;
40
41
  fieldTextSubtle: string;
41
42
  fieldGroupBorder: string;
43
+ fieldCardBorder: string;
42
44
  conditional: string;
43
45
  conditionalOnField: string;
44
46
  conditionalBorder: string;
@@ -53,9 +55,15 @@ export declare const DEFAULT_THEME: {
53
55
  secondary: string;
54
56
  danger: string;
55
57
  warning: string;
58
+ nodeRadius: string;
59
+ fieldRadius: string;
60
+ groupRadius: string;
61
+ edgeWidth: string;
56
62
  };
57
63
  export type ThemeToken = keyof typeof DEFAULT_THEME;
58
64
  export type QueryBuilderTheme = Record<ThemeToken, string>;
65
+ /** NAVY's colours (`looks.ts`): navy panels, dark field cards, mint. */
66
+ export declare const NAVY_THEME: QueryBuilderTheme;
59
67
  /** Class the editor root carries — tokens are scoped to it, so they never
60
68
  * leak into (or read from) the host page outside the editor. */
61
69
  export declare const ROOT_CLASS = "qb-root";
@@ -14,7 +14,8 @@ export { relativeDateLabel } from './core/relativeDates.js';
14
14
  export { QUERY_FORMAT_VERSION, QueryFormatError, loadQuery, saveQuery, type StoredQuery, } from './core/storedQuery.js';
15
15
  export type { ResolveName } from './core/resolveNames.js';
16
16
  export { astToParameterizedSql, astToSql, DIALECTS, DIALECT_LABELS, type NullSafeEqual, type ParameterizedSql, type ParameterizedSqlOptions, type SqlDialect, } from './core/sqlGen.js';
17
- export { EMPTY_SCHEMA, filterSchema, validateSchema, type DatabaseColumnType, type DatabaseSchema, type ColumnOption, type Relation, type SchemaIssue, type SchemaIssueKind, type Table, type TableColumn, type TableGroup, } from './core/schema.js';
17
+ export { EMPTY_SCHEMA, filterSchema, validateSchema, type DatabaseColumnType, type DatabaseSchema, type ColumnOption, type Relation, findJoinPath, reachableTables, suggestJoin, type JoinPathOptions, type JoinSuggestion, type SuggestJoinOptions, type SchemaIssue, type SchemaIssueKind, type Table, type TableColumn, type TableGroup, } from './core/schema.js';
18
18
  export { QUERY_ISSUE_KINDS, QUERY_WARNING_KINDS, validateQuery, type QueryIssue, type QueryIssueKind, type QueryWarningKind, type QueryIssueSeverity, type ValidateQueryOptions, } from './core/queryValidation.js';
19
+ export type { OnExplain, PlanFinding, PlanFindingKind } from './core/planFindings.js';
19
20
  export { default as issueLocation, type IssueLocationStep } from './core/issueLocation.js';
20
21
  export { DEFAULT_FUNCTIONS, functionsForDialect, type ArgDef, type ArgKind, type FunctionRegistry, type FunctionSignature, } from './core/functionRegistry.js';
@@ -0,0 +1,59 @@
1
+ import type { PlanFinding } from '../core/planFindings.js';
2
+ import type { QueryPipeline } from '../core/queryAst.js';
3
+ import { type ScopeRule } from '../core/scopeQuery.js';
4
+ import { type ParameterizedSqlOptions } from '../core/sqlGen.js';
5
+ /** The databases whose plans can be read. */
6
+ export type ExplainDialect = 'postgres' | 'mssql' | 'mysql';
7
+ export interface ExplainOptions extends ParameterizedSqlOptions {
8
+ /** The rule the query runs under (see scopeQuery), so the plan is the
9
+ * one the query really gets. Needs `schema`. */
10
+ scope?: ScopeRule;
11
+ }
12
+ export interface PlanReadOptions {
13
+ /** How many rows each table has, by its name in the database, e.g. from
14
+ * `SELECT relname, reltuples FROM pg_class`. A PostgreSQL plan only
15
+ * gives the rows a scan returns, after its filter: with the sizes, a big
16
+ * table read whole for a few rows is reported as a missing index. SQL
17
+ * Server's plan has them itself. */
18
+ tableRows?: Record<string, number> | ((table: string) => number | undefined);
19
+ /** Below this many rows, nothing is reported. Default 10,000. */
20
+ minRows?: number;
21
+ }
22
+ export interface ExplainedQuery {
23
+ /** SQL Server: run on the same connection before `sql`, as a batch of
24
+ * its own, and `after` once the plan is back. */
25
+ before?: string;
26
+ /** The statement to run, EXPLAIN included, with `params` bound. */
27
+ sql: string;
28
+ params: unknown[];
29
+ after?: string;
30
+ /** What the plan EXPLAIN gave says, on the parts of the query given to
31
+ * explainQuery. Takes the plan as the driver returns it (PostgreSQL:
32
+ * rows with a `QUERY PLAN` column; SQL Server: the showplan's row) or as
33
+ * its JSON or XML text. */
34
+ findings: (plan: unknown, options?: PlanReadOptions) => PlanFinding[];
35
+ }
36
+ /** A table, sub query or shared query's place in the query, under the name
37
+ * the explained SQL gives it. */
38
+ export interface Place {
39
+ /** Where it is: its FROM or join. */
40
+ path: (string | number)[];
41
+ /** Where the query body it's in is. */
42
+ body: (string | number)[];
43
+ /** Its schema table, for a table. */
44
+ table?: string;
45
+ }
46
+ /** `query` with every table, sub query and shared query's place named
47
+ * apart, and where each new name leads. Innermost bodies first: an
48
+ * EXISTS sees the names around it, so a name left in it after its own are
49
+ * renamed is the outer one, and renaming the outer body reaches it. */
50
+ export declare function namePlaces(query: QueryPipeline): {
51
+ named: QueryPipeline;
52
+ places: Map<string, Place>;
53
+ };
54
+ /** The statement to explain `query` with, and a reader for the plan it
55
+ * gives. Call it as you'd write the query's SQL to run it: on the checked
56
+ * query, with the same options (and `scope`, the rule it runs under), so
57
+ * the plan is the one it really gets. The findings are on `query` itself,
58
+ * the parts a user sees in the editor. */
59
+ export declare function explainQuery(query: QueryPipeline, dialect: ExplainDialect, options?: ExplainOptions): ExplainedQuery;
@@ -0,0 +1,4 @@
1
+ import type { PlanFinding } from '../core/planFindings.js';
2
+ import { type ReadContext } from './planPlaces.js';
3
+ /** What `plan` says about the query `context.named` was named from. */
4
+ export default function readMySqlPlan(plan: unknown, context: ReadContext): PlanFinding[];
@@ -0,0 +1,27 @@
1
+ import type { PlanFinding } from '../core/planFindings.js';
2
+ import type { QueryPipeline } from '../core/queryAst.js';
3
+ import type { ResolveName } from '../core/resolveNames.js';
4
+ import type { Place, PlanReadOptions } from './explainQuery.js';
5
+ export interface ReadContext extends PlanReadOptions {
6
+ places: Map<string, Place>;
7
+ named: QueryPipeline;
8
+ resolveName?: ResolveName;
9
+ }
10
+ /** What's at `path` in the query: a body the walk over it found. */
11
+ export declare const valueAt: (root: unknown, path: (string | number)[]) => unknown;
12
+ /** A table's size from `tableRows`, by its name in the database. A
13
+ * negative one (PostgreSQL's reltuples before ANALYZE) is not known. */
14
+ export declare function sizeOf(context: ReadContext, relation: string): number | undefined;
15
+ /** The columns of the table at `place` (named `alias`) its body's WHERE
16
+ * compares, as the query names them, among those the plan names (`named`,
17
+ * by their SQL names), and where they're compared. None: undefined. */
18
+ export declare function compared(alias: string, place: Place, context: ReadContext, named: (sqlName: string) => boolean): {
19
+ columns: string[];
20
+ path: (string | number)[];
21
+ } | undefined;
22
+ /** Where a sort of rows from `place` shows in the query: its body's GROUP
23
+ * BY for a sort for grouping, else its ORDER BY. A sort the query doesn't
24
+ * ask for (a merge join's, DISTINCT's): undefined. */
25
+ export declare function sortClause(place: Place, context: ReadContext, grouping: boolean): (string | number)[] | undefined;
26
+ /** One finding per kind and place: a table read twice is one fix. */
27
+ export declare function onePerPlace(findings: PlanFinding[]): PlanFinding[];
@@ -0,0 +1,4 @@
1
+ import type { PlanFinding } from '../core/planFindings.js';
2
+ import { type ReadContext } from './planPlaces.js';
3
+ /** What `plan` says about the query `context.named` was named from. */
4
+ export default function readPostgresPlan(plan: unknown, context: ReadContext): PlanFinding[];
@@ -0,0 +1,4 @@
1
+ import type { PlanFinding } from '../core/planFindings.js';
2
+ import { type ReadContext } from './planPlaces.js';
3
+ /** What `plan` says about the query `context.named` was named from. */
4
+ export default function readSqlServerPlan(plan: unknown, context: ReadContext): PlanFinding[];
@@ -0,0 +1,7 @@
1
+ export interface XmlElement {
2
+ name: string;
3
+ attributes: Record<string, string>;
4
+ children: XmlElement[];
5
+ }
6
+ /** The document's root element. */
7
+ export default function parseXml(text: string): XmlElement | undefined;
@@ -0,0 +1,2 @@
1
+ export { explainQuery, type ExplainDialect, type ExplainedQuery, type ExplainOptions, type PlanReadOptions, } from './explain/explainQuery.js';
2
+ export type { PlanFinding, PlanFindingKind } from './core/planFindings.js';
@@ -0,0 +1,2 @@
1
+ /** A canvas's backdrop, in the pattern `appearance` asks for. */
2
+ export default function CanvasBackground(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ interface Props {
2
+ onExplain: () => void;
3
+ checking: boolean;
4
+ /** Why it can't check now, if it can't (shown as its tooltip). */
5
+ blocked?: string;
6
+ /** What the host's onExplain threw last time. */
7
+ failed?: string;
8
+ }
9
+ /** Asks the host for the query plan's findings (`onExplain`), in the bar
10
+ * above the canvas. Only ever when pressed: EXPLAIN is a round trip to the
11
+ * database. Off, with the reason, while the query can't run. */
12
+ declare const ExplainButton: ({ onExplain, checking, blocked, failed, }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ export default ExplainButton;
@@ -1,3 +1,4 @@
1
+ import type { PlanFinding } from '../../core/planFindings.js';
1
2
  import type { QueryPipeline } from '../../core/queryAst.js';
2
3
  import type { QueryIssue } from '../../core/queryValidation.js';
3
4
  interface Props {
@@ -6,11 +7,18 @@ interface Props {
6
7
  query?: QueryPipeline;
7
8
  /** An entry of the list was picked: show where that issue is. */
8
9
  onSelect: (issue: QueryIssue) => void;
10
+ /** What the query plan says (onExplain), listed after the warnings. */
11
+ findings?: PlanFinding[];
12
+ /** The findings are about the query before its latest edits. */
13
+ findingsOutdated?: boolean;
14
+ /** A finding was picked: show where it is. */
15
+ onSelectFinding?: (finding: PlanFinding) => void;
9
16
  }
10
- /** The query's problems, in the bar above the canvas: how many errors and
11
- * warnings (each its colour and icon). Opens their list (issue 132):
12
- * errors, then warnings, each entry by its place — a section of the
13
- * canvas, or a sub query — and saying where it is; picking one goes to
14
- * it. Nothing at all without problems. */
15
- declare const IssuesButton: ({ issues, query, onSelect }: Props) => import("react/jsx-runtime").JSX.Element | null;
17
+ /** The query's problems, in the bar above the canvas: how many errors,
18
+ * warnings and performance hints (each its colour and icon). Opens their
19
+ * list (issue 132): errors, then warnings, then what the query plan says
20
+ * (issue 186), each entry by its place — a section of the canvas, or a
21
+ * sub query — and saying where it is; picking one goes to it. Nothing at
22
+ * all without any. */
23
+ declare const IssuesButton: ({ issues, query, onSelect, findings, findingsOutdated, onSelectFinding, }: Props) => import("react/jsx-runtime").JSX.Element | null;
16
24
  export default IssuesButton;
@@ -5,6 +5,7 @@ import { type QueryValue } from '../../core/queryAst.js';
5
5
  import { type DatabaseSchema, type SchemaIssue, type Table, type TableColumn } from '../../core/schema.js';
6
6
  import type { SqlDialect } from '../../core/sqlGen.js';
7
7
  import { type QueryIssue, type QueryIssueSeverity, type QueryWarningKind } from '../../core/queryValidation.js';
8
+ import { type Appearance } from '../../core/theme/appearance.js';
8
9
  import { type TablePickerOptions } from '../../core/tablePickerOptions.js';
9
10
  import { type BetweenOnText } from '../../core/BetweenOnTextContext.js';
10
11
  import { type RenderValueInput } from '../../core/ValueInputContext.js';
@@ -14,6 +15,7 @@ import type { UIComponents } from '../../core/ui/types.js';
14
15
  import { type QueryBuilderTheme } from '../../core/theme/tokens.js';
15
16
  import type { SectionLabels } from './sectionLabels.js';
16
17
  import { type OnRun } from './run.js';
18
+ import type { OnExplain } from '../../core/planFindings.js';
17
19
  export interface PipelineEditorProps {
18
20
  className?: string;
19
21
  /** The database the builder works against — its tables/columns populate
@@ -95,6 +97,9 @@ export interface PipelineEditorProps {
95
97
  * open), but nothing can be changed — no edit controls, inputs disabled,
96
98
  * no dragging, no undo/redo. */
97
99
  readOnly?: boolean;
100
+ /** How the outline in the corner starts: 'open' (default), or 'folded'
101
+ * to its title, for a small editor. The user can fold it either way. */
102
+ outline?: 'open' | 'folded';
98
103
  /** Which tables this user may see and add. Hidden tables are never
99
104
  * offered in pickers nor added automatically (not even as an
100
105
  * intermediate join); relations through them are ignored. The full
@@ -117,6 +122,11 @@ export interface PipelineEditorProps {
117
122
  * Rows — for a tall, narrow space. Combines with `direction`, which says
118
123
  * which side things start from. */
119
124
  orientation?: FlowOrientation;
125
+ /** How the canvases look beyond colours: edge shape, canvas pattern, how
126
+ * a group is drawn, where a node's buttons are. Unset parts keep
127
+ * `DEFAULT_APPEARANCE`'s (CHARCOAL's); a whole look such as NAVY sets
128
+ * this and `theme` together. */
129
+ appearance?: Partial<Appearance>;
120
130
  /** The EXISTS button ("has related rows"): which related tables its menu
121
131
  * lists (`relations`: 'toMany', the default, or 'both') and where it's
122
132
  * offered (`in`: ['where', 'having'] by default, 'joinOn' when asked
@@ -157,6 +167,11 @@ export interface PipelineEditorProps {
157
167
  * server. Return (or resolve to) a RunResult to show its rows under the
158
168
  * canvas; return nothing to show them yourself. See OnRun. */
159
169
  onRun?: OnRun;
170
+ /** Gets what the query plan (EXPLAIN) says about the query: a "Check
171
+ * performance" button above the canvas calls it, and the findings join the
172
+ * problems list, after the warnings. Gets the query, not SQL, like onRun.
173
+ * See OnExplain and PlanFinding. */
174
+ onExplain?: OnExplain;
160
175
  /** Warnings not to show, by kind (see QUERY_WARNING_KINDS) — in the
161
176
  * problems list, `onIssues` and on the canvas (the FROM node's fan-out
162
177
  * note). E.g. ['crossJoin'] for reports that CROSS JOIN on purpose.
@@ -0,0 +1,8 @@
1
+ import type { Messages } from '../../core/i18n/messages.js';
2
+ import type { PlanFinding } from '../../core/planFindings.js';
3
+ import type { QueryPipeline } from '../../core/queryAst.js';
4
+ import { type DatabaseSchema } from '../../core/schema.js';
5
+ /** A finding in the user's words: the known kinds from `messages`, naming
6
+ * the table as the canvas does (its alias, else its label); anything else
7
+ * by the host's own `message`. */
8
+ export default function planText(finding: PlanFinding, query: QueryPipeline | undefined, schema: DatabaseSchema, m: Messages): string;
@@ -11,4 +11,6 @@ export type { ExistsOptions, ExistsPlace, ExistsRelations, } from './core/exists
11
11
  export type { RenderValueInput, ValueInputProps } from './core/ValueInputContext.js';
12
12
  export { DEFAULT_MESSAGES, type Messages } from './core/i18n/messages.js';
13
13
  export { DEFAULT_THEME, type QueryBuilderTheme, type ThemeToken, } from './core/theme/tokens.js';
14
+ export { DEFAULT_APPEARANCE, type Appearance } from './core/theme/appearance.js';
15
+ export { CHARCOAL, NAVY, type Look } from './core/theme/looks.js';
14
16
  export type * from './core/ui/types.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nongt/visql",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "A visual SQL query editor for React: build a whole query on a node canvas, store it as JSON, turn it into SQL.",
5
5
  "keywords": [
6
6
  "sql",
@@ -55,6 +55,10 @@
55
55
  "types": "./dist/types/sql-import.d.ts",
56
56
  "import": "./dist/sql-import.js"
57
57
  },
58
+ "./explain": {
59
+ "types": "./dist/types/explain.d.ts",
60
+ "import": "./dist/explain.js"
61
+ },
58
62
  "./style.css": "./dist/style.css"
59
63
  },
60
64
  "typesVersions": {
@@ -76,6 +80,9 @@
76
80
  ],
77
81
  "sql-import": [
78
82
  "./dist/types/sql-import.d.ts"
83
+ ],
84
+ "explain": [
85
+ "./dist/types/explain.d.ts"
79
86
  ]
80
87
  }
81
88
  },
@@ -166,9 +173,15 @@
166
173
  "vite-plugin-istanbul": "^8.0.0",
167
174
  "vitest": "^4.1.10"
168
175
  },
176
+ "homepage": "https://nongt.github.io/visql/",
169
177
  "scripts": {
170
178
  "dev": "vite",
171
179
  "build": "tsc -b && vite build",
180
+ "site:dev": "pnpm --filter visql-site dev",
181
+ "site:build": "pnpm --filter visql-site build && vite build --base /visql/playground/ --outDir site/dist/playground --emptyOutDir --sourcemap false && node scripts/check-site.mjs",
182
+ "site:preview": "pnpm --filter visql-site preview",
183
+ "site:check": "pnpm --filter visql-site check",
184
+ "test:site": "playwright test -c playwright.site.config.ts",
172
185
  "build:lib": "vite build -c vite.lib.config.ts && tsc -p tsconfig.lib.json && node scripts/strip-dts-css.mjs && node scripts/fix-dts-extensions.mjs && node scripts/build-core-package.mjs",
173
186
  "lint": "eslint . --max-warnings 0",
174
187
  "preview": "vite preview",