"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AWSSecretsManagerPlugin = void 0;
const index_js_1 = require("../../../types/index.js");
const constants_js_1 = require("../constants.js");
const AWSSecretsManagerVersions = {
    V1: '0.0.1'
};
exports.AWSSecretsManagerPlugin = {
    id: 'awssecretsmanager',
    name: 'AWS Secrets Manager',
    moduleName: 'AWSSecretsManagerPlugin',
    modulePath: '',
    iconLocation: `${constants_js_1.PUBLIC_INTEGRATIONS_LOGO_URL}/aws_secrets_manager.psd.png`,
    docsUrl: 'https://docs-legacy.superblocks.com/development-lifecycle/secrets/aws-secrets-manager',
    type: index_js_1.PluginType.DB,
    responseType: index_js_1.PluginResponseType.JSON,
    hasRawRequest: false,
    kind: index_js_1.IntegrationKind.SECRET,
    datasourceTemplate: {
        sections: [
            {
                name: 'main',
                items: [
                    {
                        label: '',
                        name: 'provider.config.case',
                        startVersion: AWSSecretsManagerVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        hidden: true,
                        initialValue: 'awsSecretsManager'
                    },
                    {
                        label: 'Prefix (optional)',
                        name: 'provider.config.value.prefix',
                        startVersion: AWSSecretsManagerVersions.V1,
                        placeholder: 'superblocks/production/',
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        tooltip: {
                            markdownText: 'If your secrets follow [hierarchical naming conventions](https://docs.aws.amazon.com/prescriptive-guidance/latest/secure-sensitive-data-secrets-manager-terraform/naming-convention.html), filter secrets in this store by this prefix. The prefix will be stripped when accessing the secret in Superblocks.'
                        }
                    },
                    {
                        label: 'Region',
                        name: 'provider.config.value.auth.region',
                        placeholder: 'us-west-2',
                        startVersion: AWSSecretsManagerVersions.V1,
                        rules: [{ required: true, message: 'Region is required' }],
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        tooltip: {
                            markdownText: 'The AWS region where the secrets are stored.'
                        }
                    }
                ]
            },
            {
                name: 'auth',
                items: [
                    {
                        label: 'Auth type',
                        name: 'provider.config.value.auth.config.case',
                        startVersion: AWSSecretsManagerVersions.V1,
                        componentType: index_js_1.FormComponentType.DROPDOWN,
                        initialValue: 'assumeRole',
                        rules: [{ required: true }],
                        tooltip: {
                            markdownText: 'Assume role authentication is currently only supported for on-premise deployments.',
                            iconType: index_js_1.TooltipIconType.INFO
                        },
                        options: [
                            {
                                displayName: 'Assume Role',
                                key: 'assumeRole',
                                value: 'assumeRole'
                            },
                            {
                                displayName: 'Access Key',
                                key: 'static',
                                value: 'static'
                            }
                        ]
                    },
                    {
                        label: 'IAM Role ARN',
                        name: 'provider.config.value.auth.config.value.roleArn',
                        placeholder: 'my_iam_role_arn',
                        startVersion: AWSSecretsManagerVersions.V1,
                        rules: [{ required: true, message: 'IAM role arn is required' }],
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        display: {
                            show: {
                                'provider.config.value.auth.config.case': ['assumeRole']
                            }
                        }
                    },
                    {
                        label: 'Access key ID',
                        name: 'provider.config.value.auth.config.value.accessKeyId',
                        placeholder: 'my_access_key_id',
                        startVersion: AWSSecretsManagerVersions.V1,
                        rules: [{ required: true, message: 'Access key ID is required' }],
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        display: {
                            show: {
                                'provider.config.value.auth.config.case': ['static']
                            }
                        }
                    },
                    {
                        label: 'Secret access key',
                        name: 'provider.config.value.auth.config.value.secretAccessKey',
                        placeholder: 'my_secret_access_key',
                        startVersion: AWSSecretsManagerVersions.V1,
                        rules: [{ required: true, message: 'Secret access key is required' }],
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        dataType: index_js_1.InputDataType.PASSWORD,
                        display: {
                            show: {
                                'provider.config.value.auth.config.case': ['static']
                            }
                        }
                    }
                ]
            },
            {
                name: 'cache',
                items: [
                    {
                        label: 'Enable caching',
                        name: 'cache',
                        startVersion: AWSSecretsManagerVersions.V1,
                        componentType: index_js_1.FormComponentType.CHECKBOX,
                        initialValue: true,
                        tooltip: {
                            markdownText: 'Superblocks will encrypt the secret values and cache them for the specified TTL.'
                        }
                    },
                    {
                        label: 'Cache TTL (seconds)',
                        name: 'ttl',
                        startVersion: AWSSecretsManagerVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        dataType: index_js_1.InputDataType.NUMBER,
                        placeholder: 'ttl (i.e. 86400)',
                        initialValue: 86400,
                        rules: [{ required: true, message: 'If caching is enabled, a TTL is required.' }],
                        display: {
                            show: {
                                cache: ['true']
                            }
                        },
                        tooltip: {
                            markdownText: 'When the TTL expires, the next execution will fetch the secret from the store.'
                        }
                    }
                ]
            }
        ]
    },
    actionTemplate: {
        sections: []
    }
};
//# sourceMappingURL=awsSecretsManager.js.map