@fabricorg/platform 0.11.1 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/actions/index.cjs +11 -11
- package/dist/actions/index.d.cts +22 -2
- package/dist/actions/index.d.ts +22 -2
- package/dist/actions/index.js +1 -1
- package/dist/{chunk-NFHS5NWD.js → chunk-35SDMFCR.js} +19 -5
- package/dist/chunk-35SDMFCR.js.map +1 -0
- package/dist/{chunk-4YQOGV7H.js → chunk-3O4GMCCE.js} +2 -2
- package/dist/chunk-3O4GMCCE.js.map +1 -0
- package/dist/{chunk-JM55UQWK.js → chunk-4RMKUYRX.js} +2 -2
- package/dist/chunk-4RMKUYRX.js.map +1 -0
- package/dist/{chunk-JAXDEK5Z.cjs → chunk-7RV5REPT.cjs} +2 -2
- package/dist/chunk-7RV5REPT.cjs.map +1 -0
- package/dist/{chunk-3WEHM2P3.cjs → chunk-7SHNYYGI.cjs} +53 -14
- package/dist/chunk-7SHNYYGI.cjs.map +1 -0
- package/dist/{chunk-FN6IYVBK.js → chunk-FSUYD4F4.js} +53 -14
- package/dist/chunk-FSUYD4F4.js.map +1 -0
- package/dist/{chunk-N3OUWEYA.js → chunk-HL77HWWP.js} +6 -3
- package/dist/chunk-HL77HWWP.js.map +1 -0
- package/dist/{chunk-HLRIXNVG.cjs → chunk-JOATYJXQ.cjs} +2 -2
- package/dist/chunk-JOATYJXQ.cjs.map +1 -0
- package/dist/{chunk-K27DUWRY.cjs → chunk-LAZL2GDT.cjs} +25 -11
- package/dist/chunk-LAZL2GDT.cjs.map +1 -0
- package/dist/{chunk-JIT3UR27.cjs → chunk-ZZGSS65W.cjs} +9 -6
- package/dist/chunk-ZZGSS65W.cjs.map +1 -0
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.cts +6 -1
- package/dist/events/index.d.ts +6 -1
- package/dist/events/index.js +1 -1
- package/dist/index.cjs +42 -42
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/manifest/index.cjs +11 -11
- package/dist/manifest/index.d.cts +5 -2
- package/dist/manifest/index.d.ts +5 -2
- package/dist/manifest/index.js +5 -5
- package/dist/modules/index.cjs +11 -11
- package/dist/modules/index.d.cts +23 -1
- package/dist/modules/index.d.ts +23 -1
- package/dist/modules/index.js +4 -4
- package/dist/projections/index.cjs +8 -8
- package/dist/projections/index.d.cts +28 -3
- package/dist/projections/index.d.ts +28 -3
- package/dist/projections/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3WEHM2P3.cjs.map +0 -1
- package/dist/chunk-4YQOGV7H.js.map +0 -1
- package/dist/chunk-FN6IYVBK.js.map +0 -1
- package/dist/chunk-HLRIXNVG.cjs.map +0 -1
- package/dist/chunk-JAXDEK5Z.cjs.map +0 -1
- package/dist/chunk-JIT3UR27.cjs.map +0 -1
- package/dist/chunk-JM55UQWK.js.map +0 -1
- package/dist/chunk-K27DUWRY.cjs.map +0 -1
- package/dist/chunk-N3OUWEYA.js.map +0 -1
- package/dist/chunk-NFHS5NWD.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @fabricorg/platform
|
|
2
2
|
|
|
3
|
+
## 0.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Let view replay consume event streams that begin after a durable snapshot checkpoint while retaining
|
|
8
|
+
the prior cursor and sequence when no new events are available. This enables efficient, deterministic
|
|
9
|
+
`ProjectionHost` refresh without manufacturing cursor-not-found warnings.
|
|
10
|
+
- Persist per-subject sequence high-water marks so incremental replay detects gaps across snapshot
|
|
11
|
+
boundaries and does not reapply events already represented by a durable checkpoint.
|
|
12
|
+
- Fail closed when an event source claims its stream starts after a snapshot but no durable cursor is
|
|
13
|
+
present, preventing a full stream from being folded onto snapshot state twice.
|
|
14
|
+
|
|
15
|
+
## 0.12.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- Deliver Phase 1 correctness and contracts: payload-bound idempotency with staged enforcement,
|
|
20
|
+
capture/replay authority evidence, bounded invocation provenance, capability execution and view usage
|
|
21
|
+
semantics, event-schema compatibility classification, and deterministic conformance plans.
|
|
22
|
+
|
|
3
23
|
## 0.11.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/actions/index.cjs
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
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
|
|
9
|
+
get: function () { return chunkJOATYJXQ_cjs.ACTOR_TYPES; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "assertActionId", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkJOATYJXQ_cjs.assertActionId; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "assertActorType", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkJOATYJXQ_cjs.assertActorType; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "getRegisteredActionIds", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkJOATYJXQ_cjs.getRegisteredActionIds; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "isActorType", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkJOATYJXQ_cjs.isActorType; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "isRegisteredActionId", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkJOATYJXQ_cjs.isRegisteredActionId; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "registerAction", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkJOATYJXQ_cjs.registerAction; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "registerActionIfMissing", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkJOATYJXQ_cjs.registerActionIfMissing; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "resolveAction", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkJOATYJXQ_cjs.resolveAction; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "resolveRegisteredAction", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkJOATYJXQ_cjs.resolveRegisteredAction; }
|
|
46
46
|
});
|
|
47
47
|
//# sourceMappingURL=index.cjs.map
|
|
48
48
|
//# sourceMappingURL=index.cjs.map
|
package/dist/actions/index.d.cts
CHANGED
|
@@ -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 };
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -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 };
|
package/dist/actions/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ACTOR_TYPES, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction } from '../chunk-
|
|
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
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { assertPortableJsonSchema, registerObjectType } from './chunk-4MMMXV4Q.js';
|
|
2
2
|
import { registerPolicyIfMissing } from './chunk-6ER62UUN.js';
|
|
3
|
-
import { registerViewContractIfMissing } from './chunk-
|
|
3
|
+
import { registerViewContractIfMissing } from './chunk-FSUYD4F4.js';
|
|
4
4
|
import { registerStateMachineIfMissing } from './chunk-T2JLSZN6.js';
|
|
5
|
-
import { registerActionIfMissing } from './chunk-
|
|
5
|
+
import { registerActionIfMissing } from './chunk-4RMKUYRX.js';
|
|
6
6
|
import { registerDisplayRenderer } from './chunk-O5WVBQ7P.js';
|
|
7
|
-
import { isValidEventType, registerSubjectType, registerEventType } from './chunk-
|
|
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) {
|
|
@@ -365,5 +379,5 @@ function registerFabricModules(modules) {
|
|
|
365
379
|
}
|
|
366
380
|
|
|
367
381
|
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace };
|
|
368
|
-
//# sourceMappingURL=chunk-
|
|
369
|
-
//# sourceMappingURL=chunk-
|
|
382
|
+
//# sourceMappingURL=chunk-35SDMFCR.js.map
|
|
383
|
+
//# sourceMappingURL=chunk-35SDMFCR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../modules/index.ts"],"names":[],"mappings":";;;;;;;;;AAqKA,IAAM,0BAAA,uBAAiC,GAAA,EAAY;AACnD,IAAM,8BAAA,uBAAqC,GAAA,EAAY;AACvD,IAAM,2BAAA,uBAAkC,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AA8B,MAAM,CAAA;AAAA,EACrC;AAEA,EAAA,OAAO,aAAA;AACR","file":"chunk-35SDMFCR.js","sourcesContent":["import { registerActionIfMissing, type ActionDefinition } from \"../actions\";\nimport { registerDisplayRenderer, type DisplayRenderer } from \"../displays\";\nimport { isValidEventType, registerEventType, registerSubjectType } from \"../events\";\nimport {\n\tassertPortableJsonSchema,\n\tregisterObjectType,\n\ttype JsonValue,\n\ttype PortableJsonSchema,\n} from \"../objects\";\nimport { registerPolicyIfMissing, type PolicyEvaluator } from \"../policies\";\nimport { registerStateMachineIfMissing, type StateMachineDefinition } from \"../state-machines\";\nimport { registerViewContractIfMissing, type ViewContract } from \"../projections\";\n\nexport interface ModuleDependency {\n\tnamespace: string;\n\tversion?: string;\n\toptional?: boolean;\n}\n\nexport type ModuleDependencyInput = string | ModuleDependency;\n\nexport interface IdPrefixRegistration {\n\tprefix: string;\n\tname: string;\n\tmodule: string;\n}\n\nexport interface EventTypeRegistration {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n\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 ModuleDisplayRendererRegistration {\n\teventType: string;\n\trenderer: DisplayRenderer;\n}\n\nexport interface PolicyRegistration {\n\tid: string;\n\tversion?: string;\n\tdescription?: string;\n}\n\nexport interface StateMachineRegistration {\n\tentityType: string;\n\tstates: string[];\n}\n\nexport interface CapabilitySlotDefinition {\n\tname: string;\n\tdescription: string;\n\tshape?: PortableJsonSchema;\n}\n\nexport interface CapabilityActionIntent {\n\tname: string;\n\tactionId: `${string}.${string}`;\n\tdescription?: 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\troles?: string[];\n\tstability: \"experimental\" | \"beta\" | \"stable\" | \"deprecated\";\n\tdeprecated?: { since: string; replacement?: string; message: string };\n\tslots?: CapabilitySlotDefinition[];\n\tactionIntents?: CapabilityActionIntent[];\n\trequirements?: CapabilityRequirements;\n\tcertification?: { profile: string; required: boolean };\n}\n\nexport interface FabricModule<TDb = unknown> {\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tcapability?: CapabilityMetadata;\n\tdependencies?: ModuleDependencyInput[];\n\tobjectTypes?: ObjectTypeRegistrationInput[];\n\tsubjectTypes?: string[];\n\tidPrefixes?: IdPrefixRegistration[];\n\teventTypes?: EventTypeRegistrationInput[];\n\tactions?: ActionDefinition<TDb>[];\n\tpolicies?: unknown[];\n\tstateMachines?: unknown[];\n\tdisplayRenderers?: ModuleDisplayRendererRegistration[];\n\tadapterDefinitions?: unknown[];\n\tpermissions?: unknown[];\n\troles?: unknown[];\n\tredactionRules?: unknown[];\n\tdataClassifications?: unknown[];\n\tretentionRules?: unknown[];\n\tevidenceRenderers?: unknown[];\n\tviews?: ViewContract[];\n}\n\nexport interface ModuleRegistry<TDb = unknown> {\n\tmodules: ReadonlyMap<string, FabricModule<TDb>>;\n}\n\ninterface ModuleValidationContext {\n\tavailableNamespaces?: Set<string>;\n\tplannedEventTypes?: Set<string>;\n\tavailableObjectTypes?: Set<string>;\n}\n\nconst registeredModuleNamespaces = new Set<string>();\nconst registeredQualifiedObjectTypes = new Set<string>();\nconst registeredObjectDefinitions = new Map<string, ObjectTypeRegistration>();\n\nexport function getModuleDependencyNamespace(dependency: ModuleDependencyInput): string {\n\treturn typeof dependency === \"string\" ? dependency : dependency.namespace;\n}\n\nexport function getObjectTypeName(objectType: ObjectTypeRegistrationInput): string {\n\treturn typeof objectType === \"string\" ? objectType : objectType.type;\n}\n\nexport function getEventTypeName(eventType: EventTypeRegistrationInput): string {\n\treturn typeof eventType === \"string\" ? eventType : eventType.eventType;\n}\n\nexport function validateModuleNamespace(namespace: string): void {\n\tif (!namespace) {\n\t\tthrow new Error(\"Module namespace cannot be empty\");\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(namespace)) {\n\t\tthrow new Error(\n\t\t\t`Invalid module namespace: \"${namespace}\". Must be lowercase letters, numbers, and hyphens only.`,\n\t\t);\n\t}\n}\n\nexport function createModuleRegistry<TDb = unknown>(\n\tmodules: FabricModule<TDb>[] = [],\n): ModuleRegistry<TDb> {\n\tconst registered = new Map<string, FabricModule<TDb>>();\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (registered.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate FabricModule namespace \"${module.namespace}\".`);\n\t\t}\n\t\tregistered.set(module.namespace, module);\n\t}\n\treturn { modules: registered };\n}\n\nfunction validateIdentifierList(\n\tvalues: string[] | undefined,\n\tlabel: string,\n\tnamespace: string,\n): void {\n\tfor (const value of values ?? []) {\n\t\tif (!value) {\n\t\t\tthrow new Error(`Module \"${namespace}\" has an empty ${label} entry.`);\n\t\t}\n\t}\n}\n\nfunction assertJsonValue(value: unknown, path: string): asserts value is JsonValue {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return;\n\tif (typeof value === \"number\" && Number.isFinite(value)) return;\n\tif (Array.isArray(value)) {\n\t\tvalue.forEach((item, index) => assertJsonValue(item, `${path}[${index}]`));\n\t\treturn;\n\t}\n\tif (typeof value === \"object\") {\n\t\tfor (const [key, child] of Object.entries(value as Record<string, unknown>)) {\n\t\t\tassertJsonValue(child, `${path}.${key}`);\n\t\t}\n\t\treturn;\n\t}\n\tthrow new Error(`${path} must contain JSON-serializable values.`);\n}\n\nfunction qualifiedObjectType(namespace: string, type: string): string {\n\treturn `${namespace}.${type}`;\n}\n\nfunction validateObjectDefinition(\n\tobjectType: ObjectTypeRegistrationInput,\n\tnamespace: string,\n\tcontext: ModuleValidationContext,\n): void {\n\tif (typeof objectType === \"string\") return;\n\tif (objectType.schema !== undefined) {\n\t\tassertPortableJsonSchema(objectType.schema, `Module \"${namespace}\" object \"${objectType.type}\" schema`);\n\t}\n\tif (objectType.semantics !== undefined) {\n\t\tassertJsonValue(objectType.semantics, `Module \"${namespace}\" object \"${objectType.type}\" semantics`);\n\t}\n\tconst relationNames = new Set<string>();\n\tfor (const relation of objectType.relations ?? []) {\n\t\tif (!/^[a-z][a-zA-Z0-9]*$/.test(relation.name)) {\n\t\t\tthrow new Error(`Module \"${namespace}\" object \"${objectType.type}\" has invalid relation name \"${relation.name}\".`);\n\t\t}\n\t\tif (relationNames.has(relation.name)) {\n\t\t\tthrow new Error(`Module \"${namespace}\" object \"${objectType.type}\" has duplicate relation \"${relation.name}\".`);\n\t\t}\n\t\trelationNames.add(relation.name);\n\t\tif (!/^[a-z][a-z0-9-]*\\.[A-Z][a-zA-Z0-9]*$/.test(relation.target)) {\n\t\t\tthrow new Error(`Relation \"${relation.name}\" target \"${relation.target}\" must be module-qualified.`);\n\t\t}\n\t\tif (context.availableObjectTypes && !context.availableObjectTypes.has(relation.target)) {\n\t\t\tthrow new Error(`Relation \"${relation.name}\" targets missing object type \"${relation.target}\".`);\n\t\t}\n\t\tif (relation.required && relation.onTargetDelete === \"set-null\") {\n\t\t\tthrow new Error(`Required relation \"${relation.name}\" cannot use onTargetDelete \"set-null\".`);\n\t\t}\n\t}\n\tconst invariantIds = new Set<string>();\n\tfor (const invariant of objectType.invariants ?? []) {\n\t\tif (!invariant.id.trim() || !invariant.description.trim()) {\n\t\t\tthrow new Error(`Module \"${namespace}\" object \"${objectType.type}\" has an invariant without an id or description.`);\n\t\t}\n\t\tif (invariantIds.has(invariant.id)) {\n\t\t\tthrow new Error(`Module \"${namespace}\" object \"${objectType.type}\" has duplicate invariant \"${invariant.id}\".`);\n\t\t}\n\t\tinvariantIds.add(invariant.id);\n\t\tif (invariant.required && !invariant.enforcementRef?.trim()) {\n\t\t\tthrow new Error(`Required invariant \"${invariant.id}\" must declare enforcementRef.`);\n\t\t}\n\t}\n}\n\nfunction validateManifest(module: FabricModule<unknown>, context: ModuleValidationContext = {}): void {\n\tvalidateModuleNamespace(module.namespace);\n\n\tconst dependencies = (module.dependencies ?? []).map(getModuleDependencyNamespace);\n\tconst objectTypes = (module.objectTypes ?? []).map(getObjectTypeName);\n\tconst eventTypes = (module.eventTypes ?? []).map(getEventTypeName);\n\tif (module.capability) {\n\t\tif (!module.capability.displayName.trim() || !module.capability.description.trim()) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t}\n\t\tif (new Set(module.capability.roles ?? []).size !== (module.capability.roles ?? []).length || (module.capability.roles ?? []).some((role) => !/^[a-z][a-z0-9-]*$/.test(role))) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" capability has invalid or duplicate roles.`);\n\t\t}\n\t\tconst slots = new Set<string>();\n\t\tfor (const slot of module.capability.slots ?? []) {\n\t\t\tif (!/^[a-z][a-z0-9-]*$/.test(slot.name) || slots.has(slot.name)) {\n\t\t\t\tthrow new Error(`Module \"${module.namespace}\" capability has invalid or duplicate slot \"${slot.name}\".`);\n\t\t\t}\n\t\t\tslots.add(slot.name);\n\t\t\tif (slot.shape) assertPortableJsonSchema(slot.shape, `Capability slot \"${slot.name}\" shape`);\n\t\t}\n\t\tconst intents = new Set<string>();\n\t\tfor (const intent of module.capability.actionIntents ?? []) {\n\t\t\tif (!/^[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}\".`);\n\t\t\tintents.add(intent.name);\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\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tconst isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;\n\t\tconst isModuleEventType = eventTypes.includes(descriptor.eventType);\n\t\tif (!isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {\n\t\t\tthrow new Error(\n\t\t\t\t`Display renderer registered for unknown event type \"${descriptor.eventType}\". ` +\n\t\t\t\t\t`Register the event type before adding a display renderer.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst viewKeys = new Set<string>();\n\tfor (const view of module.views ?? []) {\n\t\tif (!view.name.startsWith(`${module.namespace}/`) || !/^[a-z][a-z0-9-]*\\/[a-z][a-z0-9/_-]*$/.test(view.name)) {\n\t\t\tthrow new Error(`View \"${view.name}\" must start with module namespace \"${module.namespace}/\" and use lowercase path segments.`);\n\t\t}\n\t\tif (!view.version.trim()) throw new Error(`View \"${view.name}\" must declare a version.`);\n\t\tconst key = `${view.name}@${view.version}`;\n\t\tif (viewKeys.has(key)) throw new Error(`Module \"${module.namespace}\" has duplicate view contract \"${key}\".`);\n\t\tviewKeys.add(key);\n\t\tassertPortableJsonSchema(view.shape, `View \"${key}\" shape`);\n\t\tif (!Number.isInteger(view.snapshotVersion) || view.snapshotVersion < 1) {\n\t\t\tthrow new Error(`View \"${key}\" snapshotVersion must be a positive integer.`);\n\t\t}\n\t\tif ((view.compatibleSnapshotVersions?.some((version) => version !== view.snapshotVersion) ?? false) && !view.upgradeSnapshot) {\n\t\t\tthrow new Error(`View \"${key}\" declares older compatible snapshots but no upgradeSnapshot function.`);\n\t\t}\n\t\tfor (const consumption of view.consumes) {\n\t\t\tconst isPlanned = context.plannedEventTypes?.has(consumption.eventType) ?? false;\n\t\t\tconst isModuleEvent = eventTypes.includes(consumption.eventType);\n\t\t\tif (!isValidEventType(consumption.eventType) && !isPlanned && !isModuleEvent) {\n\t\t\t\tthrow new Error(`View \"${key}\" consumes unknown event type \"${consumption.eventType}\".`);\n\t\t\t}\n\t\t\tif (consumption.schemaVersions.length === 0 || consumption.schemaVersions.some((version) => !Number.isInteger(version) || version < 1)) {\n\t\t\t\tthrow new Error(`View \"${key}\" must declare positive consumed schema versions for \"${consumption.eventType}\".`);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction sortModulesByDependency(\n\tmodules: FabricModule<unknown>[],\n\tregisteredNamespaces = registeredModuleNamespaces,\n): FabricModule<unknown>[] {\n\tconst modulesByNamespace = new Map<string, FabricModule<unknown>>();\n\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (modulesByNamespace.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate Fabric module namespace \"${module.namespace}\".`);\n\t\t}\n\t\tmodulesByNamespace.set(module.namespace, module);\n\t}\n\n\tconst sorted: FabricModule<unknown>[] = [];\n\tconst visiting = new Set<string>();\n\tconst visited = new Set<string>();\n\n\tfunction visit(module: FabricModule<unknown>, path: string[]): void {\n\t\tif (visited.has(module.namespace)) {\n\t\t\treturn;\n\t\t}\n\t\tif (visiting.has(module.namespace)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cyclic Fabric module dependency detected: ${[...path, module.namespace].join(\" -> \")}`,\n\t\t\t);\n\t\t}\n\n\t\tvisiting.add(module.namespace);\n\t\tfor (const dependency of (module.dependencies ?? []).map(getModuleDependencyNamespace)) {\n\t\t\tconst dependencyModule = modulesByNamespace.get(dependency);\n\t\t\tif (!dependencyModule) {\n\t\t\t\tif (registeredNamespaces.has(dependency)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t\t}\n\t\t\tvisit(dependencyModule, [...path, module.namespace]);\n\t\t}\n\t\tvisiting.delete(module.namespace);\n\t\tvisited.add(module.namespace);\n\t\tsorted.push(module);\n\t}\n\n\tfor (const module of modules) {\n\t\tvisit(module, []);\n\t}\n\n\treturn sorted;\n}\n\nfunction assertAcyclicRelations(modules: FabricModule<unknown>[]): void {\n\tconst relationKinds = [\n\t\t{ label: \"owned containment\", include: (relation: ObjectRelationDefinition) => relation.semantics === \"owned\" },\n\t\t{ label: \"cascade-delete\", include: (relation: ObjectRelationDefinition) => relation.onTargetDelete === \"cascade\" },\n\t\t{ label: \"required-construction\", include: (relation: ObjectRelationDefinition) => relation.required === true },\n\t];\n\tfor (const kind of relationKinds) {\n\t\tconst edges = new Map<string, string[]>();\n\t\tfor (const [source, objectType] of registeredObjectDefinitions) {\n\t\t\tedges.set(source, (objectType.relations ?? []).filter(kind.include).map((relation) => relation.target));\n\t\t}\n\t\tfor (const module of modules) {\n\t\t\tfor (const objectType of module.objectTypes ?? []) {\n\t\t\t\tif (typeof objectType === \"string\") continue;\n\t\t\t\tconst source = qualifiedObjectType(module.namespace, objectType.type);\n\t\t\t\tedges.set(source, (objectType.relations ?? []).filter(kind.include).map((relation) => relation.target));\n\t\t\t}\n\t\t}\n\t\tconst visiting = new Set<string>();\n\t\tconst visited = new Set<string>();\n\t\tconst visit = (node: string, path: string[]): void => {\n\t\t\tif (visiting.has(node)) {\n\t\t\t\tthrow new Error(`${kind.label} relation cycle detected: ${[...path, node].join(\" -> \")}`);\n\t\t\t}\n\t\t\tif (visited.has(node)) return;\n\t\t\tvisiting.add(node);\n\t\t\tfor (const target of edges.get(node) ?? []) visit(target, [...path, node]);\n\t\t\tvisiting.delete(node);\n\t\t\tvisited.add(node);\n\t\t};\n\t\tfor (const node of edges.keys()) visit(node, []);\n\t}\n}\n\nfunction registerValidatedFabricModule(module: FabricModule<unknown>): void {\n\tfor (const objectType of module.objectTypes ?? []) {\n\t\tregisterObjectType(getObjectTypeName(objectType));\n\t\tconst qualified = qualifiedObjectType(module.namespace, getObjectTypeName(objectType));\n\t\tregisteredQualifiedObjectTypes.add(qualified);\n\t\tif (typeof objectType !== \"string\") registeredObjectDefinitions.set(qualified, objectType);\n\t}\n\n\tfor (const subjectType of module.subjectTypes ?? []) {\n\t\tregisterSubjectType(subjectType);\n\t}\n\n\tfor (const eventType of module.eventTypes ?? []) {\n\t\tregisterEventType(getEventTypeName(eventType));\n\t}\n\n\tfor (const policy of module.policies ?? []) {\n\t\tregisterPolicyIfMissing(policy as PolicyEvaluator);\n\t}\n\n\tfor (const machine of module.stateMachines ?? []) {\n\t\tregisterStateMachineIfMissing(machine as StateMachineDefinition);\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tregisterActionIfMissing(action);\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tregisterDisplayRenderer(descriptor.eventType, descriptor.renderer as DisplayRenderer);\n\t}\n\tfor (const view of module.views ?? []) registerViewContractIfMissing(view);\n\n\tregisteredModuleNamespaces.add(module.namespace);\n}\n\nexport function registerFabricModule(module: FabricModule<unknown>): void {\n\tconst availableObjectTypes = new Set([\n\t\t...registeredQualifiedObjectTypes,\n\t\t...(module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType))),\n\t]);\n\tvalidateManifest(module, { availableNamespaces: registeredModuleNamespaces, availableObjectTypes });\n\tassertAcyclicRelations([module]);\n\tregisterValidatedFabricModule(module);\n}\n\nexport function registerFabricModules(modules: FabricModule<unknown>[]): FabricModule<unknown>[] {\n\tconst availableNamespaces = new Set([\n\t\t...registeredModuleNamespaces,\n\t\t...modules.map((module) => module.namespace),\n\t]);\n\tconst plannedEventTypes = new Set(\n\t\tmodules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName)),\n\t);\n\tconst availableObjectTypes = new Set([\n\t\t...registeredQualifiedObjectTypes,\n\t\t...modules.flatMap((module) =>\n\t\t\t(module.objectTypes ?? []).map((objectType) => qualifiedObjectType(module.namespace, getObjectTypeName(objectType))),\n\t\t),\n\t]);\n\n\tfor (const module of modules) {\n\t\tvalidateManifest(module, { availableNamespaces, plannedEventTypes, availableObjectTypes });\n\t}\n\tassertAcyclicRelations(modules);\n\n\tconst sortedModules = sortModulesByDependency(modules);\n\tfor (const module of sortedModules) {\n\t\tregisterValidatedFabricModule(module);\n\t}\n\n\treturn sortedModules;\n}\n"]}
|
|
@@ -51,5 +51,5 @@ function createEventTypeRegistry(initialEventTypes = []) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export { createEventTypeRegistry, getRegisteredEventTypes, getRegisteredSubjectTypes, isValidEventType, isValidSubjectType, registerEventType, registerSubjectType };
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
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;AAC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AAM,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"]}
|
|
@@ -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-
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
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,K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EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,IAAA,EAAM,CAAA;AAClC;AAEO,SAAS,wBAAwB,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"]}
|
|
@@ -59,5 +59,5 @@ exports.isValidEventType = isValidEventType;
|
|
|
59
59
|
exports.isValidSubjectType = isValidSubjectType;
|
|
60
60
|
exports.registerEventType = registerEventType;
|
|
61
61
|
exports.registerSubjectType = registerSubjectType;
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-7RV5REPT.cjs.map
|
|
63
|
+
//# sourceMappingURL=chunk-7RV5REPT.cjs.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-7RV5REPT.cjs","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"]}
|
|
@@ -23,7 +23,8 @@ async function replayView({
|
|
|
23
23
|
view,
|
|
24
24
|
events,
|
|
25
25
|
scope,
|
|
26
|
-
snapshot
|
|
26
|
+
snapshot,
|
|
27
|
+
eventsStartAfterSnapshot = false
|
|
27
28
|
}) {
|
|
28
29
|
if (snapshot && snapshot.snapshotVersion !== view.snapshotVersion && !view.compatibleSnapshotVersions?.includes(snapshot.snapshotVersion)) {
|
|
29
30
|
throw new Error(
|
|
@@ -59,24 +60,44 @@ async function replayView({
|
|
|
59
60
|
scope,
|
|
60
61
|
initialState: view.initialState,
|
|
61
62
|
snapshot: upgradedSnapshot,
|
|
62
|
-
applyEvent: (state, event) => accepted.has(event.eventType) ? view.applyEvent(state, event) : state
|
|
63
|
+
applyEvent: (state, event) => accepted.has(event.eventType) ? view.applyEvent(state, event) : state,
|
|
64
|
+
eventsStartAfterSnapshot
|
|
63
65
|
});
|
|
64
66
|
const preprocessingWarningKeys = new Set(preprocessingWarnings.map((warning) => JSON.stringify(warning)));
|
|
65
67
|
const resultWarnings = result.warnings.filter((warning) => !preprocessingWarningKeys.has(JSON.stringify(warning)));
|
|
66
|
-
return {
|
|
68
|
+
return {
|
|
69
|
+
...result,
|
|
70
|
+
eventCursor: result.eventCursor ?? upgradedSnapshot?.eventCursor ?? null,
|
|
71
|
+
eventSequence: result.appliedEvents.length ? result.eventSequence : upgradedSnapshot?.eventSequence ?? result.eventSequence,
|
|
72
|
+
subjectSequences: result.appliedEvents.length ? result.subjectSequences : upgradedSnapshot?.subjectSequences ?? result.subjectSequences,
|
|
73
|
+
warnings: [...preprocessingWarnings, ...versionWarnings, ...resultWarnings]
|
|
74
|
+
};
|
|
67
75
|
}
|
|
68
76
|
async function replayEvents({
|
|
69
77
|
events,
|
|
70
78
|
scope,
|
|
71
79
|
initialState,
|
|
72
80
|
snapshot,
|
|
73
|
-
applyEvent
|
|
81
|
+
applyEvent,
|
|
82
|
+
eventsStartAfterSnapshot = false
|
|
74
83
|
}) {
|
|
84
|
+
if (eventsStartAfterSnapshot && !snapshot?.eventCursor) {
|
|
85
|
+
throw new Error("eventsStartAfterSnapshot requires a snapshot with an eventCursor checkpoint.");
|
|
86
|
+
}
|
|
75
87
|
const warnings = [];
|
|
76
88
|
const scopedEvents = filterEventsByScope(await collectEvents(events), scope, warnings);
|
|
77
89
|
const orderedEvents = sortEvents(scopedEvents, isSubjectScoped(scope));
|
|
78
90
|
const uniqueEvents = removeDuplicateEvents(orderedEvents, warnings);
|
|
79
|
-
const
|
|
91
|
+
const initialSubjectSequences = eventsStartAfterSnapshot ? snapshotSubjectSequences(snapshot, scope) : void 0;
|
|
92
|
+
const subjectSequences = recordMissingSequenceWarnings(uniqueEvents, warnings, initialSubjectSequences);
|
|
93
|
+
const resumableEvents = applyCursor(
|
|
94
|
+
uniqueEvents,
|
|
95
|
+
snapshot,
|
|
96
|
+
isSubjectScoped(scope),
|
|
97
|
+
warnings,
|
|
98
|
+
initialSubjectSequences,
|
|
99
|
+
eventsStartAfterSnapshot
|
|
100
|
+
);
|
|
80
101
|
let state = snapshot?.snapshotData ?? initialState;
|
|
81
102
|
const appliedEvents = [];
|
|
82
103
|
let eventCursor = snapshot?.eventCursor ?? null;
|
|
@@ -92,7 +113,10 @@ async function replayEvents({
|
|
|
92
113
|
appliedEvents,
|
|
93
114
|
warnings,
|
|
94
115
|
eventCursor,
|
|
95
|
-
eventSequence
|
|
116
|
+
eventSequence,
|
|
117
|
+
subjectSequences: Object.fromEntries(
|
|
118
|
+
[...subjectSequences.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)
|
|
119
|
+
)
|
|
96
120
|
};
|
|
97
121
|
}
|
|
98
122
|
async function collectEvents(events) {
|
|
@@ -147,13 +171,12 @@ function removeDuplicateEvents(events, warnings) {
|
|
|
147
171
|
seenEventIds.add(event.id);
|
|
148
172
|
uniqueEvents.push(event);
|
|
149
173
|
}
|
|
150
|
-
recordMissingSequenceWarnings(uniqueEvents, warnings);
|
|
151
174
|
return uniqueEvents;
|
|
152
175
|
}
|
|
153
|
-
function recordMissingSequenceWarnings(events, warnings) {
|
|
154
|
-
const lastSequenceBySubject =
|
|
176
|
+
function recordMissingSequenceWarnings(events, warnings, initialSequences) {
|
|
177
|
+
const lastSequenceBySubject = new Map(initialSequences);
|
|
155
178
|
for (const event of events) {
|
|
156
|
-
const subjectKey =
|
|
179
|
+
const subjectKey = subjectSequenceKey(event.subjectType, event.subjectId);
|
|
157
180
|
const previousSequence = lastSequenceBySubject.get(subjectKey);
|
|
158
181
|
const expectedSequence = previousSequence === void 0 ? event.sequence : previousSequence + 1;
|
|
159
182
|
if (previousSequence !== void 0 && event.sequence > expectedSequence) {
|
|
@@ -169,10 +192,11 @@ function recordMissingSequenceWarnings(events, warnings) {
|
|
|
169
192
|
}
|
|
170
193
|
lastSequenceBySubject.set(subjectKey, Math.max(previousSequence ?? event.sequence, event.sequence));
|
|
171
194
|
}
|
|
195
|
+
return lastSequenceBySubject;
|
|
172
196
|
}
|
|
173
|
-
function applyCursor(events, snapshot, subjectScoped, warnings) {
|
|
197
|
+
function applyCursor(events, snapshot, subjectScoped, warnings, initialSubjectSequences, eventsStartAfterSnapshot = false) {
|
|
174
198
|
const eventCursor = snapshot?.eventCursor;
|
|
175
|
-
if (eventCursor) {
|
|
199
|
+
if (eventCursor && !eventsStartAfterSnapshot) {
|
|
176
200
|
const cursorIndex = events.findIndex((event) => event.id === eventCursor);
|
|
177
201
|
if (cursorIndex >= 0) {
|
|
178
202
|
return events.slice(cursorIndex + 1);
|
|
@@ -183,11 +207,26 @@ function applyCursor(events, snapshot, subjectScoped, warnings) {
|
|
|
183
207
|
eventId: eventCursor
|
|
184
208
|
});
|
|
185
209
|
}
|
|
210
|
+
if (initialSubjectSequences?.size) {
|
|
211
|
+
return events.filter(
|
|
212
|
+
(event) => event.sequence > (initialSubjectSequences.get(subjectSequenceKey(event.subjectType, event.subjectId)) ?? -1)
|
|
213
|
+
);
|
|
214
|
+
}
|
|
186
215
|
if (subjectScoped && snapshot?.eventSequence !== void 0 && snapshot.eventSequence !== null) {
|
|
187
216
|
return events.filter((event) => event.sequence > snapshot.eventSequence);
|
|
188
217
|
}
|
|
189
218
|
return events;
|
|
190
219
|
}
|
|
220
|
+
function snapshotSubjectSequences(snapshot, scope) {
|
|
221
|
+
const sequences = new Map(Object.entries(snapshot?.subjectSequences ?? {}));
|
|
222
|
+
if (sequences.size === 0 && scope.subjectType && scope.subjectId && snapshot?.eventSequence !== void 0 && snapshot.eventSequence !== null) {
|
|
223
|
+
sequences.set(subjectSequenceKey(scope.subjectType, scope.subjectId), snapshot.eventSequence);
|
|
224
|
+
}
|
|
225
|
+
return sequences;
|
|
226
|
+
}
|
|
227
|
+
function subjectSequenceKey(subjectType, subjectId) {
|
|
228
|
+
return `${subjectType}:${subjectId}`;
|
|
229
|
+
}
|
|
191
230
|
function sortEvents(events, subjectScoped) {
|
|
192
231
|
return [...events].sort(
|
|
193
232
|
(first, second) => subjectScoped ? compareSubjectEvents(first, second) : compareGlobalEvents(first, second)
|
|
@@ -249,5 +288,5 @@ exports.replayEvents = replayEvents;
|
|
|
249
288
|
exports.replayView = replayView;
|
|
250
289
|
exports.resolveViewContract = resolveViewContract;
|
|
251
290
|
exports.viewContractKey = viewContractKey;
|
|
252
|
-
//# sourceMappingURL=chunk-
|
|
253
|
-
//# sourceMappingURL=chunk-
|
|
291
|
+
//# sourceMappingURL=chunk-7SHNYYGI.cjs.map
|
|
292
|
+
//# sourceMappingURL=chunk-7SHNYYGI.cjs.map
|