data type
operation type; must be JSON-serialisable
reversion metadata type; must be JSON-serialisable
The identity of the datatype itself. Used in the internal representation, which is visible to query filters; but a canonical json-rql Value is substituted in retrieval and updates.
Applies an operation to some state. The implementation is welcome to mutate
the passed state
and return it as the new state.
the existing state of the shared value
the operation being applied, created using update on another clone
the new state (can be the input), an update expression to notify the app, and local metadata required to revert the operation (if applicable).
Cuts the prefix from the given operation and returns an operation which can be safely applied to a state that has the prefix already applied, e.g.
Deserialises data. If this method is not provided, the data must be directly deserialisable from JSON.
Fuses operations into a single operation. Operations are be provided in
contiguous causal order: op1
happened-before op2
OR op1
is concurrent
with op2
; AND there exists no op'
where op'
happened-before op2
and
op1
happened-before op'
.
Fuses operations into a single operation, with reversion metadata. Note that if a fusion request has reversion information in the input it should be provided in the return.
A shared data type MUST always generate a new unique identity as its lexical value, for which mutable state will exist. This will only be called once per logical instance.
Reverts an operation from the state. The implementation is welcome to
mutate the passed state
and return it as the new (old) state.
the existing state of the shared value
the operation being reverted, created using update on another clone
the additional local metadata provided by update,
or null
if no reversion metadata was provided.
the new state (can be the input), and an update expression to notify the app.
Returns the (approximate) size of the data in-memory (NOT as stringified).
Convert data to a representation that can be stringified to JSON. If this method is not provided, the data itself must be JSON serialisable. The implementation should include a version if the format is likely to change.
Provides a value to appear when the data is retrieved. The datatype should
always accept the returned value forms in its validate
method. If the
value's type should be anything other than this datatype's @id
, a
ValueObject
should be returned including the desired @type
, even if
it's a built-in type like xs:string. The value object will be compacted as
normal in the application API.
If the returned value is an expanded ValueObject
, its datatype MUST be a
fully expanded IRI.
If this method is not provided, the data itself MUST be a valid API value.
Intercepts update of data. The implementation may mutate the passed data
;
the backend may later revert the returned operation in case of rollback.
the existing state of the shared value
the json-rql expression used to perform the update
the new state of the data, an operation which can be
applied, and any additional local metadata required to revert
the operation (if applicable). If the revert is not supplied, it is assumed
to be null
.
Parses a value provided by the app. This may give the application some
leeway in type strictness; but note that the value provided back to the app
will always be that returned by {@link Datatype#toValue}, if
provided, or the Data
itself if not.
If the provided value is an expanded ValueObject
, its datatype will be a
fully pre-expanded IRI.
the valid data, or undefined if the data is not valid
Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.9.2 Source code licensed MIT. Privacy policy