"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cartFields_1 = require("../fields/cartFields");
const commonFields_1 = require("../fields/commonFields");
const customerFields_1 = require("../fields/customerFields");
const formFields_1 = require("../fields/formFields");
const routes_1 = require("../routes");
const transform_payload_1 = require("./transform-payload");
const action = {
    title: 'Save Form Event',
    description: 'Save a form event.',
    fields: {
        ...commonFields_1.commonFields,
        ...customerFields_1.customerFields,
        ...cartFields_1.cartFields,
        ...formFields_1.formFields,
        eventName: {
            label: 'Form Event Name',
            type: 'string',
            description: 'The name of the Form Event to track.',
            required: true,
            readOnly: true,
            choices: [{ label: 'form_submitted', value: 'form_submitted' }],
            default: 'form_submitted'
        }
    },
    perform: (request, data) => {
        const transformedPayload = (0, transform_payload_1.transformPayload)(data.payload);
        const payload = {
            src: 'SEGMENT',
            data: [transformedPayload]
        };
        return request(routes_1.baseURL + (0, routes_1.eventsEndpoint)(data.settings.workspaceId), {
            method: 'post',
            json: payload
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map