@expressive/sql 0.4.4 → 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.
Files changed (52) hide show
  1. package/README.md +54 -0
  2. package/dist/bin.d.ts +1 -0
  3. package/dist/bin.js +9 -0
  4. package/dist/bin.js.map +1 -0
  5. package/dist/cli.d.ts +6 -0
  6. package/dist/cli.js +80 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/columns/Bool.d.ts +37 -0
  9. package/dist/columns/Bool.js +28 -0
  10. package/dist/columns/Bool.js.map +1 -0
  11. package/dist/columns/Num.d.ts +59 -0
  12. package/dist/columns/Num.js +42 -0
  13. package/dist/columns/Num.js.map +1 -0
  14. package/dist/columns/One.d.ts +25 -0
  15. package/dist/columns/One.js +15 -0
  16. package/dist/columns/One.js.map +1 -0
  17. package/dist/columns/Str.d.ts +36 -0
  18. package/dist/columns/Str.js +21 -0
  19. package/dist/columns/Str.js.map +1 -0
  20. package/dist/columns/Time.d.ts +52 -0
  21. package/dist/columns/Time.js +45 -0
  22. package/dist/columns/Time.js.map +1 -0
  23. package/dist/connection/Connection.d.ts +61 -0
  24. package/dist/connection/Connection.js +104 -0
  25. package/dist/connection/Connection.js.map +1 -0
  26. package/dist/connection/Generator.d.ts +68 -0
  27. package/dist/connection/Generator.js +242 -0
  28. package/dist/connection/Generator.js.map +1 -0
  29. package/dist/datatypes.d.ts +102 -0
  30. package/dist/datatypes.js +47 -0
  31. package/dist/datatypes.js.map +1 -0
  32. package/dist/dispatch.d.ts +6 -0
  33. package/dist/dispatch.js +44 -0
  34. package/dist/dispatch.js.map +1 -0
  35. package/dist/index.d.ts +12 -692
  36. package/dist/index.js +13 -1092
  37. package/dist/sqlite/SQLiteConnection.d.ts +83 -0
  38. package/dist/sqlite/SQLiteConnection.js +395 -0
  39. package/dist/sqlite/SQLiteConnection.js.map +1 -0
  40. package/dist/sqlite/SQLiteGenerator.d.ts +15 -0
  41. package/dist/sqlite/SQLiteGenerator.js +54 -0
  42. package/dist/sqlite/SQLiteGenerator.js.map +1 -0
  43. package/dist/sqlite/engine.d.ts +47 -0
  44. package/dist/sqlite/engine.js +104 -0
  45. package/dist/sqlite/engine.js.map +1 -0
  46. package/dist/utils.d.ts +5 -0
  47. package/dist/utils.js +8 -0
  48. package/dist/utils.js.map +1 -0
  49. package/package.json +64 -11
  50. package/skills/expressive-sql/SKILL.md +136 -0
  51. package/dist/index.d.mts +0 -692
  52. package/dist/index.mjs +0 -1052
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @expressive/sql
2
+
3
+ Entities on [`@expressive/mvc`](https://github.com/gabeklein/expressive-mvc) Model, stored in SQLite with nothing else installed. Re-exports [`@expressive/orm`](https://github.com/gabeklein/expressive-orm/tree/main/packages/orm): entities, field helpers, `Query` and a connection come from this one import. Full guide: [README](https://github.com/gabeklein/expressive-orm#readme). Agent skill: [skills/expressive-sql](skills/expressive-sql/SKILL.md), shipped in the package with `expressive-orm`'s declared.
4
+
5
+ ```sh
6
+ npm install @expressive/sql @expressive/mvc
7
+ ```
8
+
9
+ SQLite is built into Bun (`bun:sqlite`) and Node 24 (`node:sqlite`). Elsewhere add one of `better-sqlite3`, `sqlite3` or `@libsql/client`; the first found is used.
10
+
11
+ ```ts
12
+ import { Query, SQLiteConnection, Type, greaterThan, num, one, str } from '@expressive/sql';
13
+
14
+ class User extends Type {
15
+ name = str();
16
+ age = num(null);
17
+ }
18
+
19
+ class Post extends Type {
20
+ author = one(User);
21
+ title = str({ type: "varchar", length: 120 });
22
+ }
23
+
24
+ const db = await SQLiteConnection.new([User, Post], "app.db");
25
+
26
+ const gabe = await User.new({ name: "Gabe", age: 35 });
27
+ await Post.insert({ author: gabe, title: "Hello" });
28
+
29
+ const adults = await User.find({ age: greaterThan(17) });
30
+
31
+ const titles = await Query(where => {
32
+ const post = where(Post);
33
+
34
+ where(post.author.name).equal("Gabe");
35
+
36
+ return post.title;
37
+ });
38
+
39
+ gabe.get(({ name }) => console.log(name));
40
+ await gabe.set({ name: "Gabriel" });
41
+
42
+ await db.close();
43
+ ```
44
+
45
+ `SQLiteConnection.new(types, filename?)` binds the classes; awaiting it creates missing tables, adds missing columns and checks existing ones. SQLite cannot add a `unique` column or one defaulting to `"NOW"`; `sync` reports those. Omit `filename` for an in-memory database.
46
+
47
+ ## Also here
48
+
49
+ - `Connection` - the SQL connection base: orm's floor implemented over `Query`, so a dialect supplies `prepare` (with a `Generator` subclass) and `sync`.
50
+ - `Generator` - renders a `Query` builder as SQL.
51
+ - Driver seams - `Builder`, `DataTable`, `DataField`, `Parameter`, `Computed`, `QueryTemplate`, `Where` - import from `@expressive/orm/driver`. A dialect package lists `@expressive/orm` as a direct dependency, at the range this package depends on.
52
+ - `StringColumn`, `NumericColumn`, `BooleanColumn`, `TimeColumn`, `ForeignColumn` - the column classes behind `str`, `num`, `bool`, `date` and `one`, carrying the SQL datatype vocabulary and its validation. See [Datatypes](https://github.com/gabeklein/expressive-orm#datatypes).
53
+
54
+ SQLite has no live rows - neither `node:sqlite` nor `bun:sqlite` exposes an update hook. For those, use [`@expressive/postgres`](https://github.com/gabeklein/expressive-orm/tree/main/packages/postgres).
package/dist/bin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/bin.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { dispatch } from "./dispatch.js";
3
+
4
+ //#region src/bin.ts
5
+ process.exitCode = await dispatch(process.argv.slice(2), process.cwd(), console);
6
+
7
+ //#endregion
8
+ export { };
9
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { dispatch } from './dispatch';\n\nprocess.exitCode = await dispatch(process.argv.slice(2), process.cwd(), console);\n"],"mappings":";;;;AAGA,QAAQ,WAAW,MAAM,SAAS,QAAQ,KAAK,MAAM,EAAE,EAAE,QAAQ,KAAK,EAAE,QAAQ"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ //#region src/cli.d.ts
2
+ type Output = Pick<Console, "log" | "error">;
3
+ declare function sql(args: string[], out: Output): Promise<number>;
4
+ //#endregion
5
+ export { sql as default };
6
+ //# sourceMappingURL=cli.d.ts.map
package/dist/cli.js ADDED
@@ -0,0 +1,80 @@
1
+ import { resolve } from "node:path";
2
+ import { pathToFileURL } from "node:url";
3
+
4
+ //#region src/cli.ts
5
+ const COLLECT = Symbol.for("@expressive/orm.collect");
6
+ const USAGE = `Usage: expressive sql <check | sync [--force]> <entry>
7
+
8
+ check list what sync would change; exits 1 if anything would
9
+ sync create missing tables, columns and indexes
10
+ --force sync also rebuilds columns whose type or nullability drifted
11
+
12
+ <entry> is the module that creates your connections, imported without syncing them.
13
+ Connections must be created while it loads.`;
14
+ async function collect(entry) {
15
+ const found = /* @__PURE__ */ new Set();
16
+ const scope = globalThis;
17
+ scope[COLLECT] = found;
18
+ try {
19
+ await import(pathToFileURL(resolve(entry)).href);
20
+ } finally {
21
+ delete scope[COLLECT];
22
+ }
23
+ return found;
24
+ }
25
+ async function report(conn, problems, force, out) {
26
+ const remain = force || !problems.length ? void 0 : new Set((await conn.plan(true)).problems);
27
+ for (const problem of problems) out.log(` ! ${problem}${remain && !remain.has(problem) ? " (sync --force rebuilds it)" : ""}`);
28
+ }
29
+ async function check(conn, out) {
30
+ const { steps, problems } = await conn.plan();
31
+ const current = !steps.length && !problems.length;
32
+ out.log(`${conn.constructor.name}: ${current ? "up to date" : "out of date"}`);
33
+ for (const step of steps) out.log(` + ${step.action}`);
34
+ await report(conn, problems, false, out);
35
+ return current;
36
+ }
37
+ async function sync(conn, force, out) {
38
+ const { steps, problems } = await conn.plan(force);
39
+ if (problems.length) {
40
+ out.log(`${conn.constructor.name}: not synced`);
41
+ await report(conn, problems, force, out);
42
+ return false;
43
+ }
44
+ await conn.sync(true, force);
45
+ out.log(`${conn.constructor.name}: ${steps.length ? "synced" : "up to date"}`);
46
+ for (const step of steps) out.log(` + ${step.action}`);
47
+ return true;
48
+ }
49
+ async function sql(args, out) {
50
+ const [command, ...rest] = args;
51
+ const force = rest.includes("--force");
52
+ const [entry, ...extra] = rest.filter((arg) => arg != "--force");
53
+ const valid = command == "sync" || command == "check" && !force;
54
+ if (!entry || extra.length || !valid) {
55
+ out.error(USAGE);
56
+ return 2;
57
+ }
58
+ const connections = await collect(entry).catch((error) => {
59
+ out.error(`Could not import ${entry}: ${error.message}`);
60
+ });
61
+ if (!connections) return 1;
62
+ if (!connections.size) {
63
+ out.error(`${entry} created no connection.`);
64
+ return 1;
65
+ }
66
+ let ok = true;
67
+ try {
68
+ for (const conn of connections) if (typeof conn.plan != "function") {
69
+ out.log(`${conn.constructor.name}: cannot plan a sync`);
70
+ ok = false;
71
+ } else ok = await (command == "check" ? check(conn, out) : sync(conn, force, out)) && ok;
72
+ } finally {
73
+ for (const conn of connections) await conn.close();
74
+ }
75
+ return ok ? 0 : 1;
76
+ }
77
+
78
+ //#endregion
79
+ export { sql as default };
80
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { Connection } from './connection/Connection';\n\nconst COLLECT = Symbol.for(\"@expressive/orm.collect\");\n\nconst USAGE = `Usage: expressive sql <check | sync [--force]> <entry>\n\n check list what sync would change; exits 1 if anything would\n sync create missing tables, columns and indexes\n --force sync also rebuilds columns whose type or nullability drifted\n\n<entry> is the module that creates your connections, imported without syncing them.\nConnections must be created while it loads.`;\n\ntype Output = Pick<Console, \"log\" | \"error\">;\n\nasync function collect(entry: string){\n const found = new Set<Connection>();\n const scope = globalThis as { [COLLECT]?: Set<Connection> };\n\n scope[COLLECT] = found;\n\n try {\n await import(pathToFileURL(resolve(entry)).href);\n }\n finally {\n delete scope[COLLECT];\n }\n\n return found;\n}\n\nasync function report(conn: Connection, problems: string[], force: boolean, out: Output){\n const remain = force || !problems.length ? undefined : new Set((await conn.plan(true)).problems);\n\n for (const problem of problems)\n out.log(` ! ${problem}${remain && !remain.has(problem) ? \" (sync --force rebuilds it)\" : \"\"}`);\n}\n\nasync function check(conn: Connection, out: Output){\n const { steps, problems } = await conn.plan();\n const current = !steps.length && !problems.length;\n\n out.log(`${conn.constructor.name}: ${current ? \"up to date\" : \"out of date\"}`);\n\n for (const step of steps)\n out.log(` + ${step.action}`);\n\n await report(conn, problems, false, out);\n\n return current;\n}\n\nasync function sync(conn: Connection, force: boolean, out: Output){\n const { steps, problems } = await conn.plan(force);\n\n if (problems.length) {\n out.log(`${conn.constructor.name}: not synced`);\n await report(conn, problems, force, out);\n\n return false;\n }\n\n await conn.sync(true, force);\n\n out.log(`${conn.constructor.name}: ${steps.length ? \"synced\" : \"up to date\"}`);\n\n for (const step of steps)\n out.log(` + ${step.action}`);\n\n return true;\n}\n\nexport default async function sql(args: string[], out: Output): Promise<number> {\n const [command, ...rest] = args;\n const force = rest.includes(\"--force\");\n const [entry, ...extra] = rest.filter(arg => arg != \"--force\");\n const valid = command == \"sync\" || command == \"check\" && !force;\n\n if (!entry || extra.length || !valid) {\n out.error(USAGE);\n return 2;\n }\n\n const connections = await collect(entry).catch((error: Error) => {\n out.error(`Could not import ${entry}: ${error.message}`);\n });\n\n if (!connections)\n return 1;\n\n if (!connections.size) {\n out.error(`${entry} created no connection.`);\n return 1;\n }\n\n let ok = true;\n\n try {\n for (const conn of connections)\n if (typeof conn.plan != \"function\") {\n out.log(`${conn.constructor.name}: cannot plan a sync`);\n ok = false;\n }\n else\n ok = await (command == \"check\" ? check(conn, out) : sync(conn, force, out)) && ok;\n }\n finally {\n for (const conn of connections)\n await conn.close();\n }\n\n return ok ? 0 : 1;\n}\n"],"mappings":";;;;AAKA,MAAM,UAAU,OAAO,IAAI,0BAA0B;AAErD,MAAM,QAAQ;;;;;;;;AAWd,eAAe,QAAQ,OAAc;CACnC,MAAM,wBAAQ,IAAI,KAAiB;CACnC,MAAM,QAAQ;AAEd,OAAM,WAAW;AAEjB,KAAI;AACF,QAAM,OAAO,cAAc,QAAQ,MAAM,CAAC,CAAC;WAErC;AACN,SAAO,MAAM;;AAGf,QAAO;;AAGT,eAAe,OAAO,MAAkB,UAAoB,OAAgB,KAAY;CACtF,MAAM,SAAS,SAAS,CAAC,SAAS,SAAS,SAAY,IAAI,KAAK,MAAM,KAAK,KAAK,KAAK,EAAE,SAAS;AAEhG,MAAK,MAAM,WAAW,SACpB,KAAI,IAAI,OAAO,UAAU,UAAU,CAAC,OAAO,IAAI,QAAQ,GAAG,gCAAgC,KAAK;;AAGnG,eAAe,MAAM,MAAkB,KAAY;CACjD,MAAM,EAAE,OAAO,aAAa,MAAM,KAAK,MAAM;CAC7C,MAAM,UAAU,CAAC,MAAM,UAAU,CAAC,SAAS;AAE3C,KAAI,IAAI,GAAG,KAAK,YAAY,KAAK,IAAI,UAAU,eAAe,gBAAgB;AAE9E,MAAK,MAAM,QAAQ,MACjB,KAAI,IAAI,OAAO,KAAK,SAAS;AAE/B,OAAM,OAAO,MAAM,UAAU,OAAO,IAAI;AAExC,QAAO;;AAGT,eAAe,KAAK,MAAkB,OAAgB,KAAY;CAChE,MAAM,EAAE,OAAO,aAAa,MAAM,KAAK,KAAK,MAAM;AAElD,KAAI,SAAS,QAAQ;AACnB,MAAI,IAAI,GAAG,KAAK,YAAY,KAAK,cAAc;AAC/C,QAAM,OAAO,MAAM,UAAU,OAAO,IAAI;AAExC,SAAO;;AAGT,OAAM,KAAK,KAAK,MAAM,MAAM;AAE5B,KAAI,IAAI,GAAG,KAAK,YAAY,KAAK,IAAI,MAAM,SAAS,WAAW,eAAe;AAE9E,MAAK,MAAM,QAAQ,MACjB,KAAI,IAAI,OAAO,KAAK,SAAS;AAE/B,QAAO;;AAGT,eAA8B,IAAI,MAAgB,KAA8B;CAC9E,MAAM,CAAC,SAAS,GAAG,QAAQ;CAC3B,MAAM,QAAQ,KAAK,SAAS,UAAU;CACtC,MAAM,CAAC,OAAO,GAAG,SAAS,KAAK,QAAO,QAAO,OAAO,UAAU;CAC9D,MAAM,QAAQ,WAAW,UAAU,WAAW,WAAW,CAAC;AAE1D,KAAI,CAAC,SAAS,MAAM,UAAU,CAAC,OAAO;AACpC,MAAI,MAAM,MAAM;AAChB,SAAO;;CAGT,MAAM,cAAc,MAAM,QAAQ,MAAM,CAAC,OAAO,UAAiB;AAC/D,MAAI,MAAM,oBAAoB,MAAM,IAAI,MAAM,UAAU;GACxD;AAEF,KAAI,CAAC,YACH,QAAO;AAET,KAAI,CAAC,YAAY,MAAM;AACrB,MAAI,MAAM,GAAG,MAAM,yBAAyB;AAC5C,SAAO;;CAGT,IAAI,KAAK;AAET,KAAI;AACF,OAAK,MAAM,QAAQ,YACjB,KAAI,OAAO,KAAK,QAAQ,YAAY;AAClC,OAAI,IAAI,GAAG,KAAK,YAAY,KAAK,sBAAsB;AACvD,QAAK;QAGL,MAAK,OAAO,WAAW,UAAU,MAAM,MAAM,IAAI,GAAG,KAAK,MAAM,OAAO,IAAI,KAAK;WAE7E;AACN,OAAK,MAAM,QAAQ,YACjB,OAAM,KAAK,OAAO;;AAGtB,QAAO,KAAK,IAAI"}
@@ -0,0 +1,37 @@
1
+ import { bool } from "@expressive/orm";
2
+
3
+ //#region src/columns/Bool.d.ts
4
+ declare module '@expressive/orm' {
5
+ namespace bool {
6
+ interface Boolean extends BooleanColumn {
7
+ type: "boolean";
8
+ }
9
+ interface Integer extends BooleanColumn {
10
+ type: "integer";
11
+ }
12
+ interface Text extends BooleanColumn {
13
+ type: "text";
14
+ either: readonly [true: string, false: string];
15
+ }
16
+ interface VarChar extends BooleanColumn {
17
+ type: "varchar";
18
+ either: readonly [true: string, false: string];
19
+ }
20
+ interface Types {
21
+ default: Boolean;
22
+ boolean: Boolean;
23
+ integer: Integer;
24
+ text: Text;
25
+ varchar: VarChar;
26
+ }
27
+ }
28
+ }
29
+ /** Column class behind `bool()` on SQL - `boolean`, `integer`, or `text` / `varchar` with `either`. */
30
+ declare class BooleanColumn extends bool.Type {
31
+ type: bool.DataType;
32
+ get datatype(): string;
33
+ set(value: unknown): string | number | boolean | null | undefined;
34
+ }
35
+ //#endregion
36
+ export { BooleanColumn };
37
+ //# sourceMappingURL=Bool.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { bool } from "@expressive/orm";
2
+
3
+ //#region src/columns/Bool.ts
4
+ /** Column class behind `bool()` on SQL - `boolean`, `integer`, or `text` / `varchar` with `either`. */
5
+ var BooleanColumn = class extends bool.Type {
6
+ constructor(..._args) {
7
+ super(..._args);
8
+ this.type = "boolean";
9
+ }
10
+ get datatype() {
11
+ const { type, either } = this;
12
+ if (type === "varchar" && either) {
13
+ const [TRUE, FALSE] = either.map(String);
14
+ return `varchar(${Math.max(TRUE.length, FALSE.length)})`;
15
+ }
16
+ return type;
17
+ }
18
+ set(value) {
19
+ const out = super.set(value);
20
+ if (out == null || this.either || this.type !== "boolean") return out;
21
+ return value;
22
+ }
23
+ };
24
+ bool.Type = BooleanColumn;
25
+
26
+ //#endregion
27
+ export { BooleanColumn };
28
+ //# sourceMappingURL=Bool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bool.js","names":[],"sources":["../../src/columns/Bool.ts"],"sourcesContent":["import { bool } from '@expressive/orm';\n\ndeclare module '@expressive/orm' {\n namespace bool {\n interface Boolean extends BooleanColumn {\n type: \"boolean\";\n }\n\n interface Integer extends BooleanColumn {\n type: \"integer\";\n }\n\n interface Text extends BooleanColumn {\n type: \"text\";\n either: readonly [true: string, false: string];\n }\n\n interface VarChar extends BooleanColumn {\n type: \"varchar\";\n either: readonly [true: string, false: string];\n }\n\n interface Types {\n default: Boolean;\n boolean: Boolean;\n integer: Integer;\n text: Text;\n varchar: VarChar;\n }\n }\n}\n\n/** Column class behind `bool()` on SQL - `boolean`, `integer`, or `text` / `varchar` with `either`. */\nexport class BooleanColumn extends bool.Type {\n type: bool.DataType = \"boolean\";\n\n get datatype() {\n const { type, either } = this;\n\n if (type === \"varchar\" && either) {\n const [TRUE, FALSE] = either.map(String);\n return `varchar(${Math.max(TRUE.length, FALSE.length)})`;\n }\n\n return type;\n }\n\n set(value: unknown) {\n const out = super.set(value);\n\n if (out == null || this.either || this.type !== \"boolean\")\n return out;\n\n return value as boolean;\n }\n}\n\nbool.Type = BooleanColumn;\n"],"mappings":";;;;AAiCA,IAAa,gBAAb,cAAmC,KAAK,KAAK;;;cACrB;;CAEtB,IAAI,WAAW;EACb,MAAM,EAAE,MAAM,WAAW;AAEzB,MAAI,SAAS,aAAa,QAAQ;GAChC,MAAM,CAAC,MAAM,SAAS,OAAO,IAAI,OAAO;AACxC,UAAO,WAAW,KAAK,IAAI,KAAK,QAAQ,MAAM,OAAO,CAAC;;AAGxD,SAAO;;CAGT,IAAI,OAAgB;EAClB,MAAM,MAAM,MAAM,IAAI,MAAM;AAE5B,MAAI,OAAO,QAAQ,KAAK,UAAU,KAAK,SAAS,UAC9C,QAAO;AAET,SAAO;;;AAIX,KAAK,OAAO"}
@@ -0,0 +1,59 @@
1
+ import { num } from "@expressive/orm";
2
+
3
+ //#region src/columns/Num.d.ts
4
+ declare module '@expressive/orm' {
5
+ namespace num {
6
+ interface Integer extends NumericColumn {
7
+ type: "integer";
8
+ }
9
+ interface SmallInt extends NumericColumn {
10
+ type: "smallint";
11
+ }
12
+ interface BigInt extends NumericColumn {
13
+ type: "bigint";
14
+ }
15
+ interface Real extends NumericColumn {
16
+ type: "real";
17
+ }
18
+ interface Float extends NumericColumn {
19
+ type: "float";
20
+ }
21
+ interface Double extends NumericColumn {
22
+ type: "double";
23
+ }
24
+ interface Numeric extends NumericColumn {
25
+ type: "numeric";
26
+ precision: number;
27
+ scale: number;
28
+ }
29
+ interface Decimal extends NumericColumn {
30
+ type: "decimal";
31
+ precision: number;
32
+ scale: number;
33
+ }
34
+ interface Types {
35
+ default: Integer;
36
+ integer: Integer;
37
+ smallint: SmallInt;
38
+ bigint: BigInt;
39
+ real: Real;
40
+ float: Float;
41
+ double: Double;
42
+ numeric: Numeric;
43
+ decimal: Decimal;
44
+ }
45
+ }
46
+ }
47
+ /**
48
+ * Column class behind `num()` on SQL.
49
+ *
50
+ * Checks integer ranges and `numeric` precision and scale on write.
51
+ */
52
+ declare class NumericColumn extends num.Type {
53
+ type: num.DataType;
54
+ get datatype(): string;
55
+ set(value: unknown): number | null | undefined;
56
+ }
57
+ //#endregion
58
+ export { NumericColumn };
59
+ //# sourceMappingURL=Num.d.ts.map
@@ -0,0 +1,42 @@
1
+ import { num } from "@expressive/orm";
2
+
3
+ //#region src/columns/Num.ts
4
+ const RANGE = {
5
+ smallint: [-32768, 32767],
6
+ integer: [-2147483648, 2147483647],
7
+ bigint: [-Infinity, Infinity]
8
+ };
9
+ /**
10
+ * Column class behind `num()` on SQL.
11
+ *
12
+ * Checks integer ranges and `numeric` precision and scale on write.
13
+ */
14
+ var NumericColumn = class extends num.Type {
15
+ constructor(..._args) {
16
+ super(..._args);
17
+ this.type = "integer";
18
+ }
19
+ get datatype() {
20
+ return this.type === "double" ? "double precision" : super.datatype;
21
+ }
22
+ set(value) {
23
+ const out = super.set(value);
24
+ if (typeof value != "number") return out;
25
+ const { type, precision, scale } = this;
26
+ const range = RANGE[type];
27
+ if (range) {
28
+ const [min, max] = range;
29
+ if (value !== Math.floor(value) || value < min || value > max) throw new Error(`Value ${value} out of range for ${type}.`);
30
+ } else if (precision !== void 0) {
31
+ const [whole, fraction = ""] = Math.abs(value).toString().split(".");
32
+ if (whole.length + fraction.length > precision) throw new Error(`Value ${value} exceeds precision of ${precision}.`);
33
+ if (scale !== void 0 && fraction.length > scale) throw new Error(`Value ${value} exceeds scale of ${scale}.`);
34
+ }
35
+ return out;
36
+ }
37
+ };
38
+ num.Type = NumericColumn;
39
+
40
+ //#endregion
41
+ export { NumericColumn };
42
+ //# sourceMappingURL=Num.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Num.js","names":[],"sources":["../../src/columns/Num.ts"],"sourcesContent":["import { num } from '@expressive/orm';\n\ndeclare module '@expressive/orm' {\n namespace num {\n interface Integer extends NumericColumn {\n type: \"integer\";\n }\n\n interface SmallInt extends NumericColumn {\n type: \"smallint\";\n }\n\n interface BigInt extends NumericColumn {\n type: \"bigint\";\n }\n\n interface Real extends NumericColumn {\n type: \"real\";\n }\n\n interface Float extends NumericColumn {\n type: \"float\";\n }\n\n interface Double extends NumericColumn {\n type: \"double\";\n }\n\n interface Numeric extends NumericColumn {\n type: \"numeric\";\n precision: number;\n scale: number;\n }\n\n interface Decimal extends NumericColumn {\n type: \"decimal\";\n precision: number;\n scale: number;\n }\n\n interface Types {\n default: Integer;\n integer: Integer;\n smallint: SmallInt;\n bigint: BigInt;\n real: Real;\n float: Float;\n double: Double;\n numeric: Numeric;\n decimal: Decimal;\n }\n }\n}\n\nconst RANGE: Record<string, [number, number]> = {\n smallint: [-32768, 32767],\n integer: [-2147483648, 2147483647],\n bigint: [-Infinity, Infinity]\n};\n\n/**\n * Column class behind `num()` on SQL.\n *\n * Checks integer ranges and `numeric` precision and scale on write.\n */\nexport class NumericColumn extends num.Type {\n type: num.DataType = \"integer\";\n\n get datatype() {\n return this.type === \"double\" ? \"double precision\" : super.datatype;\n }\n\n set(value: unknown) {\n const out = super.set(value);\n\n if (typeof value != \"number\")\n return out;\n\n const { type, precision, scale } = this;\n const range = RANGE[type];\n\n if (range) {\n const [min, max] = range;\n\n if (value !== Math.floor(value) || value < min || value > max)\n throw new Error(`Value ${value} out of range for ${type}.`);\n }\n else if (precision !== undefined) {\n const [whole, fraction = \"\"] = Math.abs(value).toString().split('.');\n\n if (whole.length + fraction.length > precision)\n throw new Error(`Value ${value} exceeds precision of ${precision}.`);\n\n if (scale !== undefined && fraction.length > scale)\n throw new Error(`Value ${value} exceeds scale of ${scale}.`);\n }\n\n return out;\n }\n}\n\nnum.Type = NumericColumn;\n"],"mappings":";;;AAsDA,MAAM,QAA0C;CAC9C,UAAU,CAAC,QAAQ,MAAM;CACzB,SAAS,CAAC,aAAa,WAAW;CAClC,QAAQ,CAAC,WAAW,SAAS;CAC9B;;;;;;AAOD,IAAa,gBAAb,cAAmC,IAAI,KAAK;;;cACrB;;CAErB,IAAI,WAAW;AACb,SAAO,KAAK,SAAS,WAAW,qBAAqB,MAAM;;CAG7D,IAAI,OAAgB;EAClB,MAAM,MAAM,MAAM,IAAI,MAAM;AAE5B,MAAI,OAAO,SAAS,SAClB,QAAO;EAET,MAAM,EAAE,MAAM,WAAW,UAAU;EACnC,MAAM,QAAQ,MAAM;AAEpB,MAAI,OAAO;GACT,MAAM,CAAC,KAAK,OAAO;AAEnB,OAAI,UAAU,KAAK,MAAM,MAAM,IAAI,QAAQ,OAAO,QAAQ,IACxD,OAAM,IAAI,MAAM,SAAS,MAAM,oBAAoB,KAAK,GAAG;aAEtD,cAAc,QAAW;GAChC,MAAM,CAAC,OAAO,WAAW,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,IAAI;AAEpE,OAAI,MAAM,SAAS,SAAS,SAAS,UACnC,OAAM,IAAI,MAAM,SAAS,MAAM,wBAAwB,UAAU,GAAG;AAEtE,OAAI,UAAU,UAAa,SAAS,SAAS,MAC3C,OAAM,IAAI,MAAM,SAAS,MAAM,oBAAoB,MAAM,GAAG;;AAGhE,SAAO;;;AAIX,IAAI,OAAO"}
@@ -0,0 +1,25 @@
1
+ import { Type, one } from "@expressive/orm";
2
+
3
+ //#region src/columns/One.d.ts
4
+ declare module '@expressive/orm' {
5
+ namespace one {
6
+ interface Integer<T extends Type = Type> extends ForeignColumn<T> {
7
+ type: "integer";
8
+ }
9
+ interface BigInt<T extends Type = Type> extends ForeignColumn<T> {
10
+ type: "bigint";
11
+ }
12
+ interface Types {
13
+ default: Integer;
14
+ integer: Integer;
15
+ bigint: BigInt;
16
+ }
17
+ }
18
+ }
19
+ /** Column class behind `one()` on SQL - an `integer` or `bigint` foreign key. */
20
+ declare class ForeignColumn<T extends Type = Type> extends one.Type<T> {
21
+ type: one.DataType;
22
+ }
23
+ //#endregion
24
+ export { ForeignColumn };
25
+ //# sourceMappingURL=One.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { one } from "@expressive/orm";
2
+
3
+ //#region src/columns/One.ts
4
+ /** Column class behind `one()` on SQL - an `integer` or `bigint` foreign key. */
5
+ var ForeignColumn = class extends one.Type {
6
+ constructor(..._args) {
7
+ super(..._args);
8
+ this.type = "integer";
9
+ }
10
+ };
11
+ one.Type = ForeignColumn;
12
+
13
+ //#endregion
14
+ export { ForeignColumn };
15
+ //# sourceMappingURL=One.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"One.js","names":[],"sources":["../../src/columns/One.ts"],"sourcesContent":["import { one, type Type } from '@expressive/orm';\n\ndeclare module '@expressive/orm' {\n namespace one {\n interface Integer<T extends Type = Type> extends ForeignColumn<T> {\n type: \"integer\";\n }\n\n interface BigInt<T extends Type = Type> extends ForeignColumn<T> {\n type: \"bigint\";\n }\n\n interface Types {\n default: Integer;\n integer: Integer;\n bigint: BigInt;\n }\n }\n}\n\n/** Column class behind `one()` on SQL - an `integer` or `bigint` foreign key. */\nexport class ForeignColumn<T extends Type = Type> extends one.Type<T> {\n type: one.DataType = \"integer\";\n}\n\none.Type = ForeignColumn;\n"],"mappings":";;;;AAqBA,IAAa,gBAAb,cAA0D,IAAI,KAAQ;;;cAC/C;;;AAGvB,IAAI,OAAO"}
@@ -0,0 +1,36 @@
1
+ import { str } from "@expressive/orm";
2
+
3
+ //#region src/columns/Str.d.ts
4
+ declare module '@expressive/orm' {
5
+ namespace str {
6
+ interface Text extends StringColumn {
7
+ type: "text";
8
+ }
9
+ interface VarChar extends StringColumn {
10
+ type: "varchar";
11
+ length: number;
12
+ }
13
+ interface Char extends StringColumn {
14
+ type: "char";
15
+ length: number;
16
+ }
17
+ interface UUID extends StringColumn {
18
+ type: "uuid";
19
+ }
20
+ interface Types {
21
+ default: Text;
22
+ text: Text;
23
+ varchar: VarChar;
24
+ char: Char;
25
+ uuid: UUID;
26
+ }
27
+ }
28
+ }
29
+ /** Column class behind `str()` on SQL - `text`, `varchar`, `char` or `uuid`. */
30
+ declare class StringColumn extends str.Type {
31
+ type: str.DataType;
32
+ get datatype(): string;
33
+ }
34
+ //#endregion
35
+ export { StringColumn };
36
+ //# sourceMappingURL=Str.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { str } from "@expressive/orm";
2
+
3
+ //#region src/columns/Str.ts
4
+ /** Column class behind `str()` on SQL - `text`, `varchar`, `char` or `uuid`. */
5
+ var StringColumn = class extends str.Type {
6
+ constructor(..._args) {
7
+ super(..._args);
8
+ this.type = "text";
9
+ }
10
+ get datatype() {
11
+ let { type, length, collate } = this;
12
+ if (type.endsWith("char") && length) type += `(${length})`;
13
+ if (collate) type += ` COLLATE "${collate}"`;
14
+ return type;
15
+ }
16
+ };
17
+ str.Type = StringColumn;
18
+
19
+ //#endregion
20
+ export { StringColumn };
21
+ //# sourceMappingURL=Str.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Str.js","names":[],"sources":["../../src/columns/Str.ts"],"sourcesContent":["import { str } from '@expressive/orm';\n\ndeclare module '@expressive/orm' {\n namespace str {\n interface Text extends StringColumn {\n type: \"text\";\n }\n\n interface VarChar extends StringColumn {\n type: \"varchar\";\n length: number;\n }\n\n interface Char extends StringColumn {\n type: \"char\";\n length: number;\n }\n\n interface UUID extends StringColumn {\n type: \"uuid\";\n }\n\n interface Types {\n default: Text;\n text: Text;\n varchar: VarChar;\n char: Char;\n uuid: UUID;\n }\n }\n}\n\n/** Column class behind `str()` on SQL - `text`, `varchar`, `char` or `uuid`. */\nexport class StringColumn extends str.Type {\n type: str.DataType = \"text\";\n\n get datatype() {\n let { type, length, collate } = this;\n\n if (type.endsWith(\"char\") && length)\n type += `(${length})`;\n\n if (collate)\n type += ` COLLATE \"${collate}\"`;\n\n return type;\n }\n}\n\nstr.Type = StringColumn;\n"],"mappings":";;;;AAiCA,IAAa,eAAb,cAAkC,IAAI,KAAK;;;cACpB;;CAErB,IAAI,WAAW;EACb,IAAI,EAAE,MAAM,QAAQ,YAAY;AAEhC,MAAI,KAAK,SAAS,OAAO,IAAI,OAC3B,SAAQ,IAAI,OAAO;AAErB,MAAI,QACF,SAAQ,aAAa,QAAQ;AAE/B,SAAO;;;AAIX,IAAI,OAAO"}
@@ -0,0 +1,52 @@
1
+ import { date } from "@expressive/orm";
2
+
3
+ //#region src/columns/Time.d.ts
4
+ declare module '@expressive/orm' {
5
+ namespace date {
6
+ interface Timestamp extends TimeColumn {
7
+ type: "timestamp";
8
+ }
9
+ interface Day extends TimeColumn {
10
+ type: "date";
11
+ }
12
+ interface Time extends TimeColumn {
13
+ type: "time";
14
+ }
15
+ interface Integer extends TimeColumn {
16
+ type: "integer";
17
+ }
18
+ interface Text extends TimeColumn {
19
+ type: "text";
20
+ }
21
+ interface Ms extends TimeColumn {
22
+ type: "ms";
23
+ }
24
+ interface Seconds extends TimeColumn {
25
+ type: "seconds";
26
+ }
27
+ interface Types {
28
+ default: Timestamp;
29
+ timestamp: Timestamp;
30
+ date: Day;
31
+ time: Time;
32
+ integer: Integer;
33
+ text: Text;
34
+ ms: Ms;
35
+ seconds: Seconds;
36
+ }
37
+ }
38
+ }
39
+ /**
40
+ * Column class behind `date()` on SQL.
41
+ *
42
+ * Stores a Date as `timestamp`, `date`, `time`, `ms`, `seconds`, `integer` or `text`.
43
+ */
44
+ declare class TimeColumn extends date.Type {
45
+ type: date.DataType;
46
+ get datatype(): string;
47
+ get(value: unknown): Date | undefined;
48
+ set(value: unknown): string | number | undefined;
49
+ }
50
+ //#endregion
51
+ export { TimeColumn };
52
+ //# sourceMappingURL=Time.d.ts.map
@@ -0,0 +1,45 @@
1
+ import { date } from "@expressive/orm";
2
+
3
+ //#region src/columns/Time.ts
4
+ /**
5
+ * Column class behind `date()` on SQL.
6
+ *
7
+ * Stores a Date as `timestamp`, `date`, `time`, `ms`, `seconds`, `integer` or `text`.
8
+ */
9
+ var TimeColumn = class extends date.Type {
10
+ constructor(..._args) {
11
+ super(..._args);
12
+ this.type = "timestamp";
13
+ }
14
+ get datatype() {
15
+ const { type } = this;
16
+ return type === "ms" ? "bigint" : type === "seconds" ? "integer" : super.datatype;
17
+ }
18
+ get(value) {
19
+ if (value == null) return void 0;
20
+ if (this.type === "ms") return new Date(Number(value));
21
+ if (typeof value === "number") return /* @__PURE__ */ new Date(value * 1e3);
22
+ if (typeof value === "string" && this.type === "date") {
23
+ const [year, month, day] = value.split("-").map(Number);
24
+ return new Date(year, month - 1, day);
25
+ }
26
+ if (typeof value === "string" && this.type === "time") return /* @__PURE__ */ new Date(`1970-01-01T${value}Z`);
27
+ if (typeof value === "string" && /^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d(\.\d+)?$/.test(value)) return /* @__PURE__ */ new Date(value.replace(" ", "T") + "Z");
28
+ return new Date(value);
29
+ }
30
+ set(value) {
31
+ const iso = super.set(value);
32
+ if (iso === void 0) return iso;
33
+ const date = new Date(iso);
34
+ if (this.type === "ms") return date.getTime();
35
+ if (this.type === "integer" || this.type === "seconds") return Math.floor(date.getTime() / 1e3);
36
+ if (this.type === "date") return date.toISOString().slice(0, 10);
37
+ if (this.type === "time") return date.toISOString().slice(11, 19);
38
+ return iso;
39
+ }
40
+ };
41
+ date.Type = TimeColumn;
42
+
43
+ //#endregion
44
+ export { TimeColumn };
45
+ //# sourceMappingURL=Time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Time.js","names":[],"sources":["../../src/columns/Time.ts"],"sourcesContent":["import { date } from '@expressive/orm';\n\ndeclare module '@expressive/orm' {\n namespace date {\n interface Timestamp extends TimeColumn {\n type: \"timestamp\";\n }\n\n interface Day extends TimeColumn {\n type: \"date\";\n }\n\n interface Time extends TimeColumn {\n type: \"time\";\n }\n\n interface Integer extends TimeColumn {\n type: \"integer\";\n }\n\n interface Text extends TimeColumn {\n type: \"text\";\n }\n\n interface Ms extends TimeColumn {\n type: \"ms\";\n }\n\n interface Seconds extends TimeColumn {\n type: \"seconds\";\n }\n\n interface Types {\n default: Timestamp;\n timestamp: Timestamp;\n date: Day;\n time: Time;\n integer: Integer;\n text: Text;\n ms: Ms;\n seconds: Seconds;\n }\n }\n}\n\n/**\n * Column class behind `date()` on SQL.\n *\n * Stores a Date as `timestamp`, `date`, `time`, `ms`, `seconds`, `integer` or `text`.\n */\nexport class TimeColumn extends date.Type {\n type: date.DataType = \"timestamp\";\n\n get datatype() {\n const { type } = this;\n\n return type === \"ms\" ? \"bigint\" : type === \"seconds\" ? \"integer\" : super.datatype;\n }\n\n get(value: unknown) {\n if (value == null)\n return undefined;\n\n if (this.type === \"ms\")\n return new Date(Number(value));\n\n if (typeof value === 'number')\n return new Date(value * 1000);\n\n if (typeof value === 'string' && this.type === \"date\") {\n const [year, month, day] = value.split('-').map(Number);\n return new Date(year, month - 1, day);\n }\n\n if (typeof value === 'string' && this.type === \"time\")\n return new Date(`1970-01-01T${value}Z`);\n\n if (typeof value === 'string' && /^\\d{4}-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d(\\.\\d+)?$/.test(value))\n return new Date(value.replace(\" \", \"T\") + \"Z\");\n\n return new Date(value as string | Date);\n }\n\n set(value: unknown) {\n const iso = super.set(value);\n\n if (iso === undefined)\n return iso;\n\n const date = new Date(iso);\n\n if (this.type === \"ms\")\n return date.getTime();\n\n if (this.type === \"integer\" || this.type === \"seconds\")\n return Math.floor(date.getTime() / 1000);\n\n if (this.type === \"date\")\n return date.toISOString().slice(0, 10);\n\n if (this.type === \"time\")\n return date.toISOString().slice(11, 19);\n\n return iso;\n }\n}\n\ndate.Type = TimeColumn;\n"],"mappings":";;;;;;;;AAkDA,IAAa,aAAb,cAAgC,KAAK,KAAK;;;cAClB;;CAEtB,IAAI,WAAW;EACb,MAAM,EAAE,SAAS;AAEjB,SAAO,SAAS,OAAO,WAAW,SAAS,YAAY,YAAY,MAAM;;CAG3E,IAAI,OAAgB;AAClB,MAAI,SAAS,KACX,QAAO;AAET,MAAI,KAAK,SAAS,KAChB,QAAO,IAAI,KAAK,OAAO,MAAM,CAAC;AAEhC,MAAI,OAAO,UAAU,SACnB,wBAAO,IAAI,KAAK,QAAQ,IAAK;AAE/B,MAAI,OAAO,UAAU,YAAY,KAAK,SAAS,QAAQ;GACrD,MAAM,CAAC,MAAM,OAAO,OAAO,MAAM,MAAM,IAAI,CAAC,IAAI,OAAO;AACvD,UAAO,IAAI,KAAK,MAAM,QAAQ,GAAG,IAAI;;AAGvC,MAAI,OAAO,UAAU,YAAY,KAAK,SAAS,OAC7C,wBAAO,IAAI,KAAK,cAAc,MAAM,GAAG;AAEzC,MAAI,OAAO,UAAU,YAAY,2CAA2C,KAAK,MAAM,CACrF,wBAAO,IAAI,KAAK,MAAM,QAAQ,KAAK,IAAI,GAAG,IAAI;AAEhD,SAAO,IAAI,KAAK,MAAuB;;CAGzC,IAAI,OAAgB;EAClB,MAAM,MAAM,MAAM,IAAI,MAAM;AAE5B,MAAI,QAAQ,OACV,QAAO;EAET,MAAM,OAAO,IAAI,KAAK,IAAI;AAE1B,MAAI,KAAK,SAAS,KAChB,QAAO,KAAK,SAAS;AAEvB,MAAI,KAAK,SAAS,aAAa,KAAK,SAAS,UAC3C,QAAO,KAAK,MAAM,KAAK,SAAS,GAAG,IAAK;AAE1C,MAAI,KAAK,SAAS,OAChB,QAAO,KAAK,aAAa,CAAC,MAAM,GAAG,GAAG;AAExC,MAAI,KAAK,SAAS,OAChB,QAAO,KAAK,aAAa,CAAC,MAAM,IAAI,GAAG;AAEzC,SAAO;;;AAIX,KAAK,OAAO"}
@@ -0,0 +1,61 @@
1
+ import { Connection as Connection$1, Type } from "@expressive/orm";
2
+ import { Builder } from "@expressive/orm/driver";
3
+
4
+ //#region src/connection/Connection.d.ts
5
+ declare namespace Connection {
6
+ type Types = Connection$1.Types;
7
+ type Ready<T extends Connection = Connection> = Connection$1.Ready<T>;
8
+ type Change = Connection$1.Change;
9
+ type Conflict = Connection$1.Conflict;
10
+ type Key = Connection$1.Key;
11
+ /** An open transaction's journal. */
12
+ type Transaction = Connection$1.Journal;
13
+ /** One change `sync` would make. */
14
+ interface Step {
15
+ table: string;
16
+ /** Column the step adds or indexes. Absent for a table step. */
17
+ column?: string;
18
+ /** What it does, like `create table user`. */
19
+ action: string;
20
+ /** The mismatch it resolves - what `sync(false)` reports. */
21
+ reason: string;
22
+ /** Statements applying it. */
23
+ sql: string[];
24
+ }
25
+ /** What `sync` would do, and what stops it. */
26
+ interface Plan {
27
+ steps: Step[];
28
+ /** Mismatches `sync` cannot fix. Any makes it throw. */
29
+ problems: string[];
30
+ }
31
+ }
32
+ /**
33
+ * Base class of a SQL driver - implements orm's floor as queries through `prepare`.
34
+ *
35
+ * The floor is `select`, `insert`, `update` and `remove`.
36
+ *
37
+ * A dialect supplies `schema`, `prepare`, `sync` and `plan`, and `transact` to enable `transaction`.
38
+ * Each statement throws when no bound or loaded class owns its table.
39
+ */
40
+ declare abstract class Connection extends Connection$1 {
41
+ /** DDL creating every bound class's table and indexes. */
42
+ abstract get schema(): string;
43
+ /**
44
+ * Bring the database in line with the bound classes, then mark the connection ready.
45
+ *
46
+ * Creates missing tables, columns and indexes. `fix` false changes nothing and throws for anything missing.
47
+ * `force` also converts columns whose type or nullability drifted. Throws for any problem `plan` reports.
48
+ */
49
+ abstract sync(fix?: boolean, force?: boolean): Promise<this>;
50
+ /** List what `sync` would change, and what it could not, without applying anything. */
51
+ abstract plan(force?: boolean): Promise<Connection.Plan>;
52
+ /** Compile a `Query` builder to a statement in this dialect. */
53
+ abstract prepare(builder: Builder): Builder.Statement;
54
+ select(table: string, constraints: Type.Constraint[], limit?: number, offset?: number): Promise<Record<string, any>[]>;
55
+ insert(table: string, data: Record<string, any>, returns?: boolean, conflict?: Connection.Conflict): Promise<any>;
56
+ update(table: string, id: Connection.Key, data: Record<string, any>): Promise<void>;
57
+ remove(table: string, id: Connection.Key): Promise<void>;
58
+ }
59
+ //#endregion
60
+ export { Connection };
61
+ //# sourceMappingURL=Connection.d.ts.map