import { definePlugin, createPaginatedPluginMethod, } from "../../../utils/plugin-utils";
import { ListTriggerInputFieldChoicesSchema } from "./schemas";
import { InputFieldChoiceItemSchema, } from "../../listActionInputFieldChoices/schemas";
import { appKeyResolver, actionKeyResolver, connectionIdResolver, inputFieldKeyResolver, inputsAllOptionalResolver, } from "../../../resolvers";
import { triggersDefaults } from "../shared";
import { DEFAULT_PAGE_SIZE } from "../../../constants";
export const listTriggerInputFieldChoicesPlugin = definePlugin((sdk) => createPaginatedPluginMethod(sdk, {
    ...triggersDefaults,
    name: "listTriggerInputFieldChoices",
    type: "list",
    itemType: "InputFieldChoice",
    inputSchema: ListTriggerInputFieldChoicesSchema,
    outputSchema: InputFieldChoiceItemSchema,
    defaultPageSize: DEFAULT_PAGE_SIZE,
    resolvers: {
        app: appKeyResolver,
        action: actionKeyResolver,
        connection: connectionIdResolver,
        inputField: inputFieldKeyResolver,
        inputs: inputsAllOptionalResolver,
        actionType: { type: "constant", value: "read" },
    },
    handler: async ({ sdk, options, }) => {
        const result = await sdk.listActionInputFieldChoices({
            ...options,
            actionType: "read",
        });
        return { data: result.data, nextCursor: result.nextCursor };
    },
}));
