"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const client_1 = require("./client");
const constants_1 = require("./constants");
const syncEvents_1 = __importDefault(require("./syncEvents"));
const syncModelToSFTP_1 = __importDefault(require("./syncModelToSFTP"));
const destination = {
    name: 'SFTP',
    slug: 'actions-sftp',
    mode: 'cloud',
    description: 'Sync Segment events to SFTP',
    authentication: {
        scheme: 'custom',
        fields: {
            auth_type: {
                label: 'Authentication Type',
                description: 'The type of authentication to use for the SFTP connection',
                type: 'string',
                choices: [
                    { label: 'Username and Password', value: 'password' },
                    { label: 'Username and SSH Key', value: 'ssh_key' }
                ],
                default: 'password',
                required: true
            },
            sftp_host: {
                label: 'SFTP Host',
                description: 'The hostname or IP address of the SFTP server',
                type: 'string',
                required: true
            },
            sftp_port: {
                label: 'SFTP Port',
                description: 'The port number for the SFTP connection',
                type: 'number',
                required: false,
                default: constants_1.SFTP_DEFAULT_PORT
            },
            sftp_username: {
                label: 'Username',
                description: 'Username for establishing an SFTP connection',
                type: 'string',
                required: true
            },
            sftp_password: {
                label: 'Password',
                description: 'Password for establishing an SFTP connection',
                type: 'password',
                required: {
                    conditions: [
                        {
                            fieldKey: 'auth_type',
                            operator: 'is',
                            value: 'password'
                        }
                    ]
                },
                depends_on: {
                    conditions: [
                        {
                            fieldKey: 'auth_type',
                            operator: 'is',
                            value: 'password'
                        }
                    ]
                }
            },
            sftp_ssh_key: {
                label: 'SSH Key',
                description: 'SSH Key for establishing an SFTP connection',
                type: 'password',
                required: {
                    conditions: [
                        {
                            fieldKey: 'auth_type',
                            operator: 'is',
                            value: 'ssh_key'
                        }
                    ]
                },
                depends_on: {
                    conditions: [
                        {
                            fieldKey: 'auth_type',
                            operator: 'is',
                            value: 'ssh_key'
                        }
                    ]
                }
            },
            uploadStrategy: {
                label: 'Upload Strategy',
                description: 'Select the upload strategy to use when uploading files to the SFTP server.',
                type: 'string',
                choices: [
                    { label: 'Standard [Supported by all SFTP servers]', value: constants_1.UploadStrategy.STANDARD },
                    {
                        label: 'Concurrent [Improves upload time but may not be supported by all SFTP servers. Test and enable if supported.]',
                        value: constants_1.UploadStrategy.CONCURRENT
                    }
                ],
                default: constants_1.UploadStrategy.STANDARD,
                required: false
            }
        },
        testAuthentication: async (_, { settings }) => await (0, client_1.testSFTPConnection)(settings)
    },
    actions: {
        syncEvents: syncEvents_1.default,
        syncModelToSFTP: syncModelToSFTP_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map