This commit is contained in:
Adria Navarro 2023-05-12 18:28:25 +02:00
parent cb398dad02
commit f2f0c2e708
1 changed files with 18 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import {
import AWS from "aws-sdk" import AWS from "aws-sdk"
import { AWS_REGION } from "../db/dynamoClient" import { AWS_REGION } from "../db/dynamoClient"
import { DocumentClient } from "aws-sdk/clients/dynamodb"
interface DynamoDBConfig { interface DynamoDBConfig {
region: string region: string
@ -128,7 +129,7 @@ const SCHEMA: Integration = {
class DynamoDBIntegration implements IntegrationBase { class DynamoDBIntegration implements IntegrationBase {
private config: DynamoDBConfig private config: DynamoDBConfig
private client: any private client
constructor(config: DynamoDBConfig) { constructor(config: DynamoDBConfig) {
this.config = config this.config = config
@ -148,7 +149,10 @@ class DynamoDBIntegration implements IntegrationBase {
this.client = new AWS.DynamoDB.DocumentClient(this.config) this.client = new AWS.DynamoDB.DocumentClient(this.config)
} }
async create(query: { table: string; json: object }) { async create(query: {
table: string
json: Omit<DocumentClient.PutItemInput, "TableName">
}) {
const params = { const params = {
TableName: query.table, TableName: query.table,
...query.json, ...query.json,
@ -189,7 +193,10 @@ class DynamoDBIntegration implements IntegrationBase {
return new AWS.DynamoDB(this.config).describeTable(params).promise() return new AWS.DynamoDB(this.config).describeTable(params).promise()
} }
async get(query: { table: string; json: object }) { async get(query: {
table: string
json: Omit<DocumentClient.GetItemInput, "TableName">
}) {
const params = { const params = {
TableName: query.table, TableName: query.table,
...query.json, ...query.json,
@ -197,7 +204,10 @@ class DynamoDBIntegration implements IntegrationBase {
return this.client.get(params).promise() return this.client.get(params).promise()
} }
async update(query: { table: string; json: object }) { async update(query: {
table: string
json: Omit<DocumentClient.UpdateItemInput, "TableName">
}) {
const params = { const params = {
TableName: query.table, TableName: query.table,
...query.json, ...query.json,
@ -205,7 +215,10 @@ class DynamoDBIntegration implements IntegrationBase {
return this.client.update(params).promise() return this.client.update(params).promise()
} }
async delete(query: { table: string; json: object }) { async delete(query: {
table: string
json: Omit<DocumentClient.DeleteItemInput, "TableName">
}) {
const params = { const params = {
TableName: query.table, TableName: query.table,
...query.json, ...query.json,