import type { PlatformActionHandler } from "./platform-action-registry.js"; export interface PlatformHttpStringParamRule { type: "string"; required?: boolean; allowEmpty?: boolean; values?: readonly string[]; default?: string; minLength?: number; maxLength?: number; } export interface PlatformHttpIntegerParamRule { type: "integer"; required?: boolean; values?: readonly number[]; default?: number; min?: number; max?: number; } export interface PlatformHttpBooleanParamRule { type: "boolean"; required?: boolean; default?: boolean; } export interface PlatformHttpArrayParamRule { type: "string_array" | "integer_array"; required?: boolean; minItems?: number; maxItems?: number; } export interface PlatformHttpObjectArrayParamRule { type: "object_array"; required?: boolean; minItems?: number; maxItems?: number; properties: Readonly>; } export type PlatformHttpActionParamRule = PlatformHttpStringParamRule | PlatformHttpIntegerParamRule | PlatformHttpBooleanParamRule | PlatformHttpArrayParamRule | PlatformHttpObjectArrayParamRule; type PlatformHttpQueryParamRule = Exclude; export interface PlatformHttpConditionalRequirement { param: string; equals: string | number | boolean; required: readonly string[]; } interface PlatformHttpActionRouteBase { path: string; /** 每个字段组都必须至少提供一项。 */ atLeastOne?: readonly (readonly string[])[]; /** 指定枚举分支的附加必填字段。 */ requiredWhen?: readonly PlatformHttpConditionalRequirement[]; } export interface PlatformHttpGetActionRoute extends PlatformHttpActionRouteBase { method: "GET"; params: Readonly>; } export interface PlatformHttpPostActionRoute extends PlatformHttpActionRouteBase { method: "POST"; params: Readonly>; /** 少数官方 POST 接口同时要求 query 与 JSON body。 */ queryParams?: Readonly>; } export type PlatformHttpActionRoute = PlatformHttpGetActionRoute | PlatformHttpPostActionRoute; type PlatformHttpScalar = string | number | boolean; type PlatformHttpObject = Readonly>; type PlatformHttpActionValue = PlatformHttpScalar | string[] | number[] | PlatformHttpObject[]; export type PlatformHttpActionRequest = { method: "GET"; path: string; query: Readonly>; } | { method: "POST"; path: string; query?: Readonly>; body: Readonly>; }; export type PlatformHttpActionValidationIssue = { kind: "unknown"; action: string; parameter: string; } | { kind: "required"; action: string; parameters: readonly string[]; source: "field" | "at_least_one" | "condition"; condition?: PlatformHttpConditionalRequirement; } | { kind: "invalid"; action: string; parameter: string; value: unknown; rule: PlatformHttpActionParamRule; }; export type PlatformHttpActionInvoker = (context: TContext, request: PlatformHttpActionRequest) => Promise; /** * 将声明式 HTTP 路由编译成闭合的平台动作 handler。 * * 模块统一负责字段白名单、类型、范围、one-of 与条件必填;平台适配器只需声明路由、 * 注入真实 HTTP 调用并把验证问题映射成平台错误。 */ export declare function definePlatformHttpActionRoutes(routes: Readonly>, invoke: PlatformHttpActionInvoker, invalid: (issue: PlatformHttpActionValidationIssue) => Error): Readonly>>; export {};