"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 routes_1 = require("../routes");
const transform_payload_1 = require("./transform-payload");
const action = {
    title: 'Save Base Event',
    description: 'Send a base event that has the basic fields applicable to all events.',
    fields: {
        ...commonFields_1.commonFields,
        ...customerFields_1.customerFields,
        ...cartFields_1.cartFields,
        eventName: {
            label: 'Event Name',
            type: 'string',
            description: 'The name of the event to track.',
            required: true,
            choices: [
                { label: 'page_viewed', value: 'page_viewed' },
                { label: 'cart_viewed', value: 'cart_viewed' }
            ]
        }
    },
    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