DSM & definitions

This bucket holds the two ways to obtain runtime definitions: build them in code with Definitions, or parse them from .dsm source with DSMBuilder. Both yield the same kind of registry — concepts, clubs, enumerations, structures and attachments — that the rest of the runtime resolves types against. The DSM* classes additionally model the parsed declarations themselves (a DSMStructure, its DSMStructureFields, and so on) for introspection.

When to use: reach for Definitions to assemble a schema programmatically (registering types one call at a time); reach for DSMBuilder to load and introspect an existing model file. Wrap either result in a DefinitionsInspector (or DSMDefinitionsInspector) to query types by name.

Note

The static (code-generation) path that turns a parsed model into a typed module ships in a later release. This page covers the runtime introspection surface only.

Quick Start

Build a Definitions registry in code:

const {
  Definitions, NameSpace, ValueUUId, Type,
  TypeEnumerationDescriptor, TypeStructureDescriptor,
  DefinitionsInspector,
} = require('@digitalsubstrate/dsviper');

const defs = new Definitions();
const ns = new NameSpace(ValueUUId.create(), 'Game');

// Concepts and clubs
const player = defs.createConcept(ns, 'Player', 'a participant');
const team = defs.createClub(ns, 'Team');
defs.createMembership(team, player);

// An enumeration, described then registered
const levelDesc = new TypeEnumerationDescriptor('Level');
levelDesc.addCase('beginner');
levelDesc.addCase('expert');
const level = defs.createEnumeration(ns, levelDesc);

// A structure, described field by field
const propsDesc = new TypeStructureDescriptor('Props', 'player properties');
propsDesc.addField('name', Type.STRING);
propsDesc.addField('score', Type.INT64);
const props = defs.createStructure(ns, propsDesc);

// An attachment keys a document type onto a concept
defs.createAttachment(ns, 'props', player, props);

// Inspect the assembled registry
const insp = new DefinitionsInspector(defs.const());
insp.structureTypeNames();              // [ TypeName('Props') ]
insp.checkStructure(props.typeName());  // -> TypeStructure (throws if absent)

Or parse a .dsm model and introspect the result:

const { DSMBuilder } = require('@digitalsubstrate/dsviper');

// assemble(path) loads a file or a directory of .dsm files; or append() in code
const builder = DSMBuilder.assemble('model.dsm');
const [report, dsm, defs] = builder.parse();

// Always check the report before using the definitions
if (report.hasError()) {
  for (const err of report.errors()) console.error(err.message());
  throw new Error('DSM parse failed');
}

// Walk the parsed declarations
for (const struct of dsm.structures()) {
  console.log(`struct ${struct.typeName().name()}`);
  for (const field of struct.fields()) {
    console.log(`  ${field.name()}: ${field.type().typeName().name()}`);
  }
}

A parse error is reported through the DSMParseReport, not thrown; a runtime failure (an unknown type, a duplicate case) surfaces as a JS Error whose .name is 'ViperError'.

Choosing an entry point

Goal

Start with

Then

Assemble a schema in code

Definitions

createConcept / createClub / createEnumeration / createStructure / createAttachment

Load a schema from .dsm

DSMBuilder

assemble(path) / append(name, src), then parse()

Query types by name

DefinitionsInspector

query* (returns the type or undefined) / check* (throws on miss)

Introspect a parsed model

DSMDefinitions

structures() / concepts() / enumerations() / attachments()

The mirror of this page for the Python binding is DSM Introspection; for a narrative walkthrough see the DSM guide. The type classes referenced by fields live on Types.

Generated from the @digitalsubstrate/dsviper TypeScript declarations (index.d.ts) by TypeDoc.

Summary

Class

Description

DSMAttachment

A class used to represent the definition of an attachment

DSMAttachmentFunction

A class used to represent the definition of an attachment function

DSMAttachmentFunctionPool

A class used to represent the definition of an attachment function pool

DSMBuilder

A class used to assemble a collection of DSM Definitions from various sources

DSMBuilderPart

A class used to represent a part of the assembled definitions

DSMClub

A class used to represent the definition of a club

DSMConcept

A class used to represent the definition of a concept

DSMDefinitions

A class used to represent DSM definitions

DSMDefinitionsInspector

DSMDefinitionsInspector(definitions)

DSMEnumeration

A class used to represent the definition of an enum

DSMEnumerationCase

A class used to represent the definition of a case for an enum

DSMFunction

A class used to represent the definition of a function

DSMFunctionPool

A class used to represent the definition of a function pool

DSMFunctionPrototype

A class used to represent the definition of a function prototype

DSMLiteral

DSMLiteralList

A class used to represent the definition of a literal list

DSMLiteralValue

A class used to represent the definition of a literal value

DSMParseError

A class used to represent a parse error

DSMParseReport

A class used to collect the error occurred while parsing the assembled definitions

DSMStructure

A class used to represent the definition of a struct

DSMStructureField

A class used to represent the definition of a field for a struct

DSMType

DSMTypeKey

A class used to represent the type key<element_type>

DSMTypeMap

A class used to represent the type map<key_type, element_type>

DSMTypeMat

A class used to represent the type vec<element_type, columns, rows>

DSMTypeOptional

A class used to represent the type optional<element_type>

DSMTypeReference

A class used to represent a reference to a type

DSMTypeSet

A class used to represent the type set<element_type>

DSMTypeTuple

A class used to represent the type tuple<T0, …>

DSMTypeVariant

A class used to represent the type variant<T0, …>

DSMTypeVec

A class used to represent the type vec<element_type, size>

DSMTypeVector

A class used to represent the type vector<element_type>

DSMTypeXArray

A class used to represent the type xarray<element_type>

Definitions

A class used to register concept, club, enumeration, structure and attachment

DefinitionsCollector

A class used to collect referenced types

DefinitionsConst

A class used to retrieve registered concepts, clubs, enumerations, structures and attachments

DefinitionsExtendInfo

A class used to represent the types exchanged during the synchronization of two databases

DefinitionsInspector

DefinitionsInspector(definitions)

DefinitionsMapper

A class use for INTERNAL DEVELOPMENT

Reference

class DSMAttachment()

A class used to represent the definition of an attachment.

Note: Not directly instantiable.

exported from index.d

DSMAttachment.documentType()

Return the type reference of the document.

Returns:

DSMType

DSMAttachment.documentation()

Return the documentation.

Returns:

string

DSMAttachment.identifier()

Return the identifier.

Returns:

string

DSMAttachment.keyType()

Return the type reference of the key.

Returns:

DSMTypeReference

DSMAttachment.representation()

Return the representation.

Returns:

string

DSMAttachment.runtimeId()

Return the uuid assigned by the runtime.

Returns:

ValueUUId

DSMAttachment.typeName()

Return the TypeName.

Returns:

TypeName

class DSMAttachmentFunction()

A class used to represent the definition of an attachment function.

Note: Not directly instantiable.

exported from index.d

DSMAttachmentFunction.documentation()

Return the documentation.

Returns:

string

DSMAttachmentFunction.isMutable()

Return true if the function is mutable.

Returns:

boolean

DSMAttachmentFunction.prototype()

Return the prototype.

Returns:

DSMFunctionPrototype

class DSMAttachmentFunctionPool()

A class used to represent the definition of an attachment function pool.

Note: Not directly instantiable.

exported from index.d

DSMAttachmentFunctionPool.documentation()

Return the documentation.

Returns:

string

DSMAttachmentFunctionPool.functions()

Return the list of functions.

Returns:

DSMAttachmentFunction[]

DSMAttachmentFunctionPool.name()

Return the name.

Returns:

string

DSMAttachmentFunctionPool.uuid()

Return the uuid.

Returns:

ValueUUId

class DSMBuilder()
A class used to assemble a collection of DSM Definitions from various

sources.

exported from index.d

DSMBuilder.append(source, content)

Append a content from a source.

Arguments:
  • source (string)

  • content (string)

DSMBuilder.content()

Return the content.

Returns:

string

DSMBuilder.lineOffset()

Return the line offset.

Returns:

number

DSMBuilder.parse()

Parse and return (DSMParseReport, DSMDefinitions, Definitions).

Returns:

[DSMParseReport, DSMDefinitions | undefined, DefinitionsConst | undefined]

DSMBuilder.part(line)

Return the part associated with the line number.

Arguments:
  • line (number)

Returns:

DSMBuilderPart | undefined

DSMBuilder.parts()

Return the list of parts.

Returns:

DSMBuilderPart[]

static DSMBuilder.assemble(path)
Return a DSMBuilder with the concatenated content of the DSM files found

at the path where the path is a file or a folder.

Arguments:
  • path (string)

Returns:

DSMBuilder

class DSMBuilderPart()

A class used to represent a part of the assembled definitions.

Note: Not directly instantiable.

exported from index.d

DSMBuilderPart.lineEnd()

Return the line end.

Returns:

number

DSMBuilderPart.lineStart()

Return the line start.

Returns:

number

DSMBuilderPart.source()

Return the source.

Returns:

string

class DSMClub()

A class used to represent the definition of a club.

Note: Not directly instantiable.

exported from index.d

DSMClub.documentation()

Return the documentation.

Returns:

string

DSMClub.members()

Return the list of members.

Returns:

DSMTypeReference[]

DSMClub.runtimeId()

Return the uuid assigned by the runtime.

Returns:

ValueUUId

DSMClub.typeName()

Return the TypeName.

Returns:

TypeName

DSMClub.typeReference()

Return the type reference.

Returns:

DSMTypeReference

class DSMConcept()

A class used to represent the definition of a concept.

Note: Not directly instantiable.

exported from index.d

DSMConcept.documentation()

Return the documentation.

Returns:

string

DSMConcept.parent()

Return the type reference of the parent concept or null.

Returns:

DSMTypeReference

DSMConcept.runtimeId()

Return the uuid assigned by the runtime.

Returns:

ValueUUId

DSMConcept.typeName()

Return the TypeName.

Returns:

TypeName

DSMConcept.typeReference()

Return the type reference.

Returns:

DSMTypeReference

class DSMDefinitions()
A class used to represent DSM definitions. Available representations are

plain-text, HTML, JSON, Bson, binary. Use the static factory method to get the definitions from various representation.

Note: Not directly instantiable.

exported from index.d

DSMDefinitions.attachmentFunctionPools()

Return the list of attachment function pools.

Returns:

DSMAttachmentFunctionPool[]

DSMDefinitions.attachments()

Return the list of attachments.

Returns:

DSMAttachment[]

DSMDefinitions.bsonEncode()

Return the definitions in bson.

Returns:

ValueBlob

DSMDefinitions.clubs()

Return the list of clubs.

Returns:

DSMClub[]

DSMDefinitions.concepts()

Return the list of concepts.

Returns:

DSMConcept[]

DSMDefinitions.encode(streamCodecInstancing)
Return the blob that encodes the definitions with a

StreamTokenBinaryCodec if not specified.

Arguments:
  • streamCodecInstancing (StreamCodecInstancing)

Returns:

ValueBlob

DSMDefinitions.enumerations()

Return the list of enumerations.

Returns:

DSMEnumeration[]

DSMDefinitions.functionPools()

Return the list of function pools.

Returns:

DSMFunctionPool[]

DSMDefinitions.jsonEncode(indent)
Encode and return the definitions in a JSON encoded string.

If indent is specified, the string is pretty printed.

Arguments:
  • indent (number)

Returns:

string

DSMDefinitions.structures()

Return the list of structures.

Returns:

DSMStructure[]

DSMDefinitions.toDefinitions()

Return a Definitions by converting all DSM definitions.

Returns:

Definitions

DSMDefinitions.toDsm(showDocumentation, showRuntimeId, html, attachments)
Return the definitions in the DSM language (DSL) sorted by attachment dependencies.

All attachments are used, if the parameter attachments is not specified or empty.

Arguments:
  • showDocumentation (boolean)

  • showRuntimeId (boolean)

  • html (boolean)

  • attachments (DSMAttachment[])

Returns:

string

DSMDefinitions.write(streamWriting)

Write the definitions with the StreamWriting interface.

Arguments:
  • streamWriting (StreamWriting)

static DSMDefinitions.bsonDecode(blob)

Return a DSMDefinitions from a bson encoded blob.

Arguments:
  • blob (ValueBlob)

Returns:

DSMDefinitions

static DSMDefinitions.decode(blob, streamCodecInstancing)
Return the decoded DSMDefinitions with a StreamTokenBinaryCodec

if not specified.

Arguments:
  • blob (ValueBlob)

  • streamCodecInstancing (StreamCodecInstancing)

Returns:

DSMDefinitions

static DSMDefinitions.fromDefinitions(definitions)

Convert to DSM Definitions.

Arguments:
  • definitions (DefinitionsConst)

Returns:

DSMDefinitions

static DSMDefinitions.jsonDecode(jsonString)

Return a DSMDefinitions from a JSON encoded string.

Arguments:
  • jsonString (string)

Returns:

DSMDefinitions

static DSMDefinitions.read(streamReading)

Return a DSMDefinitions.

Arguments:
  • streamReading (StreamReading)

Returns:

DSMDefinitions

class DSMDefinitionsInspector(definitions)
DSMDefinitionsInspector(definitions).

A class used to retrieve registered concepts, clubs, enumerations, structures from TypeName and attachments from identifier.

exported from index.d

Arguments:
  • definitions (DSMDefinitions)

DSMDefinitionsInspector.attachmentFunctionPoolIds()

Return the set of uuid for all function pools.

Returns:

ValueUUId[]

DSMDefinitionsInspector.attachmentIdentifiers()

Return the set of identifiers for all attachments.

Returns:

string[]

DSMDefinitionsInspector.checkAttachment(identifier)

Return the attachment or throw.

Arguments:
  • identifier (string)

Returns:

DSMAttachment

DSMDefinitionsInspector.checkAttachmentFunctionPool(uuid)

Return the attachment function pool or throw.

Arguments:
  • uuid (ValueUUId)

Returns:

DSMAttachmentFunctionPool

DSMDefinitionsInspector.checkClub(typeName)

Return the club or throw.

Arguments:
  • typeName (TypeName)

Returns:

DSMClub

DSMDefinitionsInspector.checkConcept(typeName)

Return the concept or throw.

Arguments:
  • typeName (TypeName)

Returns:

DSMConcept

DSMDefinitionsInspector.checkEnumeration(typeName)

Return the enum or throw.

Arguments:
  • typeName (TypeName)

Returns:

DSMEnumeration

DSMDefinitionsInspector.checkFunctionPool(uuid)

Return the function pool or throw.

Arguments:
  • uuid (ValueUUId)

Returns:

DSMFunctionPool

DSMDefinitionsInspector.checkStructure(typeName)

Return a struct or throw.

Arguments:
  • typeName (TypeName)

Returns:

DSMStructure

DSMDefinitionsInspector.clubTypeNames()

Return the set of TypeName for all clubs.

Returns:

TypeName[]

DSMDefinitionsInspector.conceptTypeNames()

Return the set of TypeName for all concepts.

Returns:

TypeName[]

DSMDefinitionsInspector.enumerationTypeNames()

Return the set of TypeName for all enums.

Returns:

TypeName[]

DSMDefinitionsInspector.functionPoolIds()

Return the set of uuid for all function pools.

Returns:

ValueUUId[]

DSMDefinitionsInspector.nameSpaces()

Return the set of NameSpace for all TypNames.

Returns:

NameSpace[]

DSMDefinitionsInspector.queryAttachment(identifier)

Return the attachment or null.

Arguments:
  • identifier (string)

Returns:

DSMAttachment | undefined

DSMDefinitionsInspector.queryAttachmentFunctionPool(uuid)

Return the attachment function pool or null.

Arguments:
  • uuid (ValueUUId)

Returns:

DSMAttachmentFunctionPool | undefined

DSMDefinitionsInspector.queryClub(typeName)

Return the club or null.

Arguments:
  • typeName (TypeName)

Returns:

DSMClub | undefined

DSMDefinitionsInspector.queryConcept(typeName)

Return the concept or null.

Arguments:
  • typeName (TypeName)

Returns:

DSMConcept | undefined

DSMDefinitionsInspector.queryEnumeration(typeName)

Return the enum or null.

Arguments:
  • typeName (TypeName)

Returns:

DSMEnumeration | undefined

DSMDefinitionsInspector.queryFunctionPool(uuid)

Return the function pool or null.

Arguments:
  • uuid (ValueUUId)

Returns:

DSMFunctionPool | undefined

DSMDefinitionsInspector.queryStructure(typeName)

Return a struct or null.

Arguments:
  • typeName (TypeName)

Returns:

DSMStructure | undefined

DSMDefinitionsInspector.representation(typeName)

Return the shortest representation of the TypeName.

Arguments:
  • typeName (TypeName)

Returns:

string

DSMDefinitionsInspector.structureTypeNames()

Return the set of TypeName for all structs.

Returns:

TypeName[]

class DSMEnumeration()

A class used to represent the definition of an enum.

Note: Not directly instantiable.

exported from index.d

DSMEnumeration.documentation()

Return the documentation.

Returns:

string

DSMEnumeration.members()

Return the list of members.

Returns:

DSMEnumerationCase[]

DSMEnumeration.runtimeId()

Return the uuid assigned by the runtime.

Returns:

ValueUUId

DSMEnumeration.typeName()

Return the TypeName.

Returns:

TypeName

DSMEnumeration.typeReference()

Return the type reference.

Returns:

DSMTypeReference

class DSMEnumerationCase()

A class used to represent the definition of a case for an enum.

Note: Not directly instantiable.

exported from index.d

DSMEnumerationCase.documentation()

Return the documentation.

Returns:

string

DSMEnumerationCase.name()

Return the name.

Returns:

string

class DSMFunction()

A class used to represent the definition of a function.

Note: Not directly instantiable.

exported from index.d

DSMFunction.documentation()

Return the documentation.

Returns:

string

DSMFunction.prototype()

Return the prototype.

Returns:

DSMFunctionPrototype

class DSMFunctionPool()

A class used to represent the definition of a function pool.

Note: Not directly instantiable.

exported from index.d

DSMFunctionPool.documentation()

Return the documentation.

Returns:

string

DSMFunctionPool.functions()

Return the list of functions.

Returns:

DSMFunction[]

DSMFunctionPool.name()

Return the name.

Returns:

string

DSMFunctionPool.uuid()

Return the uuid.

Returns:

ValueUUId

class DSMFunctionPrototype()

A class used to represent the definition of a function prototype.

Note: Not directly instantiable.

exported from index.d

DSMFunctionPrototype.name()

Return the name.

Returns:

string

DSMFunctionPrototype.parameters()

Return the list of parameters.

Returns:

[string, DSMType][]

DSMFunctionPrototype.returnType()

Return the type of the returned value.

Returns:

DSMType

class DSMLiteral()

exported from index.d

class DSMLiteralList()

A class used to represent the definition of a literal list.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMLiteral

DSMLiteralList.members()

Return the list of members.

Returns:

DSMLiteral[]

class DSMLiteralValue()

A class used to represent the definition of a literal value.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMLiteral

DSMLiteralValue.domain()

Return the domain.

Returns:

string

DSMLiteralValue.value()

Return the value.

Returns:

string

class DSMParseError()

A class used to represent a parse error.

Note: Not directly instantiable.

exported from index.d

DSMParseError.line()

Return the line number.

Returns:

number

DSMParseError.message()

Return the message.

Returns:

string

DSMParseError.pos()

Return the position in the line.

Returns:

number

DSMParseError.source()

Return the source.

Returns:

string

class DSMParseReport()
A class used to collect the error occurred while parsing the assembled

definitions.

Note: Not directly instantiable.

exported from index.d

DSMParseReport.errors()

Return the list of errors.

Returns:

DSMParseError[]

DSMParseReport.hasError()

Return true if errors were occurred.

Returns:

boolean

class DSMStructure()

A class used to represent the definition of a struct.

Note: Not directly instantiable.

exported from index.d

DSMStructure.documentation()

Return the documentation.

Returns:

string

DSMStructure.fields()

Return the list of fields.

Returns:

DSMStructureField[]

DSMStructure.runtimeId()

Return the uuid assigned by the runtime.

Returns:

ValueUUId

DSMStructure.typeName()

Return a TypeName.

Returns:

TypeName

DSMStructure.typeReference()

Return the type reference.

Returns:

DSMTypeReference

class DSMStructureField()

A class used to represent the definition of a field for a struct.

Note: Not directly instantiable.

exported from index.d

DSMStructureField.defaultValue()

Return the default value.

Returns:

DSMLiteral

DSMStructureField.documentation()

Return the documentation.

Returns:

string

DSMStructureField.name()

Return the name.

Returns:

string

DSMStructureField.type()

Return the type.

Returns:

DSMType

class DSMType()

exported from index.d

class DSMTypeKey()

A class used to represent the type key<element_type>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeKey.elementType()

Return type the element.

Returns:

DSMType

class DSMTypeMap()

A class used to represent the type map<key_type, element_type>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeMap.elementType()

Return the type of the element.

Returns:

DSMType

DSMTypeMap.keyType()

Return the type of the key.

Returns:

DSMType

class DSMTypeMat()

A class used to represent the type vec<element_type, columns, rows>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeMat.columns()

Return the number of columns.

Returns:

number

DSMTypeMat.elementType()

Return the type of element.

Returns:

DSMType

DSMTypeMat.rows()

Return the number of rows.

Returns:

number

class DSMTypeOptional()

A class used to represent the type optional<element_type>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeOptional.elementType()

Return the type of the element.

Returns:

DSMType

class DSMTypeReference()

A class used to represent a reference to a type.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeReference.domain()

Return the domain.

Returns:

string

DSMTypeReference.typeName()

Return a TypeName.

Returns:

TypeName

class DSMTypeSet()

A class used to represent the type set<element_type>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeSet.elementType()

Return the type of element.

Returns:

DSMType

class DSMTypeTuple()

A class used to represent the type tuple<T0, …>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeTuple.types()

Return the list of types.

Returns:

DSMType[]

class DSMTypeVariant()

A class used to represent the type variant<T0, …>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeVariant.types()

Return the list of types.

Returns:

DSMType[]

class DSMTypeVec()

A class used to represent the type vec<element_type, size>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeVec.elementType()

Return the type of element.

Returns:

DSMType

DSMTypeVec.size()

Return the size.

Returns:

number

class DSMTypeVector()

A class used to represent the type vector<element_type>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeVector.elementType()

Return type of element.

Returns:

DSMType

class DSMTypeXArray()

A class used to represent the type xarray<element_type>.

Note: Not directly instantiable.

exported from index.d

Extends:
  • DSMType

DSMTypeXArray.elementType()

Return type of element.

Returns:

DSMType

class Definitions()
A class used to register concept, club, enumeration, structure and

attachment.

exported from index.d

Definitions.const()

Return the DefinitionsConst interface.

Returns:

DefinitionsConst

Definitions.createAttachment(namespace, name, keyType, documentType, documentation)

Create an attachment.

Arguments:
  • namespace (NameSpace)

  • name (string)

  • keyType (AbstractionType)

  • documentType (Type)

  • documentation (string)

Returns:

Attachment

Definitions.createClub(namespace, name, documentation)

Create and return a club.

Arguments:
  • namespace (NameSpace)

  • name (string)

  • documentation (string)

Returns:

TypeClub

Definitions.createConcept(namespace, name, documentation, parent)

Create and return a concept.

Arguments:
  • namespace (NameSpace)

  • name (string)

  • documentation (string)

  • parent (TypeConcept)

Returns:

TypeConcept

Definitions.createEnumeration(namespace, enumerationDescriptor)

Create and return an enum from a descriptor.

Arguments:
  • namespace (NameSpace)

  • enumerationDescriptor (TypeEnumerationDescriptor)

Returns:

TypeEnumeration

Definitions.createMembership(typeClub, typeConcept)

Create a club membership.

Arguments:
  • typeClub (TypeClub)

  • typeConcept (TypeConcept)

Definitions.createStructure(namespace, structureDescriptor)

Create and return a struct from a descriptor.

Arguments:
  • namespace (NameSpace)

  • structureDescriptor (TypeStructureDescriptor)

Returns:

TypeStructure

Definitions.extend(definitions)
Extend the registered types with the types of definitions and return

information about added definitions.

Arguments:
  • definitions (DefinitionsConst)

Returns:

DefinitionsExtendInfo

Definitions.extendConcepts(definitions)

Extend the registered concepts with the concepts of definitions.

Arguments:
  • definitions (DefinitionsConst)

Returns:

ValueUUId[]

static Definitions.decode(blob, streamCodecInstancing)
Return a Definitions by decoding the blob with a StreamTokenBinaryCodec

if not specified.

Arguments:
  • blob (ValueBlob)

  • streamCodecInstancing (StreamCodecInstancing)

Returns:

Definitions

static Definitions.read(streamReading)

Read and return a Definitions.

Arguments:
  • streamReading (StreamReading)

Returns:

Definitions

class DefinitionsCollector()

A class used to collect referenced types.

Note: Not directly instantiable.

exported from index.d

DefinitionsCollector.clubRuntimeIds()

Return the set of uuid for collected clubs.

Returns:

ValueUUId[]

DefinitionsCollector.collectAttachment(attachment)

Collect the types referenced by the attachment.

Arguments:
  • attachment (Attachment)

DefinitionsCollector.collectPrototype(prototype)

Collect the types referenced by the prototype.

Arguments:
  • prototype (FunctionPrototype)

DefinitionsCollector.collectPrototypes(prototypes)

Collect the types referenced by the list of prototypes.

Arguments:
  • prototypes (FunctionPrototype[])

DefinitionsCollector.collectStructureDescriptor(typeStructureDescriptor)

Collect the types referenced by the structure descriptor.

Arguments:
  • typeStructureDescriptor (TypeStructureDescriptor)

DefinitionsCollector.collectType(type)

Collect the types referenced by the type.

Arguments:
  • type (Type)

DefinitionsCollector.conceptRuntimeIds()

Return the set of uuid for collected concepts.

Returns:

ValueUUId[]

DefinitionsCollector.enumerationRuntimeIds()

Return the set of uuid for collected enumerations.

Returns:

ValueUUId[]

DefinitionsCollector.hasAny()

Return true if the type any was collected.

Returns:

boolean

DefinitionsCollector.hasAnyConcept()

Return true if the type any_concept was collected.

Returns:

boolean

DefinitionsCollector.structureRuntimeIds()

Return the set of uuid for collected structures.

Returns:

ValueUUId[]

class DefinitionsConst()
A class used to retrieve registered concepts, clubs, enumerations, structures

and attachments.

Note: Not directly instantiable.

exported from index.d

DefinitionsConst.attachmentRuntimeIds()

Return the set of runtime ID for all attachments.

Returns:

ValueUUId[]

DefinitionsConst.attachments()

Return the list of attachments.

Returns:

Attachment[]

DefinitionsConst.checkAttachment(attachmentRuntimeId)

Return the attachment or throw.

Arguments:
  • attachmentRuntimeId (ValueUUId)

Returns:

Attachment

DefinitionsConst.checkClub(runtimeId)

Return the club or throw.

Arguments:
  • runtimeId (ValueUUId)

Returns:

TypeClub

DefinitionsConst.checkConcept(runtimeId)

Return the concept or throw.

Arguments:
  • runtimeId (ValueUUId)

Returns:

TypeConcept

DefinitionsConst.checkEnumeration(runtimeId)

Return the enum or throw.

Arguments:
  • runtimeId (ValueUUId)

Returns:

TypeEnumeration

DefinitionsConst.checkStructure(runtimeId)

Return a struct or throw.

Arguments:
  • runtimeId (ValueUUId)

Returns:

TypeStructure

DefinitionsConst.checkType(runtimeId)

Return the type or throw.

Arguments:
  • runtimeId (ValueUUId)

Returns:

Type

DefinitionsConst.clubRuntimeIds()

Return the set of runtime ID for all clubs.

Returns:

ValueUUId[]

DefinitionsConst.clubs()

Return the list of clubs.

Returns:

TypeClub[]

DefinitionsConst.collector()

Return a collector.

Returns:

DefinitionsCollector

DefinitionsConst.conceptMembers(typeConcept)

Return the list of related concepts.

Arguments:
  • typeConcept (TypeConcept)

Returns:

TypeConcept[]

DefinitionsConst.conceptRuntimeIds()

Return the set of runtime ID for all concepts.

Returns:

ValueUUId[]

DefinitionsConst.concepts()

Return the list of concepts.

Returns:

TypeConcept[]

DefinitionsConst.contains(definitions)

return true if the types and attachments of the definitions are known.

Arguments:
  • definitions (DefinitionsConst)

Returns:

boolean

DefinitionsConst.copy()

Return a copy immutable of the definitions.

Returns:

Definitions

DefinitionsConst.discard(namespace)
Remove injected constants from a target object.

If the target is null or omitted, globalThis is used.

Arguments:
  • namespace (Record<string, unknown>)

DefinitionsConst.encode(streamCodecInstancing)
Return the blob that encodes the definitions with a

StreamTokenBinaryCodec if not specified.

Arguments:
  • streamCodecInstancing (StreamCodecInstancing)

Returns:

ValueBlob

DefinitionsConst.enumerationRuntimeIds()

Return the set of runtime ID for all enums.

Returns:

ValueUUId[]

DefinitionsConst.enumerations()

Return the list of enums.

Returns:

TypeEnumeration[]

DefinitionsConst.extract(definitionsCollector)

Create and return a new Definitions from the collected types.

Arguments:
  • definitionsCollector (DefinitionsCollector)

Returns:

Definitions

DefinitionsConst.hexdigest()

Return the hexdigest.

Returns:

string

DefinitionsConst.inject(namespace)
Fill a target object with constants for all definitions.

If the target is null or omitted, globalThis is used. <namespace>_T_<name> for a concept or a club. <namespace>_K_<name> for a key of a concept or a club. <namespace>_S_<name> for a structure. <namespace>_E_<name> for a enumeration. <namespace>_P_<name>_… is the path for a property of the structure. <namespace>_A_<key.name>_<name> for an attachment.

Arguments:
  • namespace (Record<string, unknown>)

DefinitionsConst.isEqual(definitions)

Return true if self and definitions are equals.

Arguments:
  • definitions (DefinitionsConst)

Returns:

boolean

DefinitionsConst.queryAttachment(attachmentRuntimeId)

Return the attachment or null.

Arguments:
  • attachmentRuntimeId (ValueUUId)

Returns:

Attachment | undefined

DefinitionsConst.queryClub(runtimeId)

Return the club or null.

Arguments:
  • runtimeId (ValueUUId)

Returns:

TypeClub | undefined

DefinitionsConst.queryConcept(runtimeId)

Return the concept or null.

Arguments:
  • runtimeId (ValueUUId)

Returns:

TypeConcept | undefined

DefinitionsConst.queryEnumeration(runtimeId)

Return the enum or null.

Arguments:
  • runtimeId (ValueUUId)

Returns:

TypeEnumeration | undefined

DefinitionsConst.queryStructure(runtimeId)

Return a struct or null.

Arguments:
  • runtimeId (ValueUUId)

Returns:

TypeStructure | undefined

DefinitionsConst.queryType(runtimeId)

Return the type or null.

Arguments:
  • runtimeId (ValueUUId)

Returns:

Type | undefined

DefinitionsConst.queryTypes(name)

Return the list of types.

Arguments:
  • name (string)

Returns:

Type[]

DefinitionsConst.runtimeIds()

Return the set of runtime ID for all registered types.

Returns:

ValueUUId[]

DefinitionsConst.structureRuntimeIds()

Return the set of runtime ID for all structs.

Returns:

ValueUUId[]

DefinitionsConst.structures()

Return the list of structs.

Returns:

TypeStructure[]

DefinitionsConst.toDsmDefinitions()

Convert and return a DSMDefinition.

Returns:

DSMDefinitions

DefinitionsConst.types()

Return the topologically sorted list of types.

Returns:

Type[]

DefinitionsConst.write(streamWriting)

Write to a stream.

Arguments:
  • streamWriting (StreamWriting)

class DefinitionsExtendInfo()
A class used to represent the types exchanged during the synchronization of two

databases.

Note: Not directly instantiable.

exported from index.d

DefinitionsExtendInfo.attachmentRuntimeIds()

Return the set of runtime ID for all added attachments.

Returns:

ValueUUId[]

DefinitionsExtendInfo.clubRuntimeIds()

Return the set of runtime ID for all added clubs.

Returns:

ValueUUId[]

DefinitionsExtendInfo.conceptRuntimeIds()

Return the set of runtime ID for all added concepts.

Returns:

ValueUUId[]

DefinitionsExtendInfo.count()

Return the count of added definitions.

Returns:

number

DefinitionsExtendInfo.enumerationRuntimeIds()

Return the set of runtime ID for all added enumerations.

Returns:

ValueUUId[]

DefinitionsExtendInfo.memberships()

Return a dict[uuid, set[uuid]] for all memberships.

Returns:

[ValueUUId, ValueUUId][]

DefinitionsExtendInfo.structureRuntimeIds()

Return the set of runtime ID for all structures.

Returns:

ValueUUId[]

class DefinitionsInspector(definitions)
DefinitionsInspector(definitions).

A class used to retrieve registered concepts, clubs, enumerations, structures and attachments from TypeName.

exported from index.d

Arguments:
  • definitions (DefinitionsConst)

DefinitionsInspector.attachmentIdentifiers()

Return the set of identifiers for all attachments.

Returns:

string[]

DefinitionsInspector.checkAttachment(identifier)

Return the attachment or throw.

Arguments:
  • identifier (string)

Returns:

Attachment

DefinitionsInspector.checkClub(typeName)

Return the club or throw.

Arguments:
  • typeName (TypeName)

Returns:

TypeClub

DefinitionsInspector.checkConcept(typeName)

Return the concept or throw.

Arguments:
  • typeName (TypeName)

Returns:

TypeConcept

DefinitionsInspector.checkEnumeration(typeName)

Return the enum or throw.

Arguments:
  • typeName (TypeName)

Returns:

TypeEnumeration

DefinitionsInspector.checkStructure(typeName)

Return a struct or throw.

Arguments:
  • typeName (TypeName)

Returns:

TypeStructure

DefinitionsInspector.clubTypeNames()

Return the set of TypeName for all clubs.

Returns:

TypeName[]

DefinitionsInspector.conceptTypeNames()

Return the set of TypeName for all concepts.

Returns:

TypeName[]

DefinitionsInspector.enumerationTypeNames()

Return the set of TypeName for all enums.

Returns:

TypeName[]

DefinitionsInspector.nameSpaces()

Return the set of NameSpace for all TypNames.

Returns:

NameSpace[]

DefinitionsInspector.queryAttachment(identifier)

Return the attachment or null.

Arguments:
  • identifier (string)

Returns:

Attachment | undefined

DefinitionsInspector.queryClub(typeName)

Return the club or null.

Arguments:
  • typeName (TypeName)

Returns:

TypeClub | undefined

DefinitionsInspector.queryConcept(typeName)

Return the concept or null.

Arguments:
  • typeName (TypeName)

Returns:

TypeConcept | undefined

DefinitionsInspector.queryEnumeration(typeName)

Return the enum or null.

Arguments:
  • typeName (TypeName)

Returns:

TypeEnumeration | undefined

DefinitionsInspector.queryStructure(typeName)

Return a struct or null.

Arguments:
  • typeName (TypeName)

Returns:

TypeStructure | undefined

DefinitionsInspector.representation(typeName)

Return the shortest representation of the TypeName.

Arguments:
  • typeName (TypeName)

Returns:

string

DefinitionsInspector.structureTypeNames()

Return the set of TypeName for all structs.

Returns:

TypeName[]

class DefinitionsMapper(srcDefinitions, dstDefinitions)

A class use for INTERNAL DEVELOPMENT.

exported from index.d

Arguments:
  • srcDefinitions (DefinitionsConst)

  • dstDefinitions (DefinitionsConst)

DefinitionsMapper.attachment(attachment)

Return the mapped attachment.

Arguments:
  • attachment (Attachment)

Returns:

Attachment

DefinitionsMapper.source()

Return the source.

Returns:

DefinitionsConst

DefinitionsMapper.target()

Return the target.

Returns:

DefinitionsConst

DefinitionsMapper.type(type)

Return the mapped type.

Arguments:
  • type (Type)

Returns:

Type

DefinitionsMapper.value(value)

Return the mapped value.

Arguments:
  • value (Value)

Returns:

Value