@fabricorg/platform 1.10.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +31 -2
- package/dist/actions/index.cjs +45 -26
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.d.cts +225 -226
- package/dist/actions/index.d.ts +225 -226
- package/dist/actions/index.js +41 -2
- package/dist/actions/index.js.map +1 -1
- package/dist/adapters/index.cjs +696 -66
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +367 -365
- package/dist/adapters/index.d.ts +367 -365
- package/dist/adapters/index.js +682 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/agent-hitl/index.cjs +21 -10
- package/dist/agent-hitl/index.cjs.map +1 -1
- package/dist/agent-hitl/index.d.cts +30 -30
- package/dist/agent-hitl/index.d.ts +30 -30
- package/dist/agent-hitl/index.js +21 -2
- package/dist/agent-hitl/index.js.map +1 -1
- package/dist/certification/index.cjs +109 -24
- package/dist/certification/index.cjs.map +1 -1
- package/dist/certification/index.d.cts +33 -39
- package/dist/certification/index.d.ts +33 -39
- package/dist/certification/index.js +107 -8
- package/dist/certification/index.js.map +1 -1
- package/dist/discovery/index.cjs +12 -10
- package/dist/discovery/index.cjs.map +1 -1
- package/dist/discovery/index.d.cts +2 -10
- package/dist/discovery/index.d.ts +2 -10
- package/dist/discovery/index.js +12 -2
- package/dist/discovery/index.js.map +1 -1
- package/dist/engine-B4csEOEc.js +223 -0
- package/dist/engine-B4csEOEc.js.map +1 -0
- package/dist/engine-BqScuhrT.cjs +246 -0
- package/dist/engine-BqScuhrT.cjs.map +1 -0
- package/dist/events/index.cjs +39 -10
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +43 -43
- package/dist/events/index.d.ts +43 -43
- package/dist/events/index.js +39 -2
- package/dist/events/index.js.map +1 -1
- package/dist/evidence/index.cjs +12 -50
- package/dist/evidence/index.d.cts +2 -229
- package/dist/evidence/index.d.ts +2 -229
- package/dist/evidence/index.js +1 -5
- package/dist/evidence-BuCICb0c.js +516 -0
- package/dist/evidence-BuCICb0c.js.map +1 -0
- package/dist/evidence-Cq48eDvA.cjs +575 -0
- package/dist/evidence-Cq48eDvA.cjs.map +1 -0
- package/dist/governance/index.cjs +24 -18
- package/dist/governance/index.cjs.map +1 -1
- package/dist/governance/index.d.cts +80 -83
- package/dist/governance/index.d.ts +80 -83
- package/dist/governance/index.js +22 -2
- package/dist/governance/index.js.map +1 -1
- package/dist/ids/index.cjs +52 -22
- package/dist/ids/index.cjs.map +1 -1
- package/dist/ids/index.d.cts +17 -17
- package/dist/ids/index.d.ts +17 -17
- package/dist/ids/index.js +49 -2
- package/dist/ids/index.js.map +1 -1
- package/dist/index-9jasmw76.d.cts +124 -0
- package/dist/index-BXpeFdk2.d.cts +190 -0
- package/dist/index-BXpeFdk2.d.ts +190 -0
- package/dist/index-BnbsKZsT.d.cts +231 -0
- package/dist/index-CIl1rYRv.d.cts +11 -0
- package/dist/index-CIl1rYRv.d.ts +11 -0
- package/dist/index-CVHA1ypT.d.cts +262 -0
- package/dist/index-DZ4mnNb7.d.cts +78 -0
- package/dist/index-DZ4mnNb7.d.ts +78 -0
- package/dist/index-IqcDvl69.d.ts +124 -0
- package/dist/index-fmUiRBXu.d.cts +57 -0
- package/dist/index-fmUiRBXu.d.ts +57 -0
- package/dist/index-sPUPs8pr.d.ts +262 -0
- package/dist/index-z9-CYOIo.d.ts +231 -0
- package/dist/index.cjs +111 -393
- package/dist/index.d.cts +18 -17
- package/dist/index.d.ts +18 -17
- package/dist/index.js +19 -20
- package/dist/manifest/index.cjs +224 -35
- package/dist/manifest/index.cjs.map +1 -1
- package/dist/manifest/index.d.cts +130 -131
- package/dist/manifest/index.d.ts +130 -131
- package/dist/manifest/index.js +219 -7
- package/dist/manifest/index.js.map +1 -1
- package/dist/modules/index.cjs +281 -42
- package/dist/modules/index.cjs.map +1 -1
- package/dist/modules/index.d.cts +157 -159
- package/dist/modules/index.d.ts +157 -159
- package/dist/modules/index.js +274 -6
- package/dist/modules/index.js.map +1 -1
- package/dist/objects/index.cjs +355 -22
- package/dist/objects/index.cjs.map +1 -1
- package/dist/objects/index.d.cts +2 -77
- package/dist/objects/index.d.ts +2 -77
- package/dist/objects/index.js +352 -2
- package/dist/objects/index.js.map +1 -1
- package/dist/policies/index.cjs +14 -56
- package/dist/policies/index.d.cts +2 -261
- package/dist/policies/index.d.ts +2 -261
- package/dist/policies/index.js +1 -3
- package/dist/policies-DH_GCXQ-.js +627 -0
- package/dist/policies-DH_GCXQ-.js.map +1 -0
- package/dist/policies-Nxbp1CH8.cjs +698 -0
- package/dist/policies-Nxbp1CH8.cjs.map +1 -0
- package/dist/privacy/index.cjs +26 -43
- package/dist/privacy/index.cjs.map +1 -1
- package/dist/privacy/index.d.cts +2 -189
- package/dist/privacy/index.d.ts +2 -189
- package/dist/privacy/index.js +18 -3
- package/dist/privacy/index.js.map +1 -1
- package/dist/projections/index.cjs +241 -23
- package/dist/projections/index.cjs.map +1 -1
- package/dist/projections/index.d.cts +2 -125
- package/dist/projections/index.d.ts +2 -125
- package/dist/projections/index.js +238 -3
- package/dist/projections/index.js.map +1 -1
- package/dist/state-machines/index.cjs +76 -18
- package/dist/state-machines/index.cjs.map +1 -1
- package/dist/state-machines/index.d.cts +2 -55
- package/dist/state-machines/index.d.ts +2 -55
- package/dist/state-machines/index.js +74 -2
- package/dist/state-machines/index.js.map +1 -1
- package/dist/testing/index.cjs +27 -19
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +17 -19
- package/dist/testing/index.d.ts +17 -19
- package/dist/testing/index.js +25 -3
- package/dist/testing/index.js.map +1 -1
- package/package.json +6 -5
- package/dist/chunk-2AE6TMAX.cjs +0 -44
- package/dist/chunk-2AE6TMAX.cjs.map +0 -1
- package/dist/chunk-6HY35TKB.cjs +0 -491
- package/dist/chunk-6HY35TKB.cjs.map +0 -1
- package/dist/chunk-6UGEIDLC.cjs +0 -26
- package/dist/chunk-6UGEIDLC.cjs.map +0 -1
- package/dist/chunk-7GAWSUOG.js +0 -64
- package/dist/chunk-7GAWSUOG.js.map +0 -1
- package/dist/chunk-A42JJIPL.cjs +0 -699
- package/dist/chunk-A42JJIPL.cjs.map +0 -1
- package/dist/chunk-AFXKSIVI.cjs +0 -540
- package/dist/chunk-AFXKSIVI.cjs.map +0 -1
- package/dist/chunk-B5DOGDPG.js +0 -42
- package/dist/chunk-B5DOGDPG.js.map +0 -1
- package/dist/chunk-BJGZE3GE.js +0 -20
- package/dist/chunk-BJGZE3GE.js.map +0 -1
- package/dist/chunk-CRZXTZ36.cjs +0 -258
- package/dist/chunk-CRZXTZ36.cjs.map +0 -1
- package/dist/chunk-D4SWRBUH.cjs +0 -22
- package/dist/chunk-D4SWRBUH.cjs.map +0 -1
- package/dist/chunk-DBTAUI6C.cjs +0 -395
- package/dist/chunk-DBTAUI6C.cjs.map +0 -1
- package/dist/chunk-EMSAFNPX.js +0 -98
- package/dist/chunk-EMSAFNPX.js.map +0 -1
- package/dist/chunk-F3E5SXPN.cjs +0 -28
- package/dist/chunk-F3E5SXPN.cjs.map +0 -1
- package/dist/chunk-HEYMMVDP.js +0 -480
- package/dist/chunk-HEYMMVDP.js.map +0 -1
- package/dist/chunk-IFW43ELT.cjs +0 -331
- package/dist/chunk-IFW43ELT.cjs.map +0 -1
- package/dist/chunk-LFE74IJX.js +0 -20
- package/dist/chunk-LFE74IJX.js.map +0 -1
- package/dist/chunk-LZSE6QGQ.cjs +0 -60
- package/dist/chunk-LZSE6QGQ.cjs.map +0 -1
- package/dist/chunk-MCWSUGB3.cjs +0 -102
- package/dist/chunk-MCWSUGB3.cjs.map +0 -1
- package/dist/chunk-MLBALEUR.js +0 -290
- package/dist/chunk-MLBALEUR.js.map +0 -1
- package/dist/chunk-NNXQZPB3.cjs +0 -31
- package/dist/chunk-NNXQZPB3.cjs.map +0 -1
- package/dist/chunk-OFCCZ27Z.js +0 -26
- package/dist/chunk-OFCCZ27Z.js.map +0 -1
- package/dist/chunk-PDN5DOLQ.js +0 -242
- package/dist/chunk-PDN5DOLQ.js.map +0 -1
- package/dist/chunk-PIDZQAEL.js +0 -50
- package/dist/chunk-PIDZQAEL.js.map +0 -1
- package/dist/chunk-PXD7NG6X.js +0 -686
- package/dist/chunk-PXD7NG6X.js.map +0 -1
- package/dist/chunk-Q4Q4JPR3.js +0 -524
- package/dist/chunk-Q4Q4JPR3.js.map +0 -1
- package/dist/chunk-RALMUSOX.js +0 -55
- package/dist/chunk-RALMUSOX.js.map +0 -1
- package/dist/chunk-SNTV45LH.cjs +0 -295
- package/dist/chunk-SNTV45LH.cjs.map +0 -1
- package/dist/chunk-TBS2S5AX.cjs +0 -40
- package/dist/chunk-TBS2S5AX.cjs.map +0 -1
- package/dist/chunk-TYNIFC7J.js +0 -253
- package/dist/chunk-TYNIFC7J.js.map +0 -1
- package/dist/chunk-UGWGHTNC.cjs +0 -56
- package/dist/chunk-UGWGHTNC.cjs.map +0 -1
- package/dist/chunk-WI7CWNYI.cjs +0 -68
- package/dist/chunk-WI7CWNYI.cjs.map +0 -1
- package/dist/chunk-WNZP53GI.js +0 -386
- package/dist/chunk-WNZP53GI.js.map +0 -1
- package/dist/chunk-WQ3BYI7T.cjs +0 -249
- package/dist/chunk-WQ3BYI7T.cjs.map +0 -1
- package/dist/chunk-Y2PJLRIY.js +0 -36
- package/dist/chunk-Y2PJLRIY.js.map +0 -1
- package/dist/chunk-ZAEVQSB5.js +0 -326
- package/dist/chunk-ZAEVQSB5.js.map +0 -1
- package/dist/chunk-ZMQTV5OJ.js +0 -27
- package/dist/chunk-ZMQTV5OJ.js.map +0 -1
- package/dist/evidence/index.cjs.map +0 -1
- package/dist/evidence/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/policies/index.cjs.map +0 -1
- package/dist/policies/index.js.map +0 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { ActionId, ActorType, FabricRuntimeServices } from "./actions/index.js";
|
|
2
|
+
//#region policies/reconciliation-required.d.ts
|
|
3
|
+
/** A possibly committed domain effect requiring an operator decision at the handler transaction boundary. */
|
|
4
|
+
declare class ReconciliationRequiredError extends Error {
|
|
5
|
+
readonly name = "ReconciliationRequiredError";
|
|
6
|
+
readonly code: "EXECUTION_RECONCILIATION_REQUIRED";
|
|
7
|
+
constructor(message: string, options?: {
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Recognise a ReconciliationRequiredError, including one constructed by a second
|
|
13
|
+
* package copy (for example ESM and CommonJS builds loaded side by side).
|
|
14
|
+
*/
|
|
15
|
+
declare function isReconciliationRequiredError(error: unknown): error is ReconciliationRequiredError;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region policies/retryable-execution.d.ts
|
|
18
|
+
/** A transient execution dependency failure; the host decides whether retry is safe. */
|
|
19
|
+
declare class RetryableExecutionError extends Error {
|
|
20
|
+
readonly name = "RetryableExecutionError";
|
|
21
|
+
readonly code: "EXECUTION_RETRYABLE";
|
|
22
|
+
constructor(message: string, options?: {
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Recognise a RetryableExecutionError, including one constructed by a second
|
|
28
|
+
* package copy (for example ESM and CommonJS builds loaded side by side).
|
|
29
|
+
*/
|
|
30
|
+
declare function isRetryableExecutionError(error: unknown): error is RetryableExecutionError;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region policies/index.d.ts
|
|
33
|
+
type PolicyEvaluationResult = "pass" | "warn" | "block";
|
|
34
|
+
type PolicyKind = "code" | "data" | "hybrid";
|
|
35
|
+
type PolicyId = `${string}.v${number}`;
|
|
36
|
+
type PolicyEvaluationMode = "preview" | "execute";
|
|
37
|
+
declare function assertPolicyId(policyId: string): asserts policyId is PolicyId;
|
|
38
|
+
interface PolicyContext<TDb = unknown> {
|
|
39
|
+
tenantId: string;
|
|
40
|
+
spaceId: string;
|
|
41
|
+
actionInvocationId: string;
|
|
42
|
+
actionId: string;
|
|
43
|
+
/** Authenticated actor identity supplied by the host. Omitted only by legacy hosts and previews. */
|
|
44
|
+
actorId?: string;
|
|
45
|
+
actorType?: ActorType;
|
|
46
|
+
parameters: unknown;
|
|
47
|
+
db: TDb;
|
|
48
|
+
now?: Date;
|
|
49
|
+
mode?: PolicyEvaluationMode;
|
|
50
|
+
/**
|
|
51
|
+
* Optional runtime services bag, mirroring {@link FabricRuntimeServices} on
|
|
52
|
+
* `ActionContext`. Lets the host inject dependencies (HTTP clients, secret
|
|
53
|
+
* managers, external policy engines such as OPA, feature flags, etc.) that
|
|
54
|
+
* a code policy evaluator may need without resorting to module-level
|
|
55
|
+
* globals. The shape is opaque to the platform — adapters narrow it.
|
|
56
|
+
*/
|
|
57
|
+
services?: FabricRuntimeServices;
|
|
58
|
+
/** Explicit code-policy catalog for this runtime; absence fails closed. */
|
|
59
|
+
resolveCodePolicy?: (policyId: PolicyId) => PolicyEvaluator | undefined;
|
|
60
|
+
}
|
|
61
|
+
interface PolicyFact {
|
|
62
|
+
name: string;
|
|
63
|
+
value: unknown;
|
|
64
|
+
label?: string;
|
|
65
|
+
}
|
|
66
|
+
type PolicyCorrectiveActionKind = "invoke_action" | "navigate" | "manual";
|
|
67
|
+
interface PolicyCorrectiveActionBase {
|
|
68
|
+
kind: PolicyCorrectiveActionKind;
|
|
69
|
+
label: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
requiresRole?: string[];
|
|
72
|
+
requiresConfirmation?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface PolicyInvokeActionCorrectiveAction extends PolicyCorrectiveActionBase {
|
|
75
|
+
kind: "invoke_action";
|
|
76
|
+
actionId: ActionId;
|
|
77
|
+
parameters?: Record<string, unknown>;
|
|
78
|
+
}
|
|
79
|
+
interface PolicyNavigateCorrectiveAction extends PolicyCorrectiveActionBase {
|
|
80
|
+
kind: "navigate";
|
|
81
|
+
route?: string;
|
|
82
|
+
target?: {
|
|
83
|
+
surface?: string;
|
|
84
|
+
tab?: string;
|
|
85
|
+
field?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
interface PolicyManualCorrectiveAction extends PolicyCorrectiveActionBase {
|
|
89
|
+
kind: "manual";
|
|
90
|
+
}
|
|
91
|
+
type PolicyCorrectiveAction = PolicyInvokeActionCorrectiveAction | PolicyNavigateCorrectiveAction | PolicyManualCorrectiveAction;
|
|
92
|
+
interface PolicyGuidance {
|
|
93
|
+
summary?: string;
|
|
94
|
+
factsUsed: PolicyFact[];
|
|
95
|
+
correctiveActions: PolicyCorrectiveAction[];
|
|
96
|
+
}
|
|
97
|
+
interface PolicyGuidanceValidationResult {
|
|
98
|
+
valid: boolean;
|
|
99
|
+
errors: string[];
|
|
100
|
+
}
|
|
101
|
+
declare function validatePolicyGuidance(guidance: unknown): PolicyGuidanceValidationResult;
|
|
102
|
+
interface PolicyOutcome {
|
|
103
|
+
policyId: PolicyId;
|
|
104
|
+
policyVersion: number;
|
|
105
|
+
policyKind?: PolicyKind;
|
|
106
|
+
result: PolicyEvaluationResult;
|
|
107
|
+
reason?: string;
|
|
108
|
+
guidance?: PolicyGuidance;
|
|
109
|
+
metadata?: Record<string, unknown>;
|
|
110
|
+
dispatchEvidence?: PolicyDispatchEvidence;
|
|
111
|
+
}
|
|
112
|
+
interface PolicyEvaluator<TDb = unknown> {
|
|
113
|
+
policyId: PolicyId;
|
|
114
|
+
version: number;
|
|
115
|
+
kind?: Extract<PolicyKind, "code">;
|
|
116
|
+
previewSafe?: boolean;
|
|
117
|
+
evaluate: (ctx: PolicyContext<TDb>) => Promise<PolicyOutcome>;
|
|
118
|
+
}
|
|
119
|
+
type DataPolicySource = "parameters" | "context";
|
|
120
|
+
type DataPolicyLiteral = string | number | boolean | null;
|
|
121
|
+
type DataPolicyComparisonOperator = "exists" | "equals" | "notEquals" | "gt" | "gte" | "lt" | "lte";
|
|
122
|
+
interface DataPolicySourceReference {
|
|
123
|
+
source: DataPolicySource;
|
|
124
|
+
path: string;
|
|
125
|
+
}
|
|
126
|
+
type DataPolicyCondition = {
|
|
127
|
+
conditionId: string;
|
|
128
|
+
type: "always";
|
|
129
|
+
result: PolicyEvaluationResult;
|
|
130
|
+
reason?: string;
|
|
131
|
+
} | {
|
|
132
|
+
conditionId: string;
|
|
133
|
+
type: "parameter";
|
|
134
|
+
path: string;
|
|
135
|
+
operator: DataPolicyComparisonOperator;
|
|
136
|
+
value?: DataPolicyLiteral;
|
|
137
|
+
onPass?: PolicyEvaluationResult;
|
|
138
|
+
onFail?: PolicyEvaluationResult;
|
|
139
|
+
reason?: string;
|
|
140
|
+
} | {
|
|
141
|
+
conditionId: string;
|
|
142
|
+
type: "comparison";
|
|
143
|
+
left: DataPolicySourceReference;
|
|
144
|
+
operator: DataPolicyComparisonOperator;
|
|
145
|
+
value?: DataPolicyLiteral;
|
|
146
|
+
onPass?: PolicyEvaluationResult;
|
|
147
|
+
onFail?: PolicyEvaluationResult;
|
|
148
|
+
reason?: string;
|
|
149
|
+
} | {
|
|
150
|
+
conditionId: string;
|
|
151
|
+
type: "all" | "any";
|
|
152
|
+
conditions: DataPolicyCondition[];
|
|
153
|
+
onPass?: PolicyEvaluationResult;
|
|
154
|
+
onFail?: PolicyEvaluationResult;
|
|
155
|
+
reason?: string;
|
|
156
|
+
} | {
|
|
157
|
+
conditionId: string;
|
|
158
|
+
type: "not";
|
|
159
|
+
condition: DataPolicyCondition;
|
|
160
|
+
onPass?: PolicyEvaluationResult;
|
|
161
|
+
onFail?: PolicyEvaluationResult;
|
|
162
|
+
reason?: string;
|
|
163
|
+
};
|
|
164
|
+
interface DataPolicyDefinition {
|
|
165
|
+
conditions: DataPolicyCondition[];
|
|
166
|
+
defaultResult?: PolicyEvaluationResult;
|
|
167
|
+
reason?: string;
|
|
168
|
+
}
|
|
169
|
+
interface DataPolicyValidationResult {
|
|
170
|
+
valid: boolean;
|
|
171
|
+
errors: string[];
|
|
172
|
+
}
|
|
173
|
+
interface PolicyFallbackDefinition {
|
|
174
|
+
codeEvaluatorPolicyId: PolicyId;
|
|
175
|
+
onResults?: PolicyEvaluationResult[];
|
|
176
|
+
triggers?: PolicyFallbackTrigger[];
|
|
177
|
+
reason?: string;
|
|
178
|
+
}
|
|
179
|
+
type PolicyFallbackTrigger = "data_result" | "missing_data_definition" | "invalid_data_definition";
|
|
180
|
+
interface DataPolicyConditionResult {
|
|
181
|
+
conditionId: string;
|
|
182
|
+
passed: boolean;
|
|
183
|
+
result: PolicyEvaluationResult;
|
|
184
|
+
reason?: string;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Opaque, consumer-defined reference to the immutable policy authority or
|
|
188
|
+
* snapshot a runtime policy definition was resolved from. Platform records it
|
|
189
|
+
* in dispatch evidence and does not interpret it.
|
|
190
|
+
*/
|
|
191
|
+
interface PolicyAuthorityReference {
|
|
192
|
+
snapshotId: string;
|
|
193
|
+
contentHash?: string;
|
|
194
|
+
}
|
|
195
|
+
interface RuntimePolicyDefinition {
|
|
196
|
+
policyId: PolicyId;
|
|
197
|
+
policyVersion: number;
|
|
198
|
+
kind: PolicyKind;
|
|
199
|
+
/** Snapshot/authority this definition came from; copied into dispatch evidence. */
|
|
200
|
+
authority?: PolicyAuthorityReference;
|
|
201
|
+
dataDefinition?: DataPolicyDefinition;
|
|
202
|
+
codeEvaluatorPolicyId?: PolicyId;
|
|
203
|
+
fallback?: PolicyFallbackDefinition;
|
|
204
|
+
}
|
|
205
|
+
interface PolicyDispatchEvidence {
|
|
206
|
+
policyKind: PolicyKind;
|
|
207
|
+
policyId?: PolicyId;
|
|
208
|
+
policyVersion?: number;
|
|
209
|
+
/** Snapshot/authority the evaluated definition was resolved from, when supplied. */
|
|
210
|
+
authority?: PolicyAuthorityReference;
|
|
211
|
+
dispatchPath: Array<"data" | "code" | "fallback">;
|
|
212
|
+
data?: {
|
|
213
|
+
definitionVersion: number;
|
|
214
|
+
definitionStatus: "evaluated" | "missing" | "invalid";
|
|
215
|
+
conditionResults: DataPolicyConditionResult[];
|
|
216
|
+
validationErrors?: string[];
|
|
217
|
+
};
|
|
218
|
+
code?: {
|
|
219
|
+
requestedPolicyId?: PolicyId;
|
|
220
|
+
policyId: PolicyId;
|
|
221
|
+
version?: number;
|
|
222
|
+
registered: boolean;
|
|
223
|
+
skipped?: boolean;
|
|
224
|
+
skipReason?: string;
|
|
225
|
+
};
|
|
226
|
+
fallback?: {
|
|
227
|
+
used: boolean;
|
|
228
|
+
trigger: PolicyFallbackTrigger | "not_triggered";
|
|
229
|
+
reason: string;
|
|
230
|
+
fromResult?: PolicyEvaluationResult;
|
|
231
|
+
definitionVersion: number;
|
|
232
|
+
codeEvaluatorPolicyId: PolicyId;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Provenance for the engine that produced this decision when a code
|
|
236
|
+
* evaluator delegates to an external policy engine (OPA, Cedar, Cerbos,
|
|
237
|
+
* Topaz, etc.). Fabric's `policyId` / `policyVersion` remain canonical for
|
|
238
|
+
* audit; this block carries deployment provenance (decision path, bundle
|
|
239
|
+
* revision, decision ID, input hash). Adapters populate it; the platform
|
|
240
|
+
* keeps `metadata` open-ended so engine-specific typing can live in the
|
|
241
|
+
* adapter package.
|
|
242
|
+
*/
|
|
243
|
+
engine?: {
|
|
244
|
+
name: string;
|
|
245
|
+
version?: string;
|
|
246
|
+
metadata?: Record<string, unknown>;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
interface PolicyRegistry {
|
|
250
|
+
register(evaluator: PolicyEvaluator): void;
|
|
251
|
+
registerIfMissing(evaluator: PolicyEvaluator): void;
|
|
252
|
+
resolve(policyId: PolicyId): PolicyEvaluator | undefined;
|
|
253
|
+
ids(): PolicyId[];
|
|
254
|
+
}
|
|
255
|
+
declare function createPolicyRegistry(evaluators?: readonly PolicyEvaluator[]): PolicyRegistry;
|
|
256
|
+
declare function evaluateRegisteredPolicies(policyIds: PolicyId[], ctx: PolicyContext): Promise<PolicyOutcome[]>;
|
|
257
|
+
declare function evaluatePolicyDefinitions(policies: RuntimePolicyDefinition[], ctx: PolicyContext): Promise<PolicyOutcome[]>;
|
|
258
|
+
declare function evaluatePolicyDefinition(policy: RuntimePolicyDefinition, ctx: PolicyContext): Promise<PolicyOutcome>;
|
|
259
|
+
declare function validateDataPolicyDefinition(definition: DataPolicyDefinition): DataPolicyValidationResult;
|
|
260
|
+
declare function aggregatePolicyOutcomes(outcomes: PolicyOutcome[]): PolicyOutcome | undefined;
|
|
261
|
+
//#endregion
|
|
262
|
+
export { RuntimePolicyDefinition as A, isRetryableExecutionError as B, PolicyId as C, PolicyNavigateCorrectiveAction as D, PolicyManualCorrectiveAction as E, evaluatePolicyDefinitions as F, isReconciliationRequiredError as H, evaluateRegisteredPolicies as I, validateDataPolicyDefinition as L, assertPolicyId as M, createPolicyRegistry as N, PolicyOutcome as O, evaluatePolicyDefinition as P, validatePolicyGuidance as R, PolicyGuidanceValidationResult as S, PolicyKind as T, ReconciliationRequiredError as V, PolicyEvaluator as _, DataPolicyLiteral as a, PolicyFallbackTrigger as b, DataPolicyValidationResult as c, PolicyCorrectiveAction as d, PolicyCorrectiveActionBase as f, PolicyEvaluationResult as g, PolicyEvaluationMode as h, DataPolicyDefinition as i, aggregatePolicyOutcomes as j, PolicyRegistry as k, PolicyAuthorityReference as l, PolicyDispatchEvidence as m, DataPolicyCondition as n, DataPolicySource as o, PolicyCorrectiveActionKind as p, DataPolicyConditionResult as r, DataPolicySourceReference as s, DataPolicyComparisonOperator as t, PolicyContext as u, PolicyFact as v, PolicyInvokeActionCorrectiveAction as w, PolicyGuidance as x, PolicyFallbackDefinition as y, RetryableExecutionError as z };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { S as AnonymizationPolicy, o as AnonymizationMetadata } from "./index-BXpeFdk2.js";
|
|
2
|
+
//#region evidence/canonical-json.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Serializes a value as JSON with every object's keys sorted, recursively, by UTF-16 code-unit
|
|
5
|
+
* order (locale-independent). Array order is preserved.
|
|
6
|
+
*
|
|
7
|
+
* This is the serialization behind the `fabric-canonical-json-sha256-v1` digests: Host's
|
|
8
|
+
* parameter digests (`PARAMETER_DIGEST_ALGORITHM` in `@fabricorg/platform-host`) and evidence
|
|
9
|
+
* packet checksums (`EVIDENCE_PACKET_CHECKSUM_ALGORITHM`). Its output is a durable contract, so it
|
|
10
|
+
* must not change for any input. That includes values that are not plain JSON: any non-array
|
|
11
|
+
* object is rebuilt from its own enumerable entries before serialization, so a `Date` (which has
|
|
12
|
+
* none) serializes as `{}`, not as an ISO string. Convert dates to strings before calling this
|
|
13
|
+
* when they must survive into the output.
|
|
14
|
+
*/
|
|
15
|
+
declare function canonicalJson(value: unknown): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region evidence/generator.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Identifies how `EvidencePacketEnvelope.checksum` is computed: the lowercase hex SHA-256 of
|
|
20
|
+
* `canonicalJson(payload)`. It is the same identifier as Host's `PARAMETER_DIGEST_ALGORITHM`
|
|
21
|
+
* because the algorithm is the same (SHA-256 over `canonicalJson`).
|
|
22
|
+
*/
|
|
23
|
+
declare const EVIDENCE_PACKET_CHECKSUM_ALGORITHM: "fabric-canonical-json-sha256-v1";
|
|
24
|
+
/** Version of the `EvidencePacketPayload` shape produced by `generateEvidencePacket`. */
|
|
25
|
+
declare const EVIDENCE_PACKET_SCHEMA_VERSION: 1;
|
|
26
|
+
/** Packet type used when the input does not name one. */
|
|
27
|
+
declare const DEFAULT_EVIDENCE_PACKET_TYPE = "compliance_evidence";
|
|
28
|
+
/** Anonymization reason recorded when the caller does not supply one. */
|
|
29
|
+
declare const DEFAULT_EVIDENCE_REDACTION_REASON = "evidence_packet_generation";
|
|
30
|
+
/**
|
|
31
|
+
* A `Date`, or an ISO 8601 / PostgreSQL ISO date-time string with an explicit zone (`Z`, `+HH`,
|
|
32
|
+
* `+HH:MM` or `+HHMM`). Zone-less, non-ISO and out-of-range strings are rejected.
|
|
33
|
+
*/
|
|
34
|
+
type EvidenceTimestamp = Date | string;
|
|
35
|
+
/** Tenant and space every record read through the port must belong to. */
|
|
36
|
+
interface EvidenceScope {
|
|
37
|
+
tenantId: string;
|
|
38
|
+
spaceId: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* An asset event as the read port returns it. `AssetEventEnvelope` (events) and `AssetEventLike`
|
|
42
|
+
* (privacy) both satisfy this shape. Fields beyond these are kept in the packet payload.
|
|
43
|
+
*/
|
|
44
|
+
interface EvidenceEventRecord {
|
|
45
|
+
id: string;
|
|
46
|
+
tenantId: string;
|
|
47
|
+
spaceId: string;
|
|
48
|
+
eventType: string;
|
|
49
|
+
subjectType: string;
|
|
50
|
+
subjectId: string;
|
|
51
|
+
actionInvocationId?: string | null;
|
|
52
|
+
sequence: number;
|
|
53
|
+
occurredAt: EvidenceTimestamp;
|
|
54
|
+
recordedAt: EvidenceTimestamp;
|
|
55
|
+
correlationId: string;
|
|
56
|
+
causationId?: string | null;
|
|
57
|
+
payload: unknown;
|
|
58
|
+
}
|
|
59
|
+
/** An action invocation, policy evaluation or adapter invocation record. Further fields are kept. */
|
|
60
|
+
interface EvidenceRecord {
|
|
61
|
+
id: string;
|
|
62
|
+
tenantId: string;
|
|
63
|
+
spaceId: string;
|
|
64
|
+
actionInvocationId?: string | null;
|
|
65
|
+
[field: string]: unknown;
|
|
66
|
+
}
|
|
67
|
+
/** A record that belongs to one action invocation (policy evaluations, adapter invocations). */
|
|
68
|
+
interface EvidenceInvocationRecord extends EvidenceRecord {
|
|
69
|
+
actionInvocationId: string;
|
|
70
|
+
}
|
|
71
|
+
interface EvidenceEventQuery extends EvidenceScope {
|
|
72
|
+
/** The subject the packet is about. Always `subjects[0]`. */
|
|
73
|
+
primarySubject: EvidencePacketSubject;
|
|
74
|
+
/** Primary subject first, then related subjects, de-duplicated and sorted. */
|
|
75
|
+
subjects: readonly EvidencePacketSubject[];
|
|
76
|
+
}
|
|
77
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Read-only access to the application's evidence store. The generator filters nothing the port
|
|
80
|
+
* returns; it rejects, rather than drops, a record that fails one of its checks:
|
|
81
|
+
*
|
|
82
|
+
* - every record must have the generation context's `tenantId` and `spaceId`;
|
|
83
|
+
* - action invocations must have one of the requested ids, and policy evaluations and adapter
|
|
84
|
+
* invocations one of the requested `actionInvocationId`s;
|
|
85
|
+
* - records must have the documented shape (non-empty `id`, event fields, parseable timestamps) and
|
|
86
|
+
* be representable as plain JSON, and any `_privacy` value must be engine-written
|
|
87
|
+
* `AnonymizationMetadata`.
|
|
88
|
+
*
|
|
89
|
+
* Which events belong to the packet is the port's decision: the generator does not check an event's
|
|
90
|
+
* subject against `subjects`, because a port may legitimately return events recorded against the
|
|
91
|
+
* primary subject's own action invocations under another subject.
|
|
92
|
+
*/
|
|
93
|
+
interface EvidencePacketReadPort {
|
|
94
|
+
/** Asset events for the given subjects within the tenant and space. Required. */
|
|
95
|
+
listEvents(query: EvidenceEventQuery): MaybePromise<readonly EvidenceEventRecord[]>;
|
|
96
|
+
/** The application's related-subject rules. When absent, only the primary subject is used. */
|
|
97
|
+
resolveRelatedSubjects?(subject: EvidencePacketSubject, scope: EvidenceScope): MaybePromise<readonly EvidencePacketSubject[]>;
|
|
98
|
+
/** Action invocations by id. When absent, the section is empty. */
|
|
99
|
+
listActionInvocations?(scope: EvidenceScope, ids: readonly string[]): MaybePromise<readonly EvidenceRecord[]>;
|
|
100
|
+
/** Policy evaluations for the given action invocations. When absent, the section is empty. */
|
|
101
|
+
listPolicyEvaluations?(scope: EvidenceScope, actionInvocationIds: readonly string[]): MaybePromise<readonly EvidenceInvocationRecord[]>;
|
|
102
|
+
/** Adapter invocations for the given action invocations. When absent, the section is empty. */
|
|
103
|
+
listAdapterInvocations?(scope: EvidenceScope, actionInvocationIds: readonly string[]): MaybePromise<readonly EvidenceInvocationRecord[]>;
|
|
104
|
+
}
|
|
105
|
+
/** A record after normalization: plain JSON, every `Date` replaced by its ISO string. */
|
|
106
|
+
type EvidenceJsonRecord = Record<string, unknown>;
|
|
107
|
+
interface EvidencePacketPayload {
|
|
108
|
+
schemaVersion: typeof EVIDENCE_PACKET_SCHEMA_VERSION;
|
|
109
|
+
packetType: string;
|
|
110
|
+
tenantId: string;
|
|
111
|
+
spaceId: string;
|
|
112
|
+
primarySubject: EvidencePacketSubject;
|
|
113
|
+
subjects: EvidencePacketSubject[];
|
|
114
|
+
includeRelated: boolean;
|
|
115
|
+
policyVersion?: string;
|
|
116
|
+
events: EvidenceJsonRecord[];
|
|
117
|
+
actionInvocations: EvidenceJsonRecord[];
|
|
118
|
+
policyEvaluations: EvidenceJsonRecord[];
|
|
119
|
+
adapterInvocations: EvidenceJsonRecord[];
|
|
120
|
+
/** Metadata from the anonymization pass over the rest of the payload (validated engine-written `_privacy` values pass through it unchanged). */
|
|
121
|
+
redaction: AnonymizationMetadata;
|
|
122
|
+
}
|
|
123
|
+
interface GenerateEvidencePacketInput {
|
|
124
|
+
subject: EvidencePacketSubject;
|
|
125
|
+
/** Set to `false` to skip `resolveRelatedSubjects`. Defaults to `true`. */
|
|
126
|
+
includeRelated?: boolean;
|
|
127
|
+
/** Defaults to `DEFAULT_EVIDENCE_PACKET_TYPE`. */
|
|
128
|
+
packetType?: string;
|
|
129
|
+
policyVersion?: string;
|
|
130
|
+
}
|
|
131
|
+
interface GenerateEvidencePacketOptions {
|
|
132
|
+
port: EvidencePacketReadPort;
|
|
133
|
+
/**
|
|
134
|
+
* Redaction applied to the whole payload with data class `"evidence_packet"`. Required so that
|
|
135
|
+
* redaction cannot be skipped by omission; pass `{ fields: [] }` to redact nothing.
|
|
136
|
+
*/
|
|
137
|
+
anonymizationPolicy: AnonymizationPolicy;
|
|
138
|
+
anonymization?: {
|
|
139
|
+
/** Defaults to the packet id. */
|
|
140
|
+
jobId?: string;
|
|
141
|
+
/** Defaults to `DEFAULT_EVIDENCE_REDACTION_REASON`. */
|
|
142
|
+
reason?: string;
|
|
143
|
+
/** Defaults to the engine's `ANONYMIZATION_POLICY_VERSION`. */
|
|
144
|
+
policyVersion?: string;
|
|
145
|
+
};
|
|
146
|
+
/** Defaults to `createFabricId(FABRIC_ID_PREFIXES.complianceEvidencePacket)`. */
|
|
147
|
+
idFactory?: () => string;
|
|
148
|
+
}
|
|
149
|
+
type EvidencePacketGenerationErrorCode = "EVIDENCE_SCOPE_MISMATCH" | "EVIDENCE_INVALID_RECORD" | "EVIDENCE_UNREQUESTED_RECORD" | "EVIDENCE_IDENTIFIER_REDACTED";
|
|
150
|
+
declare class EvidencePacketGenerationError extends Error {
|
|
151
|
+
readonly code: EvidencePacketGenerationErrorCode;
|
|
152
|
+
constructor(code: EvidencePacketGenerationErrorCode, message: string);
|
|
153
|
+
}
|
|
154
|
+
/** Lowercase hex SHA-256 of `canonicalJson(payload)`. */
|
|
155
|
+
declare function computeEvidencePacketChecksum(payload: unknown): string;
|
|
156
|
+
/**
|
|
157
|
+
* Builds a sealed evidence packet for one subject from the application's read port.
|
|
158
|
+
*
|
|
159
|
+
* Steps: resolve subjects (primary first, then related, de-duplicated and sorted); read events,
|
|
160
|
+
* then the action invocations, policy evaluations and adapter invocations those events reference;
|
|
161
|
+
* reject any record outside `context.tenantId`/`context.spaceId`; normalize to plain JSON and sort
|
|
162
|
+
* deterministically; redact the payload with `AnonymizationEngine` (data class
|
|
163
|
+
* `"evidence_packet"`); checksum the redacted payload; and build references from it.
|
|
164
|
+
*
|
|
165
|
+
* Nothing is persisted. Storing the returned envelope is the application's job.
|
|
166
|
+
*/
|
|
167
|
+
declare function generateEvidencePacket<TDb = unknown>(input: GenerateEvidencePacketInput, context: EvidenceGenerationContext<TDb>, options: GenerateEvidencePacketOptions): Promise<EvidencePacketEnvelope<EvidencePacketPayload>>;
|
|
168
|
+
/**
|
|
169
|
+
* Recomputes an envelope's checksum. Returns `false`, never throws, when the checksum is missing,
|
|
170
|
+
* the algorithm is missing or unknown, the payload cannot be serialized, or the values differ.
|
|
171
|
+
* It covers `payload` only, which includes the subjects and the redaction metadata; the other
|
|
172
|
+
* envelope fields are not covered.
|
|
173
|
+
*/
|
|
174
|
+
declare function verifyEvidencePacketChecksum(envelope: Pick<EvidencePacketEnvelope<unknown>, "payload" | "checksum" | "checksumAlgorithm">): boolean;
|
|
175
|
+
type EvidencePacketRendererInput = Omit<GenerateEvidencePacketInput, "packetType">;
|
|
176
|
+
interface EvidencePacketRendererOptions extends GenerateEvidencePacketOptions {
|
|
177
|
+
packetType?: string;
|
|
178
|
+
}
|
|
179
|
+
/** Wraps `generateEvidencePacket` as an `EvidenceRenderer` for one packet type. */
|
|
180
|
+
declare function createEvidencePacketRenderer<TDb = unknown>(options: EvidencePacketRendererOptions): EvidenceRenderer<EvidencePacketRendererInput, EvidencePacketPayload, TDb>;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region evidence/index.d.ts
|
|
183
|
+
type EvidencePacketStatus = "draft" | "sealed" | "superseded";
|
|
184
|
+
interface EvidencePacketSubject {
|
|
185
|
+
subjectType: string;
|
|
186
|
+
subjectId: string;
|
|
187
|
+
}
|
|
188
|
+
interface EvidencePacketReference {
|
|
189
|
+
referenceType: "action_invocation" | "asset_event" | "policy_evaluation" | "adapter_invocation" | "document" | "external_observation";
|
|
190
|
+
referenceId: string;
|
|
191
|
+
checksum?: string;
|
|
192
|
+
uri?: string;
|
|
193
|
+
metadata?: Record<string, unknown>;
|
|
194
|
+
}
|
|
195
|
+
interface EvidencePacketEnvelope<TPayload = Record<string, unknown>> {
|
|
196
|
+
id: string;
|
|
197
|
+
tenantId: string;
|
|
198
|
+
spaceId: string;
|
|
199
|
+
packetType: string;
|
|
200
|
+
status: EvidencePacketStatus;
|
|
201
|
+
subjects: EvidencePacketSubject[];
|
|
202
|
+
references: EvidencePacketReference[];
|
|
203
|
+
payload: TPayload;
|
|
204
|
+
generatedAt: Date | string;
|
|
205
|
+
generatedBy: string;
|
|
206
|
+
policyVersion?: string;
|
|
207
|
+
checksum?: string;
|
|
208
|
+
/**
|
|
209
|
+
* How `checksum` was computed. Packets built by `generateEvidencePacket` use
|
|
210
|
+
* `EVIDENCE_PACKET_CHECKSUM_ALGORITHM`. Optional and additive: envelopes built before this field
|
|
211
|
+
* existed omit it.
|
|
212
|
+
*/
|
|
213
|
+
checksumAlgorithm?: string;
|
|
214
|
+
correlationId: string;
|
|
215
|
+
causationId?: string;
|
|
216
|
+
}
|
|
217
|
+
interface EvidenceGenerationContext<TDb = unknown> {
|
|
218
|
+
tenantId: string;
|
|
219
|
+
spaceId: string;
|
|
220
|
+
actorId: string;
|
|
221
|
+
correlationId: string;
|
|
222
|
+
causationId?: string;
|
|
223
|
+
db: TDb;
|
|
224
|
+
now?: Date;
|
|
225
|
+
}
|
|
226
|
+
interface EvidenceRenderer<TInput = unknown, TPayload = Record<string, unknown>, TDb = unknown> {
|
|
227
|
+
packetType: string;
|
|
228
|
+
render: (input: TInput, context: EvidenceGenerationContext<TDb>) => Promise<EvidencePacketEnvelope<TPayload>> | EvidencePacketEnvelope<TPayload>;
|
|
229
|
+
}
|
|
230
|
+
//#endregion
|
|
231
|
+
export { canonicalJson as A, EvidenceTimestamp as C, createEvidencePacketRenderer as D, computeEvidencePacketChecksum as E, generateEvidencePacket as O, EvidenceScope as S, GenerateEvidencePacketOptions as T, EvidencePacketPayload as _, EvidencePacketSubject as a, EvidencePacketRendererOptions as b, DEFAULT_EVIDENCE_REDACTION_REASON as c, EvidenceEventQuery as d, EvidenceEventRecord as f, EvidencePacketGenerationErrorCode as g, EvidencePacketGenerationError as h, EvidencePacketStatus as i, verifyEvidencePacketChecksum as k, EVIDENCE_PACKET_CHECKSUM_ALGORITHM as l, EvidenceJsonRecord as m, EvidencePacketEnvelope as n, EvidenceRenderer as o, EvidenceInvocationRecord as p, EvidencePacketReference as r, DEFAULT_EVIDENCE_PACKET_TYPE as s, EvidenceGenerationContext as t, EVIDENCE_PACKET_SCHEMA_VERSION as u, EvidencePacketReadPort as v, GenerateEvidencePacketInput as w, EvidenceRecord as x, EvidencePacketRendererInput as y };
|