21 lines
1.3 KiB
TypeScript
21 lines
1.3 KiB
TypeScript
/*
|
|
* SPEC: PJ2026-010103 HWPOD 服务。
|
|
* 实现引用: draft-2026-07-20-hwpod-temporal-split。
|
|
* 责任: HWPOD API 的 Temporal 与迁移期 Cloud API 配置解析。
|
|
*/
|
|
|
|
import { createHwpodTemporalGateway } from "./temporal.ts";
|
|
|
|
export function hwpodRuntime(env: Record<string, string | undefined> = process.env) {
|
|
const address = String(env.HWPOD_TEMPORAL_ADDRESS ?? env.TEMPORAL_ADDRESS ?? "").trim();
|
|
const namespace = String(env.HWPOD_TEMPORAL_NAMESPACE ?? "unidesk").trim();
|
|
const taskQueue = String(env.HWPOD_TEMPORAL_TASK_QUEUE ?? "hwlab-v03-hwpod").trim();
|
|
const runtimeApiUrl = String(env.HWPOD_RUNTIME_API_URL ?? "").trim().replace(/\/+$/u, "");
|
|
const runtimeApiAuthorization = String(env.HWPOD_RUNTIME_API_AUTHORIZATION ?? "").trim();
|
|
if (!runtimeApiUrl) throw codedError("hwpod_runtime_api_url_required", "HWPOD_RUNTIME_API_URL is required");
|
|
if (!runtimeApiAuthorization) throw codedError("hwpod_runtime_api_authorization_required", "HWPOD_RUNTIME_API_AUTHORIZATION is required");
|
|
return { address, namespace, taskQueue, runtimeApiUrl, runtimeApiAuthorization, temporal: createHwpodTemporalGateway({ address, namespace, taskQueue }) };
|
|
}
|
|
|
|
function codedError(code: string, message: string) { return Object.assign(new Error(message), { code }); }
|