"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 actions_core_2 = require("@segment/actions-core");
const identify_1 = __importDefault(require("./identify"));
const track_1 = __importDefault(require("./track"));
const group_1 = __importDefault(require("./group"));
const page_1 = __importDefault(require("./page"));
const destination = {
    name: 'Usermaven (Actions)',
    slug: 'actions-usermaven',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            api_key: {
                type: 'password',
                label: 'API Key',
                description: 'Found on your general settings page.',
                required: true
            },
            server_token: {
                type: 'password',
                label: 'Server Token',
                description: 'Found on your general settings page.',
                required: true
            }
        },
        testAuthentication: (_, { settings }) => {
            if (!settings.api_key || settings.api_key.length === 0) {
                throw new actions_core_2.IntegrationError('API Key is required', 'Invalid API Key', 400);
            }
            if (!settings.server_token || settings.server_token.length === 0) {
                throw new actions_core_2.IntegrationError('Server Token is required', 'Invalid Server Token', 400);
            }
        }
    },
    presets: [
        {
            name: 'Track Event',
            subscribe: 'type = "track"',
            partnerAction: 'track',
            mapping: (0, actions_core_1.defaultValues)(track_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Identify User',
            subscribe: 'type = "identify"',
            partnerAction: 'identify',
            mapping: (0, actions_core_1.defaultValues)(identify_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Group',
            subscribe: 'type = "group"',
            partnerAction: 'group',
            mapping: (0, actions_core_1.defaultValues)(group_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Page',
            subscribe: 'type = "page"',
            partnerAction: 'page',
            mapping: (0, actions_core_1.defaultValues)(page_1.default.fields),
            type: 'automatic'
        }
    ],
    actions: {
        identify: identify_1.default,
        track: track_1.default,
        group: group_1.default,
        page: page_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map