@fabricorg/platform 0.12.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +7 -8
- package/dist/actions/index.cjs +7 -27
- package/dist/actions/index.d.cts +9 -7
- package/dist/actions/index.d.ts +9 -7
- package/dist/actions/index.js +1 -1
- package/dist/{chunk-ROC326VL.cjs → chunk-35LADVKK.cjs} +48 -104
- package/dist/chunk-35LADVKK.cjs.map +1 -0
- package/dist/chunk-4QOA3VU5.js +47 -0
- package/dist/chunk-4QOA3VU5.js.map +1 -0
- package/dist/chunk-53VEUYCS.cjs +40 -0
- package/dist/chunk-53VEUYCS.cjs.map +1 -0
- package/dist/{chunk-X7WC4AYC.js → chunk-ATWWZTRC.js} +32 -74
- package/dist/chunk-ATWWZTRC.js.map +1 -0
- package/dist/chunk-BFQNKQJE.cjs +53 -0
- package/dist/{chunk-4RMKUYRX.js.map → chunk-BFQNKQJE.cjs.map} +1 -1
- package/dist/{chunk-OC4ZFJKD.cjs → chunk-CBY6GRJP.cjs} +16 -17
- package/dist/chunk-CBY6GRJP.cjs.map +1 -0
- package/dist/chunk-CQSA3BII.js +38 -0
- package/dist/chunk-CQSA3BII.js.map +1 -0
- package/dist/{chunk-ZO6HPMCK.js → chunk-CRAGTJ3B.js} +3 -3
- package/dist/{chunk-ZO6HPMCK.js.map → chunk-CRAGTJ3B.js.map} +1 -1
- package/dist/{chunk-LXS6SURU.js → chunk-J5LS5BSI.js} +70 -29
- package/dist/chunk-J5LS5BSI.js.map +1 -0
- package/dist/{chunk-MCD5VT4E.cjs → chunk-JFMNLJLY.cjs} +6 -6
- package/dist/{chunk-MCD5VT4E.cjs.map → chunk-JFMNLJLY.cjs.map} +1 -1
- package/dist/{chunk-6ER62UUN.js → chunk-JFVEPAED.js} +31 -40
- package/dist/chunk-JFVEPAED.js.map +1 -0
- package/dist/{chunk-45TSN3GO.cjs → chunk-M5FGWXT3.cjs} +70 -32
- package/dist/chunk-M5FGWXT3.cjs.map +1 -0
- package/dist/{chunk-4MMMXV4Q.js → chunk-NETLRKDS.js} +16 -15
- package/dist/chunk-NETLRKDS.js.map +1 -0
- package/dist/chunk-OWSSGFNY.js +45 -0
- package/dist/chunk-OWSSGFNY.js.map +1 -0
- package/dist/{chunk-5PDVZXEI.js → chunk-T5ESIJ4K.js} +42 -99
- package/dist/chunk-T5ESIJ4K.js.map +1 -0
- package/dist/{chunk-NJL3US7H.cjs → chunk-VZ6C4LXC.cjs} +31 -43
- package/dist/chunk-VZ6C4LXC.cjs.map +1 -0
- package/dist/chunk-WAI4UNWQ.cjs +48 -0
- package/dist/chunk-WAI4UNWQ.cjs.map +1 -0
- package/dist/{chunk-YQEXO3IQ.cjs → chunk-X3GHYMAJ.cjs} +32 -74
- package/dist/chunk-X3GHYMAJ.cjs.map +1 -0
- package/dist/events/index.cjs +3 -27
- package/dist/events/index.d.cts +13 -13
- package/dist/events/index.d.ts +13 -13
- package/dist/events/index.js +1 -1
- package/dist/index.cjs +88 -193
- package/dist/index.d.cts +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.js +10 -11
- package/dist/manifest/index.cjs +11 -15
- package/dist/manifest/index.d.cts +0 -1
- package/dist/manifest/index.d.ts +0 -1
- package/dist/manifest/index.js +5 -9
- package/dist/modules/index.cjs +15 -15
- package/dist/modules/index.d.cts +16 -23
- package/dist/modules/index.d.ts +16 -23
- package/dist/modules/index.js +4 -8
- package/dist/objects/index.cjs +5 -13
- package/dist/objects/index.d.cts +7 -4
- package/dist/objects/index.d.ts +7 -4
- package/dist/objects/index.js +1 -1
- package/dist/policies/index.cjs +12 -24
- package/dist/policies/index.d.cts +10 -5
- package/dist/policies/index.d.ts +10 -5
- package/dist/policies/index.js +1 -1
- package/dist/privacy/index.cjs +10 -10
- package/dist/privacy/index.d.cts +16 -5
- package/dist/privacy/index.d.ts +16 -5
- package/dist/privacy/index.js +1 -1
- package/dist/projections/index.cjs +6 -18
- package/dist/projections/index.d.cts +21 -7
- package/dist/projections/index.d.ts +21 -7
- package/dist/projections/index.js +1 -1
- package/dist/state-machines/index.cjs +5 -21
- package/dist/state-machines/index.d.cts +17 -31
- package/dist/state-machines/index.d.ts +17 -31
- package/dist/state-machines/index.js +1 -1
- package/package.json +1 -11
- package/dist/chunk-3O4GMCCE.js +0 -55
- package/dist/chunk-3O4GMCCE.js.map +0 -1
- package/dist/chunk-45TSN3GO.cjs.map +0 -1
- package/dist/chunk-4MMMXV4Q.js.map +0 -1
- package/dist/chunk-4RMKUYRX.js +0 -59
- package/dist/chunk-5PDVZXEI.js.map +0 -1
- package/dist/chunk-6ER62UUN.js.map +0 -1
- package/dist/chunk-7RV5REPT.cjs +0 -63
- package/dist/chunk-7RV5REPT.cjs.map +0 -1
- package/dist/chunk-EO4VSB2O.cjs +0 -99
- package/dist/chunk-EO4VSB2O.cjs.map +0 -1
- package/dist/chunk-JOATYJXQ.cjs +0 -70
- package/dist/chunk-JOATYJXQ.cjs.map +0 -1
- package/dist/chunk-LXS6SURU.js.map +0 -1
- package/dist/chunk-NJL3US7H.cjs.map +0 -1
- package/dist/chunk-O5WVBQ7P.js +0 -89
- package/dist/chunk-O5WVBQ7P.js.map +0 -1
- package/dist/chunk-OC4ZFJKD.cjs.map +0 -1
- package/dist/chunk-ROC326VL.cjs.map +0 -1
- package/dist/chunk-T2JLSZN6.js +0 -67
- package/dist/chunk-T2JLSZN6.js.map +0 -1
- package/dist/chunk-UV252FLT.cjs +0 -74
- package/dist/chunk-UV252FLT.cjs.map +0 -1
- package/dist/chunk-X7WC4AYC.js.map +0 -1
- package/dist/chunk-YQEXO3IQ.cjs.map +0 -1
- package/dist/displays/index.cjs +0 -24
- package/dist/displays/index.cjs.map +0 -1
- package/dist/displays/index.d.cts +0 -34
- package/dist/displays/index.d.ts +0 -34
- package/dist/displays/index.js +0 -3
- package/dist/displays/index.js.map +0 -1
package/dist/privacy/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
declare const ANONYMIZATION_POLICY_VERSION = "adr-026-platform-anonymization-v1";
|
|
2
2
|
type JsonObject = Record<string, unknown>;
|
|
3
|
+
interface AnonymizationFieldPolicy {
|
|
4
|
+
method: RedactionMethod;
|
|
5
|
+
match: "key" | "path";
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
interface AnonymizationPolicy {
|
|
9
|
+
fields: readonly AnonymizationFieldPolicy[];
|
|
10
|
+
preservedSemantics?: readonly string[];
|
|
11
|
+
}
|
|
3
12
|
interface AssetEventLike {
|
|
4
13
|
id: string;
|
|
5
14
|
tenantId: string;
|
|
@@ -53,6 +62,8 @@ declare class FieldRedactor {
|
|
|
53
62
|
generalize(value: unknown): unknown;
|
|
54
63
|
}
|
|
55
64
|
declare class AnonymizationEngine {
|
|
65
|
+
#private;
|
|
66
|
+
constructor(policy: AnonymizationPolicy);
|
|
56
67
|
anonymizeJsonValue<TValue>(value: TValue, context: AnonymizationContext, dataClass: PlatformDataClass): AnonymizationResult<TValue>;
|
|
57
68
|
anonymizeJsonValueAtPath<TValue>(value: TValue, context: AnonymizationContext, dataClass: PlatformDataClass, basePath: string): AnonymizationResult<TValue>;
|
|
58
69
|
anonymizeAssetEventPayload(event: AssetEventLike, context: AnonymizationContext): AnonymizationResult<unknown>;
|
|
@@ -80,9 +91,9 @@ declare class AnonymizationEngine {
|
|
|
80
91
|
declare const PLATFORM_PRIVACY_POLICY_VERSION = "fabric-platform-privacy-v1";
|
|
81
92
|
type RedactionMethod = "nullify" | "mask" | "hash" | "tokenize" | "generalize" | "drop";
|
|
82
93
|
|
|
83
|
-
declare function anonymizeJsonValue<TValue>(value: TValue, context: AnonymizationContext, dataClass: PlatformDataClass): AnonymizationResult<TValue>;
|
|
84
|
-
declare function anonymizeAssetEventPayload(event: AssetEventLike, context: AnonymizationContext): AnonymizationResult<unknown>;
|
|
85
|
-
declare function anonymizeEvidencePacket(packet: EvidencePacketLike, context: AnonymizationContext): AnonymizationResult<Pick<EvidencePacketLike, "packet" | "redactionMetadata" | "checksum">>;
|
|
94
|
+
declare function anonymizeJsonValue<TValue>(value: TValue, context: AnonymizationContext, dataClass: PlatformDataClass, policy: AnonymizationPolicy): AnonymizationResult<TValue>;
|
|
95
|
+
declare function anonymizeAssetEventPayload(event: AssetEventLike, context: AnonymizationContext, policy: AnonymizationPolicy): AnonymizationResult<unknown>;
|
|
96
|
+
declare function anonymizeEvidencePacket(packet: EvidencePacketLike, context: AnonymizationContext, policy: AnonymizationPolicy): AnonymizationResult<Pick<EvidencePacketLike, "packet" | "redactionMetadata" | "checksum">>;
|
|
86
97
|
declare function buildAnonymizationLifecycleEvidence(input: {
|
|
87
98
|
context: AnonymizationContext;
|
|
88
99
|
assetEvents?: Array<{
|
|
@@ -100,7 +111,7 @@ declare function buildAnonymizationLifecycleEvidence(input: {
|
|
|
100
111
|
packet: EvidencePacketLike;
|
|
101
112
|
metadata: AnonymizationMetadata;
|
|
102
113
|
}>;
|
|
103
|
-
}): AnonymizationLifecycleEvidence;
|
|
114
|
+
}, policy: AnonymizationPolicy): AnonymizationLifecycleEvidence;
|
|
104
115
|
type PlatformDataClass = "asset_event" | "read_model" | "raw_payload" | "evidence_packet" | "action_evidence" | "access_event";
|
|
105
116
|
interface RedactionRule {
|
|
106
117
|
fieldPath: string;
|
|
@@ -175,4 +186,4 @@ interface RetentionRule {
|
|
|
175
186
|
legalHoldExempt?: boolean;
|
|
176
187
|
}
|
|
177
188
|
|
|
178
|
-
export { ANONYMIZATION_POLICY_VERSION, type AnalyticsDataContract, type AnalyticsDataContractSource, type AnalyticsEligibilityDecision, type AnonymizationContext, AnonymizationEngine, type AnonymizationFieldMetadata, type AnonymizationLifecycleEvidence, type AnonymizationMetadata, type AnonymizationResult, type AssetEventLike, type DataClassificationRule, type EvidencePacketLike, FieldRedactor, PLATFORM_PRIVACY_POLICY_VERSION, type PlatformDataClass, type RedactionMethod, type RedactionRule, type RetentionRule, anonymizeAssetEventPayload, anonymizeEvidencePacket, anonymizeJsonValue, buildAnonymizationLifecycleEvidence, stableChecksum };
|
|
189
|
+
export { ANONYMIZATION_POLICY_VERSION, type AnalyticsDataContract, type AnalyticsDataContractSource, type AnalyticsEligibilityDecision, type AnonymizationContext, AnonymizationEngine, type AnonymizationFieldMetadata, type AnonymizationFieldPolicy, type AnonymizationLifecycleEvidence, type AnonymizationMetadata, type AnonymizationPolicy, type AnonymizationResult, type AssetEventLike, type DataClassificationRule, type EvidencePacketLike, FieldRedactor, PLATFORM_PRIVACY_POLICY_VERSION, type PlatformDataClass, type RedactionMethod, type RedactionRule, type RetentionRule, anonymizeAssetEventPayload, anonymizeEvidencePacket, anonymizeJsonValue, buildAnonymizationLifecycleEvidence, stableChecksum };
|
package/dist/privacy/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ANONYMIZATION_POLICY_VERSION, AnonymizationEngine, FieldRedactor, PLATFORM_PRIVACY_POLICY_VERSION, anonymizeAssetEventPayload, anonymizeEvidencePacket, anonymizeJsonValue, buildAnonymizationLifecycleEvidence, stableChecksum } from '../chunk-
|
|
1
|
+
export { ANONYMIZATION_POLICY_VERSION, AnonymizationEngine, FieldRedactor, PLATFORM_PRIVACY_POLICY_VERSION, anonymizeAssetEventPayload, anonymizeEvidencePacket, anonymizeJsonValue, buildAnonymizationLifecycleEvidence, stableChecksum } from '../chunk-ATWWZTRC.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkM5FGWXT3_cjs = require('../chunk-M5FGWXT3.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "createViewRegistry", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(exports, "registerViewContract", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return chunk45TSN3GO_cjs.registerViewContract; }
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(exports, "registerViewContractIfMissing", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return chunk45TSN3GO_cjs.registerViewContractIfMissing; }
|
|
9
|
+
get: function () { return chunkM5FGWXT3_cjs.createViewRegistry; }
|
|
18
10
|
});
|
|
19
11
|
Object.defineProperty(exports, "replayEvents", {
|
|
20
12
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkM5FGWXT3_cjs.replayEvents; }
|
|
22
14
|
});
|
|
23
15
|
Object.defineProperty(exports, "replayView", {
|
|
24
16
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(exports, "resolveViewContract", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return chunk45TSN3GO_cjs.resolveViewContract; }
|
|
17
|
+
get: function () { return chunkM5FGWXT3_cjs.replayView; }
|
|
30
18
|
});
|
|
31
19
|
Object.defineProperty(exports, "viewContractKey", {
|
|
32
20
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkM5FGWXT3_cjs.viewContractKey; }
|
|
34
22
|
});
|
|
35
23
|
//# sourceMappingURL=index.cjs.map
|
|
36
24
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -49,10 +49,13 @@ interface ViewUsageMetadata {
|
|
|
49
49
|
classification?: "public" | "internal" | "confidential" | "restricted";
|
|
50
50
|
}
|
|
51
51
|
declare function viewContractKey(view: Pick<ViewContract, "name" | "version">): string;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
interface ViewRegistry {
|
|
53
|
+
register(view: ViewContract): void;
|
|
54
|
+
registerIfMissing(view: ViewContract): void;
|
|
55
|
+
resolve(name: string, version: string): ViewContract | undefined;
|
|
56
|
+
keys(): string[];
|
|
57
|
+
}
|
|
58
|
+
declare function createViewRegistry(views?: readonly ViewContract[]): ViewRegistry;
|
|
56
59
|
interface ReplayViewOptions<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {
|
|
57
60
|
view: ViewContract<State, Event>;
|
|
58
61
|
events: Iterable<Event> | AsyncIterable<Event>;
|
|
@@ -60,8 +63,14 @@ interface ReplayViewOptions<State, Event extends ReplayableAssetEvent = Replayab
|
|
|
60
63
|
snapshot?: (ReplaySnapshot<State> & {
|
|
61
64
|
snapshotVersion: number;
|
|
62
65
|
}) | null;
|
|
66
|
+
/**
|
|
67
|
+
* Set when the event source already applied the snapshot cursor and returns
|
|
68
|
+
* only later events. The snapshot still seeds state, but replay must not try
|
|
69
|
+
* to find its cursor in the supplied incremental stream.
|
|
70
|
+
*/
|
|
71
|
+
eventsStartAfterSnapshot?: boolean;
|
|
63
72
|
}
|
|
64
|
-
declare function replayView<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({ view, events, scope, snapshot, }: ReplayViewOptions<State, Event>): Promise<ReplayEventsResult<State, Event>>;
|
|
73
|
+
declare function replayView<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({ view, events, scope, snapshot, eventsStartAfterSnapshot, }: ReplayViewOptions<State, Event>): Promise<ReplayEventsResult<State, Event>>;
|
|
65
74
|
interface ReplayScope {
|
|
66
75
|
tenantId: string;
|
|
67
76
|
spaceId: string;
|
|
@@ -72,6 +81,8 @@ interface ReplaySnapshot<State = unknown> {
|
|
|
72
81
|
snapshotData: State;
|
|
73
82
|
eventCursor?: string | null;
|
|
74
83
|
eventSequence?: number | null;
|
|
84
|
+
/** Per-subject high-water marks used to validate incremental replay boundaries. */
|
|
85
|
+
subjectSequences?: Record<string, number>;
|
|
75
86
|
}
|
|
76
87
|
type ReplayWarningCode = "cursor_not_found" | "duplicate_event" | "missing_sequence" | "subject_scope_incomplete" | "unsupported_event_version";
|
|
77
88
|
interface ReplayWarning {
|
|
@@ -89,6 +100,8 @@ interface ReplayEventsOptions<State, Event extends ReplayableAssetEvent = Replay
|
|
|
89
100
|
initialState: State;
|
|
90
101
|
snapshot?: ReplaySnapshot<State> | null;
|
|
91
102
|
applyEvent: (state: State, event: Event) => State | Promise<State>;
|
|
103
|
+
/** The supplied stream begins after the snapshot checkpoint. */
|
|
104
|
+
eventsStartAfterSnapshot?: boolean;
|
|
92
105
|
}
|
|
93
106
|
interface ReplayEventsResult<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {
|
|
94
107
|
state: State;
|
|
@@ -96,7 +109,8 @@ interface ReplayEventsResult<State, Event extends ReplayableAssetEvent = Replaya
|
|
|
96
109
|
warnings: ReplayWarning[];
|
|
97
110
|
eventCursor: string | null;
|
|
98
111
|
eventSequence: number;
|
|
112
|
+
subjectSequences: Record<string, number>;
|
|
99
113
|
}
|
|
100
|
-
declare function replayEvents<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({ events, scope, initialState, snapshot, applyEvent, }: ReplayEventsOptions<State, Event>): Promise<ReplayEventsResult<State, Event>>;
|
|
114
|
+
declare function replayEvents<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({ events, scope, initialState, snapshot, applyEvent, eventsStartAfterSnapshot, }: ReplayEventsOptions<State, Event>): Promise<ReplayEventsResult<State, Event>>;
|
|
101
115
|
|
|
102
|
-
export { type ReplayEventsOptions, type ReplayEventsResult, type ReplayScope, type ReplaySnapshot, type ReplayViewOptions, type ReplayWarning, type ReplayWarningCode, type ReplayableAssetEvent, type ViewContract, type ViewEventConsumption, type
|
|
116
|
+
export { type ReplayEventsOptions, type ReplayEventsResult, type ReplayScope, type ReplaySnapshot, type ReplayViewOptions, type ReplayWarning, type ReplayWarningCode, type ReplayableAssetEvent, type ViewContract, type ViewEventConsumption, type ViewRegistry, type ViewUsageMetadata, createViewRegistry, replayEvents, replayView, viewContractKey };
|
|
@@ -49,10 +49,13 @@ interface ViewUsageMetadata {
|
|
|
49
49
|
classification?: "public" | "internal" | "confidential" | "restricted";
|
|
50
50
|
}
|
|
51
51
|
declare function viewContractKey(view: Pick<ViewContract, "name" | "version">): string;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
interface ViewRegistry {
|
|
53
|
+
register(view: ViewContract): void;
|
|
54
|
+
registerIfMissing(view: ViewContract): void;
|
|
55
|
+
resolve(name: string, version: string): ViewContract | undefined;
|
|
56
|
+
keys(): string[];
|
|
57
|
+
}
|
|
58
|
+
declare function createViewRegistry(views?: readonly ViewContract[]): ViewRegistry;
|
|
56
59
|
interface ReplayViewOptions<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {
|
|
57
60
|
view: ViewContract<State, Event>;
|
|
58
61
|
events: Iterable<Event> | AsyncIterable<Event>;
|
|
@@ -60,8 +63,14 @@ interface ReplayViewOptions<State, Event extends ReplayableAssetEvent = Replayab
|
|
|
60
63
|
snapshot?: (ReplaySnapshot<State> & {
|
|
61
64
|
snapshotVersion: number;
|
|
62
65
|
}) | null;
|
|
66
|
+
/**
|
|
67
|
+
* Set when the event source already applied the snapshot cursor and returns
|
|
68
|
+
* only later events. The snapshot still seeds state, but replay must not try
|
|
69
|
+
* to find its cursor in the supplied incremental stream.
|
|
70
|
+
*/
|
|
71
|
+
eventsStartAfterSnapshot?: boolean;
|
|
63
72
|
}
|
|
64
|
-
declare function replayView<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({ view, events, scope, snapshot, }: ReplayViewOptions<State, Event>): Promise<ReplayEventsResult<State, Event>>;
|
|
73
|
+
declare function replayView<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({ view, events, scope, snapshot, eventsStartAfterSnapshot, }: ReplayViewOptions<State, Event>): Promise<ReplayEventsResult<State, Event>>;
|
|
65
74
|
interface ReplayScope {
|
|
66
75
|
tenantId: string;
|
|
67
76
|
spaceId: string;
|
|
@@ -72,6 +81,8 @@ interface ReplaySnapshot<State = unknown> {
|
|
|
72
81
|
snapshotData: State;
|
|
73
82
|
eventCursor?: string | null;
|
|
74
83
|
eventSequence?: number | null;
|
|
84
|
+
/** Per-subject high-water marks used to validate incremental replay boundaries. */
|
|
85
|
+
subjectSequences?: Record<string, number>;
|
|
75
86
|
}
|
|
76
87
|
type ReplayWarningCode = "cursor_not_found" | "duplicate_event" | "missing_sequence" | "subject_scope_incomplete" | "unsupported_event_version";
|
|
77
88
|
interface ReplayWarning {
|
|
@@ -89,6 +100,8 @@ interface ReplayEventsOptions<State, Event extends ReplayableAssetEvent = Replay
|
|
|
89
100
|
initialState: State;
|
|
90
101
|
snapshot?: ReplaySnapshot<State> | null;
|
|
91
102
|
applyEvent: (state: State, event: Event) => State | Promise<State>;
|
|
103
|
+
/** The supplied stream begins after the snapshot checkpoint. */
|
|
104
|
+
eventsStartAfterSnapshot?: boolean;
|
|
92
105
|
}
|
|
93
106
|
interface ReplayEventsResult<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {
|
|
94
107
|
state: State;
|
|
@@ -96,7 +109,8 @@ interface ReplayEventsResult<State, Event extends ReplayableAssetEvent = Replaya
|
|
|
96
109
|
warnings: ReplayWarning[];
|
|
97
110
|
eventCursor: string | null;
|
|
98
111
|
eventSequence: number;
|
|
112
|
+
subjectSequences: Record<string, number>;
|
|
99
113
|
}
|
|
100
|
-
declare function replayEvents<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({ events, scope, initialState, snapshot, applyEvent, }: ReplayEventsOptions<State, Event>): Promise<ReplayEventsResult<State, Event>>;
|
|
114
|
+
declare function replayEvents<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({ events, scope, initialState, snapshot, applyEvent, eventsStartAfterSnapshot, }: ReplayEventsOptions<State, Event>): Promise<ReplayEventsResult<State, Event>>;
|
|
101
115
|
|
|
102
|
-
export { type ReplayEventsOptions, type ReplayEventsResult, type ReplayScope, type ReplaySnapshot, type ReplayViewOptions, type ReplayWarning, type ReplayWarningCode, type ReplayableAssetEvent, type ViewContract, type ViewEventConsumption, type
|
|
116
|
+
export { type ReplayEventsOptions, type ReplayEventsResult, type ReplayScope, type ReplaySnapshot, type ReplayViewOptions, type ReplayWarning, type ReplayWarningCode, type ReplayableAssetEvent, type ViewContract, type ViewEventConsumption, type ViewRegistry, type ViewUsageMetadata, createViewRegistry, replayEvents, replayView, viewContractKey };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createViewRegistry, replayEvents, replayView, viewContractKey } from '../chunk-J5LS5BSI.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWAI4UNWQ_cjs = require('../chunk-WAI4UNWQ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "createStateMachineRegistry", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkWAI4UNWQ_cjs.createStateMachineRegistry; }
|
|
10
10
|
});
|
|
11
|
-
Object.defineProperty(exports, "
|
|
11
|
+
Object.defineProperty(exports, "validateStateMachineTransition", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(exports, "registerStateMachine", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return chunkUV252FLT_cjs.registerStateMachine; }
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "registerStateMachineIfMissing", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () { return chunkUV252FLT_cjs.registerStateMachineIfMissing; }
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports, "resolveStateMachine", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () { return chunkUV252FLT_cjs.resolveStateMachine; }
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(exports, "validateTransition", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return chunkUV252FLT_cjs.validateTransition; }
|
|
13
|
+
get: function () { return chunkWAI4UNWQ_cjs.validateStateMachineTransition; }
|
|
30
14
|
});
|
|
31
15
|
//# sourceMappingURL=index.cjs.map
|
|
32
16
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -16,39 +16,25 @@ interface TransitionContext<TDb = StateMachineDatabaseClient> {
|
|
|
16
16
|
parameters: unknown;
|
|
17
17
|
db: TDb;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* Validate whether a transition is allowed for the given entity type,
|
|
35
|
-
* from state, to state, and action ID.
|
|
36
|
-
*/
|
|
37
|
-
declare function validateTransition(entityType: string, from: string, to: string, actionId: string): {
|
|
19
|
+
interface StateMachineRegistry {
|
|
20
|
+
register(definition: StateMachineDefinition): void;
|
|
21
|
+
registerIfMissing(definition: StateMachineDefinition): void;
|
|
22
|
+
resolve(entityType: string): StateMachineDefinition | undefined;
|
|
23
|
+
validateTransition(entityType: string, from: string, to: string, actionId: string): {
|
|
24
|
+
valid: boolean;
|
|
25
|
+
error?: string;
|
|
26
|
+
};
|
|
27
|
+
allowedTransitions(entityType: string, from: string): Array<{
|
|
28
|
+
to: string;
|
|
29
|
+
causedByAction: string;
|
|
30
|
+
}>;
|
|
31
|
+
stateClass(entityType: string, state: string): StateClass | undefined;
|
|
32
|
+
}
|
|
33
|
+
declare function validateStateMachineTransition(sm: StateMachineDefinition | undefined, entityType: string, from: string, to: string, actionId: string): {
|
|
38
34
|
valid: boolean;
|
|
39
35
|
error?: string;
|
|
40
36
|
};
|
|
41
|
-
|
|
42
|
-
* Get all allowed transitions from a given state for an entity type.
|
|
43
|
-
*/
|
|
44
|
-
declare function getAllowedTransitions(entityType: string, from: string): Array<{
|
|
45
|
-
to: string;
|
|
46
|
-
causedByAction: string;
|
|
47
|
-
}>;
|
|
48
|
-
/**
|
|
49
|
-
* Get the StateClass of a given state for an entity type.
|
|
50
|
-
*/
|
|
51
|
-
declare function getEntityStateClass(entityType: string, state: string): StateClass | undefined;
|
|
37
|
+
declare function createStateMachineRegistry(definitions?: readonly StateMachineDefinition[]): StateMachineRegistry;
|
|
52
38
|
|
|
53
39
|
type StateClass = "initial" | "active" | "action_required" | "waiting" | "terminal" | "exception";
|
|
54
40
|
interface StateDefinition {
|
|
@@ -57,4 +43,4 @@ interface StateDefinition {
|
|
|
57
43
|
stateClass: StateClass;
|
|
58
44
|
}
|
|
59
45
|
|
|
60
|
-
export { type StateClass, type StateDefinition, type StateMachineDatabaseClient, type StateMachineDefinition, type
|
|
46
|
+
export { type StateClass, type StateDefinition, type StateMachineDatabaseClient, type StateMachineDefinition, type StateMachineRegistry, type TransitionContext, createStateMachineRegistry, validateStateMachineTransition };
|
|
@@ -16,39 +16,25 @@ interface TransitionContext<TDb = StateMachineDatabaseClient> {
|
|
|
16
16
|
parameters: unknown;
|
|
17
17
|
db: TDb;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* Validate whether a transition is allowed for the given entity type,
|
|
35
|
-
* from state, to state, and action ID.
|
|
36
|
-
*/
|
|
37
|
-
declare function validateTransition(entityType: string, from: string, to: string, actionId: string): {
|
|
19
|
+
interface StateMachineRegistry {
|
|
20
|
+
register(definition: StateMachineDefinition): void;
|
|
21
|
+
registerIfMissing(definition: StateMachineDefinition): void;
|
|
22
|
+
resolve(entityType: string): StateMachineDefinition | undefined;
|
|
23
|
+
validateTransition(entityType: string, from: string, to: string, actionId: string): {
|
|
24
|
+
valid: boolean;
|
|
25
|
+
error?: string;
|
|
26
|
+
};
|
|
27
|
+
allowedTransitions(entityType: string, from: string): Array<{
|
|
28
|
+
to: string;
|
|
29
|
+
causedByAction: string;
|
|
30
|
+
}>;
|
|
31
|
+
stateClass(entityType: string, state: string): StateClass | undefined;
|
|
32
|
+
}
|
|
33
|
+
declare function validateStateMachineTransition(sm: StateMachineDefinition | undefined, entityType: string, from: string, to: string, actionId: string): {
|
|
38
34
|
valid: boolean;
|
|
39
35
|
error?: string;
|
|
40
36
|
};
|
|
41
|
-
|
|
42
|
-
* Get all allowed transitions from a given state for an entity type.
|
|
43
|
-
*/
|
|
44
|
-
declare function getAllowedTransitions(entityType: string, from: string): Array<{
|
|
45
|
-
to: string;
|
|
46
|
-
causedByAction: string;
|
|
47
|
-
}>;
|
|
48
|
-
/**
|
|
49
|
-
* Get the StateClass of a given state for an entity type.
|
|
50
|
-
*/
|
|
51
|
-
declare function getEntityStateClass(entityType: string, state: string): StateClass | undefined;
|
|
37
|
+
declare function createStateMachineRegistry(definitions?: readonly StateMachineDefinition[]): StateMachineRegistry;
|
|
52
38
|
|
|
53
39
|
type StateClass = "initial" | "active" | "action_required" | "waiting" | "terminal" | "exception";
|
|
54
40
|
interface StateDefinition {
|
|
@@ -57,4 +43,4 @@ interface StateDefinition {
|
|
|
57
43
|
stateClass: StateClass;
|
|
58
44
|
}
|
|
59
45
|
|
|
60
|
-
export { type StateClass, type StateDefinition, type StateMachineDatabaseClient, type StateMachineDefinition, type
|
|
46
|
+
export { type StateClass, type StateDefinition, type StateMachineDatabaseClient, type StateMachineDefinition, type StateMachineRegistry, type TransitionContext, createStateMachineRegistry, validateStateMachineTransition };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createStateMachineRegistry, validateStateMachineTransition } from '../chunk-OWSSGFNY.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabricorg/platform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Generic, vertical-agnostic runtime for ontology-based business applications. Provides actions, modules, events, policies, state machines, adapters, displays, projections, privacy, and evidence contracts. Zero runtime dependencies; portable across any database client and any vertical (lending, insurance, healthcare, legal, etc.).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fabric",
|
|
@@ -68,16 +68,6 @@
|
|
|
68
68
|
"default": "./dist/agent-hitl/index.cjs"
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
-
"./displays": {
|
|
72
|
-
"import": {
|
|
73
|
-
"types": "./dist/displays/index.d.ts",
|
|
74
|
-
"default": "./dist/displays/index.js"
|
|
75
|
-
},
|
|
76
|
-
"require": {
|
|
77
|
-
"types": "./dist/displays/index.d.cts",
|
|
78
|
-
"default": "./dist/displays/index.cjs"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
71
|
"./events": {
|
|
82
72
|
"import": {
|
|
83
73
|
"types": "./dist/events/index.d.ts",
|
package/dist/chunk-3O4GMCCE.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// events/index.ts
|
|
2
|
-
var subjectTypeRegistry = /* @__PURE__ */ new Set([
|
|
3
|
-
"ActionInvocation",
|
|
4
|
-
"PolicyEvaluation",
|
|
5
|
-
"AdapterInvocation"
|
|
6
|
-
]);
|
|
7
|
-
var eventTypeRegistry = /* @__PURE__ */ new Set([
|
|
8
|
-
"ComplianceBlocked",
|
|
9
|
-
"StateTransitioned",
|
|
10
|
-
"AdapterInvocationStarted",
|
|
11
|
-
"AdapterInvocationSucceeded",
|
|
12
|
-
"AdapterInvocationFailed",
|
|
13
|
-
"WebhookReceived"
|
|
14
|
-
]);
|
|
15
|
-
var dynamicSubjectTypes = /* @__PURE__ */ new Set();
|
|
16
|
-
var dynamicEventTypes = /* @__PURE__ */ new Set();
|
|
17
|
-
function registerSubjectType(type) {
|
|
18
|
-
dynamicSubjectTypes.add(type);
|
|
19
|
-
}
|
|
20
|
-
function isValidSubjectType(type) {
|
|
21
|
-
return subjectTypeRegistry.has(type) || dynamicSubjectTypes.has(type);
|
|
22
|
-
}
|
|
23
|
-
function getRegisteredSubjectTypes() {
|
|
24
|
-
return Array.from(/* @__PURE__ */ new Set([...subjectTypeRegistry, ...dynamicSubjectTypes]));
|
|
25
|
-
}
|
|
26
|
-
function registerEventType(type) {
|
|
27
|
-
dynamicEventTypes.add(type);
|
|
28
|
-
}
|
|
29
|
-
function isValidEventType(type) {
|
|
30
|
-
return eventTypeRegistry.has(type) || dynamicEventTypes.has(type);
|
|
31
|
-
}
|
|
32
|
-
function getRegisteredEventTypes() {
|
|
33
|
-
return Array.from(/* @__PURE__ */ new Set([...eventTypeRegistry, ...dynamicEventTypes]));
|
|
34
|
-
}
|
|
35
|
-
function createEventTypeRegistry(initialEventTypes = []) {
|
|
36
|
-
const eventTypes = new Set(initialEventTypes);
|
|
37
|
-
return {
|
|
38
|
-
register(eventType) {
|
|
39
|
-
if (!eventType) {
|
|
40
|
-
throw new Error("Event type cannot be empty");
|
|
41
|
-
}
|
|
42
|
-
eventTypes.add(eventType);
|
|
43
|
-
},
|
|
44
|
-
has(eventType) {
|
|
45
|
-
return eventTypes.has(eventType);
|
|
46
|
-
},
|
|
47
|
-
list() {
|
|
48
|
-
return Array.from(eventTypes).sort();
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { createEventTypeRegistry, getRegisteredEventTypes, getRegisteredSubjectTypes, isValidEventType, isValidSubjectType, registerEventType, registerSubjectType };
|
|
54
|
-
//# sourceMappingURL=chunk-3O4GMCCE.js.map
|
|
55
|
-
//# sour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AsB;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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../projections/index.ts"],"names":[],"mappings":";;;AAkDA,IAAM,YAAA,uBAAmB,GAAA,EAA0B;AAE5C,SAAS,gBAAgB,IAAA,EAAsD;AACrF,EAAA,OAAO,CAAA,EAAG,IAAA,CAAK,IAAI,CAAA,CAAA,EAAI,KAAK,OAAO,CAAA,CAAA;AACpC;AAEO,SAAS,qBAAqB,IAAA,EAA0B;AAC9D,EAAA,MAAM,GAAA,GAAM,gBAAgB,IAAI,CAAA;AAChC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AAA,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,i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K,kBAAkB,CAAA;AACrC","file":"chunk-4MMMXV4Q.js","sourcesContent":["const objectTypeRegistry = new Set<string>([\n\t\"AssetEvent\",\n\t\"ActionInvocation\",\n\t\"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"]}
|