@vibesdotdev/localdb 0.0.1 → 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 +134 -112
- 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 +79 -106
- package/SPEC.md +0 -119
- 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
package/package.json
CHANGED
|
@@ -1,146 +1,119 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibesdotdev/localdb",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@vibesdotdev/filesystem": "^1.0.0-rc.2",
|
|
6
|
+
"zod": "^4.6.7"
|
|
7
|
+
},
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"@vibesdotdev/logging": "^1.0.0-rc.3",
|
|
10
|
+
"@vibesdotdev/kernel": "^1.0.0-rc.5"
|
|
11
|
+
},
|
|
5
12
|
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
13
|
"exports": {
|
|
8
14
|
".": {
|
|
15
|
+
"bun": "./dist/index.js",
|
|
9
16
|
"types": "./dist/index.d.ts",
|
|
10
|
-
"bun": "./src/index.ts",
|
|
11
17
|
"import": "./dist/index.js",
|
|
12
18
|
"default": "./dist/index.js"
|
|
13
19
|
},
|
|
14
20
|
"./plugin": {
|
|
21
|
+
"bun": "./dist/localdb.plugin.js",
|
|
15
22
|
"types": "./dist/localdb.plugin.d.ts",
|
|
16
|
-
"bun": "./src/localdb.plugin.ts",
|
|
17
23
|
"import": "./dist/localdb.plugin.js",
|
|
18
24
|
"default": "./dist/localdb.plugin.js"
|
|
19
25
|
},
|
|
20
|
-
"./cloud.plugin": {
|
|
21
|
-
"types": "./dist/localdb.cloud.plugin.d.ts",
|
|
22
|
-
"bun": "./src/localdb.cloud.plugin.ts",
|
|
23
|
-
"import": "./dist/localdb.cloud.plugin.js",
|
|
24
|
-
"default": "./dist/localdb.cloud.plugin.js"
|
|
25
|
-
},
|
|
26
26
|
"./schemas": {
|
|
27
|
+
"bun": "./dist/schemas/api.js",
|
|
27
28
|
"types": "./dist/schemas/api.d.ts",
|
|
28
|
-
"bun": "./src/schemas/api.ts",
|
|
29
29
|
"import": "./dist/schemas/api.js",
|
|
30
30
|
"default": "./dist/schemas/api.js"
|
|
31
31
|
},
|
|
32
32
|
"./migrations/load-sql": {
|
|
33
|
+
"bun": "./dist/migrations/load-sql.js",
|
|
33
34
|
"types": "./dist/migrations/load-sql.d.ts",
|
|
34
|
-
"bun": "./src/migrations/load-sql.ts",
|
|
35
35
|
"import": "./dist/migrations/load-sql.js",
|
|
36
36
|
"default": "./dist/migrations/load-sql.js"
|
|
37
37
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"import": "./dist
|
|
42
|
-
"default": "./dist
|
|
43
|
-
},
|
|
44
|
-
"./*.js": {
|
|
45
|
-
"types": "./dist/*.d.ts",
|
|
46
|
-
"bun": "./src/*.ts",
|
|
47
|
-
"import": "./dist/*.js",
|
|
48
|
-
"default": "./dist/*.js"
|
|
49
|
-
},
|
|
50
|
-
"./*/*": {
|
|
51
|
-
"types": "./dist/*/*.d.ts",
|
|
52
|
-
"bun": "./src/*/*.ts",
|
|
53
|
-
"import": "./dist/*/*.js",
|
|
54
|
-
"default": "./dist/*/*.js"
|
|
38
|
+
"./wal-policy": {
|
|
39
|
+
"bun": "./dist/core/wal-policy.js",
|
|
40
|
+
"types": "./dist/core/wal-policy.d.ts",
|
|
41
|
+
"import": "./dist/core/wal-policy.js",
|
|
42
|
+
"default": "./dist/core/wal-policy.js"
|
|
55
43
|
},
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"import": "./dist
|
|
60
|
-
"default": "./dist
|
|
44
|
+
"./location": {
|
|
45
|
+
"bun": "./dist/location.js",
|
|
46
|
+
"types": "./dist/location.d.ts",
|
|
47
|
+
"import": "./dist/location.js",
|
|
48
|
+
"default": "./dist/location.js"
|
|
61
49
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"import": "./dist
|
|
66
|
-
"default": "./dist
|
|
50
|
+
"./sqlite-driver": {
|
|
51
|
+
"bun": "./dist/driver/sqlite-driver.js",
|
|
52
|
+
"types": "./dist/driver/sqlite-driver.d.ts",
|
|
53
|
+
"import": "./dist/driver/sqlite-driver.js",
|
|
54
|
+
"default": "./dist/driver/sqlite-driver.js"
|
|
67
55
|
},
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"import": "./dist
|
|
72
|
-
"default": "./dist
|
|
56
|
+
"./sqlite-driver/base": {
|
|
57
|
+
"bun": "./dist/driver/sqlite-driver.base.js",
|
|
58
|
+
"types": "./dist/driver/sqlite-driver.base.d.ts",
|
|
59
|
+
"import": "./dist/driver/sqlite-driver.base.js",
|
|
60
|
+
"default": "./dist/driver/sqlite-driver.base.js"
|
|
73
61
|
},
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"import": "./dist
|
|
78
|
-
"default": "./dist
|
|
62
|
+
"./test-tooling/sqlite-driver-conformance": {
|
|
63
|
+
"bun": "./dist/testing/sqlite-driver-conformance.js",
|
|
64
|
+
"types": "./dist/testing/sqlite-driver-conformance.d.ts",
|
|
65
|
+
"import": "./dist/testing/sqlite-driver-conformance.js",
|
|
66
|
+
"default": "./dist/testing/sqlite-driver-conformance.js"
|
|
79
67
|
},
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"import": "./dist
|
|
84
|
-
"default": "./dist
|
|
85
|
-
},
|
|
86
|
-
"./*/*/*/*/*": {
|
|
87
|
-
"types": "./dist/*/*/*/*/*.d.ts",
|
|
88
|
-
"bun": "./src/*/*/*/*/*.ts",
|
|
89
|
-
"import": "./dist/*/*/*/*/*.js",
|
|
90
|
-
"default": "./dist/*/*/*/*/*.js"
|
|
91
|
-
},
|
|
92
|
-
"./*/*/*/*/*.js": {
|
|
93
|
-
"types": "./dist/*/*/*/*/*.d.ts",
|
|
94
|
-
"bun": "./src/*/*/*/*/*.ts",
|
|
95
|
-
"import": "./dist/*/*/*/*/*.js",
|
|
96
|
-
"default": "./dist/*/*/*/*/*.js"
|
|
68
|
+
"./pool": {
|
|
69
|
+
"bun": "./dist/pool.js",
|
|
70
|
+
"types": "./dist/pool.d.ts",
|
|
71
|
+
"import": "./dist/pool.js",
|
|
72
|
+
"default": "./dist/pool.js"
|
|
97
73
|
}
|
|
98
74
|
},
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
75
|
+
"files": [
|
|
76
|
+
"dist",
|
|
77
|
+
"README.md",
|
|
78
|
+
"LICENSE"
|
|
79
|
+
],
|
|
80
|
+
"scripts": {
|
|
81
|
+
"lint": "node ../node_modules/@vibesdotdev/internal-oxlint-toolchain/ratchet.mjs .",
|
|
82
|
+
"test": "bun test && bun run test:contention && bun run test:node",
|
|
83
|
+
"test:node": "rm -rf .cache/node-run && bun build --target=node --conditions=bun --splitting --format=esm --outdir .cache/node-run/bundle src/__tests__/node-run/localdb.node-run.ts && node --test .cache/node-run/bundle/localdb.node-run.js",
|
|
84
|
+
"check": "bun --bun tsc -p tsconfig.json",
|
|
85
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
86
|
+
"test:contention": "bun test ./src/__tests__/startup-contention.integration.ts"
|
|
102
87
|
},
|
|
103
88
|
"repository": {
|
|
104
89
|
"type": "git",
|
|
105
|
-
"url": "git
|
|
106
|
-
"directory": "
|
|
90
|
+
"url": "ssh://git@git.vibes.dev/vibesdotdev/framework.git",
|
|
91
|
+
"directory": "localdb"
|
|
107
92
|
},
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"@vibesdotdev/cli": "0.0.1"
|
|
93
|
+
"publishConfig": {
|
|
94
|
+
"registry": "https://packages.vibes.dev",
|
|
95
|
+
"access": "public"
|
|
112
96
|
},
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
|
|
97
|
+
"vibes": {
|
|
98
|
+
"visibility": "public",
|
|
99
|
+
"registry": {
|
|
100
|
+
"repositoryId": "4b1374d4-6830-4bfd-98e3-de66416368a8",
|
|
101
|
+
"directory": "localdb"
|
|
102
|
+
},
|
|
103
|
+
"handedRuntimeLogging": true
|
|
117
104
|
},
|
|
105
|
+
"type": "module",
|
|
106
|
+
"types": "./dist/index.d.ts",
|
|
118
107
|
"license": "MIT",
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"!src/**/*.test.tsx",
|
|
130
|
-
"!src/**/*.spec.ts",
|
|
131
|
-
"!src/**/*.spec.tsx",
|
|
132
|
-
"!dist/**/__tests__/**",
|
|
133
|
-
"!dist/**/__stubs__/**",
|
|
134
|
-
"!dist/**/*.test.js",
|
|
135
|
-
"!dist/**/*.test.js.map",
|
|
136
|
-
"!dist/**/*.test.d.ts",
|
|
137
|
-
"!dist/**/*.test.d.ts.map",
|
|
138
|
-
"!dist/**/*.spec.js",
|
|
139
|
-
"!dist/**/*.spec.js.map",
|
|
140
|
-
"!dist/**/*.spec.d.ts",
|
|
141
|
-
"!dist/**/*.spec.d.ts.map"
|
|
142
|
-
],
|
|
143
|
-
"vibes": {
|
|
144
|
-
"visibility": "public-framework"
|
|
108
|
+
"description": "Local SQLite storage helpers and migration utilities for Vibes development surfaces.",
|
|
109
|
+
"homepage": "https://docs.vibes.dev/localdb",
|
|
110
|
+
"bugs": {
|
|
111
|
+
"url": "https://docs.vibes.dev/localdb#support"
|
|
112
|
+
},
|
|
113
|
+
"gitHead": "51230ebdad54bc405014633f435b499fa2a06b89",
|
|
114
|
+
"_vibes_source": {
|
|
115
|
+
"repo": "ssh://git@git.vibes.dev/vibesdotdev/framework.git",
|
|
116
|
+
"sha": "51230ebdad54bc405014633f435b499fa2a06b89",
|
|
117
|
+
"workspaceDigest": "sha256:a238deb4a7000e7e51353eaa5b0088fd048ca160459aef60ae36f2d2f3b4c1d6"
|
|
145
118
|
}
|
|
146
119
|
}
|
package/SPEC.md
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# @vibesdotdev/localdb
|
|
2
|
-
|
|
3
|
-
Local SQLite primitive for the vibes consumer-hardware toolkit. Owns the
|
|
4
|
-
connection pool (one `bun:sqlite` `Database` per file path, WAL mode, busy
|
|
5
|
-
timeout, ref-counted, idle-cleanup), the namespace migration registry
|
|
6
|
-
(sequential-version enforcement, legacy `PRAGMA user_version` bootstrap,
|
|
7
|
-
`vibes_schema_versions` tracking table), the recovery/trapdoor flow (backup →
|
|
8
|
-
delete → recreate → re-migrate on migration failure or version mismatch), and
|
|
9
|
-
the `vibes dev localdb` CLI surface. Consumer hardware only — `bun:sqlite` is
|
|
10
|
-
server-runtime only. The storage adapter that wraps localdb lives in a sibling
|
|
11
|
-
adapter package, not here.
|
|
12
|
-
|
|
13
|
-
## Owns
|
|
14
|
-
|
|
15
|
-
- **Plugin descriptors registered by the plugin** (`./plugin`):
|
|
16
|
-
- `runtime/context` `dev/localdb` — server-side `LocaldbApi` access for
|
|
17
|
-
runtime callers.
|
|
18
|
-
- `cli/group` `dev.localdb` parented under `dev` — `vibes dev localdb`.
|
|
19
|
-
- `cli/command` `dev.localdb.{status,migrate,namespaces,pools,query}`.
|
|
20
|
-
- **Connection pool** (`./core/connection-pool`): per-path pooled `bun:sqlite`
|
|
21
|
-
`Database`, ref-counting, idle stale-cleanup (30 min), uniform PRAGMAs
|
|
22
|
-
(`journal_mode=WAL`, `busy_timeout=5000`, `foreign_keys=ON`,
|
|
23
|
-
`synchronous=NORMAL`, `temp_store=MEMORY`).
|
|
24
|
-
- **Migration registry** (`./core/migration-registry`): namespace-keyed
|
|
25
|
-
`Migration[]`, sequential `1..N` version enforcement,
|
|
26
|
-
`vibes_schema_versions` tracking, legacy `PRAGMA user_version` one-time
|
|
27
|
-
bootstrap, incompatible-database (version-too-high) detection.
|
|
28
|
-
- **`LocalDatabase` + `localdb` singleton manager** (`./core/database`):
|
|
29
|
-
per-`namespace:path` entry caching with per-`dbPath` async lock,
|
|
30
|
-
recovery/trapdoor on migration failure with retained backups (last 12),
|
|
31
|
-
`getRawDatabase()` for migration-free pooled access, `closeAll()` /
|
|
32
|
-
process-exit cleanup.
|
|
33
|
-
- **Public API types** (`./schemas`): `LocaldbApi`, `LocaldbRawDatabase`,
|
|
34
|
-
`LocaldbStatement`, `Migration`, `MigrationFunction`, `ConnectionStats`,
|
|
35
|
-
`ConnectionPoolApi`, `MigrationRegistryApi`.
|
|
36
|
-
|
|
37
|
-
## Does not own
|
|
38
|
-
|
|
39
|
-
- The `storage/adapter` impl `storage.localdb.core` →
|
|
40
|
-
[`storage-adapter-localdb`](../storage-adapter-localdb/SPEC.md). Per pattern
|
|
41
|
-
1, environment-specific storage adapters live in sibling packages; the
|
|
42
|
-
adapter is a thin `storage` consumer of `localdb`.
|
|
43
|
-
- Domain migration SQL → owning module:
|
|
44
|
-
- `atlas` schema → [`workspace`](../workspace/SPEC.md) (the only registrar,
|
|
45
|
-
via `packages/workspace/src/codegraph/storage/register-migrations.ts`).
|
|
46
|
-
- `pm-state` schema → [`pm`](../pm/SPEC.md) (already lives there; PM passes
|
|
47
|
-
its own dir as an absolute path to `loadMigrationSQLSync`).
|
|
48
|
-
- `external` `file_accesses` → [`external`](../external/SPEC.md) (already
|
|
49
|
-
inline-defined in `packages/external/src/register-migrations.ts`).
|
|
50
|
-
- `config` schema → [`cli`](../cli/SPEC.md) (its app-config storage
|
|
51
|
-
subsystem already declares the namespace).
|
|
52
|
-
- Cross-process / multi-tenant locking, replication, observability of pool
|
|
53
|
-
stats. Out of scope for the consumer-hardware floor; cloud storage uses
|
|
54
|
-
[`storage-adapter-drizzle`](../storage-adapter-drizzle/SPEC.md).
|
|
55
|
-
- A `runtime/client` descriptor or `getVibesLocaldbClient()`. LocalDB is a
|
|
56
|
-
runtime substrate consumed via the `localdb` singleton or the `dev/localdb`
|
|
57
|
-
context, not a domain module.
|
|
58
|
-
|
|
59
|
-
## Hard rules
|
|
60
|
-
|
|
61
|
-
- **`bun:sqlite`, server-runtime only.** All filesystem/SQLite imports are
|
|
62
|
-
dynamic and gated on `isLocaldbServerRuntime()`. `LocalDatabase.initialize()`
|
|
63
|
-
throws in browser bundles.
|
|
64
|
-
- **Sequential migration versions.** Registered migrations form `1..N` with
|
|
65
|
-
no gaps; out-of-sequence registration throws at `register()` time.
|
|
66
|
-
- **Unknown namespace = throw.** `needsMigration` / `runMigrations` /
|
|
67
|
-
`getDatabase` against an unregistered namespace is a hard failure (per
|
|
68
|
-
pattern 4); domain modules call
|
|
69
|
-
`localdb.registerMigrations(namespace, migrations)` before opening their
|
|
70
|
-
database.
|
|
71
|
-
- **Recovery is automatic and lossy.** Migration failure or
|
|
72
|
-
version-higher-than-registered triggers backup (`*.bak-{ts}`, last 12
|
|
73
|
-
retained) → delete file + WAL/SHM artifacts → fresh DB → re-run migrations
|
|
74
|
-
from version 0. Domain code must not rely on data surviving migration
|
|
75
|
-
failure.
|
|
76
|
-
- **One Database per file path.** All access goes through the pool; the
|
|
77
|
-
`usePool: false` direct-connection path stays for special cases but new
|
|
78
|
-
code uses the pool.
|
|
79
|
-
- **No domain SQL in this package.** Migration SQL files for a feature live
|
|
80
|
-
with that feature's package.
|
|
81
|
-
|
|
82
|
-
## Migration debt
|
|
83
|
-
|
|
84
|
-
All items completed in t11-mig-localdb-final-and-seal. See git history for original debt items.
|
|
85
|
-
|
|
86
|
-
## Public entrypoints
|
|
87
|
-
|
|
88
|
-
`.` — root exports (`localdb`, `LocalDatabase`, `Migration`, etc.)
|
|
89
|
-
`./plugin` — LocalDB plugin registration
|
|
90
|
-
`./schemas` — TypeScript type definitions (`LocaldbApi`, `Migration`, etc.)
|
|
91
|
-
|
|
92
|
-
Migration-era subpaths (`./core/*`, `./migrations/*`, `./localdb.plugin`) have been removed.
|
|
93
|
-
|
|
94
|
-
## Verification
|
|
95
|
-
|
|
96
|
-
`bun test` from `packages/localdb`. Covers `MigrationRegistry` (version
|
|
97
|
-
tracking, sequence validation, legacy-bootstrap, incompatible-version
|
|
98
|
-
detection), `ConnectionPool` (pooling, ref-count, stats), `LocalDatabase`
|
|
99
|
-
(init / idempotence / recovery / backup pruning), `localdb` manager
|
|
100
|
-
(namespace caching + per-path lock), and `loadMigrationSQL` file resolution.
|
|
101
|
-
Today (per `PROD-CHECKLIST.md` 2026-04-18): 79 pass / 0 fail.
|
|
102
|
-
|
|
103
|
-
## Links
|
|
104
|
-
|
|
105
|
-
- [storage/SPEC.md](../storage/SPEC.md),
|
|
106
|
-
[storage-adapter-localdb/SPEC.md](../storage-adapter-localdb/SPEC.md),
|
|
107
|
-
[storage-adapter-drizzle/SPEC.md](../storage-adapter-drizzle/SPEC.md),
|
|
108
|
-
[runtime/SPEC.md](../runtime/SPEC.md),
|
|
109
|
-
[cli/SPEC.md](../cli/SPEC.md),
|
|
110
|
-
[logging/SPEC.md](../logging/SPEC.md)
|
|
111
|
-
- Active consumers: [pm](../pm/SPEC.md), [workspace](../workspace/SPEC.md),
|
|
112
|
-
[external](../external/SPEC.md), [cli](../cli/SPEC.md),
|
|
113
|
-
[presence](../presence/SPEC.md), [prompts](../prompts/SPEC.md),
|
|
114
|
-
[experiments](../experiments/SPEC.md), [desktop](../desktop/SPEC.md),
|
|
115
|
-
[browser-automation](../browser-automation/SPEC.md),
|
|
116
|
-
[knowledge](../knowledge/SPEC.md), [setup](../setup/SPEC.md)
|
|
117
|
-
- Doctrine:
|
|
118
|
-
[RUNTIME-FIRST-MODULES.md](../../docs/architecture/RUNTIME-FIRST-MODULES.md),
|
|
119
|
-
[RUNTIME-SCOPE-TOPOLOGY.md](../../docs/architecture/RUNTIME-SCOPE-TOPOLOGY.md)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-context.d.ts","sourceRoot":"","sources":["../../src/core/error-context.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAkBlF"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function toErrorContext(error) {
|
|
2
|
-
if (error instanceof Error) {
|
|
3
|
-
return {
|
|
4
|
-
error: error.message,
|
|
5
|
-
name: error.name,
|
|
6
|
-
stack: error.stack
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
if (typeof error === 'object' && error !== null && !Array.isArray(error)) {
|
|
10
|
-
return error;
|
|
11
|
-
}
|
|
12
|
-
if (error === undefined) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
return { error: String(error) };
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=error-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-context.js","sourceRoot":"","sources":["../../src/core/error-context.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO;YACN,KAAK,EAAE,KAAK,CAAC,OAAO;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SAClB,CAAC;IACH,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,KAAgC,CAAC;IACzC,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACjC,CAAC"}
|
package/dist/core/runtime.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":"AAMA,wBAAgB,uBAAuB,CAAC,KAAK,GAAE,OAAO,UAAuB,GAAG,OAAO,CAMtF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,GAAE,OAAO,UAAuB,GAAG,OAAO,CAErF"}
|
package/dist/core/runtime.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
function hasRuntimeProcessVersion(name) {
|
|
2
|
-
if (typeof process === 'undefined')
|
|
3
|
-
return false;
|
|
4
|
-
const value = process.versions?.[name];
|
|
5
|
-
return typeof value === 'string' && value.length > 0;
|
|
6
|
-
}
|
|
7
|
-
export function isLocaldbBrowserRuntime(scope = globalThis) {
|
|
8
|
-
const globals = scope;
|
|
9
|
-
const hasWindow = typeof globals.window !== 'undefined' && globals.window !== null;
|
|
10
|
-
const hasDocument = typeof globals.document !== 'undefined' && globals.document !== null;
|
|
11
|
-
const hasServerRuntime = hasRuntimeProcessVersion('bun') || hasRuntimeProcessVersion('node');
|
|
12
|
-
return hasDocument || (hasWindow && !hasServerRuntime);
|
|
13
|
-
}
|
|
14
|
-
export function isLocaldbServerRuntime(scope = globalThis) {
|
|
15
|
-
return !isLocaldbBrowserRuntime(scope);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=runtime.js.map
|
package/dist/core/runtime.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":"AAAA,SAAS,wBAAwB,CAAC,IAAoB;IACrD,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,QAA2B,UAAU;IAC5E,MAAM,OAAO,GAAG,KAAoD,CAAC;IACrE,MAAM,SAAS,GAAG,OAAO,OAAO,CAAC,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC;IACnF,MAAM,WAAW,GAAG,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IACzF,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,KAAK,CAAC,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAC7F,OAAO,WAAW,IAAI,CAAC,SAAS,IAAI,CAAC,gBAAgB,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAA2B,UAAU;IAC3E,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LocalDB Cloud Plugin
|
|
3
|
-
*
|
|
4
|
-
* Cloud-bundle-safe variant of `localdb.plugin.ts`.
|
|
5
|
-
*
|
|
6
|
-
* LocalDB manages on-disk SQLite (libsql / better-sqlite3) for consumer
|
|
7
|
-
* environments. Every loader in `localdb.plugin.ts` is `.impl.consumer.ts`
|
|
8
|
-
* and reaches `bun:sqlite` / `node:fs`. None of it is reachable from a
|
|
9
|
-
* cloudflare-workers bundle.
|
|
10
|
-
*
|
|
11
|
-
* ai-web's plugin chain still loads localdb for shape uniformity per
|
|
12
|
-
* `apps/ai-web (consolidated)/SPEC.md` line 14. This empty cloud variant satisfies
|
|
13
|
-
* the chain without pulling consumer-only code into the cloud bundle.
|
|
14
|
-
*/
|
|
15
|
-
declare const _default: import("@vibesdotdev/runtime").RuntimePlugin;
|
|
16
|
-
export default _default;
|
|
17
|
-
//# sourceMappingURL=localdb.cloud.plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localdb.cloud.plugin.d.ts","sourceRoot":"","sources":["../src/localdb.cloud.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;AAIH,wBAMG"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LocalDB Cloud Plugin
|
|
3
|
-
*
|
|
4
|
-
* Cloud-bundle-safe variant of `localdb.plugin.ts`.
|
|
5
|
-
*
|
|
6
|
-
* LocalDB manages on-disk SQLite (libsql / better-sqlite3) for consumer
|
|
7
|
-
* environments. Every loader in `localdb.plugin.ts` is `.impl.consumer.ts`
|
|
8
|
-
* and reaches `bun:sqlite` / `node:fs`. None of it is reachable from a
|
|
9
|
-
* cloudflare-workers bundle.
|
|
10
|
-
*
|
|
11
|
-
* ai-web's plugin chain still loads localdb for shape uniformity per
|
|
12
|
-
* `apps/ai-web (consolidated)/SPEC.md` line 14. This empty cloud variant satisfies
|
|
13
|
-
* the chain without pulling consumer-only code into the cloud bundle.
|
|
14
|
-
*/
|
|
15
|
-
import { createRuntimePlugin } from '@vibesdotdev/runtime';
|
|
16
|
-
export default createRuntimePlugin({
|
|
17
|
-
// Same id as the consumer `localdb` plugin per AGENT-CONSTITUTION
|
|
18
|
-
// §PLUGIN ID PARITY: the bare id is the public capability.
|
|
19
|
-
id: 'localdb',
|
|
20
|
-
name: 'LocalDB (Cloud)',
|
|
21
|
-
description: 'Cloud-safe localdb registration — empty (localdb is consumer-only)'
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=localdb.cloud.plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localdb.cloud.plugin.js","sourceRoot":"","sources":["../src/localdb.cloud.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,eAAe,mBAAmB,CAAC;IAClC,kEAAkE;IAClE,2DAA2D;IAC3D,EAAE,EAAE,SAAS;IACb,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,oEAAoE;CACjF,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
|
|
3
|
-
export const databasePathsByNamespace: Record<string, string> = {
|
|
4
|
-
atlas: '.vibes/atlas/vibes.db',
|
|
5
|
-
session: '.vibes/session/sessions.db'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export function resolveDatabasePathForNamespace(namespace: string): string | undefined {
|
|
9
|
-
return databasePathsByNamespace[namespace];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function resolveFromCwd(p: string): string {
|
|
13
|
-
return resolve(process.cwd(), p);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function formatAgeMs(ageMs: number): string {
|
|
17
|
-
const ageMin = Math.floor(ageMs / 60000);
|
|
18
|
-
const ageSec = Math.floor((ageMs % 60000) / 1000);
|
|
19
|
-
return ageMin > 0 ? `${ageMin}m ${ageSec}s` : `${ageSec}s`;
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dev LocalDB Migrate CLI Command Descriptor
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
6
|
-
|
|
7
|
-
export default createRuntimeAsset({
|
|
8
|
-
id: 'dev.localdb.migrate',
|
|
9
|
-
kind: 'cli/command',
|
|
10
|
-
name: 'migrate',
|
|
11
|
-
description: 'Run pending migrations',
|
|
12
|
-
group: 'dev.localdb',
|
|
13
|
-
surfaces: ['cli'],
|
|
14
|
-
hardware: ['consumer'],
|
|
15
|
-
enabled: true,
|
|
16
|
-
options: [
|
|
17
|
-
{ flags: '--namespace <name>', description: 'Run migrations for a specific namespace' },
|
|
18
|
-
{ flags: '--dry-run', description: 'Show pending migrations without applying them' }
|
|
19
|
-
]
|
|
20
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
3
|
-
import { requestCLIExit, type UIContext } from '@vibesdotdev/cli/providers';
|
|
4
|
-
import type { LocaldbApi, MigrationRegistryApi } from '../../..';
|
|
5
|
-
import { resolveDatabasePathForNamespace, resolveFromCwd } from '../_shared.consumer';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
async execute(_args: Record<string, unknown>, opts: Record<string, unknown>): Promise<void> {
|
|
9
|
-
const runtime = getVibesRuntime();
|
|
10
|
-
const ui = (await runtime.context('cli/ui')) as UIContext;
|
|
11
|
-
const localdb = (await runtime.context('dev/localdb')) as LocaldbApi;
|
|
12
|
-
|
|
13
|
-
const namespaceOpt = typeof opts.namespace === 'string' ? opts.namespace : undefined;
|
|
14
|
-
const dryRun = Boolean(opts.dryRun);
|
|
15
|
-
|
|
16
|
-
ui.log(`\n=== LocalDB Migrate${dryRun ? ' (Dry Run)' : ''} ===\n`);
|
|
17
|
-
|
|
18
|
-
const namespaces = localdb.listNamespaces();
|
|
19
|
-
if (namespaces.length === 0) {
|
|
20
|
-
ui.info('No migration namespaces registered.');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const namespacesToMigrate = namespaceOpt
|
|
25
|
-
? namespaces.filter((ns) => ns === namespaceOpt)
|
|
26
|
-
: namespaces;
|
|
27
|
-
|
|
28
|
-
if (namespacesToMigrate.length === 0) {
|
|
29
|
-
ui.error(`Namespace '${namespaceOpt}' not found.`);
|
|
30
|
-
ui.info(`Available namespaces: ${namespaces.join(', ')}`);
|
|
31
|
-
requestCLIExit(1);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const { migrationRegistry } =
|
|
35
|
-
(await import('../../../core/migration-registry')) as {
|
|
36
|
-
migrationRegistry: MigrationRegistryApi;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
let migratedCount = 0;
|
|
40
|
-
let errorCount = 0;
|
|
41
|
-
|
|
42
|
-
for (const ns of namespacesToMigrate) {
|
|
43
|
-
const dbPath = resolveDatabasePathForNamespace(ns);
|
|
44
|
-
if (!dbPath) {
|
|
45
|
-
ui.warn(`Skipping '${ns}': no known database path`);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const fullPath = resolveFromCwd(dbPath);
|
|
50
|
-
if (!existsSync(fullPath)) {
|
|
51
|
-
ui.warn(`Skipping '${ns}': database not found (${dbPath})`);
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
ui.log(`\nNamespace: ${ns}`);
|
|
56
|
-
ui.log(`Database: ${dbPath}`);
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const db = localdb.getRawDatabase(fullPath, 'localdb-migrate');
|
|
60
|
-
const needsMigration = migrationRegistry.needsMigration(db, ns);
|
|
61
|
-
|
|
62
|
-
if (!needsMigration) {
|
|
63
|
-
ui.success('Already up to date');
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const status = migrationRegistry.getDatabaseStatus(db, ns);
|
|
68
|
-
ui.log(
|
|
69
|
-
`Pending: ${status.pendingMigrations} migration(s) (v${status.currentVersion} → v${status.targetVersion})`
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
if (dryRun) {
|
|
73
|
-
ui.log('Would apply:');
|
|
74
|
-
for (const m of status.migrations) {
|
|
75
|
-
if (!m.applied) ui.log(` • v${m.version}: ${m.name}`);
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
await migrationRegistry.runMigrations(db, ns);
|
|
79
|
-
ui.success('Migrations completed');
|
|
80
|
-
migratedCount++;
|
|
81
|
-
}
|
|
82
|
-
} catch (error) {
|
|
83
|
-
ui.error(`Error: ${String(error)}`);
|
|
84
|
-
errorCount++;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
ui.log('\n' + '─'.repeat(50));
|
|
89
|
-
if (dryRun) {
|
|
90
|
-
ui.info(`Dry run complete. Checked ${namespacesToMigrate.length} namespace(s).`);
|
|
91
|
-
} else {
|
|
92
|
-
ui.info(`Migration complete: ${migratedCount} migrated, ${errorCount} errors`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (errorCount > 0) requestCLIExit(1);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dev LocalDB Namespaces CLI Command Descriptor
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
6
|
-
|
|
7
|
-
export default createRuntimeAsset({
|
|
8
|
-
id: 'dev.localdb.namespaces',
|
|
9
|
-
kind: 'cli/command',
|
|
10
|
-
name: 'namespaces',
|
|
11
|
-
description: 'List registered migration namespaces',
|
|
12
|
-
group: 'dev.localdb',
|
|
13
|
-
surfaces: ['cli'],
|
|
14
|
-
hardware: ['consumer'],
|
|
15
|
-
enabled: true,
|
|
16
|
-
options: [{ flags: '--verbose', description: 'Show migration details for each namespace' }]
|
|
17
|
-
});
|