UNPKG

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.

78 lines (76 loc) 4.14 kB
import { GetBlockResponse, GetDigestResponse, ValueHolder } from "@aws-sdk/client-qldb"; import { dom } from "ion-js"; export type Base64EncodedString = string; export type Digest = Base64EncodedString | undefined; /** * Returns the string representation of a given BlockResponse. * @param blockResponse The BlockResponse to convert to string. * @returns The string representation of the supplied BlockResponse. */ export declare function blockResponseToString(blockResponse: GetBlockResponse): string; /** * Returns the string representation of a given GetDigestResponse. * @param digestResponse The GetDigestResponse to convert to string. * @returns The string representation of the supplied GetDigestResponse. */ export declare function digestResponseToString(digestResponse: GetDigestResponse): string; /** * Sleep for the specified amount of time. * @param ms The amount of time to sleep in milliseconds. * @returns Promise which fulfills with void. */ export declare function sleep(ms: number): Promise<void>; /** * Find the value of a given path in an Ion value. The path should contain a blob value. * @param value The Ion value that contains the journal block attributes. * @param path The path to a certain attribute. * @returns Uint8Array value of the blob, or null if the attribute cannot be found in the Ion value * or is not of type Blob */ export declare function getBlobValue(value: dom.Value, path: string): Uint8Array | null; /** * Returns the string representation of a given ValueHolder. * @param valueHolder The ValueHolder to convert to string. * @returns The string representation of the supplied ValueHolder. */ export declare function valueHolderToString(valueHolder: ValueHolder): string; /** * Checks a string for compliance with table naming constrains: https://docs.aws.amazon.com/qldb/latest/developerguide/limits.html#limits.naming * @param tableName A string containing a name of a table. * @returns Returns true if string complies with table naming constrains and trows an error if otherwise. */ export declare function validateTableNameConstrains(tableName: string): boolean; /** * Checks a string for compliance with ledger naming constrains: https://docs.aws.amazon.com/qldb/latest/developerguide/limits.html#limits.naming * @param ledgerName A string containing a name of a table. * @returns Returns true if string complies with ledger naming constrains and trows an error if otherwise. */ export declare function validateLedgerNameConstrains(ledgerName: string): boolean; /** * Checks a string for compliance with document attribute naming constrains. * @param attributeName A string containing a name of a document attribute. * @returns Returns true if string complies with attribute naming constrains and trows an error if otherwise. */ export declare function validateAttributeNameConstrains(attributeName: string): boolean; /** * Checks if a string is in a correct ISO 8601 datetime format like `2019-06-05T00:00:00Z` * @param dateTimeISO A string containing a name of a document attribute. * @returns Returns true if string complies with attribute naming constrains and trows an error if otherwise. */ export declare function validateStringAsISODateTime(dateTimeISO: string): boolean; /** * Convert dom.Value to writer-based Uint8Array * @param domValue The Ion value tof dom.Value type. * @returns Uint8Array value of the attribute. The buffer will * be either a UTF-8 encoded buffer for Ion text or Ion binary. The buffer is * not well-defined until [[close]] is invoked. */ export declare function toWriterBytes(domValue: dom.Value): Uint8Array; /** * Convert metadata as JSON to UTF-8 encoded buffer for Ion to make sure all properties converted correctly * @param metadataJSON The value of the QLDB-generated metadata object, converted to JSON. * @returns Uint8Array value of the attribute. The buffer will * be either a UTF-8 encoded buffer for Ion text or Ion binary. The buffer is * not well-defined until [[close]] is invoked. */ export declare function metadataJSONtoIonUint8Array(metadataJSON: any): Uint8Array;