sqlscope-rs 0.4.1 → 0.6.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 +1 -1
- package/dist/api.d.ts +8 -3
- package/dist/api.js +5 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/wasm/sqlscope_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ npm install sqlscope-rs
|
|
|
15
15
|
| --- | --- |
|
|
16
16
|
| `applyRowFilter` | Filter every in-scope table by a predicate (row-level security). |
|
|
17
17
|
| `injectCtes` | Prepend CTE definitions to a query's root `WITH`. |
|
|
18
|
-
| `rewriteTables` | Replace table references with derived tables. |
|
|
18
|
+
| `rewriteTables` | Replace table references with other tables or derived tables. |
|
|
19
19
|
| `columnOrigins` | Source columns whose values reach the result (column lineage). |
|
|
20
20
|
| `outputColumns` | Names of the columns a statement outputs. |
|
|
21
21
|
| `referencedColumns` | Columns referenced anywhere (filters included), per table. |
|
package/dist/api.d.ts
CHANGED
|
@@ -64,12 +64,16 @@ export interface UnionRewrite {
|
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Replaces references to `matchKey` (`schema.table`). Set exactly one of
|
|
67
|
-
* `inline`,
|
|
67
|
+
* `inline`, `union`, or `rename`.
|
|
68
68
|
*/
|
|
69
69
|
export interface TableRewrite {
|
|
70
70
|
matchKey: string;
|
|
71
71
|
inline?: TableRef;
|
|
72
72
|
union?: UnionRewrite;
|
|
73
|
+
/** Column names for inline; an empty list selects all columns. */
|
|
74
|
+
columns?: readonly string[];
|
|
75
|
+
/** Replace the table name directly. */
|
|
76
|
+
rename?: TableRef;
|
|
73
77
|
}
|
|
74
78
|
/** The SQL clause that contains a column reference. */
|
|
75
79
|
export type Clause = "SELECT" | "FROM" | "JOIN_ON" | "JOIN_USING" | "WHERE" | "GROUP_BY" | "HAVING" | "QUALIFY" | "WINDOW" | "ORDER_BY" | "SORT_BY" | "DISTRIBUTE_BY" | "CLUSTER_BY" | "CONNECT_BY" | "LATERAL_VIEW" | "UPDATE_SET_TARGET" | "UPDATE_SET_VALUE" | "MERGE_ON" | "MERGE_WHEN" | "RETURNING";
|
|
@@ -85,7 +89,8 @@ export interface ColumnUsage {
|
|
|
85
89
|
* `SELECT * FROM a` becomes `SELECT * FROM (SELECT * FROM a WHERE <predicate>) AS a`.
|
|
86
90
|
* By default every physical table is filtered; `tableNames`, `tablePatterns`
|
|
87
91
|
* and `defaultDb` restrict the scope. CTE references, table functions and
|
|
88
|
-
* `DUAL`
|
|
92
|
+
* the `DUAL` dummy table (Oracle, the MySQL family, Snowflake) are never
|
|
93
|
+
* wrapped. `predicate` is parsed as one boolean expression;
|
|
89
94
|
* bind or escape its values before calling. Returns the input unchanged when
|
|
90
95
|
* no table is in scope.
|
|
91
96
|
*/
|
|
@@ -100,7 +105,7 @@ export declare function injectCtes(sql: string, ctes: Iterable<CteDef | readonly
|
|
|
100
105
|
/**
|
|
101
106
|
* Replace physical table references according to `rewrites`.
|
|
102
107
|
*
|
|
103
|
-
* Matched references
|
|
108
|
+
* Matched references keep their alias (or bare
|
|
104
109
|
* name); qualified column references are rebound onto it. Returns the input
|
|
105
110
|
* unchanged when nothing matches.
|
|
106
111
|
*/
|
package/dist/api.js
CHANGED
|
@@ -23,7 +23,8 @@ function run(operation, sql, fields, options) {
|
|
|
23
23
|
* `SELECT * FROM a` becomes `SELECT * FROM (SELECT * FROM a WHERE <predicate>) AS a`.
|
|
24
24
|
* By default every physical table is filtered; `tableNames`, `tablePatterns`
|
|
25
25
|
* and `defaultDb` restrict the scope. CTE references, table functions and
|
|
26
|
-
* `DUAL`
|
|
26
|
+
* the `DUAL` dummy table (Oracle, the MySQL family, Snowflake) are never
|
|
27
|
+
* wrapped. `predicate` is parsed as one boolean expression;
|
|
27
28
|
* bind or escape its values before calling. Returns the input unchanged when
|
|
28
29
|
* no table is in scope.
|
|
29
30
|
*/
|
|
@@ -48,7 +49,7 @@ export function injectCtes(sql, ctes, options = {}) {
|
|
|
48
49
|
/**
|
|
49
50
|
* Replace physical table references according to `rewrites`.
|
|
50
51
|
*
|
|
51
|
-
* Matched references
|
|
52
|
+
* Matched references keep their alias (or bare
|
|
52
53
|
* name); qualified column references are rebound onto it. Returns the input
|
|
53
54
|
* unchanged when nothing matches.
|
|
54
55
|
*/
|
|
@@ -56,6 +57,8 @@ export function rewriteTables(sql, rewrites, options = {}) {
|
|
|
56
57
|
const plan = Array.from(rewrites, (rewrite) => ({
|
|
57
58
|
matchKey: rewrite.matchKey,
|
|
58
59
|
inline: rewrite.inline && table(rewrite.inline),
|
|
60
|
+
rename: rewrite.rename && table(rewrite.rename),
|
|
61
|
+
columns: rewrite.columns,
|
|
59
62
|
union: rewrite.union && {
|
|
60
63
|
tableAlias: rewrite.union.tableAlias,
|
|
61
64
|
columns: Array.from(rewrite.union.columns),
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* | --- | --- |
|
|
6
6
|
* | {@link applyRowFilter} | Filter every in-scope table by a predicate. |
|
|
7
7
|
* | {@link injectCtes} | Prepend CTE definitions to a query's root `WITH`. |
|
|
8
|
-
* | {@link rewriteTables} | Replace table references with derived tables. |
|
|
8
|
+
* | {@link rewriteTables} | Replace table references with other tables or derived tables. |
|
|
9
9
|
* | {@link columnOrigins} | Source columns whose values reach the result (lineage). |
|
|
10
10
|
* | {@link outputColumns} | Names of the columns a statement outputs. |
|
|
11
11
|
* | {@link referencedColumns} | Columns referenced anywhere, per table. |
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* | --- | --- |
|
|
6
6
|
* | {@link applyRowFilter} | Filter every in-scope table by a predicate. |
|
|
7
7
|
* | {@link injectCtes} | Prepend CTE definitions to a query's root `WITH`. |
|
|
8
|
-
* | {@link rewriteTables} | Replace table references with derived tables. |
|
|
8
|
+
* | {@link rewriteTables} | Replace table references with other tables or derived tables. |
|
|
9
9
|
* | {@link columnOrigins} | Source columns whose values reach the result (lineage). |
|
|
10
10
|
* | {@link outputColumns} | Names of the columns a statement outputs. |
|
|
11
11
|
* | {@link referencedColumns} | Columns referenced anywhere, per table. |
|
package/package.json
CHANGED
|
Binary file
|