"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GCPSecretsManagerPlugin = void 0;
const index_js_1 = require("../../../types/index.js");
const constants_js_1 = require("../constants.js");
const GCPSecretsManagerVersions = {
    V1: '0.0.1'
};
exports.GCPSecretsManagerPlugin = {
    id: 'gcpsecretsmanager',
    name: 'GCP Secrets Manager',
    moduleName: 'GCPSecretsManagerPlugin',
    modulePath: '',
    iconLocation: `${constants_js_1.PUBLIC_INTEGRATIONS_LOGO_URL}/secret_manager_1.png`,
    docsUrl: 'https://docs.superblocks.com/development-lifecycle/secrets/google-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: 'Project ID',
                        name: 'provider.config.value.projectId',
                        placeholder: 'project-12345',
                        startVersion: GCPSecretsManagerVersions.V1,
                        rules: [{ required: true, message: 'Project ID is required' }],
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        tooltip: {
                            markdownText: 'The project where the secrets are stored.'
                        }
                    },
                    {
                        label: 'Service account key',
                        name: 'provider.config.value.auth.config.value',
                        startVersion: GCPSecretsManagerVersions.V1,
                        // INPUT_AREA is broken (cannot be udpated after unfocus). Using
                        // code editor for now.
                        componentType: index_js_1.FormComponentType.CODE_EDITOR,
                        language: index_js_1.EditorLanguage.JSON,
                        placeholder: constants_js_1.SERVICE_ACCOUNT_GHOST_TEXT,
                        rules: [{ required: true, message: 'Service account key is required' }],
                        transformation: index_js_1.FormItemTransformation.BYTE_ARRAY
                    },
                    {
                        label: 'Enable caching',
                        name: 'cache',
                        startVersion: GCPSecretsManagerVersions.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: GCPSecretsManagerVersions.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.'
                        }
                    },
                    {
                        label: '',
                        name: 'provider.config.value.auth.config.case',
                        startVersion: GCPSecretsManagerVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        hidden: true,
                        initialValue: 'serviceAccount'
                    },
                    {
                        label: '',
                        name: 'provider.config.case',
                        startVersion: GCPSecretsManagerVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        hidden: true,
                        initialValue: 'gcpSecretManager'
                    }
                ]
            }
        ]
    },
    actionTemplate: {
        sections: []
    }
};
//# sourceMappingURL=gcpSecretsManager.js.map