@nongt/visql 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -359
- package/dist/{MuiTimePicker-BjywwrRm.js → MuiTimePicker-DRqT6ByZ.js} +1 -1
- package/dist/PipelineEditor-C10lng6j.js +10544 -0
- package/dist/core.js +336 -78
- package/dist/explain.js +165 -0
- package/dist/fixtures.js +1 -1
- package/dist/index.js +114 -98
- package/dist/issueLocation-BOSdd1JX.js +1106 -0
- package/dist/mui-date-pickers-host.js +1 -1
- package/dist/mui-date-pickers.js +1 -1
- package/dist/mui.js +95 -84
- package/dist/params-MMOdKWnW.js +2217 -0
- package/dist/{schema-DFC26AhZ.js → schema-dP_ISylQ.js} +270 -242
- package/dist/sql-import.js +613 -627
- package/dist/sqlGen-B7-2-i9V.js +903 -0
- package/dist/style.css +1 -1
- package/dist/tokens-DV5rTGMj.js +171 -0
- package/dist/types/core/ast.d.ts +1 -1
- package/dist/types/core/components/flow/NodeActionFrame.d.ts +20 -0
- package/dist/types/core/components/flow/useNodeActions.d.ts +18 -0
- package/dist/types/core/i18n/defaultMessages.d.ts +15 -0
- package/dist/types/core/i18n/messages.d.ts +11 -0
- package/dist/types/core/params.d.ts +10 -0
- package/dist/types/core/planFindings.d.ts +27 -0
- package/dist/types/core/queryHelpers.d.ts +1 -1
- package/dist/types/core/schema.d.ts +35 -20
- package/dist/types/core/scopeQuery.d.ts +2 -2
- package/dist/types/core/sqlGen.d.ts +10 -0
- package/dist/types/core/theme/appearance.d.ts +27 -0
- package/dist/types/core/theme/looks.d.ts +14 -0
- package/dist/types/core/theme/tokens.d.ts +9 -1
- package/dist/types/core-api.d.ts +3 -2
- package/dist/types/explain/explainQuery.d.ts +53 -0
- package/dist/types/explain/postgresPlan.d.ts +12 -0
- package/dist/types/explain.d.ts +2 -0
- package/dist/types/features/queryEditor/CanvasBackground.d.ts +2 -0
- package/dist/types/features/queryEditor/ExplainButton.d.ts +13 -0
- package/dist/types/features/queryEditor/IssuesButton.d.ts +14 -6
- package/dist/types/features/queryEditor/PipelineEditor.d.ts +15 -0
- package/dist/types/features/queryEditor/planText.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +14 -1
- package/dist/PipelineEditor-9-9xOJcB.js +0 -10214
- package/dist/core-api-BsEMnDQ1.js +0 -1141
- package/dist/issueLocation-732-e0B8.js +0 -3281
- 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,33 +109,42 @@ 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
|
-
/**
|
|
107
|
-
* through the relation graph (walked in both directions), as the tables
|
|
108
|
-
* would need to be added
|
|
109
|
-
* `target` itself. e.g. from [sale_transaction] to product_category
|
|
110
|
-
* [product, product_category]: product_category has no relation to
|
|
111
|
-
* sale_transaction directly, only through product.
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
112
|
+
/** The chain of tables connecting `target` to any of `existingTables`
|
|
113
|
+
* through the relation graph (walked in both directions), as the tables
|
|
114
|
+
* that would need to be added, in join order, intermediates first, ending
|
|
115
|
+
* with `target` itself. e.g. from [sale_transaction] to product_category
|
|
116
|
+
* that's [product, product_category]: product_category has no relation to
|
|
117
|
+
* sale_transaction directly, only through product.
|
|
118
|
+
*
|
|
119
|
+
* Of all the chains, the one with the fewest fan-out steps, then the
|
|
120
|
+
* fewest steps (issue 6). A fan-out step walks a relation from its `toTable`
|
|
121
|
+
* to its `fromTable`, one row to many, which repeats the rows before it.
|
|
122
|
+
* Ties go the way a breadth-first walk would: seeded in `existingTables`
|
|
123
|
+
* order, neighbours in `relations` order, so the result is deterministic.
|
|
124
|
+
* A table with `passThrough: false` is never a step (see startsOf for
|
|
125
|
+
* where it may start). Returns [] when `target` is already present,
|
|
126
|
+
* undefined when nothing connects it. */
|
|
116
127
|
export declare function findJoinPath(schema: DatabaseSchema, existingTables: string[], target: string): string[] | undefined;
|
|
117
128
|
/** Every table the relation graph (walked in both directions) reaches from
|
|
118
|
-
* `existingTables`, them included
|
|
119
|
-
*
|
|
129
|
+
* `existingTables`, them included: what findJoinPath finds a path to, for
|
|
130
|
+
* all tables in one walk. A table with `passThrough: false` is reached,
|
|
131
|
+
* but nothing past it. */
|
|
120
132
|
export declare function reachableTables(schema: DatabaseSchema, existingTables: string[]): Set<string>;
|
|
121
133
|
export interface JoinSuggestion {
|
|
122
134
|
joinType: JoinType;
|
|
123
135
|
on: ExpressionNode;
|
|
124
136
|
}
|
|
125
|
-
/** Suggests a join type + ON condition for adding `newTable` alongside the
|
|
126
|
-
* already in the pipeline, using the relation graph. Tries each
|
|
127
|
-
* order (base table first, then join-insertion order)
|
|
128
|
-
* so the result is deterministic.
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
137
|
+
/** Suggests a join type + ON condition for adding `newTable` alongside the
|
|
138
|
+
* tables already in the pipeline, using the relation graph. Tries each
|
|
139
|
+
* existing table in order (base table first, then join-insertion order);
|
|
140
|
+
* the first relation found wins, so the result is deterministic. A table
|
|
141
|
+
* with `passThrough: false` is tried only for itself, or when the query has
|
|
142
|
+
* no other table (startsOf). `joinType` defaults to 'left' when the
|
|
143
|
+
* relation's FK column (`fromColumn`) is nullable (e.g.
|
|
144
|
+
* sale_transaction.promotion_id: an INNER join there would silently drop
|
|
145
|
+
* unpromoted sales) and 'inner' otherwise, read off the column's own
|
|
146
|
+
* `nullable` flag. Returns undefined if no relation connects `newTable` to
|
|
147
|
+
* anything already present. */
|
|
133
148
|
export declare function suggestJoin(schema: DatabaseSchema, existingTables: string[], newTable: string): JoinSuggestion | undefined;
|
|
134
149
|
export type SchemaIssueKind = 'duplicateTable' | 'duplicateColumn' | 'unknownTable' | 'unknownColumn' | 'duplicateRelation' | 'invalidFormat';
|
|
135
150
|
export interface SchemaIssue {
|
|
@@ -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
|
-
*
|
|
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
|
|
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
|
|
@@ -24,6 +24,11 @@ export interface SpanMarks {
|
|
|
24
24
|
/** Writes with `marks` recording where each part goes (from the query as
|
|
25
25
|
* it's written: buildSql starts it). */
|
|
26
26
|
export declare function writeMarked<T>(marks: SpanMarks, write: () => T): T;
|
|
27
|
+
/** How `IS NOT DISTINCT FROM` is written (issue 217). `'native'`:
|
|
28
|
+
* `IS NOT DISTINCT FROM`, MySQL's `<=>`. `'expanded'`: `(a = b OR (a IS
|
|
29
|
+
* NULL AND b IS NULL))`, the same rows in any database, for SQL Server
|
|
30
|
+
* before 2022, which has no IS NOT DISTINCT FROM. */
|
|
31
|
+
export type NullSafeEqual = 'native' | 'expanded';
|
|
27
32
|
export declare function astToWhereClause(ast: ExpressionNode, dialect: SqlDialect, params?: SqlParams): string;
|
|
28
33
|
export declare function formatFromClause(from: FromClause, dialect: SqlDialect, params?: SqlParams): string;
|
|
29
34
|
export declare function formatJoinClause(join: JoinClause, dialect: SqlDialect, params?: SqlParams): string;
|
|
@@ -59,6 +64,8 @@ export declare function astToSql(pipeline: QueryPipeline, dialect: SqlDialect, o
|
|
|
59
64
|
/** The schema the query is built on: a value compared with a column
|
|
60
65
|
* that has a `format` is written in it (see ParameterizedSqlOptions). */
|
|
61
66
|
schema?: DatabaseSchema;
|
|
67
|
+
/** How a null-safe equal is written (see ParameterizedSqlOptions). */
|
|
68
|
+
nullSafeEqual?: NullSafeEqual;
|
|
62
69
|
}): string;
|
|
63
70
|
/** SQL with its values as bound parameters, for executing it. */
|
|
64
71
|
export interface ParameterizedSql {
|
|
@@ -91,6 +98,9 @@ export interface ParameterizedSqlOptions {
|
|
|
91
98
|
* — a param's value from `values` too. Without it, values are written
|
|
92
99
|
* the query's own way (a time `HH:MM:SS`). */
|
|
93
100
|
schema?: DatabaseSchema;
|
|
101
|
+
/** How `IS NOT DISTINCT FROM` is written: `'native'` (default), or
|
|
102
|
+
* `'expanded'` into `=` and IS NULL for SQL Server before 2022. */
|
|
103
|
+
nullSafeEqual?: NullSafeEqual;
|
|
94
104
|
}
|
|
95
105
|
/** The query as SQL whose values — in WHERE, JOIN ON and SELECT, including
|
|
96
106
|
* inside functions, IF/CASE and IN lists — are bound parameters rather than
|
|
@@ -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)
|
|
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";
|
package/dist/types/core-api.d.ts
CHANGED
|
@@ -9,12 +9,13 @@ export { SharedBaseError, addSharedQuery, joinSharedQuery, makeShared, makeSubQu
|
|
|
9
9
|
export { joinMultiplicity, repeatedReads, repeatedTables, rowsPerBase, type JoinMultiplicity, } from './core/fanOut.js';
|
|
10
10
|
export { ScopeError, scopeQuery, unscopedBodies, type ScopeRule, } from './core/scopeQuery.js';
|
|
11
11
|
export { addCondition, addGroupBy, addJoin, addOrderBy, addSelectItem, expr, removeJoin, requireBaseTable, setBaseTable, setDistinct, setHaving, setPaging, } from './core/queryHelpers.js';
|
|
12
|
-
export { queryParams, type QueryParam } from './core/params.js';
|
|
12
|
+
export { queryParams, type ParamColumn, type QueryParam } from './core/params.js';
|
|
13
13
|
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
|
-
export { astToParameterizedSql, astToSql, DIALECTS, DIALECT_LABELS, type ParameterizedSql, type ParameterizedSqlOptions, type SqlDialect, } from './core/sqlGen.js';
|
|
16
|
+
export { astToParameterizedSql, astToSql, DIALECTS, DIALECT_LABELS, type NullSafeEqual, type ParameterizedSql, type ParameterizedSqlOptions, type SqlDialect, } from './core/sqlGen.js';
|
|
17
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';
|
|
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,53 @@
|
|
|
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';
|
|
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 plan only gives the rows a
|
|
15
|
+
* scan returns, after its filter: with the sizes, a big table read
|
|
16
|
+
* whole for a few rows is reported as a missing index. */
|
|
17
|
+
tableRows?: Record<string, number> | ((table: string) => number | undefined);
|
|
18
|
+
/** Below this many rows, nothing is reported. Default 10,000. */
|
|
19
|
+
minRows?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ExplainedQuery {
|
|
22
|
+
/** The statement to run, EXPLAIN included, with `params` bound. */
|
|
23
|
+
sql: string;
|
|
24
|
+
params: unknown[];
|
|
25
|
+
/** What the plan EXPLAIN gave says, on the parts of the query given to
|
|
26
|
+
* explainQuery. Takes the plan as the driver returns it (rows with a
|
|
27
|
+
* `QUERY PLAN` column) or as its JSON text. */
|
|
28
|
+
findings: (plan: unknown, options?: PlanReadOptions) => PlanFinding[];
|
|
29
|
+
}
|
|
30
|
+
/** A table, sub query or shared query's place in the query, under the name
|
|
31
|
+
* the explained SQL gives it. */
|
|
32
|
+
export interface Place {
|
|
33
|
+
/** Where it is: its FROM or join. */
|
|
34
|
+
path: (string | number)[];
|
|
35
|
+
/** Where the query body it's in is. */
|
|
36
|
+
body: (string | number)[];
|
|
37
|
+
/** Its schema table, for a table. */
|
|
38
|
+
table?: string;
|
|
39
|
+
}
|
|
40
|
+
/** `query` with every table, sub query and shared query's place named
|
|
41
|
+
* apart, and where each new name leads. Innermost bodies first: an
|
|
42
|
+
* EXISTS sees the names around it, so a name left in it after its own are
|
|
43
|
+
* renamed is the outer one, and renaming the outer body reaches it. */
|
|
44
|
+
export declare function namePlaces(query: QueryPipeline): {
|
|
45
|
+
named: QueryPipeline;
|
|
46
|
+
places: Map<string, Place>;
|
|
47
|
+
};
|
|
48
|
+
/** The statement to explain `query` with, and a reader for the plan it
|
|
49
|
+
* gives. Call it as you'd write the query's SQL to run it: on the checked
|
|
50
|
+
* query, with the same options (and `scope`, the rule it runs under), so
|
|
51
|
+
* the plan is the one it really gets. The findings are on `query` itself,
|
|
52
|
+
* the parts a user sees in the editor. */
|
|
53
|
+
export declare function explainQuery(query: QueryPipeline, dialect: ExplainDialect, options?: ExplainOptions): ExplainedQuery;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
interface Context extends PlanReadOptions {
|
|
6
|
+
places: Map<string, Place>;
|
|
7
|
+
named: QueryPipeline;
|
|
8
|
+
resolveName?: ResolveName;
|
|
9
|
+
}
|
|
10
|
+
/** What `plan` says about the query `context.named` was named from. */
|
|
11
|
+
export default function readPostgresPlan(plan: unknown, context: Context): PlanFinding[];
|
|
12
|
+
export {};
|
|
@@ -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
|
|
11
|
-
* warnings (each its colour and icon). Opens their
|
|
12
|
-
* errors, then warnings,
|
|
13
|
-
*
|
|
14
|
-
* it
|
|
15
|
-
|
|
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;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.9.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",
|