@fabricorg/platform 0.11.0 → 0.12.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 (67) hide show
  1. package/CHANGELOG.md +26 -6
  2. package/README.md +1 -1
  3. package/dist/actions/index.cjs +11 -11
  4. package/dist/actions/index.d.cts +22 -2
  5. package/dist/actions/index.d.ts +22 -2
  6. package/dist/actions/index.js +1 -1
  7. package/dist/{chunk-4YQOGV7H.js → chunk-3O4GMCCE.js} +2 -2
  8. package/dist/chunk-3O4GMCCE.js.map +1 -0
  9. package/dist/{chunk-O7IHZ53Y.cjs → chunk-45TSN3GO.cjs} +18 -9
  10. package/dist/chunk-45TSN3GO.cjs.map +1 -0
  11. package/dist/{chunk-3S6UTP4X.js → chunk-4MMMXV4Q.js} +28 -3
  12. package/dist/chunk-4MMMXV4Q.js.map +1 -0
  13. package/dist/{chunk-JM55UQWK.js → chunk-4RMKUYRX.js} +2 -2
  14. package/dist/chunk-4RMKUYRX.js.map +1 -0
  15. package/dist/{chunk-3JQI3OFC.js → chunk-5PDVZXEI.js} +42 -6
  16. package/dist/chunk-5PDVZXEI.js.map +1 -0
  17. package/dist/{chunk-JAXDEK5Z.cjs → chunk-7RV5REPT.cjs} +2 -2
  18. package/dist/chunk-7RV5REPT.cjs.map +1 -0
  19. package/dist/{chunk-HLRIXNVG.cjs → chunk-JOATYJXQ.cjs} +2 -2
  20. package/dist/chunk-JOATYJXQ.cjs.map +1 -0
  21. package/dist/{chunk-7WASIL46.js → chunk-LXS6SURU.js} +18 -9
  22. package/dist/chunk-LXS6SURU.js.map +1 -0
  23. package/dist/{chunk-RYCHDNHZ.cjs → chunk-MCD5VT4E.cjs} +19 -10
  24. package/dist/chunk-MCD5VT4E.cjs.map +1 -0
  25. package/dist/{chunk-XCL2HBMB.cjs → chunk-OC4ZFJKD.cjs} +28 -3
  26. package/dist/chunk-OC4ZFJKD.cjs.map +1 -0
  27. package/dist/{chunk-ODP3DO6P.cjs → chunk-ROC326VL.cjs} +52 -16
  28. package/dist/chunk-ROC326VL.cjs.map +1 -0
  29. package/dist/{chunk-NFP5DJBT.js → chunk-ZO6HPMCK.js} +16 -7
  30. package/dist/chunk-ZO6HPMCK.js.map +1 -0
  31. package/dist/events/index.cjs +8 -8
  32. package/dist/events/index.d.cts +6 -1
  33. package/dist/events/index.d.ts +6 -1
  34. package/dist/events/index.js +1 -1
  35. package/dist/index.cjs +48 -48
  36. package/dist/index.d.cts +4 -4
  37. package/dist/index.d.ts +4 -4
  38. package/dist/index.js +6 -6
  39. package/dist/manifest/index.cjs +12 -12
  40. package/dist/manifest/index.d.cts +5 -2
  41. package/dist/manifest/index.d.ts +5 -2
  42. package/dist/manifest/index.js +6 -6
  43. package/dist/modules/index.cjs +12 -12
  44. package/dist/modules/index.d.cts +23 -1
  45. package/dist/modules/index.d.ts +23 -1
  46. package/dist/modules/index.js +5 -5
  47. package/dist/objects/index.cjs +6 -6
  48. package/dist/objects/index.d.cts +13 -0
  49. package/dist/objects/index.d.ts +13 -0
  50. package/dist/objects/index.js +1 -1
  51. package/dist/projections/index.cjs +8 -8
  52. package/dist/projections/index.d.cts +15 -1
  53. package/dist/projections/index.d.ts +15 -1
  54. package/dist/projections/index.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/chunk-3JQI3OFC.js.map +0 -1
  57. package/dist/chunk-3S6UTP4X.js.map +0 -1
  58. package/dist/chunk-4YQOGV7H.js.map +0 -1
  59. package/dist/chunk-7WASIL46.js.map +0 -1
  60. package/dist/chunk-HLRIXNVG.cjs.map +0 -1
  61. package/dist/chunk-JAXDEK5Z.cjs.map +0 -1
  62. package/dist/chunk-JM55UQWK.js.map +0 -1
  63. package/dist/chunk-NFP5DJBT.js.map +0 -1
  64. package/dist/chunk-O7IHZ53Y.cjs.map +0 -1
  65. package/dist/chunk-ODP3DO6P.cjs.map +0 -1
  66. package/dist/chunk-RYCHDNHZ.cjs.map +0 -1
  67. package/dist/chunk-XCL2HBMB.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,20 +1,40 @@
1
1
  # @fabricorg/platform
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Deliver Phase 1 correctness and contracts: payload-bound idempotency with staged enforcement,
8
+ capture/replay authority evidence, bounded invocation provenance, capability execution and view usage
9
+ semantics, event-schema compatibility classification, and deterministic conformance plans.
10
+
11
+ ## 0.11.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Close final uplift audit gaps: align Host 2.x documentation and migration evidence, surface every
16
+ compiler/generator API to LLM consumers, make memory outbox egress directly usable, sanitize relay
17
+ failures, validate complete archetype state maps, support recursive JSON Schema generation, reject
18
+ cross-platform path traversal, synchronize artifact version stamps, and include package licenses.
19
+ - Expand the portable Zod 4 JSON Schema profile, validate exportable schemas without coupling runtime
20
+ registration to non-exportable validators, pause view replay before unsupported versions, and require
21
+ declared dependencies for cross-module relations.
22
+ - Omit non-exportable parameter or result schemas from manifests instead of failing manifest export.
23
+ - Preserve every repeated duplicate-event warning while deduplicating only warnings produced by both
24
+ replay preprocessing and the scoped replay pass.
25
+
3
26
  ## 0.11.0
4
27
 
5
28
  ### Minor Changes
6
29
 
30
+ - **Breaking wire change:** advance `MODULE_MANIFEST_VERSION` from 1 to 2. Consumers must negotiate
31
+ the manifest version; v2 readers can accept v1 input through `normalizeModuleManifest` and
32
+ `normalizeModuleManifestBundle`, but no down-conversion is promised.
7
33
  - Add versioned view contracts, manifest export, event-schema filtering, and snapshot compatibility
8
34
  without prescribing a physical read-model store.
9
35
  - Add manifest v2 typed entity contracts, v1 reader normalization, optional action result schemas, and
10
36
  Host enforcement of result validation before events and adapters.
11
37
 
12
- ## Unreleased
13
-
14
- - Add manifest v2 typed object definitions, v1 reader normalization, and optional exported action
15
- result schemas while preserving the zero-dependency runtime.
16
- - Add versioned logical view contracts with event-schema filtering and explicit snapshot upgrade functions.
17
-
18
38
  ## 0.10.0
19
39
 
20
40
  ### Minor Changes
package/README.md CHANGED
@@ -100,7 +100,7 @@ const json = JSON.stringify(manifest, null, 2);
100
100
 
101
101
  `exportModuleManifest` is a pure function of the module object: it does not touch the registries and the module does not need to be registered first. Declaration order is preserved everywhere, so the same module always produces byte-identical JSON. Function fields (`handler`, policy `evaluate`, transition `guard`, dynamic `targetState`, adapter `getInput`) are never serialized — the manifest contains definitions only, never raw parameter values, secrets, or runtime data. Manifest v2 object registrations may include `PortableJsonSchema`, qualified relations, namespaced semantic annotations, and enforcement-owned invariants. Actions whose validators expose `toJSONSchema()` include `parameterSchema` and optional `resultSchema` definitions. `normalizeModuleManifest` and `normalizeModuleManifestBundle` let v2 readers accept v1 input without promising down-conversion.
102
102
 
103
- An entity schema does not validate arbitrary writes through `TDb`. Persisted-record validation requires an explicit Host/database adapter. When an action declares `resultSchema`, Platform Host validates the public result after the handler and before events or adapters; failure rolls back the handler transaction.
103
+ An entity schema does not validate arbitrary writes through `TDb`. Persisted-record validation requires an explicit Host/database adapter. When an action declares `resultSchema`, Platform Host validates the public result after the handler and before events or adapters; failure rolls back domain writes only when the Host store has a transaction provider that includes them.
104
104
 
105
105
  ## The action lifecycle
106
106
 
@@ -1,48 +1,48 @@
1
1
  'use strict';
2
2
 
3
- var chunkHLRIXNVG_cjs = require('../chunk-HLRIXNVG.cjs');
3
+ var chunkJOATYJXQ_cjs = require('../chunk-JOATYJXQ.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "ACTOR_TYPES", {
8
8
  enumerable: true,
9
- get: function () { return chunkHLRIXNVG_cjs.ACTOR_TYPES; }
9
+ get: function () { return chunkJOATYJXQ_cjs.ACTOR_TYPES; }
10
10
  });
11
11
  Object.defineProperty(exports, "assertActionId", {
12
12
  enumerable: true,
13
- get: function () { return chunkHLRIXNVG_cjs.assertActionId; }
13
+ get: function () { return chunkJOATYJXQ_cjs.assertActionId; }
14
14
  });
15
15
  Object.defineProperty(exports, "assertActorType", {
16
16
  enumerable: true,
17
- get: function () { return chunkHLRIXNVG_cjs.assertActorType; }
17
+ get: function () { return chunkJOATYJXQ_cjs.assertActorType; }
18
18
  });
19
19
  Object.defineProperty(exports, "getRegisteredActionIds", {
20
20
  enumerable: true,
21
- get: function () { return chunkHLRIXNVG_cjs.getRegisteredActionIds; }
21
+ get: function () { return chunkJOATYJXQ_cjs.getRegisteredActionIds; }
22
22
  });
23
23
  Object.defineProperty(exports, "isActorType", {
24
24
  enumerable: true,
25
- get: function () { return chunkHLRIXNVG_cjs.isActorType; }
25
+ get: function () { return chunkJOATYJXQ_cjs.isActorType; }
26
26
  });
27
27
  Object.defineProperty(exports, "isRegisteredActionId", {
28
28
  enumerable: true,
29
- get: function () { return chunkHLRIXNVG_cjs.isRegisteredActionId; }
29
+ get: function () { return chunkJOATYJXQ_cjs.isRegisteredActionId; }
30
30
  });
31
31
  Object.defineProperty(exports, "registerAction", {
32
32
  enumerable: true,
33
- get: function () { return chunkHLRIXNVG_cjs.registerAction; }
33
+ get: function () { return chunkJOATYJXQ_cjs.registerAction; }
34
34
  });
35
35
  Object.defineProperty(exports, "registerActionIfMissing", {
36
36
  enumerable: true,
37
- get: function () { return chunkHLRIXNVG_cjs.registerActionIfMissing; }
37
+ get: function () { return chunkJOATYJXQ_cjs.registerActionIfMissing; }
38
38
  });
39
39
  Object.defineProperty(exports, "resolveAction", {
40
40
  enumerable: true,
41
- get: function () { return chunkHLRIXNVG_cjs.resolveAction; }
41
+ get: function () { return chunkJOATYJXQ_cjs.resolveAction; }
42
42
  });
43
43
  Object.defineProperty(exports, "resolveRegisteredAction", {
44
44
  enumerable: true,
45
- get: function () { return chunkHLRIXNVG_cjs.resolveRegisteredAction; }
45
+ get: function () { return chunkJOATYJXQ_cjs.resolveRegisteredAction; }
46
46
  });
47
47
  //# sourceMappingURL=index.cjs.map
48
48
  //# sourceMappingURL=index.cjs.map
@@ -20,7 +20,7 @@ type ActorType = "natural_person" | "agent" | "system" | "service_account" | "ex
20
20
  declare const ACTOR_TYPES: readonly ActorType[];
21
21
  declare function isActorType(value: string): value is ActorType;
22
22
  declare function assertActorType(value: string): asserts value is ActorType;
23
- type ActionStatus = "pending" | "running" | "completed" | "failed" | "blocked_by_policy" | "waiting_for_approval" | "validation_failed";
23
+ type ActionStatus = "pending" | "running" | "completed" | "failed" | "blocked_by_policy" | "waiting_for_approval" | "reconciliation_required" | "validation_failed";
24
24
  interface FabricRuntimeServices {
25
25
  readonly [serviceName: string]: unknown;
26
26
  }
@@ -32,6 +32,10 @@ interface ActionContext<TDb = unknown> {
32
32
  actorType: ActorType;
33
33
  correlationId: string;
34
34
  causationId?: string;
35
+ provenance?: {
36
+ source: string;
37
+ auditAttributes?: Record<string, string>;
38
+ };
35
39
  db: TDb;
36
40
  services?: FabricRuntimeServices;
37
41
  }
@@ -73,6 +77,8 @@ interface ActionDefinition<TDb = unknown> {
73
77
  emitsEvents: string[];
74
78
  idempotent: boolean;
75
79
  mutatesDomain: boolean;
80
+ /** Portable execution semantics used by hosts, gateways, and generated capability contracts. */
81
+ execution?: ActionExecutionContract;
76
82
  stateMachine?: ActionStateMachineBinding;
77
83
  adapterSteps?: AdapterStep[];
78
84
  /** Completion actions can attest only after all external adapter work succeeds. */
@@ -83,6 +89,20 @@ interface ActionDefinition<TDb = unknown> {
83
89
  */
84
90
  kind?: "atomic" | "saga";
85
91
  }
92
+ type ActionConnectivity = "online-required" | "offline-capturable";
93
+ type AuthorityMoment = "capture" | "execution" | "both";
94
+ type ActionIdempotencyStance = "required" | "supported" | "prohibited";
95
+ type ActionCompletionMode = "immediate" | "accepted" | "long-running";
96
+ type ActionConsistency = "authoritative-now" | "provisional-until-reconciled";
97
+ type ActionDataSensitivity = "public" | "internal" | "confidential" | "restricted";
98
+ interface ActionExecutionContract {
99
+ connectivity: ActionConnectivity;
100
+ authorityMoment: AuthorityMoment;
101
+ idempotency: ActionIdempotencyStance;
102
+ completion: ActionCompletionMode;
103
+ consistency: ActionConsistency;
104
+ sensitivity?: ActionDataSensitivity;
105
+ }
86
106
  interface SagaContext {
87
107
  actionInvocationId: string;
88
108
  tenantId: string;
@@ -146,4 +166,4 @@ declare function resolveRegisteredAction(actionId: string): ActionDefinition | u
146
166
  declare function getRegisteredActionIds(): ActionId[];
147
167
  declare function registerActionIfMissing(definition: ActionDefinition): void;
148
168
 
149
- export { ACTOR_TYPES, type ActionContext, type ActionDefinition, type ActionHandler, type ActionId, type ActionResult, type ActionStateMachineBinding, type ActionStatus, type ActorType, type AdapterStep, type AdapterStepRetryPolicy, 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 };
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 };
@@ -20,7 +20,7 @@ type ActorType = "natural_person" | "agent" | "system" | "service_account" | "ex
20
20
  declare const ACTOR_TYPES: readonly ActorType[];
21
21
  declare function isActorType(value: string): value is ActorType;
22
22
  declare function assertActorType(value: string): asserts value is ActorType;
23
- type ActionStatus = "pending" | "running" | "completed" | "failed" | "blocked_by_policy" | "waiting_for_approval" | "validation_failed";
23
+ type ActionStatus = "pending" | "running" | "completed" | "failed" | "blocked_by_policy" | "waiting_for_approval" | "reconciliation_required" | "validation_failed";
24
24
  interface FabricRuntimeServices {
25
25
  readonly [serviceName: string]: unknown;
26
26
  }
@@ -32,6 +32,10 @@ interface ActionContext<TDb = unknown> {
32
32
  actorType: ActorType;
33
33
  correlationId: string;
34
34
  causationId?: string;
35
+ provenance?: {
36
+ source: string;
37
+ auditAttributes?: Record<string, string>;
38
+ };
35
39
  db: TDb;
36
40
  services?: FabricRuntimeServices;
37
41
  }
@@ -73,6 +77,8 @@ interface ActionDefinition<TDb = unknown> {
73
77
  emitsEvents: string[];
74
78
  idempotent: boolean;
75
79
  mutatesDomain: boolean;
80
+ /** Portable execution semantics used by hosts, gateways, and generated capability contracts. */
81
+ execution?: ActionExecutionContract;
76
82
  stateMachine?: ActionStateMachineBinding;
77
83
  adapterSteps?: AdapterStep[];
78
84
  /** Completion actions can attest only after all external adapter work succeeds. */
@@ -83,6 +89,20 @@ interface ActionDefinition<TDb = unknown> {
83
89
  */
84
90
  kind?: "atomic" | "saga";
85
91
  }
92
+ type ActionConnectivity = "online-required" | "offline-capturable";
93
+ type AuthorityMoment = "capture" | "execution" | "both";
94
+ type ActionIdempotencyStance = "required" | "supported" | "prohibited";
95
+ type ActionCompletionMode = "immediate" | "accepted" | "long-running";
96
+ type ActionConsistency = "authoritative-now" | "provisional-until-reconciled";
97
+ type ActionDataSensitivity = "public" | "internal" | "confidential" | "restricted";
98
+ interface ActionExecutionContract {
99
+ connectivity: ActionConnectivity;
100
+ authorityMoment: AuthorityMoment;
101
+ idempotency: ActionIdempotencyStance;
102
+ completion: ActionCompletionMode;
103
+ consistency: ActionConsistency;
104
+ sensitivity?: ActionDataSensitivity;
105
+ }
86
106
  interface SagaContext {
87
107
  actionInvocationId: string;
88
108
  tenantId: string;
@@ -146,4 +166,4 @@ declare function resolveRegisteredAction(actionId: string): ActionDefinition | u
146
166
  declare function getRegisteredActionIds(): ActionId[];
147
167
  declare function registerActionIfMissing(definition: ActionDefinition): void;
148
168
 
149
- export { ACTOR_TYPES, type ActionContext, type ActionDefinition, type ActionHandler, type ActionId, type ActionResult, type ActionStateMachineBinding, type ActionStatus, type ActorType, type AdapterStep, type AdapterStepRetryPolicy, 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 };
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 };
@@ -1,3 +1,3 @@
1
- export { ACTOR_TYPES, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction } from '../chunk-JM55UQWK.js';
1
+ export { ACTOR_TYPES, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction } from '../chunk-4RMKUYRX.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -51,5 +51,5 @@ function createEventTypeRegistry(initialEventTypes = []) {
51
51
  }
52
52
 
53
53
  export { createEventTypeRegistry, getRegisteredEventTypes, getRegisteredSubjectTypes, isValidEventType, isValidSubjectType, registerEventType, registerSubjectType };
54
- //# sourceMappingURL=chunk-4YQOGV7H.js.map
55
- //# sourceMappingURL=chunk-4YQOGV7H.js.map
54
+ //# sourceMappingURL=chunk-3O4GMCCE.js.map
55
+ //# sourceMappingURL=chunk-3O4GMCCE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../events/index.ts"],"names":[],"mappings":";AAyBA,IAAM,mBAAA,uBAA0B,GAAA,CAAY;AAAA,EAC3C,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACD,CAAC,CAAA;AAED,IAAM,iBAAA,uBAAwB,GAAA,CAAY;AAAA,EACzC,mBAAA;AAAA,EACA,mBAAA;AAAA,EACA,0BAAA;AAAA,EACA,4BAAA;AAAA,EACA,yBAAA;AAAA,EACA;AACD,CAAC,CAAA;AAED,IAAM,mBAAA,uBAA0B,GAAA,EAAY;AAC5C,IAAM,iBAAA,uBAAwB,GAAA,EAAY;AAMnC,SAAS,oBAAoB,IAAA,EAAoB;AACvD,EAAA,mBAAA,CAAoB,IAAI,IAAI,CAAA;AAC7B;AAEO,SAAS,mBAAmB,IAAA,EAAuB;AACzD,EAAA,OAAO,oBAAoB,GAAA,CAAI,IAAI,CAAA,IAAK,mBAAA,CAAoB,IAAI,IAAI,CAAA;AACrE;AAEO,SAAS,yBAAA,GAAsC;AACrD,EAAA,OAAO,KAAA,CAAM,IAAA,iBAAK,IAAI,GAAA,CAAI,CAAC,GAAG,mBAAA,EAAqB,GAAG,mBAAmB,CAAC,CAAC,CAAA;AAC5E;AAEO,SAAS,kBAAkB,IAAA,EAAoB;AACrD,EAAA,iBAAA,CAAkB,IAAI,IAAI,CAAA;AAC3B;AAEO,SAAS,iBAAiB,IAAA,EAAuB;AACvD,EAAA,OAAO,kBAAkB,GAAA,CAAI,IAAI,CAAA,IAAK,iBAAA,CAAkB,IAAI,IAAI,CAAA;AACjE;AAEO,SAAS,uBAAA,GAAoC;AACnD,EAAA,OAAO,KAAA,CAAM,IAAA,iBAAK,IAAI,GAAA,CAAI,CAAC,GAAG,iBAAA,EAAmB,GAAG,iBAAiB,CAAC,CAAC,CAAA;AACxE;AAQO,SAAS,uBAAA,CAAwB,iBAAA,GAA8B,EAAC,EAAsB;AAC5F,EAAA,MAAM,UAAA,GAAa,IAAI,GAAA,CAAI,iBAAiB,CAAA;AAC5C,EAAA,OAAO;AAAA,IACN,SAAS,SAAA,EAAW;AACnB,MAAA,IAAI,CAAC,SAAA,EAAW;AACf,QAAA,MAAM,IAAI,MAAM,4BAA4B,CAAA;AAAA,MAC7C;AACA,MAAA,UAAA,CAAW,IAAI,SAAS,CAAA;AAAA,IACzB,CAAA;AAAA,IACA,IAAI,SAAA,EAAW;AACd,MAAA,OAAO,UAAA,CAAW,IAAI,SAAS,CAAA;AAAA,IAChC,CAAA;AAAA,IACA,IAAA,GAAO;AACN,MAAA,OAAO,KAAA,CAAM,IAAA,CAAK,UAAU,CAAA,CAAE,IAAA,EAAK;AAAA,IACpC;AAAA,GACD;AACD","file":"chunk-3O4GMCCE.js","sourcesContent":["export interface AssetEventEnvelope<TPayload = unknown> {\n\tid: string;\n\ttenantId: string;\n\tspaceId: string;\n\teventType: string;\n\teventSchemaVersion: number;\n\tsubjectType: string;\n\tsubjectId: string;\n\tactorId: string;\n\tactorType: string;\n\tactionInvocationId?: string;\n\tpayload: TPayload;\n\tsequence: number;\n\toccurredAt: Date;\n\trecordedAt: Date;\n\tcorrelationId: string;\n\tcausationId?: string;\n\tprovenance?: EventProvenance;\n}\n\nexport interface EventProvenance {\n\tsource: \"sdui\" | \"api\" | \"agent\" | \"worker\" | \"system\";\n\tauditAttributes?: Record<string, string>;\n}\n\nconst subjectTypeRegistry = new Set<string>([\n\t\"ActionInvocation\",\n\t\"PolicyEvaluation\",\n\t\"AdapterInvocation\",\n]);\n\nconst eventTypeRegistry = new Set<string>([\n\t\"ComplianceBlocked\",\n\t\"StateTransitioned\",\n\t\"AdapterInvocationStarted\",\n\t\"AdapterInvocationSucceeded\",\n\t\"AdapterInvocationFailed\",\n\t\"WebhookReceived\",\n]);\n\nconst dynamicSubjectTypes = new Set<string>();\nconst dynamicEventTypes = new Set<string>();\n\nexport type AssetEventSubjectType = string;\nexport type AssetEventType = string;\nexport type AssetEventActorType = \"natural_person\" | \"agent\" | \"adapter\" | \"system\" | \"service_account\" | \"external_system\" | \"integration\";\n\nexport function registerSubjectType(type: string): void {\n\tdynamicSubjectTypes.add(type);\n}\n\nexport function isValidSubjectType(type: string): boolean {\n\treturn subjectTypeRegistry.has(type) || dynamicSubjectTypes.has(type);\n}\n\nexport function getRegisteredSubjectTypes(): string[] {\n\treturn Array.from(new Set([...subjectTypeRegistry, ...dynamicSubjectTypes]));\n}\n\nexport function registerEventType(type: string): void {\n\tdynamicEventTypes.add(type);\n}\n\nexport function isValidEventType(type: string): boolean {\n\treturn eventTypeRegistry.has(type) || dynamicEventTypes.has(type);\n}\n\nexport function getRegisteredEventTypes(): string[] {\n\treturn Array.from(new Set([...eventTypeRegistry, ...dynamicEventTypes]));\n}\n\nexport interface EventTypeRegistry {\n\tregister(eventType: string): void;\n\thas(eventType: string): boolean;\n\tlist(): string[];\n}\n\nexport function createEventTypeRegistry(initialEventTypes: string[] = []): EventTypeRegistry {\n\tconst eventTypes = new Set(initialEventTypes);\n\treturn {\n\t\tregister(eventType) {\n\t\t\tif (!eventType) {\n\t\t\t\tthrow new Error(\"Event type cannot be empty\");\n\t\t\t}\n\t\t\teventTypes.add(eventType);\n\t\t},\n\t\thas(eventType) {\n\t\t\treturn eventTypes.has(eventType);\n\t\t},\n\t\tlist() {\n\t\t\treturn Array.from(eventTypes).sort();\n\t\t},\n\t};\n}\n"]}
@@ -39,22 +39,31 @@ async function replayView({
39
39
  const accepted = new Map(
40
40
  view.consumes.map((consumption) => [consumption.eventType, new Set(consumption.schemaVersions)])
41
41
  );
42
+ const sourceEvents = [];
43
+ for await (const event of events) sourceEvents.push(event);
44
+ const preprocessingWarnings = [];
45
+ const orderedScopedEvents = sortEvents(filterEventsByScope(sourceEvents, scope, preprocessingWarnings), Boolean(scope.subjectType && scope.subjectId));
42
46
  const versionWarnings = [];
43
- const filtered = async function* () {
44
- for await (const event of events) {
47
+ const replayable = async function* () {
48
+ for (const event of orderedScopedEvents) {
45
49
  const versions = accepted.get(event.eventType);
46
- if (versions?.has(event.eventSchemaVersion ?? 1)) yield event;
47
- else if (versions) versionWarnings.push({ code: "unsupported_event_version", eventId: event.id, message: `View "${viewContractKey(view)}" does not consume ${event.eventType} schema version ${event.eventSchemaVersion ?? 1}.` });
50
+ if (versions && !versions.has(event.eventSchemaVersion ?? 1)) {
51
+ versionWarnings.push({ code: "unsupported_event_version", eventId: event.id, message: `View "${viewContractKey(view)}" does not consume ${event.eventType} schema version ${event.eventSchemaVersion ?? 1}; replay stopped before this event so a compatible view can resume it later.` });
52
+ return;
53
+ }
54
+ yield event;
48
55
  }
49
56
  };
50
57
  const result = await replayEvents({
51
- events: filtered(),
58
+ events: replayable(),
52
59
  scope,
53
60
  initialState: view.initialState,
54
61
  snapshot: upgradedSnapshot,
55
- applyEvent: view.applyEvent
62
+ applyEvent: (state, event) => accepted.has(event.eventType) ? view.applyEvent(state, event) : state
56
63
  });
57
- return { ...result, warnings: [...versionWarnings, ...result.warnings] };
64
+ const preprocessingWarningKeys = new Set(preprocessingWarnings.map((warning) => JSON.stringify(warning)));
65
+ const resultWarnings = result.warnings.filter((warning) => !preprocessingWarningKeys.has(JSON.stringify(warning)));
66
+ return { ...result, warnings: [...preprocessingWarnings, ...versionWarnings, ...resultWarnings] };
58
67
  }
59
68
  async function replayEvents({
60
69
  events,
@@ -240,5 +249,5 @@ exports.replayEvents = replayEvents;
240
249
  exports.replayView = replayView;
241
250
  exports.resolveViewContract = resolveViewContract;
242
251
  exports.viewContractKey = viewContractKey;
243
- //# sourceMappingURL=chunk-O7IHZ53Y.cjs.map
244
- //# sourceMappingURL=chunk-O7IHZ53Y.cjs.map
252
+ //# sourceMappingURL=chunk-45TSN3GO.cjs.map
253
+ //# sourceMappingURL=chunk-45TSN3GO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources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OAAO,EAAA;AAAA,IACR;AAEA,IAAA,IAAI,aAAa,WAAA,EAAa;AAC7B,MAAA,OAAO,CAAA;AAAA,IACR;AAAA,EACD;AAEA,EAAA,OAAO,CAAA;AACR;AAEA,SAAS,gBAAgB,KAAA,EAA6B;AACrD,EAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,WAAA,IAAe,KAAA,CAAM,SAAS,CAAA;AACpD;AAEA,SAAS,YAAY,KAAA,EAA8B;AAClD,EAAA,OAAO,KAAA,YAAiB,OAAO,KAAA,CAAM,OAAA,KAAY,IAAI,IAAA,CAAK,KAAK,CAAA,CAAE,OAAA,EAAQ;AAC1E","file":"chunk-45TSN3GO.cjs","sourcesContent":["export interface ReplayableAssetEvent<Payload = unknown> {\n\tid: string;\n\ttenantId: string;\n\tspaceId: string;\n\teventType: string;\n\teventSchemaVersion?: number;\n\tsubjectType: string;\n\tsubjectId: string;\n\tpayload: Payload;\n\tsequence: number;\n\toccurredAt: Date | string;\n\trecordedAt: Date | string;\n\tactionInvocationId: string;\n\tcorrelationId: string;\n}\n\nimport type { PortableJsonSchema } from \"../objects\";\n\nexport interface ViewEventConsumption {\n\teventType: string;\n\tschemaVersions: number[];\n}\n\nexport interface ViewContract<State = unknown, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {\n\t/** Stable module-qualified logical identity, for example `orders/summary`. */\n\tname: `${string}/${string}`;\n\tversion: string;\n\tshape: PortableJsonSchema;\n\tconsumes: ViewEventConsumption[];\n\tscope: \"tenant-space\";\n\tsnapshotVersion: number;\n\tcompatibleSnapshotVersions?: number[];\n\tusage?: ViewUsageMetadata;\n\t/** Required to transform any older compatible snapshot into the current state shape. */\n\tupgradeSnapshot?: (data: unknown, fromVersion: number) => State | Promise<State>;\n\tinitialState: State;\n\tapplyEvent: (state: State, event: Event) => State | Promise<State>;\n}\n\nexport interface ViewUsageMetadata {\n\tsemanticRole?: string;\n\tcollection?: {\n\t\tpagination: \"cursor\" | \"offset\" | \"none\";\n\t\tfilterSchema?: PortableJsonSchema;\n\t\tsortFields?: string[];\n\t};\n\tfreshness?: { maximumAgeSeconds?: number; offlineUsable?: boolean };\n\tclassification?: \"public\" | \"internal\" | \"confidential\" | \"restricted\";\n}\n\nconst viewRegistry = new Map<string, ViewContract>();\n\nexport function viewContractKey(view: Pick<ViewContract, \"name\" | \"version\">): string {\n\treturn `${view.name}@${view.version}`;\n}\n\nexport function registerViewContract(view: ViewContract): void {\n\tconst key = viewContractKey(view);\n\tif (viewRegistry.has(key)) throw new Error(`View contract \"${key}\" is already registered.`);\n\tviewRegistry.set(key, view);\n}\n\nexport function registerViewContractIfMissing(view: ViewContract): void {\n\tif (!viewRegistry.has(viewContractKey(view))) registerViewContract(view);\n}\n\nexport function resolveViewContract(name: string, version: string): ViewContract | undefined {\n\treturn viewRegistry.get(`${name}@${version}`);\n}\n\nexport function getRegisteredViewContractKeys(): string[] {\n\treturn Array.from(viewRegistry.keys());\n}\n\nexport interface ReplayViewOptions<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {\n\tview: ViewContract<State, Event>;\n\tevents: Iterable<Event> | AsyncIterable<Event>;\n\tscope: ReplayScope;\n\tsnapshot?: (ReplaySnapshot<State> & { snapshotVersion: number }) | null;\n}\n\nexport async function replayView<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({\n\tview,\n\tevents,\n\tscope,\n\tsnapshot,\n}: ReplayViewOptions<State, Event>): Promise<ReplayEventsResult<State, Event>> {\n\tif (\n\t\tsnapshot &&\n\t\tsnapshot.snapshotVersion !== view.snapshotVersion &&\n\t\t!view.compatibleSnapshotVersions?.includes(snapshot.snapshotVersion)\n\t) {\n\t\tthrow new Error(\n\t\t\t`View \"${viewContractKey(view)}\" cannot resume snapshot version ${snapshot.snapshotVersion}.`,\n\t\t);\n\t}\n\tif (snapshot && snapshot.snapshotVersion !== view.snapshotVersion && !view.upgradeSnapshot) {\n\t\tthrow new Error(\n\t\t\t`View \"${viewContractKey(view)}\" must provide upgradeSnapshot for snapshot version ${snapshot.snapshotVersion}.`,\n\t\t);\n\t}\n\tconst upgradedSnapshot = snapshot && snapshot.snapshotVersion !== view.snapshotVersion\n\t\t? { ...snapshot, snapshotVersion: view.snapshotVersion, snapshotData: await view.upgradeSnapshot!(snapshot.snapshotData, snapshot.snapshotVersion) }\n\t\t: snapshot;\n\tconst accepted = new Map(\n\t\tview.consumes.map((consumption) => [consumption.eventType, new Set(consumption.schemaVersions)]),\n\t);\n\tconst sourceEvents: Event[] = [];\n\tfor await (const event of events) sourceEvents.push(event);\n\tconst preprocessingWarnings: ReplayWarning[] = [];\n\tconst orderedScopedEvents = sortEvents(filterEventsByScope(sourceEvents, scope, preprocessingWarnings), Boolean(scope.subjectType && scope.subjectId));\n\tconst versionWarnings: ReplayWarning[] = [];\n\tconst replayable = async function* (): AsyncIterable<Event> {\n\t\tfor (const event of orderedScopedEvents) {\n\t\t\tconst versions = accepted.get(event.eventType);\n\t\t\tif (versions && !versions.has(event.eventSchemaVersion ?? 1)) {\n\t\t\t\tversionWarnings.push({ code: \"unsupported_event_version\", eventId: event.id, message: `View \"${viewContractKey(view)}\" does not consume ${event.eventType} schema version ${event.eventSchemaVersion ?? 1}; replay stopped before this event so a compatible view can resume it later.` });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tyield event;\n\t\t}\n\t};\n\tconst result = await replayEvents({\n\t\tevents: replayable(),\n\t\tscope,\n\t\tinitialState: view.initialState,\n\t\tsnapshot: upgradedSnapshot,\n\t\tapplyEvent: (state, event) => accepted.has(event.eventType) ? view.applyEvent(state, event) : state,\n\t});\n\tconst preprocessingWarningKeys = new Set(preprocessingWarnings.map((warning) => JSON.stringify(warning)));\n\tconst resultWarnings = result.warnings.filter((warning) => !preprocessingWarningKeys.has(JSON.stringify(warning)));\n\treturn { ...result, warnings: [...preprocessingWarnings, ...versionWarnings, ...resultWarnings] };\n}\n\nexport interface ReplayScope {\n\ttenantId: string;\n\tspaceId: string;\n\tsubjectType?: string;\n\tsubjectId?: string;\n}\n\nexport interface ReplaySnapshot<State = unknown> {\n\tsnapshotData: State;\n\teventCursor?: string | null;\n\teventSequence?: number | null;\n}\n\nexport type ReplayWarningCode =\n\t| \"cursor_not_found\"\n\t| \"duplicate_event\"\n\t| \"missing_sequence\"\n\t| \"subject_scope_incomplete\"\n\t| \"unsupported_event_version\";\n\nexport interface ReplayWarning {\n\tcode: ReplayWarningCode;\n\tmessage: string;\n\teventId?: string;\n\tsubjectType?: string;\n\tsubjectId?: string;\n\texpectedSequence?: number;\n\tactualSequence?: number;\n}\n\nexport interface ReplayEventsOptions<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {\n\tevents: Iterable<Event> | AsyncIterable<Event>;\n\tscope: ReplayScope;\n\tinitialState: State;\n\tsnapshot?: ReplaySnapshot<State> | null;\n\tapplyEvent: (state: State, event: Event) => State | Promise<State>;\n}\n\nexport interface ReplayEventsResult<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {\n\tstate: State;\n\tappliedEvents: Event[];\n\twarnings: ReplayWarning[];\n\teventCursor: string | null;\n\teventSequence: number;\n}\n\nexport async function replayEvents<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({\n\tevents,\n\tscope,\n\tinitialState,\n\tsnapshot,\n\tapplyEvent,\n}: ReplayEventsOptions<State, Event>): Promise<ReplayEventsResult<State, Event>> {\n\tconst warnings: ReplayWarning[] = [];\n\tconst scopedEvents = filterEventsByScope(await collectEvents(events), scope, warnings);\n\tconst orderedEvents = sortEvents(scopedEvents, isSubjectScoped(scope));\n\tconst uniqueEvents = removeDuplicateEvents(orderedEvents, warnings);\n\tconst resumableEvents = applyCursor(uniqueEvents, snapshot, isSubjectScoped(scope), warnings);\n\n\tlet state = snapshot?.snapshotData ?? initialState;\n\tconst appliedEvents: Event[] = [];\n\tlet eventCursor = snapshot?.eventCursor ?? null;\n\tlet eventSequence = snapshot?.eventSequence ?? 0;\n\n\tfor (const event of resumableEvents) {\n\t\tstate = await applyEvent(state, event);\n\t\tappliedEvents.push(event);\n\t\teventCursor = event.id;\n\t\teventSequence = event.sequence;\n\t}\n\n\treturn {\n\t\tstate,\n\t\tappliedEvents,\n\t\twarnings,\n\t\teventCursor,\n\t\teventSequence,\n\t};\n}\n\nasync function collectEvents<Event extends ReplayableAssetEvent>(\n\tevents: Iterable<Event> | AsyncIterable<Event>,\n): Promise<Event[]> {\n\tconst collected: Event[] = [];\n\n\tif (Symbol.asyncIterator in events) {\n\t\tfor await (const event of events) {\n\t\t\tcollected.push(event);\n\t\t}\n\n\t\treturn collected;\n\t}\n\n\tfor (const event of events) {\n\t\tcollected.push(event);\n\t}\n\n\treturn collected;\n}\n\nfunction filterEventsByScope<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\tscope: ReplayScope,\n\twarnings: ReplayWarning[],\n): Event[] {\n\tif ((scope.subjectType && !scope.subjectId) || (!scope.subjectType && scope.subjectId)) {\n\t\twarnings.push({\n\t\t\tcode: \"subject_scope_incomplete\",\n\t\t\tmessage: \"Both subjectType and subjectId are required for subject-scoped replay.\",\n\t\t\tsubjectType: scope.subjectType,\n\t\t\tsubjectId: scope.subjectId,\n\t\t});\n\t}\n\n\treturn events.filter((event) => {\n\t\tif (event.tenantId !== scope.tenantId || event.spaceId !== scope.spaceId) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (scope.subjectType && event.subjectType !== scope.subjectType) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (scope.subjectId && event.subjectId !== scope.subjectId) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t});\n}\n\nfunction removeDuplicateEvents<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\twarnings: ReplayWarning[],\n): Event[] {\n\tconst seenEventIds = new Set<string>();\n\tconst uniqueEvents: Event[] = [];\n\n\tfor (const event of events) {\n\t\tif (seenEventIds.has(event.id)) {\n\t\t\twarnings.push({\n\t\t\t\tcode: \"duplicate_event\",\n\t\t\t\tmessage: `Duplicate event ${event.id} ignored during replay.`,\n\t\t\t\teventId: event.id,\n\t\t\t\tsubjectType: event.subjectType,\n\t\t\t\tsubjectId: event.subjectId,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tseenEventIds.add(event.id);\n\t\tuniqueEvents.push(event);\n\t}\n\n\trecordMissingSequenceWarnings(uniqueEvents, warnings);\n\n\treturn uniqueEvents;\n}\n\nfunction recordMissingSequenceWarnings<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\twarnings: ReplayWarning[],\n): void {\n\tconst lastSequenceBySubject = new Map<string, number>();\n\n\tfor (const event of events) {\n\t\tconst subjectKey = `${event.subjectType}:${event.subjectId}`;\n\t\tconst previousSequence = lastSequenceBySubject.get(subjectKey);\n\t\tconst expectedSequence = previousSequence === undefined ? event.sequence : previousSequence + 1;\n\n\t\tif (previousSequence !== undefined && event.sequence > expectedSequence) {\n\t\t\twarnings.push({\n\t\t\t\tcode: \"missing_sequence\",\n\t\t\t\tmessage: `Missing event sequence for ${subjectKey}: expected ${expectedSequence}, received ${event.sequence}.`,\n\t\t\t\teventId: event.id,\n\t\t\t\tsubjectType: event.subjectType,\n\t\t\t\tsubjectId: event.subjectId,\n\t\t\t\texpectedSequence,\n\t\t\t\tactualSequence: event.sequence,\n\t\t\t});\n\t\t}\n\n\t\tlastSequenceBySubject.set(subjectKey, Math.max(previousSequence ?? event.sequence, event.sequence));\n\t}\n}\n\nfunction applyCursor<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\tsnapshot: ReplaySnapshot | null | undefined,\n\tsubjectScoped: boolean,\n\twarnings: ReplayWarning[],\n): Event[] {\n\tconst eventCursor = snapshot?.eventCursor;\n\n\tif (eventCursor) {\n\t\tconst cursorIndex = events.findIndex((event) => event.id === eventCursor);\n\n\t\tif (cursorIndex >= 0) {\n\t\t\treturn events.slice(cursorIndex + 1);\n\t\t}\n\n\t\twarnings.push({\n\t\t\tcode: \"cursor_not_found\",\n\t\t\tmessage: `Snapshot cursor ${eventCursor} was not found in the scoped event stream.`,\n\t\t\teventId: eventCursor,\n\t\t});\n\t}\n\n\tif (subjectScoped && snapshot?.eventSequence !== undefined && snapshot.eventSequence !== null) {\n\t\treturn events.filter((event) => event.sequence > snapshot.eventSequence!);\n\t}\n\n\treturn events;\n}\n\nfunction sortEvents<Event extends ReplayableAssetEvent>(events: Event[], subjectScoped: boolean): Event[] {\n\treturn [...events].sort((first, second) =>\n\t\tsubjectScoped ? compareSubjectEvents(first, second) : compareGlobalEvents(first, second),\n\t);\n}\n\nfunction compareSubjectEvents(first: ReplayableAssetEvent, second: ReplayableAssetEvent): number {\n\treturn compareValues(\n\t\t[first.sequence, toTimestamp(first.recordedAt), toTimestamp(first.occurredAt), first.id],\n\t\t[second.sequence, toTimestamp(second.recordedAt), toTimestamp(second.occurredAt), second.id],\n\t);\n}\n\nfunction compareGlobalEvents(first: ReplayableAssetEvent, second: ReplayableAssetEvent): number {\n\treturn compareValues(\n\t\t[\n\t\t\ttoTimestamp(first.recordedAt),\n\t\t\ttoTimestamp(first.occurredAt),\n\t\t\tfirst.actionInvocationId,\n\t\t\tfirst.correlationId,\n\t\t\tfirst.subjectType,\n\t\t\tfirst.subjectId,\n\t\t\tfirst.sequence,\n\t\t\tfirst.id,\n\t\t],\n\t\t[\n\t\t\ttoTimestamp(second.recordedAt),\n\t\t\ttoTimestamp(second.occurredAt),\n\t\t\tsecond.actionInvocationId,\n\t\t\tsecond.correlationId,\n\t\t\tsecond.subjectType,\n\t\t\tsecond.subjectId,\n\t\t\tsecond.sequence,\n\t\t\tsecond.id,\n\t\t],\n\t);\n}\n\nfunction compareValues(firstValues: Array<number | string>, secondValues: Array<number | string>): number {\n\tfor (const [index, firstValue] of firstValues.entries()) {\n\t\tconst secondValue = secondValues[index];\n\n\t\tif (firstValue < secondValue) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (firstValue > secondValue) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nfunction isSubjectScoped(scope: ReplayScope): boolean {\n\treturn Boolean(scope.subjectType && scope.subjectId);\n}\n\nfunction toTimestamp(value: Date | string): number {\n\treturn value instanceof Date ? value.getTime() : new Date(value).getTime();\n}\n"]}
@@ -21,6 +21,10 @@ var supportedSchemaKeywords = /* @__PURE__ */ new Set([
21
21
  "required",
22
22
  "additionalProperties",
23
23
  "items",
24
+ "prefixItems",
25
+ "propertyNames",
26
+ "patternProperties",
27
+ "dependentRequired",
24
28
  "allOf",
25
29
  "anyOf",
26
30
  "oneOf",
@@ -38,7 +42,16 @@ var supportedSchemaKeywords = /* @__PURE__ */ new Set([
38
42
  "uniqueItems",
39
43
  "default",
40
44
  "readOnly",
41
- "writeOnly"
45
+ "writeOnly",
46
+ "deprecated",
47
+ "contentEncoding",
48
+ "contentMediaType",
49
+ "multipleOf",
50
+ "if",
51
+ "then",
52
+ "else",
53
+ "examples",
54
+ "$comment"
42
55
  ]);
43
56
  function assertPortableJsonSchema(schema, path = "schema") {
44
57
  if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
@@ -66,6 +79,10 @@ function assertPortableJsonSchema(schema, path = "schema") {
66
79
  assertPortableJsonSchema(child, `${path}.$defs.${name}`);
67
80
  }
68
81
  }
82
+ if (value.patternProperties !== void 0) {
83
+ if (!value.patternProperties || typeof value.patternProperties !== "object" || Array.isArray(value.patternProperties)) throw new Error(`${path}.patternProperties must be an object.`);
84
+ for (const [name, child] of Object.entries(value.patternProperties)) assertPortableJsonSchema(child, `${path}.patternProperties.${name}`);
85
+ }
69
86
  for (const keyword of ["allOf", "anyOf", "oneOf"]) {
70
87
  if (value[keyword] !== void 0) {
71
88
  if (!Array.isArray(value[keyword])) throw new Error(`${path}.${keyword} must be an array.`);
@@ -73,6 +90,7 @@ function assertPortableJsonSchema(schema, path = "schema") {
73
90
  }
74
91
  }
75
92
  if (value.not !== void 0) assertPortableJsonSchema(value.not, `${path}.not`);
93
+ for (const keyword of ["propertyNames", "if", "then", "else"]) if (value[keyword] !== void 0) assertPortableJsonSchema(value[keyword], `${path}.${keyword}`);
76
94
  if (value.additionalProperties !== void 0 && typeof value.additionalProperties !== "boolean") {
77
95
  assertPortableJsonSchema(value.additionalProperties, `${path}.additionalProperties`);
78
96
  }
@@ -83,6 +101,13 @@ function assertPortableJsonSchema(schema, path = "schema") {
83
101
  assertPortableJsonSchema(value.items, `${path}.items`);
84
102
  }
85
103
  }
104
+ if (value.prefixItems !== void 0) {
105
+ if (!Array.isArray(value.prefixItems)) throw new Error(`${path}.prefixItems must be an array.`);
106
+ value.prefixItems.forEach((child, index) => assertPortableJsonSchema(child, `${path}.prefixItems[${index}]`));
107
+ }
108
+ if (value.dependentRequired !== void 0) {
109
+ if (!value.dependentRequired || typeof value.dependentRequired !== "object" || Array.isArray(value.dependentRequired) || Object.values(value.dependentRequired).some((items) => !Array.isArray(items) || items.some((item) => typeof item !== "string"))) throw new Error(`${path}.dependentRequired must map property names to arrays of property names.`);
110
+ }
86
111
  if (value.required !== void 0 && (!Array.isArray(value.required) || value.required.some((item) => typeof item !== "string"))) {
87
112
  throw new Error(`${path}.required must be an array of property names.`);
88
113
  }
@@ -106,5 +131,5 @@ function getRegisteredObjectTypes() {
106
131
  }
107
132
 
108
133
  export { assertObjectType, assertPortableJsonSchema, getRegisteredObjectTypes, isValidObjectType, registerObjectType };
109
- //# sourceMappingURL=chunk-3S6UTP4X.js.map
110
- //# sourceMappingURL=chunk-3S6UTP4X.js.map
134
+ //# sourceMappingURL=chunk-4MMMXV4Q.js.map
135
+ //# sourceMappingURL=chunk-4MMMXV4Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../objects/index.ts"],"names":[],"mappings":";AAAA,IAAM,kBAAA,uBAAyB,GAAA,CAAY;AAAA,EAC1C,YAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACD,CAAC,CAAA;AA4DD,IAAM,uBAAA,uBAA8B,GAAA,CAAI;AAAA,EACvC,SAAA;AAAA,EA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"PolicyEvaluation\",\n\t\"ApprovalRequest\",\n\t\"ConsentRecord\",\n\t\"AgentRun\",\n]);\n\nexport type FabricObjectType = string;\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };\n\n/**\n * Dependency-free JSON Schema profile accepted in portable module manifests.\n * Unknown extension keywords must use an `x-` prefix. Runtime validators may\n * support more vocabulary, but exported entity contracts stay in this profile.\n */\nexport interface PortableJsonSchema {\n\t$schema?: string;\n\t$id?: string;\n\t$ref?: string;\n\t$defs?: Record<string, PortableJsonSchema>;\n\ttitle?: string;\n\tdescription?: string;\n\ttype?: \"null\" | \"boolean\" | \"object\" | \"array\" | \"number\" | \"integer\" | \"string\" | Array<\"null\" | \"boolean\" | \"object\" | \"array\" | \"number\" | \"integer\" | \"string\">;\n\tenum?: JsonValue[];\n\tconst?: JsonValue;\n\tproperties?: Record<string, PortableJsonSchema>;\n\trequired?: string[];\n\tadditionalProperties?: boolean | PortableJsonSchema;\n\titems?: PortableJsonSchema | PortableJsonSchema[];\n\tprefixItems?: PortableJsonSchema[];\n\tpropertyNames?: PortableJsonSchema;\n\tpatternProperties?: Record<string, PortableJsonSchema>;\n\tdependentRequired?: Record<string, string[]>;\n\tallOf?: PortableJsonSchema[];\n\tanyOf?: PortableJsonSchema[];\n\toneOf?: PortableJsonSchema[];\n\tnot?: PortableJsonSchema;\n\tif?: PortableJsonSchema;\n\tthen?: PortableJsonSchema;\n\telse?: PortableJsonSchema;\n\tminimum?: number;\n\tmaximum?: number;\n\texclusiveMinimum?: number;\n\texclusiveMaximum?: number;\n\tmultipleOf?: number;\n\tminLength?: number;\n\tmaxLength?: number;\n\tpattern?: string;\n\tformat?: string;\n\tminItems?: number;\n\tmaxItems?: number;\n\tuniqueItems?: boolean;\n\tdefault?: JsonValue;\n\treadOnly?: boolean;\n\twriteOnly?: boolean;\n\tdeprecated?: boolean;\n\tcontentEncoding?: string;\n\tcontentMediaType?: string;\n\texamples?: JsonValue[];\n\t$comment?: string;\n\t[key: `x-${string}`]: JsonValue | undefined;\n}\n\nconst supportedSchemaKeywords = new Set([\n\t\"$schema\", \"$id\", \"$ref\", \"$defs\", \"title\", \"description\", \"type\", \"enum\", \"const\",\n\t\"properties\", \"required\", \"additionalProperties\", \"items\", \"prefixItems\", \"propertyNames\", \"patternProperties\", \"dependentRequired\", \"allOf\", \"anyOf\", \"oneOf\",\n\t\"not\", \"minimum\", \"maximum\", \"exclusiveMinimum\", \"exclusiveMaximum\", \"minLength\",\n\t\"maxLength\", \"pattern\", \"format\", \"minItems\", \"maxItems\", \"uniqueItems\", \"default\",\n\t\"readOnly\", \"writeOnly\", \"deprecated\", \"contentEncoding\", \"contentMediaType\", \"multipleOf\", \"if\", \"then\", \"else\", \"examples\", \"$comment\",\n]);\n\nexport function assertPortableJsonSchema(\n\tschema: unknown,\n\tpath = \"schema\",\n): asserts schema is PortableJsonSchema {\n\tif (!schema || typeof schema !== \"object\" || Array.isArray(schema)) {\n\t\tthrow new Error(`${path} must be a JSON Schema object.`);\n\t}\n\tconst value = schema as Record<string, unknown>;\n\tfor (const keyword of Object.keys(value)) {\n\t\tif (!supportedSchemaKeywords.has(keyword) && !keyword.startsWith(\"x-\")) {\n\t\t\tthrow new Error(`${path} uses unsupported JSON Schema keyword \"${keyword}\".`);\n\t\t}\n\t}\n\tif (value.properties !== undefined) {\n\t\tif (!value.properties || typeof value.properties !== \"object\" || Array.isArray(value.properties)) {\n\t\t\tthrow new Error(`${path}.properties must be an object.`);\n\t\t}\n\t\tfor (const [name, child] of Object.entries(value.properties)) {\n\t\t\tassertPortableJsonSchema(child, `${path}.properties.${name}`);\n\t\t}\n\t}\n\tif (value.$defs !== undefined) {\n\t\tif (!value.$defs || typeof value.$defs !== \"object\" || Array.isArray(value.$defs)) {\n\t\t\tthrow new Error(`${path}.$defs must be an object.`);\n\t\t}\n\t\tfor (const [name, child] of Object.entries(value.$defs)) {\n\t\t\tassertPortableJsonSchema(child, `${path}.$defs.${name}`);\n\t\t}\n\t}\n\tif (value.patternProperties !== undefined) {\n\t\tif (!value.patternProperties || typeof value.patternProperties !== \"object\" || Array.isArray(value.patternProperties)) throw new Error(`${path}.patternProperties must be an object.`);\n\t\tfor (const [name, child] of Object.entries(value.patternProperties)) assertPortableJsonSchema(child, `${path}.patternProperties.${name}`);\n\t}\n\tfor (const keyword of [\"allOf\", \"anyOf\", \"oneOf\"] as const) {\n\t\tif (value[keyword] !== undefined) {\n\t\t\tif (!Array.isArray(value[keyword])) throw new Error(`${path}.${keyword} must be an array.`);\n\t\t\tvalue[keyword].forEach((child, index) => assertPortableJsonSchema(child, `${path}.${keyword}[${index}]`));\n\t\t}\n\t}\n\tif (value.not !== undefined) assertPortableJsonSchema(value.not, `${path}.not`);\n\tfor (const keyword of [\"propertyNames\", \"if\", \"then\", \"else\"] as const) if (value[keyword] !== undefined) assertPortableJsonSchema(value[keyword], `${path}.${keyword}`);\n\tif (value.additionalProperties !== undefined && typeof value.additionalProperties !== \"boolean\") {\n\t\tassertPortableJsonSchema(value.additionalProperties, `${path}.additionalProperties`);\n\t}\n\tif (value.items !== undefined) {\n\t\tif (Array.isArray(value.items)) {\n\t\t\tvalue.items.forEach((child, index) => assertPortableJsonSchema(child, `${path}.items[${index}]`));\n\t\t} else {\n\t\t\tassertPortableJsonSchema(value.items, `${path}.items`);\n\t\t}\n\t}\n\tif (value.prefixItems !== undefined) {\n\t\tif (!Array.isArray(value.prefixItems)) throw new Error(`${path}.prefixItems must be an array.`);\n\t\tvalue.prefixItems.forEach((child, index) => assertPortableJsonSchema(child, `${path}.prefixItems[${index}]`));\n\t}\n\tif (value.dependentRequired !== undefined) {\n\t\tif (!value.dependentRequired || typeof value.dependentRequired !== \"object\" || Array.isArray(value.dependentRequired) || Object.values(value.dependentRequired).some((items) => !Array.isArray(items) || items.some((item) => typeof item !== \"string\"))) throw new Error(`${path}.dependentRequired must map property names to arrays of property names.`);\n\t}\n\tif (value.required !== undefined && (!Array.isArray(value.required) || value.required.some((item) => typeof item !== \"string\"))) {\n\t\tthrow new Error(`${path}.required must be an array of property names.`);\n\t}\n}\n\nexport function assertObjectType(type: string): asserts type is FabricObjectType {\n\tif (!/^[A-Z][a-zA-Z0-9]*$/.test(type)) {\n\t\tthrow new Error(\n\t\t\t`Invalid object type: \"${type}\". Object types must be PascalCase alphanumeric.`,\n\t\t);\n\t}\n}\n\nexport function registerObjectType(type: string): void {\n\tassertObjectType(type);\n\tobjectTypeRegistry.add(type);\n}\n\nexport function isValidObjectType(type: string): boolean {\n\treturn objectTypeRegistry.has(type);\n}\n\nexport function getRegisteredObjectTypes(): string[] {\n\treturn Array.from(objectTypeRegistry);\n}\n"]}
@@ -55,5 +55,5 @@ function registerActionIfMissing(definition) {
55
55
  }
56
56
 
57
57
  export { ACTOR_TYPES, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction };
58
- //# sourceMappingURL=chunk-JM55UQWK.js.map
59
- //# sourceMappingURL=chunk-JM55UQWK.js.map
58
+ //# sourceMappingURL=chunk-4RMKUYRX.js.map
59
+ //# sourceMappingURL=chunk-4RMKUYRX.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,CAAkC,SAAS,KAAK,CAAA;AACzD;AAEO,SAAS,gBAAgB,KAAA,EAA2C;AAC1E,EAAA,IAAI,CAAC,WAAA,CAAY,KAAK,CAAA,EAAG;AACxB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK,CAAA,CAAE,CAAA;AAAA,EAC9C;AACD;AA2KA,IAAM,QAAA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,UAAA,EAAoC;AAC3E,EAAA,IAAI,CAAC,QAAA,CAAS,GAAA,CAAI,UAAA,CAAW,QAAQ,CAAA,EAAG;AACvC,IAAA,cAAA,CAAe,UAAU,CAAA;AAAA,EAC1B;AACD","file":"chunk-4RMKUYRX.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\nconst registry = new Map<ActionId, ActionDefinition>();\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 function registerAction(definition: ActionDefinition): void {\n\tassertActionId(definition.actionId);\n\n\tif (registry.has(definition.actionId)) {\n\t\tthrow new Error(`Action \"${definition.actionId}\" is already registered`);\n\t}\n\n\tif (definition.mutatesDomain && definition.emitsEvents.length === 0) {\n\t\tthrow new Error(\n\t\t\t`Action \"${definition.actionId}\" mutates domain but emits no events. ` +\n\t\t\t\t`Every mutating action must emit at least one AssetEvent.`,\n\t\t);\n\t}\n\n\tregistry.set(definition.actionId, definition);\n}\n\nexport function resolveAction(actionId: ActionId): ActionDefinition | undefined {\n\treturn registry.get(actionId);\n}\n\nexport function isRegisteredActionId(actionId: string): actionId is ActionId {\n\treturn registry.has(actionId as ActionId);\n}\n\nexport function resolveRegisteredAction(actionId: string): ActionDefinition | undefined {\n\tif (!isRegisteredActionId(actionId)) {\n\t\treturn undefined;\n\t}\n\n\treturn resolveAction(actionId);\n}\n\nexport function getRegisteredActionIds(): ActionId[] {\n\treturn Array.from(registry.keys());\n}\n\nexport function registerActionIfMissing(definition: ActionDefinition): void {\n\tif (!registry.has(definition.actionId)) {\n\t\tregisterAction(definition);\n\t}\n}\n"]}
@@ -1,10 +1,10 @@
1
- import { assertPortableJsonSchema, registerObjectType } from './chunk-3S6UTP4X.js';
1
+ import { assertPortableJsonSchema, registerObjectType } from './chunk-4MMMXV4Q.js';
2
2
  import { registerPolicyIfMissing } from './chunk-6ER62UUN.js';
3
- import { registerViewContractIfMissing } from './chunk-7WASIL46.js';
3
+ import { registerViewContractIfMissing } from './chunk-LXS6SURU.js';
4
4
  import { registerStateMachineIfMissing } from './chunk-T2JLSZN6.js';
5
- import { registerActionIfMissing } from './chunk-JM55UQWK.js';
5
+ import { registerActionIfMissing } from './chunk-4RMKUYRX.js';
6
6
  import { registerDisplayRenderer } from './chunk-O5WVBQ7P.js';
7
- import { isValidEventType, registerSubjectType, registerEventType } from './chunk-4YQOGV7H.js';
7
+ import { isValidEventType, registerSubjectType, registerEventType } from './chunk-3O4GMCCE.js';
8
8
 
9
9
  // modules/index.ts
10
10
  var registeredModuleNamespaces = /* @__PURE__ */ new Set();
@@ -126,7 +126,21 @@ function validateManifest(module, context = {}) {
126
126
  slots.add(slot.name);
127
127
  if (slot.shape) assertPortableJsonSchema(slot.shape, `Capability slot "${slot.name}" shape`);
128
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
+ }
134
+ for (const port of module.capability.requirements?.ports ?? []) {
135
+ if (!/^[a-z][a-z0-9-]*$/.test(port.name)) throw new Error(`Module "${module.namespace}" capability has invalid port requirement "${port.name}".`);
136
+ }
137
+ }
138
+ for (const eventType of module.eventTypes ?? []) if (typeof eventType !== "string" && eventType.schema) assertPortableJsonSchema(eventType.schema, `Event "${eventType.eventType}" schema`);
139
+ for (const action of module.actions ?? []) {
140
+ if (action.execution?.idempotency === "required" && !action.idempotent) throw new Error(`Action "${action.actionId}" requires idempotency but is not declared idempotent.`);
141
+ if (action.execution?.connectivity === "offline-capturable" && action.execution.idempotency === "prohibited") throw new Error(`Offline action "${action.actionId}" cannot prohibit idempotency.`);
129
142
  }
143
+ for (const view of module.views ?? []) if (view.usage?.collection?.filterSchema) assertPortableJsonSchema(view.usage.collection.filterSchema, `View "${view.name}" filter schema`);
130
144
  for (const dependency of dependencies) {
131
145
  validateModuleNamespace(dependency);
132
146
  if (dependency === module.namespace) {
@@ -147,9 +161,31 @@ function validateManifest(module, context = {}) {
147
161
  }
148
162
  }
149
163
  for (const objectType of module.objectTypes ?? []) {
164
+ if (typeof objectType !== "string") {
165
+ for (const relation of objectType.relations ?? []) {
166
+ const targetNamespace = relation.target.slice(0, relation.target.indexOf("."));
167
+ if (targetNamespace !== module.namespace && !dependencies.includes(targetNamespace)) {
168
+ throw new Error(`Module "${module.namespace}" relation "${relation.name}" targets module "${targetNamespace}" without declaring it as a dependency.`);
169
+ }
170
+ }
171
+ }
150
172
  validateObjectDefinition(objectType, module.namespace, context);
151
173
  }
152
174
  for (const action of module.actions ?? []) {
175
+ let parameterSchema;
176
+ try {
177
+ parameterSchema = action.schema.toJSONSchema?.();
178
+ } catch {
179
+ parameterSchema = void 0;
180
+ }
181
+ if (parameterSchema !== void 0) assertPortableJsonSchema(parameterSchema, `Action "${action.actionId}" parameters`);
182
+ let resultSchema;
183
+ try {
184
+ resultSchema = action.resultSchema?.toJSONSchema?.();
185
+ } catch {
186
+ resultSchema = void 0;
187
+ }
188
+ if (resultSchema !== void 0) assertPortableJsonSchema(resultSchema, `Action "${action.actionId}" result`);
153
189
  if (!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9_]*$/.test(action.actionId)) {
154
190
  throw new Error(`Invalid action ID: ${action.actionId}`);
155
191
  }
@@ -343,5 +379,5 @@ function registerFabricModules(modules) {
343
379
  }
344
380
 
345
381
  export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace };
346
- //# sourceMappingURL=chunk-3JQI3OFC.js.map
347
- //# sourceMappingURL=chunk-3JQI3OFC.js.map
382
+ //# sourceMappingURL=chunk-5PDVZXEI.js.map
383
+ //# sourceMappingURL=chunk-5PDVZXEI.js.map