"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const actions_core_1 = require("@segment/actions-core");
const trackEvent_1 = __importDefault(require("./trackEvent"));
const identifyUser_1 = __importDefault(require("./identifyUser"));
const groupUser_1 = __importDefault(require("./groupUser"));
const trackPageView_1 = __importDefault(require("./trackPageView"));
const destination = {
    name: 'Roadway AI',
    slug: 'roadwayai-actions',
    mode: 'cloud',
    description: 'Send browser events (identify, group, track, etc.) to your RoadwayAI workspace.',
    presets: [
        {
            name: 'Track Event',
            subscribe: 'type = "track"',
            partnerAction: 'trackEvent',
            mapping: (0, actions_core_1.defaultValues)(trackEvent_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Track Page View',
            subscribe: 'type = "page"',
            partnerAction: 'trackPageView',
            mapping: (0, actions_core_1.defaultValues)(trackPageView_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Identify User',
            subscribe: 'type = "identify"',
            partnerAction: 'identifyUser',
            mapping: (0, actions_core_1.defaultValues)(identifyUser_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Group User',
            subscribe: 'type = "group"',
            partnerAction: 'groupUser',
            mapping: (0, actions_core_1.defaultValues)(groupUser_1.default.fields),
            type: 'automatic'
        }
    ],
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                label: 'API Key',
                description: 'Your RoadwayAI API key for authentication',
                type: 'password',
                required: true
            }
        },
        testAuthentication: (request, { settings }) => {
            return request(`https://production.api.roadwayai.com/api/v1/segment/validate-credentials`, {
                method: 'POST',
                body: JSON.stringify({
                    api_key: settings.apiKey
                })
            });
        }
    },
    actions: {
        groupUser: groupUser_1.default,
        trackEvent: trackEvent_1.default,
        identifyUser: identifyUser_1.default,
        trackPageView: trackPageView_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map