UNPKG

@fabric-es/fabric-cqrs

Version:

Hyperledger Fabric middleware for event sourcing and cqrs pattern

86 lines (85 loc) 2.96 kB
import type { FTSearchParameters } from 'redis-modules-sdk'; import type { BaseEntity, BaseEvent, Commit, HandlerResponse, Reducer } from '../../types'; import type { RedisRepository, OutputCommit } from '.'; export declare type QueryDatabaseResponse<TResult = any> = { status: string; message: string; result?: TResult; error?: any; }; export declare type QueryDatabase = { clearNotification: (option: { creator: string; entityName: string; id: string; commitId: string; }) => Promise<HandlerResponse<string[]>>; clearNotifications: (option: { creator: string; entityName?: string; id?: string; commitId?: string; }) => Promise<HandlerResponse<string[]>>; getRedisCommitRepo: () => RedisRepository<OutputCommit>; deleteCommitByEntityId: (option: { entityName: string; id: string; }) => Promise<HandlerResponse<number>>; deleteCommitByEntityName: (option: { entityName: string; }) => Promise<HandlerResponse<number>>; deleteEntityByEntityName: (option: { entityName: string; }) => Promise<HandlerResponse<number>>; queryCommitByEntityId: (option: { entityName: string; id: string; }) => Promise<HandlerResponse<OutputCommit[]>>; queryCommitByEntityName: (option: { entityName: string; }) => Promise<HandlerResponse<OutputCommit[]>>; mergeCommit: (option: { commit: Commit; }) => Promise<HandlerResponse<string[]>>; mergeCommitBatch: (option: { entityName: string; commits: Record<string, Commit>; }) => Promise<HandlerResponse<string[]>>; mergeEntity: <TEntity extends BaseEntity, TEvent extends BaseEvent>(option: { commit: Commit; reducer: Reducer<TEntity, TEvent>; }) => Promise<HandlerResponse<{ key: string; status: string; }[]>>; mergeEntityBatch: <TEntity, TEvent>(option: { entityName: string; commits: Record<string, Commit>; reducer: Reducer<TEntity, TEvent>; }) => Promise<HandlerResponse<{ key: string; status: string; }[]>>; fullTextSearchCommit: (option: { query: string; param?: FTSearchParameters; countTotalOnly?: boolean; }) => Promise<HandlerResponse<OutputCommit[] | number>>; fullTextSearchEntity: <TEntity = any>(option: { entityName: string; query: string; param?: FTSearchParameters; countTotalOnly?: boolean; }) => Promise<HandlerResponse<TEntity[] | number>>; getNotification: (option: { creator: string; entityName?: string; id?: string; commitId?: string; }) => Promise<HandlerResponse<Record<string, string>>>; getNotificationsByFields: (option: { creator: string; entityName?: string; id?: string; }) => Promise<HandlerResponse<Record<string, string>>>; };