"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 sendSchemaToInspector_1 = __importDefault(require("./sendSchemaToInspector"));
const avo_types_1 = require("./sendSchemaToInspector/avo-types");
const destination = {
    name: 'Avo',
    slug: 'actions-avo',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                label: 'Avo Inspector API Key',
                description: 'Avo Inspector API Key can be found in the Inspector setup page on your source in Avo.',
                type: 'password',
                required: true
            },
            env: {
                label: 'Environment',
                description: 'Avo Inspector Environment',
                type: 'string',
                choices: Object.values(avo_types_1.Environment).map((environment) => ({ label: environment, value: environment })),
                default: avo_types_1.Environment.PROD,
                required: true
            },
            appVersionPropertyName: {
                label: 'App Version Property',
                description: 'If you send a custom event property on all events that contains the app version, please enter the name of that property here (e.g. “app_version”). If you do not have a custom event property for the app version, please leave this field empty.',
                type: 'string',
                required: false
            }
        },
        testAuthentication: (request, { settings }) => {
            const resp = request(`https://api.avo.app/auth/inspector/validate`, {
                method: 'post',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    apiKey: settings.apiKey
                })
            });
            return resp;
        }
    },
    presets: [
        {
            name: 'Track Schema From Event',
            subscribe: 'type = "track"',
            partnerAction: 'sendSchemaToInspector',
            mapping: (0, actions_core_1.defaultValues)(sendSchemaToInspector_1.default.fields),
            type: 'automatic'
        }
    ],
    actions: {
        sendSchemaToInspector: sendSchemaToInspector_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map