@fabricorg/platform 1.5.1 → 1.7.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 +32 -0
- package/README.md +27 -2
- package/dist/actions/index.cjs +6 -6
- package/dist/actions/index.d.cts +79 -2
- package/dist/actions/index.d.ts +79 -2
- package/dist/actions/index.js +1 -1
- package/dist/certification/index.cjs +8 -7
- package/dist/certification/index.d.cts +1 -0
- package/dist/certification/index.d.ts +1 -0
- package/dist/certification/index.js +5 -4
- package/dist/{chunk-VZ6C4LXC.cjs → chunk-45OKKLNY.cjs} +17 -9
- package/dist/chunk-45OKKLNY.cjs.map +1 -0
- package/dist/{chunk-2W6FORTE.js → chunk-6QX4I45I.js} +5 -2
- package/dist/chunk-6QX4I45I.js.map +1 -0
- package/dist/chunk-D4SWRBUH.cjs +22 -0
- package/dist/chunk-D4SWRBUH.cjs.map +1 -0
- package/dist/{chunk-KIVQBZOA.cjs → chunk-DBTAUI6C.cjs} +10 -4
- package/dist/chunk-DBTAUI6C.cjs.map +1 -0
- package/dist/{chunk-DDO4EQ2J.js → chunk-EMSAFNPX.js} +3 -3
- package/dist/{chunk-DDO4EQ2J.js.map → chunk-EMSAFNPX.js.map} +1 -1
- package/dist/{chunk-JFVEPAED.js → chunk-GU3LZWJD.js} +17 -9
- package/dist/chunk-GU3LZWJD.js.map +1 -0
- package/dist/chunk-LFE74IJX.js +20 -0
- package/dist/chunk-LFE74IJX.js.map +1 -0
- package/dist/{chunk-PFKTD7V5.cjs → chunk-MCWSUGB3.cjs} +4 -4
- package/dist/{chunk-PFKTD7V5.cjs.map → chunk-MCWSUGB3.cjs.map} +1 -1
- package/dist/{chunk-JG35DT2G.js → chunk-MLBALEUR.js} +5 -2
- package/dist/chunk-MLBALEUR.js.map +1 -0
- package/dist/{chunk-MC3GSVJ6.js → chunk-PDN5DOLQ.js} +17 -4
- package/dist/chunk-PDN5DOLQ.js.map +1 -0
- package/dist/{chunk-CXR6KEKQ.cjs → chunk-SNTV45LH.cjs} +5 -2
- package/dist/chunk-SNTV45LH.cjs.map +1 -0
- package/dist/{chunk-GRBZYDEV.js → chunk-WNZP53GI.js} +9 -3
- package/dist/chunk-WNZP53GI.js.map +1 -0
- package/dist/{chunk-ZBXFRJON.cjs → chunk-WQ3BYI7T.cjs} +20 -7
- package/dist/chunk-WQ3BYI7T.cjs.map +1 -0
- package/dist/{chunk-MSABJAED.cjs → chunk-XCAOO6KG.cjs} +5 -2
- package/dist/chunk-XCAOO6KG.cjs.map +1 -0
- package/dist/discovery/index.cjs +12 -0
- package/dist/discovery/index.cjs.map +1 -0
- package/dist/discovery/index.d.cts +10 -0
- package/dist/discovery/index.d.ts +10 -0
- package/dist/discovery/index.js +3 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/governance/index.d.cts +1 -0
- package/dist/governance/index.d.ts +1 -0
- package/dist/index.cjs +71 -66
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +9 -8
- package/dist/manifest/index.cjs +10 -9
- package/dist/manifest/index.d.cts +3 -2
- package/dist/manifest/index.d.ts +3 -2
- package/dist/manifest/index.js +4 -3
- package/dist/modules/index.cjs +11 -10
- package/dist/modules/index.d.cts +1 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +3 -2
- package/dist/policies/index.cjs +9 -9
- package/dist/policies/index.d.cts +15 -1
- package/dist/policies/index.d.ts +15 -1
- package/dist/policies/index.js +1 -1
- package/dist/projections/index.cjs +6 -5
- package/dist/projections/index.d.cts +2 -1
- package/dist/projections/index.d.ts +2 -1
- package/dist/projections/index.js +2 -1
- package/dist/testing/index.d.cts +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/package.json +11 -1
- package/dist/chunk-2W6FORTE.js.map +0 -1
- package/dist/chunk-CXR6KEKQ.cjs.map +0 -1
- package/dist/chunk-GRBZYDEV.js.map +0 -1
- package/dist/chunk-JFVEPAED.js.map +0 -1
- package/dist/chunk-JG35DT2G.js.map +0 -1
- package/dist/chunk-KIVQBZOA.cjs.map +0 -1
- package/dist/chunk-MC3GSVJ6.js.map +0 -1
- package/dist/chunk-MSABJAED.cjs.map +0 -1
- package/dist/chunk-VZ6C4LXC.cjs.map +0 -1
- package/dist/chunk-ZBXFRJON.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
export { createStateMachineRegistry, evaluateStateMachineTransition, validateStateMachineTransition } from './chunk-7GAWSUOG.js';
|
|
1
2
|
export { createDeterministicIdFactory, createFakeActionContext, createInMemoryAdapterRegistry } from './chunk-DCC3UIUJ.js';
|
|
3
|
+
export { FABRIC_GOVERNANCE_CONTRACT_VERSION, assertGovernanceRuntimeEvidence, assertMutationGovernanceContext } from './chunk-Y2PJLRIY.js';
|
|
2
4
|
export { FABRIC_ID_PREFIXES, createFabricId, isFabricId, parseFabricId } from './chunk-RALMUSOX.js';
|
|
3
|
-
export { aggregatePolicyOutcomes, assertPolicyId, createPolicyRegistry, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, validateDataPolicyDefinition, validatePolicyGuidance } from './chunk-
|
|
5
|
+
export { aggregatePolicyOutcomes, assertPolicyId, createPolicyRegistry, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, validateDataPolicyDefinition, validatePolicyGuidance } from './chunk-GU3LZWJD.js';
|
|
4
6
|
export { ANONYMIZATION_POLICY_VERSION, AnonymizationEngine, FieldRedactor, PLATFORM_PRIVACY_POLICY_VERSION, anonymizeAssetEventPayload, anonymizeEvidencePacket, anonymizeJsonValue, buildAnonymizationLifecycleEvidence, stableChecksum } from './chunk-ATWWZTRC.js';
|
|
5
|
-
export {
|
|
6
|
-
export { ACTOR_TYPES, assertActionId, assertActorType, createActionRegistry, isActorType } from './chunk-2W6FORTE.js';
|
|
7
|
+
export { ACTOR_TYPES, assertActionId, assertActorType, createActionRegistry, isActorType } from './chunk-6QX4I45I.js';
|
|
7
8
|
export { AdapterRegistry, MissingAdapterRegistrationError, assertAdapterOutcomeConsistency, classifyAdapterOutcome, executeWithAdapterRetry, getRetryDelayMs, resolveAdapterRetryPolicy, shouldRetryAdapterOutcome } from './chunk-FAG2RTPM.js';
|
|
8
9
|
export { AgentActionPolicyRegistry } from './chunk-OFCCZ27Z.js';
|
|
9
|
-
export { STRICT_EXECUTION_CONTRACT_PROFILE, STRICT_EXECUTION_CONTRACT_PROFILE_ID, executionContractProfile } from './chunk-
|
|
10
|
-
export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator, normalizeModuleManifest, normalizeModuleManifestBundle } from './chunk-
|
|
11
|
-
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateAndOrderFabricModules, validateModuleNamespace } from './chunk-
|
|
10
|
+
export { STRICT_EXECUTION_CONTRACT_PROFILE, STRICT_EXECUTION_CONTRACT_PROFILE_ID, executionContractProfile } from './chunk-EMSAFNPX.js';
|
|
11
|
+
export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator, normalizeModuleManifest, normalizeModuleManifestBundle } from './chunk-PDN5DOLQ.js';
|
|
12
|
+
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateAndOrderFabricModules, validateModuleNamespace } from './chunk-WNZP53GI.js';
|
|
12
13
|
export { assertObjectType, assertPortableJsonSchema, createObjectTypeRegistry, validatePortableJson } from './chunk-ZAEVQSB5.js';
|
|
13
|
-
export { createViewRegistry, replayEvents, replayView, viewContractKey } from './chunk-
|
|
14
|
+
export { createViewRegistry, replayEvents, replayView, viewContractKey } from './chunk-MLBALEUR.js';
|
|
15
|
+
export { assertSurfaceDeclaration } from './chunk-LFE74IJX.js';
|
|
14
16
|
export { createEventContractRegistry } from './chunk-B5DOGDPG.js';
|
|
15
17
|
import './chunk-OZLZHISS.js';
|
|
16
|
-
export { FABRIC_GOVERNANCE_CONTRACT_VERSION, assertGovernanceRuntimeEvidence, assertMutationGovernanceContext } from './chunk-Y2PJLRIY.js';
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist/manifest/index.cjs
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkWQ3BYI7T_cjs = require('../chunk-WQ3BYI7T.cjs');
|
|
4
|
+
require('../chunk-DBTAUI6C.cjs');
|
|
5
5
|
require('../chunk-IFW43ELT.cjs');
|
|
6
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-SNTV45LH.cjs');
|
|
7
|
+
require('../chunk-D4SWRBUH.cjs');
|
|
7
8
|
require('../chunk-2AE6TMAX.cjs');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
Object.defineProperty(exports, "MODULE_MANIFEST_VERSION", {
|
|
12
13
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkWQ3BYI7T_cjs.MODULE_MANIFEST_VERSION; }
|
|
14
15
|
});
|
|
15
16
|
Object.defineProperty(exports, "exportModuleManifest", {
|
|
16
17
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkWQ3BYI7T_cjs.exportModuleManifest; }
|
|
18
19
|
});
|
|
19
20
|
Object.defineProperty(exports, "exportModuleManifestBundle", {
|
|
20
21
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkWQ3BYI7T_cjs.exportModuleManifestBundle; }
|
|
22
23
|
});
|
|
23
24
|
Object.defineProperty(exports, "isJsonSchemaExportableValidator", {
|
|
24
25
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkWQ3BYI7T_cjs.isJsonSchemaExportableValidator; }
|
|
26
27
|
});
|
|
27
28
|
Object.defineProperty(exports, "normalizeModuleManifest", {
|
|
28
29
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkWQ3BYI7T_cjs.normalizeModuleManifest; }
|
|
30
31
|
});
|
|
31
32
|
Object.defineProperty(exports, "normalizeModuleManifestBundle", {
|
|
32
33
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkWQ3BYI7T_cjs.normalizeModuleManifestBundle; }
|
|
34
35
|
});
|
|
35
36
|
//# sourceMappingURL=index.cjs.map
|
|
36
37
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SurfaceDeclaration } from '../discovery/index.cjs';
|
|
1
2
|
import { ActionExecutionContract, AdapterStepRetryPolicy, SchemaValidator } from '../actions/index.cjs';
|
|
2
3
|
import { CapabilityMetadata, ModuleDependency, ObjectRelationDefinition, DeclarativeInvariant, FabricModule } from '../modules/index.cjs';
|
|
3
4
|
import { PortableJsonSchema, JsonValue } from '../objects/index.cjs';
|
|
@@ -39,7 +40,7 @@ interface ModuleManifestAdapterStep {
|
|
|
39
40
|
operation: string;
|
|
40
41
|
retryPolicy?: AdapterStepRetryPolicy;
|
|
41
42
|
}
|
|
42
|
-
interface ModuleManifestAction {
|
|
43
|
+
interface ModuleManifestAction extends SurfaceDeclaration {
|
|
43
44
|
actionId: string;
|
|
44
45
|
version: number;
|
|
45
46
|
kind: "atomic" | "saga";
|
|
@@ -91,7 +92,7 @@ interface ModuleManifestStateMachine {
|
|
|
91
92
|
states: StateDefinition[];
|
|
92
93
|
transitions: ModuleManifestStateMachineTransition[];
|
|
93
94
|
}
|
|
94
|
-
interface ModuleManifestView {
|
|
95
|
+
interface ModuleManifestView extends SurfaceDeclaration {
|
|
95
96
|
name: string;
|
|
96
97
|
version: string;
|
|
97
98
|
shape: PortableJsonSchema;
|
package/dist/manifest/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SurfaceDeclaration } from '../discovery/index.js';
|
|
1
2
|
import { ActionExecutionContract, AdapterStepRetryPolicy, SchemaValidator } from '../actions/index.js';
|
|
2
3
|
import { CapabilityMetadata, ModuleDependency, ObjectRelationDefinition, DeclarativeInvariant, FabricModule } from '../modules/index.js';
|
|
3
4
|
import { PortableJsonSchema, JsonValue } from '../objects/index.js';
|
|
@@ -39,7 +40,7 @@ interface ModuleManifestAdapterStep {
|
|
|
39
40
|
operation: string;
|
|
40
41
|
retryPolicy?: AdapterStepRetryPolicy;
|
|
41
42
|
}
|
|
42
|
-
interface ModuleManifestAction {
|
|
43
|
+
interface ModuleManifestAction extends SurfaceDeclaration {
|
|
43
44
|
actionId: string;
|
|
44
45
|
version: number;
|
|
45
46
|
kind: "atomic" | "saga";
|
|
@@ -91,7 +92,7 @@ interface ModuleManifestStateMachine {
|
|
|
91
92
|
states: StateDefinition[];
|
|
92
93
|
transitions: ModuleManifestStateMachineTransition[];
|
|
93
94
|
}
|
|
94
|
-
interface ModuleManifestView {
|
|
95
|
+
interface ModuleManifestView extends SurfaceDeclaration {
|
|
95
96
|
name: string;
|
|
96
97
|
version: string;
|
|
97
98
|
shape: PortableJsonSchema;
|
package/dist/manifest/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator, normalizeModuleManifest, normalizeModuleManifestBundle } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator, normalizeModuleManifest, normalizeModuleManifestBundle } from '../chunk-PDN5DOLQ.js';
|
|
2
|
+
import '../chunk-WNZP53GI.js';
|
|
3
3
|
import '../chunk-ZAEVQSB5.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-MLBALEUR.js';
|
|
5
|
+
import '../chunk-LFE74IJX.js';
|
|
5
6
|
import '../chunk-B5DOGDPG.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/modules/index.cjs
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDBTAUI6C_cjs = require('../chunk-DBTAUI6C.cjs');
|
|
4
4
|
require('../chunk-IFW43ELT.cjs');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-SNTV45LH.cjs');
|
|
6
|
+
require('../chunk-D4SWRBUH.cjs');
|
|
6
7
|
require('../chunk-2AE6TMAX.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
Object.defineProperty(exports, "createModuleRegistry", {
|
|
11
12
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkDBTAUI6C_cjs.createModuleRegistry; }
|
|
13
14
|
});
|
|
14
15
|
Object.defineProperty(exports, "getEventTypeName", {
|
|
15
16
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkDBTAUI6C_cjs.getEventTypeName; }
|
|
17
18
|
});
|
|
18
19
|
Object.defineProperty(exports, "getModuleDependencyNamespace", {
|
|
19
20
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkDBTAUI6C_cjs.getModuleDependencyNamespace; }
|
|
21
22
|
});
|
|
22
23
|
Object.defineProperty(exports, "getObjectTypeName", {
|
|
23
24
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkDBTAUI6C_cjs.getObjectTypeName; }
|
|
25
26
|
});
|
|
26
27
|
Object.defineProperty(exports, "registerFabricModule", {
|
|
27
28
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkDBTAUI6C_cjs.registerFabricModule; }
|
|
29
30
|
});
|
|
30
31
|
Object.defineProperty(exports, "registerFabricModules", {
|
|
31
32
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkDBTAUI6C_cjs.registerFabricModules; }
|
|
33
34
|
});
|
|
34
35
|
Object.defineProperty(exports, "validateAndOrderFabricModules", {
|
|
35
36
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkDBTAUI6C_cjs.validateAndOrderFabricModules; }
|
|
37
38
|
});
|
|
38
39
|
Object.defineProperty(exports, "validateModuleNamespace", {
|
|
39
40
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkDBTAUI6C_cjs.validateModuleNamespace; }
|
|
41
42
|
});
|
|
42
43
|
//# sourceMappingURL=index.cjs.map
|
|
43
44
|
//# sourceMappingURL=index.cjs.map
|
package/dist/modules/index.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ import { JsonValue, PortableJsonSchema } from '../objects/index.cjs';
|
|
|
3
3
|
import { PolicyId, PolicyEvaluator } from '../policies/index.cjs';
|
|
4
4
|
import { StateMachineDefinition } from '../state-machines/index.cjs';
|
|
5
5
|
import { ViewContract } from '../projections/index.cjs';
|
|
6
|
+
import '../discovery/index.cjs';
|
|
6
7
|
|
|
7
8
|
interface ModuleDependency {
|
|
8
9
|
namespace: string;
|
package/dist/modules/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { JsonValue, PortableJsonSchema } from '../objects/index.js';
|
|
|
3
3
|
import { PolicyId, PolicyEvaluator } from '../policies/index.js';
|
|
4
4
|
import { StateMachineDefinition } from '../state-machines/index.js';
|
|
5
5
|
import { ViewContract } from '../projections/index.js';
|
|
6
|
+
import '../discovery/index.js';
|
|
6
7
|
|
|
7
8
|
interface ModuleDependency {
|
|
8
9
|
namespace: string;
|
package/dist/modules/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateAndOrderFabricModules, validateModuleNamespace } from '../chunk-
|
|
1
|
+
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateAndOrderFabricModules, validateModuleNamespace } from '../chunk-WNZP53GI.js';
|
|
2
2
|
import '../chunk-ZAEVQSB5.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-MLBALEUR.js';
|
|
4
|
+
import '../chunk-LFE74IJX.js';
|
|
4
5
|
import '../chunk-B5DOGDPG.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/policies/index.cjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk45OKKLNY_cjs = require('../chunk-45OKKLNY.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "aggregatePolicyOutcomes", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunk45OKKLNY_cjs.aggregatePolicyOutcomes; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "assertPolicyId", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk45OKKLNY_cjs.assertPolicyId; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "createPolicyRegistry", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk45OKKLNY_cjs.createPolicyRegistry; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "evaluatePolicyDefinition", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk45OKKLNY_cjs.evaluatePolicyDefinition; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "evaluatePolicyDefinitions", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk45OKKLNY_cjs.evaluatePolicyDefinitions; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "evaluateRegisteredPolicies", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunk45OKKLNY_cjs.evaluateRegisteredPolicies; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "validateDataPolicyDefinition", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunk45OKKLNY_cjs.validateDataPolicyDefinition; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "validatePolicyGuidance", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunk45OKKLNY_cjs.validatePolicyGuidance; }
|
|
38
38
|
});
|
|
39
39
|
//# sourceMappingURL=index.cjs.map
|
|
40
40
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ActorType, FabricRuntimeServices, ActionId } from '../actions/index.cjs';
|
|
2
|
+
import '../discovery/index.cjs';
|
|
2
3
|
|
|
3
4
|
type PolicyEvaluationResult = "pass" | "warn" | "block";
|
|
4
5
|
type PolicyKind = "code" | "data" | "hybrid";
|
|
@@ -153,10 +154,21 @@ interface DataPolicyConditionResult {
|
|
|
153
154
|
result: PolicyEvaluationResult;
|
|
154
155
|
reason?: string;
|
|
155
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Opaque, consumer-defined reference to the immutable policy authority or
|
|
159
|
+
* snapshot a runtime policy definition was resolved from. Platform records it
|
|
160
|
+
* in dispatch evidence and does not interpret it.
|
|
161
|
+
*/
|
|
162
|
+
interface PolicyAuthorityReference {
|
|
163
|
+
snapshotId: string;
|
|
164
|
+
contentHash?: string;
|
|
165
|
+
}
|
|
156
166
|
interface RuntimePolicyDefinition {
|
|
157
167
|
policyId: PolicyId;
|
|
158
168
|
policyVersion: number;
|
|
159
169
|
kind: PolicyKind;
|
|
170
|
+
/** Snapshot/authority this definition came from; copied into dispatch evidence. */
|
|
171
|
+
authority?: PolicyAuthorityReference;
|
|
160
172
|
dataDefinition?: DataPolicyDefinition;
|
|
161
173
|
codeEvaluatorPolicyId?: PolicyId;
|
|
162
174
|
fallback?: PolicyFallbackDefinition;
|
|
@@ -165,6 +177,8 @@ interface PolicyDispatchEvidence {
|
|
|
165
177
|
policyKind: PolicyKind;
|
|
166
178
|
policyId?: PolicyId;
|
|
167
179
|
policyVersion?: number;
|
|
180
|
+
/** Snapshot/authority the evaluated definition was resolved from, when supplied. */
|
|
181
|
+
authority?: PolicyAuthorityReference;
|
|
168
182
|
dispatchPath: Array<"data" | "code" | "fallback">;
|
|
169
183
|
data?: {
|
|
170
184
|
definitionVersion: number;
|
|
@@ -216,4 +230,4 @@ declare function evaluatePolicyDefinition(policy: RuntimePolicyDefinition, ctx:
|
|
|
216
230
|
declare function validateDataPolicyDefinition(definition: DataPolicyDefinition): DataPolicyValidationResult;
|
|
217
231
|
declare function aggregatePolicyOutcomes(outcomes: PolicyOutcome[]): PolicyOutcome | undefined;
|
|
218
232
|
|
|
219
|
-
export { type DataPolicyComparisonOperator, type DataPolicyCondition, type DataPolicyConditionResult, type DataPolicyDefinition, type DataPolicyLiteral, type DataPolicySource, type DataPolicySourceReference, type DataPolicyValidationResult, type PolicyContext, type PolicyCorrectiveAction, type PolicyCorrectiveActionBase, type PolicyCorrectiveActionKind, type PolicyDispatchEvidence, type PolicyEvaluationMode, type PolicyEvaluationResult, type PolicyEvaluator, type PolicyFact, type PolicyFallbackDefinition, type PolicyFallbackTrigger, type PolicyGuidance, type PolicyGuidanceValidationResult, type PolicyId, type PolicyInvokeActionCorrectiveAction, type PolicyKind, type PolicyManualCorrectiveAction, type PolicyNavigateCorrectiveAction, type PolicyOutcome, type PolicyRegistry, type RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, createPolicyRegistry, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, validateDataPolicyDefinition, validatePolicyGuidance };
|
|
233
|
+
export { type DataPolicyComparisonOperator, type DataPolicyCondition, type DataPolicyConditionResult, type DataPolicyDefinition, type DataPolicyLiteral, type DataPolicySource, type DataPolicySourceReference, type DataPolicyValidationResult, type PolicyAuthorityReference, type PolicyContext, type PolicyCorrectiveAction, type PolicyCorrectiveActionBase, type PolicyCorrectiveActionKind, type PolicyDispatchEvidence, type PolicyEvaluationMode, type PolicyEvaluationResult, type PolicyEvaluator, type PolicyFact, type PolicyFallbackDefinition, type PolicyFallbackTrigger, type PolicyGuidance, type PolicyGuidanceValidationResult, type PolicyId, type PolicyInvokeActionCorrectiveAction, type PolicyKind, type PolicyManualCorrectiveAction, type PolicyNavigateCorrectiveAction, type PolicyOutcome, type PolicyRegistry, type RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, createPolicyRegistry, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, validateDataPolicyDefinition, validatePolicyGuidance };
|
package/dist/policies/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ActorType, FabricRuntimeServices, ActionId } from '../actions/index.js';
|
|
2
|
+
import '../discovery/index.js';
|
|
2
3
|
|
|
3
4
|
type PolicyEvaluationResult = "pass" | "warn" | "block";
|
|
4
5
|
type PolicyKind = "code" | "data" | "hybrid";
|
|
@@ -153,10 +154,21 @@ interface DataPolicyConditionResult {
|
|
|
153
154
|
result: PolicyEvaluationResult;
|
|
154
155
|
reason?: string;
|
|
155
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Opaque, consumer-defined reference to the immutable policy authority or
|
|
159
|
+
* snapshot a runtime policy definition was resolved from. Platform records it
|
|
160
|
+
* in dispatch evidence and does not interpret it.
|
|
161
|
+
*/
|
|
162
|
+
interface PolicyAuthorityReference {
|
|
163
|
+
snapshotId: string;
|
|
164
|
+
contentHash?: string;
|
|
165
|
+
}
|
|
156
166
|
interface RuntimePolicyDefinition {
|
|
157
167
|
policyId: PolicyId;
|
|
158
168
|
policyVersion: number;
|
|
159
169
|
kind: PolicyKind;
|
|
170
|
+
/** Snapshot/authority this definition came from; copied into dispatch evidence. */
|
|
171
|
+
authority?: PolicyAuthorityReference;
|
|
160
172
|
dataDefinition?: DataPolicyDefinition;
|
|
161
173
|
codeEvaluatorPolicyId?: PolicyId;
|
|
162
174
|
fallback?: PolicyFallbackDefinition;
|
|
@@ -165,6 +177,8 @@ interface PolicyDispatchEvidence {
|
|
|
165
177
|
policyKind: PolicyKind;
|
|
166
178
|
policyId?: PolicyId;
|
|
167
179
|
policyVersion?: number;
|
|
180
|
+
/** Snapshot/authority the evaluated definition was resolved from, when supplied. */
|
|
181
|
+
authority?: PolicyAuthorityReference;
|
|
168
182
|
dispatchPath: Array<"data" | "code" | "fallback">;
|
|
169
183
|
data?: {
|
|
170
184
|
definitionVersion: number;
|
|
@@ -216,4 +230,4 @@ declare function evaluatePolicyDefinition(policy: RuntimePolicyDefinition, ctx:
|
|
|
216
230
|
declare function validateDataPolicyDefinition(definition: DataPolicyDefinition): DataPolicyValidationResult;
|
|
217
231
|
declare function aggregatePolicyOutcomes(outcomes: PolicyOutcome[]): PolicyOutcome | undefined;
|
|
218
232
|
|
|
219
|
-
export { type DataPolicyComparisonOperator, type DataPolicyCondition, type DataPolicyConditionResult, type DataPolicyDefinition, type DataPolicyLiteral, type DataPolicySource, type DataPolicySourceReference, type DataPolicyValidationResult, type PolicyContext, type PolicyCorrectiveAction, type PolicyCorrectiveActionBase, type PolicyCorrectiveActionKind, type PolicyDispatchEvidence, type PolicyEvaluationMode, type PolicyEvaluationResult, type PolicyEvaluator, type PolicyFact, type PolicyFallbackDefinition, type PolicyFallbackTrigger, type PolicyGuidance, type PolicyGuidanceValidationResult, type PolicyId, type PolicyInvokeActionCorrectiveAction, type PolicyKind, type PolicyManualCorrectiveAction, type PolicyNavigateCorrectiveAction, type PolicyOutcome, type PolicyRegistry, type RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, createPolicyRegistry, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, validateDataPolicyDefinition, validatePolicyGuidance };
|
|
233
|
+
export { type DataPolicyComparisonOperator, type DataPolicyCondition, type DataPolicyConditionResult, type DataPolicyDefinition, type DataPolicyLiteral, type DataPolicySource, type DataPolicySourceReference, type DataPolicyValidationResult, type PolicyAuthorityReference, type PolicyContext, type PolicyCorrectiveAction, type PolicyCorrectiveActionBase, type PolicyCorrectiveActionKind, type PolicyDispatchEvidence, type PolicyEvaluationMode, type PolicyEvaluationResult, type PolicyEvaluator, type PolicyFact, type PolicyFallbackDefinition, type PolicyFallbackTrigger, type PolicyGuidance, type PolicyGuidanceValidationResult, type PolicyId, type PolicyInvokeActionCorrectiveAction, type PolicyKind, type PolicyManualCorrectiveAction, type PolicyNavigateCorrectiveAction, type PolicyOutcome, type PolicyRegistry, type RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, createPolicyRegistry, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, validateDataPolicyDefinition, validatePolicyGuidance };
|
package/dist/policies/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { aggregatePolicyOutcomes, assertPolicyId, createPolicyRegistry, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, validateDataPolicyDefinition, validatePolicyGuidance } from '../chunk-
|
|
1
|
+
export { aggregatePolicyOutcomes, assertPolicyId, createPolicyRegistry, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, validateDataPolicyDefinition, validatePolicyGuidance } from '../chunk-GU3LZWJD.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSNTV45LH_cjs = require('../chunk-SNTV45LH.cjs');
|
|
4
|
+
require('../chunk-D4SWRBUH.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
Object.defineProperty(exports, "createViewRegistry", {
|
|
8
9
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkSNTV45LH_cjs.createViewRegistry; }
|
|
10
11
|
});
|
|
11
12
|
Object.defineProperty(exports, "replayEvents", {
|
|
12
13
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkSNTV45LH_cjs.replayEvents; }
|
|
14
15
|
});
|
|
15
16
|
Object.defineProperty(exports, "replayView", {
|
|
16
17
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkSNTV45LH_cjs.replayView; }
|
|
18
19
|
});
|
|
19
20
|
Object.defineProperty(exports, "viewContractKey", {
|
|
20
21
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkSNTV45LH_cjs.viewContractKey; }
|
|
22
23
|
});
|
|
23
24
|
//# sourceMappingURL=index.cjs.map
|
|
24
25
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SurfaceDeclaration } from '../discovery/index.cjs';
|
|
1
2
|
import { PortableJsonSchema } from '../objects/index.cjs';
|
|
2
3
|
|
|
3
4
|
interface ReplayableAssetEvent<Payload = unknown> {
|
|
@@ -26,7 +27,7 @@ interface ViewEventConsumption {
|
|
|
26
27
|
eventType: string;
|
|
27
28
|
schemaVersions: number[];
|
|
28
29
|
}
|
|
29
|
-
interface ViewContract<State = unknown, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {
|
|
30
|
+
interface ViewContract<State = unknown, Event extends ReplayableAssetEvent = ReplayableAssetEvent> extends SurfaceDeclaration {
|
|
30
31
|
/** Stable module-qualified logical identity, for example `orders/summary`. */
|
|
31
32
|
name: `${string}/${string}`;
|
|
32
33
|
version: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SurfaceDeclaration } from '../discovery/index.js';
|
|
1
2
|
import { PortableJsonSchema } from '../objects/index.js';
|
|
2
3
|
|
|
3
4
|
interface ReplayableAssetEvent<Payload = unknown> {
|
|
@@ -26,7 +27,7 @@ interface ViewEventConsumption {
|
|
|
26
27
|
eventType: string;
|
|
27
28
|
schemaVersions: number[];
|
|
28
29
|
}
|
|
29
|
-
interface ViewContract<State = unknown, Event extends ReplayableAssetEvent = ReplayableAssetEvent> {
|
|
30
|
+
interface ViewContract<State = unknown, Event extends ReplayableAssetEvent = ReplayableAssetEvent> extends SurfaceDeclaration {
|
|
30
31
|
/** Stable module-qualified logical identity, for example `orders/summary`. */
|
|
31
32
|
name: `${string}/${string}`;
|
|
32
33
|
version: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { createViewRegistry, replayEvents, replayView, viewContractKey } from '../chunk-
|
|
1
|
+
export { createViewRegistry, replayEvents, replayView, viewContractKey } from '../chunk-MLBALEUR.js';
|
|
2
|
+
import '../chunk-LFE74IJX.js';
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/dist/testing/index.d.cts
CHANGED
package/dist/testing/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabricorg/platform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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",
|
|
@@ -197,6 +197,16 @@
|
|
|
197
197
|
"types": "./dist/testing/index.d.cts",
|
|
198
198
|
"default": "./dist/testing/index.cjs"
|
|
199
199
|
}
|
|
200
|
+
},
|
|
201
|
+
"./discovery": {
|
|
202
|
+
"import": {
|
|
203
|
+
"types": "./dist/discovery/index.d.ts",
|
|
204
|
+
"default": "./dist/discovery/index.js"
|
|
205
|
+
},
|
|
206
|
+
"require": {
|
|
207
|
+
"types": "./dist/discovery/index.d.cts",
|
|
208
|
+
"default": "./dist/discovery/index.cjs"
|
|
209
|
+
}
|
|
200
210
|
}
|
|
201
211
|
},
|
|
202
212
|
"files": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../actions/index.ts"],"names":[],"mappings":";AAwBO,IAAM,WAAA,GAAoC;AAAA,EAChD,gBAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACD;AAEO,SAAS,YAAY,KAAA,EAAmC;AAC9D,EAAA,OAAQ,WAAA,CAAkC,SAAS,KAAK,CAAA;AACzD;AAEO,SAAS,gBAAgB,KAAA,EAA2C;AAC1E,EAAA,IAAI,CAAC,WAAA,CAAY,KAAK,CAAA,EAAG;AACxB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK,CAAA,CAAE,CAAA;AAAA,EAC9C;AACD;AAyLO,SAAS,eAAe,QAAA,EAAgD;AAC9E,EAAA,IAAI,CAAC,oCAAA,CAAqC,IAAA,CAAK,QAAQ,CAAA,EAAG;AACzD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsB,QAAQ,CAAA,CAAE,CAAA;AAAA,EACjD;AACD;AAUO,SAAS,oBAAA,CAAoC,WAAA,GAAgD,EAAC,EAAwB;AAC5H,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAqC;AACzD,EAAA,MAAM,QAAA,GAAW,CAAC,UAAA,KAA4C;AAC7D,IAAA,cAAA,CAAe,WAAW,QAAQ,CAAA;AAClC,IAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,UAAA,CAAW,QAAQ,CAAA,EAAG,MAAM,IAAI,KAAA,CAAM,CAAA,QAAA,EAAW,UAAA,CAAW,QAAQ,CAAA,uBAAA,CAAyB,CAAA;AAC7G,IAAA,IAAI,UAAA,CAAW,aAAA,IAAiB,UAAA,CAAW,WAAA,CAAY,WAAW,CAAA,EAAG;AACpE,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,QAAA,EAAW,UAAA,CAAW,QAAQ,CAAA,8FAAA,CAAgG,CAAA;AAAA,IAC/I;AACA,IAAA,OAAA,CAAQ,GAAA,CAAI,UAAA,CAAW,QAAA,EAAU,UAAU,CAAA;AAAA,EAC5C,CAAA;AACA,EAAA,KAAA,MAAW,UAAA,IAAc,WAAA,EAAa,QAAA,CAAS,UAAU,CAAA;AACzD,EAAA,OAAO;AAAA,IACN,QAAA;AAAA,IACA,kBAAkB,UAAA,EAAY;AAC7B,MAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,WAAW,QAAQ,CAAA,WAAY,UAAU,CAAA;AAAA,IAC3D,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,QAAA,KAAa,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAAA,IAC3C,GAAA,EAAK,CAAC,QAAA,KAAmC,OAAA,CAAQ,IAAI,QAAoB,CAAA;AAAA,IACzE,KAAK,MAAM,KAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,MAAM;AAAA,GACrC;AACD","file":"chunk-2W6FORTE.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\t/**\n\t * `immediate`: the invocation settles within the host's execution.\n\t * `accepted` and `long-running`: an adapter may hand the work to an\n\t * external system and the invocation stays running until that system\n\t * completes it by reference through the host's completion ingress.\n\t * Declare `completionDeadlineMs` on a `long-running` action so a callback\n\t * that never comes is noticed rather than waited on forever.\n\t */\n\tcompletion: ActionCompletionMode;\n\t/**\n\t * How long an accepted handoff may wait for its completion before the host\n\t * moves the invocation to reconciliation. Without it, nothing sweeps the\n\t * handoff. Refused on `immediate`, since nothing external completes it.\n\t */\n\tcompletionDeadlineMs?: number;\n\tconsistency: ActionConsistency;\n\tsensitivity?: ActionDataSensitivity;\n}\n\nexport interface SagaContext {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tparameters: unknown;\n\tsleep?: (delayMs: number) => Promise<void>;\n\tquery?: <T = unknown>(model: string, operation: string, args: unknown) => Promise<T>;\n\t/**\n\t * Wait for a named external signal carrying a payload of `T`, with a timeout.\n\t *\n\t * Resolves with the payload of the first signal received, or `null` if the timeout\n\t * fires first. Subsequent signals with the same name received before another\n\t * `awaitSignal` call are buffered (FIFO) so no signal is lost.\n\t *\n\t * Intended for agent-driven and webhook-driven coordination: replace polling loops\n\t * with push-based wakeups while preserving the saga's deterministic replay\n\t * semantics (the runtime is responsible for capturing signals into workflow history).\n\t *\n\t * Optional. Runtimes that cannot implement push-based signaling (e.g. an in-memory\n\t * test harness) may omit this; sagas should treat absence as a fallback condition\n\t * and use `sleep` + `query` polling instead.\n\t *\n\t * Signal *senders* are runtime-specific (e.g. a Temporal `WorkflowClient.signal()`\n\t * call from an action handler). Apps that need to send signals from action\n\t * handlers should expose a coordination service via `ActionContext.services`\n\t * — the platform does not prescribe the sender API.\n\t *\n\t * @example\n\t * const payload = await ctx.awaitSignal?.<{ result: Record<string, unknown> }>(\n\t * \"userInputProcessed\",\n\t * 5 * 60 * 1000,\n\t * );\n\t * if (payload) { /* handle pushed result *\\/ }\n\t * else { /* timeout — fall back to deterministic path *\\/ }\n\t */\n\tawaitSignal?: <T = unknown>(signalName: string, timeoutMs: number) => Promise<T | null>;\n}\n\nexport interface SagaChildActionInput {\n\tsuffix: string;\n\tactionId: string;\n\tparameters: Record<string, unknown>;\n}\n\nexport type SagaRunChild = (input: SagaChildActionInput) => Promise<Record<string, unknown>>;\n\nexport interface SagaCompletionEvent {\n\teventType: string;\n\tsubjectType: string;\n\tsubjectId: string;\n\tpayload: unknown;\n\teventSchemaVersion?: number;\n}\n\nexport interface SagaCompletion {\n\tresultData: Record<string, unknown>;\n\tevent?: SagaCompletionEvent;\n}\n\nexport type SagaImplementation = (\n\tctx: SagaContext,\n\trunChild: SagaRunChild,\n) => Promise<SagaCompletion>;\n\nexport function assertActionId(actionId: string): asserts actionId is ActionId {\n\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(actionId)) {\n\t\tthrow new Error(`Invalid action ID: ${actionId}`);\n\t}\n}\n\nexport interface ActionRegistry<TDb = unknown> {\n\tregister(definition: ActionDefinition<TDb>): void;\n\tregisterIfMissing(definition: ActionDefinition<TDb>): void;\n\tresolve(actionId: ActionId): ActionDefinition<TDb> | undefined;\n\thas(actionId: string): actionId is ActionId;\n\tids(): ActionId[];\n}\n\nexport function createActionRegistry<TDb = unknown>(definitions: readonly ActionDefinition<TDb>[] = []): ActionRegistry<TDb> {\n\tconst actions = new Map<ActionId, ActionDefinition<TDb>>();\n\tconst register = (definition: ActionDefinition<TDb>): void => {\n\t\tassertActionId(definition.actionId);\n\t\tif (actions.has(definition.actionId)) throw new Error(`Action \"${definition.actionId}\" is already registered`);\n\t\tif (definition.mutatesDomain && definition.emitsEvents.length === 0) {\n\t\t\tthrow new Error(`Action \"${definition.actionId}\" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`);\n\t\t}\n\t\tactions.set(definition.actionId, definition);\n\t};\n\tfor (const definition of definitions) register(definition);\n\treturn {\n\t\tregister,\n\t\tregisterIfMissing(definition) {\n\t\t\tif (!actions.has(definition.actionId)) register(definition);\n\t\t},\n\t\tresolve: (actionId) => actions.get(actionId),\n\t\thas: (actionId): actionId is ActionId => actions.has(actionId as ActionId),\n\t\tids: () => Array.from(actions.keys()),\n\t};\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../projections/index.ts"],"names":[],"mappings":";;;AA0DO,SAAS,gBAAgB,IAA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AAI,IAAA,CAAK,KAAK,CAAA,CAAE,OAAA,EAAQ;AAC1E","file":"chunk-CXR6KEKQ.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\t/**\n\t * Monotonic ordering cursor for the tenant/space event ledger. It is not\n\t * contiguous after a view filters event types or narrows to one subject.\n\t */\n\tsequence: number;\n\t/** Optional contiguous sequence local to this subject. */\n\tsubjectSequence?: 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\t/** Optional JSON Schema for query parameters. Parameterized variants get isolated snapshots. */\n\tparameterSchema?: 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\nexport function viewContractKey(view: Pick<ViewContract, \"name\" | \"version\">): string {\n\treturn `${view.name}@${view.version}`;\n}\n\nexport interface ViewRegistry {\n\tregister(view: ViewContract): void;\n\tregisterIfMissing(view: ViewContract): void;\n\tresolve(name: string, version: string): ViewContract | undefined;\n\tkeys(): string[];\n}\n\nexport function createViewRegistry(views: readonly ViewContract[] = []): ViewRegistry {\n\tconst registered = new Map<string, ViewContract>();\n\tconst register = (view: ViewContract): void => {\n\t\tconst key = viewContractKey(view);\n\t\tif (registered.has(key)) throw new Error(`View contract \"${key}\" is already registered.`);\n\t\tregistered.set(key, view);\n\t};\n\tfor (const view of views) register(view);\n\treturn {\n\t\tregister,\n\t\tregisterIfMissing(view) {\n\t\t\tif (!registered.has(viewContractKey(view))) register(view);\n\t\t},\n\t\tresolve: (name, version) => registered.get(`${name}@${version}`),\n\t\tkeys: () => Array.from(registered.keys()).sort(),\n\t};\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\t/**\n\t * Set when the event source already applied the snapshot cursor and returns\n\t * only later events. The snapshot still seeds state, but replay must not try\n\t * to find its cursor in the supplied incremental stream.\n\t */\n\teventsStartAfterSnapshot?: boolean;\n}\n\nexport async function replayView<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({\n\tview,\n\tevents,\n\tscope,\n\tsnapshot,\n\teventsStartAfterSnapshot = false,\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\teventsStartAfterSnapshot,\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 {\n\t\t...result,\n\t\teventCursor: result.eventCursor ?? upgradedSnapshot?.eventCursor ?? null,\n\t\teventSequence: result.appliedEvents.length\n\t\t\t? result.eventSequence\n\t\t\t: upgradedSnapshot?.eventSequence ?? result.eventSequence,\n\t\tsubjectSequences: result.appliedEvents.length\n\t\t\t? result.subjectSequences\n\t\t\t: upgradedSnapshot?.subjectSequences ?? result.subjectSequences,\n\t\twarnings: [...preprocessingWarnings, ...versionWarnings, ...resultWarnings],\n\t};\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\t/** Per-subject high-water marks. Values prefer subjectSequence when supplied. */\n\tsubjectSequences?: Record<string, number>;\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\t/** The supplied stream begins after the snapshot checkpoint. */\n\teventsStartAfterSnapshot?: boolean;\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\tsubjectSequences: Record<string, number>;\n}\n\nexport async function replayEvents<State, Event extends ReplayableAssetEvent = ReplayableAssetEvent>({\n\tevents,\n\tscope,\n\tinitialState,\n\tsnapshot,\n\tapplyEvent,\n\teventsStartAfterSnapshot = false,\n}: ReplayEventsOptions<State, Event>): Promise<ReplayEventsResult<State, Event>> {\n\tif (eventsStartAfterSnapshot && !snapshot?.eventCursor) {\n\t\tthrow new Error(\"eventsStartAfterSnapshot requires a snapshot with an eventCursor checkpoint.\");\n\t}\n\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 initialSubjectSequences = eventsStartAfterSnapshot\n\t\t? snapshotSubjectSequences(snapshot, scope)\n\t\t: undefined;\n\tconst subjectSequences = recordMissingSequenceWarnings(uniqueEvents, warnings, initialSubjectSequences);\n\tconst resumableEvents = applyCursor(\n\t\tuniqueEvents,\n\t\tsnapshot,\n\t\tisSubjectScoped(scope),\n\t\twarnings,\n\t\tinitialSubjectSequences,\n\t\teventsStartAfterSnapshot,\n\t);\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\tsubjectSequences: Object.fromEntries(\n\t\t\t[...subjectSequences.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0),\n\t\t),\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\treturn uniqueEvents;\n}\n\nfunction recordMissingSequenceWarnings<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\twarnings: ReplayWarning[],\n\tinitialSequences?: ReadonlyMap<string, number>,\n): Map<string, number> {\n\tconst lastSequenceBySubject = new Map(initialSequences);\n\n\tfor (const event of events) {\n\t\tconst subjectKey = subjectSequenceKey(event.subjectType, event.subjectId);\n\t\tconst previousSequence = lastSequenceBySubject.get(subjectKey);\n\t\tconst sequence = event.subjectSequence ?? event.sequence;\n\t\tconst expectedSequence = previousSequence === undefined ? sequence : previousSequence + 1;\n\n\t\t// A ledger sequence orders the complete tenant/space stream. A projection\n\t\t// filters that stream by event type and often by subject, so gaps in it do\n\t\t// not prove event loss. Only an explicit subject-local sequence can make\n\t\t// that guarantee.\n\t\tif (\n\t\t\tevent.subjectSequence !== undefined &&\n\t\t\tpreviousSequence !== undefined &&\n\t\t\tsequence > expectedSequence\n\t\t) {\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 ${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: sequence,\n\t\t\t});\n\t\t}\n\n\t\tlastSequenceBySubject.set(subjectKey, Math.max(previousSequence ?? sequence, sequence));\n\t}\n\treturn lastSequenceBySubject;\n}\n\nfunction applyCursor<Event extends ReplayableAssetEvent>(\n\tevents: Event[],\n\tsnapshot: ReplaySnapshot | null | undefined,\n\tsubjectScoped: boolean,\n\twarnings: ReplayWarning[],\n\tinitialSubjectSequences?: ReadonlyMap<string, number>,\n\teventsStartAfterSnapshot = false,\n): Event[] {\n\tconst eventCursor = snapshot?.eventCursor;\n\n\tif (eventCursor && !eventsStartAfterSnapshot) {\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 (initialSubjectSequences?.size) {\n\t\treturn events.filter((event) =>\n\t\t\t(event.subjectSequence ?? event.sequence) >\n\t\t\t(initialSubjectSequences.get(subjectSequenceKey(event.subjectType, event.subjectId)) ?? -1),\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 snapshotSubjectSequences(\n\tsnapshot: ReplaySnapshot | null | undefined,\n\tscope: ReplayScope,\n): Map<string, number> {\n\tconst sequences = new Map(Object.entries(snapshot?.subjectSequences ?? {}));\n\tif (\n\t\tsequences.size === 0 &&\n\t\tscope.subjectType &&\n\t\tscope.subjectId &&\n\t\tsnapshot?.eventSequence !== undefined &&\n\t\tsnapshot.eventSequence !== null\n\t) {\n\t\tsequences.set(subjectSequenceKey(scope.subjectType, scope.subjectId), snapshot.eventSequence);\n\t}\n\treturn sequences;\n}\n\nfunction subjectSequenceKey(subjectType: string, subjectId: string): string {\n\treturn `${subjectType}:${subjectId}`;\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.subjectSequence ?? first.sequence, toTimestamp(first.recordedAt), toTimestamp(first.occurredAt), first.id],\n\t\t[second.subjectSequence ?? 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"]}
|