<%- include('../partials/generatedHeader.ejs') -%>
<%- include('../partials/imports.ejs', { imports, helpers }) %>
import { requireContext } from "@prismatic-io/spectral/dist/serverTypes";

export interface <%= action.typeInterface %>Values {
<%- include('../partials/performArgs.ejs', { inputs: action.inputs, helpers }) -%>
}

/**
 * <%= action.label %>
 *
 * @description <%- action.description %>
 */
export const <%= action.import %> = {
  key: "<%= action.key %>",
  perform: async <TReturn>(
    values: <%= action.typeInterface %>Values
  ): Promise<TReturn> => {
    const context = requireContext();
    return await context.components.<%= helpers.camelCase(action.componentKey) %>.<%= action.import %>({ ...values }) as TReturn;
  },
  inputs: {
    <%- include('../partials/inputs.ejs', { inputs: action.inputs, helpers }) -%>
  },
  <%_ if (action.examplePayload) { -%>
  examplePayload: <%- typeof action.examplePayload === 'string' ? action.examplePayload : JSON.stringify(action.examplePayload, null, 2) %>,
  <%_ } -%>
} as const;