API Reference
classes
Perspectiveproxy

@perspect3vism/ad4m / Exports / PerspectiveProxy

Class: PerspectiveProxy

Perspective UI proxy object

Convenience object for UIs to interact with a perspective. It is created by some of the methods in the PerspectiveClient class and includes a reference to the PerspectiveClient object that created it.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new PerspectiveProxy(handle, ad4m)

Parameters

NameType
handlePerspectiveHandle
ad4mPerspectiveClient

Defined in

perspectives/PerspectiveProxy.ts:35 (opens in a new tab)

Properties

#client

Private #client: PerspectiveClient

Defined in

perspectives/PerspectiveProxy.ts:29 (opens in a new tab)


#handle

Private #handle: PerspectiveHandle

Defined in

perspectives/PerspectiveProxy.ts:28 (opens in a new tab)


#perspectiveLinkAddedCallbacks

Private #perspectiveLinkAddedCallbacks: LinkCallback[]

Defined in

perspectives/PerspectiveProxy.ts:30 (opens in a new tab)


#perspectiveLinkRemovedCallbacks

Private #perspectiveLinkRemovedCallbacks: LinkCallback[]

Defined in

perspectives/PerspectiveProxy.ts:31 (opens in a new tab)


#perspectiveLinkUpdatedCallbacks

Private #perspectiveLinkUpdatedCallbacks: LinkCallback[]

Defined in

perspectives/PerspectiveProxy.ts:32 (opens in a new tab)


#perspectiveSyncStateChangeCallbacks

Private #perspectiveSyncStateChangeCallbacks: SyncStateChangeCallback[]

Defined in

perspectives/PerspectiveProxy.ts:33 (opens in a new tab)

Accessors

name

get name(): string

Given name of the perspective

Returns

string

Defined in

perspectives/PerspectiveProxy.ts:106 (opens in a new tab)


neighbourhood

get neighbourhood(): void | Neighbourhood

If the perspective is shared as a Neighbourhood, this is the Neighbourhood Expression

Returns

void | Neighbourhood

Defined in

perspectives/PerspectiveProxy.ts:116 (opens in a new tab)


sharedUrl

get sharedUrl(): string | void

If the perspective is shared as a Neighbourhood, this is the Neighbourhood URL

Returns

string | void

Defined in

perspectives/PerspectiveProxy.ts:111 (opens in a new tab)


state

get state(): PerspectiveState

Returns the state of the perspective *

Returns

PerspectiveState

Defined in

perspectives/PerspectiveProxy.ts:121 (opens in a new tab)


uuid

get uuid(): string

Unique ID of the perspective

Returns

string

Defined in

perspectives/PerspectiveProxy.ts:101 (opens in a new tab)

Methods

add

add(link, status?): Promise<LinkExpression>

Adds a link to this perspective

Parameters

NameTypeDefault value
linkLinkundefined
statusLinkStatus'shared'

Returns

Promise<LinkExpression>

Defined in

perspectives/PerspectiveProxy.ts:136 (opens in a new tab)


addLinkExpression

addLinkExpression(link, status?): Promise<LinkExpression>

Adds a linkExpression to this perspective

Parameters

NameTypeDefault value
linkLinkExpressionundefined
statusLinkStatus'shared'

Returns

Promise<LinkExpression>

Defined in

perspectives/PerspectiveProxy.ts:156 (opens in a new tab)


addLinks

addLinks(links, status?): Promise<LinkExpression[]>

Adds multiple links to this perspective *

Parameters

NameTypeDefault value
linksLink[]undefined
statusLinkStatus'shared'

Returns

Promise<LinkExpression[]>

Defined in

perspectives/PerspectiveProxy.ts:141 (opens in a new tab)


addListener

addListener(type, cb): Promise<void>

Adds a link listener

Parameters

NameTypeDescription
typePerspectiveListenerTypesCan be 'link-added' or 'link-removed'
cbLinkCallbackCallback function that is called when a link is added to the perspective

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:180 (opens in a new tab)


addSdna

addSdna(sdnaCode): Promise<void>

Adds the given Social DNA code to the perspective's SDNA code

Parameters

NameType
sdnaCodestring

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:347 (opens in a new tab)


addSyncStateChangeListener

addSyncStateChangeListener(cb): Promise<void>

Adds a sync state listener

Parameters

NameTypeDescription
cbSyncStateChangeCallbackCallback function that is called when the sync state of the perspective changes

Returns

Promise<void>

A function that can be called to remove the listener

Defined in

perspectives/PerspectiveProxy.ts:194 (opens in a new tab)


availableFlows

availableFlows(exprAddr): Promise<string[]>

Returns all Social DNA flows that can be started from the given expression

Parameters

NameType
exprAddrstring

Returns

Promise<string[]>

Defined in

perspectives/PerspectiveProxy.ts:284 (opens in a new tab)


createExpression

createExpression(content, languageAddress): Promise<string>

Parameters

NameType
contentany
languageAddressstring

Returns

Promise<string>

Defined in

perspectives/PerspectiveProxy.ts:172 (opens in a new tab)


createSubject

createSubject<T>(subjectClass, exprAddr): Promise<T>

Creates a new subject instance by running its (SDNA defined) constructor, which means adding links around the given expression address so that it conforms to the given subject class.

Type parameters

Name
T

Parameters

NameTypeDescription
subjectClassTEither a string with the name of the subject class, or an object with the properties of the subject class. In the latter case, the first subject class that matches the given properties will be used.
exprAddrstringThe address of the expression to be turned into a subject instance

Returns

Promise<T>

Defined in

perspectives/PerspectiveProxy.ts:387 (opens in a new tab)


ensureSDNASubjectClass

ensureSDNASubjectClass(jsClass): Promise<void>

Takes a JS class (its constructor) and assumes that it was decorated by the

Parameters

NameType
jsClassany

Returns

Promise<void>

Subject Class

etc. decorators. It then tests if there is a subject class already present in the perspective's SDNA that matches the given class. If there is no such class, it gets the JS class's SDNA by calling its static generateSDNA() function and adds it to the perspective's SDNA.

Defined in

perspectives/PerspectiveProxy.ts:583 (opens in a new tab)


executeAction

executeAction(actions, expression, parameters): Promise<void>

Parameters

NameType
actionsany
expressionany
parametersParameter[]

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:48 (opens in a new tab)


expressionsInFlowState

expressionsInFlowState(flowName, flowState): Promise<string[]>

Returns all expressions in the given state of given Social DNA flow

Parameters

NameType
flowNamestring
flowStatenumber

Returns

Promise<string[]>

Defined in

perspectives/PerspectiveProxy.ts:298 (opens in a new tab)


flowActions

flowActions(flowName, exprAddr): Promise<string[]>

Returns available action names, with regard to Social DNA flow and expression's flow state

Parameters

NameType
flowNamestring
exprAddrstring

Returns

Promise<string[]>

Defined in

perspectives/PerspectiveProxy.ts:310 (opens in a new tab)


flowState

flowState(flowName, exprAddr): Promise<number>

Returns the given expression's flow state with regard to given Social DNA flow

Parameters

NameType
flowNamestring
exprAddrstring

Returns

Promise<number>

Defined in

perspectives/PerspectiveProxy.ts:304 (opens in a new tab)


get

get(query): Promise<LinkExpression[]>

Returns all the links of this perspective that matches the LinkQuery

Parameters

NameType
queryLinkQuery

Returns

Promise<LinkExpression[]>

Defined in

perspectives/PerspectiveProxy.ts:126 (opens in a new tab)


getAllSubjectInstances

getAllSubjectInstances<T>(subjectClass): Promise<T[]>

Returns all subject instances of the given subject class as proxy objects.

Type parameters

Name
T

Parameters

NameTypeDescription
subjectClassTEither a string with the name of the subject class, or an object with the properties of the subject class. In the latter case, all subject classes that match the given properties will be used.

Returns

Promise<T[]>

Defined in

perspectives/PerspectiveProxy.ts:454 (opens in a new tab)


getAllSubjectProxies

getAllSubjectProxies<T>(subjectClass): Promise<T[]>

Type parameters

Name
T

Parameters

NameType
subjectClassT

Returns

Promise<T[]>

Defined in

perspectives/PerspectiveProxy.ts:471 (opens in a new tab)


getExpression

getExpression(expressionURI): Promise<ExpressionRendered>

Parameters

NameType
expressionURIstring

Returns

Promise<ExpressionRendered>

Defined in

perspectives/PerspectiveProxy.ts:168 (opens in a new tab)


getNeighbourhoodProxy

getNeighbourhoodProxy(): NeighbourhoodProxy

Returns

NeighbourhoodProxy

Defined in

perspectives/PerspectiveProxy.ts:591 (opens in a new tab)


getSdna

getSdna(): Promise<string[]>

Returns the perspective's Social DNA code This will return all SDNA code elements in an array.

Returns

Promise<string[]>

Defined in

perspectives/PerspectiveProxy.ts:337 (opens in a new tab)


getSingleTarget

getSingleTarget(query): Promise<string | void>

Convenience function to get the target of the first link that matches the given query This makes sense when the query is expected to return only one link and the target of that link is what you are looking for.

Works best together with

Parameters

NameType
queryLinkQuery

Returns

Promise<string | void>

Member

setSingelTarget()

Defined in

perspectives/PerspectiveProxy.ts:246 (opens in a new tab)


getSubjectProxy

getSubjectProxy<T>(base, subjectClass): Promise<T>

For an existing subject instance (existing in the perspective's links) this function returns a proxy object that can be used to access the subject's properties and methods.

Type parameters

Name
T

Parameters

NameTypeDescription
basestringURI of the subject's root expression
subjectClassTEither a string with the name of the subject class, or an object with the properties of the subject class. In the latter case, the first subject class that matches the given properties will be used.

Returns

Promise<T>

Defined in

perspectives/PerspectiveProxy.ts:439 (opens in a new tab)


infer

infer(query): Promise<any>

Runs a Prolog query on the perspective's Prolog engine

Parameters

NameType
querystring

Returns

Promise<any>

Defined in

perspectives/PerspectiveProxy.ts:131 (opens in a new tab)


isSubjectInstance

isSubjectInstance<T>(expression, subjectClass): Promise<boolean>

Checks if the given expression is a subject instance of the given subject class

Type parameters

Name
T

Parameters

NameTypeDescription
expressionstringThe expression to be checked
subjectClassTEither a string with the name of the subject class, or an object with the properties of the subject class. In the latter case, the first subject class that matches the given properties will be used.

Returns

Promise<boolean>

Defined in

perspectives/PerspectiveProxy.ts:424 (opens in a new tab)


linkMutations

linkMutations(mutations, status?): Promise<LinkExpressionMutations>

Adds and removes multiple links from this perspective *

Parameters

NameTypeDefault value
mutationsLinkMutationsundefined
statusLinkStatus'shared'

Returns

Promise<LinkExpressionMutations>

Defined in

perspectives/PerspectiveProxy.ts:151 (opens in a new tab)


loadSnapshot

loadSnapshot(snapshot): Promise<void>

Take and load all the links from the given snapshot

Parameters

NameType
snapshotPerspective

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:227 (opens in a new tab)


remove

remove(link): Promise<{ perspectiveRemoveLink: boolean }>

Parameters

NameType
linkLinkExpressionInput

Returns

Promise<{ perspectiveRemoveLink: boolean }>

Defined in

perspectives/PerspectiveProxy.ts:164 (opens in a new tab)


removeLinks

removeLinks(links): Promise<LinkExpression[]>

Removes multiple links from this perspective *

Parameters

NameType
linksLinkExpressionInput[]

Returns

Promise<LinkExpression[]>

Defined in

perspectives/PerspectiveProxy.ts:146 (opens in a new tab)


removeListener

removeListener(type, cb): Promise<void>

Removes a previously added link listener

Parameters

NameTypeDescription
typePerspectiveListenerTypesCan be 'link-added' or 'link-removed'
cbLinkCallbackCallback function that is called when a link is added to the perspective

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:202 (opens in a new tab)


removeSubject

removeSubject<T>(subjectClass, exprAddr): Promise<void>

Removes a subject instance by running its (SDNA defined) destructor, which means removing links around the given expression address

Type parameters

Name
T

Parameters

NameTypeDescription
subjectClassTEither a string with the name of the subject class, or an object with the properties of the subject class. In the latter case, the first subject class that matches the given properties will be used.
exprAddrstringThe address of the expression to be turned into a subject instance

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:407 (opens in a new tab)


runFlowAction

runFlowAction(flowName, exprAddr, actionName): Promise<void>

Runs given Social DNA flow action

Parameters

NameType
flowNamestring
exprAddrstring
actionNamestring

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:316 (opens in a new tab)


sdnaFlows

sdnaFlows(): Promise<string[]>

Returns all the Social DNA flows defined in this perspective

Returns

Promise<string[]>

Defined in

perspectives/PerspectiveProxy.ts:278 (opens in a new tab)


setSdna

setSdna(sdnaCode): Promise<void>

Set the perspective's Social DNA code to the given string. This will replace all previous SDNA code elements with the new one.

Parameters

NameType
sdnaCodestring

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:326 (opens in a new tab)


setSingleTarget

setSingleTarget(link, status?): Promise<void>

Convenience function to ensure there is only one link with given source and predicate This function will remove all links with the same source and predicate as the given link, and then add the given link. This ensures there is only one target for the given source and predicate.

Works best together with

Parameters

NameTypeDefault value
linkLinkundefined
statusLinkStatus'shared'

Returns

Promise<void>

Member

getSingleTarget()

Defined in

perspectives/PerspectiveProxy.ts:262 (opens in a new tab)


snapshot

snapshot(): Promise<Perspective>

Create and return a snapshot of this perspective A snapshot is a rendered Perspectie object that contains all the links of the perspective.

Returns

Promise<Perspective>

Defined in

perspectives/PerspectiveProxy.ts:222 (opens in a new tab)


startFlow

startFlow(flowName, exprAddr): Promise<void>

Starts the Social DNA flow

Parameters

NameTypeDescription
flowNamestringon the expression
exprAddrstring

Returns

Promise<void>

Defined in

perspectives/PerspectiveProxy.ts:290 (opens in a new tab)


stringOrTemplateObjectToSubjectClass

stringOrTemplateObjectToSubjectClass<T>(subjectClass): Promise<string>

Type parameters

Name
T

Parameters

NameType
subjectClassT

Returns

Promise<string>

Defined in

perspectives/PerspectiveProxy.ts:364 (opens in a new tab)


subjectClasses

subjectClasses(): Promise<string[]>

Returns all the Subject classes defined in this perspectives SDNA

Returns

Promise<string[]>

Defined in

perspectives/PerspectiveProxy.ts:356 (opens in a new tab)


subjectClassesByTemplate

subjectClassesByTemplate(obj): Promise<string[]>

Returns all subject classes that match the given template object. This function looks at the properties of the template object and its setters and collections to create a Prolog query that finds all subject classes that would be converted to a proxy object with exactly the same properties and collections.

Since there could be multiple subject classes that match the given criteria, this function returns a list of class names.

Parameters

NameTypeDescription
objobjectThe template object

Returns

Promise<string[]>

Defined in

perspectives/PerspectiveProxy.ts:498 (opens in a new tab)


update

update(oldLink, newLink): Promise<LinkExpression>

Parameters

NameType
oldLinkLinkExpressionInput
newLinkLink

Returns

Promise<LinkExpression>

Defined in

perspectives/PerspectiveProxy.ts:160 (opens in a new tab)