"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.KOALA_PATH = void 0;
const actions_core_1 = require("@segment/actions-core");
const track_1 = __importDefault(require("./track"));
const identify_1 = __importDefault(require("./identify"));
exports.KOALA_PATH = process.env.NODE_ENV === 'development'
    ? 'http://localhost:3001/web/projects'
    : 'https://api2.getkoala.com/web/projects';
const presets = [
    {
        name: 'Track Calls',
        subscribe: 'type = "track"',
        partnerAction: 'track',
        mapping: (0, actions_core_1.defaultValues)(track_1.default.fields),
        type: 'automatic'
    },
    {
        name: 'Identify Calls',
        subscribe: 'type = "identify"',
        partnerAction: 'identify',
        mapping: (0, actions_core_1.defaultValues)(identify_1.default.fields),
        type: 'automatic'
    }
];
const destination = {
    name: 'Koala (Cloud)',
    slug: 'actions-koala-cloud',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            public_key: {
                label: 'Public Key',
                description: 'Your public key',
                type: 'password',
                required: true
            }
        },
        testAuthentication: (request, { settings }) => {
            return request(`${exports.KOALA_PATH}/${settings.public_key}/auth`, { method: 'get' });
        }
    },
    presets,
    actions: {
        track: track_1.default,
        identify: identify_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map