DynamoDB client that loves Deno - forked from chiefbiiko
import { createClient } from 'https://denopkg.com/ericdmoore/dynamodb-deno/mod.ts';
// config/credentials WILL NOT BE READ from the env/fs
// you MUST pass them in
// you can OPTIONALLY use chiefbiiko's other pkg to handle that if you like
//
// import { get as grabAwsCreds } from "https://denopkg.com/chiefbiiko/get-aws-config/mod.ts";
const dyno = createClient({ credentials: grabAwsCreds() });
// the client has all of DynamoDB's operations as camelCased async methods
const result = await dyno.listTables();
Philosophically I perfer my libraries to not escalate permissions. The
chiefbiiko
package is incredible, however, I prefer clarity over convenience.
It has some of automagically fetching credentials functions, and I leave those
to the user's application. As shown in the Usage documentation above;
it assumes the user can manage their own credentials, but if that it too
dificult, users can recreate a similar experience by leveraging the oother
chiefbiiko
package.
There have also been some non-material stylistic changes - since I intend to maintain this fork.
The goal for this project is to keep this project working until aws-sdk-js-v3/clients/client-dynamodb works via something like esm.sh
If you know of a deno package adapter service that works well with the offcial aws v3 dynamo client, please submit an issue to me so I can stop proping this package up, and just use the official one.
/** Generic document. */
export interface Doc {
[key: string]: any;
}
/** 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);
region?: string; // us-west-2
profile?: string; // default
canonicalUri?: string; // fx /path/to/somewhere
port?: number; // 80
host?: string; // localhost
}
/** Op options. */
export interface OpOptions {
wrapNumbers?: boolean; // wrap numbers to a special number value type? [false]
convertEmptyValues?: boolean; // convert empty strings and binaries? [false]
translateJSON?: boolean; // translate I/O JSON schemas? [true]
iteratePages?: boolean; // if a result is paged, async-iterate it? [true]
}
Creates a DynamoDB client.
The client supports all DynamoDB operations. Check the linked aws docs for info about parameters of a specific operation.
-
batchGetItem(params: Doc, options?: OpOptions): Promise<Doc>
-
batchWriteItem(params: Doc, options?: OpOptions): Promise<Doc>
-
createBackup(params: Doc, options?: OpOptions): Promise<Doc>
-
createGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>
-
deleteBackup(params: Doc, options?: OpOptions): Promise<Doc>
-
describeBackup(params: Doc, options?: OpOptions): Promise<Doc>
-
describeContinuousBackups(params: Doc, options?: OpOptions): Promise<Doc>
-
describeGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>
-
describeGlobalTableSettings(params: Doc, options?: OpOptions): Promise<Doc>
-
describeTable(params: Doc, options?: OpOptions): Promise<Doc>
-
describeTimeToLive(params: Doc, options?: OpOptions): Promise<Doc>
-
listGlobalTables(params: Doc, options?: OpOptions): Promise<Doc>
-
listTagsOfResource(params: Doc, options?: OpOptions): Promise<Doc>
-
query(params: Doc, options?: OpOptions): Promise<Doc | AsyncIterableIterator<Doc>>
-
restoreTableFromBackup(params: Doc, options?: OpOptions): Promise<Doc>
-
restoreTableToPointInTime(params: Doc, options?: OpOptions): Promise<Doc>
-
scan(params: Doc, options?: OpOptions): Promise<Doc | AsyncIterableIterator<Doc>>
-
transactGetItems(params: Doc, options?: OpOptions): Promise<Doc>
-
transactWriteItems(params: Doc, options?: OpOptions): Promise<Doc>
-
untagResource(params: Doc, options?: OpOptions): Promise<Doc>
-
updateContinuousBackups(params: Doc, options?: OpOptions): Promise<Doc>
-
updateGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>
-
updateGlobalTableSettings(params: Doc, options?: OpOptions): Promise<Doc>
-
updateTimeToLive(params: Doc, options?: OpOptions): Promise<Doc>