@terra-money/hive-persistence
Advanced tools
Comparing version 0.0.2 to 0.0.3
/// <reference types="node" /> | ||
import { ComparisonOperator } from '@aws-sdk/client-dynamodb'; | ||
export declare const convertSortKeyToBigEndianBlob: (sk: string | number) => Buffer; | ||
export declare const convertSortKeyToBigEndianBlob: (sk: string | number | Buffer) => Buffer; | ||
export interface DynamoWhereClause { | ||
@@ -5,0 +5,0 @@ key: string; |
@@ -13,2 +13,6 @@ "use strict"; | ||
return buf; | ||
default: | ||
if (Buffer.isBuffer(sk)) | ||
return sk; | ||
throw new Error(`invalid sk ${sk}`); | ||
} | ||
@@ -15,0 +19,0 @@ }; |
/// <reference types="node" /> | ||
import { AttributeValue, DynamoDBClient } from '@aws-sdk/client-dynamodb'; | ||
import { CredentialProvider } from '@aws-sdk/types'; | ||
interface DynamoDBDriverOption { | ||
region: string; | ||
tableName: string; | ||
accessKeyId: string; | ||
secretAccessKey: string; | ||
accessKeyId?: string; | ||
secretAccessKey?: string; | ||
credentialProvider?: CredentialProvider; | ||
} | ||
@@ -15,3 +17,3 @@ interface DynamoAttributeDescriptor { | ||
tableName: string; | ||
constructor({ tableName, region, accessKeyId, secretAccessKey, }: DynamoDBDriverOption); | ||
constructor({ tableName, region, accessKeyId, secretAccessKey, credentialProvider, }: DynamoDBDriverOption); | ||
set<R = T>(pk: string, sk: string | number | Buffer, data: R): Promise<import("@aws-sdk/client-dynamodb").PutItemCommandOutput>; | ||
@@ -18,0 +20,0 @@ setBatch<R = T>(batchData: { |
@@ -8,10 +8,15 @@ "use strict"; | ||
class DynamoDBDriver { | ||
constructor({ tableName, region, accessKeyId, secretAccessKey, }) { | ||
constructor({ tableName, region, accessKeyId, secretAccessKey, credentialProvider, }) { | ||
const isUsingDefaultProvider = !!credentialProvider; | ||
const credentials = isUsingDefaultProvider | ||
? undefined | ||
: { | ||
accessKeyId, | ||
secretAccessKey, | ||
}; | ||
this.tableName = tableName; | ||
this.client = new client_dynamodb_1.DynamoDBClient({ | ||
credentialDefaultProvider: () => credentialProvider, | ||
region, | ||
credentials: { | ||
accessKeyId, | ||
secretAccessKey, | ||
}, | ||
credentials, | ||
}); | ||
@@ -18,0 +23,0 @@ } |
@@ -19,8 +19,9 @@ { | ||
"name": "@terra-money/hive-persistence", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"dependencies": { | ||
"@aws-sdk/client-dynamodb": "^3.18.0", | ||
"@aws-sdk/util-dynamodb": "^3.18.0", | ||
"@aws-sdk/types": "^3.18.0", | ||
"ioredis": "^4.27.6" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21559
334
4
+ Added@aws-sdk/types@^3.18.0