Skip to main content
Module

x/dynamodb/mod.ts

deno <3 dynamodb
Latest
File
import { baseOp, deriveConfig } from "./client/mod.ts";import { Doc, camelCase } from "./util.ts";
/** Convenience export. */export { Doc } from "./util.ts";
/** Generic representation of a DynamoDB client. */export interface DynamoDBClient { describeEndpoints: (options?: Doc) => Promise<Doc>; describeLimits: (options?: Doc) => Promise<Doc>; listTables: (options?: Doc) => Promise<Doc>; scan: ( params: Doc, options?: Doc, ) => Promise<Doc | AsyncIterableIterator<Doc>>; query: ( params: Doc, options?: Doc, ) => Promise<Doc | AsyncIterableIterator<Doc>>; [key: string]: (params: Doc, options?: Doc) => Promise<Doc>;}
/** Credentials. */export interface Credentials { accessKeyId: string; // AKIAIOSFODNN7EXAMPLE secretAccessKey: string; // wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY sessionToken?: string; // somesessiontoken}
/** Client configuration. */export interface ClientConfig { credentials?: Credentials | (() => Credentials | Promise<Credentials>); region?: string; // us-west-2 profile?: string; // default canonicalUri?: string; // fx /path/to/somewhere port?: number; // 80}
/** DynamoDB operations. */export const OPS: Set<string> = new Set<string>([ "BatchGetItem", "BatchWriteItem", "CreateBackup", "CreateGlobalTable", "CreateTable", "DeleteBackup", "DeleteItem", "DeleteTable", "DescribeBackup", "DescribeContinuousBackups", "DescribeEndpoints", "DescribeGlobalTable", "DescribeGlobalTableSettings", "DescribeLimits", "DescribeTable", "DescribeTimeToLive", "GetItem", "ListBackups", "ListGlobalTables", "ListTables", "ListTagsOfResource", "PutItem", "Query", "RestoreTableFromBackup", "RestoreTableToPointInTime", "Scan", "TagResource", "TransactGetItems", "TransactWriteItems", "UntagResource", "UpdateContinuousBackups", "UpdateGlobalTable", "UpdateGlobalTableSettings", "UpdateItem", "UpdateTable", "UpdateTimeToLive",]);
/** Creates a DynamoDB client. */export function createClient(conf?: ClientConfig): DynamoDBClient { const _conf: Doc = deriveConfig(conf);
const dyno: DynamoDBClient = {} as DynamoDBClient;
for (const op of OPS) { dyno[camelCase(op)] = baseOp.bind(null, _conf, op); }
return dyno;}