@typed-sql/compiler 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 ADDED
@@ -0,0 +1,15 @@
1
+ # @typed-sql/compiler
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.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+ - @typed-sql/core@1.0.0-beta.0
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,29 @@
1
+ # @typed-sql/compiler
2
+
3
+ The dialect-neutral TypeScript source compiler behind [typed-sql](https://github.com/Lojhan/typed-sql).
4
+ It finds static SQL templates, asks the configured grammar for a row shape, injects that shape into
5
+ an in-memory TypeScript program, and preserves source mappings for diagnostics and editor tooling.
6
+
7
+ ```sh
8
+ pnpm add @typed-sql/compiler@next
9
+ ```
10
+
11
+ ```ts
12
+ import { checkFile, compileSource, extractStaticQueries, mapSqlRange } from "@typed-sql/compiler";
13
+ import { postgres } from "@typed-sql/postgres";
14
+
15
+ const result = compileSource({
16
+ source: 'import { sql } from "@typed-sql/postgres"; const q = sql`SELECT 1 AS value`;',
17
+ dialect: postgres(),
18
+ schema: { formatVersion: 1, dialect: "postgres", tables: {} },
19
+ });
20
+ ```
21
+
22
+ `compileSource` does not branch on PostgreSQL, MySQL, package names, or database drivers. It only
23
+ consumes the public `DialectPlugin` contract from `@typed-sql/core`. Unsupported, dynamic, invalid,
24
+ or ambiguous SQL remains a diagnostic or `Query<unknown>`—never `any`.
25
+
26
+ Application projects normally use this through `typed-sql check` or the language server. It is
27
+ public for grammar, editor, and build-tool integrations.
28
+
29
+ MIT © typed-sql contributors
@@ -0,0 +1,22 @@
1
+ import type { DialectPlugin, SchemaSnapshot, SqlDiagnostic } from "@typed-sql/core";
2
+ export interface CheckFileOptions<Snapshot extends SchemaSnapshot = SchemaSnapshot, Policy = unknown> {
3
+ readonly file: string;
4
+ readonly schema: string | SchemaSnapshot;
5
+ readonly dialect: DialectPlugin<Snapshot, Policy>;
6
+ readonly typePolicy?: Policy;
7
+ readonly project?: string;
8
+ readonly runTypeScript?: boolean;
9
+ }
10
+ export interface TypeScriptCheckResult {
11
+ readonly exitCode: number;
12
+ readonly output: string;
13
+ readonly command: string;
14
+ }
15
+ export interface CheckFileResult {
16
+ readonly transformedSource: string;
17
+ readonly sqlDiagnostics: readonly SqlDiagnostic[];
18
+ readonly typeScript?: TypeScriptCheckResult;
19
+ readonly ok: boolean;
20
+ }
21
+ export declare function checkFile<Snapshot extends SchemaSnapshot, Policy>(options: CheckFileOptions<Snapshot, Policy>): Promise<CheckFileResult>;
22
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../../src/check.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGpF,MAAM,WAAW,gBAAgB,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAAE,MAAM,GAAG,OAAO;IAClG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;IAClD,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAC;IAC5C,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;CACtB;AAkCD,wBAAsB,SAAS,CAAC,QAAQ,SAAS,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CA8C9I"}
@@ -0,0 +1,92 @@
1
+ import { access, readFile, unlink, writeFile } from "node:fs/promises";
2
+ import { constants } from "node:fs";
3
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
+ import { spawnSync } from "node:child_process";
5
+ import { compileSource } from "./compiler.js";
6
+ async function exists(path) {
7
+ try {
8
+ await access(path, constants.F_OK);
9
+ return true;
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
15
+ async function findUp(filename, start) {
16
+ let directory = resolve(start);
17
+ while (true) {
18
+ const candidate = join(directory, filename);
19
+ if (await exists(candidate))
20
+ return candidate;
21
+ const parent = dirname(directory);
22
+ if (parent === directory)
23
+ return undefined;
24
+ directory = parent;
25
+ }
26
+ }
27
+ function configPath(fromDirectory, target) {
28
+ const value = relative(fromDirectory, target).split(sep).join("/");
29
+ return value.startsWith(".") ? value : `./${value}`;
30
+ }
31
+ async function tscBinary(start) {
32
+ const name = process.platform === "win32" ? "tsc.cmd" : "tsc";
33
+ let directory = resolve(start);
34
+ while (true) {
35
+ const candidate = join(directory, "node_modules", ".bin", name);
36
+ if (await exists(candidate))
37
+ return candidate;
38
+ const parent = dirname(directory);
39
+ if (parent === directory)
40
+ return name;
41
+ directory = parent;
42
+ }
43
+ }
44
+ export async function checkFile(options) {
45
+ const file = resolve(options.file);
46
+ const source = await readFile(file, "utf8");
47
+ const schema = typeof options.schema === "string"
48
+ ? options.dialect.validateSnapshot(JSON.parse(await readFile(resolve(options.schema), "utf8")))
49
+ : options.dialect.validateSnapshot(options.schema);
50
+ const compilation = compileSource({
51
+ source,
52
+ dialect: options.dialect,
53
+ schema,
54
+ ...(options.typePolicy === undefined ? {} : { typePolicy: options.typePolicy }),
55
+ });
56
+ const hasSqlErrors = compilation.diagnostics.some((diagnostic) => diagnostic.severity === "error");
57
+ if (hasSqlErrors || options.runTypeScript === false) {
58
+ return { transformedSource: compilation.transformedSource, sqlDiagnostics: compilation.diagnostics, ok: !hasSqlErrors };
59
+ }
60
+ const directory = dirname(file);
61
+ const basename = file.slice(directory.length + 1);
62
+ const extensionIndex = basename.lastIndexOf(".");
63
+ const stem = extensionIndex === -1 ? basename : basename.slice(0, extensionIndex);
64
+ const extension = extensionIndex === -1 ? ".ts" : basename.slice(extensionIndex);
65
+ const nonce = `${process.pid}-${Date.now()}`;
66
+ const overlay = join(directory, `.typed-sql-${stem}-${nonce}${extension}`);
67
+ const tempConfig = join(directory, `.typed-sql-tsconfig-${nonce}.json`);
68
+ const project = options.project === undefined
69
+ ? await findUp("tsconfig.json", directory)
70
+ : resolve(options.project);
71
+ if (project === undefined)
72
+ throw new Error(`Could not find tsconfig.json from ${directory}`);
73
+ const config = {
74
+ extends: configPath(directory, project),
75
+ compilerOptions: { composite: false, declaration: false, declarationMap: false, incremental: false, noEmit: true },
76
+ files: [`./${overlay.slice(directory.length + 1)}`],
77
+ include: [],
78
+ };
79
+ await writeFile(overlay, compilation.transformedSource, "utf8");
80
+ await writeFile(tempConfig, `${JSON.stringify(config, null, 2)}\n`, "utf8");
81
+ try {
82
+ const binary = await tscBinary(directory);
83
+ const result = spawnSync(binary, ["--project", tempConfig, "--pretty", "false"], { cwd: directory, encoding: "utf8" });
84
+ const output = `${result.stdout ?? ""}${result.stderr ?? ""}`;
85
+ const typeScript = { exitCode: result.status ?? 1, output, command: `${binary} --project ${tempConfig}` };
86
+ return { transformedSource: compilation.transformedSource, sqlDiagnostics: compilation.diagnostics, typeScript, ok: typeScript.exitCode === 0 };
87
+ }
88
+ finally {
89
+ await Promise.allSettled([unlink(overlay), unlink(tempConfig)]);
90
+ }
91
+ }
92
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../../../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO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G,OAAO,EAAE,iBAAiB,EAAE,WAAW,CAAC,iBAAiB,EAAE,cAAc,EAAE,WAAW,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;IAClJ,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type DialectPlugin, type SchemaSnapshot, type SqlDiagnostic } from "@typed-sql/core";
2
+ import { type ExtractedQuery } from "./scanner.js";
3
+ export interface CompiledQuery {
4
+ readonly query: ExtractedQuery;
5
+ readonly rowType: string;
6
+ }
7
+ export interface CompileSourceResult {
8
+ readonly transformedSource: string;
9
+ readonly queries: readonly CompiledQuery[];
10
+ readonly diagnostics: readonly SqlDiagnostic[];
11
+ }
12
+ export interface CompileSourceOptions<Snapshot extends SchemaSnapshot, Policy> {
13
+ readonly source: string;
14
+ readonly dialect: DialectPlugin<Snapshot, Policy>;
15
+ readonly schema: Snapshot;
16
+ readonly typePolicy?: Policy;
17
+ }
18
+ export declare function compileSource<Snapshot extends SchemaSnapshot, Policy>(options: CompileSourceOptions<Snapshot, Policy>): CompileSourceResult;
19
+ //# sourceMappingURL=compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../../src/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAqC,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAEtF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;CAChD;AAED,MAAM,WAAW,oBAAoB,CAAC,QAAQ,SAAS,cAAc,EAAE,MAAM;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAMD,wBAAgB,aAAa,CAAC,QAAQ,SAAS,cAAc,EAAE,MAAM,EACnE,OAAO,EAAE,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,GAC9C,mBAAmB,CAoBrB"}
@@ -0,0 +1,27 @@
1
+ import { rowTypeLiteral, } from "@typed-sql/core";
2
+ import { extractStaticQueries, mapSqlRange } from "./scanner.js";
3
+ function mapDiagnostic(source, query, diagnostic) {
4
+ return { ...diagnostic, range: mapSqlRange(source, query, diagnostic.range) };
5
+ }
6
+ export function compileSource(options) {
7
+ const { source, dialect, schema } = options;
8
+ if (schema.dialect !== dialect.id) {
9
+ throw new TypeError(`Dialect ${dialect.id} cannot compile a ${schema.dialect} schema snapshot`);
10
+ }
11
+ const extracted = extractStaticQueries(source, (index) => dialect.placeholder(index), [dialect.sqlModule]);
12
+ const compiled = [];
13
+ const diagnostics = [];
14
+ for (const query of extracted) {
15
+ const resolved = dialect.analyze(query.sql, schema, options.typePolicy);
16
+ diagnostics.push(...resolved.diagnostics.map((diagnostic) => mapDiagnostic(source, query, diagnostic)));
17
+ if (!resolved.diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
18
+ compiled.push({ query, rowType: resolved.resultKind === "command" ? "never" : rowTypeLiteral(resolved.columns) });
19
+ }
20
+ }
21
+ let transformedSource = source;
22
+ for (const item of [...compiled].sort((a, b) => b.query.insertionPosition - a.query.insertionPosition)) {
23
+ transformedSource = `${transformedSource.slice(0, item.query.insertionPosition)}<${item.rowType}>${transformedSource.slice(item.query.insertionPosition)}`;
24
+ }
25
+ return { transformedSource, queries: compiled, diagnostics };
26
+ }
27
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../../src/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAIf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAuB,MAAM,cAAc,CAAC;AAoBtF,SAAS,aAAa,CAAC,MAAc,EAAE,KAAqB,EAAE,UAAyB;IACrF,OAAO,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAA+C;IAE/C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC5C,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,CAAC,WAAW,OAAO,CAAC,EAAE,qBAAqB,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAClG,CAAC;IACD,MAAM,SAAS,GAAG,oBAAoB,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3G,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,MAAM,WAAW,GAAoB,EAAE,CAAC;IACxC,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAA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js";
2
+ export { compileSource } from "./compiler.js";
3
+ export { extractStaticQueries, mapSqlRange } from "./scanner.js";
4
+ export type * from "./check.js";
5
+ export type * from "./compiler.js";
6
+ export type * from "./scanner.js";
7
+ //# 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,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { checkFile } from "./check.js";
2
+ export { compileSource } from "./compiler.js";
3
+ export { extractStaticQueries, mapSqlRange } from "./scanner.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { SourceRange } from "@typed-sql/core";
2
+ export interface ExtractedQuery {
3
+ readonly tagName: string;
4
+ readonly sql: string;
5
+ readonly parameterCount: number;
6
+ readonly insertionPosition: number;
7
+ readonly range: SourceRange;
8
+ readonly sqlOffsetMap: readonly number[];
9
+ }
10
+ export declare function extractStaticQueries(source: string, placeholderFor: (index: number) => string, sqlModules?: readonly string[]): readonly ExtractedQuery[];
11
+ export declare function mapSqlRange(source: string, query: ExtractedQuery, range: SourceRange): SourceRange;
12
+ //# sourceMappingURL=scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../../../src/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAiHD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EACzC,UAAU,GAAE,SAAS,MAAM,EAAwB,GAClD,SAAS,cAAc,EAAE,CA8B3B;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,GAAG,WAAW,CAIlG"}
@@ -0,0 +1,168 @@
1
+ const importPattern = /import\s*\{([\s\S]*?)\}\s*from\s*["']([^"']+)["']/g;
2
+ function importedSqlNames(source, sqlModules) {
3
+ const names = new Set();
4
+ for (const match of source.matchAll(importPattern)) {
5
+ const specifiers = match[1];
6
+ const moduleName = match[2];
7
+ if (specifiers === undefined || moduleName === undefined)
8
+ continue;
9
+ if (!sqlModules.has(moduleName))
10
+ continue;
11
+ for (const specifier of specifiers.split(",")) {
12
+ const parts = specifier.trim().split(/\s+as\s+/);
13
+ if (parts[0] === "sql")
14
+ names.add(parts[1] ?? "sql");
15
+ }
16
+ }
17
+ return names;
18
+ }
19
+ function positionRange(source, start, end) {
20
+ const before = source.slice(0, start);
21
+ const lastNewline = before.lastIndexOf("\n");
22
+ return {
23
+ start,
24
+ end,
25
+ line: before.split("\n").length,
26
+ column: start - lastNewline,
27
+ };
28
+ }
29
+ function skipQuoted(source, start, quote) {
30
+ let index = start + 1;
31
+ while (index < source.length) {
32
+ if (source[index] === "\\")
33
+ index += 2;
34
+ else if (source[index] === quote)
35
+ return index + 1;
36
+ else
37
+ index += 1;
38
+ }
39
+ return source.length;
40
+ }
41
+ function skipLineComment(source, start) {
42
+ const end = source.indexOf("\n", start + 2);
43
+ return end === -1 ? source.length : end + 1;
44
+ }
45
+ function skipBlockComment(source, start) {
46
+ const end = source.indexOf("*/", start + 2);
47
+ return end === -1 ? source.length : end + 2;
48
+ }
49
+ function interpolationEnd(source, start) {
50
+ let depth = 1;
51
+ let index = start;
52
+ while (index < source.length) {
53
+ const char = source[index];
54
+ if (char === '"' || char === "'")
55
+ index = skipQuoted(source, index, char);
56
+ else if (char === "`")
57
+ index = skipQuoted(source, index, "`");
58
+ else if (char === "/" && source[index + 1] === "/")
59
+ index = skipLineComment(source, index);
60
+ else if (char === "/" && source[index + 1] === "*")
61
+ index = skipBlockComment(source, index);
62
+ else if (char === "{") {
63
+ depth += 1;
64
+ index += 1;
65
+ }
66
+ else if (char === "}") {
67
+ depth -= 1;
68
+ index += 1;
69
+ if (depth === 0)
70
+ return index;
71
+ }
72
+ else
73
+ index += 1;
74
+ }
75
+ return source.length;
76
+ }
77
+ function extractTemplate(source, tagName, tagStart, backtick, placeholderFor) {
78
+ let index = backtick + 1;
79
+ let sql = "";
80
+ let parameterCount = 0;
81
+ const sqlOffsetMap = [];
82
+ while (index < source.length) {
83
+ const char = source[index];
84
+ if (char === "`") {
85
+ return {
86
+ tagName,
87
+ sql,
88
+ parameterCount,
89
+ insertionPosition: tagStart + tagName.length,
90
+ range: positionRange(source, tagStart, index + 1),
91
+ sqlOffsetMap,
92
+ };
93
+ }
94
+ if (char === "\\" && index + 1 < source.length) {
95
+ sql += source[index + 1];
96
+ sqlOffsetMap.push(index);
97
+ index += 2;
98
+ continue;
99
+ }
100
+ if (char === "$" && source[index + 1] === "{") {
101
+ parameterCount += 1;
102
+ const placeholder = placeholderFor(parameterCount);
103
+ sql += placeholder;
104
+ for (let offset = 0; offset < placeholder.length; offset += 1)
105
+ sqlOffsetMap.push(index);
106
+ index = interpolationEnd(source, index + 2);
107
+ continue;
108
+ }
109
+ sql += char;
110
+ sqlOffsetMap.push(index);
111
+ index += 1;
112
+ }
113
+ return undefined;
114
+ }
115
+ export function extractStaticQueries(source, placeholderFor, sqlModules = ["@typed-sql/core"]) {
116
+ const names = importedSqlNames(source, new Set(sqlModules));
117
+ if (names.size === 0)
118
+ return [];
119
+ const queries = [];
120
+ let index = 0;
121
+ while (index < source.length) {
122
+ const char = source[index];
123
+ if (char === '"' || char === "'") {
124
+ index = skipQuoted(source, index, char);
125
+ continue;
126
+ }
127
+ if (char === "`") {
128
+ index = skipQuoted(source, index, "`");
129
+ continue;
130
+ }
131
+ if (char === "/" && source[index + 1] === "/") {
132
+ index = skipLineComment(source, index);
133
+ continue;
134
+ }
135
+ if (char === "/" && source[index + 1] === "*") {
136
+ index = skipBlockComment(source, index);
137
+ continue;
138
+ }
139
+ if (char !== undefined && /[A-Za-z_$]/.test(char)) {
140
+ const start = index;
141
+ index += 1;
142
+ while (index < source.length && /[A-Za-z0-9_$]/.test(source[index]))
143
+ index += 1;
144
+ const name = source.slice(start, index);
145
+ if (!names.has(name))
146
+ continue;
147
+ let cursor = index;
148
+ while (/\s/.test(source[cursor] ?? ""))
149
+ cursor += 1;
150
+ if (source[cursor] !== "`")
151
+ continue;
152
+ const query = extractTemplate(source, name, start, cursor, placeholderFor);
153
+ if (query !== undefined) {
154
+ queries.push(query);
155
+ index = query.range.end;
156
+ }
157
+ continue;
158
+ }
159
+ index += 1;
160
+ }
161
+ return queries;
162
+ }
163
+ export function mapSqlRange(source, query, range) {
164
+ const start = query.sqlOffsetMap[range.start] ?? query.range.start;
165
+ const last = range.end > range.start ? query.sqlOffsetMap[range.end - 1] : start;
166
+ return positionRange(source, start, (last ?? start) + 1);
167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 @@
1
+ {
2
+ "name": "@typed-sql/compiler",
3
+ "version": "1.0.0-beta.0",
4
+ "description": "Dialect-neutral TypeScript source extraction and typed SQL compilation.",
5
+ "license": "MIT",
6
+ "author": "Lojhan",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Lojhan/typed-sql.git",
10
+ "directory": "packages/compiler"
11
+ },
12
+ "homepage": "https://github.com/Lojhan/typed-sql#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/Lojhan/typed-sql/issues"
15
+ },
16
+ "engines": {
17
+ "node": ">=22.11"
18
+ },
19
+ "files": [
20
+ "dist/**/*.js",
21
+ "dist/**/*.d.ts",
22
+ "dist/**/*.map",
23
+ "README.md",
24
+ "LICENSE",
25
+ "CHANGELOG.md"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "sideEffects": false,
31
+ "type": "module",
32
+ "exports": {
33
+ ".": "./dist/packages/compiler/src/index.js"
34
+ },
35
+ "dependencies": {
36
+ "@typed-sql/core": "1.0.0-beta.0"
37
+ },
38
+ "scripts": {
39
+ "test": "poku test --reporter=compact --enforce",
40
+ "coverage": "poku test --coverage=@pokujs/c8 --coverageConfig=.c8rc.json --reporter=compact --enforce"
41
+ }
42
+ }