amazon-qldb-kvs-nodejs
Version:
A helper module, simplifying basic interactions with Amazon Quantum Ledger Database for Node.js through a simple key-value store interface.
51 lines (50 loc) • 2.69 kB
TypeScript
import { TransactionExecutor } from "amazon-qldb-driver-nodejs";
import { QLDB, ValueHolder } from "@aws-sdk/client-qldb";
import { dom } from "ion-js";
import { Base64EncodedString } from "./Util";
export interface LedgerMetadata {
LedgerName: string;
TableName: string;
BlockAddress: ValueHolder;
DocumentId: string;
RevisionHash: Base64EncodedString;
Proof: ValueHolder;
LedgerDigest: LedgerDigest;
}
export interface LedgerDigest {
Digest: Base64EncodedString;
DigestTipAddress: ValueHolder;
}
/**
* Query the table metadata for a document with a particular key for verification.
* @param txn The {@linkcode TransactionExecutor} for lambda execute.
* @param tableName The table name to query.
* @param keyAttributeName A keyAttributeName to query.
* @param keyAttributeValue The key of the given keyAttributeName.
* @returns Promise which fulfills with a list of Ion values that contains the results of the query.
*/
export declare function lookupBlockAddressAndDocIdForKey(txn: TransactionExecutor, tableName: string, keyAttributeName: string, keyAttributeValue: string): Promise<dom.Value[]>;
/**
* Retrieve full ledger metadata of the most recent revision of the document for the given Key.
* @param txn The {@linkcode TransactionExecutor} for lambda execute.
* @param ledgerName The ledger to get the digest from.
* @param tableName The table name to query.
* @param keyAttributeName A keyAttributeName to query.
* @param keyAttributeValue The key of the given keyAttributeName.
* @param qldbClient The QLDB control plane client to use.
* @returns Promise which fulfills with void.
* @throws Error: When verification fails.
*/
export declare function getDocumentLedgerMetadata(txn: TransactionExecutor, ledgerName: string, tableName: string, keyAttributeName: string, keyAttributeValue: string, qldbClient: QLDB, ledgerDigest?: LedgerDigest): Promise<LedgerMetadata>;
/**
* Retrieve full ledger metadata of the most recent revision of the document for the given Key.
* @param txn The {@linkcode TransactionExecutor} for lambda execute.
* @param ledgerName The ledger to get the digest from.
* @param tableName The table name to query.
* @param keyAttributeName A keyAttributeName to query.
* @param keyAttributeValue The key of the given keyAttributeName.
* @param qldbClient The QLDB control plane client to use.
* @returns Promise which fulfills with void.
* @throws Error: When verification fails.
*/
export declare function getDocumentLedgerMetadataByDocIdAndTxId(txn: TransactionExecutor, ledgerName: string, tableName: string, documentId: string, transactionId: string, qldbClient: QLDB): Promise<LedgerMetadata>;