@mailwoman/sqlite 9.4.0 → 10.1.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/lib/batched.ts +7 -13
- package/lib/client.ts +15 -42
- package/lib/database-schema.ts +2 -20
- package/lib/dialect.ts +1 -1
- package/lib/driver.ts +3 -3
- package/lib/index.ts +7 -6
- package/lib/introspection.ts +15 -8
- package/lib/lookup.ts +77 -0
- package/lib/schema-columns.ts +18 -19
- package/lib/{sealed-build.ts → sealed/build.ts} +15 -26
- package/lib/sealed/db.ts +191 -0
- package/lib/sealed.ts +14 -9
- package/out/batched.d.ts +7 -13
- package/out/batched.d.ts.map +1 -1
- package/out/batched.js +3 -5
- package/out/batched.js.map +1 -1
- package/out/client.d.ts +14 -41
- package/out/client.d.ts.map +1 -1
- package/out/client.js +9 -17
- package/out/client.js.map +1 -1
- package/out/database-schema.d.ts +2 -20
- package/out/database-schema.d.ts.map +1 -1
- package/out/database-schema.js +1 -14
- package/out/database-schema.js.map +1 -1
- package/out/{dialect-config.d.ts → dialect/config.d.ts} +1 -1
- package/out/dialect/config.d.ts.map +1 -0
- package/out/{dialect-config.js → dialect/config.js} +1 -1
- package/out/dialect/config.js.map +1 -0
- package/out/dialect.d.ts +1 -1
- package/out/dialect.d.ts.map +1 -1
- package/out/driver.d.ts +1 -1
- package/out/driver.d.ts.map +1 -1
- package/out/driver.js +2 -2
- package/out/driver.js.map +1 -1
- package/out/index.d.ts +7 -6
- package/out/index.d.ts.map +1 -1
- package/out/index.js +7 -6
- package/out/index.js.map +1 -1
- package/out/introspection.d.ts +15 -8
- package/out/introspection.d.ts.map +1 -1
- package/out/introspection.js +15 -8
- package/out/introspection.js.map +1 -1
- package/out/lookup.d.ts +49 -0
- package/out/lookup.d.ts.map +1 -0
- package/out/lookup.js +55 -0
- package/out/lookup.js.map +1 -0
- package/out/schema-columns.d.ts +18 -19
- package/out/schema-columns.d.ts.map +1 -1
- package/out/schema-columns.js +14 -17
- package/out/schema-columns.js.map +1 -1
- package/out/sealed/build.d.ts +40 -0
- package/out/sealed/build.d.ts.map +1 -0
- package/out/{sealed-build.js → sealed/build.js} +3 -16
- package/out/sealed/build.js.map +1 -0
- package/out/sealed/db.d.ts +90 -0
- package/out/sealed/db.d.ts.map +1 -0
- package/out/{sealed-db.js → sealed/db.js} +63 -43
- package/out/sealed/db.js.map +1 -0
- package/out/sealed.d.ts +12 -8
- package/out/sealed.d.ts.map +1 -1
- package/out/sealed.js +11 -8
- package/out/sealed.js.map +1 -1
- package/out/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +15 -104
- package/lib/sealed-db.ts +0 -170
- package/out/dialect-config.d.ts.map +0 -1
- package/out/dialect-config.js.map +0 -1
- package/out/sealed-build.d.ts +0 -51
- package/out/sealed-build.d.ts.map +0 -1
- package/out/sealed-build.js.map +0 -1
- package/out/sealed-db.d.ts +0 -74
- package/out/sealed-db.d.ts.map +0 -1
- package/out/sealed-db.js.map +0 -1
- /package/lib/{dialect-config.ts → dialect/config.ts} +0 -0
package/lib/sealed/db.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The sealed-artifact invariant: every SQLite DB a build produces is a read-only asset. `sealDatabase`
|
|
7
|
+
* is the last step of every builder — checkpoint, freeze the journal, chmod 0444. `openBuiltClient`
|
|
8
|
+
* (`@mailwoman/sqlite/sealed`) is how anything opens a data artifact. a write-mode open of a sealed
|
|
9
|
+
* file throws a descriptive error pointing at the rebuild command instead of a cryptic SQLITE_READONLY.
|
|
10
|
+
* A caller can restore write permission only with manual `chmod u+w`; the program never changes permissions.
|
|
11
|
+
* Rebuild the artifact to make changes.
|
|
12
|
+
*
|
|
13
|
+
* `swapDatabaseIntoPlace` is the atomic publish step agents.md
|
|
14
|
+
* specifies in prose ("build it successfully. Move the previous version to a temp directory.
|
|
15
|
+
* Move the new version into place."). It lives here because this module already owns the
|
|
16
|
+
* built-artifact lifecycle. A rule stated in project prose and implemented by several builders belongs in a
|
|
17
|
+
* shared function.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { DatabaseSync } from "node:sqlite"
|
|
21
|
+
|
|
22
|
+
import { pathExists, statPath } from "@mailwoman/core/fs/readers"
|
|
23
|
+
import { changeMode, movePath, removePath, removePathIfPresent } from "@mailwoman/core/fs/writers"
|
|
24
|
+
import { basename, type PathBuilderLike } from "path-ts"
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The one capability {@link assertDatabaseIntegrity} needs.
|
|
28
|
+
*
|
|
29
|
+
* A narrow callback type lets a `DatabaseClient` satisfy the parameter with no import and no cast.
|
|
30
|
+
*/
|
|
31
|
+
type IntegrityProbe = Pick<DatabaseSync, "prepare">
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `node:sqlite` via {@link process.getBuiltinModule} — invisible to bundlers.
|
|
35
|
+
*
|
|
36
|
+
* A static import here would ride the `@mailwoman/core/utils` barrel into every consumer.
|
|
37
|
+
* The docs' plugin loader transpiles `docusaurus.config` imports and cannot resolve
|
|
38
|
+
* `node:sqlite` (CI: "Cannot find module 'sqlite'").
|
|
39
|
+
*
|
|
40
|
+
* The builtin accessor keeps `node:sqlite` out of the static import graph with zero resolve surface.
|
|
41
|
+
*/
|
|
42
|
+
function sqlite(): typeof import("node:sqlite") {
|
|
43
|
+
return process.getBuiltinModule("node:sqlite")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A write-mode open was attempted on a sealed (0444) data artifact.
|
|
48
|
+
*/
|
|
49
|
+
export class SealedArtifactError extends Error {
|
|
50
|
+
constructor(path: PathBuilderLike) {
|
|
51
|
+
super(
|
|
52
|
+
`${basename(path)} is a sealed read-only artifact — rebuild it via \`mailwoman gazetteer build …\`, ` +
|
|
53
|
+
`don't mutate it. (Deliberate unseal: chmod u+w — but prefer a rebuild.)`
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
this.name = "SealedArtifactError"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* True when the artifact exists and has no write bits (the sealed state {@link sealDatabase} leaves).
|
|
62
|
+
*/
|
|
63
|
+
export async function isSealed(path: PathBuilderLike): Promise<boolean> {
|
|
64
|
+
return (await pathExists(path)) && ((await statPath(path)).mode & 0o222) === 0
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Finalize a built DB: WAL-checkpoint → `journal_mode = delete` → remove
|
|
69
|
+
* `-wal`/`-shm` sidecars → `chmod 0o444`.
|
|
70
|
+
*
|
|
71
|
+
* Idempotent.
|
|
72
|
+
* Throws if the checkpoint cannot complete (another writer holds the DB).
|
|
73
|
+
*/
|
|
74
|
+
export async function sealDatabase(path: PathBuilderLike): Promise<void> {
|
|
75
|
+
// A previously sealed artifact needs the write bit back for the journal-mode switch.
|
|
76
|
+
if (await isSealed(path)) {
|
|
77
|
+
await changeMode(path, 0o644)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let mode: { journal_mode: string }
|
|
81
|
+
|
|
82
|
+
{
|
|
83
|
+
using db = new (sqlite().DatabaseSync)(path.toString())
|
|
84
|
+
const checkpoint = db.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get() as { busy: number }
|
|
85
|
+
|
|
86
|
+
if (checkpoint.busy !== 0) {
|
|
87
|
+
throw new Error(`sealDatabase: WAL checkpoint busy on ${path} — close all writers first`)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
mode = db.prepare("PRAGMA journal_mode = DELETE").get() as { journal_mode: string }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (mode.journal_mode !== "delete") {
|
|
94
|
+
throw new Error(`sealDatabase: journal_mode switch failed on ${path} (still ${mode.journal_mode})`)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
for (const sidecar of [`${path}-wal`, `${path}-shm`]) {
|
|
98
|
+
if (await pathExists(sidecar)) {
|
|
99
|
+
await removePath(sidecar)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
await changeMode(path, 0o444)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Verify a freshly-built database is not corrupt, immediately before it is sealed and published.
|
|
108
|
+
*
|
|
109
|
+
* Belongs beside {@link sealDatabase} for the same reason `swapDatabaseIntoPlace` does.
|
|
110
|
+
* The check is part of the built-artifact lifecycle.
|
|
111
|
+
*
|
|
112
|
+
* Every builder previously ran its own copy.
|
|
113
|
+
* `integrity_check` answers with the single row `{ integrity_check: "ok" }` on a healthy file
|
|
114
|
+
* and one row per problem otherwise, so only the first matters.
|
|
115
|
+
*
|
|
116
|
+
* A builder that reads the column and compares it to `"ok"` has done the whole check.
|
|
117
|
+
*
|
|
118
|
+
* @throws When the database reports anything other than `ok`, naming the artifact and what SQLite said.
|
|
119
|
+
*/
|
|
120
|
+
export function assertDatabaseIntegrity(db: IntegrityProbe, artifact: PathBuilderLike): void {
|
|
121
|
+
const row = db.prepare("PRAGMA integrity_check").get() as { integrity_check: string } | undefined
|
|
122
|
+
const verdict = row?.integrity_check
|
|
123
|
+
|
|
124
|
+
if (verdict !== "ok") {
|
|
125
|
+
throw new Error(`integrity_check failed on ${basename(artifact)}: ${verdict ?? "no result"}`)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Refuse a write-mode open of a sealed artifact, naming the rebuild command
|
|
131
|
+
* instead of letting SQLite answer `SQLITE_READONLY`.
|
|
132
|
+
*
|
|
133
|
+
* The open itself lives in `@mailwoman/sqlite/sealed`.
|
|
134
|
+
* `openBuiltClient`, which every caller uses.
|
|
135
|
+
*
|
|
136
|
+
* This half stays here because it is a filesystem predicate.
|
|
137
|
+
* This module reaches `node:sqlite` through {@link process.getBuiltinModule} to
|
|
138
|
+
* keep the `@mailwoman/core/utils` barrel free of it.
|
|
139
|
+
*
|
|
140
|
+
* @throws {SealedArtifactError} When `path` is sealed.
|
|
141
|
+
*/
|
|
142
|
+
export async function assertUnsealedForWrite(path: PathBuilderLike): Promise<void> {
|
|
143
|
+
if (await isSealed(path)) throw new SealedArtifactError(path)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Atomically move a freshly-built database into its published location.
|
|
148
|
+
*
|
|
149
|
+
* The build writes to a temp path, so a mid-build crash never leaves a half-written DB at `finalPath`.
|
|
150
|
+
* This moves any prior version aside, slots the new one in, then drops the old.
|
|
151
|
+
*
|
|
152
|
+
* The previous file stays intact until the replacement is committed.
|
|
153
|
+
* The function clears the `-wal` and `-shm` siblings of both paths, so a stale
|
|
154
|
+
* journal cannot pair with a new main file.
|
|
155
|
+
*
|
|
156
|
+
* The code seals (`sealDatabase`) the temp file before the swap.
|
|
157
|
+
* The published artifact is sealed.
|
|
158
|
+
* Mode 0444 still permits a rename.
|
|
159
|
+
*/
|
|
160
|
+
export async function swapDatabaseIntoPlace(tmpPath: PathBuilderLike, finalPath: PathBuilderLike): Promise<void> {
|
|
161
|
+
const tmpPathString = tmpPath.toString()
|
|
162
|
+
const finalPathString = finalPath.toString()
|
|
163
|
+
const aside = `${finalPathString}.old-${process.pid}`
|
|
164
|
+
|
|
165
|
+
if (await pathExists(finalPathString)) {
|
|
166
|
+
await movePath(finalPathString, aside)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
for (const sfx of ["-wal", "-shm"]) {
|
|
170
|
+
await removePathIfPresent(finalPathString + sfx)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
await movePath(tmpPathString, finalPathString)
|
|
175
|
+
} catch (error) {
|
|
176
|
+
// The prior version is already aside at this point.
|
|
177
|
+
// A failed forward rename must not leave the slot empty while a restorable
|
|
178
|
+
// artifact sits one rename away.
|
|
179
|
+
if ((await pathExists(aside)) && !(await pathExists(finalPathString))) {
|
|
180
|
+
await movePath(aside, finalPathString)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
throw error
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
for (const sfx of ["-wal", "-shm"]) {
|
|
187
|
+
await removePathIfPresent(tmpPathString + sfx)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
await removePathIfPresent(aside)
|
|
191
|
+
}
|
package/lib/sealed.ts
CHANGED
|
@@ -3,29 +3,34 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Open a built data artifact.
|
|
7
7
|
*
|
|
8
8
|
* This is the other half of the sealed-artifact invariant in `../utils/sealed-db.ts`: that module owns the
|
|
9
9
|
* filesystem side (seal, unseal-refusal, atomic swap) and stays free of a static `node:sqlite` import, because it
|
|
10
|
-
*
|
|
10
|
+
* flows through the `@mailwoman/core/utils` barrel into consumers that cannot resolve one. The open lives here, where
|
|
11
11
|
* `DatabaseClient` is already imported and the cost is paid. The open is asynchronous: the write branch awaits the
|
|
12
12
|
* seal check against the filesystem before the handle is constructed.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import type { PathBuilderLike } from "path-ts"
|
|
16
|
+
|
|
15
17
|
import { DatabaseClient } from "#client"
|
|
16
18
|
import type { Database } from "#database-schema"
|
|
17
|
-
import { assertUnsealedForWrite } from "#sealed
|
|
19
|
+
import { assertUnsealedForWrite } from "#sealed/db"
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
|
-
* Open a built data artifact.
|
|
21
|
-
*
|
|
22
|
+
* Open a built data artifact.
|
|
23
|
+
*
|
|
24
|
+
* Read-only by default.
|
|
25
|
+
* Builders set `write: true` when working on UNsealed staging.
|
|
26
|
+
* A sealed file raises `SealedArtifactError`.
|
|
22
27
|
*
|
|
23
|
-
* Together with `new DatabaseClient(path)` this is the whole set of ways a connection comes into being.
|
|
24
|
-
* is constructed in exactly one place, inside `DatabaseClient`,
|
|
25
|
-
* described by two schemas.
|
|
28
|
+
* Together with `new DatabaseClient(path)` this is the whole set of ways a connection comes into being.
|
|
29
|
+
* `DatabaseSync` is constructed in exactly one place, inside `DatabaseClient`,
|
|
30
|
+
* so no caller holds a raw handle and no database ends up described by two schemas.
|
|
26
31
|
*/
|
|
27
32
|
export async function openBuiltClient<DB = Database>(
|
|
28
|
-
path:
|
|
33
|
+
path: PathBuilderLike,
|
|
29
34
|
opts: { write?: boolean } = {}
|
|
30
35
|
): Promise<DatabaseClient<DB>> {
|
|
31
36
|
if (opts.write) {
|
package/out/batched.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Batched bulk-write transactions — the `
|
|
6
|
+
* Batched bulk-write transactions — the `commit`/`begin` cadence every streaming ingest repeats around its
|
|
7
7
|
* raw prepared-statement loop.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
@@ -11,26 +11,20 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export interface BatchedTransaction {
|
|
13
13
|
/**
|
|
14
|
-
* Record one written row
|
|
15
|
-
* `true` on the call that committed
|
|
14
|
+
* Record one written row, committing and reopening the transaction every `rowsPerCommit`
|
|
15
|
+
* rows and answering `true` on the call that committed.
|
|
16
16
|
*/
|
|
17
17
|
rowWritten(): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Commit the open transaction — the ordinary end of an ingest loop.
|
|
20
|
-
*/
|
|
21
18
|
commit(): void;
|
|
22
19
|
/**
|
|
23
|
-
* Best-effort `
|
|
24
|
-
*
|
|
25
|
-
* ingest stopped, not that a scratch file was tidied.
|
|
20
|
+
* Best-effort `rollback` that must never replace the real error, so the caller
|
|
21
|
+
* still sees why the ingest stopped.
|
|
26
22
|
*/
|
|
27
23
|
rollbackQuietly(): void;
|
|
28
24
|
}
|
|
29
25
|
/**
|
|
30
|
-
* Open a transaction that commits and reopens itself every `rowsPerCommit` written rows
|
|
31
|
-
*
|
|
32
|
-
* The batch size is the caller's: a geometry table whose rows carry a blob wants a smaller transaction than a
|
|
33
|
-
* fixed-width staging table, because a larger one grows the write-ahead file without improving throughput.
|
|
26
|
+
* Open a transaction that commits and reopens itself every `rowsPerCommit` written rows,
|
|
27
|
+
* with the batch size left to the caller.
|
|
34
28
|
*/
|
|
35
29
|
export declare function beginBatched(database: {
|
|
36
30
|
exec(sql: string): void;
|
package/out/batched.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batched.d.ts","sourceRoot":"","sources":["../lib/batched.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAA;IACrB
|
|
1
|
+
{"version":3,"file":"batched.d.ts","sourceRoot":"","sources":["../lib/batched.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAA;IACrB,MAAM,IAAI,IAAI,CAAA;IACd;;;OAGG;IACH,eAAe,IAAI,IAAI,CAAA;CACvB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE;IAAE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACrC,OAAO,EAAE;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,GAChC,kBAAkB,CA6BpB"}
|
package/out/batched.js
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Batched bulk-write transactions — the `
|
|
6
|
+
* Batched bulk-write transactions — the `commit`/`begin` cadence every streaming ingest repeats around its
|
|
7
7
|
* raw prepared-statement loop.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* Open a transaction that commits and reopens itself every `rowsPerCommit` written rows
|
|
11
|
-
*
|
|
12
|
-
* The batch size is the caller's: a geometry table whose rows carry a blob wants a smaller transaction than a
|
|
13
|
-
* fixed-width staging table, because a larger one grows the write-ahead file without improving throughput.
|
|
10
|
+
* Open a transaction that commits and reopens itself every `rowsPerCommit` written rows,
|
|
11
|
+
* with the batch size left to the caller.
|
|
14
12
|
*/
|
|
15
13
|
export function beginBatched(database, options) {
|
|
16
14
|
let pending = 0;
|
package/out/batched.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batched.js","sourceRoot":"","sources":["../lib/batched.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"batched.js","sourceRoot":"","sources":["../lib/batched.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC3B,QAAqC,EACrC,OAAkC;IAElC,IAAI,OAAO,GAAG,CAAC,CAAA;IAEf,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAEtB,OAAO;QACN,UAAU;YACT,OAAO,EAAE,CAAA;YAET,IAAI,OAAO,GAAG,OAAO,CAAC,aAAa;gBAAE,OAAO,KAAK,CAAA;YAEjD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACvB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAEtB,OAAO,GAAG,CAAC,CAAA;YAEX,OAAO,IAAI,CAAA;QACZ,CAAC;QACD,MAAM;YACL,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACxB,CAAC;QACD,eAAe;YACd,IAAI,CAAC;gBACJ,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACR,6CAA6C;YAC9C,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC"}
|
package/out/client.d.ts
CHANGED
|
@@ -7,80 +7,53 @@ import { DatabaseSync, type DatabaseSyncOptions, type FunctionOptions, type SQLI
|
|
|
7
7
|
import { Kysely, type KyselyConfig } from "kysely";
|
|
8
8
|
import { type PathBuilderLike } from "path-ts";
|
|
9
9
|
import type { Database } from "#database-schema";
|
|
10
|
-
import type { SqliteDialectConfig } from "#dialect
|
|
11
|
-
/**
|
|
12
|
-
* A SQLite client for one database file: a Kysely query builder over `node:sqlite`, plus the two raw statements Kysely
|
|
13
|
-
* cannot express.
|
|
14
|
-
*
|
|
15
|
-
* The client opens the file. A caller says which file and which schema; it never builds the connection itself.
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* using kdb = new DatabaseClient<MySchema>("db.sqlite", { readOnly: true })
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Handing that job to callers is what let one database be described by two schemas — the type argument here and a
|
|
22
|
-
* second one on the handle — with nothing to make them agree. It also split ownership: `SqliteDriver.destroy()` closes
|
|
23
|
-
* whatever connection it was given, so a shared handle has two owners and the first `destroy()` closes it under the
|
|
24
|
-
* other. One construction gives one schema, one owner, and a lifetime `using` can end.
|
|
25
|
-
*
|
|
26
|
-
* `exec` and `prepare` reach the same connection for the work Kysely does not model. See `core/db/schema.ts`.
|
|
27
|
-
*/
|
|
10
|
+
import type { SqliteDialectConfig } from "#dialect/config";
|
|
28
11
|
/**
|
|
29
12
|
* A connection's non-Kysely surface: the statements Kysely does not model, plus ending the connection.
|
|
30
13
|
*
|
|
31
|
-
* Schema-agnostic
|
|
32
|
-
*
|
|
33
|
-
* `DatabaseClient` (the empty default) would reject every real client. This is the narrowing the
|
|
34
|
-
* `mailwoman/no-database-handle-cast` rule prescribes, applied to the raw side.
|
|
14
|
+
* Schema-agnostic because Kysely is invariant in `DB`: a parameter typed
|
|
15
|
+
* `DatabaseClient` would reject every real client.
|
|
35
16
|
*/
|
|
36
17
|
export type RawStatements = Pick<DatabaseClient, "exec" | "prepare" | "function" | "destroy"> & Disposable;
|
|
18
|
+
/**
|
|
19
|
+
* A SQLite client for one database file: a Kysely query builder over `node:sqlite`,
|
|
20
|
+
* plus the two raw statements Kysely cannot express.
|
|
21
|
+
*/
|
|
37
22
|
export declare class DatabaseClient<DB = Database> extends Kysely<DB> implements Disposable {
|
|
38
23
|
#private;
|
|
39
24
|
/**
|
|
40
|
-
* A memory-only database, for tests and other ephemeral work.
|
|
25
|
+
* A memory-only database, for tests and other ephemeral work.
|
|
41
26
|
*/
|
|
42
27
|
static temp<DB = Database>(): DatabaseClient<DB>;
|
|
43
28
|
constructor(location: PathBuilderLike, options?: DatabaseSyncOptions, config?: Partial<KyselyConfig>);
|
|
44
29
|
constructor(database: DatabaseSync, config?: Partial<KyselyConfig>);
|
|
45
30
|
constructor(dialectConfig: SqliteDialectConfig, config?: Partial<KyselyConfig>);
|
|
46
31
|
/**
|
|
47
|
-
* Run a statement Kysely does not model: `
|
|
48
|
-
*
|
|
49
|
-
* Not to be confused with Kysely's `execute()`, which runs a compiled query. This one takes SQL text and returns
|
|
50
|
-
* nothing.
|
|
32
|
+
* Run a statement Kysely does not model: `pragma`, `vacuum`, `analyze`, `attach`, FTS5 virtual-table DDL.
|
|
51
33
|
*/
|
|
52
34
|
exec(sql: string): void;
|
|
53
35
|
/**
|
|
54
36
|
* A prepared statement on this client's connection, for the bulk-write path.
|
|
55
|
-
*
|
|
56
|
-
* Kysely compiles per call, which a positional insert loop over millions of rows cannot afford. Reach for this only
|
|
57
|
-
* there and in the other cases `AGENTS.md` lists as deliberately raw; everything cold goes through the query builder,
|
|
58
|
-
* where the schema is checked.
|
|
59
37
|
*/
|
|
60
38
|
prepare(sql: string): StatementSync;
|
|
61
39
|
/**
|
|
62
40
|
* Register a user-defined SQL function on this client's connection, callable from any statement it runs.
|
|
63
41
|
*
|
|
64
|
-
* SQLite resolves the name at statement-compile time, so registration must
|
|
42
|
+
* SQLite resolves the name at statement-compile time, so registration must
|
|
43
|
+
* precede the first query that uses it.
|
|
65
44
|
*/
|
|
66
45
|
function(name: string, options: FunctionOptions, fn: (...args: SQLOutputValue[]) => SQLInputValue): void;
|
|
67
46
|
function(name: string, fn: (...args: SQLOutputValue[]) => SQLInputValue): void;
|
|
68
47
|
/**
|
|
69
48
|
* End the connection at scope exit, synchronously.
|
|
70
49
|
*
|
|
71
|
-
* `destroy()`
|
|
72
|
-
*
|
|
73
|
-
* finalized statement) would see a connection that should have been gone. `node:sqlite`'s `close()` is synchronous,
|
|
74
|
-
* so `using` closes the file before the scope ends.
|
|
75
|
-
*
|
|
76
|
-
* Kysely's own driver state is not unwound here. It holds this one connection and nothing else, and a query issued
|
|
77
|
-
* afterwards fails on the closed handle rather than on a pool that thinks it is alive.
|
|
50
|
+
* `destroy()` returns a promise, so `Symbol.dispose` cannot call it.
|
|
51
|
+
* `node:sqlite`'s `close()` is synchronous.
|
|
78
52
|
*/
|
|
79
53
|
[Symbol.dispose](): void;
|
|
80
54
|
}
|
|
81
55
|
/**
|
|
82
|
-
* The `node:sqlite` types a caller needs when it holds a statement or binds a value.
|
|
83
|
-
* reach past this package for them.
|
|
56
|
+
* The `node:sqlite` types a caller needs when it holds a statement or binds a value.
|
|
84
57
|
*/
|
|
85
58
|
export type { DatabaseSyncOptions, SQLInputValue, SQLOutputValue, StatementSync } from "node:sqlite";
|
|
86
59
|
//# sourceMappingURL=client.d.ts.map
|
package/out/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../lib/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../lib/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC,GAAG,UAAU,CAAA;AAE1G;;;GAGG;AACH,qBAAa,cAAc,CAAC,EAAE,GAAG,QAAQ,CAAE,SAAQ,MAAM,CAAC,EAAE,CAAE,YAAW,UAAU;;IAClF;;OAEG;IACH,OAAc,IAAI,CAAC,EAAE,GAAG,QAAQ,KAAK,cAAc,CAAC,EAAE,CAAC,CAEtD;IAID,YAAY,QAAQ,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAC;IACrG,YAAY,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAC;IACnE,YAAY,aAAa,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAC;IAuC/E;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtB;IAED;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAElC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,cAAc,EAAE,KAAK,aAAa,GAAG,IAAI,CAAA;IACxG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,cAAc,EAAE,KAAK,aAAa,GAAG,IAAI,CAAA;IAe9E;;;;;OAKG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAEvB;CACD;AAED;;GAEG;AACH,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA"}
|
package/out/client.js
CHANGED
|
@@ -7,9 +7,13 @@ import { DatabaseSync, } from "node:sqlite";
|
|
|
7
7
|
import { Kysely } from "kysely";
|
|
8
8
|
import { PathBuilder } from "path-ts";
|
|
9
9
|
import { SqliteDialect } from "#dialect";
|
|
10
|
+
/**
|
|
11
|
+
* A SQLite client for one database file: a Kysely query builder over `node:sqlite`,
|
|
12
|
+
* plus the two raw statements Kysely cannot express.
|
|
13
|
+
*/
|
|
10
14
|
export class DatabaseClient extends Kysely {
|
|
11
15
|
/**
|
|
12
|
-
* A memory-only database, for tests and other ephemeral work.
|
|
16
|
+
* A memory-only database, for tests and other ephemeral work.
|
|
13
17
|
*/
|
|
14
18
|
static temp() {
|
|
15
19
|
return new DatabaseClient(":memory:");
|
|
@@ -21,7 +25,7 @@ export class DatabaseClient extends Kysely {
|
|
|
21
25
|
if (typeof source === "string" || source instanceof PathBuilder) {
|
|
22
26
|
const location = source.toString();
|
|
23
27
|
const options = optionsOrConfig;
|
|
24
|
-
// node:sqlite checks the argument count
|
|
28
|
+
// node:sqlite checks the argument count rather than the value: `new DatabaseSync(path, undefined)` throws.
|
|
25
29
|
const openArgs = options ? [location, options] : [location];
|
|
26
30
|
database = new DatabaseSync(...openArgs);
|
|
27
31
|
kyselyConfig = config;
|
|
@@ -42,20 +46,13 @@ export class DatabaseClient extends Kysely {
|
|
|
42
46
|
this.#database = database;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
|
-
* Run a statement Kysely does not model: `
|
|
46
|
-
*
|
|
47
|
-
* Not to be confused with Kysely's `execute()`, which runs a compiled query. This one takes SQL text and returns
|
|
48
|
-
* nothing.
|
|
49
|
+
* Run a statement Kysely does not model: `pragma`, `vacuum`, `analyze`, `attach`, FTS5 virtual-table DDL.
|
|
49
50
|
*/
|
|
50
51
|
exec(sql) {
|
|
51
52
|
this.#database.exec(sql);
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* A prepared statement on this client's connection, for the bulk-write path.
|
|
55
|
-
*
|
|
56
|
-
* Kysely compiles per call, which a positional insert loop over millions of rows cannot afford. Reach for this only
|
|
57
|
-
* there and in the other cases `AGENTS.md` lists as deliberately raw; everything cold goes through the query builder,
|
|
58
|
-
* where the schema is checked.
|
|
59
56
|
*/
|
|
60
57
|
prepare(sql) {
|
|
61
58
|
return this.#database.prepare(sql);
|
|
@@ -70,13 +67,8 @@ export class DatabaseClient extends Kysely {
|
|
|
70
67
|
/**
|
|
71
68
|
* End the connection at scope exit, synchronously.
|
|
72
69
|
*
|
|
73
|
-
* `destroy()`
|
|
74
|
-
*
|
|
75
|
-
* finalized statement) would see a connection that should have been gone. `node:sqlite`'s `close()` is synchronous,
|
|
76
|
-
* so `using` closes the file before the scope ends.
|
|
77
|
-
*
|
|
78
|
-
* Kysely's own driver state is not unwound here. It holds this one connection and nothing else, and a query issued
|
|
79
|
-
* afterwards fails on the closed handle rather than on a pool that thinks it is alive.
|
|
70
|
+
* `destroy()` returns a promise, so `Symbol.dispose` cannot call it.
|
|
71
|
+
* `node:sqlite`'s `close()` is synchronous.
|
|
80
72
|
*/
|
|
81
73
|
[Symbol.dispose]() {
|
|
82
74
|
this.#database[Symbol.dispose]();
|
package/out/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../lib/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,YAAY,GAMZ,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,MAAM,EAAqB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,WAAW,EAAwB,MAAM,SAAS,CAAA;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../lib/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,YAAY,GAMZ,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,MAAM,EAAqB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,WAAW,EAAwB,MAAM,SAAS,CAAA;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAWxC;;;GAGG;AACH,MAAM,OAAO,cAA8B,SAAQ,MAAU;IAC5D;;OAEG;IACI,MAAM,CAAC,IAAI;QACjB,OAAO,IAAI,cAAc,CAAK,UAAU,CAAC,CAAA;IAC1C,CAAC;IAEQ,SAAS,CAAc;IAKhC,YACC,MAA4D,EAC5D,eAA6D,EAC7D,MAA8B;QAE9B,IAAI,QAAsB,CAAA;QAC1B,IAAI,YAA+C,CAAA;QAEnD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;YACjE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;YAClC,MAAM,OAAO,GAAG,eAAkD,CAAA;YAClE,2GAA2G;YAC3G,MAAM,QAAQ,GAAmC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;YAE3F,QAAQ,GAAG,IAAI,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAA;YACxC,YAAY,GAAG,MAAM,CAAA;QACtB,CAAC;aAAM,CAAC;YACP,MAAM,aAAa,GAAG,UAAU,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;YAE1E,IAAI,OAAO,aAAa,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;gBAClD,MAAM,IAAI,SAAS,CAClB,kGAAkG;oBACjG,kEAAkE,CACnE,CAAA;YACF,CAAC;YAED,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAA;YACjC,YAAY,GAAG,eAAoD,CAAA;QACpE,CAAC;QAED,KAAK,CAAC;YACL,GAAG,YAAY;YACf,OAAO,EAAE,IAAI,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;SACxC,CAAC,CAAA;QAEF,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,GAAW;QACf,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAW;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACnC,CAAC;IAUD,QAAQ,CACP,IAAY,EACZ,WAA6E,EAC7E,EAAiD;QAEjD,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;YACvC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;YAE1C,OAAM;QACP,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,EAAG,CAAC,CAAA;IAChD,CAAC;IAED;;;;;OAKG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;IACjC,CAAC;CACD"}
|
package/out/database-schema.d.ts
CHANGED
|
@@ -3,28 +3,10 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* This file intentionally ships an empty schema. Consumers that want compile-time table typing
|
|
9
|
-
* should extend `Kysely<TheirSchema>` directly rather than baking a schema into core — the WOF
|
|
10
|
-
* resolver (Phase 4.2), corpus adapters, and any future consumer all touch different tables.
|
|
11
|
-
*
|
|
12
|
-
* The exported `Database` interface exists so `client.ts` has a target for `Kysely<Database>` and
|
|
13
|
-
* the boilerplate compiles without forcing a concrete schema commitment.
|
|
14
|
-
*
|
|
15
|
-
* IT IS THE DEFAULT, NOT THE ONLY OPTION, and reading it as the only option is how `as never` gets written. Every
|
|
16
|
-
* table name typed against `Record<string, never>` IS `never`, so `insertInto("poi")` cannot compile and a caller
|
|
17
|
-
* who believes no alternative exists casts — which disarms not just that one check but every type-level guarantee
|
|
18
|
-
* anyone later adds to the table (#1757 has the worked case: a branded key column whose check a neighbouring
|
|
19
|
-
* `as never` had already defeated).
|
|
6
|
+
* Default schema type for {@link DatabaseClient}; consumers supply their own table schema.
|
|
20
7
|
*/
|
|
21
8
|
/**
|
|
22
|
-
* Empty schema marker
|
|
23
|
-
*
|
|
24
|
-
* Consumers declare their own schema interface and pass it directly: `new Kysely<MySchema>({…})` or `new
|
|
25
|
-
* DatabaseClient<MySchema>(…)`. `DatabaseClient<DB = Database>` is generic today, so this is available now — the
|
|
26
|
-
* sentence here once deferred it to "Phase 4.2 work", which had already landed, and a reader who believed that had no
|
|
27
|
-
* option but to cast.
|
|
9
|
+
* Empty schema marker used only as the generic default.
|
|
28
10
|
*/
|
|
29
11
|
export type Database = Record<string, never>;
|
|
30
12
|
//# sourceMappingURL=database-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-schema.d.ts","sourceRoot":"","sources":["../lib/database-schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"database-schema.d.ts","sourceRoot":"","sources":["../lib/database-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA"}
|
package/out/database-schema.js
CHANGED
|
@@ -3,20 +3,7 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* This file intentionally ships an empty schema. Consumers that want compile-time table typing
|
|
9
|
-
* should extend `Kysely<TheirSchema>` directly rather than baking a schema into core — the WOF
|
|
10
|
-
* resolver (Phase 4.2), corpus adapters, and any future consumer all touch different tables.
|
|
11
|
-
*
|
|
12
|
-
* The exported `Database` interface exists so `client.ts` has a target for `Kysely<Database>` and
|
|
13
|
-
* the boilerplate compiles without forcing a concrete schema commitment.
|
|
14
|
-
*
|
|
15
|
-
* IT IS THE DEFAULT, NOT THE ONLY OPTION, and reading it as the only option is how `as never` gets written. Every
|
|
16
|
-
* table name typed against `Record<string, never>` IS `never`, so `insertInto("poi")` cannot compile and a caller
|
|
17
|
-
* who believes no alternative exists casts — which disarms not just that one check but every type-level guarantee
|
|
18
|
-
* anyone later adds to the table (#1757 has the worked case: a branded key column whose check a neighbouring
|
|
19
|
-
* `as never` had already defeated).
|
|
6
|
+
* Default schema type for {@link DatabaseClient}; consumers supply their own table schema.
|
|
20
7
|
*/
|
|
21
8
|
export {};
|
|
22
9
|
//# sourceMappingURL=database-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-schema.js","sourceRoot":"","sources":["../lib/database-schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"database-schema.js","sourceRoot":"","sources":["../lib/database-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../lib/dialect/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;OAMG;IACH,QAAQ,EAAE,YAAY,GAAG,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;IAEtD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../lib/dialect/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/out/dialect.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
import { type DatabaseIntrospector, type Dialect, type DialectAdapter, type Driver, type Kysely, type QueryCompiler } from "kysely";
|
|
7
|
-
import type { SqliteDialectConfig } from "#dialect
|
|
7
|
+
import type { SqliteDialectConfig } from "#dialect/config";
|
|
8
8
|
/**
|
|
9
9
|
* SQLite dialect that uses the [`node:sqlite`](https://nodejs.org/api/sqlite.html) library.
|
|
10
10
|
*
|
package/out/dialect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../lib/dialect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAG1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,SAAS,CAAC,MAAM,EAAE,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../lib/dialect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAG1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,SAAS,CAAC,MAAM,EAAE,mBAAmB,CAAA;IAErC,YAAY,MAAM,EAAE,mBAAmB,EAEtC;IAED,YAAY,IAAI,MAAM,CAErB;IAED,mBAAmB,IAAI,aAAa,CAEnC;IAED,aAAa,IAAI,cAAc,CAE9B;IAED,kBAAkB,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,oBAAoB,CAE5D;CACD"}
|
package/out/driver.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
import { type DatabaseConnection, type Driver, type QueryCompiler } from "kysely";
|
|
7
|
-
import type { SqliteDialectConfig } from "#dialect
|
|
7
|
+
import type { SqliteDialectConfig } from "#dialect/config";
|
|
8
8
|
export declare class SqliteDriver implements Driver {
|
|
9
9
|
#private;
|
|
10
10
|
constructor(config: SqliteDialectConfig);
|
package/out/driver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../lib/driver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAGN,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAEX,KAAK,aAAa,EAIlB,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AA0B1D,qBAAa,YAAa,YAAW,MAAM;;
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../lib/driver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAGN,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAEX,KAAK,aAAa,EAIlB,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AA0B1D,qBAAa,YAAa,YAAW,MAAM;;IAO1C,YAAY,MAAM,EAAE,mBAAmB,EAEtC;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAS1B;IAEK,iBAAiB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAOrD;IAEK,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;IAEK,iBAAiB,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAErE;IAEK,mBAAmB,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvE;IAEK,SAAS,CACd,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CAEf;IAEK,mBAAmB,CACxB,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CAEf;IAEK,gBAAgB,CACrB,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CAEf;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEvC;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAE7B;CACD"}
|
package/out/driver.js
CHANGED
|
@@ -39,8 +39,8 @@ export class SqliteDriver {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
async acquireConnection() {
|
|
42
|
-
// SQLite only has one single connection.
|
|
43
|
-
// until the single connection has been released.
|
|
42
|
+
// SQLite only has one single connection.
|
|
43
|
+
// We use a mutex here to wait until the single connection has been released.
|
|
44
44
|
await this.#connectionMutex.lock();
|
|
45
45
|
// biome-ignore lint/style/noNonNullAssertion: :shrug:
|
|
46
46
|
return this.#connection;
|