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
-
↳
LocsState
Table of contents
Constructors
Properties
Accessors
- acceptedRequests
- client
- closedLocs
- closedVerifiedIssuerLocs
- discarded
- draftRequests
- isVerifiedIssuer
- legalOfficer
- legalOfficersWithValidIdentityLoc
- openLocs
- openVerifiedIssuerLocs
- pendingRequests
- rejectedRequests
- voidedLocs
Methods
- _refresh
- _refreshWith
- _refreshWithout
- computeIsVerifiedIssuer
- discard
- discardOnSuccess
- ensureCurrent
- finalizeOnSuccess
- findById
- findByIdOrUndefined
- getCurrentState
- getCurrentStateOrThrow
- getLocRequestState
- getVerifiedIssuerLegalOfficers
- hasValidIdentityLoc
- isDefinedLegalOfficer
- isVerifiedIssuerLoc
- openCollectionLoc
- openIdentityLoc
- openLoc
- openTransactionLoc
- refresh
- refreshStates
- refreshWith
- refreshWithout
- requestCollectionLoc
- requestIdentityLoc
- requestLoc
- requestTransactionLoc
- syncDiscardOnSuccess
- toBackendCollectionParams
- toState
- toStates
- filter
- getInitialLocsState
- withPredicate
Constructors
constructor
• new LocsState(sharedState, locs, client, verifiedIssuerLocs): LocsState
Parameters
| Name | Type |
|---|---|
sharedState | SharedState |
locs | Record<string, LocRequestState> |
client | LogionClient |
verifiedIssuerLocs | Record<string, LocRequestState> |
Returns
Overrides
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
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
Defined in
packages/client/src/Loc.ts:597
legalOfficersWithValidIdentityLoc
• get legalOfficersWithValidIdentityLoc(): LegalOfficerClass[]
Returns
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
| Name | Type |
|---|---|
params? | FetchAllLocsParams |
Returns
Promise<LocsState>
Defined in
packages/client/src/Loc.ts:479
_refreshWith
▸ _refreshWith(loc): LocsState
Parameters
| Name | Type |
|---|---|
loc | LocRequestState |
Returns
Defined in
packages/client/src/Loc.ts:237
_refreshWithout
▸ _refreshWithout(locId): LocsState
Parameters
| Name | Type |
|---|---|
locId | UUID |
Returns
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
| Name | Type |
|---|---|
next | undefined | 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
Defined in
packages/client/src/State.ts:43
discardOnSuccess
▸ discardOnSuccess<T, U>(action): Promise<U>
Type parameters
| Name | Type |
|---|---|
T | extends State |
U | extends State = T |
Parameters
| Name | Type | Description |
|---|---|---|
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
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
Defined in
packages/client/src/State.ts:32
finalizeOnSuccess
▸ finalizeOnSuccess<T>(action): Promise<void>
Type parameters
| Name | Type |
|---|---|
T | extends State |
Parameters
| Name | Type | Description |
|---|---|---|
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
Defined in
packages/client/src/State.ts:117
findById
▸ findById(locId): LocRequestState
Parameters
| Name | Type |
|---|---|
locId | UUID |
Returns
Defined in
packages/client/src/Loc.ts:280
findByIdOrUndefined
▸ findByIdOrUndefined(locId): undefined | LocRequestState
Parameters
| Name | Type |
|---|---|
locId | UUID |
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
Defined in
packages/client/src/State.ts:90
getCurrentStateOrThrow
▸ getCurrentStateOrThrow(): State
Returns
Inherited from
Defined in
packages/client/src/State.ts:102
getLocRequestState
▸ getLocRequestState(index): undefined | LocRequestState
Parameters
| Name | Type |
|---|---|
index | number |
Returns
undefined | LocRequestState
Defined in
packages/client/src/Loc.ts:200
getVerifiedIssuerLegalOfficers
▸ getVerifiedIssuerLegalOfficers(locsState): LegalOfficerClass[]
Parameters
| Name | Type |
|---|---|
locsState | LocsState |
Returns
Defined in
packages/client/src/Loc.ts:550
hasValidIdentityLoc
▸ hasValidIdentityLoc(legalOfficer): boolean
Parameters
| Name | Type |
|---|---|
legalOfficer | LegalOfficer |
Returns
boolean
Defined in
packages/client/src/Loc.ts:207
isDefinedLegalOfficer
▸ isDefinedLegalOfficer(legalOfficer): legalOfficer is LegalOfficerClass
Parameters
| Name | Type |
|---|---|
legalOfficer | undefined | LegalOfficerClass |
Returns
legalOfficer is LegalOfficerClass
Defined in
packages/client/src/Loc.ts:558
isVerifiedIssuerLoc
▸ isVerifiedIssuerLoc(loc): boolean
Parameters
| Name | Type |
|---|---|
loc | LocRequestState |
Returns
boolean
Defined in
packages/client/src/Loc.ts:260
openCollectionLoc
▸ openCollectionLoc(params): Promise<OpenLoc>
Parameters
| Name | Type |
|---|---|
params | CreateCollectionLocParams & ItemsParams & BlockchainSubmissionParams |
Returns
Promise<OpenLoc>
Defined in
packages/client/src/Loc.ts:382
openIdentityLoc
▸ openIdentityLoc(params): Promise<OpenLoc>
Parameters
| Name | Type |
|---|---|
params | CreateIdentityLocParams & ItemsParams & BlockchainSubmissionParams |
Returns
Promise<OpenLoc>
Defined in
packages/client/src/Loc.ts:393
openLoc
▸ openLoc(params): Promise<OpenLoc>
Parameters
| Name | Type |
|---|---|
params | BlockchainSubmission<CreateAnyLocParams & ItemsParams> |
Returns
Promise<OpenLoc>
Defined in
packages/client/src/Loc.ts:407
openTransactionLoc
▸ openTransactionLoc(params): Promise<OpenLoc>
Parameters
| Name | Type |
|---|---|
params | CreateLocParams & ItemsParams & BlockchainSubmissionParams |
Returns
Promise<OpenLoc>
Defined in
packages/client/src/Loc.ts:375
refresh
▸ refresh(params?): Promise<LocsState>
Parameters
| Name | Type |
|---|---|
params? | FetchAllLocsParams |
Returns
Promise<LocsState>
Defined in
packages/client/src/Loc.ts:475
refreshStates
▸ refreshStates(locsState, states): Record<string, LocRequestState>
Parameters
| Name | Type |
|---|---|
locsState | LocsState |
states | Record<string, LocRequestState> |
Returns
Record<string, LocRequestState>
Defined in
packages/client/src/Loc.ts:251
refreshWith
▸ refreshWith(loc): LocsState
Parameters
| Name | Type |
|---|---|
loc | LocRequestState |
Returns
Defined in
packages/client/src/Loc.ts:233
refreshWithout
▸ refreshWithout(locId): LocsState
Parameters
| Name | Type |
|---|---|
locId | UUID |
Returns
Defined in
packages/client/src/Loc.ts:264
requestCollectionLoc
▸ requestCollectionLoc(params): Promise<DraftRequest | PendingRequest>
Parameters
| Name | Type |
|---|---|
params | CreateCollectionLocRequestParams |
Returns
Promise<DraftRequest | PendingRequest>
Defined in
packages/client/src/Loc.ts:307
requestIdentityLoc
▸ requestIdentityLoc(params): Promise<DraftRequest | PendingRequest>
Parameters
| Name | Type |
|---|---|
params | CreateIdentityLocRequestParams |
Returns
Promise<DraftRequest | PendingRequest>
Defined in
packages/client/src/Loc.ts:318
requestLoc
▸ requestLoc(params): Promise<DraftRequest | PendingRequest>
Parameters
| Name | Type |
|---|---|
params | CreateAnyLocRequestParams |
Returns
Promise<DraftRequest | PendingRequest>
Defined in
packages/client/src/Loc.ts:335
requestTransactionLoc
▸ requestTransactionLoc(params): Promise<DraftRequest | PendingRequest>
Parameters
| Name | Type |
|---|---|
params | CreateLocRequestParams |
Returns
Promise<DraftRequest | PendingRequest>
Defined in
packages/client/src/Loc.ts:300
syncDiscardOnSuccess
▸ syncDiscardOnSuccess<T, U>(action): U
Type parameters
| Name | Type |
|---|---|
T | extends State |
U | extends State = T |
Parameters
| Name | Type | Description |
|---|---|---|
action | (current: T) => U | The 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
Defined in
packages/client/src/State.ts:73
toBackendCollectionParams
▸ toBackendCollectionParams(collectionParams): undefined | BackendCollectionParams
Parameters
| Name | Type |
|---|---|
collectionParams | undefined | CollectionParams |
Returns
undefined | BackendCollectionParams
Defined in
packages/client/src/Loc.ts:365
toState
▸ toState(locMultiClient, locsState, locRequest, locBatch): Promise<AnyLocState>
Parameters
| Name | Type |
|---|---|
locMultiClient | LocMultiClient |
locsState | LocsState |
locRequest | LocRequest |
locBatch | LocBatch |
Returns
Promise<AnyLocState>
Defined in
packages/client/src/Loc.ts:521
toStates
▸ toStates(locMultiClient, locsState, locRequests, locBatch): Promise<Record<string, LocRequestState>>
Parameters
| Name | Type |
|---|---|
locMultiClient | LocMultiClient |
locsState | LocsState |
locRequests | LocRequest[] |
locBatch | LocBatch |
Returns
Promise<Record<string, LocRequestState>>
Defined in
packages/client/src/Loc.ts:503
filter
▸ filter<T>(locs, locType, predicate): T[]
Type parameters
| Name | Type |
|---|---|
T | extends LocRequestState |
Parameters
| Name | Type |
|---|---|
locs | Record<string, LocRequestState> |
locType | LocType |
predicate | (loc: LocRequestState) => boolean |
Returns
T[]
Defined in
packages/client/src/Loc.ts:226
getInitialLocsState
▸ getInitialLocsState(sharedState, client, params?): Promise<LocsState>
Parameters
| Name | Type |
|---|---|
sharedState | SharedState |
client | LogionClient |
params? | FetchAllLocsParams |
Returns
Promise<LocsState>
Defined in
packages/client/src/Loc.ts:276
withPredicate
▸ withPredicate<T>(locs, predicate): Record<LocType, T[]>
Type parameters
| Name | Type |
|---|---|
T | extends LocRequestState |
Parameters
| Name | Type |
|---|---|
locs | Record<string, LocRequestState> |
predicate | (l: LocRequestState) => boolean |
Returns
Record<LocType, T[]>