oakbun 0.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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/adapter/mysql.d.ts +21 -0
- package/dist/adapter/mysql.d.ts.map +1 -0
- package/dist/adapter/mysql.js +10 -0
- package/dist/adapter/mysql.js.map +1 -0
- package/dist/adapter/postgres.d.ts +16 -0
- package/dist/adapter/postgres.d.ts.map +1 -0
- package/dist/adapter/postgres.js +10 -0
- package/dist/adapter/postgres.js.map +1 -0
- package/dist/adapter/resolve.d.ts +16 -0
- package/dist/adapter/resolve.d.ts.map +1 -0
- package/dist/adapter/sqlite.d.ts +17 -0
- package/dist/adapter/sqlite.d.ts.map +1 -0
- package/dist/adapter/sqlite.js +10 -0
- package/dist/adapter/sqlite.js.map +1 -0
- package/dist/adapter/types.d.ts +29 -0
- package/dist/adapter/types.d.ts.map +1 -0
- package/dist/app/audit-wiring.d.ts +6 -0
- package/dist/app/audit-wiring.d.ts.map +1 -0
- package/dist/app/body-size-limit.d.ts +29 -0
- package/dist/app/body-size-limit.d.ts.map +1 -0
- package/dist/app/compression.d.ts +25 -0
- package/dist/app/compression.d.ts.map +1 -0
- package/dist/app/cookies.d.ts +17 -0
- package/dist/app/cookies.d.ts.map +1 -0
- package/dist/app/cors.d.ts +65 -0
- package/dist/app/cors.d.ts.map +1 -0
- package/dist/app/csrf.d.ts +52 -0
- package/dist/app/csrf.d.ts.map +1 -0
- package/dist/app/health.d.ts +36 -0
- package/dist/app/health.d.ts.map +1 -0
- package/dist/app/index.d.ts +282 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/logger.d.ts +4 -0
- package/dist/app/logger.d.ts.map +1 -0
- package/dist/app/middleware.d.ts +20 -0
- package/dist/app/middleware.d.ts.map +1 -0
- package/dist/app/module.d.ts +273 -0
- package/dist/app/module.d.ts.map +1 -0
- package/dist/app/plugin.d.ts +112 -0
- package/dist/app/plugin.d.ts.map +1 -0
- package/dist/app/rate-limit.d.ts +76 -0
- package/dist/app/rate-limit.d.ts.map +1 -0
- package/dist/app/request-id.d.ts +52 -0
- package/dist/app/request-id.d.ts.map +1 -0
- package/dist/app/router.d.ts +6 -0
- package/dist/app/router.d.ts.map +1 -0
- package/dist/app/scalar.d.ts +40 -0
- package/dist/app/scalar.d.ts.map +1 -0
- package/dist/app/secure-headers.d.ts +48 -0
- package/dist/app/secure-headers.d.ts.map +1 -0
- package/dist/app/system-ctx.d.ts +3 -0
- package/dist/app/system-ctx.d.ts.map +1 -0
- package/dist/app/types.d.ts +277 -0
- package/dist/app/types.d.ts.map +1 -0
- package/dist/chunk-32M77PK3.js +75 -0
- package/dist/chunk-32M77PK3.js.map +1 -0
- package/dist/chunk-7C6SKWY7.js +86 -0
- package/dist/chunk-7C6SKWY7.js.map +1 -0
- package/dist/chunk-7PGCL2E7.js +78 -0
- package/dist/chunk-7PGCL2E7.js.map +1 -0
- package/dist/chunk-F3WAOTEN.js +86 -0
- package/dist/chunk-FJSYS3BT.js +27 -0
- package/dist/chunk-UNRUXO7H.js +68 -0
- package/dist/chunk-WQ44NZ6K.js +116 -0
- package/dist/chunk-Z6ZWNWWR.js +34 -0
- package/dist/chunk-Z6ZWNWWR.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +645 -0
- package/dist/cli/commands/make/migration.d.ts +3 -0
- package/dist/cli/commands/make/migration.d.ts.map +1 -0
- package/dist/cli/commands/migrate/adapter.d.ts +14 -0
- package/dist/cli/commands/migrate/adapter.d.ts.map +1 -0
- package/dist/cli/commands/migrate/generate.d.ts +3 -0
- package/dist/cli/commands/migrate/generate.d.ts.map +1 -0
- package/dist/cli/commands/migrate/rollback.d.ts +3 -0
- package/dist/cli/commands/migrate/rollback.d.ts.map +1 -0
- package/dist/cli/commands/migrate/run.d.ts +3 -0
- package/dist/cli/commands/migrate/run.d.ts.map +1 -0
- package/dist/cli/commands/migrate/status.d.ts +3 -0
- package/dist/cli/commands/migrate/status.d.ts.map +1 -0
- package/dist/cli/commands/tinker.d.ts +7 -0
- package/dist/cli/commands/tinker.d.ts.map +1 -0
- package/dist/cli/config/defaults.d.ts +4 -0
- package/dist/cli/config/defaults.d.ts.map +1 -0
- package/dist/cli/config/loader.d.ts +3 -0
- package/dist/cli/config/loader.d.ts.map +1 -0
- package/dist/cli/config/types.d.ts +31 -0
- package/dist/cli/config/types.d.ts.map +1 -0
- package/dist/cli/discovery/commands.d.ts +4 -0
- package/dist/cli/discovery/commands.d.ts.map +1 -0
- package/dist/cli/discovery/services.d.ts +4 -0
- package/dist/cli/discovery/services.d.ts.map +1 -0
- package/dist/cli/discovery/tables.d.ts +5 -0
- package/dist/cli/discovery/tables.d.ts.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/client/error.d.ts +8 -0
- package/dist/client/error.d.ts.map +1 -0
- package/dist/client/index.d.ts +33 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/proxy.d.ts +88 -0
- package/dist/client/proxy.d.ts.map +1 -0
- package/dist/client/test-client.d.ts +30 -0
- package/dist/client/test-client.d.ts.map +1 -0
- package/dist/cron/index.d.ts +73 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/db/index.d.ts +281 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/migrations/diff.d.ts +5 -0
- package/dist/db/migrations/diff.d.ts.map +1 -0
- package/dist/db/migrations/generator.d.ts +26 -0
- package/dist/db/migrations/generator.d.ts.map +1 -0
- package/dist/db/migrations/index.d.ts +9 -0
- package/dist/db/migrations/index.d.ts.map +1 -0
- package/dist/db/migrations/introspect.d.ts +8 -0
- package/dist/db/migrations/introspect.d.ts.map +1 -0
- package/dist/db/migrations/migrator.d.ts +10 -0
- package/dist/db/migrations/migrator.d.ts.map +1 -0
- package/dist/db/migrations/runner.d.ts +7 -0
- package/dist/db/migrations/runner.d.ts.map +1 -0
- package/dist/db/migrations/tracker.d.ts +7 -0
- package/dist/db/migrations/tracker.d.ts.map +1 -0
- package/dist/db/migrations/types.d.ts +70 -0
- package/dist/db/migrations/types.d.ts.map +1 -0
- package/dist/db/sql.d.ts +148 -0
- package/dist/db/sql.d.ts.map +1 -0
- package/dist/db-XTXH6OKV.js +889 -0
- package/dist/errors/index.d.ts +30 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/events/handler.d.ts +42 -0
- package/dist/events/handler.d.ts.map +1 -0
- package/dist/events/index.d.ts +48 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events-LDXSK7ME.js +12 -0
- package/dist/executor-BM3A6AGL.js +104 -0
- package/dist/hooks/executor.d.ts +20 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/types.d.ts +10 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5562 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations-IWFQ6MZZ.js +757 -0
- package/dist/model/index.d.ts +24 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/openapi/generator.d.ts +58 -0
- package/dist/openapi/generator.d.ts.map +1 -0
- package/dist/openapi/zod-to-schema.d.ts +4 -0
- package/dist/openapi/zod-to-schema.d.ts.map +1 -0
- package/dist/resource/errors.d.ts +2 -0
- package/dist/resource/errors.d.ts.map +1 -0
- package/dist/resource/index.d.ts +98 -0
- package/dist/resource/index.d.ts.map +1 -0
- package/dist/resource/zod-table.d.ts +6 -0
- package/dist/resource/zod-table.d.ts.map +1 -0
- package/dist/schema/audit.d.ts +25 -0
- package/dist/schema/audit.d.ts.map +1 -0
- package/dist/schema/column.d.ts +31 -0
- package/dist/schema/column.d.ts.map +1 -0
- package/dist/schema/table.d.ts +68 -0
- package/dist/schema/table.d.ts.map +1 -0
- package/dist/service/index.d.ts +27 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service-W4V6TFWU.js +126 -0
- package/dist/sqlite-VTXOCD65.js +10 -0
- package/dist/system-ctx-GPF44QCE.js +42 -0
- package/package.json +69 -0
package/dist/cli/bin.js
ADDED
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
#!/usr/bin/env bun
|
|
3
|
+
import "../chunk-FJSYS3BT.js";
|
|
4
|
+
|
|
5
|
+
// src/cli/config/loader.ts
|
|
6
|
+
import { resolve } from "path";
|
|
7
|
+
async function loadConfig() {
|
|
8
|
+
const candidates = ["veln.config.ts", "veln.config.js"];
|
|
9
|
+
for (const rel of candidates) {
|
|
10
|
+
const abs = resolve(process.cwd(), rel);
|
|
11
|
+
if (await Bun.file(abs).exists()) {
|
|
12
|
+
const mod = await import(abs);
|
|
13
|
+
return mod.default ?? {};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/cli/discovery/commands.ts
|
|
20
|
+
import { resolve as resolve2 } from "path";
|
|
21
|
+
|
|
22
|
+
// src/cli/config/defaults.ts
|
|
23
|
+
var TABLE_SCAN_PATHS = [
|
|
24
|
+
"./src/features",
|
|
25
|
+
"./src/schema",
|
|
26
|
+
"./src/tables",
|
|
27
|
+
"./src"
|
|
28
|
+
];
|
|
29
|
+
var COMMAND_SCAN_PATHS = [
|
|
30
|
+
"./src/commands",
|
|
31
|
+
"./src/features"
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
// src/cli/discovery/commands.ts
|
|
35
|
+
function isCommandDef(x) {
|
|
36
|
+
return typeof x === "object" && x !== null && "_name" in x && "_action" in x;
|
|
37
|
+
}
|
|
38
|
+
function resolveCommandPaths(config) {
|
|
39
|
+
const cwd = process.cwd();
|
|
40
|
+
const relative = config.commands ? [config.commands] : config.features ? [config.features] : COMMAND_SCAN_PATHS;
|
|
41
|
+
return relative.map((p) => resolve2(cwd, p));
|
|
42
|
+
}
|
|
43
|
+
async function discoverCommands(config) {
|
|
44
|
+
const commands = [];
|
|
45
|
+
const scanPaths = resolveCommandPaths(config);
|
|
46
|
+
for (const absPath of scanPaths) {
|
|
47
|
+
const pattern = absPath.includes("features") ? "**/*.command.ts" : "**/*.ts";
|
|
48
|
+
const files = await Array.fromAsync(
|
|
49
|
+
new Bun.Glob(pattern).scan({ cwd: absPath, onlyFiles: true })
|
|
50
|
+
).catch(() => []);
|
|
51
|
+
for (const file of files) {
|
|
52
|
+
try {
|
|
53
|
+
const mod = await import(`${absPath}/${file}`);
|
|
54
|
+
if (isCommandDef(mod.default)) commands.push(mod.default);
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return commands;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/cli/commands/migrate/adapter.ts
|
|
63
|
+
import { resolve as resolve3 } from "path";
|
|
64
|
+
async function loadAdapter(config = {}) {
|
|
65
|
+
const cwd = process.cwd();
|
|
66
|
+
const candidates = [
|
|
67
|
+
"src/db.ts",
|
|
68
|
+
"src/db/index.ts",
|
|
69
|
+
"src/database.ts"
|
|
70
|
+
];
|
|
71
|
+
for (const rel of candidates) {
|
|
72
|
+
const abs = resolve3(cwd, rel);
|
|
73
|
+
if (await Bun.file(abs).exists()) {
|
|
74
|
+
try {
|
|
75
|
+
const mod = await import(abs);
|
|
76
|
+
if (mod.adapter && typeof mod.adapter.query === "function" && typeof mod.adapter.execute === "function") {
|
|
77
|
+
return mod.adapter;
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const { SQLiteAdapter } = await import("../sqlite-VTXOCD65.js");
|
|
84
|
+
const sqliteFiles = await Array.fromAsync(
|
|
85
|
+
new Bun.Glob("*.sqlite").scan({ cwd, onlyFiles: true })
|
|
86
|
+
).catch(() => []);
|
|
87
|
+
if (sqliteFiles.length > 0) {
|
|
88
|
+
return new SQLiteAdapter({ path: resolve3(cwd, sqliteFiles[0]) });
|
|
89
|
+
}
|
|
90
|
+
void config;
|
|
91
|
+
return new SQLiteAdapter();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/cli/commands/migrate/run.ts
|
|
95
|
+
async function migrateRun(_args, config) {
|
|
96
|
+
const { createMigrator } = await import("../migrations-IWFQ6MZZ.js");
|
|
97
|
+
const migrationsDir = config.migrations ?? "./migrations";
|
|
98
|
+
const adapter = await loadAdapter(config);
|
|
99
|
+
const migrator = createMigrator(adapter, { migrationsDir });
|
|
100
|
+
const results = await migrator.run();
|
|
101
|
+
if (results.length === 0) {
|
|
102
|
+
console.log("\u2705 Nothing to migrate \u2014 already up to date");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (const r of results) {
|
|
106
|
+
if (r.success) {
|
|
107
|
+
console.log(`\u2705 ${r.name} (${r.duration}ms)`);
|
|
108
|
+
} else {
|
|
109
|
+
console.error(`\u274C ${r.name} \u2014 ${r.error?.message}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/cli/commands/migrate/status.ts
|
|
115
|
+
async function migrateStatus(_args, config) {
|
|
116
|
+
const { createMigrator } = await import("../migrations-IWFQ6MZZ.js");
|
|
117
|
+
const migrationsDir = config.migrations ?? "./migrations";
|
|
118
|
+
const adapter = await loadAdapter(config);
|
|
119
|
+
const migrator = createMigrator(adapter, { migrationsDir });
|
|
120
|
+
const statuses = await migrator.status();
|
|
121
|
+
if (statuses.length === 0) {
|
|
122
|
+
console.log("No migration files found in", migrationsDir);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
for (const s of statuses) {
|
|
126
|
+
const icon = s.status === "applied" ? "\u2705" : "\u2B1C";
|
|
127
|
+
const date = s.appliedAt ? ` (${s.appliedAt.toISOString()})` : "";
|
|
128
|
+
console.log(`${icon} ${s.name}${date}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/cli/discovery/tables.ts
|
|
133
|
+
import { resolve as resolve4 } from "path";
|
|
134
|
+
function isTableDef(x) {
|
|
135
|
+
return typeof x === "object" && x !== null && "name" in x && "schema" in x && "_eventMap" in x;
|
|
136
|
+
}
|
|
137
|
+
function resolveScanPaths(config) {
|
|
138
|
+
const cwd = process.cwd();
|
|
139
|
+
const relative = config.features ? [config.features] : config.schema ? [config.schema] : config.tables ? [config.tables] : TABLE_SCAN_PATHS;
|
|
140
|
+
return relative.map((p) => resolve4(cwd, p));
|
|
141
|
+
}
|
|
142
|
+
async function scanDir(absDir, pattern) {
|
|
143
|
+
const tables = [];
|
|
144
|
+
const files = await Array.fromAsync(
|
|
145
|
+
new Bun.Glob(pattern).scan({ cwd: absDir, onlyFiles: true })
|
|
146
|
+
).catch(() => []);
|
|
147
|
+
for (const file of files) {
|
|
148
|
+
try {
|
|
149
|
+
const mod = await import(`${absDir}/${file}`);
|
|
150
|
+
for (const exp of Object.values(mod)) {
|
|
151
|
+
if (isTableDef(exp)) tables.push(exp);
|
|
152
|
+
}
|
|
153
|
+
} catch {
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return tables;
|
|
157
|
+
}
|
|
158
|
+
async function discoverTables(config) {
|
|
159
|
+
const scanPaths = resolveScanPaths(config);
|
|
160
|
+
for (const scanPath of scanPaths) {
|
|
161
|
+
const byConvention = await scanDir(scanPath, "**/*.table.ts");
|
|
162
|
+
if (byConvention.length > 0) return byConvention;
|
|
163
|
+
const loose = await scanDir(scanPath, "**/*.ts");
|
|
164
|
+
if (loose.length > 0) return loose;
|
|
165
|
+
}
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/cli/commands/migrate/generate.ts
|
|
170
|
+
async function migrateGenerate(args, config) {
|
|
171
|
+
const { generateMigration } = await import("../migrations-IWFQ6MZZ.js");
|
|
172
|
+
const name = args[0];
|
|
173
|
+
const tables = await discoverTables(config);
|
|
174
|
+
if (tables.length === 0) {
|
|
175
|
+
console.log("\u2B1C No tables found. Searched in:");
|
|
176
|
+
console.log(" ./src/features, ./src/schema, ./src/tables, ./src");
|
|
177
|
+
console.log("");
|
|
178
|
+
console.log(" Add a veln.config.ts to specify your schema path:");
|
|
179
|
+
console.log(' export default defineConfig({ schema: "./your/path" })');
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const adapter = await loadAdapter(config);
|
|
183
|
+
const result = await generateMigration({
|
|
184
|
+
tables,
|
|
185
|
+
adapter,
|
|
186
|
+
migrationsDir: config.migrations ?? "./migrations",
|
|
187
|
+
name
|
|
188
|
+
});
|
|
189
|
+
if (result.isEmpty) {
|
|
190
|
+
console.log("\u2705 No changes detected \u2014 schema is up to date");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
console.log(`\u2705 Generated: ${result.filename}`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/cli/commands/migrate/rollback.ts
|
|
197
|
+
async function migrateRollback(_args, config) {
|
|
198
|
+
const { createMigrator } = await import("../migrations-IWFQ6MZZ.js");
|
|
199
|
+
const migrationsDir = config.migrations ?? "./migrations";
|
|
200
|
+
const adapter = await loadAdapter(config);
|
|
201
|
+
const migrator = createMigrator(adapter, { migrationsDir });
|
|
202
|
+
const applied = (await migrator.status()).filter((s) => s.status === "applied");
|
|
203
|
+
if (applied.length === 0) {
|
|
204
|
+
console.log("\u2705 Nothing to rollback \u2014 no migrations applied");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const last = applied[applied.length - 1];
|
|
208
|
+
await migrator.rollback();
|
|
209
|
+
console.log(`\u21A9\uFE0F Rolled back: ${last.name}`);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/cli/commands/make/migration.ts
|
|
213
|
+
import { readdir, writeFile, mkdir } from "fs/promises";
|
|
214
|
+
import { join } from "path";
|
|
215
|
+
async function nextMigrationNumber(dir) {
|
|
216
|
+
let entries;
|
|
217
|
+
try {
|
|
218
|
+
entries = await readdir(dir);
|
|
219
|
+
} catch {
|
|
220
|
+
return 1;
|
|
221
|
+
}
|
|
222
|
+
const nums = entries.filter((f) => f.endsWith(".sql")).map((f) => {
|
|
223
|
+
const match = /^(\d+)/.exec(f);
|
|
224
|
+
return match ? parseInt(match[1], 10) : 0;
|
|
225
|
+
});
|
|
226
|
+
return nums.length === 0 ? 1 : Math.max(...nums) + 1;
|
|
227
|
+
}
|
|
228
|
+
async function makeMigration(args, config) {
|
|
229
|
+
const name = args[0] ?? "migration";
|
|
230
|
+
const migrationsDir = config.migrations ?? "./migrations";
|
|
231
|
+
const num = await nextMigrationNumber(migrationsDir);
|
|
232
|
+
const numStr = String(num).padStart(4, "0");
|
|
233
|
+
const filename = `${numStr}_${name}.sql`;
|
|
234
|
+
const filepath = join(migrationsDir, filename);
|
|
235
|
+
await mkdir(migrationsDir, { recursive: true });
|
|
236
|
+
await writeFile(filepath, `-- Migration: ${name}
|
|
237
|
+
-- Created: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
238
|
+
|
|
239
|
+
`, "utf8");
|
|
240
|
+
console.log(`\u2705 Created: ${filepath}`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// src/cli/commands/tinker.ts
|
|
244
|
+
import { resolve as resolve6 } from "path";
|
|
245
|
+
|
|
246
|
+
// src/cli/discovery/services.ts
|
|
247
|
+
import { resolve as resolve5 } from "path";
|
|
248
|
+
function isServiceDef(x) {
|
|
249
|
+
return typeof x === "object" && x !== null && "_serviceKey" in x && "_factory" in x;
|
|
250
|
+
}
|
|
251
|
+
function resolveScanPaths2(config) {
|
|
252
|
+
const cwd = process.cwd();
|
|
253
|
+
const relative = config.features ? [config.features] : config.schema ? [config.schema] : TABLE_SCAN_PATHS;
|
|
254
|
+
return relative.map((p) => resolve5(cwd, p));
|
|
255
|
+
}
|
|
256
|
+
async function discoverServices(config) {
|
|
257
|
+
const found = [];
|
|
258
|
+
const scanPaths = resolveScanPaths2(config);
|
|
259
|
+
for (const absDir of scanPaths) {
|
|
260
|
+
const files = await Array.fromAsync(
|
|
261
|
+
new Bun.Glob("**/*.service.ts").scan({ cwd: absDir, onlyFiles: true })
|
|
262
|
+
).catch(() => []);
|
|
263
|
+
for (const file of files) {
|
|
264
|
+
try {
|
|
265
|
+
const mod = await import(`${absDir}/${file}`);
|
|
266
|
+
for (const exp of Object.values(mod)) {
|
|
267
|
+
if (isServiceDef(exp)) found.push(exp);
|
|
268
|
+
}
|
|
269
|
+
} catch {
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (found.length > 0) break;
|
|
273
|
+
}
|
|
274
|
+
return found;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/cli/commands/tinker.ts
|
|
278
|
+
function isComplete(code) {
|
|
279
|
+
let depth = 0;
|
|
280
|
+
let inStr = false;
|
|
281
|
+
let strCh = "";
|
|
282
|
+
for (const ch of code) {
|
|
283
|
+
if (inStr) {
|
|
284
|
+
if (ch === strCh) inStr = false;
|
|
285
|
+
} else if (ch === '"' || ch === "'" || ch === "`") {
|
|
286
|
+
inStr = true;
|
|
287
|
+
strCh = ch;
|
|
288
|
+
} else if (ch === "(" || ch === "{" || ch === "[") {
|
|
289
|
+
depth++;
|
|
290
|
+
} else if (ch === ")" || ch === "}" || ch === "]") {
|
|
291
|
+
depth--;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return depth === 0 && !inStr;
|
|
295
|
+
}
|
|
296
|
+
function formatValue(val) {
|
|
297
|
+
if (val instanceof Date) {
|
|
298
|
+
return val.toISOString().replace("T", " ").slice(0, 19);
|
|
299
|
+
}
|
|
300
|
+
if (typeof val === "string" && /^\d{4}-\d{2}-\d{2}T/.test(val)) {
|
|
301
|
+
return val.replace("T", " ").slice(0, 19);
|
|
302
|
+
}
|
|
303
|
+
return String(val ?? "");
|
|
304
|
+
}
|
|
305
|
+
function formatTable(rows) {
|
|
306
|
+
if (rows.length === 0) return "\x1B[2m[]\x1B[0m";
|
|
307
|
+
const keys = Object.keys(rows[0]);
|
|
308
|
+
const widths = keys.map(
|
|
309
|
+
(k) => Math.max(k.length, ...rows.map((r) => formatValue(r[k]).length))
|
|
310
|
+
);
|
|
311
|
+
const top = "\u250C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u252C") + "\u2510";
|
|
312
|
+
const middle = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u253C") + "\u2524";
|
|
313
|
+
const bottom = "\u2514" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u2534") + "\u2518";
|
|
314
|
+
const header = "\u2502 " + keys.map((k, i) => `\x1B[2m${k.padEnd(widths[i])}\x1B[0m`).join(" \u2502 ") + " \u2502";
|
|
315
|
+
const rowStrs = rows.map(
|
|
316
|
+
(r) => "\u2502 " + keys.map((k, i) => formatValue(r[k]).padEnd(widths[i])).join(" \u2502 ") + " \u2502"
|
|
317
|
+
);
|
|
318
|
+
return [
|
|
319
|
+
top,
|
|
320
|
+
header,
|
|
321
|
+
middle,
|
|
322
|
+
...rowStrs,
|
|
323
|
+
bottom,
|
|
324
|
+
`\x1B[2m(${rows.length} row${rows.length === 1 ? "" : "s"})\x1B[0m`
|
|
325
|
+
].join("\n");
|
|
326
|
+
}
|
|
327
|
+
function formatResult(value) {
|
|
328
|
+
if (value === null) return "\x1B[2mnull\x1B[0m";
|
|
329
|
+
if (value === void 0) return "\x1B[2mundefined\x1B[0m";
|
|
330
|
+
if (Array.isArray(value)) {
|
|
331
|
+
if (value.length === 0) return "\x1B[2m[]\x1B[0m";
|
|
332
|
+
if (typeof value[0] === "object" && value[0] !== null) {
|
|
333
|
+
return formatTable(value);
|
|
334
|
+
}
|
|
335
|
+
return JSON.stringify(value, null, 2);
|
|
336
|
+
}
|
|
337
|
+
if (typeof value === "object") {
|
|
338
|
+
return JSON.stringify(value, null, 2);
|
|
339
|
+
}
|
|
340
|
+
return String(value);
|
|
341
|
+
}
|
|
342
|
+
function printBanner(tables, services) {
|
|
343
|
+
const tableNames = Object.keys(tables);
|
|
344
|
+
const serviceNames = Object.keys(services);
|
|
345
|
+
console.log("");
|
|
346
|
+
console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
|
|
347
|
+
console.log(" \x1B[1mOakBun Shell\x1B[0m");
|
|
348
|
+
console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
|
|
349
|
+
console.log(" \x1B[1mContext:\x1B[0m");
|
|
350
|
+
console.log(` \x1B[36mdb\x1B[0m \u2192 BoundVelnDB`);
|
|
351
|
+
console.log(` \x1B[36mtables\x1B[0m \u2192 { ${tableNames.join(", ") || "none"} }`);
|
|
352
|
+
console.log(` \x1B[36mservices\x1B[0m \u2192 { ${serviceNames.join(", ") || "none"} }`);
|
|
353
|
+
console.log(` \x1B[36mmigrator\x1B[0m \u2192 Migrator`);
|
|
354
|
+
console.log(` \x1B[36mbus\x1B[0m \u2192 EventBus`);
|
|
355
|
+
console.log("");
|
|
356
|
+
console.log(" \x1B[1mExamples:\x1B[0m");
|
|
357
|
+
if (tableNames[0]) {
|
|
358
|
+
console.log(` \x1B[2mawait db.from(tables.${tableNames[0]}).select()\x1B[0m`);
|
|
359
|
+
console.log(` \x1B[2mawait db.from(tables.${tableNames[0]}).where({ id: 1 }).first()\x1B[0m`);
|
|
360
|
+
}
|
|
361
|
+
if (serviceNames[0]) {
|
|
362
|
+
console.log(` \x1B[2mawait services.${serviceNames[0]}.findAll()\x1B[0m`);
|
|
363
|
+
}
|
|
364
|
+
console.log(` \x1B[2mawait migrator.status()\x1B[0m`);
|
|
365
|
+
console.log(` \x1B[2mbus.emit('event.name', { id: 1 })\x1B[0m`);
|
|
366
|
+
console.log("");
|
|
367
|
+
console.log(" \x1B[2m.tables .help .exit\x1B[0m");
|
|
368
|
+
console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
|
|
369
|
+
console.log("");
|
|
370
|
+
}
|
|
371
|
+
function printHelp() {
|
|
372
|
+
console.log("");
|
|
373
|
+
console.log(" \x1B[1mCommands:\x1B[0m");
|
|
374
|
+
console.log(" .tables list discovered tables");
|
|
375
|
+
console.log(" .help show this help");
|
|
376
|
+
console.log(" .exit quit the REPL");
|
|
377
|
+
console.log("");
|
|
378
|
+
console.log(" \x1B[1mContext variables:\x1B[0m");
|
|
379
|
+
console.log(" db BoundVelnDB \u2014 db.from(tables.users).select()");
|
|
380
|
+
console.log(" tables discovered TableDefs by name");
|
|
381
|
+
console.log(' adapter raw VelnAdapter \u2014 adapter.query("SELECT ...")');
|
|
382
|
+
console.log(" services instantiated services by key");
|
|
383
|
+
console.log(' bus EventBus \u2014 bus.emit("user.created", payload)');
|
|
384
|
+
console.log(" migrator Migrator \u2014 migrator.status() / migrator.run()");
|
|
385
|
+
console.log("");
|
|
386
|
+
}
|
|
387
|
+
async function evalLine(code, context) {
|
|
388
|
+
const transpiler = new Bun.Transpiler({ loader: "ts" });
|
|
389
|
+
const js = transpiler.transformSync(code);
|
|
390
|
+
const fn = new Function(
|
|
391
|
+
"db",
|
|
392
|
+
"tables",
|
|
393
|
+
"adapter",
|
|
394
|
+
"services",
|
|
395
|
+
"bus",
|
|
396
|
+
"migrator",
|
|
397
|
+
`return (async () => { return ${js} })()`
|
|
398
|
+
);
|
|
399
|
+
return fn(
|
|
400
|
+
context.db,
|
|
401
|
+
context.tables,
|
|
402
|
+
context.adapter,
|
|
403
|
+
context.services,
|
|
404
|
+
context.bus,
|
|
405
|
+
context.migrator
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
var PROMPT = "\x1B[36m>>\x1B[0m ";
|
|
409
|
+
var PROMPT_CONT = "\x1B[2m..\x1B[0m ";
|
|
410
|
+
var PROMPT_VISIBLE_LEN = 3;
|
|
411
|
+
var PROMPT_CONT_VISIBLE_LEN = 3;
|
|
412
|
+
function promptVisibleLen(state) {
|
|
413
|
+
return state.buffer ? PROMPT_CONT_VISIBLE_LEN : PROMPT_VISIBLE_LEN;
|
|
414
|
+
}
|
|
415
|
+
function clearLine(state) {
|
|
416
|
+
const promptStr = state.buffer ? PROMPT_CONT : PROMPT;
|
|
417
|
+
process.stdout.write(`\r\x1B[2K${promptStr}`);
|
|
418
|
+
}
|
|
419
|
+
function writePrompt(state) {
|
|
420
|
+
process.stdout.write(state.buffer ? PROMPT_CONT : PROMPT);
|
|
421
|
+
}
|
|
422
|
+
function redrawLine(state) {
|
|
423
|
+
clearLine(state);
|
|
424
|
+
process.stdout.write(state.currentLine);
|
|
425
|
+
const col = promptVisibleLen(state) + state.cursorPos + 1;
|
|
426
|
+
process.stdout.write(`\x1B[${col}G`);
|
|
427
|
+
}
|
|
428
|
+
async function tinker(_args, config) {
|
|
429
|
+
const adapter = await loadAdapter(config);
|
|
430
|
+
const tableList = await discoverTables(config);
|
|
431
|
+
const serviceDefs = await discoverServices(config);
|
|
432
|
+
const tables = {};
|
|
433
|
+
for (const t of tableList) tables[t.name] = t;
|
|
434
|
+
const { VelnDB } = await import("../db-XTXH6OKV.js");
|
|
435
|
+
const { HookExecutor } = await import("../executor-BM3A6AGL.js");
|
|
436
|
+
const { RequestEventQueue, EventBus } = await import("../events-LDXSK7ME.js");
|
|
437
|
+
const { createSystemCtx } = await import("../system-ctx-GPF44QCE.js");
|
|
438
|
+
const { instantiateServices } = await import("../service-W4V6TFWU.js");
|
|
439
|
+
const { createMigrator } = await import("../migrations-IWFQ6MZZ.js");
|
|
440
|
+
const hooks = new HookExecutor();
|
|
441
|
+
hooks.setAdapter(adapter);
|
|
442
|
+
const velnDB = new VelnDB(adapter, hooks);
|
|
443
|
+
const db = velnDB.withCtx(createSystemCtx(), new RequestEventQueue());
|
|
444
|
+
const services = instantiateServices(serviceDefs, db);
|
|
445
|
+
const bus = new EventBus();
|
|
446
|
+
const migrator = createMigrator(adapter, {
|
|
447
|
+
migrationsDir: resolve6(process.cwd(), config.migrations ?? "./migrations")
|
|
448
|
+
});
|
|
449
|
+
const evalCtx = { db, tables, adapter, services, bus, migrator };
|
|
450
|
+
printBanner(tables, services);
|
|
451
|
+
const state = {
|
|
452
|
+
buffer: "",
|
|
453
|
+
currentLine: "",
|
|
454
|
+
cursorPos: 0,
|
|
455
|
+
history: [],
|
|
456
|
+
historyIndex: -1
|
|
457
|
+
};
|
|
458
|
+
process.stdin.setRawMode(true);
|
|
459
|
+
process.stdin.setEncoding("utf8");
|
|
460
|
+
writePrompt(state);
|
|
461
|
+
for await (const chunk of process.stdin) {
|
|
462
|
+
const ch = String(chunk);
|
|
463
|
+
if (ch === "" || ch === "") {
|
|
464
|
+
console.log("\nBye! \u{1F44B}");
|
|
465
|
+
process.exit(0);
|
|
466
|
+
}
|
|
467
|
+
if (ch === "\x1B[A") {
|
|
468
|
+
if (state.historyIndex < state.history.length - 1) {
|
|
469
|
+
state.historyIndex++;
|
|
470
|
+
state.currentLine = state.history[state.historyIndex];
|
|
471
|
+
state.cursorPos = state.currentLine.length;
|
|
472
|
+
redrawLine(state);
|
|
473
|
+
}
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
if (ch === "\x1B[B") {
|
|
477
|
+
if (state.historyIndex > 0) {
|
|
478
|
+
state.historyIndex--;
|
|
479
|
+
state.currentLine = state.history[state.historyIndex];
|
|
480
|
+
} else {
|
|
481
|
+
state.historyIndex = -1;
|
|
482
|
+
state.currentLine = "";
|
|
483
|
+
}
|
|
484
|
+
state.cursorPos = state.currentLine.length;
|
|
485
|
+
redrawLine(state);
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (ch === "\x1B[C") {
|
|
489
|
+
if (state.cursorPos < state.currentLine.length) {
|
|
490
|
+
state.cursorPos++;
|
|
491
|
+
process.stdout.write("\x1B[C");
|
|
492
|
+
}
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (ch === "\x1B[D") {
|
|
496
|
+
if (state.cursorPos > 0) {
|
|
497
|
+
state.cursorPos--;
|
|
498
|
+
process.stdout.write("\x1B[D");
|
|
499
|
+
}
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (ch.startsWith("\x1B")) continue;
|
|
503
|
+
if (ch === "\x7F") {
|
|
504
|
+
if (state.cursorPos > 0) {
|
|
505
|
+
state.currentLine = state.currentLine.slice(0, state.cursorPos - 1) + state.currentLine.slice(state.cursorPos);
|
|
506
|
+
state.cursorPos--;
|
|
507
|
+
redrawLine(state);
|
|
508
|
+
}
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
if (ch === "\r" || ch === "\n") {
|
|
512
|
+
process.stdout.write("\n");
|
|
513
|
+
const line = state.currentLine;
|
|
514
|
+
const trimmed = line.trim();
|
|
515
|
+
state.currentLine = "";
|
|
516
|
+
state.cursorPos = 0;
|
|
517
|
+
state.historyIndex = -1;
|
|
518
|
+
if (state.buffer === "" && trimmed.startsWith(".")) {
|
|
519
|
+
if (trimmed === ".exit" || trimmed === ".quit") {
|
|
520
|
+
console.log("Bye! \u{1F44B}");
|
|
521
|
+
process.exit(0);
|
|
522
|
+
}
|
|
523
|
+
if (trimmed === ".help") {
|
|
524
|
+
printHelp();
|
|
525
|
+
writePrompt(state);
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
if (trimmed === ".tables") {
|
|
529
|
+
const names = Object.keys(tables);
|
|
530
|
+
console.log(names.length === 0 ? " No tables found." : ` ${names.join(", ")}`);
|
|
531
|
+
writePrompt(state);
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (!trimmed) {
|
|
536
|
+
writePrompt(state);
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
if (state.history[0] !== trimmed) state.history.unshift(trimmed);
|
|
540
|
+
state.buffer += (state.buffer ? "\n" : "") + line;
|
|
541
|
+
if (!isComplete(state.buffer)) {
|
|
542
|
+
writePrompt(state);
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
const code = state.buffer;
|
|
546
|
+
state.buffer = "";
|
|
547
|
+
try {
|
|
548
|
+
const result = await evalLine(code, evalCtx);
|
|
549
|
+
if (result !== void 0) console.log(formatResult(result));
|
|
550
|
+
} catch (err) {
|
|
551
|
+
console.error(`\x1B[31m[Error]\x1B[0m ${err instanceof Error ? err.message : String(err)}`);
|
|
552
|
+
}
|
|
553
|
+
writePrompt(state);
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
if (ch >= " ") {
|
|
557
|
+
state.currentLine = state.currentLine.slice(0, state.cursorPos) + ch + state.currentLine.slice(state.cursorPos);
|
|
558
|
+
state.cursorPos++;
|
|
559
|
+
if (state.cursorPos === state.currentLine.length) {
|
|
560
|
+
process.stdout.write(ch);
|
|
561
|
+
} else {
|
|
562
|
+
redrawLine(state);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
console.log("\nBye!");
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// src/cli/bin.ts
|
|
570
|
+
var BUILTIN = {
|
|
571
|
+
"migrate:run": migrateRun,
|
|
572
|
+
"migrate:status": migrateStatus,
|
|
573
|
+
"migrate:generate": migrateGenerate,
|
|
574
|
+
"migrate:rollback": migrateRollback,
|
|
575
|
+
"make:migration": makeMigration,
|
|
576
|
+
"shell": tinker
|
|
577
|
+
};
|
|
578
|
+
function parseArgs(argv, options) {
|
|
579
|
+
const result = {};
|
|
580
|
+
for (let i = 0; i < argv.length; i++) {
|
|
581
|
+
const arg = argv[i];
|
|
582
|
+
for (const opt of options) {
|
|
583
|
+
const match = /^--(\w[\w-]*)/.exec(opt.flag);
|
|
584
|
+
if (!match) continue;
|
|
585
|
+
const key = match[1];
|
|
586
|
+
if (arg === `--${key}` && argv[i + 1]) {
|
|
587
|
+
result[key] = argv[++i];
|
|
588
|
+
} else if (arg.startsWith(`--${key}=`)) {
|
|
589
|
+
result[key] = arg.slice(`--${key}=`.length);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (!arg.startsWith("-")) {
|
|
593
|
+
result[String(i)] = arg;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
598
|
+
function printHelp2() {
|
|
599
|
+
console.log(`
|
|
600
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
601
|
+
OakBun CLI
|
|
602
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
603
|
+
Migrations
|
|
604
|
+
oak migrate:run Run pending migrations
|
|
605
|
+
oak migrate:status Show migration status
|
|
606
|
+
oak migrate:generate [name] Generate migration from schema diff
|
|
607
|
+
oak migrate:rollback Rollback last migration
|
|
608
|
+
|
|
609
|
+
Generators
|
|
610
|
+
oak make:migration [name] Create empty migration file
|
|
611
|
+
|
|
612
|
+
Interactive
|
|
613
|
+
oak shell Start interactive shell with DB access
|
|
614
|
+
|
|
615
|
+
Custom commands from src/commands/ or oak.config.ts are
|
|
616
|
+
automatically discovered and available here.
|
|
617
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`.trim());
|
|
618
|
+
}
|
|
619
|
+
async function main() {
|
|
620
|
+
const [, , command, ...rest] = process.argv;
|
|
621
|
+
if (!command || command === "--help" || command === "-h") {
|
|
622
|
+
printHelp2();
|
|
623
|
+
process.exit(0);
|
|
624
|
+
}
|
|
625
|
+
const config = await loadConfig();
|
|
626
|
+
const builtin = BUILTIN[command];
|
|
627
|
+
if (builtin) {
|
|
628
|
+
await builtin(rest, config);
|
|
629
|
+
process.exit(0);
|
|
630
|
+
}
|
|
631
|
+
const customs = await discoverCommands(config);
|
|
632
|
+
const custom = customs.find((c) => c._name === command);
|
|
633
|
+
if (custom) {
|
|
634
|
+
const parsed = parseArgs(rest, custom._options);
|
|
635
|
+
await custom._action(parsed);
|
|
636
|
+
process.exit(0);
|
|
637
|
+
}
|
|
638
|
+
console.error(`Unknown command: ${command}`);
|
|
639
|
+
printHelp2();
|
|
640
|
+
process.exit(1);
|
|
641
|
+
}
|
|
642
|
+
main().catch((err) => {
|
|
643
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
644
|
+
process.exit(1);
|
|
645
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/make/migration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAoBpD,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAYrF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { VelnAdapter } from '../../../adapter/types';
|
|
2
|
+
import type { VelnConfig } from '../../config/types';
|
|
3
|
+
/**
|
|
4
|
+
* Loads the adapter for CLI commands.
|
|
5
|
+
* Resolves all paths relative to process.cwd() — the directory where the
|
|
6
|
+
* user invokes `bunx veln`, not the location of this CLI source file.
|
|
7
|
+
*
|
|
8
|
+
* Resolution order:
|
|
9
|
+
* 1. src/db.ts (or src/db/index.ts, src/database.ts) — exports `adapter`
|
|
10
|
+
* 2. *.sqlite file in project root — opened directly
|
|
11
|
+
* 3. In-memory SQLite fallback
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadAdapter(config?: VelnConfig): Promise<VelnAdapter>;
|
|
14
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/migrate/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,MAAM,GAAE,UAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CA0C/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/migrate/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAIpD,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BvF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollback.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/migrate/rollback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAGpD,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBxF"}
|