@typed-sql/config 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/config
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,31 @@
1
+ # @typed-sql/config
2
+
3
+ Grammar-neutral configuration discovery and executable TypeScript config loading for
4
+ [typed-sql](https://github.com/Lojhan/typed-sql).
5
+
6
+ ```sh
7
+ pnpm add @typed-sql/config@next
8
+ ```
9
+
10
+ ```ts
11
+ import { discoverConfig, fromConfig, loadConfig } from "@typed-sql/config";
12
+
13
+ const file = await discoverConfig(process.cwd());
14
+ const loaded = await loadConfig({ file });
15
+ const schemaFile = fromConfig(loaded.directory, loaded.config.schema.file);
16
+ ```
17
+
18
+ Discovery walks upward for:
19
+
20
+ - `typed-sql.config.ts`
21
+ - `typed-sql.config.mts`
22
+ - `typed-sql.config.mjs`
23
+ - `typed-sql.config.js`
24
+
25
+ Loaded configs must default-export a valid dialect contract. The CLI and language server use this
26
+ package so neither tool needs a built-in PostgreSQL or MySQL dependency.
27
+
28
+ Config modules are executable application build code and have the same authority as other local
29
+ scripts. Do not load configs from untrusted repositories outside an appropriate sandbox.
30
+
31
+ MIT © typed-sql contributors
@@ -0,0 +1,14 @@
1
+ import { type SchemaSnapshot, type TypedSqlConfig } from "@typed-sql/core";
2
+ export interface LoadedConfig {
3
+ readonly file: string;
4
+ readonly directory: string;
5
+ readonly config: TypedSqlConfig<SchemaSnapshot, unknown>;
6
+ }
7
+ export interface LoadConfigOptions {
8
+ readonly file?: string;
9
+ readonly cwd?: string;
10
+ }
11
+ export declare function discoverConfig(start?: string): Promise<string>;
12
+ export declare function loadConfig(options?: LoadConfigOptions): Promise<LoadedConfig>;
13
+ export declare function fromConfig(directory: string, path: string): string;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAUzB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAWD,wBAAsB,cAAc,CAAC,KAAK,SAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAW3E;AAcD,wBAAsB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAOvF;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAElE"}
@@ -0,0 +1,60 @@
1
+ import { constants } from "node:fs";
2
+ import { access } from "node:fs/promises";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ import { DIALECT_CONTRACT_VERSION, } from "@typed-sql/core";
6
+ import { tsImport } from "tsx/esm/api";
7
+ const configNames = [
8
+ "typed-sql.config.ts",
9
+ "typed-sql.config.mts",
10
+ "typed-sql.config.mjs",
11
+ "typed-sql.config.js",
12
+ ];
13
+ async function exists(path) {
14
+ try {
15
+ await access(path, constants.F_OK);
16
+ return true;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ export async function discoverConfig(start = process.cwd()) {
23
+ let directory = resolve(start);
24
+ while (true) {
25
+ for (const name of configNames) {
26
+ const candidate = join(directory, name);
27
+ if (await exists(candidate))
28
+ return candidate;
29
+ }
30
+ const parent = dirname(directory);
31
+ if (parent === directory)
32
+ throw new Error(`Could not find typed-sql.config.ts from ${start}`);
33
+ directory = parent;
34
+ }
35
+ }
36
+ function isConfig(value) {
37
+ if (typeof value !== "object" || value === null)
38
+ return false;
39
+ const candidate = value;
40
+ return candidate.dialect?.contractVersion === DIALECT_CONTRACT_VERSION
41
+ && typeof candidate.dialect.id === "string"
42
+ && typeof candidate.dialect.sqlModule === "string"
43
+ && typeof candidate.dialect.analyze === "function"
44
+ && typeof candidate.dialect.validateSnapshot === "function"
45
+ && typeof candidate.schema?.file === "string"
46
+ && typeof candidate.outDir === "string";
47
+ }
48
+ export async function loadConfig(options = {}) {
49
+ const file = options.file === undefined
50
+ ? await discoverConfig(options.cwd)
51
+ : resolve(options.cwd ?? process.cwd(), options.file);
52
+ const module = await tsImport(pathToFileURL(file).href, pathToFileURL(join(dirname(file), "package.json")).href);
53
+ if (!isConfig(module.default))
54
+ throw new TypeError(`${file} must default-export defineConfig({...})`);
55
+ return { file, directory: dirname(file), config: module.default };
56
+ }
57
+ export function fromConfig(directory, path) {
58
+ return resolve(directory, path);
59
+ }
60
+ //# 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,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,wBAAwB,GAGzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,WAAW,GAAG;IAClB,qBAAqB;IACrB,sBAAsB;IACtB,sBAAsB;IACtB,qBAAqB;CACb,CAAC;AAaX,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU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AAC,OAAO,CAAC,GAAG,CAAC;QACnC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAmC,CAAC;IACnJ,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,0CAA0C,CAAC,CAAC;IACtG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,SAAiB,EAAE,IAAY;IACxD,OAAO,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@typed-sql/config",
3
+ "version": "1.0.0-beta.0",
4
+ "description": "Shared typed-sql config discovery and TypeScript config loading.",
5
+ "license": "MIT",
6
+ "author": "Lojhan",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Lojhan/typed-sql.git",
10
+ "directory": "packages/config"
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/config/src/index.js"
34
+ },
35
+ "dependencies": {
36
+ "tsx": "4.23.12",
37
+ "@typed-sql/core": "1.0.0-beta.0"
38
+ },
39
+ "scripts": {
40
+ "test": "poku test --reporter=compact --enforce",
41
+ "coverage": "poku test --coverage=@pokujs/c8 --coverageConfig=.c8rc.json --reporter=compact --enforce"
42
+ }
43
+ }