API Reference
Modules

@coasys/ad4m / Exports

@coasys/ad4m

Table of contents

Enumerations

Classes

Interfaces

Type Aliases

Variables

Decorators Functions

Other Functions

Type Aliases

Ad4mSignalCB

Ƭ Ad4mSignalCB: (signal: any) => void

Type declaration

▸ (signal): void

Parameters
NameType
signalany
Returns

void

Defined in

language/LanguageContext.ts:37 (opens in a new tab)


Address

Ƭ Address: string

Defined in

Address.ts:1 (opens in a new tab)


AgentAppsUpdatedCallback

Ƭ AgentAppsUpdatedCallback: () => null

Type declaration

▸ (): null

Returns

null

Defined in

agent/AgentClient.ts:81 (opens in a new tab)


AgentStatusChangedCallback

Ƭ AgentStatusChangedCallback: (agent: Agent) => null

Type declaration

▸ (agent): null

Parameters
NameType
agentAgent
Returns

null

Defined in

agent/AgentClient.ts:80 (opens in a new tab)


AgentUpdatedCallback

Ƭ AgentUpdatedCallback: (agent: Agent) => null

Type declaration

▸ (agent): null

Parameters
NameType
agentAgent
Returns

null

Defined in

agent/AgentClient.ts:79 (opens in a new tab)


DID

Ƭ DID: string

Defined in

DID.ts:1 (opens in a new tab)


LinkStatus

Ƭ LinkStatus: "shared" | "local"

Defined in

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


MessageCallback

Ƭ MessageCallback: (message: PerspectiveExpression) => void

Type declaration

▸ (message): void

Parameters
NameType
messagePerspectiveExpression
Returns

void

Defined in

language/Language.ts:192 (opens in a new tab)


PerspectiveDiffObserver

Ƭ PerspectiveDiffObserver: (diff: PerspectiveDiff) => void

Type declaration

▸ (diff): void

Parameters
NameType
diffPerspectiveDiff
Returns

void

Defined in

language/Language.ts:151 (opens in a new tab)


QueryPartialEntity

Ƭ QueryPartialEntity<T>: { [P in keyof T]?: T[P] | Function }

Type parameters

Name
T

Defined in

subject/SubjectEntity.ts:7 (opens in a new tab)


StatusCallback

Ƭ StatusCallback: (caller: DID) => Perspective

Type declaration

▸ (caller): Perspective

Parameters
NameType
callerDID
Returns

Perspective

Defined in

language/Language.ts:193 (opens in a new tab)


SubjectArray

Ƭ SubjectArray<T>: T[] | { action: "setter" | "adder" | "remover" ; value: T[] }

Type parameters

Name
T

Defined in

subject/SubjectEntity.ts:355 (opens in a new tab)


SubjectEntityQueryParam

Ƭ SubjectEntityQueryParam: Object

Type declaration

NameType
page?number
size?number
source?string

Defined in

subject/SubjectEntity.ts:360 (opens in a new tab)


SyncStateChangeObserver

Ƭ SyncStateChangeObserver: (state: PerspectiveState) => void

Type declaration

▸ (state): void

Parameters
NameType
statePerspectiveState
Returns

void

Defined in

language/Language.ts:152 (opens in a new tab)


TelepresenceSignalCallback

Ƭ TelepresenceSignalCallback: (payload: PerspectiveExpression) => void

Type declaration

▸ (payload): void

Parameters
NameType
payloadPerspectiveExpression
Returns

void

Defined in

language/Language.ts:258 (opens in a new tab)

Variables

SMART_LITERAL_CONTENT_PREDICATE

Const SMART_LITERAL_CONTENT_PREDICATE: "smart_literal://content"

Defined in

SmartLiteral.ts:6 (opens in a new tab)


typeDefsString

Const typeDefsString: ""

Defined in

typeDefs.ts:6 (opens in a new tab)

Decorators Functions

InstanceQuery

InstanceQuery(options?): <T>(target: T, key: keyof T, descriptor: PropertyDescriptor) => void

Decorator for querying instances of a subject class.

Parameters

NameTypeDescription
options?InstanceQueryParamsQuery options.

Returns

fn

▸ <T>(target, key, descriptor): void

Type parameters
Name
T
Parameters
NameType
targetT
keykeyof T
descriptorPropertyDescriptor
Returns

void

Description

NOTE: Only works on methods that return a promise and will throw an error if not used on a method that returns a promise. This will allow you to query for instances of a subject class with custom clauses within the instance clauses.

Example

// Usage with where clause
InstanceQuery({ where: { name: "John" }}) // this will return all the properties of the subject class with the name "John"

Example

// Usage with condition clause
InstanceQuery({ condition: "triple(Instance, 'age', Age), Age > 18" }) // this will return all the properties of the subject class with the age greater than 18

Defined in

subject/SDNADecorators.ts:56 (opens in a new tab)


SDNAClass

SDNAClass(opts): (target: any) => void

Decorator for defining an SDNA class.

Parameters

NameTypeDescription
optsSDNAClassOptionsSDNA class options.

Returns

fn

▸ (target): void

Parameters
NameType
targetany
Returns

void

Description

This will create a new SDNA class with the given name and add custom methods to generate the SDNA for the class, for this to work the class need to have the properties defined using the decorators like SubjectProperty.

Note: This decorator is required for the class to be picked up during the initialization phase.

Example

// Usage
 SDNAClass({ name: "Person" }) // this will create a new SDNA class with the name "Person"

Defined in

subject/SDNADecorators.ts:336 (opens in a new tab)


SubjectCollection

SubjectCollection(opts): <T>(target: T, key: keyof T) => void

Decorator for defining collections of a subject class.

Parameters

NameTypeDescription
optsCollectionOptionsCollection options.

Returns

fn

▸ <T>(target, key): void

Type parameters
Name
T
Parameters
NameType
targetT
keykeyof T
Returns

void

Description

This will allow you to define collections with different conditions and how they would be defined in proflog engine.

NOTE: The property needs to be an array for it to picked up during the initialization phase.

  • All collections must have a through option which is the predicate of the collection.
  • If the collection has a where option, it can be used to define a custom condition for the collection.
  • If the collection has a local option, the collection will be stored locally in the perspective and not in the network. This is useful for collections that are not meant to be shared with the network.

Example

// Usage
SubjectCollection({ through: "ad4m://friends" }) // this will define a collection with the name "ad4m://friends"

Defined in

subject/SDNADecorators.ts:289 (opens in a new tab)


SubjectFlag

SubjectFlag(opts?): <T>(target: T, key: keyof T) => void

Decorator for defining flags of a subject class

Parameters

NameTypeDescription
opts?FlagOptionsFlag options.

Returns

fn

▸ <T>(target, key): void

Type parameters
Name
T
Parameters
NameType
targetT
keykeyof T
Returns

void

Description

The idea behind flag decorator is to define a property that is required and has an initial value. This will allow you to define a strict instance query. This behaviour can also be achieved with the SubjectProperty decorator but the SubjectFlag decorator is a shorthand for that.

NOTE: Use of Flag is discouraged and should be used only when necessary.

  • All properties must have a through & initial option which is the predicate of the property.

Example

// Usage
SubjectFlag({ through: "ad4m://name", value: "John" }) // this will define a flag with the name "ad4m://name" and the initial value "John"

Defined in

subject/SDNADecorators.ts:216 (opens in a new tab)


SubjectProperty

SubjectProperty(opts?): <T>(target: T, key: keyof T) => void

Decorator for defining properties of a subject class.

Parameters

NameTypeDescription
opts?PropertyOptionsProperty options.

Returns

fn

▸ <T>(target, key): void

Type parameters
Name
T
Parameters
NameType
targetT
keykeyof T
Returns

void

Description

This will allow you to define properties with different conditions and how they would be defined in proflog engine.

  • All properties must have a through option which is the predicate of the property. -e If the property is required, it must have an initial option which is the initial value of the property.
  • If the property is writable, it will have a setter in prolog engine. A custom setter can be defined with the setter option.
  • If resolveLanguage is defined, you can use the default Literal Language or use your custom language address that can be used to store the property.
  • If a custom getter is defined, it will be used to get the value of the property in prolog engine. If not, the default getter will be used.
  • If local is defined, the property will be stored locally in the perspective and not in the network. This is useful for properties that are not meant to be shared with the network

Example

// Usage
SubjectProperty({ through: "ad4m://name", initial: "John", required: true }) // this will define a property with the name "ad4m://name" and the initial value "John"

Defined in

subject/SDNADecorators.ts:162 (opens in a new tab)


Other Functions

ExpressionGeneric

ExpressionGeneric<DataType>(DataTypeClass): any

Type parameters

Name
DataType

Parameters

NameType
DataTypeClassClassType<DataType>

Returns

any

Defined in

expression/Expression.ts:42 (opens in a new tab)


ExpressionGenericInput

ExpressionGenericInput<DataType>(DataTypeClass): any

Type parameters

Name
DataType

Parameters

NameType
DataTypeClassClassType<DataType>

Returns

any

Defined in

expression/Expression.ts:67 (opens in a new tab)


addLink

addLink(source, predicate, target): PerspectiveAction

Parameters

NameType
sourcestring
predicatestring
targetstring

Returns

PerspectiveAction

Defined in

subject/SDNADecorators.ts:12 (opens in a new tab)


capSentence

capSentence(cap): string

Parameters

NameType
capany

Returns

string

Defined in

utils.ts:15 (opens in a new tab)


exprRef2String

exprRef2String(ref): string

Parameters

NameType
refExpressionRef

Returns

string

Defined in

expression/ExpressionRef.ts:22 (opens in a new tab)


formatList

formatList(list): any

Parameters

NameType
listany

Returns

any

Defined in

utils.ts:1 (opens in a new tab)


hasLink

hasLink(predicate): string

Parameters

NameType
predicatestring

Returns

string

Defined in

subject/SDNADecorators.ts:21 (opens in a new tab)


isExpression

isExpression(e): boolean

Parameters

NameType
eany

Returns

boolean

Defined in

expression/Expression.ts:97 (opens in a new tab)


isLink

isLink(l): boolean

Parameters

NameType
lany

Returns

boolean

Defined in

links/Links.ts:91 (opens in a new tab)


linkEqual

linkEqual(l1, l2): boolean

Parameters

NameType
l1LinkExpression
l2LinkExpression

Returns

boolean

Defined in

links/Links.ts:83 (opens in a new tab)


makeRandomPrologAtom

makeRandomPrologAtom(length): string

Parameters

NameType
lengthnumber

Returns

string

Defined in

subject/SDNADecorators.ts:303 (opens in a new tab)


parseExprUrl

parseExprUrl(url): ExpressionRef

Parameters

NameType
urlstring

Returns

ExpressionRef

Defined in

expression/ExpressionRef.ts:29 (opens in a new tab)