mirror of
https://github.com/cita-777/metapi.git
synced 2026-11-01 20:55:09 +08:00
- Added `routeCompatibility.ts` to handle response compatibility for different endpoints. - Introduced `chatEndpointStrategy.ts` to manage chat endpoint recovery and downgrading logic. - Created tests for chat formats and input file handling in `chatFormatsCore.test.ts` and `inputFile.test.ts`. - Developed `endpointCompatibility.ts` to define compatibility checks and header building for various endpoints. - Implemented protocol lifecycle management in `protocolLifecycle.ts` and corresponding tests in `protocolModel.test.ts`. - Enhanced tooltip functionality with a new `TooltipLayer` component and associated tests. - Refactored existing components to improve tooltip handling and ensure proper rendering in the application.
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import {
|
|
bootstrapRuntimeDatabaseSchema,
|
|
type RuntimeSchemaDialect,
|
|
} from './db/runtimeSchemaBootstrap.js';
|
|
|
|
let sqliteMigrationsBootstrapped = false;
|
|
|
|
export async function runSqliteRuntimeMigrations(): Promise<void> {
|
|
const migrateModule = await import('./db/migrate.js');
|
|
if (sqliteMigrationsBootstrapped) {
|
|
migrateModule.runSqliteMigrations();
|
|
return;
|
|
}
|
|
sqliteMigrationsBootstrapped = true;
|
|
}
|
|
|
|
type EnsureRuntimeDatabaseReadyInput = {
|
|
dialect: RuntimeSchemaDialect;
|
|
connectionString?: string;
|
|
ssl?: boolean;
|
|
runSqliteRuntimeMigrations?: () => Promise<void>;
|
|
ensureExternalRuntimeSchema?: () => Promise<void>;
|
|
};
|
|
|
|
export async function ensureRuntimeDatabaseReady(input: EnsureRuntimeDatabaseReadyInput): Promise<void> {
|
|
if (input.dialect === 'sqlite') {
|
|
const runSqlite = input.runSqliteRuntimeMigrations || runSqliteRuntimeMigrations;
|
|
await runSqlite();
|
|
return;
|
|
}
|
|
|
|
const ensureExternal = input.ensureExternalRuntimeSchema || (async () => {
|
|
const connectionString = (input.connectionString || '').trim();
|
|
if (!connectionString) {
|
|
throw new Error(`DB_URL is required when DB_TYPE=${input.dialect}`);
|
|
}
|
|
await bootstrapRuntimeDatabaseSchema({
|
|
dialect: input.dialect,
|
|
connectionString,
|
|
ssl: !!input.ssl,
|
|
});
|
|
});
|
|
|
|
await ensureExternal();
|
|
}
|
|
|
|
export const __runtimeDatabaseBootstrapTestUtils = {
|
|
resetSqliteMigrationsBootstrapped() {
|
|
sqliteMigrationsBootstrapped = false;
|
|
},
|
|
};
|