@typed-sql/ast 1.0.0-beta.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 +10 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/packages/ast/src/index.d.ts +6 -0
- package/dist/packages/ast/src/index.d.ts.map +1 -0
- package/dist/packages/ast/src/index.js +3 -0
- package/dist/packages/ast/src/index.js.map +1 -0
- package/dist/packages/ast/src/parser.d.ts +14 -0
- package/dist/packages/ast/src/parser.d.ts.map +1 -0
- package/dist/packages/ast/src/parser.js +800 -0
- package/dist/packages/ast/src/parser.js.map +1 -0
- package/dist/packages/ast/src/tokenizer.d.ts +15 -0
- package/dist/packages/ast/src/tokenizer.d.ts.map +1 -0
- package/dist/packages/ast/src/tokenizer.js +285 -0
- package/dist/packages/ast/src/tokenizer.js.map +1 -0
- package/dist/packages/ast/src/types.d.ts +249 -0
- package/dist/packages/ast/src/types.d.ts.map +1 -0
- package/dist/packages/ast/src/types.js +9 -0
- package/dist/packages/ast/src/types.js.map +1 -0
- package/package.json +39 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @typed-sql/ast
|
|
2
|
+
|
|
3
|
+
## 1.0.0-beta.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Release the first public typed-sql beta: exact TypeScript 7 row inference from static PostgreSQL and
|
|
8
|
+
MySQL, versioned schema introspection, application-owned drivers, config-driven grammar plugins,
|
|
9
|
+
CLI verification, editor language-server integration, versioned diagnostics, bounded parsing, and
|
|
10
|
+
real-database plus packed-tarball verification.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 typed-sql contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @typed-sql/ast
|
|
2
|
+
|
|
3
|
+
The bounded SQL tokenizer, parser, AST, and source-range package used by
|
|
4
|
+
[typed-sql](https://github.com/Lojhan/typed-sql).
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
pnpm add @typed-sql/ast@next
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { parseStatement, tokenize } from "@typed-sql/ast";
|
|
12
|
+
|
|
13
|
+
const tokens = tokenize("SELECT account.id FROM accounts AS account");
|
|
14
|
+
const statement = parseStatement("SELECT account.id FROM accounts AS account");
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The parser supports PostgreSQL and MySQL syntax modes and preserves ranges for diagnostics, hover,
|
|
18
|
+
definitions, and quick fixes. It is deliberately resource-bounded:
|
|
19
|
+
|
|
20
|
+
- maximum SQL length: 1,000,000 characters;
|
|
21
|
+
- maximum token count: 100,000;
|
|
22
|
+
- maximum parse nesting: 128 levels;
|
|
23
|
+
- structured `SqlTokenizeError` and `SqlParseError` failures with source ranges.
|
|
24
|
+
|
|
25
|
+
This is a compiler/tooling package; application code normally imports `sql` from
|
|
26
|
+
`@typed-sql/postgres` or `@typed-sql/mysql` instead. Unsupported syntax fails safely rather than
|
|
27
|
+
creating an optimistic type.
|
|
28
|
+
|
|
29
|
+
See the [supported SQL matrices](https://github.com/Lojhan/typed-sql#supported-sql) and
|
|
30
|
+
[diagnostic contract](https://github.com/Lojhan/typed-sql/blob/main/docs/DIAGNOSTICS.md).
|
|
31
|
+
|
|
32
|
+
MIT © typed-sql contributors
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DEFAULT_MAX_PARSE_DEPTH, parseSelect, parseStatement, SqlParseError } from "./parser.js";
|
|
2
|
+
export type { ParseOptions } from "./parser.js";
|
|
3
|
+
export { DEFAULT_MAX_SQL_LENGTH, DEFAULT_MAX_TOKENS, SqlTokenizeError, tokenize } from "./tokenizer.js";
|
|
4
|
+
export type { TokenizeOptions } from "./tokenizer.js";
|
|
5
|
+
export type * from "./types.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClG,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxG,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,mBAAmB,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAElG,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type TokenizeOptions } from "./tokenizer.js";
|
|
2
|
+
import { type SelectStatement, type SourceRange, type Statement } from "./types.js";
|
|
3
|
+
export declare const DEFAULT_MAX_PARSE_DEPTH = 128;
|
|
4
|
+
export interface ParseOptions extends TokenizeOptions {
|
|
5
|
+
readonly maxDepth?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class SqlParseError extends Error {
|
|
8
|
+
readonly code: string;
|
|
9
|
+
readonly range: SourceRange;
|
|
10
|
+
constructor(message: string, range: SourceRange, code?: string);
|
|
11
|
+
}
|
|
12
|
+
export declare function parseStatement(source: string, options?: ParseOptions): Statement;
|
|
13
|
+
export declare function parseSelect(source: string, options?: ParseOptions): SelectStatement;
|
|
14
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAeL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,SAAS,EASf,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAE5B,YAAY,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,SAAW,EAK/D;CACF;AA2tBD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,SAAS,CAEpF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,eAAe,CAIvF"}
|