"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DynamoDBPlugin = void 0;
const index_js_1 = require("../../types/index.js");
const index_js_2 = require("../../utils/index.js");
const constants_js_1 = require("./constants.js");
const index_js_3 = require("./shared/index.js");
const DynamoDBActions = [
    'getItem',
    'updateItem',
    'putItem',
    'deleteItem',
    'query',
    'scan',
    'executeStatement',
    'executeTransaction',
    'listTagsOfResource',
    'tagResource',
    'listTables',
    'describeTable',
    'createTable',
    'updateTable',
    'deleteTable',
    'batchWriteItem'
    // "batchExecuteStatement",
    // "batchGetItem",
    // "createBackup",
    // "createGlobalTable",
    // "deleteBackup",
    // "describeBackup",
    // "describeContinuousBackups",
    // "describeContributorInsights",
    // "describeEndpoints",
    // "describeExport",
    // "describeGlobalTable",
    // "describeGlobalTableSettings",
    // "describeKinesisStreamingDestination",
    // "describeLimits",
    // "describeTableReplicaAutoScaling",
    // "describeTimeToLive",
    // "disableKinesisStreamingDestination",
    // "enableKinesisStreamingDestination",
    // "exportTableToPointInTime",
    // "listBackups",
    // "listContributorInsights",
    // "listExports",
    // "listGlobalTables",
    // "restoreTableFromBackup",
    // "restoreTableToPointInTime",
    // "transactGetItems",
    // "transactWriteItems",
    // "untagResource",
    // "updateContinuousBackups",
    // "updateContributorInsights",
    // "updateGlobalTable",
    // "updateGlobalTableSettings",
    // "updateTableReplicaAutoScaling",
    // "updateTimeToLive",
    // "waitFor",
];
function getDynamoDBActionDropdownOptions() {
    return DynamoDBActions.map((method) => {
        const displayName = (0, index_js_2.camelCaseToDisplay)(method);
        return {
            key: method,
            value: method,
            displayName: displayName
        };
    });
}
const DynamoDBPluginVersions = {
    V1: '0.0.1',
    V4: '0.0.4',
    V5: '0.0.5'
};
exports.DynamoDBPlugin = {
    id: 'dynamodb',
    name: 'Amazon DynamoDB',
    moduleName: 'DynamoDBPlugin',
    modulePath: 'plugins/dynamodb/DynamoDBPlugin',
    iconLocation: `${constants_js_1.PUBLIC_INTEGRATIONS_LOGO_URL}/dynamodb.png`,
    docsUrl: `${constants_js_1.DOCS_BASE_URL}/aws-dynamodb`,
    type: index_js_1.PluginType.DB,
    responseType: index_js_1.PluginResponseType.JSON,
    hasRawRequest: true,
    hasMetadata: true,
    rawRequestName: 'Executed query',
    datasourceTemplate: {
        sections: [
            {
                name: 'main',
                items: [
                    {
                        label: 'Display name',
                        name: 'name',
                        startVersion: DynamoDBPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        rules: [{ required: true, message: 'Display name is required' }]
                    },
                    {
                        label: 'Region',
                        name: 'authentication.custom.region.value',
                        startVersion: DynamoDBPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        agentType: index_js_1.AgentType.MULTITENANT
                    },
                    {
                        label: 'Access key ID',
                        name: 'authentication.custom.accessKeyID.value',
                        startVersion: DynamoDBPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        agentType: index_js_1.AgentType.MULTITENANT
                    },
                    {
                        label: 'Secret key',
                        name: 'authentication.custom.secretKey.value',
                        startVersion: DynamoDBPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        dataType: index_js_1.InputDataType.PASSWORD,
                        agentType: index_js_1.AgentType.MULTITENANT
                    },
                    {
                        label: 'IAM role ARN (optional)',
                        name: 'authentication.custom.iamRoleArn.value',
                        startVersion: DynamoDBPluginVersions.V5,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        agentType: index_js_1.AgentType.MULTITENANT,
                        rules: [{ required: false }]
                    }
                ]
            },
            (0, index_js_3.getAWSAuthSection)({ startVersion: DynamoDBPluginVersions.V4, startVersionForRoleAssumption: DynamoDBPluginVersions.V5 })
        ]
    },
    actionTemplate: {
        sections: [
            {
                name: 'main',
                items: [
                    {
                        label: 'Action',
                        name: 'action',
                        startVersion: DynamoDBPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.DROPDOWN,
                        initialValue: DynamoDBActions.length > 0 && DynamoDBActions[0],
                        options: getDynamoDBActionDropdownOptions()
                    },
                    {
                        label: 'Params',
                        name: 'body',
                        startVersion: DynamoDBPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.CODE_EDITOR,
                        language: index_js_1.EditorLanguage.JSON,
                        placeholder: `{
  "TableName": "ExampleTable",
  "Key": {
      "PK": "user#abc",
      "SK": "account#0123456789"
  },
  "ConditionExpression": "#balance > :amount",
  "ExpressionAttributeNames": {
      "#balance": "balance"
  },
  "ExpressionAttributeValues": {
      ":amount": { "N": "123" },
      ":zero": { "N": "0" },
  }
}`
                    }
                ]
            }
        ]
    }
};
//# sourceMappingURL=dynamodb.js.map