@compilacion/colleciones-domain-model
v0.0.81
Published
Runtime domain-model contract (RuntimeContract + JSON Schemas) and re-exported event API for compilacion colleciones consumers.
Readme
@compilacion/colleciones-domain-model
Runtime contract for compilacion colleciones consumers. Generated and published
from the compilacion-colleciones-domain-model
repo — do not edit by hand.
Bundles, per model:
- the RuntimeContract — entities, contexts and point-in-time attributes — via
loadModel(name); - the generated JSON Schemas — one per
entity.action(event) and one per entity (state) — vialoadSchemas(name), ready to AJV-compile;
and re-exports @compilacion/colleciones-clientos at the exact version this model is built
against, so a consumer pins one package and the event-API version cannot drift from the model.
const { loadModel, loadSchemas, CollecionesEvent } = require('@compilacion/colleciones-domain-model');
const web = loadModel('web'); // RuntimeContract JSON (incl. entities.session.attributes)
const { events, state } = loadSchemas('web'); // events['session.start'], state['session']Typical consumer boot:
const Ajv = require('ajv');
const { loadSchemas } = require('@compilacion/colleciones-domain-model');
const ajv = new Ajv({ strict: false });
const { events } = loadSchemas('immoscoop');
const validators = Object.fromEntries(
Object.entries(events).map(([key, schema]) => [key, ajv.compile(schema)]),
);
// per request: const ok = validators[`${entity}.${action}`]?.(event);datatype, primitiveDatatype and the deprecated type
Every identifier, attribute and context carries:
datatype— what the value is:slug,key,languageTag,amount, … Each datatypeextendsthe next invocabulary.datatypes, down to a primitive, and that chain carries its constraints (patterns, minimum, unit, …).primitiveDatatype— the primitive that chain ends on:string,integer,number,boolean,timestamp,date,json,listorobject. Enough for anything that only stores or coerces the value.type— deprecated, listed inmeta.deprecations. The spelling from before the vocabulary, derived fromdatatypeso existing consumers keep working. ReadprimitiveDatatypefirst and fall back totypeuntil you have moved; note that a list islistthere wheretypesaysarray, and a timestamptimestampwheretypesaysdatetime.
