@fabricorg/platform 0.12.1 → 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.
Files changed (110) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +7 -8
  3. package/dist/actions/index.cjs +7 -27
  4. package/dist/actions/index.d.cts +9 -7
  5. package/dist/actions/index.d.ts +9 -7
  6. package/dist/actions/index.js +1 -1
  7. package/dist/{chunk-LAZL2GDT.cjs → chunk-35LADVKK.cjs} +48 -104
  8. package/dist/chunk-35LADVKK.cjs.map +1 -0
  9. package/dist/chunk-4QOA3VU5.js +47 -0
  10. package/dist/chunk-4QOA3VU5.js.map +1 -0
  11. package/dist/chunk-53VEUYCS.cjs +40 -0
  12. package/dist/chunk-53VEUYCS.cjs.map +1 -0
  13. package/dist/{chunk-X7WC4AYC.js → chunk-ATWWZTRC.js} +32 -74
  14. package/dist/chunk-ATWWZTRC.js.map +1 -0
  15. package/dist/chunk-BFQNKQJE.cjs +53 -0
  16. package/dist/{chunk-4RMKUYRX.js.map → chunk-BFQNKQJE.cjs.map} +1 -1
  17. package/dist/{chunk-OC4ZFJKD.cjs → chunk-CBY6GRJP.cjs} +16 -17
  18. package/dist/chunk-CBY6GRJP.cjs.map +1 -0
  19. package/dist/chunk-CQSA3BII.js +38 -0
  20. package/dist/chunk-CQSA3BII.js.map +1 -0
  21. package/dist/{chunk-HL77HWWP.js → chunk-CRAGTJ3B.js} +3 -3
  22. package/dist/{chunk-HL77HWWP.js.map → chunk-CRAGTJ3B.js.map} +1 -1
  23. package/dist/{chunk-FSUYD4F4.js → chunk-J5LS5BSI.js} +19 -17
  24. package/dist/chunk-J5LS5BSI.js.map +1 -0
  25. package/dist/{chunk-ZZGSS65W.cjs → chunk-JFMNLJLY.cjs} +6 -6
  26. package/dist/{chunk-ZZGSS65W.cjs.map → chunk-JFMNLJLY.cjs.map} +1 -1
  27. package/dist/{chunk-6ER62UUN.js → chunk-JFVEPAED.js} +31 -40
  28. package/dist/chunk-JFVEPAED.js.map +1 -0
  29. package/dist/{chunk-7SHNYYGI.cjs → chunk-M5FGWXT3.cjs} +19 -20
  30. package/dist/chunk-M5FGWXT3.cjs.map +1 -0
  31. package/dist/{chunk-4MMMXV4Q.js → chunk-NETLRKDS.js} +16 -15
  32. package/dist/chunk-NETLRKDS.js.map +1 -0
  33. package/dist/chunk-OWSSGFNY.js +45 -0
  34. package/dist/chunk-OWSSGFNY.js.map +1 -0
  35. package/dist/{chunk-35SDMFCR.js → chunk-T5ESIJ4K.js} +42 -99
  36. package/dist/chunk-T5ESIJ4K.js.map +1 -0
  37. package/dist/{chunk-NJL3US7H.cjs → chunk-VZ6C4LXC.cjs} +31 -43
  38. package/dist/chunk-VZ6C4LXC.cjs.map +1 -0
  39. package/dist/chunk-WAI4UNWQ.cjs +48 -0
  40. package/dist/chunk-WAI4UNWQ.cjs.map +1 -0
  41. package/dist/{chunk-YQEXO3IQ.cjs → chunk-X3GHYMAJ.cjs} +32 -74
  42. package/dist/chunk-X3GHYMAJ.cjs.map +1 -0
  43. package/dist/events/index.cjs +3 -27
  44. package/dist/events/index.d.cts +13 -13
  45. package/dist/events/index.d.ts +13 -13
  46. package/dist/events/index.js +1 -1
  47. package/dist/index.cjs +88 -193
  48. package/dist/index.d.cts +8 -9
  49. package/dist/index.d.ts +8 -9
  50. package/dist/index.js +10 -11
  51. package/dist/manifest/index.cjs +11 -15
  52. package/dist/manifest/index.d.cts +0 -1
  53. package/dist/manifest/index.d.ts +0 -1
  54. package/dist/manifest/index.js +5 -9
  55. package/dist/modules/index.cjs +15 -15
  56. package/dist/modules/index.d.cts +16 -23
  57. package/dist/modules/index.d.ts +16 -23
  58. package/dist/modules/index.js +4 -8
  59. package/dist/objects/index.cjs +5 -13
  60. package/dist/objects/index.d.cts +7 -4
  61. package/dist/objects/index.d.ts +7 -4
  62. package/dist/objects/index.js +1 -1
  63. package/dist/policies/index.cjs +12 -24
  64. package/dist/policies/index.d.cts +10 -5
  65. package/dist/policies/index.d.ts +10 -5
  66. package/dist/policies/index.js +1 -1
  67. package/dist/privacy/index.cjs +10 -10
  68. package/dist/privacy/index.d.cts +16 -5
  69. package/dist/privacy/index.d.ts +16 -5
  70. package/dist/privacy/index.js +1 -1
  71. package/dist/projections/index.cjs +6 -18
  72. package/dist/projections/index.d.cts +8 -5
  73. package/dist/projections/index.d.ts +8 -5
  74. package/dist/projections/index.js +1 -1
  75. package/dist/state-machines/index.cjs +5 -21
  76. package/dist/state-machines/index.d.cts +17 -31
  77. package/dist/state-machines/index.d.ts +17 -31
  78. package/dist/state-machines/index.js +1 -1
  79. package/package.json +1 -11
  80. package/dist/chunk-35SDMFCR.js.map +0 -1
  81. package/dist/chunk-3O4GMCCE.js +0 -55
  82. package/dist/chunk-3O4GMCCE.js.map +0 -1
  83. package/dist/chunk-4MMMXV4Q.js.map +0 -1
  84. package/dist/chunk-4RMKUYRX.js +0 -59
  85. package/dist/chunk-6ER62UUN.js.map +0 -1
  86. package/dist/chunk-7RV5REPT.cjs +0 -63
  87. package/dist/chunk-7RV5REPT.cjs.map +0 -1
  88. package/dist/chunk-7SHNYYGI.cjs.map +0 -1
  89. package/dist/chunk-EO4VSB2O.cjs +0 -99
  90. package/dist/chunk-EO4VSB2O.cjs.map +0 -1
  91. package/dist/chunk-FSUYD4F4.js.map +0 -1
  92. package/dist/chunk-JOATYJXQ.cjs +0 -70
  93. package/dist/chunk-JOATYJXQ.cjs.map +0 -1
  94. package/dist/chunk-LAZL2GDT.cjs.map +0 -1
  95. package/dist/chunk-NJL3US7H.cjs.map +0 -1
  96. package/dist/chunk-O5WVBQ7P.js +0 -89
  97. package/dist/chunk-O5WVBQ7P.js.map +0 -1
  98. package/dist/chunk-OC4ZFJKD.cjs.map +0 -1
  99. package/dist/chunk-T2JLSZN6.js +0 -67
  100. package/dist/chunk-T2JLSZN6.js.map +0 -1
  101. package/dist/chunk-UV252FLT.cjs +0 -74
  102. package/dist/chunk-UV252FLT.cjs.map +0 -1
  103. package/dist/chunk-X7WC4AYC.js.map +0 -1
  104. package/dist/chunk-YQEXO3IQ.cjs.map +0 -1
  105. package/dist/displays/index.cjs +0 -24
  106. package/dist/displays/index.cjs.map +0 -1
  107. package/dist/displays/index.d.cts +0 -34
  108. package/dist/displays/index.d.ts +0 -34
  109. package/dist/displays/index.js +0 -3
  110. package/dist/displays/index.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @fabricorg/platform
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Make the capability runtime vertical-neutral and instance-scoped. Move experience and display
8
+ semantics into a namespaced companion package, require explicit host registries, replace privacy
9
+ field defaults with caller-owned policy, add PostgreSQL projection adapters, and generate executable
10
+ ProjectionHost read and PlatformHost mutation seams.
11
+
3
12
  ## 0.12.1
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -48,10 +48,9 @@ That's what this package gives you. Nothing more.
48
48
  | `@fabricorg/platform/events` | `AssetEventEnvelope`, `EventTypeRegistry` |
49
49
  | `@fabricorg/platform/projections` | Replay/snapshot framework |
50
50
  | `@fabricorg/platform/adapters` | `AdapterRegistry`, retry + circuit-breaker |
51
- | `@fabricorg/platform/modules` | `FabricModule<TDb>`, `registerFabricModules` |
51
+ | `@fabricorg/platform/modules` | `FabricModule<TDb>`, `createModuleRegistry` |
52
52
  | `@fabricorg/platform/manifest` | `exportModuleManifest`, `exportModuleManifestBundle`, `ModuleManifest` |
53
53
  | `@fabricorg/platform/ids` | `createFabricId`, `FABRIC_ID_PREFIXES` |
54
- | `@fabricorg/platform/displays` | `DisplayRendererRegistration` |
55
54
  | `@fabricorg/platform/privacy` | Redaction + data classification |
56
55
  | `@fabricorg/platform/evidence` | Compliance evidence packets |
57
56
  | `@fabricorg/platform/governance` | External footprints, delegated principals, obligations, attestations, and reconciliation |
@@ -69,7 +68,7 @@ Verticals declare a `FabricModule<TDb>` that registers their actions, policies,
69
68
 
70
69
  ```ts
71
70
  import type { FabricModule } from "@fabricorg/platform/modules";
72
- import { registerFabricModules } from "@fabricorg/platform/modules";
71
+ import { createModuleRegistry } from "@fabricorg/platform/modules";
73
72
 
74
73
  const myModule: FabricModule<MyDbClient> = {
75
74
  namespace: "demo",
@@ -78,14 +77,13 @@ const myModule: FabricModule<MyDbClient> = {
78
77
  actions: [greet, /* ... */],
79
78
  policies: [/* ... */],
80
79
  stateMachines: [/* ... */],
81
- displayRenderers: [],
82
80
  };
83
81
 
84
82
  // At app startup:
85
- registerFabricModules([myModule]);
83
+ const registry = createModuleRegistry([myModule]);
86
84
  ```
87
85
 
88
- The platform never auto-loads a module. The host app composes them explicitly — no implicit defaults, no globals, no surprises.
86
+ The platform never auto-loads a module. The host app composes an instance-scoped registry and injects it into its hosts. Experience roles, slots, action intents, and display rendering live in `@fabricorg/experience-contracts`, carried through the namespaced `fabric.experience/v1` extension.
89
87
 
90
88
  ## Exporting a module manifest
91
89
 
@@ -140,11 +138,12 @@ Your worker maps action IDs to implementations. The platform dispatches generica
140
138
 
141
139
  ## Portability boundary
142
140
 
143
- The `boundary.test.ts` in this package fails CI if any of these leak in:
141
+ The repository Boundary Guard scans source and packed artifacts and fails CI if any of these leak in:
144
142
 
145
143
  - Concrete database/ORM imports — the literal `Prisma`, the field name `prisma:`, or the type default `TDb = any`
146
- - Vertical vocabulary (`lending.`, `borrower`, `lender`, `Vehicle`, `Party`, `Obligation`, `Offer`, etc.)
144
+ - Vertical vocabulary from the governed denylist
147
145
  - "Register default" hooks (`registerDefaultPolicies`, etc.) — the platform never auto-loads anything
146
+ - Module-scope mutable registries, import-time environment reads, or unapproved infrastructure imports
148
147
 
149
148
  This is what keeps the platform portable across verticals and consumers. If you fork or add new patterns specific to your domain, extend the list in `boundary.test.ts`.
150
149
 
@@ -1,48 +1,28 @@
1
1
  'use strict';
2
2
 
3
- var chunkJOATYJXQ_cjs = require('../chunk-JOATYJXQ.cjs');
3
+ var chunkBFQNKQJE_cjs = require('../chunk-BFQNKQJE.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "ACTOR_TYPES", {
8
8
  enumerable: true,
9
- get: function () { return chunkJOATYJXQ_cjs.ACTOR_TYPES; }
9
+ get: function () { return chunkBFQNKQJE_cjs.ACTOR_TYPES; }
10
10
  });
11
11
  Object.defineProperty(exports, "assertActionId", {
12
12
  enumerable: true,
13
- get: function () { return chunkJOATYJXQ_cjs.assertActionId; }
13
+ get: function () { return chunkBFQNKQJE_cjs.assertActionId; }
14
14
  });
15
15
  Object.defineProperty(exports, "assertActorType", {
16
16
  enumerable: true,
17
- get: function () { return chunkJOATYJXQ_cjs.assertActorType; }
17
+ get: function () { return chunkBFQNKQJE_cjs.assertActorType; }
18
18
  });
19
- Object.defineProperty(exports, "getRegisteredActionIds", {
19
+ Object.defineProperty(exports, "createActionRegistry", {
20
20
  enumerable: true,
21
- get: function () { return chunkJOATYJXQ_cjs.getRegisteredActionIds; }
21
+ get: function () { return chunkBFQNKQJE_cjs.createActionRegistry; }
22
22
  });
23
23
  Object.defineProperty(exports, "isActorType", {
24
24
  enumerable: true,
25
- get: function () { return chunkJOATYJXQ_cjs.isActorType; }
26
- });
27
- Object.defineProperty(exports, "isRegisteredActionId", {
28
- enumerable: true,
29
- get: function () { return chunkJOATYJXQ_cjs.isRegisteredActionId; }
30
- });
31
- Object.defineProperty(exports, "registerAction", {
32
- enumerable: true,
33
- get: function () { return chunkJOATYJXQ_cjs.registerAction; }
34
- });
35
- Object.defineProperty(exports, "registerActionIfMissing", {
36
- enumerable: true,
37
- get: function () { return chunkJOATYJXQ_cjs.registerActionIfMissing; }
38
- });
39
- Object.defineProperty(exports, "resolveAction", {
40
- enumerable: true,
41
- get: function () { return chunkJOATYJXQ_cjs.resolveAction; }
42
- });
43
- Object.defineProperty(exports, "resolveRegisteredAction", {
44
- enumerable: true,
45
- get: function () { return chunkJOATYJXQ_cjs.resolveRegisteredAction; }
25
+ get: function () { return chunkBFQNKQJE_cjs.isActorType; }
46
26
  });
47
27
  //# sourceMappingURL=index.cjs.map
48
28
  //# sourceMappingURL=index.cjs.map
@@ -159,11 +159,13 @@ interface SagaCompletion {
159
159
  }
160
160
  type SagaImplementation = (ctx: SagaContext, runChild: SagaRunChild) => Promise<SagaCompletion>;
161
161
  declare function assertActionId(actionId: string): asserts actionId is ActionId;
162
- declare function registerAction(definition: ActionDefinition): void;
163
- declare function resolveAction(actionId: ActionId): ActionDefinition | undefined;
164
- declare function isRegisteredActionId(actionId: string): actionId is ActionId;
165
- declare function resolveRegisteredAction(actionId: string): ActionDefinition | undefined;
166
- declare function getRegisteredActionIds(): ActionId[];
167
- declare function registerActionIfMissing(definition: ActionDefinition): void;
162
+ interface ActionRegistry<TDb = unknown> {
163
+ register(definition: ActionDefinition<TDb>): void;
164
+ registerIfMissing(definition: ActionDefinition<TDb>): void;
165
+ resolve(actionId: ActionId): ActionDefinition<TDb> | undefined;
166
+ has(actionId: string): actionId is ActionId;
167
+ ids(): ActionId[];
168
+ }
169
+ declare function createActionRegistry<TDb = unknown>(definitions?: readonly ActionDefinition<TDb>[]): ActionRegistry<TDb>;
168
170
 
169
- export { ACTOR_TYPES, type ActionCompletionMode, type ActionConnectivity, type ActionConsistency, type ActionContext, type ActionDataSensitivity, type ActionDefinition, type ActionExecutionContract, type ActionHandler, type ActionId, type ActionIdempotencyStance, type ActionResult, type ActionStateMachineBinding, type ActionStatus, type ActorType, type AdapterStep, type AdapterStepRetryPolicy, type AuthorityMoment, type FabricRuntimeServices, type SagaChildActionInput, type SagaCompletion, type SagaCompletionEvent, type SagaContext, type SagaImplementation, type SagaRunChild, type SchemaParseIssue, type SchemaParseResult, type SchemaValidator, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction };
171
+ export { ACTOR_TYPES, type ActionCompletionMode, type ActionConnectivity, type ActionConsistency, type ActionContext, type ActionDataSensitivity, type ActionDefinition, type ActionExecutionContract, type ActionHandler, type ActionId, type ActionIdempotencyStance, type ActionRegistry, type ActionResult, type ActionStateMachineBinding, type ActionStatus, type ActorType, type AdapterStep, type AdapterStepRetryPolicy, type AuthorityMoment, type FabricRuntimeServices, type SagaChildActionInput, type SagaCompletion, type SagaCompletionEvent, type SagaContext, type SagaImplementation, type SagaRunChild, type SchemaParseIssue, type SchemaParseResult, type SchemaValidator, assertActionId, assertActorType, createActionRegistry, isActorType };
@@ -159,11 +159,13 @@ interface SagaCompletion {
159
159
  }
160
160
  type SagaImplementation = (ctx: SagaContext, runChild: SagaRunChild) => Promise<SagaCompletion>;
161
161
  declare function assertActionId(actionId: string): asserts actionId is ActionId;
162
- declare function registerAction(definition: ActionDefinition): void;
163
- declare function resolveAction(actionId: ActionId): ActionDefinition | undefined;
164
- declare function isRegisteredActionId(actionId: string): actionId is ActionId;
165
- declare function resolveRegisteredAction(actionId: string): ActionDefinition | undefined;
166
- declare function getRegisteredActionIds(): ActionId[];
167
- declare function registerActionIfMissing(definition: ActionDefinition): void;
162
+ interface ActionRegistry<TDb = unknown> {
163
+ register(definition: ActionDefinition<TDb>): void;
164
+ registerIfMissing(definition: ActionDefinition<TDb>): void;
165
+ resolve(actionId: ActionId): ActionDefinition<TDb> | undefined;
166
+ has(actionId: string): actionId is ActionId;
167
+ ids(): ActionId[];
168
+ }
169
+ declare function createActionRegistry<TDb = unknown>(definitions?: readonly ActionDefinition<TDb>[]): ActionRegistry<TDb>;
168
170
 
169
- export { ACTOR_TYPES, type ActionCompletionMode, type ActionConnectivity, type ActionConsistency, type ActionContext, type ActionDataSensitivity, type ActionDefinition, type ActionExecutionContract, type ActionHandler, type ActionId, type ActionIdempotencyStance, type ActionResult, type ActionStateMachineBinding, type ActionStatus, type ActorType, type AdapterStep, type AdapterStepRetryPolicy, type AuthorityMoment, type FabricRuntimeServices, type SagaChildActionInput, type SagaCompletion, type SagaCompletionEvent, type SagaContext, type SagaImplementation, type SagaRunChild, type SchemaParseIssue, type SchemaParseResult, type SchemaValidator, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction };
171
+ export { ACTOR_TYPES, type ActionCompletionMode, type ActionConnectivity, type ActionConsistency, type ActionContext, type ActionDataSensitivity, type ActionDefinition, type ActionExecutionContract, type ActionHandler, type ActionId, type ActionIdempotencyStance, type ActionRegistry, type ActionResult, type ActionStateMachineBinding, type ActionStatus, type ActorType, type AdapterStep, type AdapterStepRetryPolicy, type AuthorityMoment, type FabricRuntimeServices, type SagaChildActionInput, type SagaCompletion, type SagaCompletionEvent, type SagaContext, type SagaImplementation, type SagaRunChild, type SchemaParseIssue, type SchemaParseResult, type SchemaValidator, assertActionId, assertActorType, createActionRegistry, isActorType };
@@ -1,3 +1,3 @@
1
- export { ACTOR_TYPES, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction } from '../chunk-4RMKUYRX.js';
1
+ export { ACTOR_TYPES, assertActionId, assertActorType, createActionRegistry, isActorType } from '../chunk-4QOA3VU5.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -1,17 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkOC4ZFJKD_cjs = require('./chunk-OC4ZFJKD.cjs');
4
- var chunkNJL3US7H_cjs = require('./chunk-NJL3US7H.cjs');
5
- var chunk7SHNYYGI_cjs = require('./chunk-7SHNYYGI.cjs');
6
- var chunkUV252FLT_cjs = require('./chunk-UV252FLT.cjs');
7
- var chunkJOATYJXQ_cjs = require('./chunk-JOATYJXQ.cjs');
8
- var chunkEO4VSB2O_cjs = require('./chunk-EO4VSB2O.cjs');
9
- var chunk7RV5REPT_cjs = require('./chunk-7RV5REPT.cjs');
3
+ var chunkCBY6GRJP_cjs = require('./chunk-CBY6GRJP.cjs');
4
+ var chunkM5FGWXT3_cjs = require('./chunk-M5FGWXT3.cjs');
5
+ var chunk53VEUYCS_cjs = require('./chunk-53VEUYCS.cjs');
10
6
 
11
7
  // modules/index.ts
12
- var registeredModuleNamespaces = /* @__PURE__ */ new Set();
13
- var registeredQualifiedObjectTypes = /* @__PURE__ */ new Set();
14
- var registeredObjectDefinitions = /* @__PURE__ */ new Map();
15
8
  function getModuleDependencyNamespace(dependency) {
16
9
  return typeof dependency === "string" ? dependency : dependency.namespace;
17
10
  }
@@ -32,15 +25,26 @@ function validateModuleNamespace(namespace) {
32
25
  }
33
26
  }
34
27
  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 };
28
+ const orderedModules = validateAndOrderFabricModules(modules);
29
+ const registered = new Map(orderedModules.map((module) => [module.namespace, module]));
30
+ const actions = new Map(orderedModules.flatMap((module) => (module.actions ?? []).map((action) => [action.actionId, action])));
31
+ const policies = new Map(orderedModules.flatMap((module) => (module.policies ?? []).map((policy) => {
32
+ const evaluator = policy;
33
+ return [evaluator.policyId, evaluator];
34
+ })));
35
+ const machines = new Map(orderedModules.flatMap((module) => (module.stateMachines ?? []).map((machine) => {
36
+ const definition = machine;
37
+ return [definition.entityType, definition];
38
+ })));
39
+ const views = new Map(orderedModules.flatMap((module) => (module.views ?? []).map((view) => [chunkM5FGWXT3_cjs.viewContractKey(view), view])));
40
+ return {
41
+ modules: registered,
42
+ orderedModules,
43
+ resolveAction: (actionId) => actions.get(actionId),
44
+ resolvePolicy: (policyId) => policies.get(policyId),
45
+ resolveStateMachine: (entityType) => machines.get(entityType),
46
+ resolveView: (name, version) => views.get(`${name}@${version}`)
47
+ };
44
48
  }
45
49
  function validateIdentifierList(values, label, namespace) {
46
50
  for (const value of values ?? []) {
@@ -70,7 +74,7 @@ function qualifiedObjectType(namespace, type) {
70
74
  function validateObjectDefinition(objectType, namespace, context) {
71
75
  if (typeof objectType === "string") return;
72
76
  if (objectType.schema !== void 0) {
73
- chunkOC4ZFJKD_cjs.assertPortableJsonSchema(objectType.schema, `Module "${namespace}" object "${objectType.type}" schema`);
77
+ chunkCBY6GRJP_cjs.assertPortableJsonSchema(objectType.schema, `Module "${namespace}" object "${objectType.type}" schema`);
74
78
  }
75
79
  if (objectType.semantics !== void 0) {
76
80
  assertJsonValue(objectType.semantics, `Module "${namespace}" object "${objectType.type}" semantics`);
@@ -117,32 +121,21 @@ function validateManifest(module, context = {}) {
117
121
  if (!module.capability.displayName.trim() || !module.capability.description.trim()) {
118
122
  throw new Error(`Module "${module.namespace}" capability requires displayName and description.`);
119
123
  }
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}".`);
124
+ for (const namespace of Object.keys(module.capability.extensions ?? {})) {
125
+ if (!/^[a-z][a-z0-9.-]*\.[a-z0-9.-]+\/v[1-9][0-9]*$/.test(namespace)) {
126
+ throw new Error(`Module "${module.namespace}" capability has invalid extension namespace "${namespace}".`);
127
127
  }
128
- slots.add(slot.name);
129
- if (slot.shape) chunkOC4ZFJKD_cjs.assertPortableJsonSchema(slot.shape, `Capability slot "${slot.name}" shape`);
130
- }
131
- const intents = /* @__PURE__ */ new Set();
132
- for (const intent of module.capability.actionIntents ?? []) {
133
- 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}".`);
134
- intents.add(intent.name);
135
128
  }
136
129
  for (const port of module.capability.requirements?.ports ?? []) {
137
130
  if (!/^[a-z][a-z0-9-]*$/.test(port.name)) throw new Error(`Module "${module.namespace}" capability has invalid port requirement "${port.name}".`);
138
131
  }
139
132
  }
140
- for (const eventType of module.eventTypes ?? []) if (typeof eventType !== "string" && eventType.schema) chunkOC4ZFJKD_cjs.assertPortableJsonSchema(eventType.schema, `Event "${eventType.eventType}" schema`);
133
+ for (const eventType of module.eventTypes ?? []) if (typeof eventType !== "string" && eventType.schema) chunkCBY6GRJP_cjs.assertPortableJsonSchema(eventType.schema, `Event "${eventType.eventType}" schema`);
141
134
  for (const action of module.actions ?? []) {
142
135
  if (action.execution?.idempotency === "required" && !action.idempotent) throw new Error(`Action "${action.actionId}" requires idempotency but is not declared idempotent.`);
143
136
  if (action.execution?.connectivity === "offline-capturable" && action.execution.idempotency === "prohibited") throw new Error(`Offline action "${action.actionId}" cannot prohibit idempotency.`);
144
137
  }
145
- for (const view of module.views ?? []) if (view.usage?.collection?.filterSchema) chunkOC4ZFJKD_cjs.assertPortableJsonSchema(view.usage.collection.filterSchema, `View "${view.name}" filter schema`);
138
+ for (const view of module.views ?? []) if (view.usage?.collection?.filterSchema) chunkCBY6GRJP_cjs.assertPortableJsonSchema(view.usage.collection.filterSchema, `View "${view.name}" filter schema`);
146
139
  for (const dependency of dependencies) {
147
140
  validateModuleNamespace(dependency);
148
141
  if (dependency === module.namespace) {
@@ -180,14 +173,14 @@ function validateManifest(module, context = {}) {
180
173
  } catch {
181
174
  parameterSchema = void 0;
182
175
  }
183
- if (parameterSchema !== void 0) chunkOC4ZFJKD_cjs.assertPortableJsonSchema(parameterSchema, `Action "${action.actionId}" parameters`);
176
+ if (parameterSchema !== void 0) chunkCBY6GRJP_cjs.assertPortableJsonSchema(parameterSchema, `Action "${action.actionId}" parameters`);
184
177
  let resultSchema;
185
178
  try {
186
179
  resultSchema = action.resultSchema?.toJSONSchema?.();
187
180
  } catch {
188
181
  resultSchema = void 0;
189
182
  }
190
- if (resultSchema !== void 0) chunkOC4ZFJKD_cjs.assertPortableJsonSchema(resultSchema, `Action "${action.actionId}" result`);
183
+ if (resultSchema !== void 0) chunkCBY6GRJP_cjs.assertPortableJsonSchema(resultSchema, `Action "${action.actionId}" result`);
191
184
  if (!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9_]*$/.test(action.actionId)) {
192
185
  throw new Error(`Invalid action ID: ${action.actionId}`);
193
186
  }
@@ -207,15 +200,6 @@ function validateManifest(module, context = {}) {
207
200
  );
208
201
  }
209
202
  }
210
- for (const descriptor of module.displayRenderers ?? []) {
211
- const isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;
212
- const isModuleEventType = eventTypes.includes(descriptor.eventType);
213
- if (!chunk7RV5REPT_cjs.isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {
214
- throw new Error(
215
- `Display renderer registered for unknown event type "${descriptor.eventType}". Register the event type before adding a display renderer.`
216
- );
217
- }
218
- }
219
203
  const viewKeys = /* @__PURE__ */ new Set();
220
204
  for (const view of module.views ?? []) {
221
205
  if (!view.name.startsWith(`${module.namespace}/`) || !/^[a-z][a-z0-9-]*\/[a-z][a-z0-9/_-]*$/.test(view.name)) {
@@ -225,7 +209,7 @@ function validateManifest(module, context = {}) {
225
209
  const key = `${view.name}@${view.version}`;
226
210
  if (viewKeys.has(key)) throw new Error(`Module "${module.namespace}" has duplicate view contract "${key}".`);
227
211
  viewKeys.add(key);
228
- chunkOC4ZFJKD_cjs.assertPortableJsonSchema(view.shape, `View "${key}" shape`);
212
+ chunkCBY6GRJP_cjs.assertPortableJsonSchema(view.shape, `View "${key}" shape`);
229
213
  if (!Number.isInteger(view.snapshotVersion) || view.snapshotVersion < 1) {
230
214
  throw new Error(`View "${key}" snapshotVersion must be a positive integer.`);
231
215
  }
@@ -235,7 +219,7 @@ function validateManifest(module, context = {}) {
235
219
  for (const consumption of view.consumes) {
236
220
  const isPlanned = context.plannedEventTypes?.has(consumption.eventType) ?? false;
237
221
  const isModuleEvent = eventTypes.includes(consumption.eventType);
238
- if (!chunk7RV5REPT_cjs.isValidEventType(consumption.eventType) && !isPlanned && !isModuleEvent) {
222
+ if (!isPlanned && !isModuleEvent) {
239
223
  throw new Error(`View "${key}" consumes unknown event type "${consumption.eventType}".`);
240
224
  }
241
225
  if (consumption.schemaVersions.length === 0 || consumption.schemaVersions.some((version) => !Number.isInteger(version) || version < 1)) {
@@ -244,12 +228,12 @@ function validateManifest(module, context = {}) {
244
228
  }
245
229
  }
246
230
  }
247
- function sortModulesByDependency(modules, registeredNamespaces = registeredModuleNamespaces) {
231
+ function sortModulesByDependency(modules, registeredNamespaces = /* @__PURE__ */ new Set()) {
248
232
  const modulesByNamespace = /* @__PURE__ */ new Map();
249
233
  for (const module of modules) {
250
234
  validateModuleNamespace(module.namespace);
251
235
  if (modulesByNamespace.has(module.namespace)) {
252
- throw new Error(`Duplicate Fabric module namespace "${module.namespace}".`);
236
+ throw new Error(`Duplicate FabricModule namespace "${module.namespace}".`);
253
237
  }
254
238
  modulesByNamespace.set(module.namespace, module);
255
239
  }
@@ -293,9 +277,6 @@ function assertAcyclicRelations(modules) {
293
277
  ];
294
278
  for (const kind of relationKinds) {
295
279
  const edges = /* @__PURE__ */ new Map();
296
- for (const [source, objectType] of registeredObjectDefinitions) {
297
- edges.set(source, (objectType.relations ?? []).filter(kind.include).map((relation) => relation.target));
298
- }
299
280
  for (const module of modules) {
300
281
  for (const objectType of module.objectTypes ?? []) {
301
282
  if (typeof objectType === "string") continue;
@@ -318,53 +299,13 @@ function assertAcyclicRelations(modules) {
318
299
  for (const node of edges.keys()) visit(node, []);
319
300
  }
320
301
  }
321
- function registerValidatedFabricModule(module) {
322
- for (const objectType of module.objectTypes ?? []) {
323
- chunkOC4ZFJKD_cjs.registerObjectType(getObjectTypeName(objectType));
324
- const qualified = qualifiedObjectType(module.namespace, getObjectTypeName(objectType));
325
- registeredQualifiedObjectTypes.add(qualified);
326
- if (typeof objectType !== "string") registeredObjectDefinitions.set(qualified, objectType);
327
- }
328
- for (const subjectType of module.subjectTypes ?? []) {
329
- chunk7RV5REPT_cjs.registerSubjectType(subjectType);
330
- }
331
- for (const eventType of module.eventTypes ?? []) {
332
- chunk7RV5REPT_cjs.registerEventType(getEventTypeName(eventType));
333
- }
334
- for (const policy of module.policies ?? []) {
335
- chunkNJL3US7H_cjs.registerPolicyIfMissing(policy);
336
- }
337
- for (const machine of module.stateMachines ?? []) {
338
- chunkUV252FLT_cjs.registerStateMachineIfMissing(machine);
339
- }
340
- for (const action of module.actions ?? []) {
341
- chunkJOATYJXQ_cjs.registerActionIfMissing(action);
342
- }
343
- for (const descriptor of module.displayRenderers ?? []) {
344
- chunkEO4VSB2O_cjs.registerDisplayRenderer(descriptor.eventType, descriptor.renderer);
345
- }
346
- for (const view of module.views ?? []) chunk7SHNYYGI_cjs.registerViewContractIfMissing(view);
347
- registeredModuleNamespaces.add(module.namespace);
348
- }
349
- function registerFabricModule(module) {
350
- const availableObjectTypes = /* @__PURE__ */ new Set([
351
- ...registeredQualifiedObjectTypes,
352
- ...(module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType)))
353
- ]);
354
- validateManifest(module, { availableNamespaces: registeredModuleNamespaces, availableObjectTypes });
355
- assertAcyclicRelations([module]);
356
- registerValidatedFabricModule(module);
357
- }
358
- function registerFabricModules(modules) {
359
- const availableNamespaces = /* @__PURE__ */ new Set([
360
- ...registeredModuleNamespaces,
361
- ...modules.map((module) => module.namespace)
362
- ]);
302
+ function validateAndOrderFabricModules(modules) {
303
+ const availableNamespaces = new Set(modules.map((module) => module.namespace));
363
304
  const plannedEventTypes = new Set(
364
305
  modules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName))
365
306
  );
307
+ for (const eventType of chunk53VEUYCS_cjs.createEventContractRegistry().eventTypes()) plannedEventTypes.add(eventType);
366
308
  const availableObjectTypes = /* @__PURE__ */ new Set([
367
- ...registeredQualifiedObjectTypes,
368
309
  ...modules.flatMap(
369
310
  (module) => (module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType)))
370
311
  )
@@ -373,11 +314,13 @@ function registerFabricModules(modules) {
373
314
  validateManifest(module, { availableNamespaces, plannedEventTypes, availableObjectTypes });
374
315
  }
375
316
  assertAcyclicRelations(modules);
376
- const sortedModules = sortModulesByDependency(modules);
377
- for (const module of sortedModules) {
378
- registerValidatedFabricModule(module);
379
- }
380
- return sortedModules;
317
+ return sortModulesByDependency(modules);
318
+ }
319
+ function registerFabricModules(modules) {
320
+ return validateAndOrderFabricModules(modules);
321
+ }
322
+ function registerFabricModule(module) {
323
+ validateAndOrderFabricModules([module]);
381
324
  }
382
325
 
383
326
  exports.createModuleRegistry = createModuleRegistry;
@@ -386,6 +329,7 @@ exports.getModuleDependencyNamespace = getModuleDependencyNamespace;
386
329
  exports.getObjectTypeName = getObjectTypeName;
387
330
  exports.registerFabricModule = registerFabricModule;
388
331
  exports.registerFabricModules = registerFabricModules;
332
+ exports.validateAndOrderFabricModules = validateAndOrderFabricModules;
389
333
  exports.validateModuleNamespace = validateModuleNamespace;
390
- //# sourceMappingURL=chunk-LAZL2GDT.cjs.map
391
- //# sourceMappingURL=chunk-LAZL2GDT.cjs.map
334
+ //# sourceMappingURL=chunk-35LADVKK.cjs.map
335
+ //# sourceMappingURL=chunk-35LADVKK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../modules/index.ts"],"names":["viewContractKey","assertPortableJsonSchema","createEventContractRegistry"],"mappings":";;;;;;;AAqJO,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,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I,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,aAAaC,6CAAA,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-35LADVKK.cjs","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"]}
@@ -0,0 +1,47 @@
1
+ // actions/index.ts
2
+ var ACTOR_TYPES = [
3
+ "natural_person",
4
+ "agent",
5
+ "system",
6
+ "service_account",
7
+ "external_system",
8
+ "integration"
9
+ ];
10
+ function isActorType(value) {
11
+ return ACTOR_TYPES.includes(value);
12
+ }
13
+ function assertActorType(value) {
14
+ if (!isActorType(value)) {
15
+ throw new Error(`Invalid actorType: ${value}`);
16
+ }
17
+ }
18
+ function assertActionId(actionId) {
19
+ if (!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9_]*$/.test(actionId)) {
20
+ throw new Error(`Invalid action ID: ${actionId}`);
21
+ }
22
+ }
23
+ function createActionRegistry(definitions = []) {
24
+ const actions = /* @__PURE__ */ new Map();
25
+ const register = (definition) => {
26
+ assertActionId(definition.actionId);
27
+ if (actions.has(definition.actionId)) throw new Error(`Action "${definition.actionId}" is already registered`);
28
+ if (definition.mutatesDomain && definition.emitsEvents.length === 0) {
29
+ throw new Error(`Action "${definition.actionId}" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`);
30
+ }
31
+ actions.set(definition.actionId, definition);
32
+ };
33
+ for (const definition of definitions) register(definition);
34
+ return {
35
+ register,
36
+ registerIfMissing(definition) {
37
+ if (!actions.has(definition.actionId)) register(definition);
38
+ },
39
+ resolve: (actionId) => actions.get(actionId),
40
+ has: (actionId) => actions.has(actionId),
41
+ ids: () => Array.from(actions.keys())
42
+ };
43
+ }
44
+
45
+ export { ACTOR_TYPES, assertActionId, assertActorType, createActionRegistry, isActorType };
46
+ //# sourceMappingURL=chunk-4QOA3VU5.js.map
47
+ //# sourceMappingURL=chunk-4QOA3VU5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../actions/index.ts"],"names":[],"mappings":";AAwBO,IAAM,WAAA,GAAoC;AAAA,EAChD,gBAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACD;AAEO,SAAS,YAAY,KAAA,EAAmC;AAC9D,EAAA,OAAQ,WAAA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AAA,CAAQ,GAAA,CAAI,WAAW,QAAQ,CAAA,WAAY,UAAU,CAAA;AAAA,IAC3D,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,QAAA,KAAa,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAAA,IAC3C,GAAA,EAAK,CAAC,QAAA,KAAmC,OAAA,CAAQ,IAAI,QAAoB,CAAA;AAAA,IACzE,KAAK,MAAM,KAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,MAAM;AAAA,GACrC;AACD","file":"chunk-4QOA3VU5.js","sourcesContent":["export type ActionId = `${string}.${string}`;\n\nexport interface SchemaParseIssue {\n\tpath: PropertyKey[];\n\tmessage: string;\n}\n\nexport type SchemaParseResult<T = unknown> =\n\t| { success: true; data: T }\n\t| { success: false; error: { issues: SchemaParseIssue[] } };\n\nexport interface SchemaValidator<T = unknown> {\n\tparse(input: unknown): T;\n\tsafeParse(input: unknown): SchemaParseResult<T>;\n}\n\nexport type ActorType =\n\t| \"natural_person\"\n\t| \"agent\"\n\t| \"system\"\n\t| \"service_account\"\n\t| \"external_system\"\n\t| \"integration\";\n\nexport const ACTOR_TYPES: readonly ActorType[] = [\n\t\"natural_person\",\n\t\"agent\",\n\t\"system\",\n\t\"service_account\",\n\t\"external_system\",\n\t\"integration\",\n] as const;\n\nexport function isActorType(value: string): value is ActorType {\n\treturn (ACTOR_TYPES as readonly string[]).includes(value);\n}\n\nexport function assertActorType(value: string): asserts value is ActorType {\n\tif (!isActorType(value)) {\n\t\tthrow new Error(`Invalid actorType: ${value}`);\n\t}\n}\n\nexport type ActionStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"blocked_by_policy\"\n\t| \"waiting_for_approval\"\n\t| \"reconciliation_required\"\n\t| \"validation_failed\";\n\nexport interface FabricRuntimeServices {\n\treadonly [serviceName: string]: unknown;\n}\n\nexport interface ActionContext<TDb = unknown> {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tactorId: string;\n\tactorType: ActorType;\n\tcorrelationId: string;\n\tcausationId?: string;\n\tprovenance?: { source: string; auditAttributes?: Record<string, string> };\n\tdb: TDb;\n\tservices?: FabricRuntimeServices;\n}\n\nexport interface ActionResult {\n\tsuccess: boolean;\n\tdata?: Record<string, unknown>;\n\terror?: string;\n}\n\nexport type ActionHandler<TDb = unknown> = (\n\tctx: ActionContext<TDb>,\n\tparams: unknown,\n) => Promise<ActionResult>;\n\nexport interface AdapterStepRetryPolicy {\n\tidempotent: boolean;\n\tmaxAttempts?: number;\n\tinitialDelayMs?: number;\n\tbackoffMultiplier?: number;\n\tmaxDelayMs?: number;\n}\n\nexport interface AdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n\tgetInput: (\n\t\tparams: unknown,\n\t\thandlerResult: Record<string, unknown>,\n\t) => Record<string, unknown> | undefined;\n}\n\nexport interface ActionStateMachineBinding {\n\tentityType: string;\n\ttargetState: string | ((params: unknown) => string);\n\tgetEntityId: (params: unknown) => string | undefined;\n}\n\nexport interface ActionDefinition<TDb = unknown> {\n\tactionId: ActionId;\n\tnamespace: string;\n\tversion: number;\n\tschema: SchemaValidator;\n\t/** Optional validation contract for the public handler result data. */\n\tresultSchema?: SchemaValidator;\n\thandler?: ActionHandler<TDb>;\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\tpolicies?: `${string}.v${number}`[];\n\temitsEvents: string[];\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\t/** Portable execution semantics used by hosts, gateways, and generated capability contracts. */\n\texecution?: ActionExecutionContract;\n\tstateMachine?: ActionStateMachineBinding;\n\tadapterSteps?: AdapterStep[];\n\t/** Completion actions can attest only after all external adapter work succeeds. */\n\teventPhase?: \"before_adapters\" | \"after_adapters\";\n\t/**\n\t * If \"saga\", the action is a multi-step orchestration. The worker dispatches\n\t * to a registered saga implementation instead of running `handler` directly.\n\t */\n\tkind?: \"atomic\" | \"saga\";\n}\n\nexport type ActionConnectivity = \"online-required\" | \"offline-capturable\";\nexport type AuthorityMoment = \"capture\" | \"execution\" | \"both\";\nexport type ActionIdempotencyStance = \"required\" | \"supported\" | \"prohibited\";\nexport type ActionCompletionMode = \"immediate\" | \"accepted\" | \"long-running\";\nexport type ActionConsistency = \"authoritative-now\" | \"provisional-until-reconciled\";\nexport type ActionDataSensitivity = \"public\" | \"internal\" | \"confidential\" | \"restricted\";\n\nexport interface ActionExecutionContract {\n\tconnectivity: ActionConnectivity;\n\tauthorityMoment: AuthorityMoment;\n\tidempotency: ActionIdempotencyStance;\n\tcompletion: ActionCompletionMode;\n\tconsistency: ActionConsistency;\n\tsensitivity?: ActionDataSensitivity;\n}\n\nexport interface SagaContext {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tparameters: unknown;\n\tsleep?: (delayMs: number) => Promise<void>;\n\tquery?: <T = unknown>(model: string, operation: string, args: unknown) => Promise<T>;\n\t/**\n\t * Wait for a named external signal carrying a payload of `T`, with a timeout.\n\t *\n\t * Resolves with the payload of the first signal received, or `null` if the timeout\n\t * fires first. Subsequent signals with the same name received before another\n\t * `awaitSignal` call are buffered (FIFO) so no signal is lost.\n\t *\n\t * Intended for agent-driven and webhook-driven coordination: replace polling loops\n\t * with push-based wakeups while preserving the saga's deterministic replay\n\t * semantics (the runtime is responsible for capturing signals into workflow history).\n\t *\n\t * Optional. Runtimes that cannot implement push-based signaling (e.g. an in-memory\n\t * test harness) may omit this; sagas should treat absence as a fallback condition\n\t * and use `sleep` + `query` polling instead.\n\t *\n\t * Signal *senders* are runtime-specific (e.g. a Temporal `WorkflowClient.signal()`\n\t * call from an action handler). Apps that need to send signals from action\n\t * handlers should expose a coordination service via `ActionContext.services`\n\t * — the platform does not prescribe the sender API.\n\t *\n\t * @example\n\t * const payload = await ctx.awaitSignal?.<{ result: Record<string, unknown> }>(\n\t * \"userInputProcessed\",\n\t * 5 * 60 * 1000,\n\t * );\n\t * if (payload) { /* handle pushed result *\\/ }\n\t * else { /* timeout — fall back to deterministic path *\\/ }\n\t */\n\tawaitSignal?: <T = unknown>(signalName: string, timeoutMs: number) => Promise<T | null>;\n}\n\nexport interface SagaChildActionInput {\n\tsuffix: string;\n\tactionId: string;\n\tparameters: Record<string, unknown>;\n}\n\nexport type SagaRunChild = (input: SagaChildActionInput) => Promise<Record<string, unknown>>;\n\nexport interface SagaCompletionEvent {\n\teventType: string;\n\tsubjectType: string;\n\tsubjectId: string;\n\tpayload: unknown;\n\teventSchemaVersion?: number;\n}\n\nexport interface SagaCompletion {\n\tresultData: Record<string, unknown>;\n\tevent?: SagaCompletionEvent;\n}\n\nexport type SagaImplementation = (\n\tctx: SagaContext,\n\trunChild: SagaRunChild,\n) => Promise<SagaCompletion>;\n\nexport function assertActionId(actionId: string): asserts actionId is ActionId {\n\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(actionId)) {\n\t\tthrow new Error(`Invalid action ID: ${actionId}`);\n\t}\n}\n\nexport interface ActionRegistry<TDb = unknown> {\n\tregister(definition: ActionDefinition<TDb>): void;\n\tregisterIfMissing(definition: ActionDefinition<TDb>): void;\n\tresolve(actionId: ActionId): ActionDefinition<TDb> | undefined;\n\thas(actionId: string): actionId is ActionId;\n\tids(): ActionId[];\n}\n\nexport function createActionRegistry<TDb = unknown>(definitions: readonly ActionDefinition<TDb>[] = []): ActionRegistry<TDb> {\n\tconst actions = new Map<ActionId, ActionDefinition<TDb>>();\n\tconst register = (definition: ActionDefinition<TDb>): void => {\n\t\tassertActionId(definition.actionId);\n\t\tif (actions.has(definition.actionId)) throw new Error(`Action \"${definition.actionId}\" is already registered`);\n\t\tif (definition.mutatesDomain && definition.emitsEvents.length === 0) {\n\t\t\tthrow new Error(`Action \"${definition.actionId}\" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`);\n\t\t}\n\t\tactions.set(definition.actionId, definition);\n\t};\n\tfor (const definition of definitions) register(definition);\n\treturn {\n\t\tregister,\n\t\tregisterIfMissing(definition) {\n\t\t\tif (!actions.has(definition.actionId)) register(definition);\n\t\t},\n\t\tresolve: (actionId) => actions.get(actionId),\n\t\thas: (actionId): actionId is ActionId => actions.has(actionId as ActionId),\n\t\tids: () => Array.from(actions.keys()),\n\t};\n}\n"]}