@typesql/core 0.4.0 → 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/CHANGELOG.md +112 -0
- package/README.md +35 -90
- package/dist/adapter.d.ts +9 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +9 -0
- package/dist/adapter.js.map +1 -0
- package/dist/cache/discover.d.ts +3 -0
- package/dist/cache/discover.d.ts.map +1 -1
- package/dist/cache/discover.js +80 -22
- package/dist/cache/discover.js.map +1 -1
- package/dist/cache/evaluate.d.ts +87 -0
- package/dist/cache/evaluate.d.ts.map +1 -0
- package/dist/cache/evaluate.js +481 -0
- package/dist/cache/evaluate.js.map +1 -0
- package/dist/cache/format.d.ts.map +1 -1
- package/dist/cache/format.js +33 -11
- package/dist/cache/format.js.map +1 -1
- package/dist/cache/job.d.ts +3 -7
- package/dist/cache/job.d.ts.map +1 -1
- package/dist/cache/job.js +155 -167
- package/dist/cache/job.js.map +1 -1
- package/dist/cache/mapper.d.ts.map +1 -1
- package/dist/cache/mapper.js +26 -7
- package/dist/cache/mapper.js.map +1 -1
- package/dist/cache/print.d.ts +7 -7
- package/dist/cache/print.d.ts.map +1 -1
- package/dist/cache/print.js +61 -13
- package/dist/cache/print.js.map +1 -1
- package/dist/cache/rpc.d.ts.map +1 -1
- package/dist/cache/rpc.js +11 -2
- package/dist/cache/rpc.js.map +1 -1
- package/dist/cache/scan.d.ts.map +1 -1
- package/dist/cache/scan.js +5 -3
- package/dist/cache/scan.js.map +1 -1
- package/dist/cache/store.d.ts.map +1 -1
- package/dist/cache/store.js +33 -8
- package/dist/cache/store.js.map +1 -1
- package/dist/create-sql.d.ts +122 -66
- package/dist/create-sql.d.ts.map +1 -1
- package/dist/create-sql.js +11 -11
- package/dist/create-sql.js.map +1 -1
- package/dist/engine/ast.d.ts +6 -1
- package/dist/engine/ast.d.ts.map +1 -1
- package/dist/engine/binder/clauses.d.ts +53 -27
- package/dist/engine/binder/clauses.d.ts.map +1 -1
- package/dist/engine/binder/from.d.ts +183 -102
- package/dist/engine/binder/from.d.ts.map +1 -1
- package/dist/engine/binder/narrow.d.ts +12 -11
- package/dist/engine/binder/narrow.d.ts.map +1 -1
- package/dist/engine/binder/resolve.d.ts +49 -16
- package/dist/engine/binder/resolve.d.ts.map +1 -1
- package/dist/engine/cache.d.ts +39 -31
- package/dist/engine/cache.d.ts.map +1 -1
- package/dist/engine/ddl/apply.d.ts +124 -72
- package/dist/engine/ddl/apply.d.ts.map +1 -1
- package/dist/engine/errors.d.ts +0 -4
- package/dist/engine/errors.d.ts.map +1 -1
- package/dist/engine/index.d.ts +28 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +8 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/infer.d.ts +41 -32
- package/dist/engine/infer.d.ts.map +1 -1
- package/dist/engine/inline.d.ts +66 -36
- package/dist/engine/inline.d.ts.map +1 -1
- package/dist/engine/json.d.ts +44 -38
- package/dist/engine/json.d.ts.map +1 -1
- package/dist/engine/lexer/chars.d.ts.map +1 -1
- package/dist/engine/lexer/lex.d.ts +72 -26
- package/dist/engine/lexer/lex.d.ts.map +1 -1
- package/dist/engine/lexer/next.d.ts +1 -1
- package/dist/engine/lexer/tokens.d.ts +6 -1
- package/dist/engine/lexer/tokens.d.ts.map +1 -1
- package/dist/engine/lexer/unicode.d.ts +21 -15
- package/dist/engine/lexer/unicode.d.ts.map +1 -1
- package/dist/engine/named.d.ts +26 -7
- package/dist/engine/named.d.ts.map +1 -1
- package/dist/engine/parser/ddl.d.ts +196 -76
- package/dist/engine/parser/ddl.d.ts.map +1 -1
- package/dist/engine/parser/dml.d.ts +79 -41
- package/dist/engine/parser/dml.d.ts.map +1 -1
- package/dist/engine/parser/expr.d.ts +95 -47
- package/dist/engine/parser/expr.d.ts.map +1 -1
- package/dist/engine/parser/json.d.ts +85 -21
- package/dist/engine/parser/json.d.ts.map +1 -1
- package/dist/engine/parser/keywords.d.ts.map +1 -1
- package/dist/engine/parser/merge.d.ts +15 -10
- package/dist/engine/parser/merge.d.ts.map +1 -1
- package/dist/engine/parser/select.d.ts +150 -75
- package/dist/engine/parser/select.d.ts.map +1 -1
- package/dist/engine/parser/stmt.d.ts +12 -13
- package/dist/engine/parser/stmt.d.ts.map +1 -1
- package/dist/engine/parser/typename.d.ts +8 -8
- package/dist/engine/parser/typename.d.ts.map +1 -1
- package/dist/engine/parser/util.d.ts +15 -6
- package/dist/engine/parser/util.d.ts.map +1 -1
- package/dist/engine/parser/utility.d.ts +19 -12
- package/dist/engine/parser/utility.d.ts.map +1 -1
- package/dist/engine/parser/xml.d.ts +53 -33
- package/dist/engine/parser/xml.d.ts.map +1 -1
- package/dist/engine/project/dml.d.ts +158 -73
- package/dist/engine/project/dml.d.ts.map +1 -1
- package/dist/engine/project/merge.d.ts +30 -11
- package/dist/engine/project/merge.d.ts.map +1 -1
- package/dist/engine/project/naming.d.ts +16 -13
- package/dist/engine/project/naming.d.ts.map +1 -1
- package/dist/engine/project/select.d.ts +93 -44
- package/dist/engine/project/select.d.ts.map +1 -1
- package/dist/engine/project/stmt.d.ts +1 -1
- package/dist/engine/project/stmt.d.ts.map +1 -1
- package/dist/engine/shape.d.ts +3 -3
- package/dist/engine/shape.d.ts.map +1 -1
- package/dist/engine/splice.d.ts +42 -17
- package/dist/engine/splice.d.ts.map +1 -1
- package/dist/engine/suggest.d.ts +7 -9
- package/dist/engine/suggest.d.ts.map +1 -1
- package/dist/engine/typer/catalog.d.ts +612 -164
- package/dist/engine/typer/catalog.d.ts.map +1 -1
- package/dist/engine/typer/operators.d.ts +17 -17
- package/dist/engine/typer/operators.d.ts.map +1 -1
- package/dist/engine/typer/params.d.ts +141 -76
- package/dist/engine/typer/params.d.ts.map +1 -1
- package/dist/engine/typer/pg-functions.d.ts +61 -18
- package/dist/engine/typer/pg-functions.d.ts.map +1 -1
- package/dist/engine/typer/sqljson.d.ts +24 -12
- package/dist/engine/typer/sqljson.d.ts.map +1 -1
- package/dist/engine/typer/typeof.d.ts +147 -52
- package/dist/engine/typer/typeof.d.ts.map +1 -1
- package/dist/engine/typer/xml.d.ts +39 -15
- package/dist/engine/typer/xml.d.ts.map +1 -1
- package/dist/engine/types.d.ts +16 -21
- package/dist/engine/types.d.ts.map +1 -1
- package/dist/engine/write.d.ts +14 -10
- package/dist/engine/write.d.ts.map +1 -1
- package/dist/index.d.ts +11 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -7
- package/dist/index.js.map +1 -1
- package/dist/migrations.d.ts +6 -3
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js.map +1 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -1
- package/dist/query.js.map +1 -1
- package/dist/row-keys.d.ts.map +1 -1
- package/dist/row-keys.js.map +1 -1
- package/dist/runtime/inline.d.ts +7 -10
- package/dist/runtime/inline.d.ts.map +1 -1
- package/dist/runtime/inline.js +21 -31
- package/dist/runtime/inline.js.map +1 -1
- package/dist/runtime/json.d.ts.map +1 -1
- package/dist/runtime/json.js.map +1 -1
- package/dist/runtime/splice.d.ts.map +1 -1
- package/dist/runtime/splice.js +3 -1
- package/dist/runtime/splice.js.map +1 -1
- package/dist/runtime/write.d.ts.map +1 -1
- package/dist/runtime/write.js +5 -2
- package/dist/runtime/write.js.map +1 -1
- package/dist/schema/column.d.ts +2 -2
- package/dist/schema/column.d.ts.map +1 -1
- package/dist/schema/index.d.ts +4 -4
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/normalize.d.ts.map +1 -1
- package/dist/schema/pg-catalog.d.ts +15 -2
- package/dist/schema/pg-catalog.d.ts.map +1 -1
- package/dist/schema/pg-types.d.ts.map +1 -1
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js.map +1 -1
- package/dist/type-map/index.d.ts +3 -3
- package/dist/type-map/index.d.ts.map +1 -1
- package/package.json +9 -4
- package/src/adapter.ts +13 -0
- package/src/cache/discover.ts +296 -150
- package/src/cache/evaluate.ts +576 -0
- package/src/cache/format.ts +150 -105
- package/src/cache/job.ts +784 -612
- package/src/cache/mapper.ts +129 -89
- package/src/cache/print.ts +186 -120
- package/src/cache/rpc.ts +79 -57
- package/src/cache/scan.ts +91 -82
- package/src/cache/store.ts +176 -99
- package/src/create-sql.ts +721 -312
- package/src/engine/ast.ts +615 -304
- package/src/engine/binder/clauses.ts +572 -174
- package/src/engine/binder/from.ts +876 -243
- package/src/engine/binder/narrow.ts +138 -41
- package/src/engine/binder/resolve.ts +228 -87
- package/src/engine/cache.ts +247 -90
- package/src/engine/ddl/apply.ts +1168 -431
- package/src/engine/errors.ts +6 -12
- package/src/engine/index.ts +108 -0
- package/src/engine/infer.ts +271 -111
- package/src/engine/inline.ts +344 -154
- package/src/engine/json.ts +377 -127
- package/src/engine/lexer/chars.ts +71 -6
- package/src/engine/lexer/lex.ts +536 -185
- package/src/engine/lexer/next.ts +1 -1
- package/src/engine/lexer/tokens.ts +30 -7
- package/src/engine/lexer/unicode.ts +382 -96
- package/src/engine/named.ts +183 -63
- package/src/engine/parser/ddl.ts +1945 -647
- package/src/engine/parser/dml.ts +529 -221
- package/src/engine/parser/expr.ts +1503 -625
- package/src/engine/parser/json.ts +702 -291
- package/src/engine/parser/keywords.ts +198 -27
- package/src/engine/parser/merge.ts +202 -82
- package/src/engine/parser/select.ts +1269 -507
- package/src/engine/parser/stmt.ts +132 -48
- package/src/engine/parser/typename.ts +160 -55
- package/src/engine/parser/util.ts +147 -59
- package/src/engine/parser/utility.ts +103 -50
- package/src/engine/parser/xml.ts +478 -187
- package/src/engine/project/dml.ts +1286 -395
- package/src/engine/project/merge.ts +335 -93
- package/src/engine/project/naming.ts +83 -29
- package/src/engine/project/select.ts +929 -297
- package/src/engine/project/stmt.ts +25 -7
- package/src/engine/shape.ts +37 -15
- package/src/engine/splice.ts +255 -81
- package/src/engine/suggest.ts +159 -67
- package/src/engine/typer/catalog.ts +1427 -671
- package/src/engine/typer/operators.ts +561 -180
- package/src/engine/typer/params.ts +934 -232
- package/src/engine/typer/pg-functions.ts +37 -14
- package/src/engine/typer/sqljson.ts +299 -99
- package/src/engine/typer/typeof.ts +884 -246
- package/src/engine/typer/xml.ts +245 -76
- package/src/engine/types.ts +72 -35
- package/src/engine/write.ts +109 -36
- package/src/index.ts +46 -24
- package/src/migrations.ts +62 -45
- package/src/query.ts +124 -82
- package/src/row-keys.ts +42 -29
- package/src/runtime/inline.ts +106 -88
- package/src/runtime/json.ts +17 -11
- package/src/runtime/splice.ts +206 -152
- package/src/runtime/write.ts +67 -46
- package/src/schema/column.ts +45 -16
- package/src/schema/index.ts +38 -4
- package/src/schema/normalize.ts +88 -33
- package/src/schema/pg-catalog.ts +16 -3
- package/src/schema/pg-types.ts +63 -18
- package/src/transaction.ts +60 -35
- package/src/type-map/index.ts +126 -91
- package/dist/editor/call.d.ts +0 -33
- package/dist/editor/call.d.ts.map +0 -1
- package/dist/editor/call.js +0 -79
- package/dist/editor/call.js.map +0 -1
- package/dist/editor/complete.d.ts +0 -42
- package/dist/editor/complete.d.ts.map +0 -1
- package/dist/editor/complete.js +0 -82
- package/dist/editor/complete.js.map +0 -1
- package/dist/editor/index.d.ts +0 -10
- package/dist/editor/index.d.ts.map +0 -1
- package/dist/editor/index.js +0 -37
- package/dist/editor/index.js.map +0 -1
- package/dist/editor/scan.d.ts +0 -53
- package/dist/editor/scan.d.ts.map +0 -1
- package/dist/editor/scan.js +0 -599
- package/dist/editor/scan.js.map +0 -1
- package/dist/editor/schema.d.ts +0 -37
- package/dist/editor/schema.d.ts.map +0 -1
- package/dist/editor/schema.js +0 -118
- package/dist/editor/schema.js.map +0 -1
- package/src/editor/call.ts +0 -107
- package/src/editor/complete.ts +0 -115
- package/src/editor/index.ts +0 -40
- package/src/editor/scan.ts +0 -614
- package/src/editor/schema.ts +0 -157
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,117 @@
|
|
|
1
1
|
# @typesql/core
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- `@typesql/core/editor` is removed: editor completions moved to `@typesql/language-server`, which the VS Code extension bundles.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- `SELECT … INTO` inside a WITH query is rejected with PostgreSQL's `SELECT ... INTO is not allowed here` (it was read as a data-modifying WITH query), and that error points at the new table's name, as in PostgreSQL.
|
|
12
|
+
|
|
13
|
+
- Lexer errors read like PostgreSQL's: an unterminated literal names where it starts (`unterminated quoted string at or near "'abc"`, `unterminated bit string literal …`), and a character no token starts with is `syntax error at or near "\\"`.
|
|
14
|
+
|
|
15
|
+
- `UPDATE … SET (a) = x` with a source that is neither `ROW(…)` nor a subquery is an error, as in PostgreSQL (`source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression`).
|
|
16
|
+
|
|
17
|
+
- A window function in the operand of `IN (SELECT …)` is checked like any other (`window "w" does not exist`).
|
|
18
|
+
|
|
19
|
+
- `SELECT … INTO` without a table name is a syntax error, as in PostgreSQL, instead of being accepted.
|
|
20
|
+
|
|
21
|
+
- `$1 BETWEEN a AND b` types the parameter as `a` (`$1 BETWEEN id AND big` → `number`, not `string | number | bigint`), as in PostgreSQL, which resolves `$1 >= a` first.
|
|
22
|
+
|
|
23
|
+
- Bit strings (`B'101'`, `X'1F'`) are typed `bit` instead of `text`, and a digit that does not belong is an error (`"2" is not a valid binary digit`), as in PostgreSQL.
|
|
24
|
+
|
|
25
|
+
- `DECLARE` rejects contradictory options (`ASENSITIVE` with `INSENSITIVE`, `SCROLL` with `NO SCROLL`), and errors after `NO`, `WITH` / `WITHOUT` and a lone sign in `FETCH` point at the token PostgreSQL names.
|
|
26
|
+
|
|
27
|
+
- Subscripts of `point`, `line` (`float8`), `lseg`, `box` (`point`) and `name` (`"char"`) are typed as in PostgreSQL instead of `unknown`, and a `UESCAPE` at the end of the statement reports `UESCAPE must be followed by a simple string literal at end of input`.
|
|
28
|
+
|
|
29
|
+
- Syntax errors after a `WITH` that is not followed by `(` in CREATE TABLE / VIEW, after `UPDATE` without `SET` or `DO` without `NOTHING` in a MERGE action, and after an `AS` without a label point at the token PostgreSQL points at.
|
|
30
|
+
|
|
31
|
+
- A call decoration the function does not take is an error, as in PostgreSQL: `*`, `DISTINCT`, `FILTER` or `OVER` on a plain function (`lower(x) FILTER (…)`), a window function without `OVER`, and `count()` without `*`.
|
|
32
|
+
|
|
33
|
+
- A parameter in a numeric-category argument (`abs($1)`, `width_bucket($1, …)`) is `float8` (`number`) instead of `numeric`, and `to_tsvector($1)` / `ts_headline($1, …)` take text instead of jsonb, as PostgreSQL resolves them.
|
|
34
|
+
|
|
35
|
+
- A JSON step that misses (`x -> 'nope'`, an index past the end, a key on an array) is SQL NULL, so `coalesce(x -> 'nope', '[]')` is typed `[]` instead of `[] | null`.
|
|
36
|
+
|
|
37
|
+
- Subscripts in a row on an array (`a[1][2]`, `a[1][1:2]`) apply to the array together, as in PostgreSQL: they are typed as its element, or as the array when one is a slice, instead of `unknown`.
|
|
38
|
+
|
|
39
|
+
- Error messages name the `"char"` and `bit varying` types as PostgreSQL does (`cannot subscript type bit varying …`).
|
|
40
|
+
|
|
41
|
+
- A column of `CREATE TABLE … AS SELECT NULL AS x` or of a view over `SELECT NULL` is `text`, as in PostgreSQL, instead of a column that only takes `null`.
|
|
42
|
+
|
|
43
|
+
- A window function inside the array of `x = ANY (ARRAY[…])` is checked like any other (`window "w" does not exist`).
|
|
44
|
+
|
|
45
|
+
- An array slice is nullable when a bound is (`nums[n:2]`, `nums[NULL:2]`), as in PostgreSQL, and a subscript chain with a slice (`nums[1][1:2]`) is NULL only through a NULL array or subscript (out of range it is an empty array).
|
|
46
|
+
|
|
47
|
+
- `SUBSTRING` and `OVERLAY` of a `varbit` are typed `bit`, as in PostgreSQL.
|
|
48
|
+
|
|
49
|
+
- Subscripting an enum (`mood[1]`, in a query or as an assignment target) reports PostgreSQL's `cannot subscript type mood because it does not support subscripting`.
|
|
50
|
+
|
|
51
|
+
- The README is shorter: install, one example and links to the docs site, which now has the details it used to repeat.
|
|
52
|
+
|
|
53
|
+
- A sort order in an `ON CONFLICT` target (`ON CONFLICT (email DESC)`, `NULLS FIRST`) is an error, as in PostgreSQL.
|
|
54
|
+
|
|
55
|
+
- An ORDER BY / GROUP BY position written with leading zeros (`ORDER BY 01`) is that position, and one past the int4 range is a non-integer constant, as in PostgreSQL.
|
|
56
|
+
|
|
57
|
+
- `x IN (SELECT …)` and `x = ANY (SELECT …)` over a subquery without columns report `subquery has too few columns`, as PostgreSQL does.
|
|
58
|
+
|
|
59
|
+
- "Trailing junk" errors quote the whole junk token (`123abc`, `100__000`, `$0_1`), and invalid Unicode escapes in `E'…'` strings say where they are, as PostgreSQL does.
|
|
60
|
+
|
|
61
|
+
- An assignment target with `.*` (`SET col.* = …`, `INSERT INTO t (col.*)`) reports PostgreSQL's `row expansion via "*" is not supported here` at the column.
|
|
62
|
+
|
|
63
|
+
- Subscripting a value of a type without subscripts (`json`, `text`, …) is an error in any expression, and a `jsonb` slice is too, as in PostgreSQL; they were typed `unknown`.
|
|
64
|
+
|
|
65
|
+
- `ORDER BY` / `GROUP BY` / `DISTINCT ON` position errors (`ORDER BY position 2 is not in select list`) point at the number, as in PostgreSQL.
|
|
66
|
+
|
|
67
|
+
- A national character literal `N'abc'` is a `character` value (`string`), as in PostgreSQL, instead of `unknown`.
|
|
68
|
+
|
|
69
|
+
- `SELECT DISTINCT *` checks its ORDER BY too: an expression that is not in the select list (`ORDER BY id + 1`) is an error, as in PostgreSQL.
|
|
70
|
+
|
|
71
|
+
- A row compared with a subquery (`(a, b) = (SELECT x, y …)`) is a nullable boolean and needs a subquery of the same width, as in PostgreSQL; it was rejected as a scalar subquery with more than one column.
|
|
72
|
+
|
|
73
|
+
- DDL errors name relations as PostgreSQL does: a missing schema in `ALTER TABLE`, `DROP TABLE`, `INHERITS` or `LIKE` reports `schema "s" does not exist`, a missing relation there is spelled as written (`relation "public.t" does not exist`), `DROP` / `is not a table` messages use the bare name, and two parents with different column types report `inherited column "x" has a type conflict`.
|
|
74
|
+
|
|
75
|
+
- A typed literal with a schema-qualified type name, `pg_catalog.int4 '1'`, is accepted (the schema is dropped, as in casts) instead of being a syntax error.
|
|
76
|
+
|
|
77
|
+
- A missing relation written with `public.` keeps it in the error (`relation "public.t" does not exist`), and errors about a schema-qualified name point at the name, as in PostgreSQL.
|
|
78
|
+
|
|
79
|
+
- `INSERT INTO t AS excluded … ON CONFLICT DO UPDATE SET c = excluded.c` is an error (`table reference "excluded" is ambiguous`), as in PostgreSQL.
|
|
80
|
+
|
|
81
|
+
- Syntax errors in `1 + ANY 2`, `f(1 => x)`, `current_date()` and `localtime('a')` point at the token PostgreSQL points at, and `current_user(1)` is a syntax error, as in PostgreSQL.
|
|
82
|
+
|
|
83
|
+
- The merged column of `FULL JOIN … USING` / `NATURAL FULL JOIN` is nullable when either side's column is (a row without a match carries that side's NULL), as in PostgreSQL; it was non-null unless both were nullable.
|
|
84
|
+
|
|
85
|
+
- `U&'…' uescapeé` (UESCAPE followed by a non-ASCII letter) reads as an alias, as in PostgreSQL, instead of an error.
|
|
86
|
+
|
|
87
|
+
## 0.5.0
|
|
88
|
+
|
|
89
|
+
### Minor Changes
|
|
90
|
+
|
|
91
|
+
- What adapters and custom executors build on moved to `@typesql/core/adapter`: `createTransactionalSql`, `runTransaction`, `SqlDriver`, `mapRows`, `rowKeysOf`, `camelCase` and `JsonParam`.
|
|
92
|
+
|
|
93
|
+
- The engine's types (`Analyze`, `ArgsOf`, `KeyedRow`, `ListRep`, `SetRep`, the inline markers, lexer, parser, schema and type cache types, …) moved to `@typesql/core/engine`; the root keeps `Sql`, `Query`, `Fragment`, the schema helpers, `RowOf`, `ParamsOf`, `Validate`, `ApplyDdl` and the other types you write in application code.
|
|
94
|
+
|
|
95
|
+
- The root export is the user-facing API only: the standalone `param`, `valueOrDefault` and `json` are gone (use `sql.param`, `sql.json`), and so are the splice and query-building helpers (`splice`, `renumberParams`, `maxParam`, `quoteIdent`, `joinFragments`, `hasSlots`, `rewriteNamed`, `makeQuery`, `makeFragment`).
|
|
96
|
+
|
|
97
|
+
- `sql.valueOrDefault` is removed: `sql.param(value)` sends `DEFAULT` when the value is `undefined`, and a value that can be `undefined` is a compile error where `DEFAULT` is not allowed and inside `sql.fragment`.
|
|
98
|
+
|
|
99
|
+
- `sql.list` is merged into `sql.join`: joining a runtime array of fragments whose texts are known is checked as `sql.list` did, and `sql.join` throws when there are no items.
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- No user-visible change: PostgreSQL's parser (libpg-query) is a development dependency, for a test that compares parse trees.
|
|
104
|
+
|
|
105
|
+
- No user-visible change: the type cache job evaluates statements through an internal module the type oracles share.
|
|
106
|
+
|
|
107
|
+
- Types follow PostgreSQL 18: `PgCatalog` has the new catalog columns (`pg_attribute.attcacheoff` is gone), the new built-in functions are known, and `reverse(bytea)` and `json(b)_strip_nulls(x, strip_in_arrays)` are typed.
|
|
108
|
+
|
|
109
|
+
- The README's documentation links point to the docs site, after its pages moved.
|
|
110
|
+
|
|
111
|
+
- No user-visible change: comments in the type engine say its rules are verified against PostgreSQL 18, which the type and function oracles now check.
|
|
112
|
+
|
|
113
|
+
- No user-visible change: simpler printed-type parsing in the type cache job, with mutation-testing annotations.
|
|
114
|
+
|
|
3
115
|
## 0.4.0
|
|
4
116
|
|
|
5
117
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,123 +1,68 @@
|
|
|
1
1
|
# @typesql/core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
**inside the type system** and gives you the exact row type, the parameter types, and (for DDL)
|
|
5
|
-
the resulting schema. No codegen, no database connection, no build step. Zero runtime
|
|
6
|
-
dependencies.
|
|
3
|
+
Write Postgres SQL in TypeScript and get exact types for rows and parameters. TypeSQL parses your SQL inside the type checker: no codegen, no database connection, no build step.
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
regression tests that can be checked statically, the parser accepts exactly what Postgres accepts
|
|
10
|
-
and rejects its syntax errors ([how it is tested](https://typesql.karsli.net/guide/postgres-compatibility)).
|
|
5
|
+
## Install
|
|
11
6
|
|
|
12
7
|
```sh
|
|
13
|
-
|
|
8
|
+
npm install @typesql/core
|
|
14
9
|
```
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Add the adapter for your driver to run queries: [`@typesql/pg`](https://www.npmjs.com/package/@typesql/pg)
|
|
19
|
-
(node-postgres) or [`@typesql/postgres`](https://www.npmjs.com/package/@typesql/postgres)
|
|
20
|
-
(postgres.js). Already describing your database for an ORM? `@typesql/kysely`,
|
|
21
|
-
`@typesql/drizzle` and `@typesql/prisma` take the schema from it.
|
|
11
|
+
Requires TypeScript 7.1 or later and Node.js 26 or later.
|
|
22
12
|
|
|
23
13
|
## Usage
|
|
24
14
|
|
|
15
|
+
Describe your tables with Postgres type names, then write queries:
|
|
16
|
+
|
|
25
17
|
```ts
|
|
26
18
|
import { createSql, type Col, type Generated, type Nullable } from "@typesql/core";
|
|
27
19
|
|
|
28
20
|
interface DB {
|
|
29
21
|
users: {
|
|
30
|
-
id: Generated<"int4">; // has a default
|
|
31
|
-
email: Col<"text">;
|
|
32
|
-
display_name: Nullable<"text">;
|
|
33
|
-
created_at: Generated<"timestamptz">;
|
|
22
|
+
id: Generated<"int4">; // has a default, so optional on INSERT
|
|
23
|
+
email: Col<"text">; // NOT NULL
|
|
24
|
+
display_name: Nullable<"text">; // NULL allowed
|
|
34
25
|
};
|
|
35
26
|
posts: {
|
|
36
27
|
id: Generated<"int8">;
|
|
37
28
|
author_id: Col<"int4">;
|
|
38
29
|
title: Col<"text">;
|
|
39
|
-
body: Nullable<"text">;
|
|
40
30
|
};
|
|
41
31
|
}
|
|
42
32
|
|
|
43
33
|
const sql = createSql<DB>();
|
|
44
34
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
const query = sql(
|
|
36
|
+
`SELECT u.email, p.title
|
|
37
|
+
FROM users u LEFT JOIN posts p ON p.author_id = u.id
|
|
38
|
+
WHERE u.id = $1`,
|
|
39
|
+
7,
|
|
40
|
+
);
|
|
41
|
+
// row: { email: string; title: string | null }
|
|
42
|
+
// params: [number | null]
|
|
43
|
+
|
|
44
|
+
sql("SELECT emial FROM users");
|
|
45
|
+
// error: column "emial" does not exist. Perhaps you meant the column "email"?
|
|
55
46
|
```
|
|
56
47
|
|
|
57
|
-
|
|
58
|
-
can be passed positionally (`$1`), by name (`:email` with an object), or inline with
|
|
59
|
-
`${sql.param(value)}` (`${sql.json(value)}` for JSON); all are sent as bind parameters and
|
|
60
|
-
checked against their context.
|
|
61
|
-
|
|
62
|
-
## What you get
|
|
63
|
-
|
|
64
|
-
- **Rows and parameters** for `SELECT` (joins, subqueries, CTEs, set operations, aggregates,
|
|
65
|
-
window functions) and `INSERT`/`UPDATE`/`DELETE … RETURNING`.
|
|
66
|
-
- **Nullability** from the schema, outer joins, `WHERE` filters and expressions (`COALESCE`,
|
|
67
|
-
aggregates, `CASE`).
|
|
68
|
-
- **Typed JSON**: `json_build_object`, `json_agg`, `to_json(t)` and `->` / `#>` give the JSON's
|
|
69
|
-
structure, typed as Postgres serializes it.
|
|
70
|
-
- **Postgres column naming** (`?column?`, `count`, `lower`) and Postgres-worded compile errors.
|
|
71
|
-
- **Fragments**: `sql.fragment`, `sql.id`, `sql.join`, `sql.list` (runtime arrays of typed elements), `sql.raw`, spliced into inference with
|
|
72
|
-
`$n` renumbering.
|
|
73
|
-
- **Write helpers**: `sql.valueOrDefault(x)` sends `DEFAULT` for `undefined`; `sql.set(table, partial)`
|
|
74
|
-
and `sql.values(table, rows)` build typed `SET` lists and `VALUES` rows from objects.
|
|
75
|
-
- **DDL**: `ApplyDdl<DB, "ALTER TABLE …">` and the `migrations()` builder derive the schema from
|
|
76
|
-
your migrations.
|
|
77
|
-
- **Running queries**: with `createSql(executor)` (or an adapter's `createSql(client)`), queries
|
|
78
|
-
have `execute()`, `executeTakeFirst()`, `executeTakeFirstOrThrow()` and `executeCount()` (the
|
|
79
|
-
affected row count). An `Executor` resolves to the rows or to `{ rows, rowCount }`. An
|
|
80
|
-
adapter's `sql` also has `sql.transaction(fn)`, which runs `fn` with a `sql` bound to one
|
|
81
|
-
transaction (`TransactionalSql`).
|
|
82
|
-
- **camelCase rows**: `createSql(executor, { rowKeys: "camelCase" })` renames the rows'
|
|
83
|
-
top-level keys (`created_at` → `createdAt`, as Kysely's `CamelCasePlugin` does) in the types
|
|
84
|
-
and at runtime, leaving JSON values alone.
|
|
85
|
-
- **Escape hatch**: `sql.as<Row>(…)` for SQL the engine cannot type.
|
|
86
|
-
|
|
87
|
-
## Schema
|
|
88
|
-
|
|
89
|
-
Columns are declared with Postgres type names; a type map turns them into TypeScript types
|
|
90
|
-
(`DefaultTypeMap` matches node-postgres: `int8` and `numeric` rows are `string`; their parameters
|
|
91
|
-
also take numbers and bigints, and date parameters take `Date | string`):
|
|
92
|
-
|
|
93
|
-
| Helper | Meaning |
|
|
94
|
-
|---|---|
|
|
95
|
-
| `Col<"text">` | `NOT NULL`, no default |
|
|
96
|
-
| `Nullable<"text">` | `NULL` allowed |
|
|
97
|
-
| `Generated<"int4">` | has a default: optional in `INSERT` |
|
|
98
|
-
| `NullableGenerated<"text">` | both |
|
|
99
|
-
| `Enum<"mood">` | values in `DB["$types"]["mood"]` |
|
|
100
|
-
| `Json<T>` | `jsonb` holding `T`: rows read `T`, `->` indexes into it, `${sql.json(v)}` writes it |
|
|
101
|
-
| `View<{ … }>` | read-only relation |
|
|
48
|
+
[Open the example in the TypeScript Playground](https://www.typescriptlang.org/play/#code/PTAEBUE8AcFMGUCKAZAXKACgewM4BcBzAJ1h1CWQBpRoBDInWAE1ACNIIYEBjIgS2h4A5GTxdQOSPlgBbAHSgAokz55QeABa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1HAjlOweWgmFoJ4TVdbI5DSGQfjsV81AtLEauGb8mh-Hk+QFR7FnAec0fyAdsfigA1BzkEWxQxoHY96lquQgZkXm+qyIdLni45FHARbjkWHlxgSphqFp5hrTwHa9vEdpuzp46zlOiyuz6LEbsQuyHvQ2IXUSdwUnJzJslAXJajIQpih0ZA0oyhRJz4aVihkexaoHP9FAAmd9F8UBpswuEAh-EdyTAP2iHQNIQh8ooHhT2AHhpLAkjyrHpVduw4+Z3l+RnHlOdm6rBqzWABaFkWxbPIdhMeTjYDCLAHhzxx8-QGjWvohKyEWecZ0WRbkBDqJKTIPKaTpOMQjwOwgA) <!-- playground:core -->: edit the SQL and hover the types, with nothing to install. The Playground runs TypeScript 6, so treat it as a demo.
|
|
102
49
|
|
|
103
|
-
|
|
104
|
-
`pg_stat_activity`, `pg_tables`, `information_schema.columns` and other system catalogs, add the
|
|
105
|
-
opt-in slice: `createSql<DB & PgCatalog>()`.
|
|
50
|
+
## Run queries
|
|
106
51
|
|
|
107
|
-
|
|
52
|
+
`@typesql/core` types your queries. To run them, add the package for your driver or ORM:
|
|
108
53
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
54
|
+
| Package | Runs queries on |
|
|
55
|
+
|---|---|
|
|
56
|
+
| [`@typesql/pg`](https://www.npmjs.com/package/@typesql/pg) | node-postgres |
|
|
57
|
+
| [`@typesql/postgres`](https://www.npmjs.com/package/@typesql/postgres) | postgres.js |
|
|
58
|
+
| [`@typesql/kysely`](https://www.npmjs.com/package/@typesql/kysely) | Kysely, with its `DB` interface as the schema |
|
|
59
|
+
| [`@typesql/drizzle`](https://www.npmjs.com/package/@typesql/drizzle) | Drizzle, with its schema |
|
|
60
|
+
| [`@typesql/prisma`](https://www.npmjs.com/package/@typesql/prisma) | Prisma Client, with its schema |
|
|
115
61
|
|
|
116
62
|
## Documentation
|
|
117
63
|
|
|
118
|
-
[
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
[
|
|
123
|
-
[Editor completions](https://github.com/ismailkarsli/typesql/blob/main/packages/docs/guide/editor.md)
|
|
64
|
+
The full guide is at **[typesql.karsli.net](https://typesql.karsli.net)**. It covers the [schema](https://typesql.karsli.net/guide/schema), [parameters](https://typesql.karsli.net/guide/parameters), [writing data](https://typesql.karsli.net/guide/writing-data), [dynamic SQL](https://typesql.karsli.net/guide/dynamic-sql), [migrations](https://typesql.karsli.net/guide/migrations), the [type cache](https://typesql.karsli.net/guide/performance) and [known limits](https://typesql.karsli.net/guide/limits).
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@typesql/core/adapter`: what driver adapters and custom executors build on. Applications
|
|
3
|
+
* import `@typesql/core` or an adapter package instead.
|
|
4
|
+
*/
|
|
5
|
+
export { mapRows, rowKeysOf } from "./query.js";
|
|
6
|
+
export { camelCase } from "./row-keys.js";
|
|
7
|
+
export { JsonParam } from "./runtime/json.js";
|
|
8
|
+
export { createTransactionalSql, runTransaction, type SqlDriver, } from "./transaction.js";
|
|
9
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACN,sBAAsB,EACtB,cAAc,EACd,KAAK,SAAS,GACd,MAAM,kBAAkB,CAAC"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@typesql/core/adapter`: what driver adapters and custom executors build on. Applications
|
|
3
|
+
* import `@typesql/core` or an adapter package instead.
|
|
4
|
+
*/
|
|
5
|
+
export { mapRows, rowKeysOf } from "./query.js";
|
|
6
|
+
export { camelCase } from "./row-keys.js";
|
|
7
|
+
export { JsonParam } from "./runtime/json.js";
|
|
8
|
+
export { createTransactionalSql, runTransaction, } from "./transaction.js";
|
|
9
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACN,sBAAsB,EACtB,cAAc,GAEd,MAAM,kBAAkB,CAAC"}
|
package/dist/cache/discover.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface Kinds {
|
|
|
17
17
|
export interface SqlSite {
|
|
18
18
|
/** The query literal (with `:name` and `${sql.param()}` markers as written). */
|
|
19
19
|
readonly key: string;
|
|
20
|
+
readonly file: string;
|
|
20
21
|
readonly db: Type;
|
|
21
22
|
readonly tm: Type;
|
|
22
23
|
readonly keys: Type;
|
|
@@ -26,10 +27,12 @@ export interface SqlSite {
|
|
|
26
27
|
/** A statement written as a type: `RowOf<DB, TM, "SELECT …">`, or a literal argument of the project's own alias. */
|
|
27
28
|
export interface TypeSite {
|
|
28
29
|
readonly key: string;
|
|
30
|
+
readonly file: string;
|
|
29
31
|
readonly db: Type;
|
|
30
32
|
}
|
|
31
33
|
export interface DdlSite {
|
|
32
34
|
readonly key: string;
|
|
35
|
+
readonly file: string;
|
|
33
36
|
/** The schema before the step (`Migrations<DB>`'s `DB`). */
|
|
34
37
|
readonly db: Type;
|
|
35
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.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sB,QAAQ,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EACrC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,GACpC,OAAO,CAAC;IAAE,GAAG,EAAE,OAAO,EAAE,CAAC;IAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAAC,GAAG,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,CAyJhE;AAqFD,uFAAuF;AACvF,wBAAsB,SAAS,CAC9B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GACnC,OAAO,CAAC,OAAO,CAAC,CAQlB"}
|
package/dist/cache/discover.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the statements of a program: `sql(…)` calls (the callee is core's `Sql` or
|
|
3
|
+
* `TransactionalSql`, whatever it is named locally) and `migrations().add(…)` steps. Only the
|
|
4
|
+
* callee, the receiver and the first arguments are typed, not the call: discovering 500
|
|
5
|
+
* queries takes milliseconds and analyses none of them.
|
|
6
|
+
*/
|
|
1
7
|
const SLOT = /\{[A-Za-z_][A-Za-z0-9_]*\}/;
|
|
2
8
|
/** Core aliases taking `(DB, …, Q)`: the index of `Q`. */
|
|
3
|
-
const QUERY_ALIASES = {
|
|
4
|
-
|
|
9
|
+
const QUERY_ALIASES = {
|
|
10
|
+
RowOf: 2,
|
|
11
|
+
ParamsOf: 2,
|
|
12
|
+
ArgsOf: 2,
|
|
13
|
+
ParamsArgs: 2,
|
|
14
|
+
Validate: 1,
|
|
15
|
+
KindOf: 1,
|
|
16
|
+
NamesOf: 1,
|
|
17
|
+
Analysis: 1,
|
|
18
|
+
};
|
|
19
|
+
const DDL_ALIASES = {
|
|
20
|
+
ApplyDdl: 1,
|
|
21
|
+
ValidateDdl: 1,
|
|
22
|
+
};
|
|
5
23
|
const LOOKS_LIKE_QUERY = /^\s*(\(\s*)*(select|with|insert|update|delete|values|table)\b/i;
|
|
6
24
|
const LOOKS_LIKE_DDL = /^\s*(create|alter|drop|comment)\b/i;
|
|
7
25
|
export async function discover(program, checker, kinds, isCorePath, include) {
|
|
@@ -22,58 +40,83 @@ export async function discover(program, checker, kinds, isCorePath, include) {
|
|
|
22
40
|
const fileDbs = new Map();
|
|
23
41
|
const loose = [];
|
|
24
42
|
// statements written as types
|
|
25
|
-
const syms = refs.length
|
|
43
|
+
const syms = refs.length
|
|
44
|
+
? await checker.getSymbolAtLocation(refs.map((r) => r.typeName))
|
|
45
|
+
: [];
|
|
26
46
|
await Promise.all(refs.map(async (r, i) => {
|
|
27
47
|
let sym = syms[i];
|
|
28
48
|
if (sym && sym.flags & 2097152 /* SymbolFlags.Alias */)
|
|
29
49
|
sym = await checker.getAliasedSymbol(sym);
|
|
30
50
|
const args = r.typeArguments ?? [];
|
|
31
51
|
const isCore = !!sym && sym.declarations.some((d) => isCorePath(d.path));
|
|
32
|
-
const qAt = isCore
|
|
52
|
+
const qAt = isCore
|
|
53
|
+
? (QUERY_ALIASES[sym.name] ?? DDL_ALIASES[sym.name])
|
|
54
|
+
: undefined;
|
|
33
55
|
if (qAt !== undefined && args[0] && args[qAt]) {
|
|
34
56
|
const db = await checker.getTypeFromTypeNode(args[0]);
|
|
35
57
|
fileDbs.set(db.id, db);
|
|
36
58
|
const key = literalOf(args[qAt], kinds);
|
|
37
59
|
if (key === null)
|
|
38
60
|
return;
|
|
39
|
-
(sym.name in DDL_ALIASES ? ddl : types).push({
|
|
61
|
+
(sym.name in DDL_ALIASES ? ddl : types).push({
|
|
62
|
+
key,
|
|
63
|
+
db,
|
|
64
|
+
file: fileName,
|
|
65
|
+
});
|
|
40
66
|
return;
|
|
41
67
|
}
|
|
42
68
|
// the project's own alias of a core one: `type Row<Q extends string> = RowOf<DB, TM, Q>`
|
|
43
|
-
const wrapped = sym && !isCore
|
|
69
|
+
const wrapped = sym && !isCore
|
|
70
|
+
? await wrappedCoreAlias(sym, program, checker, kinds, isCorePath, aliasMemo)
|
|
71
|
+
: null;
|
|
44
72
|
if (wrapped) {
|
|
45
|
-
const key = args[wrapped.param]
|
|
73
|
+
const key = args[wrapped.param]
|
|
74
|
+
? literalOf(args[wrapped.param], kinds)
|
|
75
|
+
: null;
|
|
76
|
+
// Stryker disable next-line ConditionalExpression: a null key (the alias given a non-literal) gives no entry either way; this skips evaluating it
|
|
46
77
|
if (key !== null)
|
|
47
|
-
(wrapped.ddl ? ddl : types).push({
|
|
78
|
+
(wrapped.ddl ? ddl : types).push({
|
|
79
|
+
key,
|
|
80
|
+
db: wrapped.db,
|
|
81
|
+
file: fileName,
|
|
82
|
+
});
|
|
48
83
|
}
|
|
49
84
|
else if (!isCore) {
|
|
50
85
|
for (const a of args) {
|
|
51
86
|
const key = literalOf(a, kinds);
|
|
52
|
-
if (key !== null &&
|
|
87
|
+
if (key !== null &&
|
|
88
|
+
(LOOKS_LIKE_QUERY.test(key) || LOOKS_LIKE_DDL.test(key)))
|
|
53
89
|
loose.push(key);
|
|
54
90
|
}
|
|
55
91
|
}
|
|
56
92
|
}));
|
|
57
93
|
// migration steps: the receiver is core's Migrations<DB>
|
|
58
|
-
const adds = calls.filter((c) => c.expression.kind === kinds.PropertyAccessExpression &&
|
|
94
|
+
const adds = calls.filter((c) => c.expression.kind === kinds.PropertyAccessExpression &&
|
|
95
|
+
c.expression.name.text === "add");
|
|
59
96
|
if (adds.length) {
|
|
60
97
|
const receivers = await checker.getTypeAtLocation(adds.map((c) => c.expression.expression));
|
|
61
98
|
const args = await checker.getTypeAtLocation(adds.map((c) => c.arguments[0]));
|
|
62
99
|
await Promise.all(adds.map(async (_, i) => {
|
|
63
100
|
const r = receivers[i];
|
|
64
101
|
const a = args[i];
|
|
65
|
-
if (!a.isStringLiteralType() ||
|
|
102
|
+
if (!a.isStringLiteralType() ||
|
|
103
|
+
!(await isCoreRef(r, ["Migrations"], isCorePath)))
|
|
66
104
|
return;
|
|
67
105
|
const [db] = await checker.getTypeArguments(r);
|
|
106
|
+
// Stryker disable next-line ConditionalExpression: a Migrations<DB> receiver has its type argument
|
|
68
107
|
if (db)
|
|
69
|
-
ddl.push({ key: a.value, db });
|
|
108
|
+
ddl.push({ key: a.value, db, file: fileName });
|
|
70
109
|
}));
|
|
71
110
|
}
|
|
72
111
|
// sql(…) calls: the callee is core's Sql or TransactionalSql
|
|
73
112
|
const others = calls.filter((c) => !adds.includes(c));
|
|
74
|
-
const callees = others.length
|
|
113
|
+
const callees = others.length
|
|
114
|
+
? await checker.getTypeAtLocation(others.map((c) => c.expression))
|
|
115
|
+
: [];
|
|
75
116
|
const hits = (await Promise.all(others.map((_, i) => isCoreRef(callees[i], ["Sql", "TransactionalSql"], isCorePath).then((ok) => (ok ? i : -1))))).filter((i) => i >= 0);
|
|
76
|
-
const firstArgs = hits.length
|
|
117
|
+
const firstArgs = hits.length
|
|
118
|
+
? await checker.getTypeAtLocation(hits.map((i) => others[i].arguments[0]))
|
|
119
|
+
: [];
|
|
77
120
|
await Promise.all(hits.map(async (i, k) => {
|
|
78
121
|
const [db, tm, keys] = await checker.getTypeArguments(callees[i]);
|
|
79
122
|
if (!db || !tm || !keys)
|
|
@@ -83,12 +126,18 @@ export async function discover(program, checker, kinds, isCorePath, include) {
|
|
|
83
126
|
if (!a.isStringLiteralType())
|
|
84
127
|
return;
|
|
85
128
|
const call = others[i];
|
|
86
|
-
const slots = SLOT.test(a.value) && call.arguments.length > 1
|
|
87
|
-
|
|
129
|
+
const slots = SLOT.test(a.value) && call.arguments.length > 1
|
|
130
|
+
? await checker.getTypeAtLocation(call.arguments[1])
|
|
131
|
+
: null;
|
|
132
|
+
sql.push({ key: a.value, db, tm, keys, slots, file: fileName });
|
|
88
133
|
}));
|
|
89
134
|
for (const key of loose)
|
|
90
135
|
for (const db of fileDbs.values())
|
|
91
|
-
(LOOKS_LIKE_DDL.test(key) ? ddl : types).push({
|
|
136
|
+
(LOOKS_LIKE_DDL.test(key) ? ddl : types).push({
|
|
137
|
+
key,
|
|
138
|
+
db,
|
|
139
|
+
file: fileName,
|
|
140
|
+
});
|
|
92
141
|
}
|
|
93
142
|
return { sql, types, ddl };
|
|
94
143
|
}
|
|
@@ -115,11 +164,16 @@ function wrappedCoreAlias(sym, program, checker, kinds, isCorePath, memo) {
|
|
|
115
164
|
const dbArg = ref.typeArguments?.[0];
|
|
116
165
|
if (!qArg || !dbArg || qArg.kind !== kinds.TypeReference)
|
|
117
166
|
return null;
|
|
118
|
-
const qName = qArg.typeName
|
|
167
|
+
const qName = qArg.typeName
|
|
168
|
+
.text;
|
|
119
169
|
const param = decl.typeParameters?.findIndex((tp) => tp.name.text === qName) ?? -1;
|
|
120
170
|
if (param < 0)
|
|
121
171
|
return null;
|
|
122
|
-
return {
|
|
172
|
+
return {
|
|
173
|
+
param,
|
|
174
|
+
db: await checker.getTypeFromTypeNode(dbArg),
|
|
175
|
+
ddl: target.name in DDL_ALIASES,
|
|
176
|
+
};
|
|
123
177
|
})();
|
|
124
178
|
memo.set(sym.id, found);
|
|
125
179
|
}
|
|
@@ -135,9 +189,11 @@ function nodesIn(sf, kinds) {
|
|
|
135
189
|
const calls = [];
|
|
136
190
|
const refs = [];
|
|
137
191
|
const walk = (n) => {
|
|
138
|
-
if (n.kind === kinds.CallExpression &&
|
|
192
|
+
if (n.kind === kinds.CallExpression &&
|
|
193
|
+
n.arguments.length > 0)
|
|
139
194
|
calls.push(n);
|
|
140
|
-
else if (n.kind === kinds.TypeReference &&
|
|
195
|
+
else if (n.kind === kinds.TypeReference &&
|
|
196
|
+
n.typeArguments?.some((a) => literalOf(a, kinds) !== null))
|
|
141
197
|
refs.push(n);
|
|
142
198
|
n.forEachChild(walk);
|
|
143
199
|
};
|
|
@@ -149,6 +205,8 @@ export async function isCoreRef(type, names, isCorePath) {
|
|
|
149
205
|
if (!type.isTypeReference())
|
|
150
206
|
return false;
|
|
151
207
|
const sym = await type.getSymbol();
|
|
152
|
-
return !!sym &&
|
|
208
|
+
return (!!sym &&
|
|
209
|
+
names.includes(sym.name) &&
|
|
210
|
+
sym.declarations.some((d) => isCorePath(d.path)));
|
|
153
211
|
}
|
|
154
212
|
//# sourceMappingURL=discover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.js","sources":["../../src/cache/discover.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discover.js","sources":["../../src/cache/discover.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuDH,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAC1C,0DAA0D;AAC1D,MAAM,aAAa,GAAwC;IAC1D,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACX,CAAC;AACF,MAAM,WAAW,GAAwC;IACxD,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,CAAC;CACd,CAAC;AACF,MAAM,gBAAgB,GACrB,gEAAgE,CAAC;AAClE,MAAM,cAAc,GAAG,oCAAoC,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC7B,OAAgB,EAChB,OAAgB,EAChB,KAAY,EACZ,UAAqC,EACrC,OAAsC;IAEtC,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAmC,CAAC;IAC7D,KAAK,MAAM,QAAQ,IAAI,MAAM,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAC3D,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,SAAS;QACjC,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