import type { SerializedCookie } from "./types.js"; export type RecordedCommandJsonPrimitive = string | number | boolean | null; export type RecordedCommandJsonSchemaType = "array" | "boolean" | "integer" | "null" | "number" | "object" | "string"; export type RecordedCommandJsonSchema = boolean | { $schema?: string; additionalProperties?: boolean | RecordedCommandJsonSchema; allOf?: RecordedCommandJsonSchema[]; anyOf?: RecordedCommandJsonSchema[]; const?: RecordedCommandJsonPrimitive; description?: string; enum?: RecordedCommandJsonPrimitive[]; items?: RecordedCommandJsonSchema | RecordedCommandJsonSchema[]; oneOf?: RecordedCommandJsonSchema[]; properties?: Record; required?: string[]; type?: RecordedCommandJsonSchemaType | RecordedCommandJsonSchemaType[]; }; export type RecordedCommandVariableValue = RecordedCommandJsonPrimitive | RecordedCommandVariableValue[] | { [key: string]: RecordedCommandVariableValue; }; export interface RecordedCommandVariable { name: string; description: string; type: "input" | "output"; /** * 变量值的 JSON Schema。第三方调用方可在执行前读取 command.json, * 直接获得对象、数组等结构化入参/出参契约。 */ jsonSchema?: RecordedCommandJsonSchema; /** * 仅对 input 变量有意义:是否必填。 * - `true/undefined`: 必填(兼容历史数据,默认视为必填) * - `false`: 可选 */ required?: boolean; /** * 仅对 output 变量有意义。 * - `value/undefined`: 从 sourcePath 读取值。 * - `exists`: 判断 sourcePath 指向的对象中是否存在 sourceKeyTemplate 对应的 key。 * - `list`: 从 sourcePath 读取数组,并保留为结构化列表。 */ sourceKind?: "value" | "exists" | "list"; sourceKeyTemplate?: string; sourceStepIndex?: number; sourcePath?: string; } export interface RecordedCommandStep { method: string; pathTemplate: string; headers?: Record; bodyTemplate?: unknown; bodyContentType?: string; pagination?: { type: "page_num"; pageNumberPath: string; totalPagesPath?: string; hasMorePath?: string; dedupeByPath?: string; startPage?: number; }; responseSummary?: string; isFileUpload?: boolean; } export interface RecordedCommand { name: string; description: string; createdAt: string; /** @deprecated 执行时使用当前登录用户的 projectOrigin,命令文件不再持久化该字段。 */ projectOrigin?: string; steps: RecordedCommandStep[]; variables: RecordedCommandVariable[]; } export type RecordedCommandSource = "local" | "builtin"; export type ListedRecordedCommand = RecordedCommand & { overridesBuiltin?: boolean; source: RecordedCommandSource; }; export declare function getCommandsDir(homeDir: string): string; export declare function getCommandFilePath(homeDir: string, name: string): string; export declare const RECORDED_COMMAND_NAME_ERROR = "\u547D\u4EE4\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u8FDE\u5B57\u7B26\u548C\u4E0B\u5212\u7EBF"; export declare function assertValidRecordedCommandName(name: string): void; export declare function loadRecordedCommand(homeDir: string, name: string): Promise; export declare function loadAvailableRecordedCommand(homeDir: string, name: string): Promise<{ command: RecordedCommand; source: RecordedCommandSource; }>; export declare function saveRecordedCommand(homeDir: string, command: RecordedCommand): Promise; export declare function listRecordedCommands(homeDir: string): Promise; export declare function listAvailableRecordedCommands(homeDir: string): Promise; export declare function deleteRecordedCommand(homeDir: string, name: string): Promise; export declare function substituteVariables(template: string, variables: Record): string; export declare function substituteBodyVariables(bodyTemplate: unknown, variables: Record): unknown; export declare function getByPath(obj: unknown, path: string): unknown; export declare function extractByPath(obj: unknown, path: string): string | undefined; export declare function executeRecordedStep(options: { cookies: SerializedCookie[]; fetchImpl?: typeof fetch; projectOrigin: string; step: RecordedCommandStep; variables: Record; }): Promise<{ status: number; data: unknown; }>; //# sourceMappingURL=recorded-command.d.ts.map