"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 alias_1 = __importDefault(require("./alias"));
const event_1 = __importDefault(require("./event"));
const identify_1 = __importDefault(require("./identify"));
const destination = {
    name: 'Altertable',
    slug: 'actions-altertable',
    mode: 'cloud',
    description: 'Send events server-side to the [Altertable REST API](https://altertable.ai/docs/product-analytics/reference/api).',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                label: 'API Key',
                description: 'Your Altertable API key',
                type: 'password',
                required: true
            },
            environment: {
                label: 'Environment',
                description: 'The environment to send events to',
                type: 'string',
                required: true,
                default: 'production'
            },
            endpoint: {
                label: 'Endpoint',
                description: 'The endpoint to send events to',
                type: 'string',
                format: 'uri',
                required: true,
                default: 'https://api.altertable.ai'
            }
        }
    },
    extendRequest: ({ settings }) => {
        return {
            headers: {
                'X-API-Key': settings.apiKey,
                'Content-Type': 'application/json'
            }
        };
    },
    actions: {
        alias: alias_1.default,
        event: event_1.default,
        identify: identify_1.default
    },
    presets: [
        {
            name: 'Track',
            subscribe: 'type = "track"',
            partnerAction: 'event',
            mapping: (0, actions_core_1.defaultValues)(event_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Page View',
            subscribe: 'type = "page"',
            partnerAction: 'event',
            mapping: {
                ...(0, actions_core_1.defaultValues)(event_1.default.fields),
                event: '$pageview'
            },
            type: 'automatic'
        },
        {
            name: 'Screen View',
            subscribe: 'type = "screen"',
            partnerAction: 'event',
            mapping: {
                ...(0, actions_core_1.defaultValues)(event_1.default.fields),
                event: '$screen'
            },
            type: 'automatic'
        },
        {
            name: 'Identify',
            subscribe: 'type = "identify"',
            partnerAction: 'identify',
            mapping: (0, actions_core_1.defaultValues)(identify_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Alias',
            subscribe: 'type = "alias"',
            partnerAction: 'alias',
            mapping: (0, actions_core_1.defaultValues)(alias_1.default.fields),
            type: 'automatic'
        }
    ]
};
exports.default = destination;
//# sourceMappingURL=index.js.map