Agreement preconditions applicable to the domain.
Data invariant constraints applicable to the domain.
A transport security interceptor. If the initial transport security is not compatible with the rest of the domain, this clone may not be able to join until the app is updated.
Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.9.2-edge.2 Source code licensed MIT. Privacy policy
Extensions applied to a m-ld clone.
Extensions can then be installed in two ways:
app
parameter of the clone function.The first option is suitable when the data is always going to be used by the same app – because the app will always know it has to include the extension.
The second option is more suitable if the data may be shared to other apps, because the need for the extension is declared in the data itself, and apps can load it dynamically as required.
To write an extension to be declared in the domain data, implement MeldExtensions with one or more of its methods, in a Javascript class. Then, to declare the extension in the domain, you write:
{ "@id": "http://m-ld.org/extensions", "@list": { "≪priority≫": { "@id": "≪your-extension-iri≫", "@type": "http://js.m-ld.org/#CommonJSExport", "http://js.m-ld.org/#require": "≪your-extension-module≫", "http://js.m-ld.org/#class": "≪your-extension-class-name≫" } } }
Breaking this down:
"http://m-ld.org/extensions"
is the identity of the extensions list. This is a constant that m-ld knows about (it's in them-ld.org
domain).@list
keyword, because extensions are ordered by priority.≪priority≫
(a number) will determine where in the list your extension appears. The highest priority is"0"
. The value is decided by you, based on what you know about your extensions. In most cases it won't matter, since extensions shouldn't interfere with each other."@type"
identifies this extension as a Javascript module loaded in CommonJS style. (We'll support ES6 modules in future.)"http://js.m-ld.org/#require"
and"http://js.m-ld.org/#class"
properties tell the module loader how to instantiate your module class. It will call a globalrequire
function with the first, dereference the second and callnew
on it.Most extensions will provide a static convenience function to generate this JSON, which can be called in the genesis clone (example).