import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb'; /** * Document: Represents a single document within a DynamoDB table. * * This class provides methods to interact with a specific document within a DynamoDB table. * It allows for operations such as getting, setting, deleting, and updating the document. * Additionally, it provides a way to access sub-collections within the document. */ declare class Document { readonly dynamometer: Dynamometer; private readonly _path; readonly id: string; readonly parent: Parent; /** * @param dynamometer - The Dynamometer instance associated with this document. * @param _path - The path to the document within the DynamoDB table. * @param id - The ID of the document. * @param parent - The parent collection containing this document. */ constructor(dynamometer: Dynamometer, _path: string, id: string, parent: Parent); /** * Computes the full path to the document by appending the document ID to the provided path. * * @returns The full path to the document. */ get path(): string; /** * Create and return a new Collection instance within this document. * * @param collectionPath - The path for the sub-collection. * @param args - Optional arguments for the sub-collection. * @returns A new Collection instance. */ collection(collectionPath: string, args?: CollectionArgs): Collection; /** * Retrieve the data of this document from the DynamoDB table. * * @returns A promise that resolves with the document data. */ get(): Promise; /** * Set or overwrite the data of this document in the DynamoDB table. * * @param data - The data to set for the document. */ set(data: any): Promise; /** * Delete this document from the DynamoDB table. */ delete(): Promise; /** * Update the data of this document in the DynamoDB table. * * @param data - The data to update for the document. */ update(data: any): Promise; } /** * Collection: Represents a collection of documents within a DynamoDB table. * * This class provides methods to interact with a specific collection within a DynamoDB table. * It allows for operations such as querying, adding, and accessing individual documents within the collection. */ type CollectionArgs = { /** * @description Adds a prefix to every document which is created within this collection. * @example { prefix: 'COMMENT' } -> COMMENT#12345... */ prefix?: string; }; declare class Collection { private readonly dynamometer; readonly path: string; parent?: Parent | undefined; private readonly args?; private beginsWithValue; /** * @param dynamometer - The Dynamometer instance associated with this collection. * @param path - The path to the collection within the DynamoDB table. * @param parent - The parent document containing this collection (if any). * @param args - Optional arguments for the collection. */ constructor(dynamometer: Dynamometer, path: string, parent?: Parent | undefined, args?: CollectionArgs | undefined); /** * Retrieve all documents within this collection from the DynamoDB table. * * @returns A promise that resolves with an array of documents. */ get(): Promise>; /** * Filter documents within this collection based on a prefix for the sort key. * * @param sortKeyBeginsWith - The prefix for the sort key. * @returns The current Collection instance for chaining. */ beginsWith(sortKeyBeginsWith: string): Collection; /** * Access a specific document within this collection. * * @param id - The ID of the document. If not provided, a new ID will be generated. * @returns A Document instance representing the specified document. */ doc(id?: string): Document; /** * Add a new document to this collection in the DynamoDB table. * * @param data - The data for the new document. * @returns A promise that resolves with a Document instance representing the newly added document. */ add(data: Type): Promise>; /** * Create a document ID by optionally prefixing it based on the collection arguments. * * @param id - The base ID. * @returns The created document ID. */ private createId; } /** * Dynamometer: A utility class for working with AWS DynamoDB. * * This class provides a higher-level abstraction for interacting with DynamoDB tables. * It offers a simplified way to create and manage collections within a DynamoDB table. */ /** * Configuration type for Dynamometer. * * @property tableName - The name of the DynamoDB table. * @property generateId - Optional function to generate unique IDs. * @property delimiter - Optional delimiter used in composite keys. * @property partitionKey - Optional name for the partition key. * @property sortKey - Optional name for the sort key. * @property idField - Optional name for the ID field. */ type DynamometerConfig = { tableName: string; generateId?: () => string; delimiter?: string; partitionKey?: string; sortKey?: string; idField?: string; }; declare class Dynamometer { readonly config: Required; readonly dynamoDBDocument: DynamoDBDocument; /** * Private constructor to enforce the use of static factory methods. * * @param ddbDocClient - The DynamoDBDocument client. * @param config - The configuration for the Dynamometer instance. */ private constructor(); /** * Static factory method to create a new Dynamometer instance. * * @param config - The configuration for the Dynamometer instance. * @returns A new Dynamometer instance. */ static create(config: DynamometerConfig): Dynamometer; /** * Static factory method to create a new Dynamometer instance from an existing DynamoDBDocument. * * @param dynamoDBDocument - The existing DynamoDBDocument client. * @param config - The configuration for the Dynamometer instance. * @returns A new Dynamometer instance. */ static fromDynamoDBDocument(dynamoDBDocument: DynamoDBDocument, config: DynamometerConfig): Dynamometer; /** * Create and return a new Collection instance. * * @param collectionPath - The path for the collection. * @param args - Optional arguments for the collection. * @returns A new Collection instance. */ collection(collectionPath: string, args?: CollectionArgs): Collection; } export { Collection, CollectionArgs, Document, Dynamometer, DynamometerConfig };