import { definePlugin, createPaginatedPluginMethod, } from "../../../utils/plugin-utils";
import { ListTriggersSchema } from "./schemas";
import { ActionItemSchema } from "../../../schemas/Action";
import { appKeyResolver } from "../../../resolvers";
import { triggersDefaults } from "../shared";
import { DEFAULT_PAGE_SIZE } from "../../../constants";
export const listTriggersPlugin = definePlugin((sdk) => createPaginatedPluginMethod(sdk, {
    ...triggersDefaults,
    name: "listTriggers",
    type: "list",
    itemType: "Action",
    inputSchema: ListTriggersSchema,
    outputSchema: ActionItemSchema,
    defaultPageSize: DEFAULT_PAGE_SIZE,
    resolvers: { app: appKeyResolver },
    handler: async ({ sdk, options, }) => {
        // Thin pass-through to listActions with actionType pinned to "read".
        // Awaiting the paginated method returns the first page.
        const result = await sdk.listActions({
            ...options,
            actionType: "read",
        });
        return { data: result.data, nextCursor: result.nextCursor };
    },
}));
