@vibesdotdev/localdb 0.0.2 → 1.0.0-rc.2
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/LICENSE +18 -0
- package/README.md +123 -2
- package/dist/cli/commands/_shared.consumer.d.ts +1 -3
- package/dist/cli/commands/_shared.consumer.d.ts.map +1 -1
- package/dist/cli/commands/_shared.consumer.js +1 -11
- package/dist/cli/commands/_shared.consumer.js.map +1 -1
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.d.ts +9 -3
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.d.ts.map +1 -1
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.js +59 -45
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.js.map +1 -1
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.d.ts +8 -3
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.js +12 -10
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.d.ts +6 -3
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.js +8 -7
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/query/dev.localdb.query.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/query/dev.localdb.query.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.d.ts +13 -3
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.d.ts.map +1 -1
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.js +66 -51
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.js.map +1 -1
- package/dist/cli/commands/status/dev.localdb.status.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/status/dev.localdb.status.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.d.ts +9 -3
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.d.ts.map +1 -1
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.js +41 -29
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.js.map +1 -1
- package/dist/cli/inputs.d.ts +25 -0
- package/dist/cli/inputs.d.ts.map +1 -0
- package/dist/cli/inputs.js +81 -0
- package/dist/cli/inputs.js.map +1 -0
- package/dist/cli/types.d.ts +45 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +14 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/core/connection-pool.d.ts +204 -46
- package/dist/core/connection-pool.d.ts.map +1 -1
- package/dist/core/connection-pool.js +610 -101
- package/dist/core/connection-pool.js.map +1 -1
- package/dist/core/database.d.ts +243 -63
- package/dist/core/database.d.ts.map +1 -1
- package/dist/core/database.js +937 -203
- package/dist/core/database.js.map +1 -1
- package/dist/core/holders.d.ts +15 -0
- package/dist/core/holders.d.ts.map +1 -0
- package/dist/core/holders.js +4 -0
- package/dist/core/holders.js.map +1 -0
- package/dist/core/host-kinds.d.ts +22 -0
- package/dist/core/host-kinds.d.ts.map +1 -0
- package/dist/core/host-kinds.js +52 -0
- package/dist/core/host-kinds.js.map +1 -0
- package/dist/core/live-runtime.d.ts +17 -0
- package/dist/core/live-runtime.d.ts.map +1 -0
- package/dist/core/live-runtime.js +28 -0
- package/dist/core/live-runtime.js.map +1 -0
- package/dist/core/migration-registry.d.ts +115 -80
- package/dist/core/migration-registry.d.ts.map +1 -1
- package/dist/core/migration-registry.js +340 -199
- package/dist/core/migration-registry.js.map +1 -1
- package/dist/core/open-connection.d.ts +11 -0
- package/dist/core/open-connection.d.ts.map +1 -0
- package/dist/core/open-connection.js +70 -0
- package/dist/core/open-connection.js.map +1 -0
- package/dist/core/outcome.d.ts +21 -0
- package/dist/core/outcome.d.ts.map +1 -0
- package/dist/core/outcome.js +22 -0
- package/dist/core/outcome.js.map +1 -0
- package/dist/core/pool-api.d.ts +19 -0
- package/dist/core/pool-api.d.ts.map +1 -0
- package/dist/core/pool-api.js +59 -0
- package/dist/core/pool-api.js.map +1 -0
- package/dist/core/slow-statement.d.ts +81 -0
- package/dist/core/slow-statement.d.ts.map +1 -0
- package/dist/core/slow-statement.js +149 -0
- package/dist/core/slow-statement.js.map +1 -0
- package/dist/core/wal-policy.d.ts +86 -0
- package/dist/core/wal-policy.d.ts.map +1 -0
- package/dist/core/wal-policy.js +115 -0
- package/dist/core/wal-policy.js.map +1 -0
- package/dist/dev.localdb.cli-group.descriptor.d.ts +1 -1
- package/dist/dev.localdb.cli-group.descriptor.d.ts.map +1 -1
- package/dist/dev.localdb.context.descriptor.d.ts +15 -1
- package/dist/dev.localdb.context.descriptor.d.ts.map +1 -1
- package/dist/dev.localdb.context.descriptor.js +1 -1
- package/dist/dev.localdb.context.descriptor.js.map +1 -1
- package/dist/dev.localdb.context.impl.consumer.d.ts +12 -5
- package/dist/dev.localdb.context.impl.consumer.d.ts.map +1 -1
- package/dist/dev.localdb.context.impl.consumer.js +14 -5
- package/dist/dev.localdb.context.impl.consumer.js.map +1 -1
- package/dist/driver/sqlite-driver.base.d.ts +107 -0
- package/dist/driver/sqlite-driver.base.d.ts.map +1 -0
- package/dist/driver/sqlite-driver.base.js +426 -0
- package/dist/driver/sqlite-driver.base.js.map +1 -0
- package/dist/driver/sqlite-driver.d.ts +154 -0
- package/dist/driver/sqlite-driver.d.ts.map +1 -0
- package/dist/driver/sqlite-driver.js +103 -0
- package/dist/driver/sqlite-driver.js.map +1 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/localdb.client.descriptor.d.ts +10 -0
- package/dist/localdb.client.descriptor.d.ts.map +1 -0
- package/dist/localdb.client.descriptor.js +13 -0
- package/dist/localdb.client.descriptor.js.map +1 -0
- package/dist/localdb.client.impl.consumer.d.ts +11 -0
- package/dist/localdb.client.impl.consumer.d.ts.map +1 -0
- package/dist/localdb.client.impl.consumer.js +11 -0
- package/dist/localdb.client.impl.consumer.js.map +1 -0
- package/dist/localdb.plugin.d.ts +2 -2
- package/dist/localdb.plugin.d.ts.map +1 -1
- package/dist/localdb.plugin.js +58 -10
- package/dist/localdb.plugin.js.map +1 -1
- package/dist/location.d.ts +6 -0
- package/dist/location.d.ts.map +1 -0
- package/dist/location.js +6 -0
- package/dist/location.js.map +1 -0
- package/dist/migrations/load-sql.d.ts +25 -21
- package/dist/migrations/load-sql.d.ts.map +1 -1
- package/dist/migrations/load-sql.js +91 -76
- package/dist/migrations/load-sql.js.map +1 -1
- package/dist/pool.d.ts +3 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +3 -0
- package/dist/pool.js.map +1 -0
- package/dist/schemas/api.d.ts +133 -59
- package/dist/schemas/api.d.ts.map +1 -1
- package/dist/schemas/api.js +1 -1
- package/dist/schemas/api.js.map +1 -1
- package/dist/schemas/migrations.d.ts +123 -0
- package/dist/schemas/migrations.d.ts.map +1 -0
- package/dist/schemas/migrations.js +55 -0
- package/dist/schemas/migrations.js.map +1 -0
- package/dist/schemas/pool.d.ts +27 -0
- package/dist/schemas/pool.d.ts.map +1 -0
- package/dist/schemas/pool.js +7 -0
- package/dist/schemas/pool.js.map +1 -0
- package/dist/schemas/sqlite-driver-base.d.ts +50 -0
- package/dist/schemas/sqlite-driver-base.d.ts.map +1 -0
- package/dist/schemas/sqlite-driver-base.js +2 -0
- package/dist/schemas/sqlite-driver-base.js.map +1 -0
- package/dist/testing/sqlite-driver-conformance.d.ts +42 -0
- package/dist/testing/sqlite-driver-conformance.d.ts.map +1 -0
- package/dist/testing/sqlite-driver-conformance.js +471 -0
- package/dist/testing/sqlite-driver-conformance.js.map +1 -0
- package/package.json +78 -104
- package/dist/core/error-context.d.ts +0 -2
- package/dist/core/error-context.d.ts.map +0 -1
- package/dist/core/error-context.js +0 -17
- package/dist/core/error-context.js.map +0 -1
- package/dist/core/runtime.d.ts +0 -3
- package/dist/core/runtime.d.ts.map +0 -1
- package/dist/core/runtime.js +0 -17
- package/dist/core/runtime.js.map +0 -1
- package/dist/localdb.cloud.plugin.d.ts +0 -17
- package/dist/localdb.cloud.plugin.d.ts.map +0 -1
- package/dist/localdb.cloud.plugin.js +0 -23
- package/dist/localdb.cloud.plugin.js.map +0 -1
- package/src/cli/commands/_shared.consumer.ts +0 -20
- package/src/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.ts +0 -20
- package/src/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.ts +0 -97
- package/src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.ts +0 -17
- package/src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.ts +0 -46
- package/src/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.ts +0 -16
- package/src/cli/commands/pools/dev.localdb.pools.cli-command.impl.ts +0 -37
- package/src/cli/commands/query/dev.localdb.query.cli-command.descriptor.ts +0 -21
- package/src/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.ts +0 -69
- package/src/cli/commands/status/dev.localdb.status.cli-command.descriptor.ts +0 -20
- package/src/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.ts +0 -93
- package/src/core/connection-pool.ts +0 -240
- package/src/core/database.ts +0 -419
- package/src/core/error-context.ts +0 -19
- package/src/core/migration-registry.ts +0 -321
- package/src/core/runtime.ts +0 -17
- package/src/dev.localdb.cli-group.descriptor.ts +0 -20
- package/src/dev.localdb.context.descriptor.ts +0 -13
- package/src/dev.localdb.context.impl.consumer.ts +0 -12
- package/src/index.ts +0 -28
- package/src/localdb.cloud.plugin.ts +0 -24
- package/src/localdb.plugin.ts +0 -43
- package/src/migrations/atlas/001-initial-schema.sql +0 -173
- package/src/migrations/atlas/002-lang-server-fields.sql +0 -12
- package/src/migrations/atlas/003-config-id-dedup.sql +0 -31
- package/src/migrations/atlas/004-fix-on-conflict-constraints.sql +0 -25
- package/src/migrations/atlas/005-diagnostics.sql +0 -66
- package/src/migrations/atlas/006-diagnostic-summaries.sql +0 -65
- package/src/migrations/atlas/007-diagnostic-slice.sql +0 -83
- package/src/migrations/load-sql.ts +0 -133
- package/src/schemas/api.ts +0 -92
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SQLite driver kind (`localdb/sqlite-driver`): LocalDB's contract with the
|
|
3
|
+
* host that opens SQLite files (#011 ruling 2026-10-03).
|
|
4
|
+
*
|
|
5
|
+
* LocalDB owns this contract and the policy above it (pragmas, WAL
|
|
6
|
+
* maintenance, startup retry, migrations); each host package implements it
|
|
7
|
+
* with its own SQLite binding (`bun:sqlite` in runtime-environment-bun,
|
|
8
|
+
* `node:sqlite` in runtime-environment-node) and registers the implementation
|
|
9
|
+
* on the runtimes it builds. LocalDB resolves it from the runtime each call is
|
|
10
|
+
* handed and never reads a host error shape: hosts classify every failure into
|
|
11
|
+
* the typed refusals below.
|
|
12
|
+
*
|
|
13
|
+
* Calls are synchronous, as SQLite's are. See SPEC "SQLite driver kind".
|
|
14
|
+
*/
|
|
15
|
+
import * as z from 'zod/v4';
|
|
16
|
+
import { CapabilityError, createRuntimeKind, isCapabilityError, RuntimeDescriptorSchema } from '@vibesdotdev/kernel';
|
|
17
|
+
/** The kind id hosts register their driver under. */
|
|
18
|
+
export const LOCALDB_SQLITE_DRIVER_KIND = 'localdb/sqlite-driver';
|
|
19
|
+
/** Every refusal a driver raises, by reason. Host errors are classified into bounded details and never attached as `cause`. */
|
|
20
|
+
export const SQLITE_DRIVER_REFUSALS = {
|
|
21
|
+
/** `INVALID_INPUT`: the open request is not an absolute path (or `:memory:`) with well-formed own options. */
|
|
22
|
+
openInvalid: 'sqlite-open-invalid',
|
|
23
|
+
/** `NOT_FOUND`: `create: false` and no file at the path. */
|
|
24
|
+
databaseMissing: 'sqlite-database-missing',
|
|
25
|
+
/** `UNAVAILABLE`: the host could not open the file. */
|
|
26
|
+
openFailed: 'sqlite-open-failed',
|
|
27
|
+
/** `CONFLICT`, retryable: `SQLITE_BUSY` or `SQLITE_LOCKED`. */
|
|
28
|
+
busy: 'sqlite-busy',
|
|
29
|
+
/** `INTERNAL`: any other SQLite failure of a statement. */
|
|
30
|
+
statementFailed: 'sqlite-statement-failed',
|
|
31
|
+
/** `INVALID_INPUT`: SQL text that is not a string. */
|
|
32
|
+
sqlInvalid: 'sqlite-sql-invalid',
|
|
33
|
+
/** `INVALID_INPUT`: a bound parameter is not a {@link SqliteBinding}. */
|
|
34
|
+
bindingInvalid: 'sqlite-binding-invalid',
|
|
35
|
+
/** `INVALID_INPUT`: a transaction body returned a Promise; it was rolled back. */
|
|
36
|
+
transactionAsync: 'sqlite-transaction-async',
|
|
37
|
+
/** `UNAVAILABLE`: a call on a connection after `close()`. */
|
|
38
|
+
connectionClosed: 'sqlite-connection-closed',
|
|
39
|
+
/** `INTERNAL`: the host refused to close the connection. */
|
|
40
|
+
closeFailed: 'sqlite-close-failed'
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* What a failed statement hit, as a fixed word the host reads from SQLite's
|
|
44
|
+
* result code and text: owners branch on it (a missing table is an empty
|
|
45
|
+
* store, a unique collision a lost race) without SQLite's text — which quotes
|
|
46
|
+
* the statement's literals and names — ever reaching a message. Carried as
|
|
47
|
+
* `details.condition` on `sqlite-statement-failed`.
|
|
48
|
+
*/
|
|
49
|
+
export const SQLITE_FAILURE_CONDITIONS = [
|
|
50
|
+
'unique-constraint',
|
|
51
|
+
'missing-table',
|
|
52
|
+
'missing-column',
|
|
53
|
+
'already-exists',
|
|
54
|
+
'syntax-error'
|
|
55
|
+
];
|
|
56
|
+
const SqliteFailureDetailsSchema = z.object({ condition: z.enum(SQLITE_FAILURE_CONDITIONS) });
|
|
57
|
+
/** How many `cause` links {@link sqliteFailureCondition} follows to find the driver's refusal. */
|
|
58
|
+
const CAUSE_DEPTH_LIMIT = 8;
|
|
59
|
+
/**
|
|
60
|
+
* The condition a driver's `sqlite-statement-failed` refusal carries, found on
|
|
61
|
+
* `failure` or along its `cause` chain (an owner may wrap it), or `undefined`.
|
|
62
|
+
* It reads only the typed refusal, never a host error's text.
|
|
63
|
+
*/
|
|
64
|
+
export function sqliteFailureCondition(failure) {
|
|
65
|
+
let current = failure;
|
|
66
|
+
for (let depth = 0; depth < CAUSE_DEPTH_LIMIT && current instanceof Error; depth++) {
|
|
67
|
+
if (current instanceof CapabilityError && current.reason === SQLITE_DRIVER_REFUSALS.statementFailed) {
|
|
68
|
+
return SqliteFailureDetailsSchema.safeParse(current.details).data?.condition;
|
|
69
|
+
}
|
|
70
|
+
current = current.cause;
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
/** A driver descriptor: which host implements it. */
|
|
75
|
+
export const SqliteDriverDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
76
|
+
kind: z.literal(LOCALDB_SQLITE_DRIVER_KIND),
|
|
77
|
+
host: z.string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, 'a host label is a kebab-case id')
|
|
78
|
+
});
|
|
79
|
+
/** The contract's shape: a host label and an `open` function. */
|
|
80
|
+
const SqliteDriverMembersSchema = z.object({
|
|
81
|
+
host: z.string().min(1),
|
|
82
|
+
open: z.custom((open) => open instanceof Function)
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Whether an implementation a loader produced honors the driver contract's
|
|
86
|
+
* shape: a non-empty host label and an `open` function. A getter or Proxy
|
|
87
|
+
* trap that throws while it is read propagates to the resolving call, which
|
|
88
|
+
* rejects; it is never answered as a driver.
|
|
89
|
+
*/
|
|
90
|
+
export function isSqliteDriver(implementation) {
|
|
91
|
+
return SqliteDriverMembersSchema.safeParse(implementation).success;
|
|
92
|
+
}
|
|
93
|
+
/** The kind LocalDB registers; a loader whose implementation is not a driver is refused `implementation-invalid`. */
|
|
94
|
+
export const sqliteDriverKind = createRuntimeKind({
|
|
95
|
+
id: LOCALDB_SQLITE_DRIVER_KIND,
|
|
96
|
+
descriptorSchema: SqliteDriverDescriptorSchema,
|
|
97
|
+
validateImplementation: isSqliteDriver
|
|
98
|
+
});
|
|
99
|
+
/** Whether `error` is a driver's `sqlite-busy` refusal: the only startup failure LocalDB retries. */
|
|
100
|
+
export function isSqliteBusy(failure) {
|
|
101
|
+
return isCapabilityError(failure) && failure.reason === SQLITE_DRIVER_REFUSALS.busy;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=sqlite-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-driver.js","sourceRoot":"","sources":["../../src/driver/sqlite-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAEjB,uBAAuB,EAEvB,MAAM,qBAAqB,CAAC;AAE7B,qDAAqD;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAElE,+HAA+H;AAC/H,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,8GAA8G;IAC9G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AAqD;AACrD,MAAM,CAAC,MAAM,4BAA4B,GAAG,uBAAuB,CAAC,MAAM,CAAC;IAC1E,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iCAAiC,EAAE,iCAAiC,CAAC;CAC5F,CAAC,CAAC;AAIH,iEAAiE;AACjE,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAuB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,QAAQ,CAAC;CACxE,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,cAA4B;IAC1D,OAAO,yBAAyB,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC;AACpE,CAAC;AAED,qHAAqH;AACrH,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAkC;IAClF,EAAE,EAAE,0BAA0B;IAC9B,gBAAgB,EAAE,4BAA4B;IAC9C,sBAAsB,EAAE,cAAc;CACtC,CAAC,CAAC;AAEH,qGAAqG;AACrG,MAAM,UAAU,YAAY,CAAC,OAAsB;IAClD,OAAO,iBAAiB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,sBAAsB,CAAC,IAAI,CAAC;AACrF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
* Unified SQLite database management for vibes dev toolkit.
|
|
5
5
|
* Provides connection pooling, migration management, and consistent configuration.
|
|
6
6
|
*/
|
|
7
|
-
export type { LocaldbApi, LocaldbRawDatabase, LocalDatabase as LocalDatabaseInterface, Migration, MigrationFunction, ConnectionStats, ConnectionPoolApi, MigrationRegistryApi } from './schemas/api';
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
7
|
+
export type { LocaldbApi, LocaldbRawDatabase, LocalDatabase as LocalDatabaseInterface, Migration, MigrationDescriptor, MigrationFunction, NamespaceDatabaseLocation, ConnectionStats, ConnectionPoolApi, MigrationRegistryApi } from './schemas/api.ts';
|
|
8
|
+
export type { SqliteBinding, SqliteConnection, SqliteRow, SqliteRunResult, SqliteStatement, SqliteTransactionOptions, SqliteValue } from './driver/sqlite-driver.ts';
|
|
9
|
+
export { LocalDatabase, localdb, disposeLocalDatabaseConnections } from './core/database.ts';
|
|
10
|
+
export { fileSystemOf, sqliteDriverOf } from './core/host-kinds.ts';
|
|
11
|
+
export { LOCALDB_POOL_KIND, poolKind } from './core/connection-pool.ts';
|
|
12
|
+
export type { WalCheckpointTrigger } from './core/connection-pool.ts';
|
|
13
|
+
export { WAL_JOURNAL_SIZE_LIMIT_BYTES, WAL_MAINTENANCE_INTERVAL_MS, MAX_TRANSACTION_AGE_MS, checkpointWal, localDatabasePragmaStatements, type WalCheckpointOutcome, type WalCheckpointStatus } from './core/wal-policy.ts';
|
|
14
|
+
export { migrationRegistry, migrationKind, MIGRATION_KIND, isMigrationNamespaceRegistered, MIGRATION_NAMESPACE_REGISTERED } from './core/migration-registry.ts';
|
|
15
|
+
export { loadMigrationSQL, listMigrationFiles, parseVersionFromFilename, parseMigrationName } from './migrations/load-sql.ts';
|
|
16
|
+
export { connectionPool } from './core/pool-api.ts';
|
|
17
|
+
export { PoolDescriptorSchema, type PoolDescriptor } from './schemas/pool.ts';
|
|
12
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACX,UAAU,EACV,kBAAkB,EAClB,aAAa,IAAI,sBAAsB,EACvC,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACX,UAAU,EACV,kBAAkB,EAClB,aAAa,IAAI,sBAAsB,EACvC,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACX,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,eAAe,EACf,wBAAwB,EACxB,WAAW,EACX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,aAAa,EACb,OAAO,EACP,+BAA+B,EAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACN,iBAAiB,EACjB,QAAQ,EACR,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACN,4BAA4B,EAC5B,2BAA2B,EAC3B,sBAAsB,EACtB,aAAa,EACb,6BAA6B,EAC7B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,8BAA8B,EAC9B,8BAA8B,EAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
* Unified SQLite database management for vibes dev toolkit.
|
|
5
5
|
* Provides connection pooling, migration management, and consistent configuration.
|
|
6
6
|
*/
|
|
7
|
-
export { LocalDatabase, localdb } from
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
7
|
+
export { LocalDatabase, localdb, disposeLocalDatabaseConnections } from "./core/database.js";
|
|
8
|
+
export { fileSystemOf, sqliteDriverOf } from "./core/host-kinds.js";
|
|
9
|
+
export { LOCALDB_POOL_KIND, poolKind } from "./core/connection-pool.js";
|
|
10
|
+
export { WAL_JOURNAL_SIZE_LIMIT_BYTES, WAL_MAINTENANCE_INTERVAL_MS, MAX_TRANSACTION_AGE_MS, checkpointWal, localDatabasePragmaStatements } from "./core/wal-policy.js";
|
|
11
|
+
export { migrationRegistry, migrationKind, MIGRATION_KIND, isMigrationNamespaceRegistered, MIGRATION_NAMESPACE_REGISTERED } from "./core/migration-registry.js";
|
|
12
|
+
export { loadMigrationSQL, listMigrationFiles, parseVersionFromFilename, parseMigrationName } from "./migrations/load-sql.js";
|
|
13
|
+
export { connectionPool } from "./core/pool-api.js";
|
|
14
|
+
export { PoolDescriptorSchema } from "./schemas/pool.js";
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH,OAAO,EACN,aAAa,EACb,OAAO,EACP,+BAA+B,EAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACN,iBAAiB,EACjB,QAAQ,EACR,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,4BAA4B,EAC5B,2BAA2B,EAC3B,sBAAsB,EACtB,aAAa,EACb,6BAA6B,EAG7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,8BAA8B,EAC9B,8BAA8B,EAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAuB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LocalDB Runtime Client Descriptor
|
|
3
|
+
*
|
|
4
|
+
* The runtime-owned logical owner of LocalDB access. Pure data: the
|
|
5
|
+
* implementation loads lazily through `src/localdb.client.impl.consumer.ts`.
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntimeClientDescriptor } from '@vibesdotdev/kernel/client';
|
|
8
|
+
declare const descriptor: RuntimeClientDescriptor;
|
|
9
|
+
export default descriptor;
|
|
10
|
+
//# sourceMappingURL=localdb.client.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localdb.client.descriptor.d.ts","sourceRoot":"","sources":["../src/localdb.client.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,QAAA,MAAM,UAAU,EAAE,uBAIjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LocalDB Runtime Client Descriptor
|
|
3
|
+
*
|
|
4
|
+
* The runtime-owned logical owner of LocalDB access. Pure data: the
|
|
5
|
+
* implementation loads lazily through `src/localdb.client.impl.consumer.ts`.
|
|
6
|
+
*/
|
|
7
|
+
const descriptor = {
|
|
8
|
+
kind: 'runtime/client',
|
|
9
|
+
id: 'localdb',
|
|
10
|
+
description: 'Runtime-owned logical LocalDB access — migrations, connections, status'
|
|
11
|
+
};
|
|
12
|
+
export default descriptor;
|
|
13
|
+
//# sourceMappingURL=localdb.client.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localdb.client.descriptor.js","sourceRoot":"","sources":["../src/localdb.client.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,UAAU,GAA4B;IAC3C,IAAI,EAAE,gBAAgB;IACtB,EAAE,EAAE,SAAS;IACb,WAAW,EAAE,wEAAwE;CACrF,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LocalDB Runtime Client Implementation (Consumer)
|
|
3
|
+
*
|
|
4
|
+
* The kernel instantiates this per runtime through the `runtime/client`
|
|
5
|
+
* `localdb` descriptor; callers resolve it with `getVibesClient` (async) or
|
|
6
|
+
* `tryGetVibesClient` (synchronously, once activation warmed the cache), or
|
|
7
|
+
* through the `dev/localdb` context which resolves to this same instance.
|
|
8
|
+
*/
|
|
9
|
+
import { LocalDBManager } from './core/database.ts';
|
|
10
|
+
export default LocalDBManager;
|
|
11
|
+
//# sourceMappingURL=localdb.client.impl.consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localdb.client.impl.consumer.d.ts","sourceRoot":"","sources":["../src/localdb.client.impl.consumer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LocalDB Runtime Client Implementation (Consumer)
|
|
3
|
+
*
|
|
4
|
+
* The kernel instantiates this per runtime through the `runtime/client`
|
|
5
|
+
* `localdb` descriptor; callers resolve it with `getVibesClient` (async) or
|
|
6
|
+
* `tryGetVibesClient` (synchronously, once activation warmed the cache), or
|
|
7
|
+
* through the `dev/localdb` context which resolves to this same instance.
|
|
8
|
+
*/
|
|
9
|
+
import { LocalDBManager } from "./core/database.js";
|
|
10
|
+
export default LocalDBManager;
|
|
11
|
+
//# sourceMappingURL=localdb.client.impl.consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localdb.client.impl.consumer.js","sourceRoot":"","sources":["../src/localdb.client.impl.consumer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAe,cAAc,CAAC"}
|
package/dist/localdb.plugin.d.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Local SQLite database management — migrations, connections, status.
|
|
5
5
|
*/
|
|
6
|
-
declare const
|
|
7
|
-
export default
|
|
6
|
+
declare const defaultExport: import("@vibesdotdev/kernel").RuntimePlugin;
|
|
7
|
+
export default defaultExport;
|
|
8
8
|
//# sourceMappingURL=localdb.plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localdb.plugin.d.ts","sourceRoot":"","sources":["../src/localdb.plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"localdb.plugin.d.ts","sourceRoot":"","sources":["../src/localdb.plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkCH,QAAA,MAAM,aAAa,6CA2DjB,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
package/dist/localdb.plugin.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Local SQLite database management — migrations, connections, status.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { migrationKind, MIGRATION_KIND } from "./core/migration-registry.js";
|
|
7
|
+
import { createRuntimePlugin, loader } from '@vibesdotdev/kernel';
|
|
8
|
+
import { getVibesClient } from '@vibesdotdev/kernel/client';
|
|
7
9
|
// CLI
|
|
8
10
|
import localdbGroup from "./dev.localdb.cli-group.descriptor.js";
|
|
9
11
|
import localdbMigrate from "./cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.js";
|
|
@@ -13,10 +15,21 @@ import localdbQuery from "./cli/commands/query/dev.localdb.query.cli-command.des
|
|
|
13
15
|
import localdbStatus from "./cli/commands/status/dev.localdb.status.cli-command.descriptor.js";
|
|
14
16
|
// Context
|
|
15
17
|
import localdbContextDescriptor from "./dev.localdb.context.descriptor.js";
|
|
16
|
-
|
|
18
|
+
// Runtime-owned logical owner (resolved through the kernel, warmed on activation)
|
|
19
|
+
import localdbClientDescriptor from "./localdb.client.descriptor.js";
|
|
20
|
+
import { clearDirectPluginDisposal, markDirectPluginDisposal } from "./core/database.js";
|
|
21
|
+
// The SQLite driver kind the hosts implement (SPEC "SQLite driver kind")
|
|
22
|
+
import { LOCALDB_SQLITE_DRIVER_KIND, sqliteDriverKind } from "./driver/sqlite-driver.js";
|
|
23
|
+
// The physical pool kind (SPEC "Connection pool"): the plugin registers the
|
|
24
|
+
// kind and a runtime-owned default pool, so single-runtime processes share one
|
|
25
|
+
// connection per path with no further composition.
|
|
26
|
+
import { ensureDefaultPool } from "./core/connection-pool.js";
|
|
27
|
+
// Hoisted const: tsc rewriteRelativeImportExtensions does not rewrite `.ts` specifiers inside `export default <expr>` (TS 6.0.3).
|
|
28
|
+
const defaultExport = createRuntimePlugin({
|
|
17
29
|
id: 'localdb',
|
|
18
30
|
name: 'LocalDB',
|
|
19
31
|
description: 'Local SQLite database management — migrations, connections, status',
|
|
32
|
+
optionalDependencies: ['logging'],
|
|
20
33
|
descriptors: [
|
|
21
34
|
localdbGroup,
|
|
22
35
|
localdbMigrate,
|
|
@@ -24,15 +37,50 @@ export default createRuntimePlugin({
|
|
|
24
37
|
localdbPools,
|
|
25
38
|
localdbQuery,
|
|
26
39
|
localdbStatus,
|
|
27
|
-
localdbContextDescriptor
|
|
40
|
+
localdbContextDescriptor,
|
|
41
|
+
localdbClientDescriptor
|
|
28
42
|
],
|
|
29
43
|
loaders: [
|
|
30
|
-
loader('dev.localdb.migrate', 'consumer', () => import(
|
|
31
|
-
loader('dev.localdb.namespaces', () => import(
|
|
32
|
-
loader('dev.localdb.pools', () => import(
|
|
33
|
-
loader('dev.localdb.query', 'consumer', () => import(
|
|
34
|
-
loader('dev.localdb.status', 'consumer', () => import(
|
|
35
|
-
loader('dev/localdb', 'consumer', () => import(
|
|
36
|
-
|
|
44
|
+
loader('dev.localdb.migrate', 'consumer', () => import("./cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.js")),
|
|
45
|
+
loader('dev.localdb.namespaces', () => import("./cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.js")),
|
|
46
|
+
loader('dev.localdb.pools', () => import("./cli/commands/pools/dev.localdb.pools.cli-command.impl.js")),
|
|
47
|
+
loader('dev.localdb.query', 'consumer', () => import("./cli/commands/query/dev.localdb.query.cli-command.impl.consumer.js")),
|
|
48
|
+
loader('dev.localdb.status', 'consumer', () => import("./cli/commands/status/dev.localdb.status.cli-command.impl.consumer.js")),
|
|
49
|
+
loader('dev/localdb', 'consumer', () => import("./dev.localdb.context.impl.consumer.js")),
|
|
50
|
+
loader('localdb', 'consumer', () => import("./localdb.client.impl.consumer.js"))
|
|
51
|
+
],
|
|
52
|
+
// The host environment registers the driver kind with its driver; a runtime
|
|
53
|
+
// composed without one still gets the kind, and resolving it then refuses typed.
|
|
54
|
+
onRegister(runtime) {
|
|
55
|
+
if (!runtime.hasKind(MIGRATION_KIND))
|
|
56
|
+
runtime.registerKind(migrationKind);
|
|
57
|
+
if (!runtime.hasKind(LOCALDB_SQLITE_DRIVER_KIND))
|
|
58
|
+
runtime.registerKind(sqliteDriverKind);
|
|
59
|
+
ensureDefaultPool(runtime);
|
|
60
|
+
markDirectPluginDisposal(runtime);
|
|
61
|
+
},
|
|
62
|
+
// Warm the runtime-owned client and its physical pool, so synchronous
|
|
63
|
+
// callers can use `tryGetVibesClient('localdb', runtime)` and pool
|
|
64
|
+
// statistics right after activation.
|
|
65
|
+
onActivate: async (runtime) => {
|
|
66
|
+
const client = await getVibesClient('localdb', runtime);
|
|
67
|
+
await client.ensurePool();
|
|
68
|
+
},
|
|
69
|
+
// Each connection's WAL maintenance tick (D-WAL) runs on the lifecycle of a
|
|
70
|
+
// persistent runtime that holds it and ends with that runtime; finite hosts
|
|
71
|
+
// checkpoint on release and close instead. Disposal gives back what the
|
|
72
|
+
// disposing runtime holds, reported on it. A reload retiring this plugin from a
|
|
73
|
+
// runtime that lives on disposes it on a live lifecycle (and never again): the
|
|
74
|
+
// release then runs as that lifecycle's own work at the runtime's disposal.
|
|
75
|
+
async onDispose(runtime) {
|
|
76
|
+
clearDirectPluginDisposal(runtime);
|
|
77
|
+
const { releaseAtDisposal, localdb } = await import("./core/database.js");
|
|
78
|
+
if (runtime.lifecycle.phase === 'live') {
|
|
79
|
+
releaseAtDisposal(runtime, localdb);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
await localdb.closeAll(runtime);
|
|
83
|
+
}
|
|
37
84
|
});
|
|
85
|
+
export default defaultExport;
|
|
38
86
|
//# sourceMappingURL=localdb.plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localdb.plugin.js","sourceRoot":"","sources":["../src/localdb.plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"localdb.plugin.js","sourceRoot":"","sources":["../src/localdb.plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClE,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AAC,KAAK,KAAK,MAAM,EAAE,CAAC;YACxC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACpC,OAAO;QACR,CAAC;QACD,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACD,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RuntimeRef } from '@vibesdotdev/kernel';
|
|
2
|
+
import { type NamespaceDatabaseLocation } from './core/migration-registry.ts';
|
|
3
|
+
export type { NamespaceDatabaseLocation };
|
|
4
|
+
/** Resolve a namespace's owner-declared database location without guessing. */
|
|
5
|
+
export declare function resolveDatabaseLocationForNamespace(runtime: RuntimeRef, namespace: string): NamespaceDatabaseLocation | undefined;
|
|
6
|
+
//# sourceMappingURL=location.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../src/location.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAqB,KAAK,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEjG,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAE1C,+EAA+E;AAC/E,wBAAgB,mCAAmC,CAClD,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,MAAM,GACf,yBAAyB,GAAG,SAAS,CAEvC"}
|
package/dist/location.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { migrationRegistry } from "./core/migration-registry.js";
|
|
2
|
+
/** Resolve a namespace's owner-declared database location without guessing. */
|
|
3
|
+
export function resolveDatabaseLocationForNamespace(runtime, namespace) {
|
|
4
|
+
return migrationRegistry.getNamespaceLocation(runtime, namespace);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.js","sourceRoot":"","sources":["../src/location.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAkC,MAAM,8BAA8B,CAAC;AAIjG,+EAA+E;AAC/E,MAAM,UAAU,mCAAmC,CAClD,OAAmB,EACnB,SAAiB;IAEjB,OAAO,iBAAiB,CAAC,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -1,45 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SQL Migration Loader
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Reads an owner's migration SQL files from the absolute directory the owner
|
|
5
|
+
* passes (PM and Workspace pass their own `migrations/<namespace>` directory),
|
|
6
|
+
* through the runtime's filesystem (`filesystem/adapter`). LocalDB ships no SQL
|
|
7
|
+
* of its own, so there is no package-relative lookup.
|
|
6
8
|
*/
|
|
9
|
+
import { type RuntimeRef } from '@vibesdotdev/kernel';
|
|
7
10
|
/**
|
|
8
|
-
* Load a SQL migration file
|
|
11
|
+
* Load a SQL migration file from an owner's migration directory, through the
|
|
12
|
+
* runtime's filesystem.
|
|
9
13
|
*
|
|
10
|
-
* @param
|
|
14
|
+
* @param runtime - The runtime the owner was handed
|
|
15
|
+
* @param directory - The owner's absolute migration directory
|
|
11
16
|
* @param filename - The SQL filename (e.g., '001-initial-schema.sql')
|
|
12
|
-
* @returns
|
|
17
|
+
* @returns The SQL content; every failure rejects (`INVALID_INPUT
|
|
18
|
+
* migration-directory-relative`, `NOT_FOUND migration-file-missing`, or the
|
|
19
|
+
* filesystem's own refusal)
|
|
13
20
|
*/
|
|
14
|
-
export declare function loadMigrationSQL(
|
|
21
|
+
export declare function loadMigrationSQL(runtime: RuntimeRef, directory: string, filename: string): Promise<string>;
|
|
15
22
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
23
|
+
* List the SQL files in an owner's migration directory, sorted by version,
|
|
24
|
+
* through the runtime's filesystem. A directory that does not exist lists
|
|
25
|
+
* nothing.
|
|
18
26
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
export declare function loadMigrationSQLSync(namespace: string, filename: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* List all SQL files in a namespace directory
|
|
26
|
-
*
|
|
27
|
-
* @param namespace - The migration namespace (atlas, session, external)
|
|
28
|
-
* @returns Array of SQL filenames sorted by version number
|
|
27
|
+
* @param runtime - The runtime the owner was handed
|
|
28
|
+
* @param directory - The owner's absolute migration directory
|
|
29
|
+
* @returns SQL filenames sorted by their numeric version prefix
|
|
29
30
|
*/
|
|
30
|
-
export declare function listMigrationFiles(
|
|
31
|
+
export declare function listMigrationFiles(runtime: RuntimeRef, directory: string): Promise<string[]>;
|
|
31
32
|
/**
|
|
32
33
|
* Parse version number from a migration filename
|
|
33
34
|
*
|
|
34
35
|
* @param filename - The SQL filename (e.g., '001-initial-schema.sql')
|
|
35
|
-
* @returns The version number
|
|
36
|
+
* @returns The version number; a filename without a leading `<digits>-`, or
|
|
37
|
+
* whose version is not a safe integer, refuses `INVALID_INPUT
|
|
38
|
+
* migration-filename-invalid`
|
|
36
39
|
*/
|
|
37
40
|
export declare function parseVersionFromFilename(filename: string): number;
|
|
38
41
|
/**
|
|
39
42
|
* Parse migration name from a filename
|
|
40
43
|
*
|
|
41
44
|
* @param filename - The SQL filename (e.g., '001-initial-schema.sql')
|
|
42
|
-
* @returns The migration name (e.g., 'initial_schema')
|
|
45
|
+
* @returns The migration name (e.g., 'initial_schema'); a filename that is not
|
|
46
|
+
* a string refuses `INVALID_INPUT migration-filename-invalid`
|
|
43
47
|
*/
|
|
44
48
|
export declare function parseMigrationName(filename: string): string;
|
|
45
49
|
//# sourceMappingURL=load-sql.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-sql.d.ts","sourceRoot":"","sources":["../../src/migrations/load-sql.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"load-sql.d.ts","sourceRoot":"","sources":["../../src/migrations/load-sql.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAkBvE;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUhH;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAWlG;AAuCD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO3D"}
|