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,56 @@
import {
BoundedRunListProjectionUnavailableError,
InvalidBoundedRunListProjectionError,
executeBoundedRunListProjection,
type BoundedRunListInput,
} from '@qinglong/runtime-core/bounded-run-list-projection';
import type { ProjectRunListReader } from '@qinglong/runtime-core/project-run-list';
import type { LocalApiResponse } from '../transport/contract';
export interface LocalApiRunListRequest {
readonly projectId: string;
readonly input: Readonly<BoundedRunListInput>;
}
export interface LocalApiRunListRoute {
handle(request: Readonly<LocalApiRunListRequest>): Promise<LocalApiResponse>;
}
function unavailable(): LocalApiResponse {
return Object.freeze({
statusCode: 503,
body: Object.freeze({ code: 'run_list_unavailable' }),
});
}
export function createLocalApiRunListRoute(
runs: ProjectRunListReader,
): Readonly<LocalApiRunListRoute> {
if (!runs || typeof runs.listRunsByProject !== 'function') {
throw new TypeError('Local API Run list repository is invalid');
}
return Object.freeze({
async handle(request: Readonly<LocalApiRunListRequest>) {
try {
const result = await executeBoundedRunListProjection(
runs,
request.projectId,
request.input,
);
return Object.freeze({
statusCode: 200,
body: Object.freeze({ ...result }),
});
} catch (error) {
if (
error instanceof InvalidBoundedRunListProjectionError ||
error instanceof BoundedRunListProjectionUnavailableError
) {
return unavailable();
}
throw error;
}
},
});
}