API Reference
Modules

@coasys/ad4m / Exports

@coasys/ad4m

Table of contents

Enumerations

Classes

Interfaces

Type Aliases

Variables

Decorators Functions

Other Functions

Type Aliases

AddLinkExpressionRequest

Ƭ AddLinkExpressionRequest: Object

Type declaration

NameType
batchId?string
linkLinkExpression
status?string

Defined in

core/src/generated/api/AddLinkExpressionRequest.ts:4 (opens in a new tab)


AddLinkRequest

Ƭ AddLinkRequest: Object

Type declaration

NameType
batchId?string
linkLinkInput
status?string

Defined in

core/src/generated/api/AddLinkRequest.ts:4 (opens in a new tab)


AddLinksBulkRequest

Ƭ AddLinksBulkRequest: Object

Type declaration

NameType
batchId?string
linksLinkInput[]
status?string

Defined in

core/src/generated/api/AddLinksBulkRequest.ts:4 (opens in a new tab)


AddSdnaRequest

Ƭ AddSdnaRequest: Object

Type declaration

NameType
namestring
sdnaCode?string
sdnaTypestring
shaclJson?string

Defined in

core/src/generated/api/AddSdnaRequest.ts:3 (opens in a new tab)


Address

Ƭ Address: string

Defined in

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


AllInstancesResult

Ƭ AllInstancesResult: Object

Type declaration

NameType
AllInstancesAd4mModel[]
TotalCount?number

Defined in

core/src/model/types.ts:707 (opens in a new tab)


ApplyTemplateRequest

Ƭ ApplyTemplateRequest: Object

Type declaration

NameType
sourceLanguageHashstring
templateDatastring

Defined in

core/src/generated/api/ApplyTemplateRequest.ts:3 (opens in a new tab)


AuthorCondition

Ƭ AuthorCondition: string | string[] | { contains?: string ; not?: string | string[] }

Who wrote a link: a DID, any of several DIDs, or { not } / { contains } over the author DID.

Defined in

core/src/model/types.ts:24 (opens in a new tab)


AutoProcessorEvent

Ƭ AutoProcessorEvent: Object

A single step-signal from one auto-processor pass on one perspective.

Type declaration

NameTypeDescription
agentDidstring | nullDID of the agent this executor ran the pass as — lets a multi-user / multi-executor observer see which peer claimed/processed vs backed off.
basesstring[]Instance base URIs written by the pass (present on Processed).
batchKeystring | nullContent hash of the batch — the same [super::claim::batch_key] value the perspective-scoped [AutoProcessorNeighbourhoodState] carries. Present from BatchReady onward, and it is what makes the two streams joinable. Without it a consumer holding both has no way to say "this LlmRequestSent belongs to the row I opened on that Claimed" — the fine-grained stream carries item_ids and the neighbourhood stream carries only the hash of them, so correlating meant re-implementing this hash client-side and matching the Rust serialization exactly. A consumer that merges a peer's coarse phases with its own fine ones needs one shared key, and this is it.
detailstring | nullFree-form context for the step (a holder/elected DID, an error, …).
itemIdsstring[]The batch's source item ids (present from BatchReady onward).
llmInputstring | nullLive-debug raw LLM prompt for this pass. Present ONLY on [AutoProcessorStep::LlmRequestSent] events, and only when the processor was configured with AutoProcessorConfig.emit_debug_events = true. Never carried on Processed (which carries bases only). Absent (None) in the normal path — LLM prompts are 10s of KB and would otherwise inflate every event.
llmOutputstring | nullLive-debug raw LLM response for this pass. Present ONLY on [AutoProcessorStep::LlmResponseReceived] events, and only when the processor was configured with AutoProcessorConfig.emit_debug_events = true. Never carried on Processed. Same size / privacy rules as llm_input.
perspectiveUuidstringUUID of the perspective the processor runs on.
processorIdstringThe processor's id (AutoProcessorConfig::processor_id).
stepAutoProcessorStepWhich step this event marks.
toolArgsJsonstring | nullJSON-encoded arguments the LLM sent to the tool. Present ONLY on [AutoProcessorStep::ToolCall]; absent on ToolResult (where tool_result carries the return text instead). Same size / gating rules as llm_input / llm_output.
toolNamestring | nullName of the tool the harness LLM invoked (or that just returned). Present on [AutoProcessorStep::ToolCall] + [AutoProcessorStep::ToolResult] events; absent on every other step. Present only when the processor has emit_debug_events: true.
toolResultstring | nullThe tool's return text. Present ONLY on [AutoProcessorStep::ToolResult]; may be truncated by the emitter when the tool returns a large payload (e.g. a _query result). Same size / gating rules as llm_input / llm_output.

Defined in

core/src/generated/api/AutoProcessorEvent.ts:7 (opens in a new tab)


AutoProcessorNeighbourhoodStateEvent

Ƭ AutoProcessorNeighbourhoodStateEvent: Object

One observation of an auto-processor pass by THIS executor. Small on purpose: perspective + processor + claimant DID + batch key + phase. Consumers merge these across ticks + across peers (via link-added on has_claim) to render "who is currently processing what."

Type declaration

NameTypeDescription
batchKeystringContent hash of the batch (see [super::claim::batch_key]) — lets a consumer merge Claimed and Finished events for the same batch without duplicating rows.
claimantDidstringDID that claimed the batch — the executor's own DID for locally initiated passes.
perspectiveUuidstringUUID of the perspective the pass runs on.
phaseNeighbourhoodPhaseWhich lifecycle transition this event marks.
processorIdstringThe processor's id (AutoProcessorConfig::processor_id).

Defined in

core/src/generated/api/AutoProcessorNeighbourhoodState.ts:10 (opens in a new tab)


AutoProcessorStep

Ƭ AutoProcessorStep: "batchReady" | "claimed" | "backedOff" | "awaitingAuthor" | "notCandidate" | "gatheringTranscript" | "runningInterpretation" | "llmRequestSent" | "llmResponseReceived" | "toolCall" | "toolResult" | "processed" | "shapesMissing" | "emptyTranscript" | "failed"

One step in an auto-processor pass (serde camelCase of the Rust enum).

Lifecycle (winning peer, emitDebugEvents: true)

A pass on the winning executor emits, in order:

  1. batchReady — debounced batch reached threshold, pass starting
  2. claimed — this executor won the try_claim
  3. gatheringTranscript — pulling the batch's transcript turns
  4. runningInterpretation — about to invoke the LLM
  5. llmRequestSent — prompt built + dispatched; carries llmInput (only when emitDebugEvents: true)
  6. llmResponseReceived — LLM response arrived; carries llmOutput (only when emitDebugEvents: true) — the UI can render "waiting on LLM" between steps 5-6
  7. processed — pass complete; carries bases[] (new/updated instance URIs)

Lifecycle (losing peer, or short-circuit)

  • batchReady → backedOff — another peer claimed the batch first
  • batchReady → awaitingAuthor — no author of the batch is online
  • batchReady → notCandidate — this peer stood down for an earlier author
  • claimed → shapesMissing — a configured class shape hasn't synced
  • claimed → emptyTranscript — the batch drained empty
  • any → failed — the model errored or timed out; detail carries why. Distinct from the two above, which are the pass correctly finding nothing to do — reporting "nothing to extract" when the LLM endpoint was unreachable points someone at their transcript instead of at their model settings.

Lifecycle (one-shot runInterpretation)

A one-shot pass emits nothing unless the caller passes observe (see runInterpretation). With it:

runningInterpretation → [llmRequestSent → llmResponseReceived] → processed | failed

— plus claimed → finished/abandoned on the neighbourhood stream, so one-shot and watch passes render through the same consumer code. There is no batchReady, gatheringTranscript or claim: the caller supplied the transcript, and processorId/batchKey both carry the caller's own observationId.

Payload fields per step

All steps carry perspectiveUuid, processorId, agentDid, itemIds[] and batchKey (the join key to the neighbourhood-state stream). Additional payload:

  • backedOff, notCandidate → detail = holder / elected-author DID
  • shapesMissing → detail = comma-joined missing class URIs
  • failed → detail = the error
  • llmRequestSent → llmInput = raw prompt
  • llmResponseReceived → llmOutput = raw LLM response
  • processed → bases[] = new/updated instance URIs

Defined in

core/src/perspectives/AutoProcessor.ts:76 (opens in a new tab)


CommitBatchRequest

Ƭ CommitBatchRequest: Object

Type declaration

NameType
batchIdstring

Defined in

core/src/generated/api/CommitBatchRequest.ts:3 (opens in a new tab)


ConformanceFilterFn

Ƭ ConformanceFilterFn: (relationPredicate: string, targetClass: Ad4mModelLike) => { conformanceConditions: ConformanceCondition[] ; getter: string } | undefined

Type declaration

▸ (relationPredicate, targetClass): { conformanceConditions: ConformanceCondition[] ; getter: string } | undefined

Signature for the conformance-filter builder injected by the caller.

Parameters
NameType
relationPredicatestring
targetClassAd4mModelLike
Returns

{ conformanceConditions: ConformanceCondition[] ; getter: string } | undefined

Defined in

core/src/model/shacl-gen.ts:15 (opens in a new tab)


CreateExpressionRequest

Ƭ CreateExpressionRequest: Object

Type declaration

NameType
contentstring
languageAddressstring

Defined in

core/src/generated/api/CreateExpressionRequest.ts:3 (opens in a new tab)


CreatePerspectiveRequest

Ƭ CreatePerspectiveRequest: Object

Type declaration

NameType
namestring

Defined in

core/src/generated/api/CreatePerspectiveRequest.ts:3 (opens in a new tab)


CreateSubjectRequest

Ƭ CreateSubjectRequest: Object

Type declaration

NameType
batchId?string
expressionAddressstring
initialValues?string
subjectClassstring

Defined in

core/src/generated/api/CreateSubjectRequest.ts:3 (opens in a new tab)


DID

Ƭ DID: string

Defined in

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


EmbedRequest

Ƭ EmbedRequest: Object

Type declaration

NameType
modelIdstring
textstring

Defined in

core/src/generated/api/EmbedRequest.ts:3 (opens in a new tab)


EventName

Ƭ EventName: keyof EventMap

Defined in

core/src/generated/api/Events.ts:47 (opens in a new tab)


ExecuteCommandsRequest

Ƭ ExecuteCommandsRequest: Object

Type declaration

NameType
batchId?string
commandsstring
expressionstring
parameters?string

Defined in

core/src/generated/api/ExecuteCommandsRequest.ts:3 (opens in a new tab)


ExportRequest

Ƭ ExportRequest: Object

Type declaration

NameType
filePathstring
perspectiveUuid?string
typestring

Defined in

core/src/generated/api/ExportRequest.ts:3 (opens in a new tab)


ExpressionManyRequest

Ƭ ExpressionManyRequest: Object

Type declaration

NameType
urlsstring[]

Defined in

core/src/generated/api/ExpressionManyRequest.ts:3 (opens in a new tab)


ExpressionShape

Ƭ ExpressionShape<DataType, Proof>: Object

The fields every expression carries, with DataType as its data.

Type parameters

NameType
DataTypeDataType
ProofExpressionProof

Type declaration

NameType
authorstring
dataDataType
proofProof
timestampstring

Defined in

core/src/expression/Expression.ts:25 (opens in a new tab)


FriendSendMessageRequest

Ƭ FriendSendMessageRequest: Object

Type declaration

NameType
messageany

Defined in

core/src/generated/api/FriendSendMessageRequest.ts:3 (opens in a new tab)


FriendsListRequest

Ƭ FriendsListRequest: Object

Type declaration

NameType
didsstring[]

Defined in

core/src/generated/api/FriendsListRequest.ts:3 (opens in a new tab)


GenerateAgentRequest

Ƭ GenerateAgentRequest: Object

Type declaration

NameType
passphrasestring

Defined in

core/src/generated/api/GenerateAgentRequest.ts:3 (opens in a new tab)


GenerateJwtRequest

Ƭ GenerateJwtRequest: Object

Type declaration

NameType
randstring
requestIdstring

Defined in

core/src/generated/api/GenerateJwtRequest.ts:3 (opens in a new tab)


GetOptions

Ƭ GetOptions: Pick<Query, "include" | "properties">

Options accepted by the instance get() method.

A subset of Query — only hydration controls apply to a single known instance.

Defined in

core/src/model/types.ts:701 (opens in a new tab)


GetSubjectDataRequest

Ƭ GetSubjectDataRequest: Object

Type declaration

NameType
expressionAddressstring
subjectClassstring

Defined in

core/src/generated/api/GetSubjectDataRequest.ts:3 (opens in a new tab)


HasManyMethods

Ƭ HasManyMethods<Keys>: { [K in Keys as `add${Capitalize<K>}`]: Function } & { [K in Keys as `remove${Capitalize<K>}`]: Function } & { [K in Keys as `set${Capitalize<K>}`]: Function }

Utility type that describes the auto-generated helper methods for a HasMany relation. For a property named comments on a class Post, the following methods will be available on instances:

post.addComment(value) post.removeComment(value) post.setComment(values)

Type parameters

NameType
Keysextends string

Defined in

core/src/model/decorators.ts:1032 (opens in a new tab)


HostRate

Ƭ HostRate: Object

Price in HOT the host charges for one metered operation.

Type declaration

NameType
descriptionstring
priceInHOTnumber

Defined in

core/src/generated/api/HostRate.ts:6 (opens in a new tab)


ImportAgentRequest

Ƭ ImportAgentRequest: Object

Type declaration

NameType
didstring
didDocumentstring
keystorestring
passphrasestring

Defined in

core/src/generated/api/ImportAgentRequest.ts:3 (opens in a new tab)


ImportRequest

Ƭ ImportRequest: Object

Type declaration

NameType
filePathstring
typestring

Defined in

core/src/generated/api/ImportRequest.ts:3 (opens in a new tab)


IncludeExtras

Ƭ IncludeExtras<T, I>: I extends Record<string, any> ? Extract<keyof I, `$${string}`> extends never ? unknown : { [K in Extract<keyof I, `$${string}`>]: I[K] extends Object ? number : I[K] extends Object ? R extends RelationKeysOf<T> ? RelatedModel<T, R> | null : never : I[K] extends Object ? R extends RelationKeysOf<T> ? RelatedModel<T, R>[] : never : unknown } : unknown

Given a model T and an include literal I, compute the extra fields contributed by $-prefixed projection keys.

  • { count: true } → number
  • { from: R, limit: 1 } → RelatedModel<T,R> | null
  • { from: R } (no limit/1) → RelatedModel<T,R>[]

Returns unknown (intersection-neutral) when I has no $-keys, so that T & IncludeExtras<T, I> collapses back to T and downstream type predicates ((x): x is T => ...) keep working unchanged.

Type parameters

NameType
Textends Ad4mModel
II

Defined in

core/src/model/types.ts:655 (opens in a new tab)


IncludeOf

Ƭ IncludeOf<Q>: Q extends { include?: infer I } ? I : undefined

Helper that extracts the include literal from a TypedQuery for use with IncludeExtras.

Type parameters

Name
Q

Defined in

core/src/model/types.ts:694 (opens in a new tab)


JoinNeighbourhoodRequest

Ƭ JoinNeighbourhoodRequest: Object

Type declaration

NameType
urlstring

Defined in

core/src/generated/api/JoinNeighbourhoodRequest.ts:3 (opens in a new tab)


LinkLanguageTemplatesRequest

Ƭ LinkLanguageTemplatesRequest: Object

Type declaration

NameType
addressesstring[]

Defined in

core/src/generated/api/LinkLanguageTemplatesRequest.ts:3 (opens in a new tab)


LinkStatus

Ƭ LinkStatus: "shared" | "local" | "SHARED" | "LOCAL"

Link status argument. The executor accepts either case and returns links with the upper-case form (LinkExpression.status).

Defined in

core/src/perspectives/PerspectiveProxy.ts:530 (opens in a new tab)


LinksMap

Ƭ LinksMap: Record<string, LinkRow[]>

instance.__links: requested entry (spelled as requested) → its rows, oldest first.

Defined in

core/src/model/types.ts:454 (opens in a new tab)


LiteralStorageMode

Ƭ LiteralStorageMode: { kind: "deterministic" } | { kind: "envelope" } | { kind: "custom" ; language: string }

How a property's value is stored / resolved.

Defined in

core/src/model/query-sparql.ts:218 (opens in a new tab)


LockAgentRequest

Ƭ LockAgentRequest: Object

Type declaration

NameType
passphrasestring

Defined in

core/src/generated/api/LockAgentRequest.ts:3 (opens in a new tab)


ModelDataKeys

Ƭ ModelDataKeys<T>: { [K in keyof T]: K extends keyof Ad4mModel ? never : T[K] extends Function ? never : K }[keyof T]

Keys of T that are user-declared (not methods, not inherited from Ad4mModel).

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:482 (opens in a new tab)


ModelType

Ƭ ModelType: "LLM" | "EMBEDDING" | "TRANSCRIPTION"

Defined in

core/src/ai/AITypes.ts:26 (opens in a new tab)


NeighbourhoodPhase

Ƭ NeighbourhoodPhase: "claimed" | "finished" | "abandoned"

Coarse-grained phase of a neighbourhood-state event.

claimed — this executor just started a pass. finished — the pass completed successfully. abandoned — the pass short-circuited (missing shape / empty batch / error); the claim will TTL-expire.

Defined in

core/src/perspectives/AutoProcessor.ts:101 (opens in a new tab)


NodeExpression

Ƭ NodeExpression: { type: "focus" } | { type: "literal" ; value: string | number | boolean } | { predicate: string ; type: "path" } | { expr: NodeExpression ; type: "exists" } | { cond: NodeExpression ; else?: NodeExpression ; then: NodeExpression ; type: "if" } | { args: NodeExpression[] ; type: "concat" } | { args: NodeExpression[] ; type: "coalesce" } | { args: NodeExpression[] ; iri: string ; type: "function" }

Union type representing all supported transform expressions. Each variant maps to a SHACL-AF §6 expression construct.

Defined in

core/src/shacl/NodeExpression.ts:15 (opens in a new tab)


NumericWhereOps

Ƭ NumericWhereOps: Object

Type declaration

NameTypeDescription
author?AuthorConditionSee author.
between?[number, number]-
eq?number | number[]See eq.
gt?number-
gte?number-
lt?number-
lte?number-
not?number | number[]-

Defined in

core/src/model/types.ts:541 (opens in a new tab)


OpenLinkRequest

Ƭ OpenLinkRequest: Object

Type declaration

NameType
urlstring

Defined in

core/src/generated/api/OpenLinkRequest.ts:3 (opens in a new tab)


Order

Ƭ Order: Object

Index signature

▪ [propertyName: string]: "ASC" | "DESC"

Defined in

core/src/model/types.ts:82 (opens in a new tab)


PaginationResult

Ƭ PaginationResult<T>: Object

Type parameters

Name
T

Type declaration

NameType
pageNumbernumber
pageSizenumber
resultsT[]
totalCount?number

Defined in

core/src/model/types.ts:709 (opens in a new tab)


PermitCapabilityRequest

Ƭ PermitCapabilityRequest: Object

Type declaration

NameType
authstring

Defined in

core/src/generated/api/PermitCapabilityRequest.ts:3 (opens in a new tab)


PerspectiveState

Ƭ PerspectiveState: typeof PerspectiveState[keyof typeof PerspectiveState]

Defined in

core/src/perspectives/PerspectiveHandle.ts:7 (opens in a new tab)

core/src/perspectives/PerspectiveHandle.ts:15 (opens in a new tab)


ProducedByFlowFilter

Ƭ ProducedByFlowFilter: Object

The where.producedByFlow filter — see producedByFlow.

Type declaration

NameType
flowstring
state?string

Defined in

core/src/model/types.ts:81 (opens in a new tab)


PromptRequest

Ƭ PromptRequest: Object

Type declaration

NameType
promptstring
taskIdstring

Defined in

core/src/generated/api/PromptRequest.ts:3 (opens in a new tab)


PropertyCondition

Ƭ PropertyCondition: string | number | boolean | { equals: unknown } | { in: unknown[] } | { exists: true } | { matches: string }

Per-property condition for a ModelQuery. String / number / boolean shorthands compile to an equality match; the object forms are the full shape a ModelQuery engine consumer will evaluate against a class instance's decoded property value.

Only the shorthand + equals / in / exists / matches operators are declared in v1 (see design doc §4.1). More operators can land as additional variants without a schema break.

Defined in

core/src/shacl/SHACLFlow.ts:31 (opens in a new tab)


PropertyKeysOf

Ƭ PropertyKeysOf<T>: { [K in keyof T]: K extends ModelDataKeys<T> ? NonNullable<T[K]> extends Ad4mModel ? never : NonNullable<T[K]> extends Ad4mModel[] ? never : K : never }[keyof T]

Keys of T that can appear in a where clause — scalars and scalar arrays. Excludes typed Ad4mModel references (single or array); string[]/number[] remain included because they're often filterable even when also used as link targets.

Iterates over keyof T directly (not ModelDataKeys<T>) to preserve the key constraint — mapped types over computed type aliases sometimes widen to string | undefined in the key position, which then breaks indexing.

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:496 (opens in a new tab)


PublishLanguageRequest

Ƭ PublishLanguageRequest: Object

Type declaration

NameType
languageMetaLanguageMetaInput
languagePathstring

Defined in

core/src/generated/api/PublishLanguageRequest.ts:4 (opens in a new tab)


PublishNeighbourhoodRequest

Ƭ PublishNeighbourhoodRequest: Object

Type declaration

NameType
linkLanguagestring
metaPerspective
perspectiveUuidstring

Defined in

core/src/generated/api/PublishNeighbourhoodRequest.ts:4 (opens in a new tab)


Query

Ƭ Query: Object

Type declaration

NameTypeDescription
count?boolean-
deepQuery?booleanWhen true, SPARQL property getters (@Property with getter) ARE evaluated during collection hydration. Defaults to true — getters run post-pagination via batched VALUES queries so the cost is O(getters), not O(instances × getters). Set to false to explicitly skip getter evaluation for performance-sensitive queries where getter-backed properties are not needed.
include?IncludeMap-
includeAll?booleanWhen true, eager-loads every declared forward relation on the model. Equivalent to listing all relation field names in include: {} explicitly. Useful for tree-walking and manifest-style inspections. Individual relations can still be overridden via include (explicit entries take precedence).
includeUnverified?booleanAlso hydrate from links whose signature did not verify. By default the executor withholds every link whose stored signature verdict is not valid, so a forged or tampered link never becomes a property value, a relation target, author or updatedAt. That includes a typed relation's generated conformance getter. A getter you write yourself runs as written, so it reads unverified links unless it joins the link's ad4m://ontology/proofValid itself. Set this to true only to display an unverified claim, e.g. a UI that marks a value as unverified. Anything that acts on the data, such as a vote counter or a role check, must leave it off. Included relations inherit the setting unless their sub-query sets its own. The same applies to the rows under __links and to what selects an instance: where (including a per-link author), the class's flags, count/totalCount, the order behind limit/offset, parent scopes and $ projections, transitive ones included. With true, selection reads unverified links too.
limit?number-
linkStatus?LinkStatusRead instances as they exist in links of one status only. 'shared' hydrates from Shared links only: every property, relation, author and updatedAt comes from links that are gossiped to the neighbourhood, and none from this executor's Local links. That is the read to use when showing data to another user (#1024). 'local' is the converse. Unset or null (the default) reads both, and a property declared local: true still reads only its Local links. Relations include typed @HasMany / @HasOne relations, which are filled by the conformance getter the SDK generates: the executor adds the status check to that getter's relation link. A hand-written getter is run as written, so it reads links of any status unless it checks <ad4m://ontology/status> itself. Included relations and the instances a $ projection hydrates inherit the setting, unless an include's sub-query sets its own. The __links rows (see links) are restricted the same way. Combines with includeUnverified: a link must have the requested status and pass the signature check, both on the same link. So a Local link whose signature did not verify is withheld under linkStatus: 'local' too, and comes back only with linkStatus: 'local', includeUnverified: true (or with no linkStatus and includeUnverified: true). Scope: this restricts the links that hydrate an instance and the links that select it (where, the class's flags, count/totalCount, $ projections, parent scopes and the order behind limit/offset). So an instance is returned under 'local' only when it is flagged in a Local link, and under 'shared' only when it is flagged in a Shared one.
links?string[]Return the individual links behind each instance, with their own author, timestamp, signature and signature verdict, under instance.__links. For a collection this is per-item provenance: who added each member, when, and whether their signature holds. Each entry is a property or relation name the model declares, or an absolute predicate IRI — including one the model does not declare (an annotation such as a revocation tombstone). A name wins over the IRI reading. Every requested entry is present on every instance, as [] when it has no such link. An entry that is neither a declared name nor an IRI, or that names a reverse relation (@BelongsToOne / @BelongsToMany), makes the query fail rather than answer []. The rows are read by a second query after the instances are hydrated, so asking for them never changes createdAt, updatedAt or any property. See LinkRow.
offset?number-
order?Order-
parent?ScopeFilter to instances that are the target of a link from a given parent.
properties?string[]-
where?Where-

Defined in

core/src/model/types.ts:326 (opens in a new tab)


QueryRequest

Ƭ QueryRequest: Object

Unified query request (harmonised: engine + query in one).

Type declaration

NameType
enginestring
querystring

Defined in

core/src/generated/api/QueryRequest.ts:6 (opens in a new tab)


RawScope

Ƭ RawScope: Object

Raw form of Scope (parent node + linking predicate) — the only variant the WebSocket auto-processor config accepts. Scope's model form ({ model: typeof Ad4mModel, id, field? }) references a JS class constructor, which JSON.stringify silently drops, so the executor would receive { id } and the scope would be unresolvable. Client callers who hold a model class should resolve its predicate via ModelQueryBuilder.buildParentScope() first and pass the result here.

Type declaration

NameType
idstring
predicatestring

Defined in

core/src/perspectives/AutoProcessor.ts:15 (opens in a new tab)


RelatedModel

Ƭ RelatedModel<T, K>: NonNullable<T[K]> extends infer U[] ? U extends Ad4mModel ? U : Ad4mModel : NonNullable<T[K]> extends Ad4mModel ? NonNullable<T[K]> : Ad4mModel

The model type referenced by a relation field K on T. Falls back to Ad4mModel (loose) for the string[] relation pattern, since no target class is available at the type level.

Type parameters

NameType
Textends Ad4mModel
Kextends RelationKeysOf<T>

Defined in

core/src/model/types.ts:521 (opens in a new tab)


RelationKeysOf

Ƭ RelationKeysOf<T>: { [K in keyof T]: K extends ModelDataKeys<T> ? NonNullable<T[K]> extends Ad4mModel ? K : NonNullable<T[K]> extends Ad4mModel[] ? K : NonNullable<T[K]> extends string[] ? K : never : never }[keyof T]

Keys of T that can appear in include — typed Ad4mModel references AND string[] link-target arrays (the @HasMany + string[] pattern that AD4M uses for relations without a target class thunk). Handles both ?: Foo (optional → Foo | undefined) and Foo | null field shapes, and optional/nullable array variants (?: Foo[], Foo[] | null).

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:509 (opens in a new tab)


RelationSubQuery

Ƭ RelationSubQuery: Omit<Query, "parent" | "count">

Sub-query options for a specific relation inside an IncludeMap.

Equivalent to Query without top-level scoping (parent) or count, since the result set is already constrained to the linked relation.

Example

await post.get({ include: { comments: { order: { createdAt: 'DESC' }, limit: 5 } } });

Defined in

core/src/model/types.ts:467 (opens in a new tab)


RemoveLinkRequest

Ƭ RemoveLinkRequest: Object

Type declaration

NameType
batchId?string
linkLinkExpressionInput

Defined in

core/src/generated/api/RemoveLinkRequest.ts:4 (opens in a new tab)


RemoveLinksBulkRequest

Ƭ RemoveLinksBulkRequest: Object

Type declaration

NameType
batchId?string
linksLinkExpressionInput[]

Defined in

core/src/generated/api/RemoveLinksBulkRequest.ts:4 (opens in a new tab)


ResultsWithTotalCount

Ƭ ResultsWithTotalCount<T>: Object

Type parameters

Name
T

Type declaration

NameType
resultsT[]
totalCount?number

Defined in

core/src/model/types.ts:708 (opens in a new tab)


RpcMethod

Ƭ RpcMethod: keyof RpcMethods

Defined in

core/src/generated/api/RpcMethods.ts:333 (opens in a new tab)


RunInterpretationRequest

Ƭ RunInterpretationRequest: Object

Run generic LLM interpretation over a transcript into the perspective's own SHACL subject classes. Shapes are resolved server-side from the perspective's registered classes, so callers pass only the transcript.

Type declaration

NameTypeDescription
basePrefixstringURI namespace new instance identities are minted under, e.g. soa://ext/.
classes?string[]Local names of the subject classes to extract into (e.g. ["Task","Belief"]). None/empty selects all subject classes registered in the perspective.
emitDebugEvents?booleanEmit LlmRequestSent / LlmResponseReceived (carrying the raw prompt and response) for this pass. Ignored without observation_id — there would be nothing to correlate the payloads to. Same switch, same reasons, as AutoProcessorConfig.emit_debug_events.
existingScope?anyOptional parent-scope filter for the dedup lookup: when set, only existing instances of the target classes that live under this scope are candidates for upsert. None = whole-perspective dedup set (the pre-scope default). Same semantics as AutoProcessorConfig.existingScope.
mintScope?anyOptional parent-scope target for newly minted instances: when set, every base URI the pass CREATES is additionally linked as a child of mintScope.id via the scope's predicate. Upserts of pre-existing instances are NOT linked (would multi-parent unrelated graph state). Must be the Raw variant of Scope (id + predicate). Same semantics as AutoProcessorConfig.mintScope.
observationId?stringOpt into live observability for this one-shot pass, under an id the caller chooses. A watch pass is identified by its batch_key — a hash of the source items the watcher gathered. A one-shot pass has neither: the caller supplies the transcript directly, so there are no source item ids to hash and no claim to key off. Rather than invent a server-side id the caller would then have to correlate by guesswork (the pass is one blocking RPC, so there is no earlier response to carry it), the caller names the pass and gets its own id back on every event. Present: the pass emits RunningInterpretation → Processed on the auto-processor-event topic, plus Claimed → Finished/Abandoned on the neighbourhood topic, all carrying this value as both processor_id and batch_key. Absent: the pass is silent, exactly as before — no existing caller changes behaviour.
transcriptTranscriptTurn[]-
uuidstring-

Defined in

core/src/generated/api/RunInterpretationRequest.ts:9 (opens in a new tab)


Scope

Ƭ Scope: { field?: string ; id: string ; model: typeof Ad4mModel } | { id: string ; predicate: string } | TraverseScope

A named subgraph scope: a parent node + linking predicate.

Reusable across contexts that need to identify "the subtree under node X linked via predicate P": query-time filtering as a parent filter on a ModelQuery (the "all Messages belonging to Channel X" case) AND AutoProcessor's existingScope / mintScope fields — the former constrains dedup lookups; the latter turns each new mint into a child link under the given node.

Model form (preferred for parent-filter queries) — predicate auto-resolved from the parent model's relation metadata. Use field to disambiguate when the parent has multiple relations targeting the same child class. AutoProcessor mintScope requires the Raw form because only Raw carries an explicit linking predicate; Model scopes have no predicate to write.

Raw form — explicit predicate string, no metadata lookup.

Traverse form — bounded traversal from one or more anchors, for reading a tree rather than one node's children. Read-only: AutoProcessor's write scopes reject it, because it names no single parent to write under.

Defined in

core/src/model/types.ts:107 (opens in a new tab)


ScopedEventName

Ƭ ScopedEventName: "perspective-added" | "perspective-removed" | "perspective-updated" | "sync-state-change" | "link-added" | "link-removed" | "link-updated" | "signal" | "notification-triggered" | "query-subscription-update" | "auto-processor-event" | "auto-processor-neighbourhood-state"

Events about one perspective: they carry perspectiveUuid.

Defined in

core/src/generated/api/Events.ts:50 (opens in a new tab)


SetDefaultModelRequest

Ƭ SetDefaultModelRequest: Object

Type declaration

NameType
modelTypeModelType

Defined in

core/src/generated/api/SetDefaultModelRequest.ts:4 (opens in a new tab)


SetFreeHostingEnabledRequest

Ƭ SetFreeHostingEnabledRequest: Object

Type declaration

NameType
enabledboolean

Defined in

core/src/generated/api/SetFreeHostingEnabledRequest.ts:3 (opens in a new tab)


SetHostRatesRequest

Ƭ SetHostRatesRequest: Object

Type declaration

NameType
ratesHostRate[]

Defined in

core/src/generated/api/SetHostRatesRequest.ts:4 (opens in a new tab)


SetMultiUserRequest

Ƭ SetMultiUserRequest: Object

Type declaration

NameType
enabledboolean

Defined in

core/src/generated/api/SetMultiUserRequest.ts:3 (opens in a new tab)


SetStatusRequest

Ƭ SetStatusRequest: Object

Type declaration

NameType
statusany

Defined in

core/src/generated/api/SetStatusRequest.ts:3 (opens in a new tab)


SetUnytMembraneProofRequest

Ƭ SetUnytMembraneProofRequest: Object

Type declaration

NameTypeDescription
proofstringBase64-encoded membrane proof from the hosting joining service.

Defined in

core/src/generated/api/SetUnytMembraneProofRequest.ts:3 (opens in a new tab)


SignMessageRequest

Ƭ SignMessageRequest: Object

Type declaration

NameType
messagestring

Defined in

core/src/generated/api/SignMessageRequest.ts:3 (opens in a new tab)


StringWhereOps

Ƭ StringWhereOps: Object

Type declaration

NameTypeDescription
author?AuthorConditionSee author.
contains?string-
eq?string | string[]See eq.
not?string | string[]-

Defined in

core/src/model/types.ts:532 (opens in a new tab)


TelepresenceSignalCallback

Ƭ TelepresenceSignalCallback: (payload: PerspectiveExpression, recipientDid?: string) => void

Type declaration

▸ (payload, recipientDid?): void

Callback shape used by the client to receive telepresence signals from a Neighbourhood's link Language.

Parameters
NameType
payloadPerspectiveExpression
recipientDid?string
Returns

void

Defined in

core/src/language/Language.ts:78 (opens in a new tab)


TranscriptTurn

Ƭ TranscriptTurn: Object

One conversation turn fed to the extractor.

Type declaration

NameType
speakerstring
textstring

Defined in

core/src/generated/api/TranscriptTurn.ts:6 (opens in a new tab)


TraverseScope

Ƭ TraverseScope: TraverseByPredicate | TraverseByModel

Walk a predicate from several anchors at once, and optionally all the way down.

This exists because a tree read one level at a time costs a round trip per level and — under a subscription — one subscription per parent. Asking for every anchor in one query makes both proportional to depth instead.

The predicate is named the same two ways the other scopes name it: literally, or by the model and relation that own it. See TraverseByPredicate and TraverseByModel.

Defined in

core/src/model/types.ts:124 (opens in a new tab)


TrustedAgentsRequest

Ƭ TrustedAgentsRequest: Object

Type declaration

NameType
agentsstring[]

Defined in

core/src/generated/api/TrustedAgentsRequest.ts:3 (opens in a new tab)


TypedIncludeMap

Ƭ TypedIncludeMap<T>: HasNoTypedFields<T> extends true ? IncludeMap : StrictTypedIncludeMap<T>

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:638 (opens in a new tab)


TypedIncludeProjection

Ƭ TypedIncludeProjection<T>: { [K in RelationKeysOf<T>]: Object | Object | Object }[RelationKeysOf<T>]

Projection — from must be a real relation on T; where/order constrained to that target. Modelled as a discriminated union so the literal count: true and limit: 1 variants narrow inference into IncludeExtras (count → number, limit-1 → scalar).

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:627 (opens in a new tab)


TypedOrder

Ƭ TypedOrder<T>: HasNoTypedFields<T> extends true ? Order : StrictTypedOrder<T>

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:605 (opens in a new tab)


TypedQuery

Ƭ TypedQuery<T>: HasNoTypedFields<T> extends true ? Query : StrictTypedQuery<T>

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:690 (opens in a new tab)


TypedQueryWhere

Ƭ TypedQueryWhere<T>: TypedWhere<T> & { producedByFlow?: ProducedByFlowFilter }

Top-level typed where of a query on T: TypedWhere plus producedByFlow. Kept out of TypedWhere itself because that shape is reused under OR/AND/NOT and in include sub-queries, where the executor rejects producedByFlow (see producedByFlow).

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:594 (opens in a new tab)


TypedRelationSubQuery

Ƭ TypedRelationSubQuery<U>: Object

Sub-query for an eager-loaded relation — inherits the target model's constraints.

Type parameters

NameType
Uextends Ad4mModel

Type declaration

NameTypeDescription
include?TypedIncludeMap<U>-
includeUnverified?booleanSee includeUnverified. Inherited from the parent query when unset.
limit?number-
linkStatus?LinkStatusSee linkStatus. Inherited from the parent query when unset.
links?string[]-
offset?number-
order?TypedOrder<U>-
where?TypedWhere<U>-

Defined in

core/src/model/types.ts:611 (opens in a new tab)


TypedWhere

Ƭ TypedWhere<T>: HasNoTypedFields<T> extends true ? Where : StrictTypedWhere<T>

Public typed where for a model class. Falls back to the loose Where shape when T has no declared fields (e.g. fromSHACL-derived classes).

Type parameters

NameType
Textends Ad4mModel

Defined in

core/src/model/types.ts:587 (opens in a new tab)


TypedWhereCondition

Ƭ TypedWhereCondition<V>: V extends string ? string | string[] | StringWhereOps : V extends number ? number | number[] | NumericWhereOps : V extends boolean ? boolean | { author?: AuthorCondition ; eq?: boolean } : V extends infer U[] ? U extends string ? string | string[] | StringWhereOps : U extends number ? number | number[] | NumericWhereOps : WhereCondition : WhereCondition

Type parameters

Name
V

Defined in

core/src/model/types.ts:554 (opens in a new tab)


UnlockAgentRequest

Ƭ UnlockAgentRequest: Object

Type declaration

NameType
holochain?boolean
passphrasestring

Defined in

core/src/generated/api/UnlockAgentRequest.ts:3 (opens in a new tab)


UnytVersionInfo

Ƭ UnytVersionInfo: Object

The Unyt alliance DNA: installed and bundled versions, and why the last install failed. setUnytMembraneProof installs in the background, so this is where its outcome shows.

Type declaration

NameTypeDescription
bundledstringVersion of the DNA bundled with this executor.
installErrorstring | nullError of the last install that failed; null after a success or a new proof.
installedstring | nullVersion of the installed DNA; null until an install succeeds.

Defined in

core/src/generated/api/UnytVersionInfo.ts:8 (opens in a new tab)


UpdateLinkRequest

Ƭ UpdateLinkRequest: Object

Type declaration

NameType
batchId?string
newLinkLinkInput
oldLinkLinkExpressionInput

Defined in

core/src/generated/api/UpdateLinkRequest.ts:5 (opens in a new tab)


UpdatePerspectiveRequest

Ƭ UpdatePerspectiveRequest: Object

Type declaration

NameType
namestring

Defined in

core/src/generated/api/UpdatePerspectiveRequest.ts:3 (opens in a new tab)


ValueTuple

Ƭ ValueTuple: [name: string, value: any, resolve?: boolean]

Defined in

core/src/model/types.ts:715 (opens in a new tab)


VerifySignatureRequest

Ƭ VerifySignatureRequest: Object

Type declaration

NameType
datastring
didstring
signedDatastring

Defined in

core/src/generated/api/VerifySignatureRequest.ts:3 (opens in a new tab)


Where

Ƭ Where: Object

Index signature

▪ [propertyName: string]: WhereCondition | undefined

Type declaration

NameTypeDescription
AND?Where[]Logical AND: instance must satisfy all of the given sub-clauses.
NOT?WhereLogical NOT: instance must NOT satisfy the given sub-clause.
OR?Where[]Logical OR: instance must satisfy at least one of the given sub-clauses.
producedByFlow?ProducedByFlowFilterOnly instances that are valid outputs of a completed run of flow (optionally: of a run settled into terminal state state). Decided executor-side by cryptographic receipt verification, not by a property: an instance passes only when a verified receipt of the flow names it among the outputs its quorum committed to AND its live content still matches that commitment. Fail-closed — a forged, unverifiable or stale receipt excludes the instance — and applied BEFORE limit/ offset, so a page of N is N valid outputs. Only supported as a top-level key on the queried class; anywhere else the query errors.

Defined in

core/src/model/types.ts:58 (opens in a new tab)


WhereCondition

Ƭ WhereCondition: string | number | boolean | string[] | number[] | { [K in keyof WhereOps]?: WhereOps[K] } | Where[] | Where

Defined in

core/src/model/types.ts:48 (opens in a new tab)


WhereOps

Ƭ WhereOps: Object

Type declaration

NameTypeDescription
authorAuthorConditionPer-link author: the link that satisfies this property's condition was written by this author, e.g. { agent: { eq: did, author: admin } }. Alone, { agent: { author: admin } }: admin wrote some agent link. Only on properties and relations stored as links (not getters, timestamp or id). See "Filtering by Author" in the model-classes guide.
between[number, number]-
containsstring | number-
eqstring | number | boolean | string[] | number[]Equality as an operator: { eq: X } is the bare value X (an array means any of). It lets a value sit beside author, and cannot be combined with the other value operators.
gtnumber-
gtenumber-
ltnumber-
ltenumber-
notstring | number | boolean | string[] | number[]-

Defined in

core/src/model/types.ts:29 (opens in a new tab)


WriteSettingsRequest

Ƭ WriteSettingsRequest: Object

Type declaration

NameType
settingsstring

Defined in

core/src/generated/api/WriteSettingsRequest.ts:3 (opens in a new tab)

Variables

ACCEPTED_BY_GETTER

• Const ACCEPTED_BY_GETTER: "SELECT ?target WHERE { ?source <ad4m://acceptedBy> ?target . FILTER EXISTS { ?_vote <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<( ?source <ad4m://acceptedBy> ?target )>> ; <ad4m://ontology/author> ?_author ; <ad4m://ontology/proofValid> ?_valid . FILTER(STR(?_author) = STR(?target) && STR(?_valid) = \"true\") } }"

The engine's vote rule (signed_by: the link's author is the DID it names, and its signature verified) as a getter over the link's reifier. Must match the acceptedBy getter in hardwired_sdna/flow_transition_proposal.json byte for byte: whichever side registers the class first decides the stored shape.

Defined in

core/src/perspectives/FlowModels.ts:42 (opens in a new tab)


LONG_METHODS

• Const LONG_METHODS: ReadonlySet<RpcMethod>

Calls that can run for minutes: the client's default timeout is its long one.

Defined in

core/src/generated/api/RpcMethods.ts:406 (opens in a new tab)


LONG_TIMEOUT_MS

• Const LONG_TIMEOUT_MS: number

Default timeout for calls that can run for minutes: LLM work, Holochain, publishing.

Defined in

core/src/apiClient.ts:52 (opens in a new tab)


PROPOSER_GETTER

• Const PROPOSER_GETTER: "SELECT ?target WHERE { ?source <ad4m://flow/proposer> ?target . FILTER EXISTS { ?_claim <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<( ?source <ad4m://flow/proposer> ?target )>> ; <ad4m://ontology/author> ?_author ; <ad4m://ontology/proofValid> ?_valid . FILTER(STR(?_author) = STR(?target) && STR(?_valid) = \"true\") } }"

The engine's proposer rule (self_authored_proposer: a proposer link signed by the DID it names) as a getter. Must match the proposer getter in hardwired_sdna/flow_transition_proposal.json byte for byte, as ACCEPTED_BY_GETTER must.

Defined in

core/src/perspectives/FlowModels.ts:32 (opens in a new tab)


PerspectiveState

• Const PerspectiveState: Object

Type declaration

NameType
LinkLanguageFailedToInstall"LINK_LANGUAGE_FAILED_TO_INSTALL"
LinkLanguageInstalledButNotSynced"LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED"
NeighboudhoodCreationInitiated"NEIGHBOURHOOD_CREATION_INITIATED"
NeighbourhoodJoinInitiated"NEIGHBOURHOOD_JOIN_INITIATED"
Private"PRIVATE"
Synced"SYNCED"

Defined in

core/src/perspectives/PerspectiveHandle.ts:7 (opens in a new tab)

core/src/perspectives/PerspectiveHandle.ts:15 (opens in a new tab)


READ_METHODS

• Const READ_METHODS: ReadonlySet<RpcMethod>

Idempotent reads: the client resends one once after a reconnect.

Defined in

core/src/generated/api/RpcMethods.ts:336 (opens in a new tab)


SCOPED_EVENTS

• Const SCOPED_EVENTS: ReadonlySet<EventName>

ScopedEventName as a set.

Defined in

core/src/generated/api/Events.ts:53 (opens in a new tab)


SMART_LITERAL_CONTENT_PREDICATE

• Const SMART_LITERAL_CONTENT_PREDICATE: "smart_literal://content"

Defined in

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


fileToDataUri

• Const fileToDataUri: Readonly<{ cond: NodeExpression ; else: NodeExpression = elseExpr; then: NodeExpression = thenExpr; type: "if" = 'if' }>

Built-in transform: FileData → data: URI

Converts a file stored via FILE_STORAGE_LANGUAGE into a data: URL. If the object has a data_base64 field, returns: data:{file_type};base64,{data_base64} Otherwise passes through the input unchanged.

This is the Rust equivalent of the JS defaultFileDecode function.

Usage:

@Property({
  through: 'we://image',
  resolveLanguage: 'literal',
  transform: fileToDataUri,
})
avatar?: string;

Defined in

core/src/shacl/index.ts:52 (opens in a new tab)


typeDefsString

• Const typeDefsString: ""

Defined in

core/src/typeDefs.ts:4 (opens in a new tab)

Decorators Functions

BelongsToMany

▸ BelongsToMany(opts): PropertyDecorator

Decorator for defining the inverse side of a many-to-many relation.

Parameters

NameType
optsRelationOptions

Returns

PropertyDecorator

Description

Declares the non-owning (inverse) side of a many-to-many relationship. The property is a read-only relation since the owning side manages links.

Supports two calling conventions:

@BelongsToMany({ through: "post://tag", target: () => Post })
@BelongsToMany(() => Post, { through: "post://tag" })

Example

@Model({ name: "Tag" })
class Tag extends Ad4mModel {
  @BelongsToMany(() => Post, { through: "post://tag" })
  posts: string[] = [];
}

Defined in

core/src/model/decorators.ts:1397 (opens in a new tab)

▸ BelongsToMany(target, opts?): PropertyDecorator

Parameters

NameType
target() => Ad4mModelLike
opts?Omit<RelationOptions, "target">

Returns

PropertyDecorator

Defined in

core/src/model/decorators.ts:1398 (opens in a new tab)


BelongsToOne

▸ BelongsToOne(opts): PropertyDecorator

Decorator for defining the inverse side of a one-to-one relation.

Parameters

NameType
optsRelationOptions

Returns

PropertyDecorator

Description

Declares the non-owning (inverse) side of a one-to-one relationship. The property is read-only since the owning side manages the link.

Supports two calling conventions:

@BelongsToOne({ through: "post://author", target: () => Post })
@BelongsToOne(() => Post, { through: "post://author" })

Example

@Model({ name: "Author" })
class Author extends Ad4mModel {
  @BelongsToOne(() => Post, { through: "post://author" })
  post: string = "";
}

Defined in

core/src/model/decorators.ts:1334 (opens in a new tab)

▸ BelongsToOne(target, opts?): PropertyDecorator

Parameters

NameType
target() => Ad4mModelLike
opts?Omit<RelationOptions, "target">

Returns

PropertyDecorator

Defined in

core/src/model/decorators.ts:1335 (opens in a new tab)


Flag

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

Decorator for defining flags on model classes.

Parameters

NameTypeDescription
optsFlagOptionsFlag configuration

Returns

fn

▸ <T>(target, key): void

Type parameters
Name
T
Parameters
NameType
targetT
keykeyof T
Returns

void

Description

A specialized property decorator for defining immutable type flags or markers on model instances. Flags are always required properties with a fixed value that cannot be changed after creation.

Common uses for flags:

  • Type discrimination between different kinds of models
  • Marking models with specific capabilities or features
  • Versioning or compatibility markers

Note: Use of Flag is discouraged unless you specifically need type-based filtering or discrimination between different kinds of models. For most cases, regular properties with

Property

or

Optional

are more appropriate.

Example

class Message extends Ad4mModel {
  // Type flag to identify message models
  @Flag({
    through: "ad4m://type",
    value: "ad4m://message"
  })
  type: string = "";
 
  // Version flag for compatibility
  @Flag({
    through: "ad4m://version",
    value: "1.0.0"
  })
  version: string = "";
 
  // Feature flag
  @Flag({
    through: "message://feature",
    value: "message://encrypted"
  })
  feature: string = "";
}
 
// Later you can query for specific types:
const messages = await Message.query(perspective)
  .where({ type: "ad4m://message" })
  .run();

Defined in

core/src/model/decorators.ts:533 (opens in a new tab)


HasMany

▸ HasMany(opts): PropertyDecorator

Decorator for defining a one-to-many relation.

Parameters

NameType
optsRelationOptions

Returns

PropertyDecorator

Description

Declares that the decorated property is an array of related model instances. Under the hood it registers the relation in the relation registry and also creates the corresponding relation entry so that the SDNA / SHACL generators continue to emit the correct subject-class code.

Supports two calling conventions:

// Options-object style
@HasMany({ through: "post://comment", target: () => Comment })
 
// Target-first shorthand
@HasMany(() => Comment, { through: "post://comment" })

Example

@Model({ name: "Post" })
class Post extends Ad4mModel {
  @HasMany(() => Comment, { through: "post://comment" })
  comments: string[] = [];
}

Defined in

core/src/model/decorators.ts:1165 (opens in a new tab)

▸ HasMany(target, opts?): PropertyDecorator

Parameters

NameType
target() => Ad4mModelLike
opts?Omit<RelationOptions, "target">

Returns

PropertyDecorator

Defined in

core/src/model/decorators.ts:1166 (opens in a new tab)


HasOne

▸ HasOne(opts): PropertyDecorator

Decorator for defining a one-to-one relation (owning side).

Parameters

NameType
optsRelationOptions

Returns

PropertyDecorator

Description

Declares that the decorated property holds a single related model instance. The owning side manages the link.

Supports two calling conventions:

@HasOne({ through: "post://author", target: () => Author })
@HasOne(() => Author, { through: "post://author" })

Example

@Model({ name: "Post" })
class Post extends Ad4mModel {
  @HasOne(() => Author, { through: "post://author" })
  author: string = "";
}

Defined in

core/src/model/decorators.ts:1235 (opens in a new tab)

▸ HasOne(target, opts?): PropertyDecorator

Parameters

NameType
target() => Ad4mModelLike
opts?Omit<RelationOptions, "target">

Returns

PropertyDecorator

Defined in

core/src/model/decorators.ts:1236 (opens in a new tab)


Model

▸ Model(opts): (target: any) => void

Decorator for defining model classes in AD4M.

Parameters

NameTypeDescription
optsModelConfigModel configuration

Returns

fn

▸ (target): void

Parameters
NameType
targetany
Returns

void

Description

The root decorator that must be applied to any class that represents a model in AD4M. It registers the class as a Social DNA (SDNA) subject class and provides the infrastructure for storing and retrieving instances.

This decorator:

  • Registers the class with a unique name in the AD4M system
  • Generates the necessary SDNA code for the model's properties and relations
  • Enables the use of other model decorators (@Property, @HasMany, etc.)
  • Provides static query methods through the Ad4mModel base class

Schema generation calls the class constructor once, without a perspective, to read field defaults, so keep constructors free of side effects.

Example

@Model({ name: "Recipe" })
class Recipe extends Ad4mModel {
  @Property({
    through: "recipe://name"
  })
  name: string = "";
 
  @HasMany({ through: "recipe://ingredient" })
  ingredients: string[] = [];
 
  // Static query methods from Ad4mModel:
  static async findByName(perspective: PerspectiveProxy, name: string) {
    return Recipe.query(perspective)
      .where({ name })
      .run();
  }
}
 
// Using the model:
const recipe = new Recipe(perspective);
recipe.name = "Chocolate Cake";
await recipe.save();
 
// Querying instances:
const recipes = await Recipe.query(perspective)
  .where({ name: "Chocolate Cake" })
  .run();
 
// Using with PerspectiveProxy:
await perspective.ensureSDNASubjectClass(Recipe);

Defined in

core/src/model/decorators.ts:641 (opens in a new tab)


Optional

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

Convenience decorator for defining optional (not required) properties.

Parameters

NameTypeDescription
optsPropertyOptionsProperty configuration (same options as @Property)

Returns

fn

▸ <T>(target, key): void

Type parameters
Name
T
Parameters
NameType
targetT
keykeyof T
Returns

void

Description

Equivalent to @Property but defaults required to false and does not apply any initial defaults. Use this when a property may or may not have a value, and you want full control over its configuration.

Example

class Recipe extends Ad4mModel {
  @Optional({ through: "recipe://description" })
  description?: string;
}

Defined in

core/src/model/decorators.ts:460 (opens in a new tab)


Property

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

The primary property decorator for AD4M model classes.

Parameters

NameTypeDescription
optsPropertyOptionsProperty configuration

Returns

fn

▸ <T>(target, key): void

Type parameters
Name
T
Parameters
NameType
targetT
keykeyof T
Returns

void

Description

The core property decorator with smart defaults. All other property decorators (@Optional, @ReadOnly) are thin wrappers that adjust these defaults.

Smart defaults (all overridable):

  • required → false
  • readOnly → false
  • resolveLanguage → unset → deterministic typed literal storage (the perf default). Set resolveLanguage: "literal" for a signed-envelope value, or a custom language address to resolve through that language.
  • initial → undefined (no link created until a value is explicitly set)

Properties are optional by default. When a model instance is created without providing a value for an optional property, no link is added to the graph. Set required: true explicitly when a property must always be present (this also adds a "literal:string:uninitialized" sentinel as the initial value so that the SDNA constructor creates a placeholder link).

Example

class User extends Ad4mModel {
  // Optional property (default) — no link created until a value is set
  @Property({
    through: "user://name"
  })
  name: string = "";
 
  // Explicitly required property with sentinel initial value
  @Property({
    through: "user://status",
    required: true
  })
  status: string = "";
 
  // Required property with custom initial value
  @Property({
    through: "user://role",
    required: true,
    initial: "user://member"
  })
  role: string = "";
 
  // Optional property with signed-envelope literal storage
  // (per-value provenance)
  @Property({
    through: "user://bio",
    resolveLanguage: "literal"
  })
  bio: string = "";
}

Defined in

core/src/model/decorators.ts:737 (opens in a new tab)


ReadOnly

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

Decorator for defining read-only properties on model classes.

Parameters

NameTypeDescription
optsPropertyOptionsProperty configuration

Returns

fn

▸ <T>(target, key): void

Type parameters
Name
T
Parameters
NameType
targetT
keykeyof T
Returns

void

Description

A convenience decorator that defines a read-only property. Equivalent to @Property with readOnly: true.

Read-only properties are ideal for:

  • Computed or derived values
  • Properties that should never change after creation
  • Properties that are set by the system
  • Properties that represent immutable data

Example

class Post extends Ad4mModel {
  // Read-only property with custom getter for computed value
  @ReadOnly({
    through: "post://likes",
    getter: `findall(User, triple(Base, "post://liked_by", User), Users), length(Users, Value)`
  })
  likeCount: number = 0;
 
  // Read-only property for creation timestamp
  @ReadOnly({
    through: "post://created_at",
    initial: new Date().toISOString()
  })
  createdAt: string = "";
 
  // Read-only property that resolves to a Literal
  @ReadOnly({
    through: "post://author",
    resolveLanguage: "literal"
  })
  author: string = "";
 
  // Read-only property for system-managed data
  @ReadOnly({
    through: "post://version",
    initial: "1.0.0"
  })
  version: string = "";
}

Defined in

core/src/model/decorators.ts:807 (opens in a new tab)


Other Functions

ExpressionGeneric

▸ ExpressionGeneric<DataType>(DataTypeClass): (author?: string, timestamp?: string, data?: DataType, proof?: ExpressionProof) => ExpressionShape<DataType>

Type parameters

Name
DataType

Parameters

NameType
DataTypeClassClassType<DataType>

Returns

fn

• (author?, timestamp?, data?, proof?)

Parameters
NameType
author?string
timestamp?string
data?DataType
proof?ExpressionProof

Defined in

core/src/expression/Expression.ts:32 (opens in a new tab)


ExpressionGenericInput

▸ ExpressionGenericInput<DataType>(DataTypeClass): () => ExpressionShape<DataType, ExpressionProofInput>

Type parameters

Name
DataType

Parameters

NameType
DataTypeClassClassType<DataType>

Returns

fn

• ()

Defined in

core/src/expression/Expression.ts:49 (opens in a new tab)


buildConformanceFilter

▸ buildConformanceFilter(relationPredicate, targetClass): { conformanceConditions: ConformanceCondition[] ; getter: string } | undefined

Build a conformance filter for a relation whose target model is known.

Inspects the target class's property metadata to derive:

  • conformanceConditions: Structured, DB-agnostic conditions (flag & required checks)
  • getter: Pre-computed graph traversal expression that traverses outgoing links and filters target nodes to only those conforming to the target shape.

Parameters

NameTypeDescription
relationPredicatestringThe relation's predicate URI (e.g. "flux://entry_type")
targetClassAd4mModelLikeThe target model class (resolved from the target() thunk)

Returns

{ conformanceConditions: ConformanceCondition[] ; getter: string } | undefined

{ getter, conformanceConditions } or undefined if no conditions could be derived

Defined in

core/src/model/decorators.ts:235 (opens in a new tab)


buildModelFromJSONSchema

▸ buildModelFromJSONSchema(BaseClass, schema, options): typeof Ad4mModel

Core implementation of Ad4mModel.fromJSONSchema().

Creates a dynamic Ad4mModel subclass from a JSON Schema definition, wiring up property / relation metadata, setters, and the @Model decorator.

Parameters

NameTypeDescription
BaseClasstypeof Ad4mModelThe Ad4mModel class (or subclass) to extend
schemaJSONSchemaJSON Schema definition
optionsJSONSchemaToModelOptionsConfiguration options

Returns

typeof Ad4mModel

Generated Ad4mModel subclass

Defined in

core/src/model/json-schema.ts:263 (opens in a new tab)


buildSDNA

▸ buildSDNA(subjectName, obj, properties, allRelationsMeta): Object

Build SDNA (Social DNA) Prolog code for a model class.

Parameters

NameTypeDescription
subjectNamestringThe model's registered name (from @Model({ name }))
objanytarget.prototype — used to inspect prototype methods (e.g. setter stubs, subjectConstructor, isSubjectInstance)
propertiesRecord<string, PropertyMetadataEntry>Merged property metadata (from getPropertiesMetadata)
allRelationsMetaRecord<string, RelationMetadataEntry>Merged relation metadata (from getRelationsMetadata)

Returns

Object

NameType
namestring
sdnastring

Defined in

core/src/model/sdna.ts:21 (opens in a new tab)


buildSHACL

▸ buildSHACL(subjectName, target, properties, allRelationsMeta, conformanceFilterFn, seedCache?, interpretationHint?): Object

Build a SHACL shape for a model class.

Parameters

NameTypeDescription
subjectNamestringThe model's registered name (from @Model({ name }))
targetanyThe class constructor (used for prototype access, inheritance chain, and relation target resolution)
propertiesRecord<string, PropertyMetadataEntry>Merged property metadata (from getPropertiesMetadata)
allRelationsMetaRecord<string, RelationMetadataEntry>Merged relation metadata (from getRelationsMetadata)
conformanceFilterFnConformanceFilterFnInjected conformance-filter builder (avoids circular dependency back into decorators.ts)
seedCache?(partial: { name: string ; shape: SHACLShape }) => voidOptional early-cache seeding callback. When invoked with a partial { shape, name }, any re-entrant generateSHACL() call on the same target — which happens when a relation's target: () => SameClass points at us, directly or transitively — observes the in-progress shape rather than re-entering this function infinitely. Provided by @Model via getMemoizedSHACL; safe to omit when calling buildSHACL directly (e.g. from a one-off SDNA build tool).
interpretationHint?stringNatural-language hint declared on the @Model decorator that steers the generic LLM extractor when producing instances of this class. Attached to the SHACL shape node and re-emitted as an ad4m://interpretation_hint link by SHACLShape.toLinks().

Returns

Object

NameType
namestring
shapeSHACLShape

Defined in

core/src/model/shacl-gen.ts:31 (opens in a new tab)


buildSPARQLQuery

▸ buildSPARQLQuery(metadata, allRelationsMetadata, query, modelClass): string

Build a SPARQL query that returns all links belonging to instances of the given model class, optionally filtered by where conditions.

Uses direct triple patterns: ?source ?predicate ?target with named graph storage and metadata keyed by graph IRI.

Parameters

NameType
metadataModelMetadata
allRelationsMetadataRecord<string, RelationMetadataEntry>
queryQuery
modelClassany

Returns

string

Defined in

core/src/model/query-sparql.ts:324 (opens in a new tab)


buildWhereCondition

▸ buildWhereCondition(predicate, condition, opts?): string

Compile a single Where condition for a property into a SPARQL triple pattern that can be embedded in a getter's WHERE clause.

The generated pattern operates on ?target — e.g.: ?target <pred> <value> . FILTER EXISTS { ?target <pred> ?_v0 }

Parameters

NameTypeDescription
predicatestringThe predicate URI for the property
conditionWhereConditionThe Where condition value
opts?ObjectOptional settings. isDeterministicLiteral (default true) selects the direct typed-literal WHERE path. Set to false when the property stores a signed envelope (resolveLanguage: "literal") or a custom-language expression — the envelope path unwraps with parse_literal before comparing.
opts.isDeterministicLiteral?boolean-
opts.varIndex?number-

Returns

string

A single SPARQL condition string

Defined in

core/src/model/query-utils.ts:58 (opens in a new tab)


capSentence

▸ capSentence(cap): string

Parameters

NameType
capany

Returns

string

Defined in

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


clearQueryCache

▸ clearQueryCache(): void

Clear all cache entries (useful for testing).

Returns

void

Defined in

core/src/model/query-cache.ts:70 (opens in a new tab)


coalesce

▸ coalesce(...args): NodeExpression

Coalesce: returns the first non-null evaluated argument.

Parameters

NameType
...argsNodeExpression[]

Returns

NodeExpression

Defined in

core/src/shacl/builders.ts:76 (opens in a new tab)


compileWhereClause

▸ compileWhereClause(where, metadata): string[]

Compile a full Where clause to an array of SPARQL condition strings.

When metadata is provided, property names are resolved to predicates using the model's property metadata. When metadata is null, property names are treated as raw predicate URIs.

Only handles regular properties — special fields (id, author, timestamp) and relation fields are skipped (they are only relevant at runtime query time, not for compile-time getter generation).

Parameters

NameType
whereWhere
metadataModelMetadata

Returns

string[]

Defined in

core/src/model/query-utils.ts:198 (opens in a new tab)


concat

▸ concat(...args): NodeExpression

String concatenation: joins evaluated arguments as strings. Null/undefined arguments are skipped.

Parameters

NameType
...argsNodeExpression[]

Returns

NodeExpression

Defined in

core/src/shacl/builders.ts:69 (opens in a new tab)


createPersistentCache

▸ createPersistentCache<T>(dbName, storeName): PersistentCache<T>

Create a PersistentCache backed by IndexedDB (browser) or NullCache (Node.js).

Type parameters

NameType
Tunknown

Parameters

NameTypeDescription
dbNamestringIndexedDB database name
storeNamestringIndexedDB object store name

Returns

PersistentCache<T>

Defined in

core/src/cache/PersistentCache.ts:133 (opens in a new tab)


determineNamespace

▸ determineNamespace(schema, options): string

Determines the namespace for predicates using cascading precedence:

  1. Explicit namespace in options
  2. x-ad4m metadata in schema
  3. Infer from schema title
  4. Try to extract from $id
  5. Error if nothing works

Parameters

NameType
schemaJSONSchema
optionsJSONSchemaToModelOptions

Returns

string

Defined in

core/src/model/json-schema.ts:108 (opens in a new tab)


determinePredicate

▸ determinePredicate(schema, propertyName, propertySchema, namespace, options): string

Determines the predicate for a specific property using cascading precedence:

  1. Explicit property mapping
  2. x-ad4m metadata in property schema
  3. Predicate template
  4. Custom predicate generator
  5. Default: namespace + property name

Parameters

NameType
schemaJSONSchema
propertyNamestring
propertySchemaJSONSchemaProperty
namespacestring
optionsJSONSchemaToModelOptions

Returns

string

Defined in

core/src/model/json-schema.ts:157 (opens in a new tab)


effectiveLiteralStorage

▸ effectiveLiteralStorage(meta): LiteralStorageMode

Derive the effective storage mode from a property's explicit options. resolveLanguage is the sole selector and is NOT defaulted at the decorator level:

  • unset → deterministic typed literal (the perf default for a plain @Property())
  • "literal" → signed envelope on the built-in literal language (per-value provenance, e.g. Flux message bodies)
  • <custom address> → signed expression on that custom language

Parameters

NameType
metaObject
meta.resolveLanguage?string

Returns

LiteralStorageMode

Defined in

core/src/model/query-sparql.ts:233 (opens in a new tab)


escapeQueryString

▸ escapeQueryString(value): string

Escapes a string value for safe use in query strings.

Parameters

NameTypeDescription
valuestringThe string value to escape

Returns

string

The escaped string safe for query interpolation (without surrounding quotes)

Description

Prevents SQL injection by properly escaping special characters in string values that will be interpolated into query strings. This handles the most common special characters that could break SQL queries or enable injection attacks.

Single quotes, backslashes, and other special characters are escaped using backslash notation, which is the standard escaping mechanism for query.

Example

const userInput = "user's input with 'quotes'";
const escaped = escapeQueryString(userInput);
const query = `SELECT * FROM link WHERE uri = '${escaped}'`;
// Results in: SELECT * FROM link WHERE uri = 'user\'s input with \'quotes\''

Defined in

core/src/utils.ts:49 (opens in a new tab)


exists

▸ exists(expr): NodeExpression

Existence check: returns true if the inner expression is non-null and non-empty.

Parameters

NameType
exprNodeExpression

Returns

NodeExpression

Defined in

core/src/shacl/builders.ts:36 (opens in a new tab)


exprRef2String

▸ exprRef2String(ref): string

Parameters

NameType
refExpressionRef

Returns

string

Defined in

core/src/expression/ExpressionRef.ts:16 (opens in a new tab)


fn

▸ fn(iri, args?): NodeExpression

Function call: invoke a named transform function by IRI. Primarily used for built-in functions like "ad4m://fn/defaultFileDecode".

Parameters

NameTypeDefault value
iristringundefined
argsNodeExpression[][]

Returns

NodeExpression

Defined in

core/src/shacl/builders.ts:84 (opens in a new tab)


focus

▸ focus(): NodeExpression

Identity expression: pass the focus node through unchanged.

Returns

NodeExpression

Defined in

core/src/shacl/builders.ts:13 (opens in a new tab)


formatList

▸ formatList(list): any

Parameters

NameType
listany

Returns

any

Defined in

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


formatQueryValue

▸ formatQueryValue(value): string

Format a JavaScript value for embedding in a query expression.

  • Strings are single-quoted with backslash / quote / newline escaping
  • Numbers and booleans are passed through as-is
  • Arrays are recursed

Parameters

NameType
valueany

Returns

string

Defined in

core/src/model/query-utils.ts:20 (opens in a new tab)


formatSPARQLValue

▸ formatSPARQLValue(value): string

Format a value as a SPARQL string literal (double-quoted).

Parameters

NameType
valueany

Returns

string

Defined in

core/src/model/query-sparql.ts:270 (opens in a new tab)


getCachedResult

▸ getCachedResult(perspectiveUUID, queryText): any | undefined

Get a cached query result if it exists and hasn't expired.

Parameters

NameType
perspectiveUUIDstring
queryTextstring

Returns

any | undefined

Defined in

core/src/model/query-cache.ts:27 (opens in a new tab)


getDefaultValueForType

▸ getDefaultValueForType(type?): any

Gets default value for a JSON Schema type.

Parameters

NameType
type?string

Returns

any

Defined in

core/src/model/json-schema.ts:238 (opens in a new tab)


getMemoizedSHACL

▸ getMemoizedSHACL(target, compute): any

Get or compute memoised SHACL for a class. Used by

Parameters

NameType
targetFunction
compute(seed: (partial: any) => void) => any

Returns

any

Model

decorator.

The compute callback receives a seed(partial) function: calling it stores partial in the cache before compute returns, so any re-entrant getMemoizedSHACL(target, …) call from inside compute observes the in-progress shape instead of re-entering compute infinitely.

This matters for self-referential models — e.g.

@Model({ name: "Channel" })
class Channel extends Ad4mModel {
    @HasMany({ predicate: "…/child", target: () => Channel })
    childChannels!: Channel[];
}

Without the seed, building the SHACL shape for Channel invokes Channel.generateSHACL() while walking the childChannels relation's target (shacl-gen.ts ~line 327), which re-enters this function with an empty cache, blowing the stack.

Defined in

core/src/model/decorators.ts:164 (opens in a new tab)


getPropertiesMetadata

▸ getPropertiesMetadata(ctor): Record<string, PropertyMetadataEntry>

Retrieve property metadata for a given class constructor. Walks the prototype chain so subclass decorators compose with parent decorators. Results are memoised per class constructor.

Parameters

NameType
ctorFunction

Returns

Record<string, PropertyMetadataEntry>

Defined in

core/src/model/decorators.ts:99 (opens in a new tab)


getPropertyOption

▸ getPropertyOption(propertyName, propertySchema, options, optionName, defaultValue?): any

Gets property-specific options using cascading precedence:

  1. Property-specific options
  2. x-ad4m metadata in property
  3. Global option
  4. Default value

Parameters

NameType
propertyNamestring
propertySchemaJSONSchemaProperty
optionsJSONSchemaToModelOptions
optionNamekeyof PropertyOptions
defaultValue?any

Returns

any

Defined in

core/src/model/json-schema.ts:209 (opens in a new tab)


getRelationsMetadata

▸ getRelationsMetadata(ctor): Record<string, RelationMetadataEntry>

Retrieve relation metadata for a given class constructor. Walks the prototype chain so subclass decorators compose with parent decorators. Results are memoised per class constructor.

Parameters

NameType
ctorFunction

Returns

Record<string, RelationMetadataEntry>

Defined in

core/src/model/decorators.ts:123 (opens in a new tab)


hasJsOnlyWhereFilters

▸ hasJsOnlyWhereFilters(metadata, allRelationsMetadata, where?): boolean

Check whether a where clause contains filters that cannot be pushed down to SPARQL and must be evaluated in JS after hydration.

JS-only filters include:

  • Literal-stored properties (equality, comparison, contains, etc.)
  • Reverse relations (belongsToOne / belongsToMany)
  • author / timestamp filters (skipped by buildSPARQLWhereFilters)
  • OR / AND / NOT combinators (skipped by buildSPARQLWhereFilters — see below)

When JS-only filters exist, SPARQL-level LIMIT/OFFSET must NOT be applied because the database would cap the candidate set before JS filters run, potentially discarding matches beyond the LIMIT.

Parameters

NameType
metadataModelMetadata
allRelationsMetadataRecord<string, RelationMetadataEntry>
where?Where

Returns

boolean

Defined in

core/src/model/query-sparql.ts:34 (opens in a new tab)


hintFor

▸ hintFor(msg): string

Add a short cause hint to known subscription failures. The executor needs its main key to register a live query; on a restarted executor whose wallet was never unlocked this surfaces as a bare 403.

Parameters

NameType
msgstring

Returns

string

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:69 (opens in a new tab)


ifExpr

▸ ifExpr(cond): Object

Conditional expression with optional else branch. Returns a chainable builder that supports .then() and .else().

Parameters

NameType
condNodeExpression

Returns

Object

NameType
then(thenExpr: NodeExpression) => { else: (elseExpr?: NodeExpression) => Readonly<{ cond: NodeExpression ; else: NodeExpression = elseExpr; then: NodeExpression = thenExpr; type: "if" = 'if' }> ; toExpression: () => Readonly<{ cond: NodeExpression ; then: NodeExpression = thenExpr; type: "if" = 'if' }> }

Defined in

core/src/shacl/builders.ts:44 (opens in a new tab)


invalidatePerspectiveCache

▸ invalidatePerspectiveCache(perspectiveUUID): void

Invalidate all cache entries for a given perspective. Called after write operations to ensure stale data isn't served.

Parameters

NameType
perspectiveUUIDstring

Returns

void

Defined in

core/src/model/query-cache.ts:58 (opens in a new tab)


isArrayType

▸ isArrayType(schema): boolean

Parameters

NameType
schemaJSONSchemaProperty

Returns

boolean

Defined in

core/src/model/json-schema.ts:85 (opens in a new tab)


isExpression

▸ isExpression(e): boolean

Parameters

NameType
eany

Returns

boolean

Defined in

core/src/expression/Expression.ts:66 (opens in a new tab)


isIncludeProjection

▸ isIncludeProjection(val): val is IncludeProjection

Type guard for IncludeProjection objects.

Parameters

NameType
valunknown

Returns

val is IncludeProjection

Defined in

core/src/model/types.ts:322 (opens in a new tab)


isLink

▸ isLink(l): boolean

Parameters

NameType
lany

Returns

boolean

Defined in

core/src/links/Links.ts:105 (opens in a new tab)


isNodeExpression

▸ isNodeExpression(v): v is NodeExpression

Type guard to check if a value is a valid NodeExpression.

Parameters

NameType
vunknown

Returns

v is NodeExpression

Defined in

core/src/shacl/NodeExpression.ts:28 (opens in a new tab)


isNumericType

▸ isNumericType(schema): boolean

Parameters

NameType
schemaJSONSchemaProperty

Returns

boolean

Defined in

core/src/model/json-schema.ts:93 (opens in a new tab)


isObjectType

▸ isObjectType(schema): boolean

Parameters

NameType
schemaJSONSchemaProperty

Returns

boolean

Defined in

core/src/model/json-schema.ts:89 (opens in a new tab)


isSchemaType

▸ isSchemaType(schema, expectedType): boolean

Parameters

NameType
schemaJSONSchemaProperty
expectedTypestring

Returns

boolean

Defined in

core/src/model/json-schema.ts:81 (opens in a new tab)


isTraverseScope

▸ isTraverseScope(scope): scope is TraverseScope

Whether this scope is a traversal rather than a single named parent.

The other two forms carry id; this one carries ids and may name several, so anything reaching for one parent — every write path — has to ask first.

Parameters

NameType
scopeScope

Returns

scope is TraverseScope

Defined in

core/src/model/types.ts:240 (opens in a new tab)


linkEqual

▸ linkEqual(l1, l2): boolean

Parameters

NameType
l1LinkExpression
l2LinkExpression

Returns

boolean

Defined in

core/src/links/Links.ts:97 (opens in a new tab)


linkExpressionInputToWire

▸ linkExpressionInputToWire(link): WireLinkExpressionInput

Parameters

NameType
linkLinkExpressionInput

Returns

WireLinkExpressionInput

Defined in

core/src/links/Links.ts:80 (opens in a new tab)


linkExpressionToWire

▸ linkExpressionToWire(link): WireLinkExpression

Parameters

NameType
linkLinkExpression

Returns

WireLinkExpression

Defined in

core/src/links/Links.ts:70 (opens in a new tab)


linkMutationsToWire

▸ linkMutationsToWire(mutations): WireLinkMutations

Parameters

NameType
mutationsLinkMutations

Returns

WireLinkMutations

Defined in

core/src/links/Links.ts:90 (opens in a new tab)


literal

▸ literal(value): NodeExpression

Literal constant expression.

Parameters

NameType
valuestring | number | boolean

Returns

NodeExpression

Defined in

core/src/shacl/builders.ts:20 (opens in a new tab)


looksLikeUri

▸ looksLikeUri(value): boolean

Check whether a string value is a well-formed absolute IRI that can be stored verbatim as a link target (raw NamedNode) instead of being wrapped in a literal:string:* URI.

This mirrors the Rust is_safe_iri_target / looks_like_absolute_iri predicate in rust-executor/src/perspectives/model_query/utils.rs and is load-bearing: a value that returns true here MUST also be safely queryable on the Rust side (validate_iri gate on the SPARQL UNION { ?s <pred> <val> } IRI arm), otherwise scheme-lookalike prose such as "Note: buy milk", "Re: standup", "TODO: fix this" slips through the write regex, is stored as an invalid NamedNode, and becomes a silent no-match on read.

Fast-path scheme check (^[a-zA-Z][a-zA-Z0-9+\-._]*:) followed by the same rejection set the Rust validate_iri applies: any Unicode whitespace, C0/C1 control chars, and the SPARQL-breaking characters < > { } ".

Parameters

NameType
valuestring

Returns

boolean

Defined in

core/src/model/query-sparql.ts:165 (opens in a new tab)


neighbourhoodExpressionFromWire

▸ neighbourhoodExpressionFromWire(wire): NeighbourhoodExpression

Build a NeighbourhoodExpression, with a Perspective as its meta, from the wire shape.

Parameters

NameType
wireDecoratedNeighbourhoodExpression

Returns

NeighbourhoodExpression

Defined in

core/src/perspectives/PerspectiveHandle.ts:49 (opens in a new tab)


normalizeNamespaceString

▸ normalizeNamespaceString(namespace): string

Parameters

NameType
namespacestring

Returns

string

Defined in

core/src/model/json-schema.ts:60 (opens in a new tab)


normalizeSchemaType

▸ normalizeSchemaType(type?): string | undefined

Parameters

NameType
type?string | string[]

Returns

string | undefined

Defined in

core/src/model/json-schema.ts:71 (opens in a new tab)


normalizeValue

▸ normalizeValue(value): any

Normalize a value for snapshot storage. Arrays of model instances are reduced to their .id strings so that dirty-tracking compares stable identifiers instead of object references.

Parameters

NameType
valueany

Returns

any

Defined in

core/src/model/hydration.ts:18 (opens in a new tab)


normalizeWhereForSparql

▸ normalizeWhereForSparql(metadata, where?): Where | undefined

Prepare a where for this client-side SPARQL builder: unwrap { eq: X } to the bare X, and refuse a per-link author.

A per-link author (nested, { agent: { eq: X, author: A } }, or a top-level author beside link-backed property or relation conditions) is answered by the executor, which joins each matched link's reifier (#1114). This builder has no such join, and treating the author as instance-level here would answer a different, wider question. findAll()/count() answer it.

Parameters

NameType
metadataModelMetadata
where?Where

Returns

Where | undefined

Defined in

core/src/model/query-sparql.ts:94 (opens in a new tab)


parseExprUrl

▸ parseExprUrl(url): ExpressionRef

Parameters

NameType
urlstring

Returns

ExpressionRef

Defined in

core/src/expression/ExpressionRef.ts:23 (opens in a new tab)


parseLit

▸ parseLit(val): string

Decode a Literal-encoded SPARQL binding back to a plain string.

Returns '' for undefined/empty input. Falls through to the raw value if decoding fails — bindings against properties resolved through a custom language are already raw URIs and should pass through unchanged.

Signed-envelope literals

Properties declared with resolveLanguage: 'literal' are written through the built-in literal language, which wraps the value in a signed expression envelope ({ author, timestamp, data, proof }) and encodes the whole envelope as a literal:json: URL — see rust-executor/src/languages/mod.rs::expression_create (literal branch). On read, parseLit unwraps .data from that envelope so callers get the original scalar value instead of the envelope JSON.

The Channel V refactor moved most scalar properties to deterministic typed XSD literals which no longer round-trip through this envelope — for those properties the SPARQL binding is already the lexical form and this helper decodes to the primitive. Signed-envelope literals still exist for any property that opts back into resolveLanguage: 'literal' (e.g. per-message provenance for chat bodies), which is why the .data unwrap is preserved here.

Non-envelope JSON objects (literal:json: payloads that are not signed envelopes) are JSON-stringified for display.

Parameters

NameType
valstring

Returns

string

Defined in

core/src/perspectives/SparqlBindings.ts:75 (opens in a new tab)


parseLitBoolean

▸ parseLitBoolean(val): boolean

Decode a Literal-encoded binding to a boolean. Returns false on empty input.

Parameters

NameType
valstring

Returns

boolean

Defined in

core/src/perspectives/SparqlBindings.ts:127 (opens in a new tab)


parseLitNumber

▸ parseLitNumber(val): number

Decode a Literal-encoded binding to a number. Returns 0 on empty/invalid input.

Parameters

NameType
valstring

Returns

number

Defined in

core/src/perspectives/SparqlBindings.ts:119 (opens in a new tab)


parseSparqlCount

▸ parseSparqlCount(result): number

Sum a SPARQL COUNT(?x) result down to a plain number (returns 0 on empty).

Parameters

NameType
resultCountBinding[]

Returns

number

Defined in

core/src/perspectives/SparqlBindings.ts:40 (opens in a new tab)


path

▸ path(predicate): NodeExpression

Path expression: navigate to a property on the resolved object. The predicate can be a full IRI (e.g., "file_storage://data_base64") or a simple property name. The Rust evaluator will strip the namespace.

Parameters

NameType
predicatestring

Returns

NodeExpression

Defined in

core/src/shacl/builders.ts:29 (opens in a new tab)


queryCacheSize

▸ queryCacheSize(): number

Get the current size of the cache (useful for testing).

Returns

number

Defined in

core/src/model/query-cache.ts:77 (opens in a new tab)


requireSingleParent

▸ requireSingleParent(parent): Exclude<Scope, TraverseScope>

Narrow a scope to the one-parent forms, for the paths that write a link.

A traversal describes a read outward from several anchors. Creating a record "under" one would have to pick which, and nothing in the scope says — so this refuses rather than guessing at the first of the list. The executor's write scopes refuse it for the same reason.

Parameters

NameType
parentScope

Returns

Exclude<Scope, TraverseScope>

Defined in

core/src/model/query-common.ts:26 (opens in a new tab)


resolveParentPredicate

▸ resolveParentPredicate(parent, childCtor): string

Parameters

NameType
parentScope
childCtorFunction

Returns

string

Defined in

core/src/model/query-common.ts:36 (opens in a new tab)


setCachedResult

▸ setCachedResult(perspectiveUUID, queryText, result, ttlMs?): void

Store a query result in the cache with TTL.

Parameters

NameTypeDefault value
perspectiveUUIDstringundefined
queryTextstringundefined
resultanyundefined
ttlMsnumberDEFAULT_TTL_MS

Returns

void

Defined in

core/src/model/query-cache.ts:41 (opens in a new tab)


setPropertyRegistryEntry

▸ setPropertyRegistryEntry(ctor, propName, meta): void

Programmatically register property metadata for a given constructor. Used by fromJSONSchema() and other dynamic model builders.

Parameters

NameType
ctorFunction
propNamestring
metaPropertyMetadataEntry & { writable?: boolean }

Returns

void

Defined in

core/src/model/decorators.ts:191 (opens in a new tab)


setRelationRegistryEntry

▸ setRelationRegistryEntry(ctor, relName, meta): void

Programmatically register relation metadata for a given constructor. Used by fromJSONSchema() and other dynamic model builders.

Parameters

NameType
ctorFunction
relNamestring
metaRelationMetadataEntry

Returns

void

Defined in

core/src/model/decorators.ts:204 (opens in a new tab)


valueToLiteralIri

▸ valueToLiteralIri(value): string

Convert a JS value to its literal: IRI form, matching how the Rust executor stores property values in the default deterministic-literal path (resolveLanguage unset). Strings that already look like URIs are returned as-is.

Exported so write-side helpers (e.g. Ad4mModel.setProperty's literal resolve path) can keep their on-disk form aligned with what queryToSPARQL() filters against — otherwise the same value can be stored as <literal:string:https%3A...> from one path while WHERE builders probe <https://example.com> from the other.

The object/array arm mirrors Rust's Literal::from_json in perspective_instance.rs::resolve_property_value (which routes Value::Object | Value::Array through JSON encoding). Without it, JS would fall through to String(value) and turn {a: 1} into "[object Object]" and [1, 2, 3] into "1,2,3" before wrapping.

Parameters

NameType
valueany

Returns

string

Defined in

core/src/model/query-sparql.ts:192 (opens in a new tab)