@fabricorg/platform 0.12.0 → 1.0.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.
- package/CHANGELOG.md +21 -0
- package/README.md +7 -8
- package/dist/actions/index.cjs +7 -27
- package/dist/actions/index.d.cts +9 -7
- package/dist/actions/index.d.ts +9 -7
- package/dist/actions/index.js +1 -1
- package/dist/{chunk-ROC326VL.cjs → chunk-35LADVKK.cjs} +48 -104
- package/dist/chunk-35LADVKK.cjs.map +1 -0
- package/dist/chunk-4QOA3VU5.js +47 -0
- package/dist/chunk-4QOA3VU5.js.map +1 -0
- package/dist/chunk-53VEUYCS.cjs +40 -0
- package/dist/chunk-53VEUYCS.cjs.map +1 -0
- package/dist/{chunk-X7WC4AYC.js → chunk-ATWWZTRC.js} +32 -74
- package/dist/chunk-ATWWZTRC.js.map +1 -0
- package/dist/chunk-BFQNKQJE.cjs +53 -0
- package/dist/{chunk-4RMKUYRX.js.map → chunk-BFQNKQJE.cjs.map} +1 -1
- package/dist/{chunk-OC4ZFJKD.cjs → chunk-CBY6GRJP.cjs} +16 -17
- package/dist/chunk-CBY6GRJP.cjs.map +1 -0
- package/dist/chunk-CQSA3BII.js +38 -0
- package/dist/chunk-CQSA3BII.js.map +1 -0
- package/dist/{chunk-ZO6HPMCK.js → chunk-CRAGTJ3B.js} +3 -3
- package/dist/{chunk-ZO6HPMCK.js.map → chunk-CRAGTJ3B.js.map} +1 -1
- package/dist/{chunk-LXS6SURU.js → chunk-J5LS5BSI.js} +70 -29
- package/dist/chunk-J5LS5BSI.js.map +1 -0
- package/dist/{chunk-MCD5VT4E.cjs → chunk-JFMNLJLY.cjs} +6 -6
- package/dist/{chunk-MCD5VT4E.cjs.map → chunk-JFMNLJLY.cjs.map} +1 -1
- package/dist/{chunk-6ER62UUN.js → chunk-JFVEPAED.js} +31 -40
- package/dist/chunk-JFVEPAED.js.map +1 -0
- package/dist/{chunk-45TSN3GO.cjs → chunk-M5FGWXT3.cjs} +70 -32
- package/dist/chunk-M5FGWXT3.cjs.map +1 -0
- package/dist/{chunk-4MMMXV4Q.js → chunk-NETLRKDS.js} +16 -15
- package/dist/chunk-NETLRKDS.js.map +1 -0
- package/dist/chunk-OWSSGFNY.js +45 -0
- package/dist/chunk-OWSSGFNY.js.map +1 -0
- package/dist/{chunk-5PDVZXEI.js → chunk-T5ESIJ4K.js} +42 -99
- package/dist/chunk-T5ESIJ4K.js.map +1 -0
- package/dist/{chunk-NJL3US7H.cjs → chunk-VZ6C4LXC.cjs} +31 -43
- package/dist/chunk-VZ6C4LXC.cjs.map +1 -0
- package/dist/chunk-WAI4UNWQ.cjs +48 -0
- package/dist/chunk-WAI4UNWQ.cjs.map +1 -0
- package/dist/{chunk-YQEXO3IQ.cjs → chunk-X3GHYMAJ.cjs} +32 -74
- package/dist/chunk-X3GHYMAJ.cjs.map +1 -0
- package/dist/events/index.cjs +3 -27
- package/dist/events/index.d.cts +13 -13
- package/dist/events/index.d.ts +13 -13
- package/dist/events/index.js +1 -1
- package/dist/index.cjs +88 -193
- package/dist/index.d.cts +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.js +10 -11
- package/dist/manifest/index.cjs +11 -15
- package/dist/manifest/index.d.cts +0 -1
- package/dist/manifest/index.d.ts +0 -1
- package/dist/manifest/index.js +5 -9
- package/dist/modules/index.cjs +15 -15
- package/dist/modules/index.d.cts +16 -23
- package/dist/modules/index.d.ts +16 -23
- package/dist/modules/index.js +4 -8
- package/dist/objects/index.cjs +5 -13
- package/dist/objects/index.d.cts +7 -4
- package/dist/objects/index.d.ts +7 -4
- package/dist/objects/index.js +1 -1
- package/dist/policies/index.cjs +12 -24
- package/dist/policies/index.d.cts +10 -5
- package/dist/policies/index.d.ts +10 -5
- package/dist/policies/index.js +1 -1
- package/dist/privacy/index.cjs +10 -10
- package/dist/privacy/index.d.cts +16 -5
- package/dist/privacy/index.d.ts +16 -5
- package/dist/privacy/index.js +1 -1
- package/dist/projections/index.cjs +6 -18
- package/dist/projections/index.d.cts +21 -7
- package/dist/projections/index.d.ts +21 -7
- package/dist/projections/index.js +1 -1
- package/dist/state-machines/index.cjs +5 -21
- package/dist/state-machines/index.d.cts +17 -31
- package/dist/state-machines/index.d.ts +17 -31
- package/dist/state-machines/index.js +1 -1
- package/package.json +1 -11
- package/dist/chunk-3O4GMCCE.js +0 -55
- package/dist/chunk-3O4GMCCE.js.map +0 -1
- package/dist/chunk-45TSN3GO.cjs.map +0 -1
- package/dist/chunk-4MMMXV4Q.js.map +0 -1
- package/dist/chunk-4RMKUYRX.js +0 -59
- package/dist/chunk-5PDVZXEI.js.map +0 -1
- package/dist/chunk-6ER62UUN.js.map +0 -1
- package/dist/chunk-7RV5REPT.cjs +0 -63
- package/dist/chunk-7RV5REPT.cjs.map +0 -1
- package/dist/chunk-EO4VSB2O.cjs +0 -99
- package/dist/chunk-EO4VSB2O.cjs.map +0 -1
- package/dist/chunk-JOATYJXQ.cjs +0 -70
- package/dist/chunk-JOATYJXQ.cjs.map +0 -1
- package/dist/chunk-LXS6SURU.js.map +0 -1
- package/dist/chunk-NJL3US7H.cjs.map +0 -1
- package/dist/chunk-O5WVBQ7P.js +0 -89
- package/dist/chunk-O5WVBQ7P.js.map +0 -1
- package/dist/chunk-OC4ZFJKD.cjs.map +0 -1
- package/dist/chunk-ROC326VL.cjs.map +0 -1
- package/dist/chunk-T2JLSZN6.js +0 -67
- package/dist/chunk-T2JLSZN6.js.map +0 -1
- package/dist/chunk-UV252FLT.cjs +0 -74
- package/dist/chunk-UV252FLT.cjs.map +0 -1
- package/dist/chunk-X7WC4AYC.js.map +0 -1
- package/dist/chunk-YQEXO3IQ.cjs.map +0 -1
- package/dist/displays/index.cjs +0 -24
- package/dist/displays/index.cjs.map +0 -1
- package/dist/displays/index.d.cts +0 -34
- package/dist/displays/index.d.ts +0 -34
- package/dist/displays/index.js +0 -3
- package/dist/displays/index.js.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// state-machines/engine.ts
|
|
2
|
+
function validateStateMachineTransition(sm, entityType, from, to, actionId) {
|
|
3
|
+
if (!sm) return { valid: false, error: `No state machine registered for entity type "${entityType}".` };
|
|
4
|
+
const fromDef = sm.states[from];
|
|
5
|
+
if (!fromDef) return { valid: false, error: `State "${from}" does not exist in state machine for entity type "${entityType}".` };
|
|
6
|
+
const toDef = sm.states[to];
|
|
7
|
+
if (!toDef) return { valid: false, error: `State "${to}" does not exist in state machine for entity type "${entityType}".` };
|
|
8
|
+
const transitionExists = sm.transitions.some((transition) => transition.from === from && transition.to === to && transition.causedByAction === actionId);
|
|
9
|
+
return transitionExists ? { valid: true } : { valid: false, error: `Transition from "${from}" to "${to}" via action "${actionId}" is not defined for entity type "${entityType}".` };
|
|
10
|
+
}
|
|
11
|
+
function createStateMachineRegistry(definitions = []) {
|
|
12
|
+
const machines = /* @__PURE__ */ new Map();
|
|
13
|
+
const register = (definition) => {
|
|
14
|
+
if (machines.has(definition.entityType)) throw new Error(`State machine for entity type "${definition.entityType}" is already registered.`);
|
|
15
|
+
machines.set(definition.entityType, definition);
|
|
16
|
+
};
|
|
17
|
+
const validateTransition = (entityType, from, to, actionId) => validateStateMachineTransition(machines.get(entityType), entityType, from, to, actionId);
|
|
18
|
+
for (const definition of definitions) register(definition);
|
|
19
|
+
return {
|
|
20
|
+
register,
|
|
21
|
+
registerIfMissing(definition) {
|
|
22
|
+
if (!machines.has(definition.entityType)) register(definition);
|
|
23
|
+
},
|
|
24
|
+
resolve: (entityType) => machines.get(entityType),
|
|
25
|
+
validateTransition,
|
|
26
|
+
allowedTransitions(entityType, from) {
|
|
27
|
+
const sm = machines.get(entityType);
|
|
28
|
+
if (!sm) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
return sm.transitions.filter((t) => t.from === from).map((t) => ({ to: t.to, causedByAction: t.causedByAction }));
|
|
32
|
+
},
|
|
33
|
+
stateClass(entityType, state) {
|
|
34
|
+
const sm = machines.get(entityType);
|
|
35
|
+
if (!sm) {
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
return sm.states[state]?.stateClass;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { createStateMachineRegistry, validateStateMachineTransition };
|
|
44
|
+
//# sourceMappingURL=chunk-OWSSGFNY.js.map
|
|
45
|
+
//# sourceMappingURL=chunk-OWSSGFNY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../state-machines/engine.ts"],"names":[],"mappings":";AAgCO,SAAS,8BAAA,CACf,EAAA,EACA,UAAA,EACA,IAAA,EACA,IACA,QAAA,EACqC;AACrC,EAAA,IAAI,CAAC,IAAI,OAAO,EAAE,OAAO,KAAA,EAAO,KAAA,EAAO,CAAA,6CAAA,EAAgD,UAAU,CAAA,EAAA,CAAA,EAAK;AACtG,EAAA,MAAM,OAAA,GAAU,EAAA,CAAG,MAAA,CAAO,IAAI,CAAA;AAC9B,EAAA,IAAI,CAAC,OAAA,EAAS,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,CAAA,OAAA,EAAU,IAAI,CAAA,mDAAA,EAAsD,UAAU,CAAA,EAAA,CAAA,EAAK;AAC/H,EAAA,MAAM,KAAA,GAAQ,EAAA,CAAG,MAAA,CAAO,EAAE,CAAA;AAC1B,EAAA,IAAI,CAAC,KAAA,EAAO,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,CAAA,OAAA,EAAU,EAAE,CAAA,mDAAA,EAAsD,UAAU,CAAA,EAAA,CAAA,EAAK;AAC3H,EAAA,MAAM,gBAAA,GAAmB,EAAA,CAAG,WAAA,CAAY,IAAA,CAAK,CAAC,UAAA,KAAe,UAAA,CAAW,IAAA,KAAS,IAAA,IAAQ,UAAA,CAAW,EAAA,KAAO,EAAA,IAAM,UAAA,CAAW,mBAAmB,QAAQ,CAAA;AACvJ,EAAA,OAAO,mBACJ,EAAE,KAAA,E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AAC,EAAA,EAAI;AACR,QAAA,OAAO,EAAC;AAAA,MACT;AACA,MAAA,OAAO,GAAG,WAAA,CACR,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,IAAI,CAAA,CAC7B,IAAI,CAAC,CAAA,MAAO,EAAE,EAAA,EAAI,CAAA,CAAE,IAAI,cAAA,EAAgB,CAAA,CAAE,gBAAe,CAAE,CAAA;AAAA,IAC5D,CAAA;AAAA,IACA,UAAA,CAAW,YAAY,KAAA,EAAO;AAC/B,MAAA,MAAM,EAAA,GAAK,QAAA,CAAS,GAAA,CAAI,UAAU,CAAA;AAClC,MAAA,IAAI,CAAC,EAAA,EAAI;AACR,QAAA,OAAO,MAAA;AAAA,MACR;AACA,MAAA,OAAO,EAAA,CAAG,MAAA,CAAO,KAAK,CAAA,EAAG,UAAA;AAAA,IACxB;AAAA,GACD;AACD","file":"chunk-OWSSGFNY.js","sourcesContent":["import type { StateClass, StateDefinition } from \"./index\";\n\nexport interface StateMachineDefinition {\n\tentityType: string;\n\tstates: Record<string, StateDefinition>;\n\ttransitions: Array<{\n\t\tfrom: string;\n\t\tto: string;\n\t\tcausedByAction: string;\n\t\tguard?: (ctx: TransitionContext) => boolean | Promise<boolean>;\n\t}>;\n}\n\nexport type StateMachineDatabaseClient = unknown;\n\nexport interface TransitionContext<TDb = StateMachineDatabaseClient> {\n\tentity: Record<string, unknown>;\n\tactionInvocationId: string;\n\tactorId: string;\n\tparameters: unknown;\n\tdb: TDb;\n}\n\nexport interface StateMachineRegistry {\n\tregister(definition: StateMachineDefinition): void;\n\tregisterIfMissing(definition: StateMachineDefinition): void;\n\tresolve(entityType: string): StateMachineDefinition | undefined;\n\tvalidateTransition(entityType: string, from: string, to: string, actionId: string): { valid: boolean; error?: string };\n\tallowedTransitions(entityType: string, from: string): Array<{ to: string; causedByAction: string }>;\n\tstateClass(entityType: string, state: string): StateClass | undefined;\n}\n\nexport function validateStateMachineTransition(\n\tsm: StateMachineDefinition | undefined,\n\tentityType: string,\n\tfrom: string,\n\tto: string,\n\tactionId: string,\n): { valid: boolean; error?: string } {\n\tif (!sm) return { valid: false, error: `No state machine registered for entity type \"${entityType}\".` };\n\tconst fromDef = sm.states[from];\n\tif (!fromDef) return { valid: false, error: `State \"${from}\" does not exist in state machine for entity type \"${entityType}\".` };\n\tconst toDef = sm.states[to];\n\tif (!toDef) return { valid: false, error: `State \"${to}\" does not exist in state machine for entity type \"${entityType}\".` };\n\tconst transitionExists = sm.transitions.some((transition) => transition.from === from && transition.to === to && transition.causedByAction === actionId);\n\treturn transitionExists\n\t\t? { valid: true }\n\t\t: { valid: false, error: `Transition from \"${from}\" to \"${to}\" via action \"${actionId}\" is not defined for entity type \"${entityType}\".` };\n}\n\nexport function createStateMachineRegistry(definitions: readonly StateMachineDefinition[] = []): StateMachineRegistry {\n\tconst machines = new Map<string, StateMachineDefinition>();\n\tconst register = (definition: StateMachineDefinition): void => {\n\t\tif (machines.has(definition.entityType)) throw new Error(`State machine for entity type \"${definition.entityType}\" is already registered.`);\n\t\tmachines.set(definition.entityType, definition);\n\t};\n\tconst validateTransition = (entityType: string, from: string, to: string, actionId: string) =>\n\t\tvalidateStateMachineTransition(machines.get(entityType), entityType, from, to, actionId);\n\tfor (const definition of definitions) register(definition);\n\treturn {\n\t\tregister,\n\t\tregisterIfMissing(definition) {\n\t\t\tif (!machines.has(definition.entityType)) register(definition);\n\t\t},\n\t\tresolve: (entityType) => machines.get(entityType),\n\t\tvalidateTransition,\n\t\tallowedTransitions(entityType, from) {\n\tconst sm = machines.get(entityType);\n\tif (!sm) {\n\t\treturn [];\n\t}\n\treturn sm.transitions\n\t\t.filter((t) => t.from === from)\n\t\t.map((t) => ({ to: t.to, causedByAction: t.causedByAction }));\n\t\t},\n\t\tstateClass(entityType, state) {\n\tconst sm = machines.get(entityType);\n\tif (!sm) {\n\t\treturn undefined;\n\t}\n\treturn sm.states[state]?.stateClass;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { assertPortableJsonSchema
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { registerStateMachineIfMissing } from './chunk-T2JLSZN6.js';
|
|
5
|
-
import { registerActionIfMissing } from './chunk-4RMKUYRX.js';
|
|
6
|
-
import { registerDisplayRenderer } from './chunk-O5WVBQ7P.js';
|
|
7
|
-
import { isValidEventType, registerSubjectType, registerEventType } from './chunk-3O4GMCCE.js';
|
|
1
|
+
import { assertPortableJsonSchema } from './chunk-NETLRKDS.js';
|
|
2
|
+
import { viewContractKey } from './chunk-J5LS5BSI.js';
|
|
3
|
+
import { createEventContractRegistry } from './chunk-CQSA3BII.js';
|
|
8
4
|
|
|
9
5
|
// modules/index.ts
|
|
10
|
-
var registeredModuleNamespaces = /* @__PURE__ */ new Set();
|
|
11
|
-
var registeredQualifiedObjectTypes = /* @__PURE__ */ new Set();
|
|
12
|
-
var registeredObjectDefinitions = /* @__PURE__ */ new Map();
|
|
13
6
|
function getModuleDependencyNamespace(dependency) {
|
|
14
7
|
return typeof dependency === "string" ? dependency : dependency.namespace;
|
|
15
8
|
}
|
|
@@ -30,15 +23,26 @@ function validateModuleNamespace(namespace) {
|
|
|
30
23
|
}
|
|
31
24
|
}
|
|
32
25
|
function createModuleRegistry(modules = []) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
const orderedModules = validateAndOrderFabricModules(modules);
|
|
27
|
+
const registered = new Map(orderedModules.map((module) => [module.namespace, module]));
|
|
28
|
+
const actions = new Map(orderedModules.flatMap((module) => (module.actions ?? []).map((action) => [action.actionId, action])));
|
|
29
|
+
const policies = new Map(orderedModules.flatMap((module) => (module.policies ?? []).map((policy) => {
|
|
30
|
+
const evaluator = policy;
|
|
31
|
+
return [evaluator.policyId, evaluator];
|
|
32
|
+
})));
|
|
33
|
+
const machines = new Map(orderedModules.flatMap((module) => (module.stateMachines ?? []).map((machine) => {
|
|
34
|
+
const definition = machine;
|
|
35
|
+
return [definition.entityType, definition];
|
|
36
|
+
})));
|
|
37
|
+
const views = new Map(orderedModules.flatMap((module) => (module.views ?? []).map((view) => [viewContractKey(view), view])));
|
|
38
|
+
return {
|
|
39
|
+
modules: registered,
|
|
40
|
+
orderedModules,
|
|
41
|
+
resolveAction: (actionId) => actions.get(actionId),
|
|
42
|
+
resolvePolicy: (policyId) => policies.get(policyId),
|
|
43
|
+
resolveStateMachine: (entityType) => machines.get(entityType),
|
|
44
|
+
resolveView: (name, version) => views.get(`${name}@${version}`)
|
|
45
|
+
};
|
|
42
46
|
}
|
|
43
47
|
function validateIdentifierList(values, label, namespace) {
|
|
44
48
|
for (const value of values ?? []) {
|
|
@@ -115,21 +119,10 @@ function validateManifest(module, context = {}) {
|
|
|
115
119
|
if (!module.capability.displayName.trim() || !module.capability.description.trim()) {
|
|
116
120
|
throw new Error(`Module "${module.namespace}" capability requires displayName and description.`);
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const slots = /* @__PURE__ */ new Set();
|
|
122
|
-
for (const slot of module.capability.slots ?? []) {
|
|
123
|
-
if (!/^[a-z][a-z0-9-]*$/.test(slot.name) || slots.has(slot.name)) {
|
|
124
|
-
throw new Error(`Module "${module.namespace}" capability has invalid or duplicate slot "${slot.name}".`);
|
|
122
|
+
for (const namespace of Object.keys(module.capability.extensions ?? {})) {
|
|
123
|
+
if (!/^[a-z][a-z0-9.-]*\.[a-z0-9.-]+\/v[1-9][0-9]*$/.test(namespace)) {
|
|
124
|
+
throw new Error(`Module "${module.namespace}" capability has invalid extension namespace "${namespace}".`);
|
|
125
125
|
}
|
|
126
|
-
slots.add(slot.name);
|
|
127
|
-
if (slot.shape) assertPortableJsonSchema(slot.shape, `Capability slot "${slot.name}" shape`);
|
|
128
|
-
}
|
|
129
|
-
const intents = /* @__PURE__ */ new Set();
|
|
130
|
-
for (const intent of module.capability.actionIntents ?? []) {
|
|
131
|
-
if (!/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/.test(intent.name) || intents.has(intent.name)) throw new Error(`Module "${module.namespace}" capability has invalid or duplicate action intent "${intent.name}".`);
|
|
132
|
-
intents.add(intent.name);
|
|
133
126
|
}
|
|
134
127
|
for (const port of module.capability.requirements?.ports ?? []) {
|
|
135
128
|
if (!/^[a-z][a-z0-9-]*$/.test(port.name)) throw new Error(`Module "${module.namespace}" capability has invalid port requirement "${port.name}".`);
|
|
@@ -205,15 +198,6 @@ function validateManifest(module, context = {}) {
|
|
|
205
198
|
);
|
|
206
199
|
}
|
|
207
200
|
}
|
|
208
|
-
for (const descriptor of module.displayRenderers ?? []) {
|
|
209
|
-
const isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;
|
|
210
|
-
const isModuleEventType = eventTypes.includes(descriptor.eventType);
|
|
211
|
-
if (!isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {
|
|
212
|
-
throw new Error(
|
|
213
|
-
`Display renderer registered for unknown event type "${descriptor.eventType}". Register the event type before adding a display renderer.`
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
201
|
const viewKeys = /* @__PURE__ */ new Set();
|
|
218
202
|
for (const view of module.views ?? []) {
|
|
219
203
|
if (!view.name.startsWith(`${module.namespace}/`) || !/^[a-z][a-z0-9-]*\/[a-z][a-z0-9/_-]*$/.test(view.name)) {
|
|
@@ -233,7 +217,7 @@ function validateManifest(module, context = {}) {
|
|
|
233
217
|
for (const consumption of view.consumes) {
|
|
234
218
|
const isPlanned = context.plannedEventTypes?.has(consumption.eventType) ?? false;
|
|
235
219
|
const isModuleEvent = eventTypes.includes(consumption.eventType);
|
|
236
|
-
if (!
|
|
220
|
+
if (!isPlanned && !isModuleEvent) {
|
|
237
221
|
throw new Error(`View "${key}" consumes unknown event type "${consumption.eventType}".`);
|
|
238
222
|
}
|
|
239
223
|
if (consumption.schemaVersions.length === 0 || consumption.schemaVersions.some((version) => !Number.isInteger(version) || version < 1)) {
|
|
@@ -242,12 +226,12 @@ function validateManifest(module, context = {}) {
|
|
|
242
226
|
}
|
|
243
227
|
}
|
|
244
228
|
}
|
|
245
|
-
function sortModulesByDependency(modules, registeredNamespaces =
|
|
229
|
+
function sortModulesByDependency(modules, registeredNamespaces = /* @__PURE__ */ new Set()) {
|
|
246
230
|
const modulesByNamespace = /* @__PURE__ */ new Map();
|
|
247
231
|
for (const module of modules) {
|
|
248
232
|
validateModuleNamespace(module.namespace);
|
|
249
233
|
if (modulesByNamespace.has(module.namespace)) {
|
|
250
|
-
throw new Error(`Duplicate
|
|
234
|
+
throw new Error(`Duplicate FabricModule namespace "${module.namespace}".`);
|
|
251
235
|
}
|
|
252
236
|
modulesByNamespace.set(module.namespace, module);
|
|
253
237
|
}
|
|
@@ -291,9 +275,6 @@ function assertAcyclicRelations(modules) {
|
|
|
291
275
|
];
|
|
292
276
|
for (const kind of relationKinds) {
|
|
293
277
|
const edges = /* @__PURE__ */ new Map();
|
|
294
|
-
for (const [source, objectType] of registeredObjectDefinitions) {
|
|
295
|
-
edges.set(source, (objectType.relations ?? []).filter(kind.include).map((relation) => relation.target));
|
|
296
|
-
}
|
|
297
278
|
for (const module of modules) {
|
|
298
279
|
for (const objectType of module.objectTypes ?? []) {
|
|
299
280
|
if (typeof objectType === "string") continue;
|
|
@@ -316,53 +297,13 @@ function assertAcyclicRelations(modules) {
|
|
|
316
297
|
for (const node of edges.keys()) visit(node, []);
|
|
317
298
|
}
|
|
318
299
|
}
|
|
319
|
-
function
|
|
320
|
-
|
|
321
|
-
registerObjectType(getObjectTypeName(objectType));
|
|
322
|
-
const qualified = qualifiedObjectType(module.namespace, getObjectTypeName(objectType));
|
|
323
|
-
registeredQualifiedObjectTypes.add(qualified);
|
|
324
|
-
if (typeof objectType !== "string") registeredObjectDefinitions.set(qualified, objectType);
|
|
325
|
-
}
|
|
326
|
-
for (const subjectType of module.subjectTypes ?? []) {
|
|
327
|
-
registerSubjectType(subjectType);
|
|
328
|
-
}
|
|
329
|
-
for (const eventType of module.eventTypes ?? []) {
|
|
330
|
-
registerEventType(getEventTypeName(eventType));
|
|
331
|
-
}
|
|
332
|
-
for (const policy of module.policies ?? []) {
|
|
333
|
-
registerPolicyIfMissing(policy);
|
|
334
|
-
}
|
|
335
|
-
for (const machine of module.stateMachines ?? []) {
|
|
336
|
-
registerStateMachineIfMissing(machine);
|
|
337
|
-
}
|
|
338
|
-
for (const action of module.actions ?? []) {
|
|
339
|
-
registerActionIfMissing(action);
|
|
340
|
-
}
|
|
341
|
-
for (const descriptor of module.displayRenderers ?? []) {
|
|
342
|
-
registerDisplayRenderer(descriptor.eventType, descriptor.renderer);
|
|
343
|
-
}
|
|
344
|
-
for (const view of module.views ?? []) registerViewContractIfMissing(view);
|
|
345
|
-
registeredModuleNamespaces.add(module.namespace);
|
|
346
|
-
}
|
|
347
|
-
function registerFabricModule(module) {
|
|
348
|
-
const availableObjectTypes = /* @__PURE__ */ new Set([
|
|
349
|
-
...registeredQualifiedObjectTypes,
|
|
350
|
-
...(module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType)))
|
|
351
|
-
]);
|
|
352
|
-
validateManifest(module, { availableNamespaces: registeredModuleNamespaces, availableObjectTypes });
|
|
353
|
-
assertAcyclicRelations([module]);
|
|
354
|
-
registerValidatedFabricModule(module);
|
|
355
|
-
}
|
|
356
|
-
function registerFabricModules(modules) {
|
|
357
|
-
const availableNamespaces = /* @__PURE__ */ new Set([
|
|
358
|
-
...registeredModuleNamespaces,
|
|
359
|
-
...modules.map((module) => module.namespace)
|
|
360
|
-
]);
|
|
300
|
+
function validateAndOrderFabricModules(modules) {
|
|
301
|
+
const availableNamespaces = new Set(modules.map((module) => module.namespace));
|
|
361
302
|
const plannedEventTypes = new Set(
|
|
362
303
|
modules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName))
|
|
363
304
|
);
|
|
305
|
+
for (const eventType of createEventContractRegistry().eventTypes()) plannedEventTypes.add(eventType);
|
|
364
306
|
const availableObjectTypes = /* @__PURE__ */ new Set([
|
|
365
|
-
...registeredQualifiedObjectTypes,
|
|
366
307
|
...modules.flatMap(
|
|
367
308
|
(module) => (module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType)))
|
|
368
309
|
)
|
|
@@ -371,13 +312,15 @@ function registerFabricModules(modules) {
|
|
|
371
312
|
validateManifest(module, { availableNamespaces, plannedEventTypes, availableObjectTypes });
|
|
372
313
|
}
|
|
373
314
|
assertAcyclicRelations(modules);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
315
|
+
return sortModulesByDependency(modules);
|
|
316
|
+
}
|
|
317
|
+
function registerFabricModules(modules) {
|
|
318
|
+
return validateAndOrderFabricModules(modules);
|
|
319
|
+
}
|
|
320
|
+
function registerFabricModule(module) {
|
|
321
|
+
validateAndOrderFabricModules([module]);
|
|
379
322
|
}
|
|
380
323
|
|
|
381
|
-
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace };
|
|
382
|
-
//# sourceMappingURL=chunk-
|
|
383
|
-
//# sourceMappingURL=chunk-
|
|
324
|
+
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateAndOrderFabricModules, validateModuleNamespace };
|
|
325
|
+
//# sourceMappingURL=chunk-T5ESIJ4K.js.map
|
|
326
|
+
//# sourceMappingURL=chunk-T5ESIJ4K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../modules/index.ts"],"names":[],"mappings":";;;;;AAqJO,SAAS,6BAA6B,UAAA,EAA2C;AACvF,EAAA,OAAO,OAAO,UAAA,KAAe,QAAA,GAAW,UAAA,GAAa,UAAA,CAAW,SAAA;AACjE;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AAM,EAAE,CAAA;AAAA,EAChD;AACD;AAEO,SAAS,8BAA6C,OAAA,EAAmD;AAC/G,EAAA,MAAM,mBAAA,GAAsB,IAAI,GAAA,CAAI,OAAA,CAAQ,IAAI,CAAC,MAAA,KAAW,MAAA,CAAO,SAAS,CAAC,CAAA;AAC7E,EAAA,MAAM,oBAAoB,IAAI,GAAA;AAAA,IAC7B,OAAA,CAAQ,OAAA,CAAQ,CAAC,MAAA,KAAA,CAAY,MAAA,CAAO,cAAc,EAAC,EAAG,GAAA,CAAI,gBAAgB,CAAC;AAAA,GAC5E;AACA,EAAA,KAAA,MAAW,aAAa,2BAAA,EAA4B,CAAE,YAAW,EAAG,iBAAA,CAAkB,IAAI,SAAS,CAAA;AACnG,EAAA,MAAM,oBAAA,uBAA2B,GAAA,CAAI;AAAA,IACpC,GAAG,OAAA,CAAQ,OAAA;AAAA,MAAQ,CAAC,MAAA,KAAA,CAClB,MAAA,CAAO,WAAA,IAAe,EAAC,EAAG,GAAA,CAAI,CAAC,UAAA,KAAe,oBAAoB,MAAA,CAAO,SAAA,EAAW,iBAAA,CAAkB,UAAU,CAAC,CAAC;AAAA;AACpH,GACA,CAAA;AAED,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC7B,IAAA,gBAAA,CAAiB,MAAA,EAAiC,EAAE,mBAAA,EAAqB,iBAAA,EAAmB,sBAAsB,CAAA;AAAA,EACnH;AACA,EAAA,sBAAA,CAAuB,OAAkC,CAAA;AACzD,EAAA,OAAO,wBAAwB,OAAkC,CAAA;AAClE;AAGO,SAAS,sBAAqC,OAAA,EAAmD;AACvG,EAAA,OAAO,8BAA8B,OAAO,CAAA;AAC7C;AAGO,SAAS,qBAAoC,MAAA,EAAiC;AACpF,EAAA,6BAAA,CAA8B,CAAC,MAAM,CAAC,CAAA;AACvC","file":"chunk-T5ESIJ4K.js","sourcesContent":["import type { ActionDefinition } from \"../actions\";\nimport { createEventContractRegistry } from \"../events\";\nimport {\n\tassertPortableJsonSchema,\n\ttype JsonValue,\n\ttype PortableJsonSchema,\n} from \"../objects\";\nimport type { PolicyEvaluator, PolicyId } from \"../policies\";\nimport type { StateMachineDefinition } from \"../state-machines\";\nimport { viewContractKey, 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\tschema?: PortableJsonSchema;\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 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 CapabilityPortRequirement {\n\tname: string;\n\tversion?: string;\n\tstandard?: { name: string; version?: string };\n}\n\nexport interface CapabilityRequirements {\n\tports?: CapabilityPortRequirement[];\n\tpermissions?: string[];\n\tentitlements?: string[];\n\tfeatureFlags?: string[];\n}\n\nexport interface CapabilityMetadata {\n\tdisplayName: string;\n\tdescription: string;\n\tstability: \"experimental\" | \"beta\" | \"stable\" | \"deprecated\";\n\tdeprecated?: { since: string; replacement?: string; message: string };\n\trequirements?: CapabilityRequirements;\n\tcertification?: { profile: string; required: boolean };\n\t/** Namespaced declared data preserved by Platform and interpreted only by its owning package. */\n\textensions?: Record<string, JsonValue>;\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\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\torderedModules: readonly FabricModule<TDb>[];\n\tresolveAction(actionId: `${string}.${string}`): ActionDefinition<TDb> | undefined;\n\tresolvePolicy(policyId: PolicyId): PolicyEvaluator | undefined;\n\tresolveStateMachine(entityType: string): StateMachineDefinition | undefined;\n\tresolveView(name: string, version: string): ViewContract | undefined;\n}\n\ninterface ModuleValidationContext {\n\tavailableNamespaces?: Set<string>;\n\tplannedEventTypes?: Set<string>;\n\tavailableObjectTypes?: Set<string>;\n}\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 orderedModules = validateAndOrderFabricModules(modules);\n\tconst registered = new Map(orderedModules.map((module) => [module.namespace, module]));\n\tconst actions = new Map(orderedModules.flatMap((module) => (module.actions ?? []).map((action) => [action.actionId, action] as const)));\n\tconst policies = new Map(orderedModules.flatMap((module) => (module.policies ?? []).map((policy) => {\n\t\tconst evaluator = policy as PolicyEvaluator;\n\t\treturn [evaluator.policyId, evaluator] as const;\n\t})));\n\tconst machines = new Map(orderedModules.flatMap((module) => (module.stateMachines ?? []).map((machine) => {\n\t\tconst definition = machine as StateMachineDefinition;\n\t\treturn [definition.entityType, definition] as const;\n\t})));\n\tconst views = new Map(orderedModules.flatMap((module) => (module.views ?? []).map((view) => [viewContractKey(view), view] as const)));\n\treturn {\n\t\tmodules: registered,\n\t\torderedModules,\n\t\tresolveAction: (actionId) => actions.get(actionId),\n\t\tresolvePolicy: (policyId) => policies.get(policyId),\n\t\tresolveStateMachine: (entityType) => machines.get(entityType),\n\t\tresolveView: (name, version) => views.get(`${name}@${version}`),\n\t};\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\tfor (const namespace of Object.keys(module.capability.extensions ?? {})) {\n\t\t\tif (!/^[a-z][a-z0-9.-]*\\.[a-z0-9.-]+\\/v[1-9][0-9]*$/.test(namespace)) {\n\t\t\t\tthrow new Error(`Module \"${module.namespace}\" capability has invalid extension namespace \"${namespace}\".`);\n\t\t\t}\n\t\t}\n\t\tfor (const port of module.capability.requirements?.ports ?? []) {\n\t\t\tif (!/^[a-z][a-z0-9-]*$/.test(port.name)) throw new Error(`Module \"${module.namespace}\" capability has invalid port requirement \"${port.name}\".`);\n\t\t}\n\t}\n\tfor (const eventType of module.eventTypes ?? []) if (typeof eventType !== \"string\" && eventType.schema) assertPortableJsonSchema(eventType.schema, `Event \"${eventType.eventType}\" schema`);\n\tfor (const action of module.actions ?? []) {\n\t\tif (action.execution?.idempotency === \"required\" && !action.idempotent) throw new Error(`Action \"${action.actionId}\" requires idempotency but is not declared idempotent.`);\n\t\tif (action.execution?.connectivity === \"offline-capturable\" && action.execution.idempotency === \"prohibited\") throw new Error(`Offline action \"${action.actionId}\" cannot prohibit idempotency.`);\n\t}\n\tfor (const view of module.views ?? []) if (view.usage?.collection?.filterSchema) assertPortableJsonSchema(view.usage.collection.filterSchema, `View \"${view.name}\" filter schema`);\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\tif (typeof objectType !== \"string\") {\n\t\t\tfor (const relation of objectType.relations ?? []) {\n\t\t\t\tconst targetNamespace = relation.target.slice(0, relation.target.indexOf(\".\"));\n\t\t\t\tif (targetNamespace !== module.namespace && !dependencies.includes(targetNamespace)) {\n\t\t\t\t\tthrow new Error(`Module \"${module.namespace}\" relation \"${relation.name}\" targets module \"${targetNamespace}\" without declaring it as a dependency.`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateObjectDefinition(objectType, module.namespace, context);\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tlet parameterSchema: unknown;\n\t\ttry { parameterSchema = (action.schema as { toJSONSchema?: () => unknown }).toJSONSchema?.(); } catch { parameterSchema = undefined; }\n\t\tif (parameterSchema !== undefined) assertPortableJsonSchema(parameterSchema, `Action \"${action.actionId}\" parameters`);\n\t\tlet resultSchema: unknown;\n\t\ttry { resultSchema = (action.resultSchema as { toJSONSchema?: () => unknown } | undefined)?.toJSONSchema?.(); } catch { resultSchema = undefined; }\n\t\tif (resultSchema !== undefined) assertPortableJsonSchema(resultSchema, `Action \"${action.actionId}\" result`);\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\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 (!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: ReadonlySet<string> = new Set(),\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 FabricModule 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 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\nexport function validateAndOrderFabricModules<TDb = unknown>(modules: FabricModule<TDb>[]): FabricModule<TDb>[] {\n\tconst availableNamespaces = new Set(modules.map((module) => module.namespace));\n\tconst plannedEventTypes = new Set(\n\t\tmodules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName)),\n\t);\n\tfor (const eventType of createEventContractRegistry().eventTypes()) plannedEventTypes.add(eventType);\n\tconst availableObjectTypes = new Set([\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 as FabricModule<unknown>, { availableNamespaces, plannedEventTypes, availableObjectTypes });\n\t}\n\tassertAcyclicRelations(modules as FabricModule<unknown>[]);\n\treturn sortModulesByDependency(modules as FabricModule<unknown>[]) as FabricModule<TDb>[];\n}\n\n/** @deprecated Use createModuleRegistry(); registration is now explicit and instance-scoped. */\nexport function registerFabricModules<TDb = unknown>(modules: FabricModule<TDb>[]): FabricModule<TDb>[] {\n\treturn validateAndOrderFabricModules(modules);\n}\n\n/** @deprecated Use createModuleRegistry([module]); registration is now explicit and instance-scoped. */\nexport function registerFabricModule<TDb = unknown>(module: FabricModule<TDb>): void {\n\tvalidateAndOrderFabricModules([module]);\n}\n"]}
|
|
@@ -90,14 +90,14 @@ var DATA_POLICY_MAX_CONDITIONS_PER_NODE = 20;
|
|
|
90
90
|
var DATA_POLICY_MAX_TOTAL_CONDITIONS = 100;
|
|
91
91
|
var DATA_POLICY_MAX_PATH_SEGMENTS = 12;
|
|
92
92
|
var DATA_POLICY_MAX_STRING_LENGTH = 500;
|
|
93
|
-
var DATA_POLICY_CONTEXT_PATHS =
|
|
93
|
+
var DATA_POLICY_CONTEXT_PATHS = Object.freeze([
|
|
94
94
|
"tenantId",
|
|
95
95
|
"spaceId",
|
|
96
96
|
"actionInvocationId",
|
|
97
97
|
"actionId",
|
|
98
98
|
"mode"
|
|
99
99
|
]);
|
|
100
|
-
var DATA_POLICY_COMPARISON_OPERATORS =
|
|
100
|
+
var DATA_POLICY_COMPARISON_OPERATORS = Object.freeze([
|
|
101
101
|
"exists",
|
|
102
102
|
"equals",
|
|
103
103
|
"notEquals",
|
|
@@ -106,35 +106,26 @@ var DATA_POLICY_COMPARISON_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
106
106
|
"lt",
|
|
107
107
|
"lte"
|
|
108
108
|
]);
|
|
109
|
-
var POLICY_RESULTS =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
throw new Error(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
`Conflicting policy registration for "${evaluator.policyId}". A different evaluator is already registered.`
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function resolvePolicy(policyId) {
|
|
134
|
-
return registry.get(policyId);
|
|
135
|
-
}
|
|
136
|
-
function getRegisteredPolicyIds() {
|
|
137
|
-
return Array.from(registry.keys());
|
|
109
|
+
var POLICY_RESULTS = Object.freeze(["pass", "warn", "block"]);
|
|
110
|
+
function createPolicyRegistry(evaluators = []) {
|
|
111
|
+
const policies = /* @__PURE__ */ new Map();
|
|
112
|
+
const register = (evaluator) => {
|
|
113
|
+
assertPolicyId(evaluator.policyId);
|
|
114
|
+
const existing = policies.get(evaluator.policyId);
|
|
115
|
+
if (existing && existing !== evaluator) throw new Error(`Conflicting policy registration for "${evaluator.policyId}". A different evaluator is already registered.`);
|
|
116
|
+
policies.set(evaluator.policyId, evaluator);
|
|
117
|
+
};
|
|
118
|
+
for (const evaluator of evaluators) register(evaluator);
|
|
119
|
+
return {
|
|
120
|
+
register,
|
|
121
|
+
registerIfMissing(evaluator) {
|
|
122
|
+
const existing = policies.get(evaluator.policyId);
|
|
123
|
+
if (!existing) register(evaluator);
|
|
124
|
+
else if (existing !== evaluator) throw new Error(`Conflicting policy registration for "${evaluator.policyId}". A different evaluator is already registered.`);
|
|
125
|
+
},
|
|
126
|
+
resolve: (policyId) => policies.get(policyId),
|
|
127
|
+
ids: () => Array.from(policies.keys())
|
|
128
|
+
};
|
|
138
129
|
}
|
|
139
130
|
async function evaluateRegisteredPolicies(policyIds, ctx) {
|
|
140
131
|
return evaluatePolicyDefinitions(
|
|
@@ -166,7 +157,7 @@ async function evaluatePolicyDefinition(policy, ctx) {
|
|
|
166
157
|
}
|
|
167
158
|
async function evaluateCodePolicy(policy, ctx) {
|
|
168
159
|
const codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId ?? policy.policyId;
|
|
169
|
-
const evaluator =
|
|
160
|
+
const evaluator = ctx.resolveCodePolicy?.(codeEvaluatorPolicyId);
|
|
170
161
|
if (!evaluator) {
|
|
171
162
|
return {
|
|
172
163
|
policyId: policy.policyId,
|
|
@@ -394,7 +385,7 @@ function validateDataPolicyDefinition(definition) {
|
|
|
394
385
|
`conditions must contain at most ${DATA_POLICY_MAX_CONDITIONS_PER_NODE} top-level conditions`
|
|
395
386
|
);
|
|
396
387
|
}
|
|
397
|
-
if (definition.defaultResult && !POLICY_RESULTS.
|
|
388
|
+
if (definition.defaultResult && !POLICY_RESULTS.includes(definition.defaultResult)) {
|
|
398
389
|
errors.push("defaultResult must be pass, warn, or block");
|
|
399
390
|
}
|
|
400
391
|
let totalConditions = 0;
|
|
@@ -427,7 +418,7 @@ function validateDataPolicyCondition(condition, errors, depth, count) {
|
|
|
427
418
|
errors.push(`condition ${condition.conditionId} reason must be a bounded string`);
|
|
428
419
|
}
|
|
429
420
|
if (condition.type === "always") {
|
|
430
|
-
if (!POLICY_RESULTS.
|
|
421
|
+
if (!POLICY_RESULTS.includes(condition.result)) {
|
|
431
422
|
errors.push(`condition ${condition.conditionId} result must be pass, warn, or block`);
|
|
432
423
|
}
|
|
433
424
|
return;
|
|
@@ -464,7 +455,7 @@ function validateDataPolicyCondition(condition, errors, depth, count) {
|
|
|
464
455
|
errors.push(`condition ${condition.conditionId} has unsupported type`);
|
|
465
456
|
}
|
|
466
457
|
function validateOptionalPolicyResult(result, fieldName, errors) {
|
|
467
|
-
if (result !== void 0 && !POLICY_RESULTS.
|
|
458
|
+
if (result !== void 0 && !POLICY_RESULTS.includes(result)) {
|
|
468
459
|
errors.push(`${fieldName} must be pass, warn, or block`);
|
|
469
460
|
}
|
|
470
461
|
}
|
|
@@ -477,12 +468,12 @@ function validateSourceReference(reference, conditionId, errors) {
|
|
|
477
468
|
errors.push(`condition ${conditionId} source must be parameters or context`);
|
|
478
469
|
}
|
|
479
470
|
validatePath(reference.path, `condition ${conditionId} left.path`, errors);
|
|
480
|
-
if (reference.source === "context" && !DATA_POLICY_CONTEXT_PATHS.
|
|
471
|
+
if (reference.source === "context" && !DATA_POLICY_CONTEXT_PATHS.includes(reference.path)) {
|
|
481
472
|
errors.push(`condition ${conditionId} uses an unsupported context path`);
|
|
482
473
|
}
|
|
483
474
|
}
|
|
484
475
|
function validateComparison(operator, value, conditionId, errors) {
|
|
485
|
-
if (!DATA_POLICY_COMPARISON_OPERATORS.
|
|
476
|
+
if (!DATA_POLICY_COMPARISON_OPERATORS.includes(operator)) {
|
|
486
477
|
errors.push(`condition ${conditionId} has unsupported operator`);
|
|
487
478
|
return;
|
|
488
479
|
}
|
|
@@ -660,14 +651,11 @@ function aggregatePolicyOutcomes(outcomes) {
|
|
|
660
651
|
|
|
661
652
|
exports.aggregatePolicyOutcomes = aggregatePolicyOutcomes;
|
|
662
653
|
exports.assertPolicyId = assertPolicyId;
|
|
654
|
+
exports.createPolicyRegistry = createPolicyRegistry;
|
|
663
655
|
exports.evaluatePolicyDefinition = evaluatePolicyDefinition;
|
|
664
656
|
exports.evaluatePolicyDefinitions = evaluatePolicyDefinitions;
|
|
665
657
|
exports.evaluateRegisteredPolicies = evaluateRegisteredPolicies;
|
|
666
|
-
exports.getRegisteredPolicyIds = getRegisteredPolicyIds;
|
|
667
|
-
exports.registerPolicy = registerPolicy;
|
|
668
|
-
exports.registerPolicyIfMissing = registerPolicyIfMissing;
|
|
669
|
-
exports.resolvePolicy = resolvePolicy;
|
|
670
658
|
exports.validateDataPolicyDefinition = validateDataPolicyDefinition;
|
|
671
659
|
exports.validatePolicyGuidance = validatePolicyGuidance;
|
|
672
|
-
//# sourceMappingURL=chunk-
|
|
673
|
-
//# sourceMappingURL=chunk-
|
|
660
|
+
//# sourceMappingURL=chunk-VZ6C4LXC.cjs.map
|
|
661
|
+
//# sourceMappingURL=chunk-VZ6C4LXC.cjs.map
|