"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sendData_1 = __importDefault(require("./sendData"));
const trackEvents_1 = __importDefault(require("./trackEvents"));
const actions_core_1 = require("@segment/actions-core");
const consts_1 = require("./consts");
const destination = {
    name: 'Blend Ai',
    slug: 'actions-blend-ai',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                type: 'password',
                label: 'API Key',
                description: 'Blend API key - found on integration page.',
                required: true
            }
        },
        testAuthentication: (request) => request(consts_1.BASE_URL + 'authenticate')
    },
    onDelete: async (request, { payload }) => request(consts_1.BASE_URL + 'delete', {
        method: 'post',
        json: { external_ids: [payload.userId] }
    }),
    extendRequest: ({ settings }) => {
        return {
            method: 'POST',
            headers: { Authorization: `Bearer ${settings.apiKey}` },
            json: { apiKey: settings.apiKey }
        };
    },
    presets: [
        {
            name: 'Send Data to Blend',
            subscribe: 'type = "identify" or type = "page" or type = "screen" or type = "track"',
            partnerAction: 'trackEvents',
            mapping: (0, actions_core_1.defaultValues)(trackEvents_1.default.fields),
            type: 'automatic'
        }
    ],
    actions: {
        sendData: sendData_1.default,
        trackEvents: trackEvents_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map