@nongt/visql-core 0.12.2 → 0.14.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.
@@ -156,7 +156,8 @@ export interface SubqueryNode extends Record<string, unknown> {
156
156
  }
157
157
  /** `x IN (a, b, c)` (issue 130): the right side of IN, its values one
158
158
  * item each — literals in the editor, each with the input of what it's
159
- * compared with; params and other values from code. IN's other right side
159
+ * compared with, or one param as the whole list (`listParam`); other
160
+ * values from code. IN's other right side
160
161
  * is a sub query. Also BETWEEN's right side (issue 169): its two bounds,
161
162
  * low then high (`x BETWEEN low AND high`, both included). NOT BETWEEN is
162
163
  * a `not` around one, as NOT IN is. */
@@ -164,6 +165,10 @@ export interface ListNode extends Record<string, unknown> {
164
165
  type: 'list';
165
166
  items: ExpressionNode[];
166
167
  }
168
+ /** The param that is all of a list (`x IN (:ids)`), not a relative date:
169
+ * the editor shows such a list as that param, whose values the host
170
+ * gives when the query runs. */
171
+ export declare function listParam(list: ListNode): ParamNode | undefined;
167
172
  export interface CaseNode extends Record<string, unknown>, ColumnCopy {
168
173
  type: 'case';
169
174
  subject?: ExpressionNode;
@@ -28,6 +28,10 @@ export interface TableColumn {
28
28
  label: string;
29
29
  type: DatabaseColumnType;
30
30
  nullable?: boolean;
31
+ /** What the column means, for whoever builds a query: a line under its
32
+ * label in the field picker (search matches it too), and shown on
33
+ * hovering it once picked. E.g. that NULL means "not specified". */
34
+ description?: string;
31
35
  /** A fixed set of allowed values (an enum, a status…). Values compared
32
36
  * against this column are then picked from a dropdown instead of typed. */
33
37
  options?: ColumnOption[];
@@ -56,14 +60,28 @@ export interface ColumnOption {
56
60
  * `toTable.toColumn` — so the `from` side is the "many" side (e.g.
57
61
  * sale_transaction.product_id → product.id). The reverse direction
58
62
  * (product → its sales) is derived wherever it's needed; never declare it as
59
- * a second entry (validateSchema reports that as a duplicate). Single-column
60
- * keys only. */
63
+ * a second entry (validateSchema reports that as a duplicate). A key of
64
+ * several columns lists the others in `also`. */
61
65
  export interface Relation {
62
66
  fromTable: string;
63
67
  fromColumn: string;
64
68
  toTable: string;
65
69
  toColumn: string;
70
+ /** The key's other columns, when it's more than one (issue 44): a sale
71
+ * line referencing its sale by `store_id` and `sale_no`. A join's ON
72
+ * then matches every pair, ANDed. */
73
+ also?: {
74
+ fromColumn: string;
75
+ toColumn: string;
76
+ }[];
66
77
  }
78
+ /** Every column pair of a relation's key, `fromColumn`/`toColumn` first. */
79
+ export declare function keyColumns(r: Relation): {
80
+ fromColumn: string;
81
+ toColumn: string;
82
+ }[];
83
+ /** `conditions` ANDed: the one alone, else a group of them. */
84
+ export declare function allOf(conditions: ExpressionNode[]): ExpressionNode;
67
85
  /** Everything the builder knows about the database it's building queries for —
68
86
  * supplied by the host app (PipelineEditor's `schema` prop, distributed to
69
87
  * components via SchemaContext) rather than baked into this package. Every
@@ -173,8 +191,8 @@ export interface SuggestJoinOptions {
173
191
  * order (base table first, then join-insertion order) and the first
174
192
  * relation found wins, so the result is deterministic. A table with
175
193
  * `passThrough: false` is tried only for itself, or when the query has no
176
- * other table (startsOf). `joinType` is 'left' when the relation's FK
177
- * column (`fromColumn`) is nullable (e.g. sale_transaction.promotion_id:
194
+ * other table (startsOf). `joinType` is 'left' when one of the relation's FK
195
+ * columns (`fromColumn`, `also`) is nullable (e.g. sale_transaction.promotion_id:
178
196
  * an INNER join there would silently drop unpromoted sales) or the table
179
197
  * it's tied to is in `options.leftJoined`, and 'inner' otherwise. Returns
180
198
  * undefined if no relation connects `newTable` to anything already
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nongt/visql-core",
3
- "version": "0.12.2",
3
+ "version": "0.14.0",
4
4
  "description": "The query logic of @nongt/visql, for a backend: load, check, scope, write SQL, import SQL, read query plans. No React, no dependencies.",
5
5
  "keywords": [
6
6
  "sql",