@fabricorg/archetypes
v2.1.2
Published
Optional cross-industry archetype vocabulary and conformance tools for Fabric module manifests.
Readme
@fabricorg/archetypes
Optional, versioned cross-industry archetypes for Fabric module manifests: Party, Offering, Agreement, Resource, Activity, and Settlement.
The package owns typed namespaced annotations and conformance. @fabricorg/platform remains unaware
of archetype names.
import { archetypeSemantics, assertArchetypeConformance } from "@fabricorg/archetypes";
import { createModuleRegistry } from "@fabricorg/platform";
const objectType = {
type: "ServiceVisit",
semantics: archetypeSemantics({
id: "fabric.Activity",
version: "0.1",
stateMap: { planned: "planned", working: "executing", done: "completed" },
}),
};
assertArchetypeConformance(module);
const registry = createModuleRegistry([module]);Use validateArchetypeConformance for report-only build tooling. Use
assertArchetypeConformance explicitly before Platform registration when startup enforcement is
required. Base Platform registration never interprets archetype annotations.
Your own archetypes
The six shipped archetypes are a reference vocabulary, not the whole set. A vertical defines its own
with defineArchetype and certifies against it with createArchetypeConformance, which includes the
reference set by default so one assembly certifies both:
const conformance = createArchetypeConformance([defineArchetype({ id: "outdoor.Relationship", /* ... */ })]);
conformance.assert(module);Ids are <namespace>.<PascalName>. A definition is validated structurally before it can certify
anything, and an id that collides with a reference archetype under a different meaning is refused.
