feat(ql3): establish 3.0 incubation baseline

This commit is contained in:
whyour
2026-08-12 00:25:26 +08:00
parent 4bf92dcfeb
commit c699c32461
2817 changed files with 779642 additions and 653 deletions
@@ -0,0 +1,35 @@
import type { DatabaseSync } from 'node:sqlite';
type Row = Record<string, unknown>;
function projectId(row: Row): string {
const value = row.projectId;
if (typeof value !== 'string') {
throw new TypeError('Local instance authority Project is invalid');
}
return value;
}
export function resolveLocalInstanceAuthorityProjectId(
client: DatabaseSync,
): string | null {
const claimed = client
.prepare(
`SELECT "project_id" AS "projectId"
FROM "QingLong3LocalOwnerBootstrapChallenges"
WHERE "consumed_at_ms" IS NOT NULL
ORDER BY "consumed_at_ms" ASC, "project_id" ASC, "version" ASC
LIMIT 1`,
)
.get() as Row | undefined;
if (claimed) return projectId(claimed);
const fallback = client
.prepare(
`SELECT "id" AS "projectId"
FROM "QingLong3Projects"
WHERE "id" = 'default'
LIMIT 1`,
)
.get() as Row | undefined;
return fallback ? projectId(fallback) : null;
}