"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 destination = {
    name: 'Schematic',
    slug: 'actions-schematic',
    mode: 'cloud',
    description: 'Send Segment events to Schematic to enrich/update user and company profiles.',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                type: 'password',
                label: 'API Key',
                description: 'Found on your settings page.',
                required: true
            }
        },
        testAuthentication: (request, { settings }) => {
            return request(`https://api.schematichq.com/environments`, {
                method: 'GET',
                headers: { 'X-Schematic-Api-Key': `${settings.apiKey}` }
            });
        }
    },
    actions: {
        trackEvent: trackEvent_1.default,
        identifyUser: identifyUser_1.default
    },
    presets: [
        {
            name: 'Track Event',
            subscribe: 'type = "track"',
            partnerAction: 'trackEvent',
            mapping: (0, actions_core_1.defaultValues)(trackEvent_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'
        }
    ],
    extendRequest: ({ settings }) => {
        return {
            headers: { Authorization: `Bearer ${settings.apiKey}` }
        };
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map