import { z } from "zod";
import { AppKeyPropertySchema, AppPropertySchema, ActionTypePropertySchema, ActionKeyPropertySchema, ActionPropertySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, AuthenticationIdPropertySchema, InputsPropertySchema, ActionTimeoutMsPropertySchema, } from "../../types/properties";
const RunActionDescription = "Execute an action with the given inputs";
// Base schema for shared properties
const RunActionBaseSchema = z.object({
    connection: ConnectionPropertySchema.optional().describe("Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."),
    connectionId: ConnectionIdPropertySchema.nullable()
        .optional()
        .describe("Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service.")
        .meta({ deprecated: true }),
    /** @deprecated Use connection instead */
    authenticationId: AuthenticationIdPropertySchema.nullable()
        .optional()
        .meta({ deprecated: true }),
    inputs: InputsPropertySchema.optional().describe("Input parameters for the action"),
    timeoutMs: ActionTimeoutMsPropertySchema,
    pageSize: z.number().min(1).optional().describe("Number of results per page"),
    maxItems: z
        .number()
        .min(1)
        .optional()
        .describe("Maximum total items to return across all pages"),
    cursor: z.string().optional().describe("Cursor to start from"),
});
// Schema for docs/registry (new param names only)
export const RunActionSchema = z
    .object({
    app: AppPropertySchema,
    actionType: ActionTypePropertySchema,
    action: ActionPropertySchema,
})
    .merge(RunActionBaseSchema)
    .describe(RunActionDescription)
    .meta({
    aliases: {
        appKey: "app",
        actionKey: "action",
        connectionId: "connection",
        authenticationId: "connection",
    },
});
// Deprecated schema (backward compat)
const RunActionSchemaDeprecated = z
    .object({
    appKey: AppKeyPropertySchema,
    actionType: ActionTypePropertySchema,
    actionKey: ActionKeyPropertySchema,
})
    .merge(RunActionBaseSchema);
// Union for runtime validation (accepts either new or old names)
export const RunActionInputSchema = z
    .union([RunActionSchema, RunActionSchemaDeprecated])
    .describe(RunActionDescription);
