/**
 * Plugin schemas for listApps
 *
 * Imports base query schema from @zapier/zapier-sdk-core (sdkapi) and extends
 * with SDK-specific options.
 *
 * Note: The sdkapi endpoint uses ListAppsQuerySchema (HTTP query params),
 * but the SDK exposes ListAppsSchema (user-friendly options):
 * - ListAppsOptions accepts `appKeys` as array, `cursor`, `maxItems`
 * - ListAppsQuery accepts `appKeys` as comma-separated string, `offset`
 * - The plugin transforms between these formats
 */
import { z } from "zod";
import { AppsPropertySchema } from "../../types/properties";
// Import schemas and types from @zapier/zapier-sdk-core (sdkapi)
import { AppItemSchema as AppItemSchemaBase, ListAppsResponseSchema as ListAppsResponseSchemaBase, ListAppsQuerySchema as ListAppsQueryBase, } from "@zapier/zapier-sdk-core/v0/schemas/apps";
// Re-export for consumers
export { AppItemSchemaBase as AppItemSchema };
export { ListAppsResponseSchemaBase as ListAppsResponseSchema };
/**
 * SDK user-facing options for listApps
 *
 * Extends ListAppsQuerySchema from zapier-sdk-core with SDK-specific options:
 * - appKeys: array (not comma-separated string)
 * - cursor: pagination cursor (not offset)
 * - maxItems: SDK-specific pagination limit
 */
export const ListAppsSchema = ListAppsQueryBase.omit({
    offset: true,
    app_keys: true,
    page_size: true,
})
    .extend({
    // New name for appKeys
    apps: AppsPropertySchema.optional().describe("Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"),
    // Override appKeys to be an array instead of comma-separated string
    /** @deprecated Use `apps` instead. */
    appKeys: z
        .array(z.string())
        .optional()
        .describe("Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')")
        .meta({ deprecated: true }),
    // Override pageSize to make optional (base has default value)
    pageSize: z.number().min(1).optional().describe("Number of apps per page"),
    // SDK specific property for pagination/iterable helpers
    maxItems: z
        .number()
        .min(1)
        .optional()
        .describe("Maximum total items to return across all pages"),
    // SDK specific property for pagination/iterable helpers
    cursor: z.string().optional().describe("Cursor to start from"),
})
    .describe("List all available apps with optional filtering");
