feat: expose bounded Sub2API runtime events
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { defaultCodexPoolRuntimeTargetId } from "./runtime-target";
|
||||
|
||||
export type RuntimeAction = "list" | "get" | "errors" | "infrastructure" | "apply" | "delete";
|
||||
export type RuntimeAction = "list" | "get" | "errors" | "events" | "infrastructure" | "apply" | "delete";
|
||||
|
||||
export interface RuntimeOptions {
|
||||
action: RuntimeAction;
|
||||
@@ -29,8 +29,8 @@ export interface RuntimeOptions {
|
||||
|
||||
export function parseRuntimeOptions(args: string[]): RuntimeOptions {
|
||||
const [actionRaw = "list", ...rest] = args;
|
||||
if (!(["list", "get", "errors", "infrastructure", "apply", "delete"] as string[]).includes(actionRaw)) {
|
||||
throw new Error("runtime usage: list|get|errors|infrastructure|apply|delete [--account <name-or-id>|--accounts <selectors>|--select-configured-policy --account-type apikey [--exclude-accounts <selectors>]] [--recent 24h] [--group <name-or-id>|--all-groups] [--platform <name>] [--page-token <token>] [--since 24h] [--tail 50000] [--template <id>] [--kind temp-unschedulable|priority|account-name] [--priority <0-1000>|--name <account-name>] [--confirm] [--target <id>] [--json|--full|--raw]");
|
||||
if (!(["list", "get", "errors", "events", "infrastructure", "apply", "delete"] as string[]).includes(actionRaw)) {
|
||||
throw new Error("runtime usage: list|get|errors|events|infrastructure|apply|delete [--account <name-or-id>|--accounts <selectors>|--select-configured-policy --account-type apikey [--exclude-accounts <selectors>]] [--recent 24h] [--group <name-or-id>|--all-groups] [--platform <name>] [--page-token <token>] [--since 24h] [--tail 50000] [--template <id>] [--kind temp-unschedulable|priority|account-name] [--priority <0-1000>|--name <account-name>] [--confirm] [--target <id>] [--json|--full|--raw]");
|
||||
}
|
||||
let account: string | null = null;
|
||||
let accounts: string[] = [];
|
||||
@@ -137,9 +137,9 @@ export function parseRuntimeOptions(args: string[]): RuntimeOptions {
|
||||
if (kind === "account-name" && template !== null) throw new Error("runtime apply --kind account-name does not accept --template");
|
||||
if (kind !== "account-name" && name !== null) throw new Error("--name requires --kind account-name");
|
||||
if (action !== "apply" && template !== null) throw new Error(`runtime ${action} does not accept --template`);
|
||||
if (action !== "errors" && action !== "infrastructure" && (since !== "24h" || tail !== 50_000)) throw new Error(`runtime ${action} does not accept --since or --tail`);
|
||||
if (action !== "errors" && action !== "events" && action !== "infrastructure" && (since !== "24h" || tail !== 50_000)) throw new Error(`runtime ${action} does not accept --since or --tail`);
|
||||
if (!/^\d+[mhd]$/u.test(since)) throw new Error("--since must use <number>m, <number>h, or <number>d");
|
||||
if (["list", "get", "errors", "infrastructure"].includes(action) && confirm) throw new Error(`runtime ${action} does not accept --confirm`);
|
||||
if (["list", "get", "errors", "events", "infrastructure"].includes(action) && confirm) throw new Error(`runtime ${action} does not accept --confirm`);
|
||||
if ([full, raw, json].filter(Boolean).length > 1) throw new Error("use only one of --json, --full, or --raw");
|
||||
return { action, account, accounts, selectConfiguredPolicy, accountType, excludeAccounts, group, allGroups, platform, pageToken, template, kind, priority, name, confirm, full, raw, json, recent, since, tail, targetId };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user