"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 createUsageEvent_1 = __importDefault(require("./createUsageEvent"));
const destination = {
    name: 'Lark',
    slug: 'actions-lark',
    mode: 'cloud',
    description: 'Send usage events to Lark for billing and metering purposes.',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                label: 'API Key',
                description: 'Your Lark API key. You can find this in your Lark dashboard.',
                type: 'password',
                required: true
            }
        },
        testAuthentication: async (request, { settings }) => {
            return request('https://api.uselark.ai/subjects', {
                method: 'get',
                headers: {
                    'X-API-Key': settings.apiKey
                }
            });
        }
    },
    extendRequest({ settings }) {
        return {
            headers: {
                'X-API-Key': settings.apiKey,
                'Content-Type': 'application/json'
            }
        };
    },
    actions: {
        createUsageEvent: createUsageEvent_1.default
    },
    presets: [
        {
            name: 'Send Usage Event to Lark',
            subscribe: 'type = "track"',
            partnerAction: 'createUsageEvent',
            mapping: (0, actions_core_1.defaultValues)(createUsageEvent_1.default.fields),
            type: 'automatic'
        }
    ]
};
exports.default = destination;
//# sourceMappingURL=index.js.map