Skip to main content

Reference / Modules / client / LocsState

Class: LocsState

client.LocsState

A State instance is a state in the "state machine" sense. It comes with some behavior and state transition methods. A state transition method returns an instance of the next state given the executed operation, which discards current object.

This class should be extended by client class. It provides method enabling the client class to query if it was already discarded or not as well as methods actually discarding the state.

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new LocsState(sharedState, locs, client, verifiedIssuerLocs): LocsState

Parameters

NameType
sharedStateSharedState
locsRecord<string, LocRequestState>
clientLogionClient
verifiedIssuerLocsRecord<string, LocRequestState>

Returns

LocsState

Overrides

State.constructor

Defined in

packages/client/src/Loc.ts:159

Properties

_client

Private Readonly _client: LogionClient

Defined in

packages/client/src/Loc.ts:157


_isVerifiedIssuer

Private _isVerifiedIssuer: undefined | boolean

Defined in

packages/client/src/Loc.ts:576


_locs

Private _locs: Record<string, LocRequestState>

Defined in

packages/client/src/Loc.ts:155


_verifiedIssuerLocs

Private _verifiedIssuerLocs: Record<string, LocRequestState>

Defined in

packages/client/src/Loc.ts:156


sharedState

Private Readonly sharedState: SharedState

Defined in

packages/client/src/Loc.ts:154

Accessors

acceptedRequests

get acceptedRequests(): Record<LocType, AcceptedRequest[]>

Returns

Record<LocType, AcceptedRequest[]>

Defined in

packages/client/src/Loc.ts:196


client

get client(): LogionClient

Returns

LogionClient

Defined in

packages/client/src/Loc.ts:562


closedLocs

get closedLocs(): Record<LocType, (ClosedLoc | ClosedCollectionLoc)[]>

Returns

Record<LocType, (ClosedLoc | ClosedCollectionLoc)[]>

Defined in

packages/client/src/Loc.ts:180


closedVerifiedIssuerLocs

get closedVerifiedIssuerLocs(): Record<LocType, (ClosedLoc | ClosedCollectionLoc)[]>

Returns

Record<LocType, (ClosedLoc | ClosedCollectionLoc)[]>

Defined in

packages/client/src/Loc.ts:590


discarded

get discarded(): boolean

Returns

boolean

Description

True if this state was discarded

Inherited from

State.discarded

Defined in

packages/client/src/State.ts:24


draftRequests

get draftRequests(): Record<LocType, DraftRequest[]>

Returns

Record<LocType, DraftRequest[]>

Defined in

packages/client/src/Loc.ts:172


isVerifiedIssuer

get isVerifiedIssuer(): boolean

Tells if current user is a Verified Issuer.

Returns

boolean

True if it is, false otherwise.

Defined in

packages/client/src/Loc.ts:571


legalOfficer

get legalOfficer(): LegalOfficerLocsStateCommands

Returns

LegalOfficerLocsStateCommands

Defined in

packages/client/src/Loc.ts:597


legalOfficersWithValidIdentityLoc

get legalOfficersWithValidIdentityLoc(): LegalOfficerClass[]

Returns

LegalOfficerClass[]

Defined in

packages/client/src/Loc.ts:214


openLocs

get openLocs(): Record<LocType, OpenLoc[]>

Returns

Record<LocType, OpenLoc[]>

Defined in

packages/client/src/Loc.ts:176


openVerifiedIssuerLocs

get openVerifiedIssuerLocs(): Record<LocType, OpenLoc[]>

Returns

Record<LocType, OpenLoc[]>

Defined in

packages/client/src/Loc.ts:583


pendingRequests

get pendingRequests(): Record<LocType, PendingRequest[]>

Returns

Record<LocType, PendingRequest[]>

Defined in

packages/client/src/Loc.ts:188


rejectedRequests

get rejectedRequests(): Record<LocType, RejectedRequest[]>

Returns

Record<LocType, RejectedRequest[]>

Defined in

packages/client/src/Loc.ts:192


voidedLocs

get voidedLocs(): Record<LocType, (VoidedLoc | VoidedCollectionLoc)[]>

Returns

Record<LocType, (VoidedLoc | VoidedCollectionLoc)[]>

Defined in

packages/client/src/Loc.ts:184

Methods

_refresh

_refresh(params?): Promise<LocsState>

Parameters

NameType
params?FetchAllLocsParams

Returns

Promise<LocsState>

Defined in

packages/client/src/Loc.ts:479


_refreshWith

_refreshWith(loc): LocsState

Parameters

NameType
locLocRequestState

Returns

LocsState

Defined in

packages/client/src/Loc.ts:237


_refreshWithout

_refreshWithout(locId): LocsState

Parameters

NameType
locIdUUID

Returns

LocsState

Defined in

packages/client/src/Loc.ts:268


computeIsVerifiedIssuer

computeIsVerifiedIssuer(): boolean

Returns

boolean

Defined in

packages/client/src/Loc.ts:578


discard

discard(next): void

Parameters

NameType
nextundefined | State

Returns

void

Description

Discards current state. One must discard the state only if the state transition was successfully executed. It may be safer to use discardOnSuccess.

Inherited from

State.discard

Defined in

packages/client/src/State.ts:43


discardOnSuccess

discardOnSuccess<T, U>(action): Promise<U>

Type parameters

NameType
Textends State
Uextends State = T

Parameters

NameTypeDescription
action(current: T) => Promise<U>The state transition logic producing next state

Returns

Promise<U>

Next state if state transition logic execution did not throw

Descripiton

Discards current state only if given state transition logic executed successfully (i.e. without throwing an error).

Inherited from

State.discardOnSuccess

Defined in

packages/client/src/State.ts:55


ensureCurrent

ensureCurrent(): void

Returns

void

Description

Throws an error if this state was discarded. This should be called by all public methods of client class.

Inherited from

State.ensureCurrent

Defined in

packages/client/src/State.ts:32


finalizeOnSuccess

finalizeOnSuccess<T>(action): Promise<void>

Type parameters

NameType
Textends State

Parameters

NameTypeDescription
action(current: T) => Promise<void>The state transition logic producing next state

Returns

Promise<void>

Next state if state transition logic execution did not throw

Descripiton

Finalizes (i.e. replaces with no new state) current state only if given state transition logic executed successfully (i.e. without throwing an error).

Inherited from

State.finalizeOnSuccess

Defined in

packages/client/src/State.ts:117


findById

findById(locId): LocRequestState

Parameters

NameType
locIdUUID

Returns

LocRequestState

Defined in

packages/client/src/Loc.ts:280


findByIdOrUndefined

findByIdOrUndefined(locId): undefined | LocRequestState

Parameters

NameType
locIdUUID

Returns

undefined | LocRequestState

Defined in

packages/client/src/Loc.ts:289


getCurrentState

getCurrentState(): undefined | State

Returns

undefined | State

This state if not discareded or the current state or undefined when there is no current state.

Description

If the state has been discarded, provides the replacing current state if any.

Inherited from

State.getCurrentState

Defined in

packages/client/src/State.ts:90


getCurrentStateOrThrow

getCurrentStateOrThrow(): State

Returns

State

Inherited from

State.getCurrentStateOrThrow

Defined in

packages/client/src/State.ts:102


getLocRequestState

getLocRequestState(index): undefined | LocRequestState

Parameters

NameType
indexnumber

Returns

undefined | LocRequestState

Defined in

packages/client/src/Loc.ts:200


getVerifiedIssuerLegalOfficers

getVerifiedIssuerLegalOfficers(locsState): LegalOfficerClass[]

Parameters

NameType
locsStateLocsState

Returns

LegalOfficerClass[]

Defined in

packages/client/src/Loc.ts:550


hasValidIdentityLoc

hasValidIdentityLoc(legalOfficer): boolean

Parameters

NameType
legalOfficerLegalOfficer

Returns

boolean

Defined in

packages/client/src/Loc.ts:207


isDefinedLegalOfficer

isDefinedLegalOfficer(legalOfficer): legalOfficer is LegalOfficerClass

Parameters

NameType
legalOfficerundefined | LegalOfficerClass

Returns

legalOfficer is LegalOfficerClass

Defined in

packages/client/src/Loc.ts:558


isVerifiedIssuerLoc

isVerifiedIssuerLoc(loc): boolean

Parameters

NameType
locLocRequestState

Returns

boolean

Defined in

packages/client/src/Loc.ts:260


openCollectionLoc

openCollectionLoc(params): Promise<OpenLoc>

Parameters

NameType
paramsCreateCollectionLocParams & ItemsParams & BlockchainSubmissionParams

Returns

Promise<OpenLoc>

Defined in

packages/client/src/Loc.ts:382


openIdentityLoc

openIdentityLoc(params): Promise<OpenLoc>

Parameters

NameType
paramsCreateIdentityLocParams & ItemsParams & BlockchainSubmissionParams

Returns

Promise<OpenLoc>

Defined in

packages/client/src/Loc.ts:393


openLoc

openLoc(params): Promise<OpenLoc>

Parameters

NameType
paramsBlockchainSubmission<CreateAnyLocParams & ItemsParams>

Returns

Promise<OpenLoc>

Defined in

packages/client/src/Loc.ts:407


openTransactionLoc

openTransactionLoc(params): Promise<OpenLoc>

Parameters

NameType
paramsCreateLocParams & ItemsParams & BlockchainSubmissionParams

Returns

Promise<OpenLoc>

Defined in

packages/client/src/Loc.ts:375


refresh

refresh(params?): Promise<LocsState>

Parameters

NameType
params?FetchAllLocsParams

Returns

Promise<LocsState>

Defined in

packages/client/src/Loc.ts:475


refreshStates

refreshStates(locsState, states): Record<string, LocRequestState>

Parameters

NameType
locsStateLocsState
statesRecord<string, LocRequestState>

Returns

Record<string, LocRequestState>

Defined in

packages/client/src/Loc.ts:251


refreshWith

refreshWith(loc): LocsState

Parameters

NameType
locLocRequestState

Returns

LocsState

Defined in

packages/client/src/Loc.ts:233


refreshWithout

refreshWithout(locId): LocsState

Parameters

NameType
locIdUUID

Returns

LocsState

Defined in

packages/client/src/Loc.ts:264


requestCollectionLoc

requestCollectionLoc(params): Promise<DraftRequest | PendingRequest>

Parameters

NameType
paramsCreateCollectionLocRequestParams

Returns

Promise<DraftRequest | PendingRequest>

Defined in

packages/client/src/Loc.ts:307


requestIdentityLoc

requestIdentityLoc(params): Promise<DraftRequest | PendingRequest>

Parameters

NameType
paramsCreateIdentityLocRequestParams

Returns

Promise<DraftRequest | PendingRequest>

Defined in

packages/client/src/Loc.ts:318


requestLoc

requestLoc(params): Promise<DraftRequest | PendingRequest>

Parameters

NameType
paramsCreateAnyLocRequestParams

Returns

Promise<DraftRequest | PendingRequest>

Defined in

packages/client/src/Loc.ts:335


requestTransactionLoc

requestTransactionLoc(params): Promise<DraftRequest | PendingRequest>

Parameters

NameType
paramsCreateLocRequestParams

Returns

Promise<DraftRequest | PendingRequest>

Defined in

packages/client/src/Loc.ts:300


syncDiscardOnSuccess

syncDiscardOnSuccess<T, U>(action): U

Type parameters

NameType
Textends State
Uextends State = T

Parameters

NameTypeDescription
action(current: T) => UThe state transition logic producing next state

Returns

U

Next state if state transition logic execution did not throw

Descripiton

Same as discardOnSuccess but with a synchronous action.

Inherited from

State.syncDiscardOnSuccess

Defined in

packages/client/src/State.ts:73


toBackendCollectionParams

toBackendCollectionParams(collectionParams): undefined | BackendCollectionParams

Parameters

NameType
collectionParamsundefined | CollectionParams

Returns

undefined | BackendCollectionParams

Defined in

packages/client/src/Loc.ts:365


toState

toState(locMultiClient, locsState, locRequest, locBatch): Promise<AnyLocState>

Parameters

NameType
locMultiClientLocMultiClient
locsStateLocsState
locRequestLocRequest
locBatchLocBatch

Returns

Promise<AnyLocState>

Defined in

packages/client/src/Loc.ts:521


toStates

toStates(locMultiClient, locsState, locRequests, locBatch): Promise<Record<string, LocRequestState>>

Parameters

NameType
locMultiClientLocMultiClient
locsStateLocsState
locRequestsLocRequest[]
locBatchLocBatch

Returns

Promise<Record<string, LocRequestState>>

Defined in

packages/client/src/Loc.ts:503


filter

filter<T>(locs, locType, predicate): T[]

Type parameters

NameType
Textends LocRequestState

Parameters

NameType
locsRecord<string, LocRequestState>
locTypeLocType
predicate(loc: LocRequestState) => boolean

Returns

T[]

Defined in

packages/client/src/Loc.ts:226


getInitialLocsState

getInitialLocsState(sharedState, client, params?): Promise<LocsState>

Parameters

NameType
sharedStateSharedState
clientLogionClient
params?FetchAllLocsParams

Returns

Promise<LocsState>

Defined in

packages/client/src/Loc.ts:276


withPredicate

withPredicate<T>(locs, predicate): Record<LocType, T[]>

Type parameters

NameType
Textends LocRequestState

Parameters

NameType
locsRecord<string, LocRequestState>
predicate(l: LocRequestState) => boolean

Returns

Record<LocType, T[]>

Defined in

packages/client/src/Loc.ts:218