import { AttributeDefinition, AttributeValue, BatchExecuteStatementCommandInput, DeleteItemInput, DeleteItemOutput, DeleteRequest, DynamoDB, DynamoDBClientConfig, ExecuteStatementInput, ExecuteStatementOutput, ExecuteTransactionCommandInput, GetItemInput, GetItemOutput, GlobalSecondaryIndex, KeySchemaElement, Projection, PutItemInput, PutItemOutput, PutRequest, QueryInput, ScalarAttributeType, ScanInput, TransactWriteItemsInput, UpdateItemInput, UpdateItemOutput } from '@aws-sdk/client-dynamodb'; import { DynamoDBStreamsClient } from '@aws-sdk/client-dynamodb-streams'; import { NativeAttributeValue } from '@aws-sdk/util-dynamodb'; import { PMapByPageOptions } from '@collabland/common'; import { WaiterResult } from '@smithy/util-waiter'; /** * Index name for (classifier, sk) */ export declare const GSI_CLASSIFIER_SK = "GSI-CLASSIFIER-SK"; /** * Index name for (classifier, pk) */ export declare const GSI_CLASSIFIER_PK = "GSI-CLASSIFIER-PK"; /** * Index name for (classifier, slug) */ export declare const GSI_CLASSIFIER_SLUG = "GSI-CLASSIFIER-SLUG"; /** * Index name for (sk, pk) */ export declare const GSI_SK = "GSI-SK"; /** * Index name for (source, bucket) */ export declare const GSI_SOURCE_BUCKET = "GSI-SOURCE-BUCKET"; /** * Index name for (platform, userName) */ export declare const GSI_PLATFORM_USER_NAME = "GSI-PLATFORM-USER_NAME"; /** * Index name for (address, pk) for wallet addresses */ export declare const GSI_ADDRESS_PK = "GSI-ADDRESS-PK"; /** * Index name of (classifier, status) for jobs */ export declare const GSI_CLASSIFIER_STATUS = "GSI-CLASSIFIER-STATUS"; /** * Index name of (flowAccountId, pk) for Dapper wallets */ export declare const GSI_FLOW_ACCOUNT_ID_PK = "GSI-FLOW_ACC_ID-PK"; /** * Index name of (classifierGroup, pk) */ export declare const GSI_CLASSIFIER_GROUP_PK = "GSI-CLASSIFIER_GROUP-PK"; /** * Index name of (classifierGroup, communityPk) */ export declare const GSI_CLASSIFIER_GROUP_COMMUNITY_PK = "GSI-CLASSIFIER_GROUP-COMMUNITY_PK"; /** * Index name of (classifier, userName) */ export declare const GSI_CLASSIFIER_USER_NAME = "GSI-CLASSIFIER-USER_NAME"; /** * Index name of (classifier, firstName) */ export declare const GSI_CLASSIFIER_FIRST_NAME = "GSI-CLASSIFIER-FIRST_NAME"; /** * Index name of (classifier, _searchFirstName) */ export declare const GSI_CLASSIFIER_SEARCH_FIRST_NAME = "GSI-CLASSIFIER-SEARCH_FIRST_NAME"; /** * Index name of (classifier, _searchUserName) */ export declare const GSI_CLASSIFIER_SEARCH_USER_NAME = "GSI-CLASSIFIER-SEARCH_USER_NAME"; /** * Index name of (classifier, _searchLastName) */ export declare const GSI_CLASSIFIER_SEARCH_LAST_NAME = "GSI-CLASSIFIER-SEARCH_LAST_NAME"; /** * An Item that use TS/JS types/values */ export type Item = Record; /** * A DynamoDB item with extra typing */ export type DbItem = Record; /** * A TS/JS type */ export type NativeType = T[K] extends DbItem | undefined ? Omit & { [P in K]?: Item; } : never; /** * A DynamoDB type */ export type DbType = T[K] extends Item | undefined ? Omit & { [P in K]?: DbItem; } : never; /** * Result set from DynamoDB table scan */ export type ResultSet = { items: Record[]; lastEvaluatedKey?: Item; paginationToken?: string; }; export type Pagination = { /** * Exclusive start key */ paginationKey?: Item; /** * Maximum number of items to be fetched after the start key. Default to * unlimited (-1). */ limit?: number; }; /** * Encode pagination key into a string * @param paginationKey - Exclusive start key */ export declare function encodePaginationToken(paginationKey: Item): string; /** * Encode pagination key into a string * @param paginationKey - Exclusive start key */ export declare function decodePaginationToken(paginationToken: string): Item; /** * Convert the item to DB item * @param item - Item value */ export declare function toDb(item?: Item): Record | undefined; export declare function toDbSafe(item?: Item): Record | undefined; export declare function toDbAttribute(val?: NativeAttributeValue): AttributeValue; export declare function toDbList(items?: Item[]): (Record | undefined)[] | undefined; export declare function _fromDb(item?: DbItem): Record | undefined; /** * Unmarshall DB item into a native item * @param item - DynamoDB item */ export declare function fromDb(item?: DbItem): Item | undefined; export declare function fromDbList(items?: DbItem[]): Item[]; export declare function setPaginationToken(resultSet: ResultSet): ResultSet; export declare function getDefaultDynamoDBConfig(): DynamoDBClientConfig; /** * Configuration of AWS DynamoDB */ export type DynamoDbConfig = { /** * DynamoDB configuration */ config?: DynamoDBClientConfig; /** * Tables */ tables?: string[]; consistentRead?: boolean; }; export interface SourceBucket { source: string; bucket?: string; } export type IndexKeys = Record; export type PutItemInputSpec = NativeType; export type PutItemOutputSpec = NativeType; export type GetItemInputSpec = NativeType; export type GetItemOutputSpec = NativeType; export type DeleteItemInputSpec = NativeType; export type DeleteItemOutputSpec = NativeType; export type UpdateItemInputSpec = NativeType; export type UpdateItemOutputSpec = NativeType; export type DeleteRequestSpec = NativeType; export type PutRequestSpec = NativeType; export type QueryInputSpec = NativeType; export type ScanInputSpec = NativeType; export type ExecuteStatementInputSpec = Omit & { Parameters?: NativeAttributeValue[]; }; type ExecuteStatementOutputSpec = Omit & { Items?: NativeAttributeValue[]; }; export declare class DynamoDbServiceClient { private dynamoDbConfig; readonly dynamodb: DynamoDB; readonly tables: string[]; indexKeys: Record; readonly streamsClient: DynamoDBStreamsClient; constructor(dynamoDbConfig?: DynamoDbConfig); get apiTable(): string; get botTable(): string; init(): Promise; create(input: PutItemInputSpec): Promise; private consistentRead; get(input: GetItemInputSpec): Promise; delete(input: DeleteItemInputSpec): Promise; update(input: UpdateItemInputSpec): Promise; batchWrite(tableName: string, deleteItems: DeleteRequestSpec[], putItems: PutRequestSpec[]): Promise; /** * Query the table by page * @param params - Query parameters * @param limit - Page size */ private queryByPage; fetchByPage(params: QueryInputSpec, pageSize?: number): AsyncGenerator; /** * Query the table by page * @param params - Query parameters * @param pageSize - Page size */ private scanByPage; query(params: QueryInputSpec, pagination?: Pagination): Promise; scan(params: ScanInputSpec, pageSize?: number): Promise; createAll(table: string, resultSet: ResultSet, options?: PMapByPageOptions): Promise; /** * Build query parameters based on the index name * @param tableName - Table name * @param indexName - Index name, use table name or '' for the main one * @param key - Partition and Sort key value for the index * @param pagination - Pagination */ buildQueryByIndex(tableName: string, indexName: string | undefined, key: { pk: NativeAttributeValue; sk?: NativeAttributeValue; }, pagination?: Pagination): Omit & { ExpressionAttributeValues?: Item | undefined; ExclusiveStartKey?: Item | undefined; }; setPagination(params: QueryInputSpec, pagination?: Pagination): void; /** * Build KeySchema for an index * @param pk - Partition key name * @param sk - Sort key name */ buildKeySchema(pk: string, sk?: string): KeySchemaElement[]; /** * Query the table by index * @param tableName - Table name * @param indexName - Index name, use table name or '' for the main one * @param key - Partition key/Sort key for the index * @param pagination - Pagination */ queryByIndex(tableName: string, indexName: string | undefined, key: { pk: NativeAttributeValue; sk?: NativeAttributeValue; }, pagination?: Pagination): Promise; /** *Build a global secondary index (GSI) * @param name - Index name * @param pk - Partition key name * @param sk - Sort key name */ buildGlobalSecondaryIndex(name: string, pk: string, sk?: string, projection?: Projection): GlobalSecondaryIndex; /** * Build attribute definitions * @param attrs - Attributes (name, type) */ buildAttributeDefinitions(attrs: Record): AttributeDefinition[]; /** * Create a table * @param tableName - Table name */ createTable(tableName: string): Promise; listTables(): Promise; /** * Describe a table * @param tableName - Table name */ describeTable(tableName: string): Promise; /** * Describe table/index keys * @param tableName - Table name */ describeIndexKeys(tableName: string): Promise; /** * Extract pk/sk attribute names from the key schema * @param schema - Key schema */ private getKeys; /** * Delete a table * @param tableName - Table name */ deleteTable(tableName: string): Promise; /** * Wait for the table to exist * @param tableName - Table name */ waitUntilTableExists(tableName: string, maxWaitTime?: number): Promise; /** * Wait for the table to not exist * @param tableName - Table name */ waitUntilTableNotExists(tableName: string, maxWaitTime?: number): Promise; transactWrite(params: TransactWriteItemsInput): Promise; executeStatement(params: ExecuteStatementInputSpec): Promise; executeBatchStatement(params: BatchExecuteStatementCommandInput): Promise; executeTransaction(params: ExecuteTransactionCommandInput): Promise; listStreams(tableName: string): Promise; getStreamShards(streamArn: string, limit?: number, exclusiveStartShardId?: string): Promise<{ shards: import("@aws-sdk/client-dynamodb-streams").Shard[]; lastEvaluatedShardId: string | undefined; }>; getSharedIterator(streamArn: string, shardId: string, iteratorType: 'TRIM_HORIZON' | 'LATEST' | 'AT_SEQUENCE_NUMBER' | 'AFTER_SEQUENCE_NUMBER', sequenceNumber?: string): Promise; getStreamRecords(iterator: string, limit?: number): Promise<{ records: import("@aws-sdk/client-dynamodb-streams")._Record[] | undefined; next: string | undefined; }>; } export {};