"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 productVariantFields_1 = require("../fields/productVariantFields");
const routes_1 = require("../routes");
const transform_payload_1 = require("./transform-payload");
const action = {
    title: 'Save Product Event',
    description: 'Save a product event.',
    fields: {
        ...commonFields_1.commonFields,
        ...customerFields_1.customerFields,
        ...cartFields_1.cartFields,
        ...productVariantFields_1.productVariantFields,
        eventName: {
            label: 'Product Event Name',
            type: 'string',
            description: 'The name of the Product event to track.',
            required: true,
            readOnly: true,
            choices: [{ label: 'product_viewed', value: 'product_viewed' }],
            default: 'product_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