import { z } from "zod";
import { withPositional } from "../utils/schema-utils";
import { MAX_PAGE_LIMIT, DEFAULT_ACTION_TIMEOUT_MS } from "../constants";
// Shared property definitions for common parameters across functions
// These can be reused in function schemas without duplication
export const AppKeyPropertySchema = withPositional(z
    .string()
    .min(1)
    .describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')"));
export const AppPropertySchema = withPositional(z
    .string()
    .min(1)
    .describe("App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"));
export const ActionTypePropertySchema = z
    .enum([
    "read",
    "read_bulk",
    "write",
    "run",
    "search",
    "search_or_write",
    "search_and_write",
    "filter",
])
    .describe("Action type that matches the action's defined type");
export const ActionKeyPropertySchema = z
    .string()
    .min(1)
    .describe("Action key to execute");
export const ActionPropertySchema = withPositional(z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')"));
export const InputFieldPropertySchema = withPositional(z.string().min(1).describe("Input field key to get choices for"));
export const ConnectionIdPropertySchema = z
    .union([z.string(), z.number().int().positive()])
    .describe("Connection ID to use for this action");
/** @deprecated Use ConnectionIdPropertySchema instead */
export const AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
    deprecated: true,
});
export const ConnectionPropertySchema = z
    .union([z.string(), z.number().int().positive()])
    .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.");
export const InputsPropertySchema = z
    .record(z.string(), z.unknown())
    .describe("Input parameters for the action");
export const LimitPropertySchema = z
    .number()
    .int()
    .min(1)
    .max(MAX_PAGE_LIMIT)
    .default(50)
    .describe("Maximum number of items to return");
export const OffsetPropertySchema = z
    .number()
    .int()
    .min(0)
    .default(0)
    .describe("Number of items to skip for pagination");
export const OutputPropertySchema = z.string().describe("Output file path");
export const DebugPropertySchema = z
    .boolean()
    .default(false)
    .describe("Enable debug logging");
export const ParamsPropertySchema = z
    .record(z.string(), z.unknown())
    .describe("Additional parameters");
export const ActionTimeoutMsPropertySchema = z
    .number()
    .min(1000)
    .optional()
    .describe(`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`);
export const TablePropertySchema = withPositional(z
    .string()
    .regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
    .describe("The unique identifier of the table"));
export const RecordPropertySchema = withPositional(z
    .string()
    .regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")
    .describe("The unique identifier of the record"));
export const RecordsPropertySchema = z
    .array(z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID"))
    .min(1)
    .max(100)
    .describe("Record IDs to operate on");
export const FieldsPropertySchema = z
    .array(z.union([z.string(), z.number()]))
    .describe('Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).');
export const AppsPropertySchema = z
    .array(z.string())
    .describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
export const TablesPropertySchema = z
    .array(z.string())
    .describe("Filter by specific table IDs");
export const ConnectionsPropertySchema = z
    .array(z.string())
    .describe("List of connection IDs to filter by");
export const TriggerInboxPropertySchema = withPositional(z
    .string()
    .min(1)
    .describe("Trigger inbox identifier — UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."));
export const TriggerInboxNamePropertySchema = z
    .string()
    .min(1)
    .max(100)
    .describe("Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox.");
export const LeasePropertySchema = z
    .string()
    .min(1)
    .describe("Lease ID returned from leaseTriggerInboxMessages");
export const LeaseSecondsPropertySchema = z
    .number()
    .int()
    .min(1)
    .max(3600)
    .describe("Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes).");
export const LeaseLimitPropertySchema = z
    .number()
    .int()
    .min(1)
    .max(100)
    .describe("Maximum messages to lease in a single batch (1-100)");
