@fabricorg/platform 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +48 -2
  2. package/README.md +21 -0
  3. package/dist/actions/index.cjs +11 -11
  4. package/dist/actions/index.d.cts +2 -0
  5. package/dist/actions/index.d.ts +2 -0
  6. package/dist/actions/index.js +1 -1
  7. package/dist/chunk-3JQI3OFC.js +347 -0
  8. package/dist/chunk-3JQI3OFC.js.map +1 -0
  9. package/dist/chunk-3S6UTP4X.js +110 -0
  10. package/dist/chunk-3S6UTP4X.js.map +1 -0
  11. package/dist/{chunk-JSTGOT6P.js → chunk-7WASIL46.js} +58 -3
  12. package/dist/chunk-7WASIL46.js.map +1 -0
  13. package/dist/{chunk-BWNPGRRV.cjs → chunk-HLRIXNVG.cjs} +2 -2
  14. package/dist/chunk-HLRIXNVG.cjs.map +1 -0
  15. package/dist/{chunk-4SMPJPJ6.js → chunk-JM55UQWK.js} +2 -2
  16. package/dist/chunk-JM55UQWK.js.map +1 -0
  17. package/dist/chunk-NFP5DJBT.js +219 -0
  18. package/dist/chunk-NFP5DJBT.js.map +1 -0
  19. package/dist/{chunk-Q3WYIWCN.cjs → chunk-O7IHZ53Y.cjs} +63 -2
  20. package/dist/chunk-O7IHZ53Y.cjs.map +1 -0
  21. package/dist/chunk-ODP3DO6P.cjs +355 -0
  22. package/dist/chunk-ODP3DO6P.cjs.map +1 -0
  23. package/dist/chunk-RYCHDNHZ.cjs +226 -0
  24. package/dist/chunk-RYCHDNHZ.cjs.map +1 -0
  25. package/dist/chunk-XCL2HBMB.cjs +116 -0
  26. package/dist/chunk-XCL2HBMB.cjs.map +1 -0
  27. package/dist/index.cjs +92 -39
  28. package/dist/index.d.cts +4 -3
  29. package/dist/index.d.ts +4 -3
  30. package/dist/index.js +6 -5
  31. package/dist/manifest/index.cjs +40 -0
  32. package/dist/manifest/index.cjs.map +1 -0
  33. package/dist/manifest/index.d.cts +181 -0
  34. package/dist/manifest/index.d.ts +181 -0
  35. package/dist/manifest/index.js +11 -0
  36. package/dist/manifest/index.js.map +1 -0
  37. package/dist/modules/index.cjs +11 -10
  38. package/dist/modules/index.d.cts +49 -1
  39. package/dist/modules/index.d.ts +49 -1
  40. package/dist/modules/index.js +4 -3
  41. package/dist/objects/index.cjs +9 -5
  42. package/dist/objects/index.d.cts +45 -1
  43. package/dist/objects/index.d.ts +45 -1
  44. package/dist/objects/index.js +1 -1
  45. package/dist/projections/index.cjs +26 -2
  46. package/dist/projections/index.d.cts +38 -2
  47. package/dist/projections/index.d.ts +38 -2
  48. package/dist/projections/index.js +1 -1
  49. package/package.json +11 -1
  50. package/dist/chunk-35DD3H55.js +0 -187
  51. package/dist/chunk-35DD3H55.js.map +0 -1
  52. package/dist/chunk-4SMPJPJ6.js.map +0 -1
  53. package/dist/chunk-BWNPGRRV.cjs.map +0 -1
  54. package/dist/chunk-I35B576X.js +0 -30
  55. package/dist/chunk-I35B576X.js.map +0 -1
  56. package/dist/chunk-JSTGOT6P.js.map +0 -1
  57. package/dist/chunk-Q3WYIWCN.cjs.map +0 -1
  58. package/dist/chunk-QETQGAXJ.cjs +0 -35
  59. package/dist/chunk-QETQGAXJ.cjs.map +0 -1
  60. package/dist/chunk-SSYKDXR4.cjs +0 -195
  61. package/dist/chunk-SSYKDXR4.cjs.map +0 -1
@@ -1,6 +1,61 @@
1
1
  'use strict';
2
2
 
3
3
  // projections/index.ts
4
+ var viewRegistry = /* @__PURE__ */ new Map();
5
+ function viewContractKey(view) {
6
+ return `${view.name}@${view.version}`;
7
+ }
8
+ function registerViewContract(view) {
9
+ const key = viewContractKey(view);
10
+ if (viewRegistry.has(key)) throw new Error(`View contract "${key}" is already registered.`);
11
+ viewRegistry.set(key, view);
12
+ }
13
+ function registerViewContractIfMissing(view) {
14
+ if (!viewRegistry.has(viewContractKey(view))) registerViewContract(view);
15
+ }
16
+ function resolveViewContract(name, version) {
17
+ return viewRegistry.get(`${name}@${version}`);
18
+ }
19
+ function getRegisteredViewContractKeys() {
20
+ return Array.from(viewRegistry.keys());
21
+ }
22
+ async function replayView({
23
+ view,
24
+ events,
25
+ scope,
26
+ snapshot
27
+ }) {
28
+ if (snapshot && snapshot.snapshotVersion !== view.snapshotVersion && !view.compatibleSnapshotVersions?.includes(snapshot.snapshotVersion)) {
29
+ throw new Error(
30
+ `View "${viewContractKey(view)}" cannot resume snapshot version ${snapshot.snapshotVersion}.`
31
+ );
32
+ }
33
+ if (snapshot && snapshot.snapshotVersion !== view.snapshotVersion && !view.upgradeSnapshot) {
34
+ throw new Error(
35
+ `View "${viewContractKey(view)}" must provide upgradeSnapshot for snapshot version ${snapshot.snapshotVersion}.`
36
+ );
37
+ }
38
+ const upgradedSnapshot = snapshot && snapshot.snapshotVersion !== view.snapshotVersion ? { ...snapshot, snapshotVersion: view.snapshotVersion, snapshotData: await view.upgradeSnapshot(snapshot.snapshotData, snapshot.snapshotVersion) } : snapshot;
39
+ const accepted = new Map(
40
+ view.consumes.map((consumption) => [consumption.eventType, new Set(consumption.schemaVersions)])
41
+ );
42
+ const versionWarnings = [];
43
+ const filtered = async function* () {
44
+ for await (const event of events) {
45
+ const versions = accepted.get(event.eventType);
46
+ if (versions?.has(event.eventSchemaVersion ?? 1)) yield event;
47
+ else if (versions) versionWarnings.push({ code: "unsupported_event_version", eventId: event.id, message: `View "${viewContractKey(view)}" does not consume ${event.eventType} schema version ${event.eventSchemaVersion ?? 1}.` });
48
+ }
49
+ };
50
+ const result = await replayEvents({
51
+ events: filtered(),
52
+ scope,
53
+ initialState: view.initialState,
54
+ snapshot: upgradedSnapshot,
55
+ applyEvent: view.applyEvent
56
+ });
57
+ return { ...result, warnings: [...versionWarnings, ...result.warnings] };
58
+ }
4
59
  async function replayEvents({
5
60
  events,
6
61
  scope,
@@ -178,6 +233,12 @@ function toTimestamp(value) {
178
233
  return value instanceof Date ? value.getTime() : new Date(value).getTime();
179
234
  }
180
235
 
236
+ exports.getRegisteredViewContractKeys = getRegisteredViewContractKeys;
237
+ exports.registerViewContract = registerViewContract;
238
+ exports.registerViewContractIfMissing = registerViewContractIfMissing;
181
239
  exports.replayEvents = replayEvents;
182
- //# sourceMappingURL=chunk-Q3WYIWCN.cjs.map
183
- //# sourceMappingURL=chunk-Q3WYIWCN.cjs.map
240
+ exports.replayView = replayView;
241
+ exports.resolveViewContract = resolveViewContract;
242
+ exports.viewContractKey = viewContractKey;
243
+ //# sourceMappingURL=chunk-O7IHZ53Y.cjs.map
244
+ //# sourceMappingURL=chunk-O7IHZ53Y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../projections/index.ts"],"names":[],"mappings":";;;AAsCA,IAAM,YAAA,uBAAmB,GAAA,EAA0B;AAE5C,SAAS,gBAAgB,IAAA,EAAsD;AACrF,EAAA,OAAO,CAAA,EAAG,IAAA,CAAK,IAAI,CAAA,CAAA,EAAI,KAAK,OAAO,CAAA,CAAA;AACpC;AAEO,SAAS,qBAAqB,IAAA,EAA0B;AAC9D,EAAA,MAAM,GAAA,GAAM,gBAAgB,IAAI,CAAA;AAChC,EAAA,IAAI,YAAA,CAAa,IAAI,GAAG,CAAA,QAAS,IAAI,KAAA,CAAM,CAAA,eAAA,EAAkB,GAAG,CAAA,wBAAA,CAA0B,CAAA;AAC1F,EAAA,YAAA,CAAa,GAAA,CAAI,KAAK,IAAI,CAAA;AAC3B;AAEO,SAAS,8BAA8B,IAAA,EAA0B;AACvE,EAAA,IAAI,CAAC,aAAa,GAAA,CAAI,eAAA,CAAgB,IAAI,CAAC,CAAA,uBAAwB,IAAI,CAAA;AACxE;AAEO,SAAS,mBAAA,CAAoB,MAAc,OAAA,EAA2C;AAC5F,EAAA,OAAO,aAAa,GAAA,CAAI,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,OAAO,CAAA,CAAE,CAAA;AAC7C;AAEO,SAAS,6BAAA,GAA0C;AACzD,EAAA,OAAO,KAAA,CAAM,IAAA,CAA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"chunk-O7IHZ53Y.cjs","sourcesContent":["export interface ReplayableAssetEvent<Payload = unknown> {\n\tid: string;\n\ttenantId: string;\n\tspaceId: string;\n\teventType: string;\n\teventSchemaVersion?: number;\n\tsubjectType: string;\n\tsubjectId: string;\n\tpayload: Payload;\n\tsequence: number;\n\toccurredAt: Date | string;\n\trecordedAt: Date | string;\n\tactionInvocationId: string;\n\tcorrelationId: string;\n}\n\nimport type { PortableJsonSchema } from \"../objects\";\n\nexport interface ViewEventConsumption {\n\teventType: string;\n\tschemaVersions: number[];\n}\n\nexport interface ViewContract<State = unknown, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {\n\t/** Stable module-qualified logical identity, for example `orders/summary`. */\n\tname: `${string}/${string}`;\n\tversion: string;\n\tshape: PortableJsonSchema;\n\tconsumes: ViewEventConsumption[];\n\tscope: \"tenant-space\";\n\tsnapshotVersion: number;\n\tcompatibleSnapshotVersions?: number[];\n\t/** Required to transform any older compatible snapshot into the current state shape. */\n\tupgradeSnapshot?: (data: unknown, fromVersion: number) => State | Promise<State>;\n\tinitialState: State;\n\tapplyEvent: (state: State, event: Event) => State | Promise<State>;\n}\n\nconst viewRegistry = new Map<string, ViewContract>();\n\nexport function viewContractKey(view: Pick<ViewContract, \"name\" | \"version\">): string {\n\treturn `${view.name}@${view.version}`;\n}\n\nexport function registerViewContract(view: ViewContract): void {\n\tconst key = viewContractKey(view);\n\tif (viewRegistry.has(key)) throw new Error(`View contract \"${key}\" is already registered.`);\n\tviewRegistry.set(key, view);\n}\n\nexport function registerViewContractIfMissing(view: ViewContract): void {\n\tif (!viewRegistry.has(viewContractKey(view))) registerViewContract(view);\n}\n\nexport function resolveViewContract(name: string, version: string): ViewContract | undefined {\n\treturn viewRegistry.get(`${name}@${version}`);\n}\n\nexport function getRegisteredViewContractKeys(): string[] {\n\treturn Array.from(viewRegistry.keys());\n}\n\nexport interface ReplayViewOptions<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {\n\tview: ViewContract<State, Event>;\n\tevents: Iterable<Event> | AsyncIterable<Event>;\n\tscope: ReplayScope;\n\tsnapshot?: (ReplaySnapshot<State> & { snapshotVersion: number }) | null;\n}\n\nexport async function replayView<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({\n\tview,\n\tevents,\n\tscope,\n\tsnapshot,\n}: ReplayViewOptions<State, Event>): Promise<ReplayEventsResult<State, Event>> {\n\tif (\n\t\tsnapshot &&\n\t\tsnapshot.snapshotVersion !== view.snapshotVersion &&\n\t\t!view.compatibleSnapshotVersions?.includes(snapshot.snapshotVersion)\n\t) {\n\t\tthrow new Error(\n\t\t\t`View \"${viewContractKey(view)}\" cannot resume snapshot version ${snapshot.snapshotVersion}.`,\n\t\t);\n\t}\n\tif (snapshot && snapshot.snapshotVersion !== view.snapshotVersion && !view.upgradeSnapshot) {\n\t\tthrow new Error(\n\t\t\t`View \"${viewContractKey(view)}\" must provide upgradeSnapshot for snapshot version ${snapshot.snapshotVersion}.`,\n\t\t);\n\t}\n\tconst upgradedSnapshot = snapshot && snapshot.snapshotVersion !== view.snapshotVersion\n\t\t? { ...snapshot, snapshotVersion: view.snapshotVersion, snapshotData: await view.upgradeSnapshot!(snapshot.snapshotData, snapshot.snapshotVersion) }\n\t\t: snapshot;\n\tconst accepted = new Map(\n\t\tview.consumes.map((consumption) => [consumption.eventType, new Set(consumption.schemaVersions)]),\n\t);\n\tconst versionWarnings: ReplayWarning[] = [];\n\tconst filtered = async function* (): AsyncIterable<Event> {\n\t\tfor await (const event of events) {\n\t\t\tconst versions = accepted.get(event.eventType);\n\t\t\tif (versions?.has(event.eventSchemaVersion ?? 1)) yield event;\n\t\t\telse if (versions) versionWarnings.push({ code: \"unsupported_event_version\", eventId: event.id, message: `View \"${viewContractKey(view)}\" does not consume ${event.eventType} schema version ${event.eventSchemaVersion ?? 1}.` });\n\t\t}\n\t};\n\tconst result = await replayEvents({\n\t\tevents: filtered(),\n\t\tscope,\n\t\tinitialState: view.initialState,\n\t\tsnapshot: upgradedSnapshot,\n\t\tapplyEvent: view.applyEvent,\n\t});\n\treturn { ...result, warnings: [...versionWarnings, ...result.warnings] };\n}\n\nexport interface ReplayScope {\n\ttenantId: string;\n\tspaceId: string;\n\tsubjectType?: string;\n\tsubjectId?: string;\n}\n\nexport interface ReplaySnapshot<State = unknown> {\n\tsnapshotData: State;\n\teventCursor?: string | null;\n\teventSequence?: number | null;\n}\n\nexport type ReplayWarningCode =\n\t| \"cursor_not_found\"\n\t| \"duplicate_event\"\n\t| \"missing_sequence\"\n\t| \"subject_scope_incomplete\"\n\t| \"unsupported_event_version\";\n\nexport interface ReplayWarning {\n\tcode: ReplayWarningCode;\n\tmessage: string;\n\teventId?: string;\n\tsubjectType?: string;\n\tsubjectId?: string;\n\texpectedSequence?: number;\n\tactualSequence?: number;\n}\n\nexport interface ReplayEventsOptions<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {\n\tevents: Iterable<Event> | AsyncIterable<Event>;\n\tscope: ReplayScope;\n\tinitialState: State;\n\tsnapshot?: ReplaySnapshot<State> | null;\n\tapplyEvent: (state: State, event: Event) => State | Promise<State>;\n}\n\nexport interface ReplayEventsResult<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {\n\tstate: State;\n\tappliedEvents: Event[];\n\twarnings: ReplayWarning[];\n\teventCursor: string | null;\n\teventSequence: number;\n}\n\nexport async function replayEvents<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({\n\tevents,\n\tscope,\n\tinitialState,\n\tsnapshot,\n\tapplyEvent,\n}: ReplayEventsOptions<State, Event>): Promise<ReplayEventsResult<State, Event>> {\n\tconst warnings: ReplayWarning[] = [];\n\tconst scopedEvents = filterEventsByScope(await collectEvents(events), scope, warnings);\n\tconst orderedEvents = sortEvents(scopedEvents, isSubjectScoped(scope));\n\tconst uniqueEvents = removeDuplicateEvents(orderedEvents, warnings);\n\tconst resumableEvents = applyCursor(uniqueEvents, snapshot, isSubjectScoped(scope), warnings);\n\n\tlet state = snapshot?.snapshotData ?? initialState;\n\tconst appliedEvents: Event[] = [];\n\tlet eventCursor = snapshot?.eventCursor ?? null;\n\tlet eventSequence = snapshot?.eventSequence ?? 0;\n\n\tfor (const event of resumableEvents) {\n\t\tstate = await applyEvent(state, event);\n\t\tappliedEvents.push(event);\n\t\teventCursor = event.id;\n\t\teventSequence = event.sequence;\n\t}\n\n\treturn {\n\t\tstate,\n\t\tappliedEvents,\n\t\twarnings,\n\t\teventCursor,\n\t\teventSequence,\n\t};\n}\n\nasync function collectEvents<Event extends ReplayableAssetEvent>(\n\tevents: Iterable<Event> | AsyncIterable<Event>,\n): Promise<Event[]> {\n\tconst collected: Event[] = [];\n\n\tif (Symbol.asyncIterator in events) {\n\t\tfor await (const event of events) {\n\t\t\tcollected.push(event);\n\t\t}\n\n\t\treturn collected;\n\t}\n\n\tfor (const event of events) {\n\t\tcollected.push(event);\n\t}\n\n\treturn collected;\n}\n\nfunction filterEventsByScope<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\tscope: ReplayScope,\n\twarnings: ReplayWarning[],\n): Event[] {\n\tif ((scope.subjectType && !scope.subjectId) || (!scope.subjectType && scope.subjectId)) {\n\t\twarnings.push({\n\t\t\tcode: \"subject_scope_incomplete\",\n\t\t\tmessage: \"Both subjectType and subjectId are required for subject-scoped replay.\",\n\t\t\tsubjectType: scope.subjectType,\n\t\t\tsubjectId: scope.subjectId,\n\t\t});\n\t}\n\n\treturn events.filter((event) => {\n\t\tif (event.tenantId !== scope.tenantId || event.spaceId !== scope.spaceId) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (scope.subjectType && event.subjectType !== scope.subjectType) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (scope.subjectId && event.subjectId !== scope.subjectId) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t});\n}\n\nfunction removeDuplicateEvents<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\twarnings: ReplayWarning[],\n): Event[] {\n\tconst seenEventIds = new Set<string>();\n\tconst uniqueEvents: Event[] = [];\n\n\tfor (const event of events) {\n\t\tif (seenEventIds.has(event.id)) {\n\t\t\twarnings.push({\n\t\t\t\tcode: \"duplicate_event\",\n\t\t\t\tmessage: `Duplicate event ${event.id} ignored during replay.`,\n\t\t\t\teventId: event.id,\n\t\t\t\tsubjectType: event.subjectType,\n\t\t\t\tsubjectId: event.subjectId,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tseenEventIds.add(event.id);\n\t\tuniqueEvents.push(event);\n\t}\n\n\trecordMissingSequenceWarnings(uniqueEvents, warnings);\n\n\treturn uniqueEvents;\n}\n\nfunction recordMissingSequenceWarnings<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\twarnings: ReplayWarning[],\n): void {\n\tconst lastSequenceBySubject = new Map<string, number>();\n\n\tfor (const event of events) {\n\t\tconst subjectKey = `${event.subjectType}:${event.subjectId}`;\n\t\tconst previousSequence = lastSequenceBySubject.get(subjectKey);\n\t\tconst expectedSequence = previousSequence === undefined ? event.sequence : previousSequence + 1;\n\n\t\tif (previousSequence !== undefined && event.sequence > expectedSequence) {\n\t\t\twarnings.push({\n\t\t\t\tcode: \"missing_sequence\",\n\t\t\t\tmessage: `Missing event sequence for ${subjectKey}: expected ${expectedSequence}, received ${event.sequence}.`,\n\t\t\t\teventId: event.id,\n\t\t\t\tsubjectType: event.subjectType,\n\t\t\t\tsubjectId: event.subjectId,\n\t\t\t\texpectedSequence,\n\t\t\t\tactualSequence: event.sequence,\n\t\t\t});\n\t\t}\n\n\t\tlastSequenceBySubject.set(subjectKey, Math.max(previousSequence ?? event.sequence, event.sequence));\n\t}\n}\n\nfunction applyCursor<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\tsnapshot: ReplaySnapshot | null | undefined,\n\tsubjectScoped: boolean,\n\twarnings: ReplayWarning[],\n): Event[] {\n\tconst eventCursor = snapshot?.eventCursor;\n\n\tif (eventCursor) {\n\t\tconst cursorIndex = events.findIndex((event) => event.id === eventCursor);\n\n\t\tif (cursorIndex >= 0) {\n\t\t\treturn events.slice(cursorIndex + 1);\n\t\t}\n\n\t\twarnings.push({\n\t\t\tcode: \"cursor_not_found\",\n\t\t\tmessage: `Snapshot cursor ${eventCursor} was not found in the scoped event stream.`,\n\t\t\teventId: eventCursor,\n\t\t});\n\t}\n\n\tif (subjectScoped && snapshot?.eventSequence !== undefined && snapshot.eventSequence !== null) {\n\t\treturn events.filter((event) => event.sequence > snapshot.eventSequence!);\n\t}\n\n\treturn events;\n}\n\nfunction sortEvents<Event extends ReplayableAssetEvent>(events: Event[], subjectScoped: boolean): Event[] {\n\treturn [...events].sort((first, second) =>\n\t\tsubjectScoped ? compareSubjectEvents(first, second) : compareGlobalEvents(first, second),\n\t);\n}\n\nfunction compareSubjectEvents(first: ReplayableAssetEvent, second: ReplayableAssetEvent): number {\n\treturn compareValues(\n\t\t[first.sequence, toTimestamp(first.recordedAt), toTimestamp(first.occurredAt), first.id],\n\t\t[second.sequence, toTimestamp(second.recordedAt), toTimestamp(second.occurredAt), second.id],\n\t);\n}\n\nfunction compareGlobalEvents(first: ReplayableAssetEvent, second: ReplayableAssetEvent): number {\n\treturn compareValues(\n\t\t[\n\t\t\ttoTimestamp(first.recordedAt),\n\t\t\ttoTimestamp(first.occurredAt),\n\t\t\tfirst.actionInvocationId,\n\t\t\tfirst.correlationId,\n\t\t\tfirst.subjectType,\n\t\t\tfirst.subjectId,\n\t\t\tfirst.sequence,\n\t\t\tfirst.id,\n\t\t],\n\t\t[\n\t\t\ttoTimestamp(second.recordedAt),\n\t\t\ttoTimestamp(second.occurredAt),\n\t\t\tsecond.actionInvocationId,\n\t\t\tsecond.correlationId,\n\t\t\tsecond.subjectType,\n\t\t\tsecond.subjectId,\n\t\t\tsecond.sequence,\n\t\t\tsecond.id,\n\t\t],\n\t);\n}\n\nfunction compareValues(firstValues: Array<number | string>, secondValues: Array<number | string>): number {\n\tfor (const [index, firstValue] of firstValues.entries()) {\n\t\tconst secondValue = secondValues[index];\n\n\t\tif (firstValue < secondValue) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (firstValue > secondValue) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nfunction isSubjectScoped(scope: ReplayScope): boolean {\n\treturn Boolean(scope.subjectType && scope.subjectId);\n}\n\nfunction toTimestamp(value: Date | string): number {\n\treturn value instanceof Date ? value.getTime() : new Date(value).getTime();\n}\n"]}
@@ -0,0 +1,355 @@
1
+ 'use strict';
2
+
3
+ var chunkXCL2HBMB_cjs = require('./chunk-XCL2HBMB.cjs');
4
+ var chunkNJL3US7H_cjs = require('./chunk-NJL3US7H.cjs');
5
+ var chunkO7IHZ53Y_cjs = require('./chunk-O7IHZ53Y.cjs');
6
+ var chunkUV252FLT_cjs = require('./chunk-UV252FLT.cjs');
7
+ var chunkHLRIXNVG_cjs = require('./chunk-HLRIXNVG.cjs');
8
+ var chunkEO4VSB2O_cjs = require('./chunk-EO4VSB2O.cjs');
9
+ var chunkJAXDEK5Z_cjs = require('./chunk-JAXDEK5Z.cjs');
10
+
11
+ // modules/index.ts
12
+ var registeredModuleNamespaces = /* @__PURE__ */ new Set();
13
+ var registeredQualifiedObjectTypes = /* @__PURE__ */ new Set();
14
+ var registeredObjectDefinitions = /* @__PURE__ */ new Map();
15
+ function getModuleDependencyNamespace(dependency) {
16
+ return typeof dependency === "string" ? dependency : dependency.namespace;
17
+ }
18
+ function getObjectTypeName(objectType) {
19
+ return typeof objectType === "string" ? objectType : objectType.type;
20
+ }
21
+ function getEventTypeName(eventType) {
22
+ return typeof eventType === "string" ? eventType : eventType.eventType;
23
+ }
24
+ function validateModuleNamespace(namespace) {
25
+ if (!namespace) {
26
+ throw new Error("Module namespace cannot be empty");
27
+ }
28
+ if (!/^[a-z][a-z0-9-]*$/.test(namespace)) {
29
+ throw new Error(
30
+ `Invalid module namespace: "${namespace}". Must be lowercase letters, numbers, and hyphens only.`
31
+ );
32
+ }
33
+ }
34
+ function createModuleRegistry(modules = []) {
35
+ const registered = /* @__PURE__ */ new Map();
36
+ for (const module of modules) {
37
+ validateModuleNamespace(module.namespace);
38
+ if (registered.has(module.namespace)) {
39
+ throw new Error(`Duplicate FabricModule namespace "${module.namespace}".`);
40
+ }
41
+ registered.set(module.namespace, module);
42
+ }
43
+ return { modules: registered };
44
+ }
45
+ function validateIdentifierList(values, label, namespace) {
46
+ for (const value of values ?? []) {
47
+ if (!value) {
48
+ throw new Error(`Module "${namespace}" has an empty ${label} entry.`);
49
+ }
50
+ }
51
+ }
52
+ function assertJsonValue(value, path) {
53
+ if (value === null || typeof value === "string" || typeof value === "boolean") return;
54
+ if (typeof value === "number" && Number.isFinite(value)) return;
55
+ if (Array.isArray(value)) {
56
+ value.forEach((item, index) => assertJsonValue(item, `${path}[${index}]`));
57
+ return;
58
+ }
59
+ if (typeof value === "object") {
60
+ for (const [key, child] of Object.entries(value)) {
61
+ assertJsonValue(child, `${path}.${key}`);
62
+ }
63
+ return;
64
+ }
65
+ throw new Error(`${path} must contain JSON-serializable values.`);
66
+ }
67
+ function qualifiedObjectType(namespace, type) {
68
+ return `${namespace}.${type}`;
69
+ }
70
+ function validateObjectDefinition(objectType, namespace, context) {
71
+ if (typeof objectType === "string") return;
72
+ if (objectType.schema !== void 0) {
73
+ chunkXCL2HBMB_cjs.assertPortableJsonSchema(objectType.schema, `Module "${namespace}" object "${objectType.type}" schema`);
74
+ }
75
+ if (objectType.semantics !== void 0) {
76
+ assertJsonValue(objectType.semantics, `Module "${namespace}" object "${objectType.type}" semantics`);
77
+ }
78
+ const relationNames = /* @__PURE__ */ new Set();
79
+ for (const relation of objectType.relations ?? []) {
80
+ if (!/^[a-z][a-zA-Z0-9]*$/.test(relation.name)) {
81
+ throw new Error(`Module "${namespace}" object "${objectType.type}" has invalid relation name "${relation.name}".`);
82
+ }
83
+ if (relationNames.has(relation.name)) {
84
+ throw new Error(`Module "${namespace}" object "${objectType.type}" has duplicate relation "${relation.name}".`);
85
+ }
86
+ relationNames.add(relation.name);
87
+ if (!/^[a-z][a-z0-9-]*\.[A-Z][a-zA-Z0-9]*$/.test(relation.target)) {
88
+ throw new Error(`Relation "${relation.name}" target "${relation.target}" must be module-qualified.`);
89
+ }
90
+ if (context.availableObjectTypes && !context.availableObjectTypes.has(relation.target)) {
91
+ throw new Error(`Relation "${relation.name}" targets missing object type "${relation.target}".`);
92
+ }
93
+ if (relation.required && relation.onTargetDelete === "set-null") {
94
+ throw new Error(`Required relation "${relation.name}" cannot use onTargetDelete "set-null".`);
95
+ }
96
+ }
97
+ const invariantIds = /* @__PURE__ */ new Set();
98
+ for (const invariant of objectType.invariants ?? []) {
99
+ if (!invariant.id.trim() || !invariant.description.trim()) {
100
+ throw new Error(`Module "${namespace}" object "${objectType.type}" has an invariant without an id or description.`);
101
+ }
102
+ if (invariantIds.has(invariant.id)) {
103
+ throw new Error(`Module "${namespace}" object "${objectType.type}" has duplicate invariant "${invariant.id}".`);
104
+ }
105
+ invariantIds.add(invariant.id);
106
+ if (invariant.required && !invariant.enforcementRef?.trim()) {
107
+ throw new Error(`Required invariant "${invariant.id}" must declare enforcementRef.`);
108
+ }
109
+ }
110
+ }
111
+ function validateManifest(module, context = {}) {
112
+ validateModuleNamespace(module.namespace);
113
+ const dependencies = (module.dependencies ?? []).map(getModuleDependencyNamespace);
114
+ const objectTypes = (module.objectTypes ?? []).map(getObjectTypeName);
115
+ const eventTypes = (module.eventTypes ?? []).map(getEventTypeName);
116
+ if (module.capability) {
117
+ if (!module.capability.displayName.trim() || !module.capability.description.trim()) {
118
+ throw new Error(`Module "${module.namespace}" capability requires displayName and description.`);
119
+ }
120
+ if (new Set(module.capability.roles ?? []).size !== (module.capability.roles ?? []).length || (module.capability.roles ?? []).some((role) => !/^[a-z][a-z0-9-]*$/.test(role))) {
121
+ throw new Error(`Module "${module.namespace}" capability has invalid or duplicate roles.`);
122
+ }
123
+ const slots = /* @__PURE__ */ new Set();
124
+ for (const slot of module.capability.slots ?? []) {
125
+ if (!/^[a-z][a-z0-9-]*$/.test(slot.name) || slots.has(slot.name)) {
126
+ throw new Error(`Module "${module.namespace}" capability has invalid or duplicate slot "${slot.name}".`);
127
+ }
128
+ slots.add(slot.name);
129
+ if (slot.shape) chunkXCL2HBMB_cjs.assertPortableJsonSchema(slot.shape, `Capability slot "${slot.name}" shape`);
130
+ }
131
+ }
132
+ for (const dependency of dependencies) {
133
+ validateModuleNamespace(dependency);
134
+ if (dependency === module.namespace) {
135
+ throw new Error(`Module "${module.namespace}" cannot depend on itself.`);
136
+ }
137
+ if (context.availableNamespaces && !context.availableNamespaces.has(dependency)) {
138
+ throw new Error(`Module "${module.namespace}" depends on missing module "${dependency}".`);
139
+ }
140
+ }
141
+ validateIdentifierList(objectTypes, "objectTypes", module.namespace);
142
+ validateIdentifierList(module.subjectTypes, "subjectTypes", module.namespace);
143
+ validateIdentifierList(eventTypes, "eventTypes", module.namespace);
144
+ for (const objectType of objectTypes) {
145
+ if (!/^[A-Z][a-zA-Z0-9]*$/.test(objectType)) {
146
+ throw new Error(
147
+ `Invalid object type: "${objectType}". Object types must be PascalCase alphanumeric.`
148
+ );
149
+ }
150
+ }
151
+ for (const objectType of module.objectTypes ?? []) {
152
+ validateObjectDefinition(objectType, module.namespace, context);
153
+ }
154
+ for (const action of module.actions ?? []) {
155
+ if (!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9_]*$/.test(action.actionId)) {
156
+ throw new Error(`Invalid action ID: ${action.actionId}`);
157
+ }
158
+ if (action.namespace !== module.namespace) {
159
+ throw new Error(
160
+ `Action "${action.actionId}" declares namespace "${action.namespace}" but is registered by module "${module.namespace}".`
161
+ );
162
+ }
163
+ if (!action.actionId.startsWith(`${module.namespace}.`)) {
164
+ throw new Error(
165
+ `Action "${action.actionId}" must start with module namespace "${module.namespace}."`
166
+ );
167
+ }
168
+ if (action.mutatesDomain && action.emitsEvents.length === 0) {
169
+ throw new Error(
170
+ `Action "${action.actionId}" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`
171
+ );
172
+ }
173
+ }
174
+ for (const descriptor of module.displayRenderers ?? []) {
175
+ const isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;
176
+ const isModuleEventType = eventTypes.includes(descriptor.eventType);
177
+ if (!chunkJAXDEK5Z_cjs.isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {
178
+ throw new Error(
179
+ `Display renderer registered for unknown event type "${descriptor.eventType}". Register the event type before adding a display renderer.`
180
+ );
181
+ }
182
+ }
183
+ const viewKeys = /* @__PURE__ */ new Set();
184
+ for (const view of module.views ?? []) {
185
+ if (!view.name.startsWith(`${module.namespace}/`) || !/^[a-z][a-z0-9-]*\/[a-z][a-z0-9/_-]*$/.test(view.name)) {
186
+ throw new Error(`View "${view.name}" must start with module namespace "${module.namespace}/" and use lowercase path segments.`);
187
+ }
188
+ if (!view.version.trim()) throw new Error(`View "${view.name}" must declare a version.`);
189
+ const key = `${view.name}@${view.version}`;
190
+ if (viewKeys.has(key)) throw new Error(`Module "${module.namespace}" has duplicate view contract "${key}".`);
191
+ viewKeys.add(key);
192
+ chunkXCL2HBMB_cjs.assertPortableJsonSchema(view.shape, `View "${key}" shape`);
193
+ if (!Number.isInteger(view.snapshotVersion) || view.snapshotVersion < 1) {
194
+ throw new Error(`View "${key}" snapshotVersion must be a positive integer.`);
195
+ }
196
+ if ((view.compatibleSnapshotVersions?.some((version) => version !== view.snapshotVersion) ?? false) && !view.upgradeSnapshot) {
197
+ throw new Error(`View "${key}" declares older compatible snapshots but no upgradeSnapshot function.`);
198
+ }
199
+ for (const consumption of view.consumes) {
200
+ const isPlanned = context.plannedEventTypes?.has(consumption.eventType) ?? false;
201
+ const isModuleEvent = eventTypes.includes(consumption.eventType);
202
+ if (!chunkJAXDEK5Z_cjs.isValidEventType(consumption.eventType) && !isPlanned && !isModuleEvent) {
203
+ throw new Error(`View "${key}" consumes unknown event type "${consumption.eventType}".`);
204
+ }
205
+ if (consumption.schemaVersions.length === 0 || consumption.schemaVersions.some((version) => !Number.isInteger(version) || version < 1)) {
206
+ throw new Error(`View "${key}" must declare positive consumed schema versions for "${consumption.eventType}".`);
207
+ }
208
+ }
209
+ }
210
+ }
211
+ function sortModulesByDependency(modules, registeredNamespaces = registeredModuleNamespaces) {
212
+ const modulesByNamespace = /* @__PURE__ */ new Map();
213
+ for (const module of modules) {
214
+ validateModuleNamespace(module.namespace);
215
+ if (modulesByNamespace.has(module.namespace)) {
216
+ throw new Error(`Duplicate Fabric module namespace "${module.namespace}".`);
217
+ }
218
+ modulesByNamespace.set(module.namespace, module);
219
+ }
220
+ const sorted = [];
221
+ const visiting = /* @__PURE__ */ new Set();
222
+ const visited = /* @__PURE__ */ new Set();
223
+ function visit(module, path) {
224
+ if (visited.has(module.namespace)) {
225
+ return;
226
+ }
227
+ if (visiting.has(module.namespace)) {
228
+ throw new Error(
229
+ `Cyclic Fabric module dependency detected: ${[...path, module.namespace].join(" -> ")}`
230
+ );
231
+ }
232
+ visiting.add(module.namespace);
233
+ for (const dependency of (module.dependencies ?? []).map(getModuleDependencyNamespace)) {
234
+ const dependencyModule = modulesByNamespace.get(dependency);
235
+ if (!dependencyModule) {
236
+ if (registeredNamespaces.has(dependency)) {
237
+ continue;
238
+ }
239
+ throw new Error(`Module "${module.namespace}" depends on missing module "${dependency}".`);
240
+ }
241
+ visit(dependencyModule, [...path, module.namespace]);
242
+ }
243
+ visiting.delete(module.namespace);
244
+ visited.add(module.namespace);
245
+ sorted.push(module);
246
+ }
247
+ for (const module of modules) {
248
+ visit(module, []);
249
+ }
250
+ return sorted;
251
+ }
252
+ function assertAcyclicRelations(modules) {
253
+ const relationKinds = [
254
+ { label: "owned containment", include: (relation) => relation.semantics === "owned" },
255
+ { label: "cascade-delete", include: (relation) => relation.onTargetDelete === "cascade" },
256
+ { label: "required-construction", include: (relation) => relation.required === true }
257
+ ];
258
+ for (const kind of relationKinds) {
259
+ const edges = /* @__PURE__ */ new Map();
260
+ for (const [source, objectType] of registeredObjectDefinitions) {
261
+ edges.set(source, (objectType.relations ?? []).filter(kind.include).map((relation) => relation.target));
262
+ }
263
+ for (const module of modules) {
264
+ for (const objectType of module.objectTypes ?? []) {
265
+ if (typeof objectType === "string") continue;
266
+ const source = qualifiedObjectType(module.namespace, objectType.type);
267
+ edges.set(source, (objectType.relations ?? []).filter(kind.include).map((relation) => relation.target));
268
+ }
269
+ }
270
+ const visiting = /* @__PURE__ */ new Set();
271
+ const visited = /* @__PURE__ */ new Set();
272
+ const visit = (node, path) => {
273
+ if (visiting.has(node)) {
274
+ throw new Error(`${kind.label} relation cycle detected: ${[...path, node].join(" -> ")}`);
275
+ }
276
+ if (visited.has(node)) return;
277
+ visiting.add(node);
278
+ for (const target of edges.get(node) ?? []) visit(target, [...path, node]);
279
+ visiting.delete(node);
280
+ visited.add(node);
281
+ };
282
+ for (const node of edges.keys()) visit(node, []);
283
+ }
284
+ }
285
+ function registerValidatedFabricModule(module) {
286
+ for (const objectType of module.objectTypes ?? []) {
287
+ chunkXCL2HBMB_cjs.registerObjectType(getObjectTypeName(objectType));
288
+ const qualified = qualifiedObjectType(module.namespace, getObjectTypeName(objectType));
289
+ registeredQualifiedObjectTypes.add(qualified);
290
+ if (typeof objectType !== "string") registeredObjectDefinitions.set(qualified, objectType);
291
+ }
292
+ for (const subjectType of module.subjectTypes ?? []) {
293
+ chunkJAXDEK5Z_cjs.registerSubjectType(subjectType);
294
+ }
295
+ for (const eventType of module.eventTypes ?? []) {
296
+ chunkJAXDEK5Z_cjs.registerEventType(getEventTypeName(eventType));
297
+ }
298
+ for (const policy of module.policies ?? []) {
299
+ chunkNJL3US7H_cjs.registerPolicyIfMissing(policy);
300
+ }
301
+ for (const machine of module.stateMachines ?? []) {
302
+ chunkUV252FLT_cjs.registerStateMachineIfMissing(machine);
303
+ }
304
+ for (const action of module.actions ?? []) {
305
+ chunkHLRIXNVG_cjs.registerActionIfMissing(action);
306
+ }
307
+ for (const descriptor of module.displayRenderers ?? []) {
308
+ chunkEO4VSB2O_cjs.registerDisplayRenderer(descriptor.eventType, descriptor.renderer);
309
+ }
310
+ for (const view of module.views ?? []) chunkO7IHZ53Y_cjs.registerViewContractIfMissing(view);
311
+ registeredModuleNamespaces.add(module.namespace);
312
+ }
313
+ function registerFabricModule(module) {
314
+ const availableObjectTypes = /* @__PURE__ */ new Set([
315
+ ...registeredQualifiedObjectTypes,
316
+ ...(module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType)))
317
+ ]);
318
+ validateManifest(module, { availableNamespaces: registeredModuleNamespaces, availableObjectTypes });
319
+ assertAcyclicRelations([module]);
320
+ registerValidatedFabricModule(module);
321
+ }
322
+ function registerFabricModules(modules) {
323
+ const availableNamespaces = /* @__PURE__ */ new Set([
324
+ ...registeredModuleNamespaces,
325
+ ...modules.map((module) => module.namespace)
326
+ ]);
327
+ const plannedEventTypes = new Set(
328
+ modules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName))
329
+ );
330
+ const availableObjectTypes = /* @__PURE__ */ new Set([
331
+ ...registeredQualifiedObjectTypes,
332
+ ...modules.flatMap(
333
+ (module) => (module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType)))
334
+ )
335
+ ]);
336
+ for (const module of modules) {
337
+ validateManifest(module, { availableNamespaces, plannedEventTypes, availableObjectTypes });
338
+ }
339
+ assertAcyclicRelations(modules);
340
+ const sortedModules = sortModulesByDependency(modules);
341
+ for (const module of sortedModules) {
342
+ registerValidatedFabricModule(module);
343
+ }
344
+ return sortedModules;
345
+ }
346
+
347
+ exports.createModuleRegistry = createModuleRegistry;
348
+ exports.getEventTypeName = getEventTypeName;
349
+ exports.getModuleDependencyNamespace = getModuleDependencyNamespace;
350
+ exports.getObjectTypeName = getObjectTypeName;
351
+ exports.registerFabricModule = registerFabricModule;
352
+ exports.registerFabricModules = registerFabricModules;
353
+ exports.validateModuleNamespace = validateModuleNamespace;
354
+ //# sourceMappingURL=chunk-ODP3DO6P.cjs.map
355
+ //# sourceMappingURL=chunk-ODP3DO6P.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../modules/index.ts"],"names":["assertPortableJsonSchema","isValidEventType","registerObjectType","registerSubjectType","registerEventType","registerPolicyIfMissing","registerStateMachineIfMissing","registerActionIfMissing","registerDisplayRenderer"],"mappings":";;;;;;;;;;;AA+IA,IAAM,0BAAA,uBAAiC,GAAA,EAAY;AACnD,IAAM,8BAAA,uBAAqC,GAAA,EAAY;AACvD,IAAM,2BAAA,uBAAkC,GAAA,EAAoC;AAErE,SAAS,6BAA6B,UAAA,EAA2C;AACvF,EAAA,OAAO,OAAO,UAAA,KAAe,QAAA,GAAW,UAAA,GAAa,UAAA,CAAW,SAAA;AACjE;AAEO,SAAS,kBAAkB,UAAA,EAAiD;AAClF,EAAA,OAAO,OAAO,UAAA,KAAe,QAAA,GAAW,UAAA,GAAa,UAAA,CAAW,IAAA;AACjE;AAEO,SAAS,iBAAiB,SAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,SAAA,KAAc,QAAA,GAAW,SAAA,GAAY,SAAA,CAAU,SAAA;AAC9D;AAEO,SAAS,wBAAwB,SAAA,EAAyB;AAChE,EAAA,IAAI,CAAC,SAAA,EAAW;AACf,IAAA,MAAM,IAAI,MAAM,kCAAkC,CAAA;AAAA,EACnD;AACA,EAAA,IAAI,CAAC,mBAAA,CAAoB,IAAA,CAAK,SAAS,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,KAAA;AAAA,MACT,8BAA8B,SAAS,CAAA,wDAAA;AAAA,KACxC;AAAA,EACD;AACD;AAEO,SAAS,oBAAA,CACf,OAAA,GAA+B,EAAC,EACV;AACtB,EAAA,MAAM,UAAA,uBAAiB,GAAA,EAA+B;AACtD,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC7B,IAAA,uBAAA,CAAwB,OAAO,SAAS,CAAA;AACxC,IAAA,IAAI,UAAA,CAAW,GAAA,CAAI,MAAA,CAAO,SAAS,CAA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AAA,KAAA,MAAW,UAAU,aAAA,EAAe;AACnC,IAAA,6BAAA,CAA8B,MAAM,CAAA;AAAA,EACrC;AAEA,EAAA,OAAO,aAAA;AACR","file":"chunk-ODP3DO6P.cjs","sourcesContent":["import { registerActionIfMissing, type ActionDefinition } from \"../actions\";\nimport { registerDisplayRenderer, type DisplayRenderer } from \"../displays\";\nimport { isValidEventType, registerEventType, registerSubjectType } from \"../events\";\nimport {\n\tassertPortableJsonSchema,\n\tregisterObjectType,\n\ttype JsonValue,\n\ttype PortableJsonSchema,\n} from \"../objects\";\nimport { registerPolicyIfMissing, type PolicyEvaluator } from \"../policies\";\nimport { registerStateMachineIfMissing, type StateMachineDefinition } from \"../state-machines\";\nimport { registerViewContractIfMissing, type ViewContract } from \"../projections\";\n\nexport interface ModuleDependency {\n\tnamespace: string;\n\tversion?: string;\n\toptional?: boolean;\n}\n\nexport type ModuleDependencyInput = string | ModuleDependency;\n\nexport interface IdPrefixRegistration {\n\tprefix: string;\n\tname: string;\n\tmodule: string;\n}\n\nexport interface EventTypeRegistration {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n}\n\nexport type EventTypeRegistrationInput = string | EventTypeRegistration;\n\nexport interface ObjectTypeRegistration {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n\tisCoreModuleType?: boolean;\n\tschema?: PortableJsonSchema;\n\tsemantics?: Record<string, JsonValue>;\n\trelations?: ObjectRelationDefinition[];\n\tinvariants?: DeclarativeInvariant[];\n}\n\nexport type ObjectRelationCardinality = \"one\" | \"many\";\nexport type ObjectRelationSemantics = \"reference\" | \"owned\";\nexport type ObjectRelationDeleteBehavior = \"restrict\" | \"cascade\" | \"set-null\";\n\nexport interface ObjectRelationDefinition {\n\tname: string;\n\ttarget: `${string}.${string}`;\n\tcardinality: ObjectRelationCardinality;\n\trequired?: boolean;\n\tsemantics: ObjectRelationSemantics;\n\tonTargetDelete: ObjectRelationDeleteBehavior;\n}\n\nexport type InvariantEnforcement =\n\t| \"json-schema\"\n\t| \"state-machine\"\n\t| \"policy\"\n\t| \"host-adapter\"\n\t| \"application\";\n\nexport interface DeclarativeInvariant {\n\tid: string;\n\tdescription: string;\n\trequired?: boolean;\n\tenforcement: InvariantEnforcement;\n\tenforcementRef?: string;\n}\n\nexport type ObjectTypeRegistrationInput = string | ObjectTypeRegistration;\n\nexport interface ModuleDisplayRendererRegistration {\n\teventType: string;\n\trenderer: DisplayRenderer;\n}\n\nexport interface PolicyRegistration {\n\tid: string;\n\tversion?: string;\n\tdescription?: string;\n}\n\nexport interface StateMachineRegistration {\n\tentityType: string;\n\tstates: string[];\n}\n\nexport interface CapabilitySlotDefinition {\n\tname: string;\n\tdescription: string;\n\tshape?: PortableJsonSchema;\n}\n\nexport interface CapabilityMetadata {\n\tdisplayName: string;\n\tdescription: string;\n\troles?: string[];\n\tstability: \"experimental\" | \"beta\" | \"stable\" | \"deprecated\";\n\tdeprecated?: { since: string; replacement?: string; message: string };\n\tslots?: CapabilitySlotDefinition[];\n\tcertification?: { profile: string; required: boolean };\n}\n\nexport interface FabricModule<TDb = unknown> {\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tcapability?: CapabilityMetadata;\n\tdependencies?: ModuleDependencyInput[];\n\tobjectTypes?: ObjectTypeRegistrationInput[];\n\tsubjectTypes?: string[];\n\tidPrefixes?: IdPrefixRegistration[];\n\teventTypes?: EventTypeRegistrationInput[];\n\tactions?: ActionDefinition<TDb>[];\n\tpolicies?: unknown[];\n\tstateMachines?: unknown[];\n\tdisplayRenderers?: ModuleDisplayRendererRegistration[];\n\tadapterDefinitions?: unknown[];\n\tpermissions?: unknown[];\n\troles?: unknown[];\n\tredactionRules?: unknown[];\n\tdataClassifications?: unknown[];\n\tretentionRules?: unknown[];\n\tevidenceRenderers?: unknown[];\n\tviews?: ViewContract[];\n}\n\nexport interface ModuleRegistry<TDb = unknown> {\n\tmodules: ReadonlyMap<string, FabricModule<TDb>>;\n}\n\ninterface ModuleValidationContext {\n\tavailableNamespaces?: Set<string>;\n\tplannedEventTypes?: Set<string>;\n\tavailableObjectTypes?: Set<string>;\n}\n\nconst registeredModuleNamespaces = new Set<string>();\nconst registeredQualifiedObjectTypes = new Set<string>();\nconst registeredObjectDefinitions = new Map<string, ObjectTypeRegistration>();\n\nexport function getModuleDependencyNamespace(dependency: ModuleDependencyInput): string {\n\treturn typeof dependency === \"string\" ? dependency : dependency.namespace;\n}\n\nexport function getObjectTypeName(objectType: ObjectTypeRegistrationInput): string {\n\treturn typeof objectType === \"string\" ? objectType : objectType.type;\n}\n\nexport function getEventTypeName(eventType: EventTypeRegistrationInput): string {\n\treturn typeof eventType === \"string\" ? eventType : eventType.eventType;\n}\n\nexport function validateModuleNamespace(namespace: string): void {\n\tif (!namespace) {\n\t\tthrow new Error(\"Module namespace cannot be empty\");\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(namespace)) {\n\t\tthrow new Error(\n\t\t\t`Invalid module namespace: \"${namespace}\". Must be lowercase letters, numbers, and hyphens only.`,\n\t\t);\n\t}\n}\n\nexport function createModuleRegistry<TDb = unknown>(\n\tmodules: FabricModule<TDb>[] = [],\n): ModuleRegistry<TDb> {\n\tconst registered = new Map<string, FabricModule<TDb>>();\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (registered.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate FabricModule namespace \"${module.namespace}\".`);\n\t\t}\n\t\tregistered.set(module.namespace, module);\n\t}\n\treturn { modules: registered };\n}\n\nfunction validateIdentifierList(\n\tvalues: string[] | undefined,\n\tlabel: string,\n\tnamespace: string,\n): void {\n\tfor (const value of values ?? []) {\n\t\tif (!value) {\n\t\t\tthrow new Error(`Module \"${namespace}\" has an empty ${label} entry.`);\n\t\t}\n\t}\n}\n\nfunction assertJsonValue(value: unknown, path: string): asserts value is JsonValue {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return;\n\tif (typeof value === \"number\" && Number.isFinite(value)) return;\n\tif (Array.isArray(value)) {\n\t\tvalue.forEach((item, index) => assertJsonValue(item, `${path}[${index}]`));\n\t\treturn;\n\t}\n\tif (typeof value === \"object\") {\n\t\tfor (const [key, child] of Object.entries(value as Record<string, unknown>)) {\n\t\t\tassertJsonValue(child, `${path}.${key}`);\n\t\t}\n\t\treturn;\n\t}\n\tthrow new Error(`${path} must contain JSON-serializable values.`);\n}\n\nfunction qualifiedObjectType(namespace: string, type: string): string {\n\treturn `${namespace}.${type}`;\n}\n\nfunction validateObjectDefinition(\n\tobjectType: ObjectTypeRegistrationInput,\n\tnamespace: string,\n\tcontext: ModuleValidationContext,\n): void {\n\tif (typeof objectType === \"string\") return;\n\tif (objectType.schema !== undefined) {\n\t\tassertPortableJsonSchema(objectType.schema, `Module \"${namespace}\" object \"${objectType.type}\" schema`);\n\t}\n\tif (objectType.semantics !== undefined) {\n\t\tassertJsonValue(objectType.semantics, `Module \"${namespace}\" object \"${objectType.type}\" semantics`);\n\t}\n\tconst relationNames = new Set<string>();\n\tfor (const relation of objectType.relations ?? []) {\n\t\tif (!/^[a-z][a-zA-Z0-9]*$/.test(relation.name)) {\n\t\t\tthrow new Error(`Module \"${namespace}\" object \"${objectType.type}\" has invalid relation name \"${relation.name}\".`);\n\t\t}\n\t\tif (relationNames.has(relation.name)) {\n\t\t\tthrow new Error(`Module \"${namespace}\" object \"${objectType.type}\" has duplicate relation \"${relation.name}\".`);\n\t\t}\n\t\trelationNames.add(relation.name);\n\t\tif (!/^[a-z][a-z0-9-]*\\.[A-Z][a-zA-Z0-9]*$/.test(relation.target)) {\n\t\t\tthrow new Error(`Relation \"${relation.name}\" target \"${relation.target}\" must be module-qualified.`);\n\t\t}\n\t\tif (context.availableObjectTypes && !context.availableObjectTypes.has(relation.target)) {\n\t\t\tthrow new Error(`Relation \"${relation.name}\" targets missing object type \"${relation.target}\".`);\n\t\t}\n\t\tif (relation.required && relation.onTargetDelete === \"set-null\") {\n\t\t\tthrow new Error(`Required relation \"${relation.name}\" cannot use onTargetDelete \"set-null\".`);\n\t\t}\n\t}\n\tconst invariantIds = new Set<string>();\n\tfor (const invariant of objectType.invariants ?? []) {\n\t\tif (!invariant.id.trim() || !invariant.description.trim()) {\n\t\t\tthrow new Error(`Module \"${namespace}\" object \"${objectType.type}\" has an invariant without an id or description.`);\n\t\t}\n\t\tif (invariantIds.has(invariant.id)) {\n\t\t\tthrow new Error(`Module \"${namespace}\" object \"${objectType.type}\" has duplicate invariant \"${invariant.id}\".`);\n\t\t}\n\t\tinvariantIds.add(invariant.id);\n\t\tif (invariant.required && !invariant.enforcementRef?.trim()) {\n\t\t\tthrow new Error(`Required invariant \"${invariant.id}\" must declare enforcementRef.`);\n\t\t}\n\t}\n}\n\nfunction validateManifest(module: FabricModule<unknown>, context: ModuleValidationContext = {}): void {\n\tvalidateModuleNamespace(module.namespace);\n\n\tconst dependencies = (module.dependencies ?? []).map(getModuleDependencyNamespace);\n\tconst objectTypes = (module.objectTypes ?? []).map(getObjectTypeName);\n\tconst eventTypes = (module.eventTypes ?? []).map(getEventTypeName);\n\tif (module.capability) {\n\t\tif (!module.capability.displayName.trim() || !module.capability.description.trim()) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t}\n\t\tif (new Set(module.capability.roles ?? []).size !== (module.capability.roles ?? []).length || (module.capability.roles ?? []).some((role) => !/^[a-z][a-z0-9-]*$/.test(role))) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" capability has invalid or duplicate roles.`);\n\t\t}\n\t\tconst slots = new Set<string>();\n\t\tfor (const slot of module.capability.slots ?? []) {\n\t\t\tif (!/^[a-z][a-z0-9-]*$/.test(slot.name) || slots.has(slot.name)) {\n\t\t\t\tthrow new Error(`Module \"${module.namespace}\" capability has invalid or duplicate slot \"${slot.name}\".`);\n\t\t\t}\n\t\t\tslots.add(slot.name);\n\t\t\tif (slot.shape) assertPortableJsonSchema(slot.shape, `Capability slot \"${slot.name}\" shape`);\n\t\t}\n\t}\n\n\tfor (const dependency of dependencies) {\n\t\tvalidateModuleNamespace(dependency);\n\t\tif (dependency === module.namespace) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" cannot depend on itself.`);\n\t\t}\n\t\tif (context.availableNamespaces && !context.availableNamespaces.has(dependency)) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t}\n\t}\n\n\tvalidateIdentifierList(objectTypes, \"objectTypes\", module.namespace);\n\tvalidateIdentifierList(module.subjectTypes, \"subjectTypes\", module.namespace);\n\tvalidateIdentifierList(eventTypes, \"eventTypes\", module.namespace);\n\n\tfor (const objectType of objectTypes) {\n\t\tif (!/^[A-Z][a-zA-Z0-9]*$/.test(objectType)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid object type: \"${objectType}\". Object types must be PascalCase alphanumeric.`,\n\t\t\t);\n\t\t}\n\t}\n\tfor (const objectType of module.objectTypes ?? []) {\n\t\tvalidateObjectDefinition(objectType, module.namespace, context);\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId)) {\n\t\t\tthrow new Error(`Invalid action ID: ${action.actionId}`);\n\t\t}\n\n\t\tif (action.namespace !== module.namespace) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" declares namespace \"${action.namespace}\" ` +\n\t\t\t\t\t`but is registered by module \"${module.namespace}\".`,\n\t\t\t);\n\t\t}\n\n\t\tif (!action.actionId.startsWith(`${module.namespace}.`)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" must start with module namespace \"${module.namespace}.\"`,\n\t\t\t);\n\t\t}\n\n\t\tif (action.mutatesDomain && action.emitsEvents.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" mutates domain but emits no events. ` +\n\t\t\t\t\t`Every mutating action must emit at least one AssetEvent.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tconst isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;\n\t\tconst isModuleEventType = eventTypes.includes(descriptor.eventType);\n\t\tif (!isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {\n\t\t\tthrow new Error(\n\t\t\t\t`Display renderer registered for unknown event type \"${descriptor.eventType}\". ` +\n\t\t\t\t\t`Register the event type before adding a display renderer.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst viewKeys = new Set<string>();\n\tfor (const view of module.views ?? []) {\n\t\tif (!view.name.startsWith(`${module.namespace}/`) || !/^[a-z][a-z0-9-]*\\/[a-z][a-z0-9/_-]*$/.test(view.name)) {\n\t\t\tthrow new Error(`View \"${view.name}\" must start with module namespace \"${module.namespace}/\" and use lowercase path segments.`);\n\t\t}\n\t\tif (!view.version.trim()) throw new Error(`View \"${view.name}\" must declare a version.`);\n\t\tconst key = `${view.name}@${view.version}`;\n\t\tif (viewKeys.has(key)) throw new Error(`Module \"${module.namespace}\" has duplicate view contract \"${key}\".`);\n\t\tviewKeys.add(key);\n\t\tassertPortableJsonSchema(view.shape, `View \"${key}\" shape`);\n\t\tif (!Number.isInteger(view.snapshotVersion) || view.snapshotVersion < 1) {\n\t\t\tthrow new Error(`View \"${key}\" snapshotVersion must be a positive integer.`);\n\t\t}\n\t\tif ((view.compatibleSnapshotVersions?.some((version) => version !== view.snapshotVersion) ?? false) && !view.upgradeSnapshot) {\n\t\t\tthrow new Error(`View \"${key}\" declares older compatible snapshots but no upgradeSnapshot function.`);\n\t\t}\n\t\tfor (const consumption of view.consumes) {\n\t\t\tconst isPlanned = context.plannedEventTypes?.has(consumption.eventType) ?? false;\n\t\t\tconst isModuleEvent = eventTypes.includes(consumption.eventType);\n\t\t\tif (!isValidEventType(consumption.eventType) && !isPlanned && !isModuleEvent) {\n\t\t\t\tthrow new Error(`View \"${key}\" consumes unknown event type \"${consumption.eventType}\".`);\n\t\t\t}\n\t\t\tif (consumption.schemaVersions.length === 0 || consumption.schemaVersions.some((version) => !Number.isInteger(version) || version < 1)) {\n\t\t\t\tthrow new Error(`View \"${key}\" must declare positive consumed schema versions for \"${consumption.eventType}\".`);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction sortModulesByDependency(\n\tmodules: FabricModule<unknown>[],\n\tregisteredNamespaces = registeredModuleNamespaces,\n): FabricModule<unknown>[] {\n\tconst modulesByNamespace = new Map<string, FabricModule<unknown>>();\n\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (modulesByNamespace.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate Fabric module namespace \"${module.namespace}\".`);\n\t\t}\n\t\tmodulesByNamespace.set(module.namespace, module);\n\t}\n\n\tconst sorted: FabricModule<unknown>[] = [];\n\tconst visiting = new Set<string>();\n\tconst visited = new Set<string>();\n\n\tfunction visit(module: FabricModule<unknown>, path: string[]): void {\n\t\tif (visited.has(module.namespace)) {\n\t\t\treturn;\n\t\t}\n\t\tif (visiting.has(module.namespace)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cyclic Fabric module dependency detected: ${[...path, module.namespace].join(\" -> \")}`,\n\t\t\t);\n\t\t}\n\n\t\tvisiting.add(module.namespace);\n\t\tfor (const dependency of (module.dependencies ?? []).map(getModuleDependencyNamespace)) {\n\t\t\tconst dependencyModule = modulesByNamespace.get(dependency);\n\t\t\tif (!dependencyModule) {\n\t\t\t\tif (registeredNamespaces.has(dependency)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t\t}\n\t\t\tvisit(dependencyModule, [...path, module.namespace]);\n\t\t}\n\t\tvisiting.delete(module.namespace);\n\t\tvisited.add(module.namespace);\n\t\tsorted.push(module);\n\t}\n\n\tfor (const module of modules) {\n\t\tvisit(module, []);\n\t}\n\n\treturn sorted;\n}\n\nfunction assertAcyclicRelations(modules: FabricModule<unknown>[]): void {\n\tconst relationKinds = [\n\t\t{ label: \"owned containment\", include: (relation: ObjectRelationDefinition) => relation.semantics === \"owned\" },\n\t\t{ label: \"cascade-delete\", include: (relation: ObjectRelationDefinition) => relation.onTargetDelete === \"cascade\" },\n\t\t{ label: \"required-construction\", include: (relation: ObjectRelationDefinition) => relation.required === true },\n\t];\n\tfor (const kind of relationKinds) {\n\t\tconst edges = new Map<string, string[]>();\n\t\tfor (const [source, objectType] of registeredObjectDefinitions) {\n\t\t\tedges.set(source, (objectType.relations ?? []).filter(kind.include).map((relation) => relation.target));\n\t\t}\n\t\tfor (const module of modules) {\n\t\t\tfor (const objectType of module.objectTypes ?? []) {\n\t\t\t\tif (typeof objectType === \"string\") continue;\n\t\t\t\tconst source = qualifiedObjectType(module.namespace, objectType.type);\n\t\t\t\tedges.set(source, (objectType.relations ?? []).filter(kind.include).map((relation) => relation.target));\n\t\t\t}\n\t\t}\n\t\tconst visiting = new Set<string>();\n\t\tconst visited = new Set<string>();\n\t\tconst visit = (node: string, path: string[]): void => {\n\t\t\tif (visiting.has(node)) {\n\t\t\t\tthrow new Error(`${kind.label} relation cycle detected: ${[...path, node].join(\" -> \")}`);\n\t\t\t}\n\t\t\tif (visited.has(node)) return;\n\t\t\tvisiting.add(node);\n\t\t\tfor (const target of edges.get(node) ?? []) visit(target, [...path, node]);\n\t\t\tvisiting.delete(node);\n\t\t\tvisited.add(node);\n\t\t};\n\t\tfor (const node of edges.keys()) visit(node, []);\n\t}\n}\n\nfunction registerValidatedFabricModule(module: FabricModule<unknown>): void {\n\tfor (const objectType of module.objectTypes ?? []) {\n\t\tregisterObjectType(getObjectTypeName(objectType));\n\t\tconst qualified = qualifiedObjectType(module.namespace, getObjectTypeName(objectType));\n\t\tregisteredQualifiedObjectTypes.add(qualified);\n\t\tif (typeof objectType !== \"string\") registeredObjectDefinitions.set(qualified, objectType);\n\t}\n\n\tfor (const subjectType of module.subjectTypes ?? []) {\n\t\tregisterSubjectType(subjectType);\n\t}\n\n\tfor (const eventType of module.eventTypes ?? []) {\n\t\tregisterEventType(getEventTypeName(eventType));\n\t}\n\n\tfor (const policy of module.policies ?? []) {\n\t\tregisterPolicyIfMissing(policy as PolicyEvaluator);\n\t}\n\n\tfor (const machine of module.stateMachines ?? []) {\n\t\tregisterStateMachineIfMissing(machine as StateMachineDefinition);\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tregisterActionIfMissing(action);\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tregisterDisplayRenderer(descriptor.eventType, descriptor.renderer as DisplayRenderer);\n\t}\n\tfor (const view of module.views ?? []) registerViewContractIfMissing(view);\n\n\tregisteredModuleNamespaces.add(module.namespace);\n}\n\nexport function registerFabricModule(module: FabricModule<unknown>): void {\n\tconst availableObjectTypes = new Set([\n\t\t...registeredQualifiedObjectTypes,\n\t\t...(module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType))),\n\t]);\n\tvalidateManifest(module, { availableNamespaces: registeredModuleNamespaces, availableObjectTypes });\n\tassertAcyclicRelations([module]);\n\tregisterValidatedFabricModule(module);\n}\n\nexport function registerFabricModules(modules: FabricModule<unknown>[]): FabricModule<unknown>[] {\n\tconst availableNamespaces = new Set([\n\t\t...registeredModuleNamespaces,\n\t\t...modules.map((module) => module.namespace),\n\t]);\n\tconst plannedEventTypes = new Set(\n\t\tmodules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName)),\n\t);\n\tconst availableObjectTypes = new Set([\n\t\t...registeredQualifiedObjectTypes,\n\t\t...modules.flatMap((module) =>\n\t\t\t(module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType))),\n\t\t),\n\t]);\n\n\tfor (const module of modules) {\n\t\tvalidateManifest(module, { availableNamespaces, plannedEventTypes, availableObjectTypes });\n\t}\n\tassertAcyclicRelations(modules);\n\n\tconst sortedModules = sortModulesByDependency(modules);\n\tfor (const module of sortedModules) {\n\t\tregisterValidatedFabricModule(module);\n\t}\n\n\treturn sortedModules;\n}\n"]}