UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

76 lines (75 loc) 7.4 kB
import { AccessPattern } from '../../../entity/actions/accessPattern/accessPattern.js'; import { BatchDeleteRequest } from '../../../entity/actions/batchDelete/index.js'; import { BatchGetRequest } from '../../../entity/actions/batchGet/index.js'; import { BatchPutRequest } from '../../../entity/actions/batchPut/index.js'; import type { DeleteItemOptions, DeleteItemResponse } from '../../../entity/actions/delete/index.js'; import type { FormatItemOptions, InferReadItemOptions } from '../../../entity/actions/format/index.js'; import type { GetItemOptions, GetItemResponse } from '../../../entity/actions/get/index.js'; import type { InferWriteItemOptions, ParseItemOptions } from '../../../entity/actions/parse/index.js'; import type { Condition } from '../../../entity/actions/parseCondition/index.js'; import type { EntityPaths } from '../../../entity/actions/parsePaths/index.js'; import type { PutItemInput, PutItemOptions, PutItemResponse } from '../../../entity/actions/put/index.js'; import type { ConditionCheckOptions } from '../../../entity/actions/transactCheck/index.js'; import { ConditionCheck } from '../../../entity/actions/transactCheck/index.js'; import type { DeleteTransactionOptions } from '../../../entity/actions/transactDelete/index.js'; import { DeleteTransaction } from '../../../entity/actions/transactDelete/index.js'; import type { ExecuteTransactGetInput, ExecuteTransactGetResponses, GetTransactionOptions } from '../../../entity/actions/transactGet/index.js'; import { GetTransaction } from '../../../entity/actions/transactGet/index.js'; import type { PutTransactionOptions } from '../../../entity/actions/transactPut/index.js'; import { PutTransaction } from '../../../entity/actions/transactPut/index.js'; import type { UpdateTransactionOptions } from '../../../entity/actions/transactUpdate/index.js'; import { UpdateTransaction } from '../../../entity/actions/transactUpdate/index.js'; import type { ExecuteTransactWriteInput, ExecuteTransactWriteResponses } from '../../../entity/actions/transactWrite/index.js'; import type { UpdateItemInput, UpdateItemOptions, UpdateItemResponse } from '../../../entity/actions/update/index.js'; import type { UpdateAttributesInput, UpdateAttributesOptions, UpdateAttributesResponse } from '../../../entity/actions/updateAttributes/index.js'; import type { Entity } from '../../../entity/entity.js'; import type { FormattedItem, InputItem, KeyInputItem, TransformedItem, ValidItem } from '../../../entity/index.js'; import { EntityAction } from '../../../entity/index.js'; import type { ConditionExpression, ParseConditionOptions } from '../../../schema/actions/parseCondition/index.js'; import type { ParsePathsOptions, ProjectionExpression } from '../../../schema/actions/parsePaths/index.js'; import type { Schema, TransformedValue } from '../../../schema/index.js'; import type { PrimaryKey } from '../../../table/actions/parsePrimaryKey/index.js'; import type { Query, QueryOptions, QueryResponse } from '../../../table/actions/query/index.js'; import type { ScanOptions, ScanResponse } from '../../../table/actions/scan/index.js'; import type { Cast, _Omit } from '../../../types/index.js'; export declare class EntityRepository<ENTITY extends Entity = Entity> extends EntityAction<ENTITY> { static actionName: "repository"; put<OPTIONS extends PutItemOptions<ENTITY> = PutItemOptions<ENTITY>>(item: PutItemInput<ENTITY>, options?: OPTIONS): Promise<PutItemResponse<ENTITY, OPTIONS>>; get<OPTIONS extends GetItemOptions<ENTITY> = GetItemOptions<ENTITY>>(key: KeyInputItem<ENTITY>, options?: OPTIONS): Promise<GetItemResponse<ENTITY, OPTIONS>>; update<OPTIONS extends UpdateItemOptions<ENTITY> = UpdateItemOptions<ENTITY>>(item: UpdateItemInput<ENTITY>, options?: OPTIONS): Promise<UpdateItemResponse<ENTITY, OPTIONS>>; updateAttributes<OPTIONS extends UpdateAttributesOptions<ENTITY> = UpdateAttributesOptions<ENTITY>>(item: UpdateAttributesInput<ENTITY>, options?: OPTIONS): Promise<UpdateAttributesResponse<ENTITY, OPTIONS>>; delete<OPTIONS extends DeleteItemOptions<ENTITY> = DeleteItemOptions<ENTITY>>(key: KeyInputItem<ENTITY>, options?: OPTIONS): Promise<DeleteItemResponse<ENTITY, OPTIONS>>; scan<OPTIONS extends ScanOptions<ENTITY['table'], [ENTITY]> = ScanOptions<ENTITY['table'], [ENTITY]>>(options?: OPTIONS): Promise<ScanResponse<ENTITY['table'], [ENTITY], OPTIONS>>; query<QUERY extends Query<ENTITY['table']>, OPTIONS extends QueryOptions<ENTITY['table'], [ENTITY], QUERY> = QueryOptions<ENTITY['table'], [ ENTITY ], QUERY>>(query: QUERY, options?: OPTIONS): Promise<QueryResponse<ENTITY['table'], QUERY, [ENTITY], OPTIONS>>; batchGet(key: KeyInputItem<ENTITY>): BatchGetRequest<ENTITY>; batchPut(item: InputItem<ENTITY>): BatchPutRequest<ENTITY>; batchDelete(key: KeyInputItem<ENTITY>): BatchDeleteRequest<ENTITY>; static executeTransactGet<TRANSACTIONS extends ExecuteTransactGetInput>(...transactions: TRANSACTIONS): Promise<ExecuteTransactGetResponses<TRANSACTIONS>>; transactGet<OPTIONS extends GetTransactionOptions<ENTITY> = GetTransactionOptions<ENTITY>>(key: KeyInputItem<ENTITY>, options?: OPTIONS): GetTransaction<ENTITY>; static executeTransactWrite<TRANSACTIONS extends ExecuteTransactWriteInput>(...transactions: TRANSACTIONS): Promise<ExecuteTransactWriteResponses<TRANSACTIONS>>; transactPut<OPTIONS extends PutTransactionOptions<ENTITY> = PutTransactionOptions<ENTITY>>(item: PutItemInput<ENTITY>, options?: OPTIONS): PutTransaction<ENTITY, OPTIONS>; transactUpdate<OPTIONS extends UpdateTransactionOptions<ENTITY> = UpdateTransactionOptions<ENTITY>>(item: UpdateItemInput<ENTITY>, options?: OPTIONS): UpdateTransaction<ENTITY, OPTIONS>; transactDelete<OPTIONS extends DeleteTransactionOptions<ENTITY> = DeleteTransactionOptions<ENTITY>>(key: KeyInputItem<ENTITY>, options?: OPTIONS): DeleteTransaction<ENTITY, OPTIONS>; transactCheck(key: KeyInputItem<ENTITY>, condition: Condition<ENTITY>, options?: ConditionCheckOptions): ConditionCheck<ENTITY>; accessPattern<SCHEMA extends Schema, QUERY extends Query<ENTITY['table']>, DEFAULT_OPTIONS extends QueryOptions<ENTITY['table'], [ENTITY], QUERY> = QueryOptions<ENTITY['table'], [ ENTITY ], QUERY>, CONTEXT_OPTIONS extends QueryOptions<ENTITY['table'], [ENTITY], QUERY> = QueryOptions<ENTITY['table'], [ ENTITY ], QUERY>>(schema: SCHEMA, pattern: (input: TransformedValue<SCHEMA>) => QUERY & { options?: CONTEXT_OPTIONS; }, options?: DEFAULT_OPTIONS): AccessPattern<ENTITY, SCHEMA, Cast<_Omit<QUERY, 'options'>, Query<ENTITY['table']>>, DEFAULT_OPTIONS, CONTEXT_OPTIONS>; parse<OPTIONS extends ParseItemOptions = {}>(item: { [KEY: string]: unknown; }, options?: OPTIONS): { parsedItem: ValidItem<ENTITY, InferWriteItemOptions<OPTIONS>>; item: TransformedItem<ENTITY, InferWriteItemOptions<OPTIONS>> & PrimaryKey<ENTITY['table']>; key: PrimaryKey<ENTITY['table']>; }; parseCondition(condition: Condition<ENTITY>, options?: ParseConditionOptions): ConditionExpression; parsePaths(attributes: EntityPaths<ENTITY>[], options?: ParsePathsOptions): ProjectionExpression; format<OPTIONS extends FormatItemOptions<ENTITY> = {}>(item: { [KEY: string]: unknown; }, options?: OPTIONS): FormattedItem<ENTITY, InferReadItemOptions<ENTITY, OPTIONS>>; }