Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @fabric-es/fabric-cqrs

fabric-cqrs

Installation

yarn install @fabric-es/fabric-cqrs

Type aliases

BaseEvent

BaseEvent: object

Type declaration

  • Optional Readonly lifeCycle?: Lifecycle

    lifecycle type

  • Optional payload?: any

    event payload

  • Optional Readonly type?: string

    event type

Commit

Commit: object
about

Commit

Type declaration

  • Optional commitId?: string

    commit Id

  • Optional entityId?: string

    entity Id

  • entityName: string

    entity name

  • Optional events?: BaseEvent[]

    RESERVED FIELD: events array

  • Optional eventsString?: string

    RESERVED FIELD: stringified events

  • Optional hash?: string

    RESERVED FIELD: hash of privatedata's events string

  • id: string

    (same as entityId)

  • Optional mspId?: string

    organization Id

  • Optional signedRequest?: string

    RESERVED FIELD: signed request

  • Optional version?: number

    version number

CommitInRedis

CommitInRedis: object
about

Commit physically in redis. Notice that FieldOption.altName may rename field when writing to Redis. Hence key names of CommitInRedis may be different from key names of [[RedisCommitFields]].

Type declaration

CommitSearchDefinition

about

consolidated fields defintion of commit in Redis. It defines all FieldOption of Commit

CommonCommitFields

CommonCommitFields: Pick<Commit, "id" | "commitId" | "entityName" | "mspId" | "version" | "events" | "signedRequest">
about

common field of commit; originated from Commit

CounterIndexDefintion

CounterIndexDefintion: RedisearchDefinition<CommonCounterFields & DerivedCounterFields>

DerivedCommitFields

DerivedCommitFields: object
about

derived / new fields introducted, before writing to Redis. The dervied fields is useful to better search capability, during full-text-search. It may uplift the deeply nested field values, such "creator", to flatten Redis K/V structure.

Type declaration

  • creator: string
  • event: string
  • evstr: string
  • ts: number

DerivedCounterFields

DerivedCounterFields: object
about

derived / new fields introducted, right BEFORE writing to Redis. The dervied fields is useful to better search capability, during full-text-search. It may uplift the deeply nested field values, such "creator", to flatten Redis K/V structure. Derived field is an optional implementation

ingore

Type declaration

  • event: string

FabricResponse

FabricResponse: object
about

generic response from Fabric

Type declaration

  • message: string
  • result: any
  • status: string

FieldOption

FieldOption: object
about

define property of each Redis Hash field. The naming convention of Redis Hash Fields is lowercase with removed special character. The original field name may be invalid, and "altName" can fix it.

Type declaration

  • Optional altName?: string
  • Optional index?: Omit<FTSchemaField, "name">

GetByEntityNameResponse

GetByEntityNameResponse<TEntity>: object

Type parameters

  • TEntity

Type declaration

  • currentStates: TEntity[]
  • errors: string[]

HandlerResponse

HandlerResponse<TData>: object

Type parameters

  • TData

Type declaration

  • Optional data?: TData
  • Optional error?: any
  • Optional errors?: Error[]
  • Optional message?: string
  • status: string

NotificationCenter

NotificationCenter: object
about

notification center

Type declaration

  • clearNotification: function

    clear one notification

      • Parameters

        • option: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<string[]>>

  • clearNotifications: function

    clear all notifications

      • Parameters

        • option: object
          • creator: string
          • Optional entityName?: string
          • Optional id?: string

        Returns Promise<HandlerResponse<string[]>>

  • getNotification: function

    return single notification, and reset to '0', indicating "READ".

      • Parameters

        • option: object
          • Optional commitId?: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<Record<string, string>>>

  • getNotificationsByFields: function

    return a list of notifications. It will NOT reset to 'O'

      • Parameters

        • option: object
          • creator: string
          • Optional entityName?: string
          • Optional id?: string

        Returns Promise<HandlerResponse<Record<string, string>>>

  • notify: function

    add new notification

      • Parameters

        • option: object
          • commitId: string
          • creator: string
          • entityName: string
          • Optional expiryBySec?: number
          • id: string

        Returns Promise<HandlerResponse<string>>

Paginated

Paginated<TResult>: object

Type parameters

  • TResult

Type declaration

  • cursor: number
  • hasMore: boolean
  • items: TResult[]
  • total: number

Pattern

Pattern: "COMMITS_BY_ENTITYNAME" | "COMMITS_BY_ENTITYNAME_ENTITYID" | "ENTITIES_BY_ENTITYNAME" | "ENTITIES_BY_ENTITYNAME_ENTITYID"

PickedCommit

PickedCommit: Required<Pick<Commit, "id" | "entityName" | "commitId" | "mspId" | "entityId" | "events" | "version" | "signedRequest">>
about

Below commit fields will be saved in Redis. Field, like 'hash' and 'eventstring' is not implemented; are reserved for future use. Also, some commit fields may be belonging to Private data, will neither be saved in Redis.

PrivateRepoOption

PrivateRepoOption: object
about

private Repository Options

Type declaration

PrivateRepository

PrivateRepository<TEntity, TEvent>: object
about

repository for private data Noitce that both read and write are made directly to Fabric. No Redis involved.

Type parameters

  • TEntity

  • TEvent

Type declaration

  • create: function
    about

    📥 write events to private repository, with enrollmentId, and entityId

    similar

    Repository.create

    example
    const response: HandlerResponse<Commit> = await repository
      .create({ enrollmentId, id })
      .save({ events });
    returns
    {
      save: (payload: { events: TEvent[] }) =>
        Promise<HandlerResponse<Commit>>
    }
      • (option: object): object
      • Parameters

        • option: object
          • enrollmentId: string
          • id: string

        Returns object

  • deleteByEntityIdCommitId: RepoFcn_IdCommitId<FabricResponse>
    about

    📥 delete commits by entityId and commitId

    returns
    (payload: { commitId: string; id: string }) =>
      Promise<HandlerResponse<FabricResponse>>
  • disconnect: function
    about

    disconnect from fabric peer

    returns

    () => void

      • (): void
      • Returns void

  • getById: function
    about

    update current entity, by appending new events

    1. 📥 get currentState of entity by entityId
    2. 📥 return Save function to append new events
    similar

    Repository.getById

    example
    const { save, currentState } = await repository.getById({ enrollmentId, id });
    console.log(currentState);
    const { data, status } = await save({
        events: [
          {
            type: 'Any-Event',
            payload: { id, desc: 'hello', tag: 'any-tag' },
          },
        ],
      })
    returns
    {
      currentState: TEntity;
      save: (payload: { events: TEvent[] }) =>
              Promise<HandlerResponse<Commit>>
    }
      • (option: object): Promise<object>
      • Parameters

        • option: object
          • enrollmentId: string
          • id: string

        Returns Promise<object>

  • getCommitByEntityIdCommitId: RepoFcn_IdCommitId<Commit[]>
    about

    📥 get commits by entityName and commitId

    similar

    Repository.getCommitByEntityIdCommitId

    returns
    (payload: { commitId: string; id: string }) =>
      Promise<HandlerResponse<Commit[]>>
  • getCommitByEntityName: RepoFcn<Commit[]>
    about

    📥 get commits by entityName

    similar

    Repository.getCommitByEntityName

    returns
    () => Promise<HandlerResponse<Commit[]>>
  • getCommitById: RepoFcn_Id<Commit[]>
    about

    get commits by entity id

    returns
    (payload: { id: string }) => Promise<HandlerResponse<Commit[]>>
  • getEntityName: function
    about

    📥 get entityName

    similar

    Repository.getEntityName

    returns

    () => string

      • (): string
      • Returns string

PubSubPayload

PubSubPayload: object
about

payload fired when entity is added to Redis

Type declaration

  • entityAdded: object
    • commit: Commit
    • events: string[]
    • key: string

PubSubSysEvent

PubSubSysEvent: object
about

system event when Redis PubSub event is sent

Type declaration

  • systemEvent: object
    • Optional data?: any
    • Optional error?: string
    • event: string
    • Optional message?: string
    • Optional status?: string
    • timestamp: number

QueryDatabase

QueryDatabase: object
about

Query database

  • 🔑 key format of commit c:entityName:entityId:commitId*
  • 🔑 key format of entity e:entityName:entityId*

Type declaration

  • clearNotification: function

    clear one notification

      • Parameters

        • option: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<string[]>>

  • clearNotifications: function

    clear all notifications

      • Parameters

        • option: object
          • Optional commitId?: string
          • creator: string
          • Optional entityName?: string
          • Optional id?: string

        Returns Promise<HandlerResponse<string[]>>

  • deleteCommitByEntityId: function

    delete commit by entityId

    returns
    // example
    {
      status: 'OK',
      message: `XX records are removed`,
      result: number_of_records_deleted,
    }
  • deleteCommitByEntityName: function

    delete commit by entityName

  • deleteEntityByEntityName: function
  • fullTextSearchCommit: function

    full text search on commit, or just return item count of result

  • fullTextSearchEntity: function

    full text search on entity, or just return item count of result

    see

    FTSearchParameters is defined by node_modules/redis-modules-sdk/lib/modules/redisearch.d.ts

    see

    Search Query Syntax

    example

    query

    // example
    {
       entityName: 'counter'
       query: 'some_input*'
       cursor: 0,
       pagesize: 10,
       param: { sortBy: { sort: 'ASC', field: 'de' } }
    }
      • Type parameters

        • TEntity

        Parameters

        • option: object
          • Optional countTotalOnly?: boolean
          • entityName: string
          • Optional param?: FTSearchParameters
          • query: string

        Returns Promise<HandlerResponse<TEntity[] | number>>

  • getNotification: function
    about

    get active notification by commitId

    returns
    // example
    {
      status,
      result:
    }
      • Parameters

        • option: object
          • Optional commitId?: string
          • creator: string
          • Optional entityName?: string
          • Optional id?: string

        Returns Promise<HandlerResponse<Record<string, string>>>

  • getNotificationsByFields: function
    about

    get list of notifications

      • Parameters

        • option: object
          • creator: string
          • Optional entityName?: string
          • Optional id?: string

        Returns Promise<HandlerResponse<Record<string, string>>>

  • getRedisCommitRepo: function
  • mergeCommit: function
    about

    merge single commit to commit history, and update index

    returns
    // example
    {
      status:
      message:
      result: array_of_unique_redis_keys
    }
  • mergeCommitBatch: function
    about

    merge multiple batch of commit to commit history and update index

  • mergeEntity: function
  • mergeEntityBatch: function

    merge multiple new entity

      • Type parameters

        • TEntity

        • TEvent

        Parameters

        • option: object
          • commits: Record<string, Commit>
          • entityName: string
          • reducer: Reducer<TEntity, TEvent>

        Returns Promise<HandlerResponse<object[]>>

  • queryCommitByEntityId: function

    query commits by entityId

  • queryCommitByEntityName: function

    query commits by entityName

QueryDatabaseResponse

QueryDatabaseResponse<TResult>: object

Type parameters

  • TResult

Type declaration

  • Optional error?: any
  • message: string
  • Optional result?: TResult
  • status: string

QueryHandler

QueryHandler: object
about

QueryHandler provides high level query capability per organization

Type declaration

  • clearNotification: function

    clear one notification

      • Parameters

        • option: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<string[]>>

  • clearNotifications: function
      • Parameters

        • option: object
          • Optional commitId?: string
          • creator: string
          • Optional entityName?: string
          • Optional id?: string

        Returns Promise<HandlerResponse<string[]>>

  • command_deleteByEntityId: function
    about

    📥 delete commit by entityId

    unit_test

    this api is solely for unit-test purpose.

    same

    Repository.command_deleteByEntityId

    returns
    (payload: { id: string }) =>
      Promise<HandlerResponse<<FabricResponse>>>
  • command_getByEntityName: function
    about

    📥 get commits by entityName

    unit_test

    this api is solely for unit-test purpose.

    same

    Repository.command_getByEntityName

    returns
    () => Promise<HandlerResponse<Commit[]>>
  • create: function
    about

    📥 write events to onchain repository, with enrollmentId, and entityId

    unit_test

    this api is solely for unit-test purpose.

    same

    Repository.create

      • <TEvent>(entityName: string): function
      • Type parameters

        • TEvent

        Parameters

        • entityName: string

        Returns function

          • (option: object): object
          • Parameters

            • option: object
              • enrollmentId: string
              • id: string

            Returns object

  • disconnect: function
    about

    disconnect from fabric peer

    returns

    () => void

      • (): void
      • Returns void

  • fullTextSearchCommit: function
    about

    full text search of commit, returning paginated result

    see

    FTSearchParameters is defined by node_modules/redis-modules-sdk/lib/modules/redisearch.d.ts

    see

    Search Query Syntax

  • fullTextSearchEntity: function
    about

    full text search of entity, returning paginated result

    see

    FTSearchParameters is defined by node_modules/redis-modules-sdk/lib/modules/redisearch.d.ts

    see

    Search Query Syntax

      • Type parameters

        • TOutputEntity

        Parameters

        • option: object
          • cursor: number
          • entityName: string
          • pagesize: number
          • Optional param?: FTSearchParameters
          • query: string

        Returns Promise<HandlerResponse<Paginated<TOutputEntity>>>

  • getByEntityName: function
    about

    📤 get commits by entityName. Reduce to entity, on the fly

    returns
    () => Promise<HandlerResponse<TEntity[]>>
      • <TEntity>(entityName: string): RepoFcn<TEntity[]>
      • Type parameters

        • TEntity

        Parameters

        • entityName: string

        Returns RepoFcn<TEntity[]>

  • getById: function
    about

    update current entity, by appending new events

    1. 📤 get currentState of entity by entityId
    2. 📥 return Save function to append new events
    same

    Repository.getById

      • <TEntity, TEvent>(entityName: string): function
      • Type parameters

        • TEntity

        • TEvent

        Parameters

        • entityName: string

        Returns function

          • (option: object): Promise<object>
          • Parameters

            • option: object
              • enrollmentId: string
              • id: string

            Returns Promise<object>

  • getCommitById: function
    about

    📤 get commits by entityId

    same

    Repository.getCommitById

    returns
    (payload: { id: string }) => Promise<HandlerResponse<Commit[]>>
  • getNotification: function
    about

    primarily used by web ui, to retrieve one notification.

      • Parameters

        • payload: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<Record<string, string>>>

  • getNotifications: function
    about

    primarily used by web ui, to retrieve the list of active notifications.

      • Parameters

        • payload: object
          • creator: string
          • Optional entityName?: string
          • Optional id?: string

        Returns Promise<HandlerResponse<Record<string, string>>>

  • query_deleteCommitByEntityId: function
    about

    📤 delete commmts by entityId

    same

    Repository.query_deleteCommitByEntityId

    returns
    (payload: { id: string }) => Promise<HandlerResponse<number>>
  • query_deleteCommitByEntityName: function
    about

    📤 delete commit by entityName

    same

    Repository.query_deleteCommitByEntityName

    returns
    () => Promise<HandlerResponse<number>>
      • (entityName: string): RepoFcn<number>
      • Parameters

        • entityName: string

        Returns RepoFcn<number>

  • query_deleteEntityByEntityName: function
      • (entityName: string): RepoFcn<number>
      • Parameters

        • entityName: string

        Returns RepoFcn<number>

  • reconcile: function
    about

    used by bootstraping programs to reconcile entity from Fabric to Redis

    returns
    (payload: { entityName: string }) =>
      Promise<HandlerResponse<{ key: string; status: string }[]>>
  • reconciled: function
    about

    notify the query-handler that reconciliation completed

    returns

    () => void

      • (): void
      • Returns void

  • subscribeHub: function
    about

    subscribe to Fabric channel event hub

    returns

    () => void

      • (entityNames: string[]): Promise<any>
      • Parameters

        • entityNames: string[]

        Returns Promise<any>

  • unsubscribeHub: function
    about

    unsubscribe to Fabric channel event hub

    returns

    () => void

      • (): void
      • Returns void

QueryHandlerOption

QueryHandlerOption: object
about

queryHandler Options

Type declaration

  • channelName: string
  • connectionProfile: string

    path to connectionProfile

  • entityNames: string[]

    when the query handler starts, it reconciles entities from Fabric to Redis

  • gateway: Gateway

    high level fabric api - gateway

  • Optional logger?: Logger

    winston logger

  • network: Network

    high level fabric api - network

  • Optional pubSub?: RedisPubSub

    redisPubSub instance

  • queryDatabase: QueryDatabase

    query database instance

  • reducers: Record<string, Reducer>

    multiple reducers

  • wallet: Wallet

    wallet instance

RedisRepository

RedisRepository<TItem, TItemInRedis, TResult>: object
about

abstraction of Redis operations

Type parameters

  • TItem

  • TItemInRedis

  • TResult

Type declaration

  • createIndex: function

    create index, either eidx:ENTITYNAME or cidx

      • (): Promise<"OK">
      • Returns Promise<"OK">

  • deleteItemsByPattern: function
    example

    2 commits are successfully delete, pipelineExec returns [ [ null, 1 ], [ null, 1 ] ] .then return tuple [error, number-of-successful-delete]

      • (pattern: string): Promise<[any, number]>
      • Parameters

        • pattern: string

        Returns Promise<[any, number]>

  • dropIndex: function

    drop redisearch index, either eidx:ENTITYNAME or cidx

      • (deleteHash?: boolean): Promise<"OK">
      • Parameters

        • Optional deleteHash: boolean

        Returns Promise<"OK">

  • getIndexName: function
      • (): string
      • Returns string

  • getKey: function

    return key of item. The item is either an entity, or commit

      • (item: any): string
      • Parameters

        • item: any

        Returns string

  • getPattern: function

    return the pattern expression

      • (pattern: Pattern, args: string[]): string
      • Parameters

        Returns string

  • getPostSelector: function
      • (): Selector<TItemInRedis, TResult>
      • Returns Selector<TItemInRedis, TResult>

  • getPreSelector: function
      • (): Selector<TItem, TItemInRedis>
      • Returns Selector<TItem, TItemInRedis>

  • hgetall: function

    return hash

      • (key: string): Promise<TResult>
      • Parameters

        • key: string

        Returns Promise<TResult>

  • hmset: function

    hmset write to Redis.

    param

    item to save

    param

    is used to compute derived fields, if preSelector exists

    see

    https://redis.io/commands/hmset

    see

    https://oss.redislabs.com/redisearch/Commands/#hsethsetnxhdelhincrbyhdecrby

      • (item: any, history?: Commit[]): Promise<"OK">
      • Parameters

        • item: any
        • Optional history: Commit[]

        Returns Promise<"OK">

  • queryCommitsByPattern: function
    about

    restore commit history from Redis format, and detect any errors pipelinExec .then will return tuple [error, commitInRedis[])

      • Parameters

        • pattern: string

        Returns Promise<[any, OutputCommit[]] | null>

  • search: function

    perform search

      • (option: object): Promise<[Error[], number, TResult[]]>
      • Parameters

        • option: object
          • Optional countTotalOnly?: boolean
          • index: string
          • kind: "commit" | "entity"
          • Optional param?: FTSearchParameters
          • query: string
          • Optional restoreFn?: any

        Returns Promise<[Error[], number, TResult[]]>

RedisearchDefinition

RedisearchDefinition<T>: object
about

Map of FieldOptions for each Hash field of Redisearch

Type parameters

  • T

Type declaration

Reducer

Reducer<TEntity, TEvent>: function
about

reducer computes the current state of an entity

Type parameters

  • TEntity

  • TEvent

Type declaration

    • (history: TEvent[], initial?: TEntity): TEntity
    • Parameters

      • history: TEvent[]
      • Optional initial: TEntity

      Returns TEntity

ReducerCallback

ReducerCallback<TEntity, TEvent>: function
about

domain entity specific callback function used in reducer

Type parameters

Type declaration

    • (entity: TEntity, event: TEvent): TEntity
    • Parameters

      • entity: TEntity
      • event: TEvent

      Returns TEntity

RepoFcn

RepoFcn<TResponse>: function

Type parameters

  • TResponse

Type declaration

RepoFcn_Id

RepoFcn_Id<TResponse>: function

Type parameters

  • TResponse

Type declaration

RepoFcn_IdCommitId

RepoFcn_IdCommitId<TResponse>: function

Type parameters

  • TResponse

Type declaration

    • Parameters

      • payload: object
        • commitId: string
        • id: string

      Returns Promise<HandlerResponse<TResponse>>

RepoOption

RepoOption: object
about

repository options

Type declaration

Repository

Repository<TEntity, TOutputEntity, TEvent>: object
about

repository

command-side.📥

prefix command_ is write-to-Fabric operations

query-side.📤

prefix query_ is query-from-Redis operation

Type parameters

  • TEntity

  • TOutputEntity

  • TEvent

Type declaration

  • command_deleteByEntityId: RepoFcn_Id<FabricResponse>
    about

    📥 delete commit by entityId

    same

    QueryHandler.command_deleteByEntityId

    returns
    (payload: { id: string }) =>
      Promise<HandlerResponse<<FabricResponse>>>
  • Optional command_getByEntityIdCommitId?: RepoFcn_IdCommitId<Commit[]>
    about

    📥 get commits by entityName and commitId

    returns
    (payload: { commitId: string; id: string }) =>
      Promise<HandlerResponse<Commit[]>>
  • command_getByEntityName: RepoFcn<Commit[]>
    about

    📥 get commits by entityName

    same

    QueryHandler.command_getByEntityName

    returns
    () => Promise<HandlerResponse<Commit[]>>
  • create: function
    about

    📥 write events to repository, with enrollmentId, and entityId

    same

    QueryHandler.create

    example
    const response: HandlerResponse<Commit> = await repository
      .create({ enrollmentId, id })
      .save({ events });
    returns
    {
      save: (payload: { events: TEvent[] }) =>
        Promise<HandlerResponse<Commit>>
    }
      • (option: object): object
      • Parameters

        • option: object
          • enrollmentId: string
          • id: string

        Returns object

  • disconnect: function
    about

    disconnect from fabric peer

    returns

    () => void

      • (): void
      • Returns void

  • fullTextSearchCommit: function
    about

    full text search of commit.

    similar

    QueryHandler.getPaginatedCommitById

  • fullTextSearchEntity: function
    about

    full text search of entity

    similar

    QueryHandler.getPaginatedEntityById

      • Parameters

        • option: object
          • cursor: number
          • entityName: string
          • pagesize: number
          • Optional param?: FTSearchParameters
          • query: string

        Returns Promise<HandlerResponse<Paginated<TOutputEntity>>>

  • getByEntityName: function
    about

    📤 get commits by entityName. Reduce to entity, on the fly. There is no meta data, like _commit, _event

    returns
    () => Promise<HandlerResponse<TEntity[]>>
  • getById: function
    about

    update current entity, by appending new events

    1. 📤 get currentState of entity by entityId
    2. 📥 return Save function to append new events
    same

    QueryHandler.getById

    example
    const { save, currentState } = await repository.getById({ enrollmentId, id });
    console.log(currentState);
    const { data, status } = await save({
        events: [
          {
            type: 'Any-Event',
            payload: { id, desc: 'hello', tag: 'any-tag' },
          },
        ],
      })
    returns
    {
      currentState: TEntity;
      save: (payload: { events: TEvent[] }) =>
              Promise<HandlerResponse<Commit>>
    }
      • (option: object): Promise<object>
      • Parameters

        • option: object
          • enrollmentId: string
          • id: string

        Returns Promise<object>

  • getCommitById: RepoFcn_Id<Commit[]>
    about

    📤 get commits by entityId

    same

    QueryHandler.getCommitById

    returns
    (payload: { id: string }) => Promise<HandlerResponse<Commit[]>>
  • getEntityName: function
    about

    📤 get EntityName

    returns

    () => string

      • (): string
      • Returns string

  • query_deleteCommitByEntityId: RepoFcn_Id<number>
    about

    📤 delete commmts by entityId

    same

    QueryHandler.query_deleteCommitByEntityId

    returns
    (payload: { id: string }) => Promise<HandlerResponse<number>>
  • query_deleteCommitByEntityName: RepoFcn<number>
    about

    📤 delete commit by entityName

    same

    QueryHandler.query_deleteCommitByEntityId

    returns
    () => Promise<HandlerResponse<number>>

SaveFcn

SaveFcn<TEvent>: function

Type parameters

  • TEvent

Type declaration

TArg

TArg: object

Type declaration

  • Optional countTotalOnly?: boolean
  • Optional entityName?: string
  • param: FTSearchParameters
  • query: string

Variables

Const CLOUD

CLOUD: 4 = 4

Const CONSOLE

CONSOLE: 1 = 1

Const FILE

FILE: 2 = 2

Const TRACK_FIELD_S

TRACK_FIELD_S: "privateData" = "privateData"

Const appendTimestamp

appendTimestamp: FormatWrap = format((info, opts) => {if (opts.tz) info.timestamp = moment().tz(opts.tz).format();return info;})

Const basePostSelector

basePostSelector: Selector<any, any> = createStructuredSelector({modifiedAt: (item) => item?.ts,createdAt: (item) => item?.created,creator: (item) => item?.creator,organization: (item) =>(item && item.organization) ? JSON.parse(item?.organization) : undefined,privateData: (item) =>(item && item.privateData) ? JSON.parse(item?.privateData) : undefined,})

Const basePreSelector

basePreSelector: Selector<any, any> = createStructuredSelector({ts: ([{ _ts }]) => _ts,created: ([{ _created }]) => _created,creator: ([{ _creator }]) => _creator,organization: ([{ _organization }]) => JSON.stringify(_organization),privateData: ([{ _privateData }]) => JSON.stringify(_privateData),})

combine

combine: combine

Const debug

debug: Debugger = Debug('types:reducer')

Const debug

debug: Debugger = Debug('queryHandler:createRedisRepository:pipelineExec')

label

label: label

Const logFormat

logFormat: Format = printf(({ level, message, label, timestamp }) => {return `${timestamp} [${level}]: ${message} (${label})`;})

Const loggers

loggers: Record<string, Logger>

Const postSelector

postSelector: Selector<CommitInRedis, OutputCommit> = createStructuredSelector({id: ({ id }) => id,entityName: ({ entityName }) => entityName,commitId: ({ commitId }) => commitId,mspId: ({ mspId }) => mspId,creator: ({ creator }) => creator,event: ({ event }) => event,entityId: ({ entityId }) => entityId,version: (commit) => {let version;try {version = parseInt(commit?.v, 10);} catch {console.error('fail to parse redisCommit - version');}return version;},ts: (commit) => {let ts: number;try {ts = parseInt(commit?.ts, 10);} catch {console.error('fail to parse redisCommit - ts');}return ts;},events: (commit) => {let events;try {events = JSON.parse(commit?.evstr);} catch {console.error('fail to parse redisCommit - events');}return events;},signedRequest: ({ signedRequest }) => signedRequest,})
about

restore CommitInRedis base to original Commit format, appended with additional fields producing OutputCommit

see

https://www.npmjs.com/package/reselect

example
// original commit
 {
   id: 'qh_proj_test_001',
   entityName: 'test_proj',
   version: 0,
   commitId: '20200528133519841',
   entityId: 'qh_proj_test_001',
   mspId: 'Org1MSP',
   events: [ { type: 'Increment', payload: [Object] } ]
 }
// CommitInRedis - processed by preSelector
 {
   id: 'qh_proj_test_001',
   entityName: 'test_proj',
   v: '0',       // renamed
   commitId: '20200528133519841',
   entityId: 'qh_proj_test_001',
   mspId: 'Org1MSP',
   event: 'Increment', // derived field
   creator: 'org1-admin', // derived field
   evstr: [{\"type\":\"Increment\", .... \"}}]   // dervied field
   ts: '1590738792' // derived field
 }
// OutputCommit - processed by postSelector
 {
   id: 'qh_proj_test_001',
   entityName: 'test_proj',
   event: 'Increment',
   mspId: 'Org1MSP',
   creator: 'org1-admin',
   commitId: '20200528133519841',
   entityId: 'qh_proj_test_001',
   version: 0,    // converted
   events: [ { type: 'Increment', ... } ],   // converted
   ts: 1590738792
 }

Const preSelector

preSelector: Selector<[PickedCommit], CommitInRedis> = createStructuredSelector({id: ([{ id }]) => id,entityName: ([{ entityName }]) => entityName,commitId: ([{ commitId }]) => commitId,mspId: ([{ mspId }]) => mspId,entityId: ([{ entityId }]) => entityId,creator: ([{ events }]) => events[0]?.payload?._creator,event: ([{ events }]) =>trimStart(events.reduce((pre, { type }) => `${pre},${type}`, ''),','),evstr: ([{ events }]) => JSON.stringify(events),ts: ([{ events }]) => (events[0]?.payload?._ts || 0).toString(),v: ([{ version }]) => version.toString(),signedRequest: ([{ signedRequest }]) => signedRequest,})
about

from PickedCommit to CommitInRedis

input

example PickedCommit

{
   id: 'qh_proj_test_001',
   entityName: 'test_proj',
   version: 0,
   commitId: '20200528133519841',
   entityId: 'qh_proj_test_001',
   mspId: 'Org1MSP',
   events: [ { type: 'Increment', payload: [Object] } ]
 }
output

example CommitInRedis

# redis-cli returns
127.0.0.1:6379> FT.SEARCH cidx qh*
2) "c:test_proj:qh_proj_test_001:20200528133519841"
3)  1) "entityName"
2) "test_proj"
3) "id"
4) "qh_proj_test_001"
5) "event"
6) "Increment"
7) "mspId"
8) "Org1MSP"
9) "creator"
10) "org1-admin"
11) "entityId"
12) "qh_proj_test_001"
13) "evstr"
14) "[{\"type\":\"Increment\",\"payload\":{\"id\":\"qh_proj_test_001\",\"desc\":\"query handler #1 proj\",\"tag\":\"projection\",\"_ts\":1590738792,\"_created\":1590738792,\"_creator\":\"org1-admin\"}}]"
15) "commitId"
16) "20200528133519841"
17) "ts"
18) "1590738792"
19) "v"
20) "0"

printf

printf: printf

Functions

Const computeEntity

Const createCommitId

  • createCommitId(): string
  • Returns string

Const createNotificationCenter

  • createNotificationCenter(client: Redisearch): object
  • about

    Parameters

    • client: Redisearch

      Redisearch client

    Returns object

    • clearNotification: function
      • clearNotification(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<object | object>

    • clearNotifications: function
      • clearNotifications(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<object | object>

    • getNotification: function
      • getNotification(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<object | object>

    • getNotificationsByFields: function
      • getNotificationsByFields(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<object | object>

    • notify: function
      • notify(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • commitId: string
          • creator: string
          • entityName: string
          • expiryBySec: number
          • id: string

        Returns Promise<object | object>

Const createPrivateRepository

  • createPrivateRepository<TEntity, TEvent>(entity: any, callback: any, option: any): object
  • about

    create repository for private data

    typeparams

    TEntity

    typeparams

    TEvent

    params

    entityName

    params

    reducer

    params

    option

    params

    parentName

    Type parameters

    • TEntity

    • TEvent

    Parameters

    • entity: any
    • callback: any
    • option: any

    Returns object

    • create: function
        • (option: object): object
        • Parameters

          • option: object
            • enrollmentId: string
            • id: string

          Returns object

    • deleteByEntityIdCommitId: RepoFcn_IdCommitId<FabricResponse>
    • getById: function
        • (option: object): Promise<object>
        • Parameters

          • option: object
            • enrollmentId: string
            • id: string

          Returns Promise<object>

    • getCommitByEntityIdCommitId: RepoFcn_IdCommitId<Commit[]>
    • getCommitByEntityName: RepoFcn<Commit[]>
    • getCommitById: RepoFcn_Id<Commit[]>
    • disconnect: function
      • disconnect(): any
      • Returns any

    • getEntityName: function
      • getEntityName(): any
      • Returns any

    • getParentName: function
      • getParentName(): any
      • Returns any

Const createQueryDatabase

  • createQueryDatabase(client: Redisearch, repos: Record<string, RedisRepository<any, any, any>>, __namedParameters?: object): object
  • about

    create query database

    example

    subscribe.unit-test.ts

    params

    client redisearch client

    params

    repos RedisRepositories

    Parameters

    • client: Redisearch
    • repos: Record<string, RedisRepository<any, any, any>>
    • Default value __namedParameters: object = { notifyExpiryBySec: 86400 }
      • notifyExpiryBySec: number

    Returns object

    QueryDatabase

    • clearNotification: function
      • Parameters

        • option: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<string[]>>

    • clearNotifications: function
      • Parameters

        • option: object
          • Optional commitId?: string
          • creator: string
          • Optional entityName?: string
          • Optional id?: string

        Returns Promise<HandlerResponse<string[]>>

    • deleteCommitByEntityId: function
      • deleteCommitByEntityId(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • entityName: string
          • id: string

        Returns Promise<object | object>

    • deleteCommitByEntityName: function
      • deleteCommitByEntityName(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • entityName: string

        Returns Promise<object | object>

    • deleteEntityByEntityName: function
      • deleteEntityByEntityName<TEntity>(__namedParameters: object): Promise<object | object>
      • Type parameters

        • TEntity

        Parameters

        • __namedParameters: object
          • entityName: any

        Returns Promise<object | object>

    • fullTextSearchCommit: function
      • fullTextSearchCommit(__namedParameters: object): Promise<HandlerResponse<any>>
      • Parameters

        • __namedParameters: object
          • countTotalOnly: boolean
          • param: FTSearchParameters
          • query: string

        Returns Promise<HandlerResponse<any>>

    • fullTextSearchEntity: function
      • fullTextSearchEntity<TEntity>(__namedParameters: object): Promise<HandlerResponse<any>>
      • Type parameters

        • TEntity

        Parameters

        • __namedParameters: object
          • countTotalOnly: any
          • entityName: any
          • param: any
          • query: any

        Returns Promise<HandlerResponse<any>>

    • getNotification: function
      • getNotification(__namedParameters: object): Promise<HandlerResponse<Record<string, string>>>
      • Parameters

        • __namedParameters: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<Record<string, string>>>

    • getNotificationsByFields: function
      • getNotificationsByFields(__namedParameters: object): Promise<HandlerResponse<Record<string, string>>>
      • Parameters

        • __namedParameters: object
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<Record<string, string>>>

    • getRedisCommitRepo: function
    • mergeCommit: function
      • mergeCommit(__namedParameters: object): Promise<object>
      • Parameters

        • __namedParameters: object

        Returns Promise<object>

    • mergeCommitBatch: function
      • mergeCommitBatch(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • commits: Record<string, Commit>
          • entityName: string

        Returns Promise<object | object>

    • mergeEntity: function
      • mergeEntity(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object

        Returns Promise<object | object>

    • mergeEntityBatch: function
      • mergeEntityBatch(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • commits: Record<string, Commit>
          • entityName: string
          • reducer: Reducer<TEntity, TEvent>

        Returns Promise<object | object>

    • queryCommitByEntityId: function
      • queryCommitByEntityId(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • entityName: string
          • id: string

        Returns Promise<object | object>

    • queryCommitByEntityName: function
      • queryCommitByEntityName(__namedParameters: object): Promise<object | object>
      • Parameters

        • __namedParameters: object
          • entityName: string

        Returns Promise<object | object>

Const createQueryHandler

  • about

    Create query handler

    example

    subscribe.unit-test.ts

    params

    options [[QueryHandlerOptions]]

    Parameters

    Returns object

    QueryHandler

    • clearNotification: function
      • clearNotification(__namedParameters: object): Promise<HandlerResponse<string[]>>
      • Parameters

        • __namedParameters: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<string[]>>

    • clearNotifications: function
      • clearNotifications(__namedParameters: object): Promise<HandlerResponse<string[]>>
      • Parameters

        • __namedParameters: object
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<string[]>>

    • command_deleteByEntityId: function
      • Parameters

        • entityName: string

        Returns RepoFcn_Id<FabricResponse>

    • command_getByEntityName: function
      • Parameters

        • entityName: string

        Returns RepoFcn<Commit[]>

    • create: function
      • create<TEvent>(entityName: any): function
      • Type parameters

        • TEvent

        Parameters

        • entityName: any

        Returns function

          • (option: object): object
          • Parameters

            • option: object
              • enrollmentId: string
              • id: string

            Returns object

    • disconnect: function
      • disconnect(): void
      • Returns void

    • fullTextSearchCommit: function
      • Type parameters

        • OutputCommit

        Parameters

        • __namedParameters: object
          • cursor: any
          • pagesize: any
          • param: any
          • query: any

        Returns Promise<HandlerResponse<Paginated<OutputCommit>>>

    • fullTextSearchEntity: function
      • Type parameters

        • TEntity

        Parameters

        • __namedParameters: object
          • cursor: any
          • entityName: any
          • pagesize: any
          • param: any
          • query: any

        Returns Promise<HandlerResponse<Paginated<TOutputEntity>>>

    • getByEntityName: function
      • getByEntityName<TEntity>(entityName: any): function
      • Type parameters

        • TEntity

        Parameters

        • entityName: any

        Returns function

    • getById: function
      • getById<TEntity, TEvent>(entityName: any): function
      • Type parameters

        • TEntity

        • TEvent

        Parameters

        • entityName: any

        Returns function

          • (option: object): Promise<object>
          • Parameters

            • option: object
              • enrollmentId: string
              • id: string

            Returns Promise<object>

    • getCommitById: function
      • Parameters

        • entityName: string

        Returns RepoFcn_Id<Commit[]>

    • getNotification: function
      • getNotification(__namedParameters: object): Promise<HandlerResponse<Record<string, string>>>
      • Parameters

        • __namedParameters: object
          • commitId: string
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<Record<string, string>>>

    • getNotifications: function
      • getNotifications(__namedParameters: object): Promise<HandlerResponse<Record<string, string>>>
      • Parameters

        • __namedParameters: object
          • creator: string
          • entityName: string
          • id: string

        Returns Promise<HandlerResponse<Record<string, string>>>

    • query_deleteCommitByEntityId: function
      • query_deleteCommitByEntityId(entityName: string): RepoFcn_Id<any>
      • Parameters

        • entityName: string

        Returns RepoFcn_Id<any>

    • query_deleteCommitByEntityName: function
      • query_deleteCommitByEntityName(entityName: string): RepoFcn<any>
      • Parameters

        • entityName: string

        Returns RepoFcn<any>

    • query_deleteEntityByEntityName: function
      • query_deleteEntityByEntityName(entityName: string): (Anonymous function)
      • Parameters

        • entityName: string

        Returns (Anonymous function)

    • reconcile: function
      • Parameters

        • payload: object
          • entityName: string

        Returns Promise<HandlerResponse<object[]> | HandlerResponse<object[]>>

    • reconciled: function
      • reconciled(): boolean
      • Returns boolean

    • subscribeHub: function
      • subscribeHub(entityNames: string[]): Promise<boolean>
      • Parameters

        • entityNames: string[]

        Returns Promise<boolean>

    • unsubscribeHub: function
      • unsubscribeHub(): void
      • Returns void

Const createRedisRepository

  • createRedisRepository<TItem, TItemInRedis, TResult>(entity: any, __namedParameters: object): object
  • about

    create abstract layer for redis repository

    typeparams

    TInput item before writing to Redis / input to pre-selector

    typeparams

    TIItemInRedis item in redis

    typeparams

    TOutput item after processing by post-selector

    Type parameters

    • TItem

    • TItemInRedis

    • TResult

    Parameters

    • entity: any
    • __namedParameters: object
      • client: any
      • fields: any
      • kind: any
      • param: any
      • postSelector: any
      • preSelector: any

    Returns object

    • createIndex: function
      • createIndex(): any
      • Returns any

    • deleteItemsByPattern: function
      • deleteItemsByPattern(pattern: string): Promise<[any, number]>
      • Parameters

        • pattern: string

        Returns Promise<[any, number]>

    • dropIndex: function
      • dropIndex(deleteHash?: boolean): any
      • Parameters

        • Default value deleteHash: boolean = true

        Returns any

    • getIndexName: function
      • getIndexName(): any
      • Returns any

    • getKey: function
      • getKey(item: TItemInRedis): any
      • Parameters

        • item: TItemInRedis

        Returns any

    • getPattern: function
      • getPattern(pattern: Pattern, args: string[]): string
      • Parameters

        Returns string

    • getPostSelector: function
      • getPostSelector(): Selector<TItemInRedis, TResult>
      • Returns Selector<TItemInRedis, TResult>

    • getPreSelector: function
      • getPreSelector(): Selector<TItem, TItemInRedis>
      • Returns Selector<TItem, TItemInRedis>

    • hgetall: function
      • hgetall(key: string): any
      • Parameters

        • key: string

        Returns any

    • hmset: function
      • hmset(item: any, history: Commit[]): any
      • Parameters

        Returns any

    • queryCommitsByPattern: function
      • queryCommitsByPattern(pattern: string): Promise<[any, OutputCommit[]]>
      • Parameters

        • pattern: string

        Returns Promise<[any, OutputCommit[]]>

    • search: function
      • search(__namedParameters: object): Promise<[Error[], any, any[]] | [any[], any, any]>
      • Parameters

        • __namedParameters: object
          • countTotalOnly: boolean
          • index: string
          • kind: "commit" | "entity"
          • param: FTSearchParameters
          • query: string
          • restoreFn: any

        Returns Promise<[Error[], any, any[]] | [any[], any, any]>

Const createRepository

  • createRepository<TEntity, TEvent>(entity: any, callback: any, option: any): object
  • about

    create repository for public / onchain data

    example

    repo.unit-test.ts

    const repo = createRepository<Counter, CounterEvent>(
        entityName,
        reducer,
        {
            queryDatabase,
            gateway,
            network,
            channelName,
            connectionProfile,
            wallet,
            logger,
      });
    typeparams

    TEntity

    typeparams

    TEvent

    params

    entityName

    params

    reducer Reducer

    params

    option RepoOption

    Type parameters

    • TEntity

    • TEvent

    Parameters

    • entity: any
    • callback: any
    • option: any

    Returns object

    • command_deleteByEntityId: RepoFcn_Id<FabricResponse>
    • command_getByEntityIdCommitId: RepoFcn_IdCommitId<Commit[]>
    • command_getByEntityName: RepoFcn<Commit[]>
    • create: function
        • (option: object): object
        • Parameters

          • option: object
            • enrollmentId: string
            • id: string

          Returns object

    • getByEntityName: function
    • getById: function
        • (option: object): Promise<object>
        • Parameters

          • option: object
            • enrollmentId: string
            • id: string

          Returns Promise<object>

    • getCommitById: RepoFcn_Id<Commit[]>
    • query_deleteCommitByEntityId: RepoFcn_Id<any>
    • query_deleteCommitByEntityName: RepoFcn<any>
    • disconnect: function
      • disconnect(): any
      • Returns any

    • fullTextSearchCommit: function
      • Parameters

        • __namedParameters: object
          • cursor: number
          • pagesize: number
          • param: FTSearchParameters
          • query: string

        Returns Promise<HandlerResponse<Paginated<Commit>>>

    • fullTextSearchEntity: function
      • Parameters

        • __namedParameters: object
          • cursor: number
          • entityName: string
          • pagesize: number
          • param: FTSearchParameters
          • query: string

        Returns Promise<HandlerResponse<Paginated<TOutputEntity>>>

    • getEntityName: function
      • getEntityName(): any
      • Returns any

Const dispatchSearch

  • dispatchSearch<TResult, TArg>(__namedParameters: object): function
  • Type parameters

    • TResult

    • TArg

    Parameters

    • __namedParameters: object
      • logger: any
      • store: any

    Returns function

Const evaluate

  • evaluate(fcn: string, args: string[], __namedParameters: object): Promise<Record<string, Commit> | object>
  • about

    evaluate transaction

    params

    fcn function

    params

    args args

    params

    network network { network: Network }

    Parameters

    • fcn: string
    • args: string[]
    • __namedParameters: object
      • network: Network

    Returns Promise<Record<string, Commit> | object>

    Record<string, Commit> | { error: any }

Const evaluate$

  • evaluate$(fcn: string, args: string[], options: object): Observable<Record<string, Commit> | object>
  • about

    observables

    params

    fcn

    params

    args

    params

    options

    Parameters

    • fcn: string
    • args: string[]
    • options: object
      • network: Network

    Returns Observable<Record<string, Commit> | object>

Const getContract

  • getContract(network: Network): Promise<object>
  • about

    return contract of fabric-sdk Notice that the contract is hardcoded 'eventstore'

    params

    fabric-network.Network

    Parameters

    • network: Network

    Returns Promise<object>

    { contract: fabric-network.Contract }

Const getEntities

  • getEntities(__namedParameters: object): any[]
  • Parameters

    • __namedParameters: object
      • entityName: any
      • mockdb: any
      • reducer: any

    Returns any[]

Const getEntities

  • getEntities(__namedParameters: object): any[]
  • Parameters

    • __namedParameters: object
      • entityName: any
      • mockdb: any
      • reducer: any

    Returns any[]

Const getHistory

  • getHistory(commits: Commit[]): any[]
  • Parameters

    Returns any[]

Const getHistory

  • getHistory(commits: Commit[]): any[]
  • Parameters

    Returns any[]

Const getLogger

  • getLogger(__namedParameters: object): Logger
  • Parameters

    • __namedParameters: object
      • level: string
      • name: string
      • target: string
      • timezone: string

    Returns Logger

Const getMockRepository

  • getMockRepository<TEntity, TEvent>(mockdb: Record<string, Commit>, entityName: string, reducer: function): Pick<Repository<TEntity, TEvent>, "create" | "getById" | "getByEntityName" | "getCommitById" | "getEntityName" | "fullTextSearchEntity">
  • about

    create mock repository for public / onchain data

    params

    mockdb

    params

    entityName

    params

    reducer

    Type parameters

    • TEntity

    • TEvent

    Parameters

    • mockdb: Record<string, Commit>
    • entityName: string
    • reducer: function
        • (history: any): TEntity
        • Parameters

          • history: any

          Returns TEntity

    Returns Pick<Repository<TEntity, TEvent>, "create" | "getById" | "getByEntityName" | "getCommitById" | "getEntityName" | "fullTextSearchEntity">

Const getNetwork

  • getNetwork(__namedParameters: object): Promise<object>
  • about

    get network services Special Notes:

    1. asLocalhost is used only for running with docker-compose
    2. discovery is used for on chain / public data only
    params

    option

    Parameters

    • __namedParameters: object
      • asLocalhost: boolean
      • channelName: string
      • connectionProfile: string
      • discovery: boolean
      • enrollmentId: string
      • eventHandlerStrategy: any
      • queryHandlerStrategy: any
      • wallet: Wallet

    Returns Promise<object>

    {
      enrollmentId: string;
      network: Network;
      gateway: Gateway;
    }

Const getPaginated

  • getPaginated(items: T[], total: any, cursor: number): object
  • Parameters

    • items: T[]
    • total: any
    • cursor: number

    Returns object

    • cursor: number
    • hasMore: boolean
    • items: T[]
    • total: any

Const getPrivateMockRepository

  • getPrivateMockRepository<TEntity, TEvent>(mockdb: Record<string, Commit>, entityName: string, reducer: function): Pick<PrivateRepository<TEntity, TEvent>, "create" | "getById" | "getCommitByEntityName" | "getEntityName">
  • about

    create mocked repository for private data

    params

    mockdb

    params

    entityName

    params

    reducer

    Type parameters

    • TEntity

    • TEvent

    Parameters

    • mockdb: Record<string, Commit>
    • entityName: string
    • reducer: function
        • (history: any): TEntity
        • Parameters

          • history: any

          Returns TEntity

    Returns Pick<PrivateRepository<TEntity, TEvent>, "create" | "getById" | "getCommitByEntityName" | "getEntityName">

Const getReducer

  • about

    return high order reducer function

    Type parameters

    Parameters

    Returns Reducer<T, E>

Const isBaseEventArray

  • isBaseEventArray(input: any): input
  • Parameters

    • input: any

    Returns input

Const isCommit

  • isCommit(value: any): value
  • Parameters

    • value: any

    Returns value

Const isCommitRecord

  • isCommitRecord(input: Record<string, any>): input
  • Parameters

    • input: Record<string, any>

    Returns input

Const isFabricResponse

  • isFabricResponse(input: any): input
  • Parameters

    • input: any

    Returns input

Const isOutputCommit

  • isOutputCommit(value: any): value
  • Parameters

    • value: any

    Returns value

Const queryFullTextSearch

  • queryFullTextSearch<TItem>(__namedParameters: object): Promise<object | object>
  • Type parameters

    • TItem

    Parameters

    • __namedParameters: object
      • cursor: any
      • entityName: any
      • logger: any
      • pagesize: any
      • param: any
      • query: any
      • store: any

    Returns Promise<object | object>

Const submit

  • submit(fcn: string, args: string[], __namedParameters: object): Promise<Record<string, Commit> | object>
  • about

    submit transaction to eventstore chaincode

    params

    fcn function

    params

    args args

    params

    network { network: Network }

    Parameters

    • fcn: string
    • args: string[]
    • __namedParameters: object
      • network: Network

    Returns Promise<Record<string, Commit> | object>

    Record<string, Commit> & { error?: any; status?: string; message?: string }

Const submit$

  • submit$(fcn: string, args: string[], options: object): Observable<Record<string, Commit> & object>
  • about

    observables

    params

    fcn

    params

    args

    params

    options

    Parameters

    • fcn: string
    • args: string[]
    • options: object
      • network: Network

    Returns Observable<Record<string, Commit> & object>

Const submitPrivateData

  • submitPrivateData(fcn: string, args: string[], transientData: Record<string, Buffer>, __namedParameters: object): Promise<Record<string, Commit> | object>
  • about

    submit transaction to privatedata chaincode

    params

    fcn function

    params

    args args

    params

    transientData transient data

    params

    network network

    Parameters

    • fcn: string
    • args: string[]
    • transientData: Record<string, Buffer>
    • __namedParameters: object
      • network: Network

    Returns Promise<Record<string, Commit> | object>

Const submitPrivateData$

  • submitPrivateData$(fcn: string, args: string[], transientData: Record<string, Buffer>, options: object): Observable<Record<string, Commit> & object>
  • about

    observables

    params

    fcn

    params

    args

    params

    transientData

    params

    options

    Parameters

    • fcn: string
    • args: string[]
    • transientData: Record<string, Buffer>
    • options: object
      • network: Network

    Returns Observable<Record<string, Commit> & object>

Const trackingReducer

  • trackingReducer(commits: Commit[]): object | object | object
  • about

    reducer for private data tracking events.

    Parameters

    Returns object | object | object

Object literals

Const baseIndexDefinition

baseIndexDefinition: object

_created

_created: object

altName

altName: string = "created"

index

index: object

sortable

sortable: boolean = true

type

type: string = "NUMERIC"

_creator

_creator: object

altName

altName: string = "creator"

index

index: object

type

type: string = "TEXT"

_organization

_organization: object

altName

altName: string = "organization"

index

index: object

sortable

sortable: boolean = true

type

type: string = "TEXT"

_ts

_ts: object

altName

altName: string = "ts"

index

index: object

sortable

sortable: boolean = true

type

type: string = "NUMERIC"

Const commitSearchDefinition

commitSearchDefinition: object
about

Redisearch index definition of CommitInRedis. This is internal use only.

commitId

commitId: object

Type declaration

evstr

evstr: object

Derived field of stringified events

Type declaration

signedRequest

signedRequest: object

Type declaration

version

version: object

Type declaration

creator

creator: object

Derived field of _creator event name involved

index

index: object

type

type: string = "TEXT"

entityName

entityName: object

index

index: object

sortable

sortable: true = true

type

type: string = "TEXT"

event

event: object

Derived field of _event - it indicates event name included in this commit

index

index: object

type

type: string = "TAG"

id

id: object

same as entityId

index

index: object

sortable

sortable: true = true

type

type: string = "TEXT"

mspId

mspId: object

MSP Id

index

index: object

type

type: string = "TAG"

ts

ts: object

Derived field of _ts, i.e. timestamp

index

index: object

sortable

sortable: true = true

type

type: string = "NUMERIC"