"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 sendTrackEvent_1 = __importDefault(require("./sendTrackEvent"));
const sendIdentifyEvent_1 = __importDefault(require("./sendIdentifyEvent"));
const sendGroupEvent_1 = __importDefault(require("./sendGroupEvent"));
const sendPageEvent_1 = __importDefault(require("./sendPageEvent"));
const sendScreenEvent_1 = __importDefault(require("./sendScreenEvent"));
const api_1 = require("./api");
const destination = {
    name: 'Canvas',
    slug: 'actions-canvas',
    mode: 'cloud',
    description: 'Send your Segment data to Canvas',
    authentication: {
        scheme: 'custom',
        fields: {
            apiToken: {
                label: 'API Token',
                description: 'API token generated by Canvas',
                type: 'password',
                required: true
            }
        },
        testAuthentication: (request) => {
            return request((0, api_1.getAuthUrl)(), {
                method: 'post'
            });
        }
    },
    extendRequest({ settings }) {
        return {
            headers: {
                'X-Auth-Token': settings.apiToken
            }
        };
    },
    presets: [
        {
            name: sendTrackEvent_1.default.title,
            subscribe: 'type = "track"',
            partnerAction: 'sendTrackEvent',
            mapping: (0, actions_core_1.defaultValues)(sendTrackEvent_1.default.fields),
            type: 'automatic'
        },
        {
            name: sendIdentifyEvent_1.default.title,
            subscribe: 'type = "identify"',
            partnerAction: 'sendIdentifyEvent',
            mapping: (0, actions_core_1.defaultValues)(sendIdentifyEvent_1.default.fields),
            type: 'automatic'
        },
        {
            name: sendGroupEvent_1.default.title,
            subscribe: 'type = "group"',
            partnerAction: 'sendGroupEvent',
            mapping: (0, actions_core_1.defaultValues)(sendGroupEvent_1.default.fields),
            type: 'automatic'
        },
        {
            name: sendPageEvent_1.default.title,
            subscribe: 'type = "page"',
            partnerAction: 'sendPageEvent',
            mapping: (0, actions_core_1.defaultValues)(sendPageEvent_1.default.fields),
            type: 'automatic'
        },
        {
            name: sendScreenEvent_1.default.title,
            subscribe: 'type = "screen"',
            partnerAction: 'sendScreenEvent',
            mapping: (0, actions_core_1.defaultValues)(sendScreenEvent_1.default.fields),
            type: 'automatic'
        }
    ],
    actions: {
        sendTrackEvent: sendTrackEvent_1.default,
        sendIdentifyEvent: sendIdentifyEvent_1.default,
        sendGroupEvent: sendGroupEvent_1.default,
        sendPageEvent: sendPageEvent_1.default,
        sendScreenEvent: sendScreenEvent_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map