@fabricorg/platform 1.1.0 → 1.2.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 +46 -0
- package/README.md +20 -7
- package/dist/adapters/index.cjs +18 -6
- package/dist/adapters/index.d.cts +76 -1
- package/dist/adapters/index.d.ts +76 -1
- package/dist/adapters/index.js +1 -1
- package/dist/{chunk-YZKUEC2J.cjs → chunk-3BGFHSSK.cjs} +4 -4
- package/dist/{chunk-YZKUEC2J.cjs.map → chunk-3BGFHSSK.cjs.map} +1 -1
- package/dist/{chunk-6T6F3TNQ.cjs → chunk-3UBX7KQM.cjs} +12 -11
- package/dist/chunk-3UBX7KQM.cjs.map +1 -0
- package/dist/{chunk-53YJK3LK.js → chunk-63MYMAEX.js} +5 -4
- package/dist/chunk-63MYMAEX.js.map +1 -0
- package/dist/{chunk-OWSSGFNY.js → chunk-7GAWSUOG.js} +22 -3
- package/dist/chunk-7GAWSUOG.js.map +1 -0
- package/dist/{chunk-IFMZPLM4.js → chunk-AWP6JDD5.js} +3 -3
- package/dist/{chunk-IFMZPLM4.js.map → chunk-AWP6JDD5.js.map} +1 -1
- package/dist/{chunk-M5FGWXT3.cjs → chunk-CXR6KEKQ.cjs} +11 -10
- package/dist/chunk-CXR6KEKQ.cjs.map +1 -0
- package/dist/{chunk-3ZW5USXF.js → chunk-DTY3CHQZ.js} +24 -5
- package/dist/chunk-DTY3CHQZ.js.map +1 -0
- package/dist/chunk-IFW43ELT.cjs +331 -0
- package/dist/chunk-IFW43ELT.cjs.map +1 -0
- package/dist/{chunk-J5LS5BSI.js → chunk-JG35DT2G.js} +11 -10
- package/dist/chunk-JG35DT2G.js.map +1 -0
- package/dist/{chunk-ETONSTUW.js → chunk-LZNXUTJQ.js} +4 -3
- package/dist/chunk-LZNXUTJQ.js.map +1 -0
- package/dist/{chunk-NPVIFZQV.cjs → chunk-N2BBUKCX.cjs} +26 -4
- package/dist/chunk-N2BBUKCX.cjs.map +1 -0
- package/dist/{chunk-ANPJYXBK.cjs → chunk-TBS2S5AX.cjs} +8 -2
- package/dist/chunk-TBS2S5AX.cjs.map +1 -0
- package/dist/{chunk-A2VTSATF.cjs → chunk-UITRHBZH.cjs} +7 -6
- package/dist/chunk-UITRHBZH.cjs.map +1 -0
- package/dist/{chunk-WAI4UNWQ.cjs → chunk-WI7CWNYI.cjs} +22 -2
- package/dist/chunk-WI7CWNYI.cjs.map +1 -0
- package/dist/{chunk-3OWMPDBD.js → chunk-Y2PJLRIY.js} +8 -2
- package/dist/chunk-Y2PJLRIY.js.map +1 -0
- package/dist/chunk-ZAEVQSB5.js +326 -0
- package/dist/chunk-ZAEVQSB5.js.map +1 -0
- package/dist/governance/index.cjs +4 -4
- package/dist/governance/index.d.cts +4 -0
- package/dist/governance/index.d.ts +4 -0
- package/dist/governance/index.js +1 -1
- package/dist/index.cjs +62 -42
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -8
- package/dist/manifest/index.cjs +10 -10
- package/dist/manifest/index.d.cts +1 -0
- package/dist/manifest/index.d.ts +1 -0
- package/dist/manifest/index.js +4 -4
- package/dist/modules/index.cjs +11 -11
- package/dist/modules/index.d.cts +2 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -3
- package/dist/objects/index.cjs +8 -4
- package/dist/objects/index.d.cts +11 -1
- package/dist/objects/index.d.ts +11 -1
- package/dist/objects/index.js +1 -1
- package/dist/projections/index.cjs +5 -5
- package/dist/projections/index.d.cts +9 -1
- package/dist/projections/index.d.ts +9 -1
- package/dist/projections/index.js +1 -1
- package/dist/state-machines/index.cjs +7 -3
- package/dist/state-machines/index.d.cts +10 -1
- package/dist/state-machines/index.d.ts +10 -1
- package/dist/state-machines/index.js +1 -1
- package/dist/testing/index.cjs +5 -5
- package/dist/testing/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-3OWMPDBD.js.map +0 -1
- package/dist/chunk-3ZW5USXF.js.map +0 -1
- package/dist/chunk-53YJK3LK.js.map +0 -1
- package/dist/chunk-6T6F3TNQ.cjs.map +0 -1
- package/dist/chunk-A2VTSATF.cjs.map +0 -1
- package/dist/chunk-ANPJYXBK.cjs.map +0 -1
- package/dist/chunk-CBY6GRJP.cjs +0 -140
- package/dist/chunk-CBY6GRJP.cjs.map +0 -1
- package/dist/chunk-ETONSTUW.js.map +0 -1
- package/dist/chunk-J5LS5BSI.js.map +0 -1
- package/dist/chunk-M5FGWXT3.cjs.map +0 -1
- package/dist/chunk-NETLRKDS.js +0 -136
- package/dist/chunk-NETLRKDS.js.map +0 -1
- package/dist/chunk-NPVIFZQV.cjs.map +0 -1
- package/dist/chunk-OWSSGFNY.js.map +0 -1
- package/dist/chunk-WAI4UNWQ.cjs.map +0 -1
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// objects/index.ts
|
|
4
|
+
var BUILT_IN_OBJECT_TYPES = Object.freeze([
|
|
5
|
+
"AssetEvent",
|
|
6
|
+
"ActionInvocation",
|
|
7
|
+
"PolicyEvaluation",
|
|
8
|
+
"ApprovalRequest",
|
|
9
|
+
"ConsentRecord",
|
|
10
|
+
"AgentRun"
|
|
11
|
+
]);
|
|
12
|
+
var supportedSchemaKeywords = Object.freeze([
|
|
13
|
+
"$schema",
|
|
14
|
+
"$id",
|
|
15
|
+
"$ref",
|
|
16
|
+
"$defs",
|
|
17
|
+
"title",
|
|
18
|
+
"description",
|
|
19
|
+
"type",
|
|
20
|
+
"enum",
|
|
21
|
+
"const",
|
|
22
|
+
"properties",
|
|
23
|
+
"required",
|
|
24
|
+
"additionalProperties",
|
|
25
|
+
"items",
|
|
26
|
+
"prefixItems",
|
|
27
|
+
"propertyNames",
|
|
28
|
+
"patternProperties",
|
|
29
|
+
"dependentRequired",
|
|
30
|
+
"allOf",
|
|
31
|
+
"anyOf",
|
|
32
|
+
"oneOf",
|
|
33
|
+
"not",
|
|
34
|
+
"minimum",
|
|
35
|
+
"maximum",
|
|
36
|
+
"exclusiveMinimum",
|
|
37
|
+
"exclusiveMaximum",
|
|
38
|
+
"minLength",
|
|
39
|
+
"maxLength",
|
|
40
|
+
"pattern",
|
|
41
|
+
"format",
|
|
42
|
+
"minItems",
|
|
43
|
+
"maxItems",
|
|
44
|
+
"uniqueItems",
|
|
45
|
+
"default",
|
|
46
|
+
"readOnly",
|
|
47
|
+
"writeOnly",
|
|
48
|
+
"deprecated",
|
|
49
|
+
"contentEncoding",
|
|
50
|
+
"contentMediaType",
|
|
51
|
+
"multipleOf",
|
|
52
|
+
"if",
|
|
53
|
+
"then",
|
|
54
|
+
"else",
|
|
55
|
+
"examples",
|
|
56
|
+
"$comment"
|
|
57
|
+
]);
|
|
58
|
+
function assertPortableJsonSchema(schema, path = "schema") {
|
|
59
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
|
60
|
+
throw new Error(`${path} must be a JSON Schema object.`);
|
|
61
|
+
}
|
|
62
|
+
const value = schema;
|
|
63
|
+
for (const keyword of Object.keys(value)) {
|
|
64
|
+
if (!supportedSchemaKeywords.includes(keyword) && !keyword.startsWith("x-")) {
|
|
65
|
+
throw new Error(`${path} uses unsupported JSON Schema keyword "${keyword}".`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (value.properties !== void 0) {
|
|
69
|
+
if (!value.properties || typeof value.properties !== "object" || Array.isArray(value.properties)) {
|
|
70
|
+
throw new Error(`${path}.properties must be an object.`);
|
|
71
|
+
}
|
|
72
|
+
for (const [name, child] of Object.entries(value.properties)) {
|
|
73
|
+
assertPortableJsonSchema(child, `${path}.properties.${name}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (value.$defs !== void 0) {
|
|
77
|
+
if (!value.$defs || typeof value.$defs !== "object" || Array.isArray(value.$defs)) {
|
|
78
|
+
throw new Error(`${path}.$defs must be an object.`);
|
|
79
|
+
}
|
|
80
|
+
for (const [name, child] of Object.entries(value.$defs)) {
|
|
81
|
+
assertPortableJsonSchema(child, `${path}.$defs.${name}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (value.patternProperties !== void 0) {
|
|
85
|
+
if (!value.patternProperties || typeof value.patternProperties !== "object" || Array.isArray(value.patternProperties)) throw new Error(`${path}.patternProperties must be an object.`);
|
|
86
|
+
for (const [name, child] of Object.entries(value.patternProperties)) assertPortableJsonSchema(child, `${path}.patternProperties.${name}`);
|
|
87
|
+
}
|
|
88
|
+
for (const keyword of ["allOf", "anyOf", "oneOf"]) {
|
|
89
|
+
if (value[keyword] !== void 0) {
|
|
90
|
+
if (!Array.isArray(value[keyword])) throw new Error(`${path}.${keyword} must be an array.`);
|
|
91
|
+
value[keyword].forEach((child, index) => assertPortableJsonSchema(child, `${path}.${keyword}[${index}]`));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (value.not !== void 0) assertPortableJsonSchema(value.not, `${path}.not`);
|
|
95
|
+
for (const keyword of ["propertyNames", "if", "then", "else"]) if (value[keyword] !== void 0) assertPortableJsonSchema(value[keyword], `${path}.${keyword}`);
|
|
96
|
+
if (value.additionalProperties !== void 0 && typeof value.additionalProperties !== "boolean") {
|
|
97
|
+
assertPortableJsonSchema(value.additionalProperties, `${path}.additionalProperties`);
|
|
98
|
+
}
|
|
99
|
+
if (value.items !== void 0) {
|
|
100
|
+
if (Array.isArray(value.items)) {
|
|
101
|
+
value.items.forEach((child, index) => assertPortableJsonSchema(child, `${path}.items[${index}]`));
|
|
102
|
+
} else {
|
|
103
|
+
assertPortableJsonSchema(value.items, `${path}.items`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (value.prefixItems !== void 0) {
|
|
107
|
+
if (!Array.isArray(value.prefixItems)) throw new Error(`${path}.prefixItems must be an array.`);
|
|
108
|
+
value.prefixItems.forEach((child, index) => assertPortableJsonSchema(child, `${path}.prefixItems[${index}]`));
|
|
109
|
+
}
|
|
110
|
+
if (value.dependentRequired !== void 0) {
|
|
111
|
+
if (!value.dependentRequired || typeof value.dependentRequired !== "object" || Array.isArray(value.dependentRequired) || Object.values(value.dependentRequired).some((items) => !Array.isArray(items) || items.some((item) => typeof item !== "string"))) throw new Error(`${path}.dependentRequired must map property names to arrays of property names.`);
|
|
112
|
+
}
|
|
113
|
+
if (value.required !== void 0 && (!Array.isArray(value.required) || value.required.some((item) => typeof item !== "string"))) {
|
|
114
|
+
throw new Error(`${path}.required must be an array of property names.`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function validatePortableJson(schema, value) {
|
|
118
|
+
const issues = [];
|
|
119
|
+
validateSchema(schema, value, [], schema, issues, /* @__PURE__ */ new Set());
|
|
120
|
+
return issues;
|
|
121
|
+
}
|
|
122
|
+
function validateSchema(schema, value, path, root, issues, refStack) {
|
|
123
|
+
if (!isJsonValue(value)) {
|
|
124
|
+
issues.push({ path, message: "Value must contain JSON-serializable data." });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (schema.$ref) {
|
|
128
|
+
const prefix = "#/$defs/";
|
|
129
|
+
if (!schema.$ref.startsWith(prefix)) {
|
|
130
|
+
issues.push({ path, message: `Unsupported JSON Schema reference "${schema.$ref}".` });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const name = schema.$ref.slice(prefix.length);
|
|
134
|
+
const referenced = root.$defs?.[name];
|
|
135
|
+
if (!referenced) {
|
|
136
|
+
issues.push({ path, message: `JSON Schema reference "${schema.$ref}" was not found.` });
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (refStack.has(schema.$ref)) {
|
|
140
|
+
issues.push({ path, message: `Circular JSON Schema reference "${schema.$ref}" is not supported.` });
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const nextRefs = new Set(refStack);
|
|
144
|
+
nextRefs.add(schema.$ref);
|
|
145
|
+
validateSchema(referenced, value, path, root, issues, nextRefs);
|
|
146
|
+
}
|
|
147
|
+
if (schema.allOf) {
|
|
148
|
+
for (const child of schema.allOf) validateSchema(child, value, path, root, issues, refStack);
|
|
149
|
+
}
|
|
150
|
+
if (schema.anyOf && !schema.anyOf.some((child) => validateWithoutIssues(child, value, root, refStack))) {
|
|
151
|
+
issues.push({ path, message: "Value must satisfy at least one JSON Schema alternative." });
|
|
152
|
+
}
|
|
153
|
+
if (schema.oneOf && schema.oneOf.filter((child) => validateWithoutIssues(child, value, root, refStack)).length !== 1) {
|
|
154
|
+
issues.push({ path, message: "Value must satisfy exactly one JSON Schema alternative." });
|
|
155
|
+
}
|
|
156
|
+
if (schema.not && validateWithoutIssues(schema.not, value, root, refStack)) {
|
|
157
|
+
issues.push({ path, message: "Value must not satisfy the JSON Schema exclusion." });
|
|
158
|
+
}
|
|
159
|
+
if (schema.if) {
|
|
160
|
+
const condition = validateWithoutIssues(schema.if, value, root, refStack);
|
|
161
|
+
if (condition && schema.then) validateSchema(schema.then, value, path, root, issues, refStack);
|
|
162
|
+
if (!condition && schema.else) validateSchema(schema.else, value, path, root, issues, refStack);
|
|
163
|
+
}
|
|
164
|
+
if (schema.const !== void 0 && !jsonValuesEqual(value, schema.const)) {
|
|
165
|
+
issues.push({ path, message: "Value does not match the JSON Schema const." });
|
|
166
|
+
}
|
|
167
|
+
if (schema.enum && !schema.enum.some((item) => jsonValuesEqual(value, item))) {
|
|
168
|
+
issues.push({ path, message: "Value is not one of the allowed JSON Schema enum values." });
|
|
169
|
+
}
|
|
170
|
+
if (schema.type !== void 0) {
|
|
171
|
+
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
172
|
+
if (!types.some((type) => matchesJsonType(type, value))) {
|
|
173
|
+
issues.push({ path, message: `Value must have JSON Schema type ${types.join(" or ")}.` });
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (typeof value === "string") {
|
|
178
|
+
if (schema.minLength !== void 0 && [...value].length < schema.minLength) issues.push({ path, message: `String must contain at least ${schema.minLength} characters.` });
|
|
179
|
+
if (schema.maxLength !== void 0 && [...value].length > schema.maxLength) issues.push({ path, message: `String must contain at most ${schema.maxLength} characters.` });
|
|
180
|
+
if (schema.pattern !== void 0) {
|
|
181
|
+
try {
|
|
182
|
+
if (!new RegExp(schema.pattern).test(value)) issues.push({ path, message: "String does not match the JSON Schema pattern." });
|
|
183
|
+
} catch {
|
|
184
|
+
issues.push({ path, message: "JSON Schema pattern is invalid." });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (typeof value === "number") {
|
|
189
|
+
if (schema.minimum !== void 0 && value < schema.minimum) issues.push({ path, message: `Number must be greater than or equal to ${schema.minimum}.` });
|
|
190
|
+
if (schema.maximum !== void 0 && value > schema.maximum) issues.push({ path, message: `Number must be less than or equal to ${schema.maximum}.` });
|
|
191
|
+
if (schema.exclusiveMinimum !== void 0 && value <= schema.exclusiveMinimum) issues.push({ path, message: `Number must be greater than ${schema.exclusiveMinimum}.` });
|
|
192
|
+
if (schema.exclusiveMaximum !== void 0 && value >= schema.exclusiveMaximum) issues.push({ path, message: `Number must be less than ${schema.exclusiveMaximum}.` });
|
|
193
|
+
if (schema.multipleOf !== void 0 && !isMultipleOf(value, schema.multipleOf)) issues.push({ path, message: `Number must be a multiple of ${schema.multipleOf}.` });
|
|
194
|
+
}
|
|
195
|
+
if (Array.isArray(value)) {
|
|
196
|
+
if (schema.minItems !== void 0 && value.length < schema.minItems) issues.push({ path, message: `Array must contain at least ${schema.minItems} items.` });
|
|
197
|
+
if (schema.maxItems !== void 0 && value.length > schema.maxItems) issues.push({ path, message: `Array must contain at most ${schema.maxItems} items.` });
|
|
198
|
+
if (schema.uniqueItems && value.some((item, index) => value.findIndex((other) => jsonValuesEqual(item, other)) !== index)) issues.push({ path, message: "Array items must be unique." });
|
|
199
|
+
if (schema.prefixItems) {
|
|
200
|
+
for (const [index, child] of schema.prefixItems.entries()) {
|
|
201
|
+
if (index < value.length) validateSchema(child, value[index], [...path, index], root, issues, refStack);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (schema.items && !Array.isArray(schema.items)) {
|
|
205
|
+
for (const [index, item] of value.entries()) validateSchema(schema.items, item, [...path, index], root, issues, refStack);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
209
|
+
const object = value;
|
|
210
|
+
for (const required of schema.required ?? []) {
|
|
211
|
+
if (!(required in object)) issues.push({ path: [...path, required], message: "Required property is missing." });
|
|
212
|
+
}
|
|
213
|
+
for (const [name, child] of Object.entries(schema.properties ?? {})) {
|
|
214
|
+
if (name in object) validateSchema(child, object[name], [...path, name], root, issues, refStack);
|
|
215
|
+
}
|
|
216
|
+
for (const [name, child] of Object.entries(schema.patternProperties ?? {})) {
|
|
217
|
+
let matcher;
|
|
218
|
+
try {
|
|
219
|
+
matcher = new RegExp(name);
|
|
220
|
+
} catch {
|
|
221
|
+
issues.push({ path, message: "JSON Schema patternProperties pattern is invalid." });
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
for (const property of Object.keys(object)) {
|
|
225
|
+
if (matcher.test(property)) validateSchema(child, object[property], [...path, property], root, issues, refStack);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (schema.propertyNames) {
|
|
229
|
+
for (const property of Object.keys(object)) validateSchema(schema.propertyNames, property, [...path, property], root, issues, refStack);
|
|
230
|
+
}
|
|
231
|
+
if (schema.additionalProperties === false) {
|
|
232
|
+
const declared = new Set(Object.keys(schema.properties ?? {}));
|
|
233
|
+
for (const property of Object.keys(schema.patternProperties ?? {})) declared.add(property);
|
|
234
|
+
for (const property of Object.keys(object)) {
|
|
235
|
+
const matchesPattern = Object.keys(schema.patternProperties ?? {}).some((pattern) => {
|
|
236
|
+
try {
|
|
237
|
+
return new RegExp(pattern).test(property);
|
|
238
|
+
} catch {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
if (!declared.has(property) && !matchesPattern) issues.push({ path: [...path, property], message: "Additional properties are not permitted." });
|
|
243
|
+
}
|
|
244
|
+
} else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
245
|
+
const declared = new Set(Object.keys(schema.properties ?? {}));
|
|
246
|
+
for (const property of Object.keys(object)) {
|
|
247
|
+
if (!declared.has(property)) validateSchema(schema.additionalProperties, object[property], [...path, property], root, issues, refStack);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
for (const [property, dependencies] of Object.entries(schema.dependentRequired ?? {})) {
|
|
251
|
+
if (property in object) {
|
|
252
|
+
for (const dependency of dependencies) if (!(dependency in object)) issues.push({ path: [...path, dependency], message: `Property is required when "${property}" is present.` });
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function validateWithoutIssues(schema, value, root, refStack) {
|
|
258
|
+
const issues = [];
|
|
259
|
+
validateSchema(schema, value, [], root, issues, refStack);
|
|
260
|
+
return issues.length === 0;
|
|
261
|
+
}
|
|
262
|
+
function matchesJsonType(type, value) {
|
|
263
|
+
switch (type) {
|
|
264
|
+
case "null":
|
|
265
|
+
return value === null;
|
|
266
|
+
case "boolean":
|
|
267
|
+
return typeof value === "boolean";
|
|
268
|
+
case "object":
|
|
269
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
270
|
+
case "array":
|
|
271
|
+
return Array.isArray(value);
|
|
272
|
+
case "number":
|
|
273
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
274
|
+
case "integer":
|
|
275
|
+
return typeof value === "number" && Number.isSafeInteger(value);
|
|
276
|
+
case "string":
|
|
277
|
+
return typeof value === "string";
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function isMultipleOf(value, divisor) {
|
|
281
|
+
if (!Number.isFinite(divisor) || divisor <= 0) return false;
|
|
282
|
+
const quotient = value / divisor;
|
|
283
|
+
return Math.abs(quotient - Math.round(quotient)) < Number.EPSILON * Math.max(1, Math.abs(quotient));
|
|
284
|
+
}
|
|
285
|
+
function jsonValuesEqual(left, right) {
|
|
286
|
+
if (Object.is(left, right)) return true;
|
|
287
|
+
if (typeof left !== typeof right || left === null || right === null) return false;
|
|
288
|
+
if (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((item, index) => jsonValuesEqual(item, right[index]));
|
|
289
|
+
if (typeof left === "object" && typeof right === "object") {
|
|
290
|
+
const leftObject = left;
|
|
291
|
+
const rightObject = right;
|
|
292
|
+
const keys = Object.keys(leftObject);
|
|
293
|
+
return keys.length === Object.keys(rightObject).length && keys.every((key) => key in rightObject && jsonValuesEqual(leftObject[key], rightObject[key]));
|
|
294
|
+
}
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
function isJsonValue(value) {
|
|
298
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
299
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
300
|
+
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
301
|
+
if (value && typeof value === "object") {
|
|
302
|
+
const prototype = Object.getPrototypeOf(value);
|
|
303
|
+
return (prototype === Object.prototype || prototype === null) && Object.values(value).every(isJsonValue);
|
|
304
|
+
}
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
function assertObjectType(type) {
|
|
308
|
+
if (!/^[A-Z][a-zA-Z0-9]*$/.test(type)) {
|
|
309
|
+
throw new Error(
|
|
310
|
+
`Invalid object type: "${type}". Object types must be PascalCase alphanumeric.`
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function createObjectTypeRegistry(initialTypes = []) {
|
|
315
|
+
const objectTypes = /* @__PURE__ */ new Set([...BUILT_IN_OBJECT_TYPES, ...initialTypes]);
|
|
316
|
+
return {
|
|
317
|
+
register(type) {
|
|
318
|
+
assertObjectType(type);
|
|
319
|
+
objectTypes.add(type);
|
|
320
|
+
},
|
|
321
|
+
has: (type) => objectTypes.has(type),
|
|
322
|
+
list: () => Array.from(objectTypes).sort()
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
exports.assertObjectType = assertObjectType;
|
|
327
|
+
exports.assertPortableJsonSchema = assertPortableJsonSchema;
|
|
328
|
+
exports.createObjectTypeRegistry = createObjectTypeRegistry;
|
|
329
|
+
exports.validatePortableJson = validatePortableJson;
|
|
330
|
+
//# sourceMappingURL=chunk-IFW43ELT.cjs.map
|
|
331
|
+
//# sourceMappingURL=chunk-IFW43ELT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../objects/index.ts"],"names":[],"mappings":";;;AAAA,IAAM,qBAAA,GAAwB,OAAO,MAAA,CAAO;AAAA,EAC3C,YAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACD,CAAC,CAAA;AA4DD,IAAM,uBAAA,GAA0B,OAAO,MAAA,CAAO;AAAA,EAC7C,SAAA;AAAA,EAAW,KAAA;AAAA,EAAO,MAAA;AAAA,EAAQ,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,aAAA;AAAA,EAAe,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,OAAA;AAAA,EAC3E,YAAA;AAAA,EAAc,UAAA;AAAA,EAAY,sBAAA;AAAA,EAAwB,OAAA;AAAA,EAAS,aAAA;AAAA,EAAe,eAAA;AAAA,EAAiB,mBAAA;AAAA,EAAqB,mBAAA;AAAA,EAAqB,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,OAAA;AAAA,EACvJ,KAAA;AAAA,EAAO,SAAA;AAAA,EAAW,SAAA;AAAA,EAAW,kBAAA;AAAA,EAAoB,kBAAA;AAAA,EAAoB,WAAA;AAAA,EACrE,WAAA;AAAA,EAAa,SAAA;AAAA,EAAW,QAAA;AAAA,EAAU,UAAA;AAAA,EAAY,UAAA;AAAA,EAAY,aAAA;AAAA,EAAe,SAAA;AAAA,EACzE,UAAA;AA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A,gBAAA,CAAiB,IAAI,CAAA;AACrB,MAAA,WAAA,CAAY,IAAI,IAAI,CAAA;AAAA,IACrB,CAAA;AAAA,IACA,GAAA,EAAK,CAAC,IAAA,KAAS,WAAA,CAAY,IAAI,IAAI,CAAA;AAAA,IACnC,MAAM,MAAM,KAAA,CAAM,IAAA,CAAK,WAAW,EAAE,IAAA;AAAK,GAC1C;AACD","file":"chunk-IFW43ELT.cjs","sourcesContent":["const BUILT_IN_OBJECT_TYPES = Object.freeze([\n\t\"AssetEvent\",\n\t\"ActionInvocation\",\n\t\"PolicyEvaluation\",\n\t\"ApprovalRequest\",\n\t\"ConsentRecord\",\n\t\"AgentRun\",\n]);\n\nexport type FabricObjectType = string;\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };\n\n/**\n * Dependency-free JSON Schema profile accepted in portable module manifests.\n * Unknown extension keywords must use an `x-` prefix. Runtime validators may\n * support more vocabulary, but exported entity contracts stay in this profile.\n */\nexport interface PortableJsonSchema {\n\t$schema?: string;\n\t$id?: string;\n\t$ref?: string;\n\t$defs?: Record<string, PortableJsonSchema>;\n\ttitle?: string;\n\tdescription?: string;\n\ttype?: \"null\" | \"boolean\" | \"object\" | \"array\" | \"number\" | \"integer\" | \"string\" | Array<\"null\" | \"boolean\" | \"object\" | \"array\" | \"number\" | \"integer\" | \"string\">;\n\tenum?: JsonValue[];\n\tconst?: JsonValue;\n\tproperties?: Record<string, PortableJsonSchema>;\n\trequired?: string[];\n\tadditionalProperties?: boolean | PortableJsonSchema;\n\titems?: PortableJsonSchema | PortableJsonSchema[];\n\tprefixItems?: PortableJsonSchema[];\n\tpropertyNames?: PortableJsonSchema;\n\tpatternProperties?: Record<string, PortableJsonSchema>;\n\tdependentRequired?: Record<string, string[]>;\n\tallOf?: PortableJsonSchema[];\n\tanyOf?: PortableJsonSchema[];\n\toneOf?: PortableJsonSchema[];\n\tnot?: PortableJsonSchema;\n\tif?: PortableJsonSchema;\n\tthen?: PortableJsonSchema;\n\telse?: PortableJsonSchema;\n\tminimum?: number;\n\tmaximum?: number;\n\texclusiveMinimum?: number;\n\texclusiveMaximum?: number;\n\tmultipleOf?: number;\n\tminLength?: number;\n\tmaxLength?: number;\n\tpattern?: string;\n\tformat?: string;\n\tminItems?: number;\n\tmaxItems?: number;\n\tuniqueItems?: boolean;\n\tdefault?: JsonValue;\n\treadOnly?: boolean;\n\twriteOnly?: boolean;\n\tdeprecated?: boolean;\n\tcontentEncoding?: string;\n\tcontentMediaType?: string;\n\texamples?: JsonValue[];\n\t$comment?: string;\n\t[key: `x-${string}`]: JsonValue | undefined;\n}\n\nconst supportedSchemaKeywords = Object.freeze([\n\t\"$schema\", \"$id\", \"$ref\", \"$defs\", \"title\", \"description\", \"type\", \"enum\", \"const\",\n\t\"properties\", \"required\", \"additionalProperties\", \"items\", \"prefixItems\", \"propertyNames\", \"patternProperties\", \"dependentRequired\", \"allOf\", \"anyOf\", \"oneOf\",\n\t\"not\", \"minimum\", \"maximum\", \"exclusiveMinimum\", \"exclusiveMaximum\", \"minLength\",\n\t\"maxLength\", \"pattern\", \"format\", \"minItems\", \"maxItems\", \"uniqueItems\", \"default\",\n\t\"readOnly\", \"writeOnly\", \"deprecated\", \"contentEncoding\", \"contentMediaType\", \"multipleOf\", \"if\", \"then\", \"else\", \"examples\", \"$comment\",\n]);\n\nexport function assertPortableJsonSchema(\n\tschema: unknown,\n\tpath = \"schema\",\n): asserts schema is PortableJsonSchema {\n\tif (!schema || typeof schema !== \"object\" || Array.isArray(schema)) {\n\t\tthrow new Error(`${path} must be a JSON Schema object.`);\n\t}\n\tconst value = schema as Record<string, unknown>;\n\tfor (const keyword of Object.keys(value)) {\n\t\tif (!supportedSchemaKeywords.includes(keyword) && !keyword.startsWith(\"x-\")) {\n\t\t\tthrow new Error(`${path} uses unsupported JSON Schema keyword \"${keyword}\".`);\n\t\t}\n\t}\n\tif (value.properties !== undefined) {\n\t\tif (!value.properties || typeof value.properties !== \"object\" || Array.isArray(value.properties)) {\n\t\t\tthrow new Error(`${path}.properties must be an object.`);\n\t\t}\n\t\tfor (const [name, child] of Object.entries(value.properties)) {\n\t\t\tassertPortableJsonSchema(child, `${path}.properties.${name}`);\n\t\t}\n\t}\n\tif (value.$defs !== undefined) {\n\t\tif (!value.$defs || typeof value.$defs !== \"object\" || Array.isArray(value.$defs)) {\n\t\t\tthrow new Error(`${path}.$defs must be an object.`);\n\t\t}\n\t\tfor (const [name, child] of Object.entries(value.$defs)) {\n\t\t\tassertPortableJsonSchema(child, `${path}.$defs.${name}`);\n\t\t}\n\t}\n\tif (value.patternProperties !== undefined) {\n\t\tif (!value.patternProperties || typeof value.patternProperties !== \"object\" || Array.isArray(value.patternProperties)) throw new Error(`${path}.patternProperties must be an object.`);\n\t\tfor (const [name, child] of Object.entries(value.patternProperties)) assertPortableJsonSchema(child, `${path}.patternProperties.${name}`);\n\t}\n\tfor (const keyword of [\"allOf\", \"anyOf\", \"oneOf\"] as const) {\n\t\tif (value[keyword] !== undefined) {\n\t\t\tif (!Array.isArray(value[keyword])) throw new Error(`${path}.${keyword} must be an array.`);\n\t\t\tvalue[keyword].forEach((child, index) => assertPortableJsonSchema(child, `${path}.${keyword}[${index}]`));\n\t\t}\n\t}\n\tif (value.not !== undefined) assertPortableJsonSchema(value.not, `${path}.not`);\n\tfor (const keyword of [\"propertyNames\", \"if\", \"then\", \"else\"] as const) if (value[keyword] !== undefined) assertPortableJsonSchema(value[keyword], `${path}.${keyword}`);\n\tif (value.additionalProperties !== undefined && typeof value.additionalProperties !== \"boolean\") {\n\t\tassertPortableJsonSchema(value.additionalProperties, `${path}.additionalProperties`);\n\t}\n\tif (value.items !== undefined) {\n\t\tif (Array.isArray(value.items)) {\n\t\t\tvalue.items.forEach((child, index) => assertPortableJsonSchema(child, `${path}.items[${index}]`));\n\t\t} else {\n\t\t\tassertPortableJsonSchema(value.items, `${path}.items`);\n\t\t}\n\t}\n\tif (value.prefixItems !== undefined) {\n\t\tif (!Array.isArray(value.prefixItems)) throw new Error(`${path}.prefixItems must be an array.`);\n\t\tvalue.prefixItems.forEach((child, index) => assertPortableJsonSchema(child, `${path}.prefixItems[${index}]`));\n\t}\n\tif (value.dependentRequired !== undefined) {\n\t\tif (!value.dependentRequired || typeof value.dependentRequired !== \"object\" || Array.isArray(value.dependentRequired) || Object.values(value.dependentRequired).some((items) => !Array.isArray(items) || items.some((item) => typeof item !== \"string\"))) throw new Error(`${path}.dependentRequired must map property names to arrays of property names.`);\n\t}\n\tif (value.required !== undefined && (!Array.isArray(value.required) || value.required.some((item) => typeof item !== \"string\"))) {\n\t\tthrow new Error(`${path}.required must be an array of property names.`);\n\t}\n}\n\nexport interface JsonSchemaValidationIssue {\n\tpath: Array<string | number>;\n\tmessage: string;\n}\n\n/**\n * Validate JSON data against the dependency-free JSON Schema profile used by\n * portable contracts. This intentionally returns issues instead of throwing so\n * hosts can expose a stable, typed validation failure without leaking values.\n */\nexport function validatePortableJson(\n\tschema: PortableJsonSchema,\n\tvalue: unknown,\n): JsonSchemaValidationIssue[] {\n\tconst issues: JsonSchemaValidationIssue[] = [];\n\tvalidateSchema(schema, value, [], schema, issues, new Set());\n\treturn issues;\n}\n\nfunction validateSchema(\n\tschema: PortableJsonSchema,\n\tvalue: unknown,\n\tpath: Array<string | number>,\n\troot: PortableJsonSchema,\n\tissues: JsonSchemaValidationIssue[],\n\trefStack: Set<string>,\n): void {\n\tif (!isJsonValue(value)) {\n\t\tissues.push({ path, message: \"Value must contain JSON-serializable data.\" });\n\t\treturn;\n\t}\n\tif (schema.$ref) {\n\t\tconst prefix = \"#/$defs/\";\n\t\tif (!schema.$ref.startsWith(prefix)) {\n\t\t\tissues.push({ path, message: `Unsupported JSON Schema reference \"${schema.$ref}\".` });\n\t\t\treturn;\n\t\t}\n\t\tconst name = schema.$ref.slice(prefix.length);\n\t\tconst referenced = root.$defs?.[name];\n\t\tif (!referenced) {\n\t\t\tissues.push({ path, message: `JSON Schema reference \"${schema.$ref}\" was not found.` });\n\t\t\treturn;\n\t\t}\n\t\tif (refStack.has(schema.$ref)) {\n\t\t\tissues.push({ path, message: `Circular JSON Schema reference \"${schema.$ref}\" is not supported.` });\n\t\t\treturn;\n\t\t}\n\t\tconst nextRefs = new Set(refStack);\n\t\tnextRefs.add(schema.$ref);\n\t\tvalidateSchema(referenced, value, path, root, issues, nextRefs);\n\t}\n\n\tif (schema.allOf) {\n\t\tfor (const child of schema.allOf) validateSchema(child, value, path, root, issues, refStack);\n\t}\n\tif (schema.anyOf && !schema.anyOf.some((child) => validateWithoutIssues(child, value, root, refStack))) {\n\t\tissues.push({ path, message: \"Value must satisfy at least one JSON Schema alternative.\" });\n\t}\n\tif (schema.oneOf && schema.oneOf.filter((child) => validateWithoutIssues(child, value, root, refStack)).length !== 1) {\n\t\tissues.push({ path, message: \"Value must satisfy exactly one JSON Schema alternative.\" });\n\t}\n\tif (schema.not && validateWithoutIssues(schema.not, value, root, refStack)) {\n\t\tissues.push({ path, message: \"Value must not satisfy the JSON Schema exclusion.\" });\n\t}\n\n\tif (schema.if) {\n\t\tconst condition = validateWithoutIssues(schema.if, value, root, refStack);\n\t\tif (condition && schema.then) validateSchema(schema.then, value, path, root, issues, refStack);\n\t\tif (!condition && schema.else) validateSchema(schema.else, value, path, root, issues, refStack);\n\t}\n\n\tif (schema.const !== undefined && !jsonValuesEqual(value, schema.const)) {\n\t\tissues.push({ path, message: \"Value does not match the JSON Schema const.\" });\n\t}\n\tif (schema.enum && !schema.enum.some((item) => jsonValuesEqual(value, item))) {\n\t\tissues.push({ path, message: \"Value is not one of the allowed JSON Schema enum values.\" });\n\t}\n\n\tif (schema.type !== undefined) {\n\t\tconst types = Array.isArray(schema.type) ? schema.type : [schema.type];\n\t\tif (!types.some((type) => matchesJsonType(type, value))) {\n\t\t\tissues.push({ path, message: `Value must have JSON Schema type ${types.join(\" or \")}.` });\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (typeof value === \"string\") {\n\t\tif (schema.minLength !== undefined && [...value].length < schema.minLength) issues.push({ path, message: `String must contain at least ${schema.minLength} characters.` });\n\t\tif (schema.maxLength !== undefined && [...value].length > schema.maxLength) issues.push({ path, message: `String must contain at most ${schema.maxLength} characters.` });\n\t\tif (schema.pattern !== undefined) {\n\t\t\ttry {\n\t\t\t\tif (!new RegExp(schema.pattern).test(value)) issues.push({ path, message: \"String does not match the JSON Schema pattern.\" });\n\t\t\t} catch {\n\t\t\t\tissues.push({ path, message: \"JSON Schema pattern is invalid.\" });\n\t\t\t}\n\t\t}\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tif (schema.minimum !== undefined && value < schema.minimum) issues.push({ path, message: `Number must be greater than or equal to ${schema.minimum}.` });\n\t\tif (schema.maximum !== undefined && value > schema.maximum) issues.push({ path, message: `Number must be less than or equal to ${schema.maximum}.` });\n\t\tif (schema.exclusiveMinimum !== undefined && value <= schema.exclusiveMinimum) issues.push({ path, message: `Number must be greater than ${schema.exclusiveMinimum}.` });\n\t\tif (schema.exclusiveMaximum !== undefined && value >= schema.exclusiveMaximum) issues.push({ path, message: `Number must be less than ${schema.exclusiveMaximum}.` });\n\t\tif (schema.multipleOf !== undefined && !isMultipleOf(value, schema.multipleOf)) issues.push({ path, message: `Number must be a multiple of ${schema.multipleOf}.` });\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tif (schema.minItems !== undefined && value.length < schema.minItems) issues.push({ path, message: `Array must contain at least ${schema.minItems} items.` });\n\t\tif (schema.maxItems !== undefined && value.length > schema.maxItems) issues.push({ path, message: `Array must contain at most ${schema.maxItems} items.` });\n\t\tif (schema.uniqueItems && value.some((item, index) => value.findIndex((other) => jsonValuesEqual(item, other)) !== index)) issues.push({ path, message: \"Array items must be unique.\" });\n\t\tif (schema.prefixItems) {\n\t\t\tfor (const [index, child] of schema.prefixItems.entries()) {\n\t\t\t\tif (index < value.length) validateSchema(child, value[index], [...path, index], root, issues, refStack);\n\t\t\t}\n\t\t}\n\t\tif (schema.items && !Array.isArray(schema.items)) {\n\t\t\tfor (const [index, item] of value.entries()) validateSchema(schema.items, item, [...path, index], root, issues, refStack);\n\t\t}\n\t}\n\n\tif (value && typeof value === \"object\" && !Array.isArray(value)) {\n\t\tconst object = value as Record<string, unknown>;\n\t\tfor (const required of schema.required ?? []) {\n\t\t\tif (!(required in object)) issues.push({ path: [...path, required], message: \"Required property is missing.\" });\n\t\t}\n\t\tfor (const [name, child] of Object.entries(schema.properties ?? {})) {\n\t\t\tif (name in object) validateSchema(child, object[name], [...path, name], root, issues, refStack);\n\t\t}\n\t\tfor (const [name, child] of Object.entries(schema.patternProperties ?? {})) {\n\t\t\tlet matcher: RegExp;\n\t\t\ttry {\n\t\t\t\tmatcher = new RegExp(name);\n\t\t\t} catch {\n\t\t\t\tissues.push({ path, message: \"JSON Schema patternProperties pattern is invalid.\" });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (const property of Object.keys(object)) {\n\t\t\t\tif (matcher.test(property)) validateSchema(child, object[property], [...path, property], root, issues, refStack);\n\t\t\t}\n\t\t}\n\t\tif (schema.propertyNames) {\n\t\t\tfor (const property of Object.keys(object)) validateSchema(schema.propertyNames, property, [...path, property], root, issues, refStack);\n\t\t}\n\t\tif (schema.additionalProperties === false) {\n\t\t\tconst declared = new Set(Object.keys(schema.properties ?? {}));\n\t\t\tfor (const property of Object.keys(schema.patternProperties ?? {})) declared.add(property);\n\t\t\tfor (const property of Object.keys(object)) {\n\t\t\t\tconst matchesPattern = Object.keys(schema.patternProperties ?? {}).some((pattern) => {\n\t\t\t\t\ttry { return new RegExp(pattern).test(property); } catch { return false; }\n\t\t\t\t});\n\t\t\t\tif (!declared.has(property) && !matchesPattern) issues.push({ path: [...path, property], message: \"Additional properties are not permitted.\" });\n\t\t\t}\n\t\t} else if (schema.additionalProperties && typeof schema.additionalProperties === \"object\") {\n\t\t\tconst declared = new Set(Object.keys(schema.properties ?? {}));\n\t\t\tfor (const property of Object.keys(object)) {\n\t\t\t\tif (!declared.has(property)) validateSchema(schema.additionalProperties, object[property], [...path, property], root, issues, refStack);\n\t\t\t}\n\t\t}\n\t\tfor (const [property, dependencies] of Object.entries(schema.dependentRequired ?? {})) {\n\t\t\tif (property in object) {\n\t\t\t\tfor (const dependency of dependencies) if (!(dependency in object)) issues.push({ path: [...path, dependency], message: `Property is required when \"${property}\" is present.` });\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction validateWithoutIssues(\n\tschema: PortableJsonSchema,\n\tvalue: unknown,\n\troot: PortableJsonSchema,\n\trefStack: Set<string>,\n): boolean {\n\tconst issues: JsonSchemaValidationIssue[] = [];\n\tvalidateSchema(schema, value, [], root, issues, refStack);\n\treturn issues.length === 0;\n}\n\ntype PortableJsonType = \"null\" | \"boolean\" | \"object\" | \"array\" | \"number\" | \"integer\" | \"string\";\n\nfunction matchesJsonType(type: PortableJsonType, value: unknown): boolean {\n\tswitch (type) {\n\t\tcase \"null\": return value === null;\n\t\tcase \"boolean\": return typeof value === \"boolean\";\n\t\tcase \"object\": return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n\t\tcase \"array\": return Array.isArray(value);\n\t\tcase \"number\": return typeof value === \"number\" && Number.isFinite(value);\n\t\tcase \"integer\": return typeof value === \"number\" && Number.isSafeInteger(value);\n\t\tcase \"string\": return typeof value === \"string\";\n\t}\n}\n\nfunction isMultipleOf(value: number, divisor: number): boolean {\n\tif (!Number.isFinite(divisor) || divisor <= 0) return false;\n\tconst quotient = value / divisor;\n\treturn Math.abs(quotient - Math.round(quotient)) < Number.EPSILON * Math.max(1, Math.abs(quotient));\n}\n\nfunction jsonValuesEqual(left: unknown, right: unknown): boolean {\n\tif (Object.is(left, right)) return true;\n\tif (typeof left !== typeof right || left === null || right === null) return false;\n\tif (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((item, index) => jsonValuesEqual(item, right[index]));\n\tif (typeof left === \"object\" && typeof right === \"object\") {\n\t\tconst leftObject = left as Record<string, unknown>;\n\t\tconst rightObject = right as Record<string, unknown>;\n\t\tconst keys = Object.keys(leftObject);\n\t\treturn keys.length === Object.keys(rightObject).length && keys.every((key) => key in rightObject && jsonValuesEqual(leftObject[key], rightObject[key]));\n\t}\n\treturn false;\n}\n\nfunction isJsonValue(value: unknown): value is JsonValue {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every(isJsonValue);\n\tif (value && typeof value === \"object\") {\n\t\tconst prototype = Object.getPrototypeOf(value);\n\t\treturn (prototype === Object.prototype || prototype === null) &&\n\t\t\tObject.values(value as Record<string, unknown>).every(isJsonValue);\n\t}\n\treturn false;\n}\n\nexport function assertObjectType(type: string): asserts type is FabricObjectType {\n\tif (!/^[A-Z][a-zA-Z0-9]*$/.test(type)) {\n\t\tthrow new Error(\n\t\t\t`Invalid object type: \"${type}\". Object types must be PascalCase alphanumeric.`,\n\t\t);\n\t}\n}\n\nexport interface ObjectTypeRegistry {\n\tregister(type: string): void;\n\thas(type: string): boolean;\n\tlist(): string[];\n}\n\nexport function createObjectTypeRegistry(initialTypes: readonly string[] = []): ObjectTypeRegistry {\n\tconst objectTypes = new Set([...BUILT_IN_OBJECT_TYPES, ...initialTypes]);\n\treturn {\n\t\tregister(type) {\n\t\t\tassertObjectType(type);\n\t\t\tobjectTypes.add(type);\n\t\t},\n\t\thas: (type) => objectTypes.has(type),\n\t\tlist: () => Array.from(objectTypes).sort(),\n\t};\n}\n"]}
|
|
@@ -178,19 +178,20 @@ function recordMissingSequenceWarnings(events, warnings, initialSequences) {
|
|
|
178
178
|
for (const event of events) {
|
|
179
179
|
const subjectKey = subjectSequenceKey(event.subjectType, event.subjectId);
|
|
180
180
|
const previousSequence = lastSequenceBySubject.get(subjectKey);
|
|
181
|
-
const
|
|
182
|
-
|
|
181
|
+
const sequence = event.subjectSequence ?? event.sequence;
|
|
182
|
+
const expectedSequence = previousSequence === void 0 ? sequence : previousSequence + 1;
|
|
183
|
+
if (event.subjectSequence !== void 0 && previousSequence !== void 0 && sequence > expectedSequence) {
|
|
183
184
|
warnings.push({
|
|
184
185
|
code: "missing_sequence",
|
|
185
|
-
message: `Missing event sequence for ${subjectKey}: expected ${expectedSequence}, received ${
|
|
186
|
+
message: `Missing event sequence for ${subjectKey}: expected ${expectedSequence}, received ${sequence}.`,
|
|
186
187
|
eventId: event.id,
|
|
187
188
|
subjectType: event.subjectType,
|
|
188
189
|
subjectId: event.subjectId,
|
|
189
190
|
expectedSequence,
|
|
190
|
-
actualSequence:
|
|
191
|
+
actualSequence: sequence
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
|
-
lastSequenceBySubject.set(subjectKey, Math.max(previousSequence ??
|
|
194
|
+
lastSequenceBySubject.set(subjectKey, Math.max(previousSequence ?? sequence, sequence));
|
|
194
195
|
}
|
|
195
196
|
return lastSequenceBySubject;
|
|
196
197
|
}
|
|
@@ -209,7 +210,7 @@ function applyCursor(events, snapshot, subjectScoped, warnings, initialSubjectSe
|
|
|
209
210
|
}
|
|
210
211
|
if (initialSubjectSequences?.size) {
|
|
211
212
|
return events.filter(
|
|
212
|
-
(event) => event.sequence > (initialSubjectSequences.get(subjectSequenceKey(event.subjectType, event.subjectId)) ?? -1)
|
|
213
|
+
(event) => (event.subjectSequence ?? event.sequence) > (initialSubjectSequences.get(subjectSequenceKey(event.subjectType, event.subjectId)) ?? -1)
|
|
213
214
|
);
|
|
214
215
|
}
|
|
215
216
|
if (subjectScoped && snapshot?.eventSequence !== void 0 && snapshot.eventSequence !== null) {
|
|
@@ -234,8 +235,8 @@ function sortEvents(events, subjectScoped) {
|
|
|
234
235
|
}
|
|
235
236
|
function compareSubjectEvents(first, second) {
|
|
236
237
|
return compareValues(
|
|
237
|
-
[first.sequence, toTimestamp(first.recordedAt), toTimestamp(first.occurredAt), first.id],
|
|
238
|
-
[second.sequence, toTimestamp(second.recordedAt), toTimestamp(second.occurredAt), second.id]
|
|
238
|
+
[first.subjectSequence ?? first.sequence, toTimestamp(first.recordedAt), toTimestamp(first.occurredAt), first.id],
|
|
239
|
+
[second.subjectSequence ?? second.sequence, toTimestamp(second.recordedAt), toTimestamp(second.occurredAt), second.id]
|
|
239
240
|
);
|
|
240
241
|
}
|
|
241
242
|
function compareGlobalEvents(first, second) {
|
|
@@ -282,5 +283,5 @@ function toTimestamp(value) {
|
|
|
282
283
|
}
|
|
283
284
|
|
|
284
285
|
export { createViewRegistry, replayEvents, replayView, viewContractKey };
|
|
285
|
-
//# sourceMappingURL=chunk-
|
|
286
|
-
//# sourceMappingURL=chunk-
|
|
286
|
+
//# sourceMappingURL=chunk-JG35DT2G.js.map
|
|
287
|
+
//# sourceMappingURL=chunk-JG35DT2G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../projections/index.ts"],"names":[],"mappings":";AA0DO,SAAS,gBAAgB,IAAA,EAAsD;AACrF,EAAA,OAAO,CAAA,EAAG,IAAA,CAAK,IAAI,CAAA,CAAA,EAAI,KAAK,OAAO,CAAA,CAAA;AACpC;AASO,SAAS,kBAAA,CAAmB,KAAA,GAAiC,EAAC,EAAiB;AACrF,EAAA,MAAM,UAAA,uBAAiB,GAAA,EAA0B;AACjD,EAAA,MAAM,QAAA,GAAW,CAAC,IAAA,KAA6B;AAC9C,IAAA,MAAM,GAAA,GAAM,gBAAgB,IAAI,CAAA;AAChC,IAAA,IAAI,UAAA,CAAW,IAAI,GAAG,CAAA,QAAS,IAAI,KAAA,CAAM,CAAA,eAAA,EAAkB,GAAG,CAAA,wBAAA,CAA0B,CAAA;AACxF,IAAA,UAAA,CAAW,GAAA,CAAI,KAAK,IAAI,CAAA;AAAA,EACzB,CAAA;AACA,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,EAAO,QAAA,CAAS,IAAI,CAAA;AACvC,EAAA,OAAO;AAAA,IACN,QAAA;AAAA,IACA,kBAAkB,IAAA,EAAM;AACvB,MAAA,IAAI,CAAC,WAAW,GAAA,CAAI,eA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qC,YAAA,EAA8C;AACzG,EAAA,KAAA,MAAW,CAAC,KAAA,EAAO,UAAU,CAAA,IAAK,WAAA,CAAY,SAAQ,EAAG;AACxD,IAAA,MAAM,WAAA,GAAc,aAAa,KAAK,CAAA;AAEtC,IAAA,IAAI,aAAa,WAAA,EAAa;AAC7B,MAAA,OAAO,EAAA;AAAA,IACR;AAEA,IAAA,IAAI,aAAa,WAAA,EAAa;AAC7B,MAAA,OAAO,CAAA;AAAA,IACR;AAAA,EACD;AAEA,EAAA,OAAO,CAAA;AACR;AAEA,SAAS,gBAAgB,KAAA,EAA6B;AACrD,EAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,WAAA,IAAe,KAAA,CAAM,SAAS,CAAA;AACpD;AAEA,SAAS,YAAY,KAAA,EAA8B;AAClD,EAAA,OAAO,KAAA,YAAiB,OAAO,KAAA,CAAM,OAAA,KAAY,IAAI,IAAA,CAAK,KAAK,CAAA,CAAE,OAAA,EAAQ;AAC1E","file":"chunk-JG35DT2G.js","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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEventTypeName, getObjectTypeName, getModuleDependencyNamespace } from './chunk-
|
|
1
|
+
import { getEventTypeName, getObjectTypeName, getModuleDependencyNamespace } from './chunk-63MYMAEX.js';
|
|
2
2
|
|
|
3
3
|
// manifest/index.ts
|
|
4
4
|
var MODULE_MANIFEST_VERSION = 2;
|
|
@@ -189,6 +189,7 @@ function exportView(view) {
|
|
|
189
189
|
scope: view.scope,
|
|
190
190
|
snapshotVersion: view.snapshotVersion
|
|
191
191
|
};
|
|
192
|
+
if (view.parameterSchema !== void 0) output.parameterSchema = cloneJson(view.parameterSchema);
|
|
192
193
|
if (view.compatibleSnapshotVersions) output.compatibleSnapshotVersions = [...view.compatibleSnapshotVersions];
|
|
193
194
|
if (view.usage) output.usage = cloneJson(view.usage);
|
|
194
195
|
return output;
|
|
@@ -224,5 +225,5 @@ function exportModuleManifestBundle(modules) {
|
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator, normalizeModuleManifest, normalizeModuleManifestBundle };
|
|
227
|
-
//# sourceMappingURL=chunk-
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
228
|
+
//# sourceMappingURL=chunk-LZNXUTJQ.js.map
|
|
229
|
+
//# sourceMappingURL=chunk-LZNXUTJQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../manifest/index.ts"],"names":[],"mappings":";;;AA8BO,IAAM,uBAAA,GAA0B;AAkKhC,SAAS,wBACf,QAAA,EACiB;AACjB,EAAA,MAAM,UAAkB,QAAA,CAAS,eAAA;AACjC,EAAA,IAAI,OAAA,KAAY,CAAA,IAAK,OAAA,KAAY,uBAAA,EAAyB;AACzD,IAAA,MAAM,IAAI,K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\n\tSchemaValidator,\n} from \"../actions\";\nimport {\n\tgetEventTypeName,\n\tgetModuleDependencyNamespace,\n\tgetObjectTypeName,\n\ttype FabricModule,\n\ttype CapabilityMetadata,\n\ttype DeclarativeInvariant,\n\ttype ModuleDependency,\n\ttype ModuleDependencyInput,\n\ttype ObjectRelationDefinition,\n} from \"../modules\";\nimport type { JsonValue, PortableJsonSchema } from \"../objects\";\nimport type {\n\tDataPolicyDefinition,\n\tPolicyFallbackDefinition,\n\tPolicyKind,\n} from \"../policies\";\nimport type { StateDefinition, StateMachineDefinition } from \"../state-machines\";\nimport type { ViewContract } from \"../projections\";\n\n/**\n * Version of the module manifest contract. Bump when the serialized shape\n * changes in a way consumers must detect.\n */\nexport const MODULE_MANIFEST_VERSION = 2 as const;\n\nexport interface ModuleManifestObjectType {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n\tschema?: PortableJsonSchema;\n\tsemantics?: Record<string, JsonValue>;\n\trelations?: ObjectRelationDefinition[];\n\tinvariants?: DeclarativeInvariant[];\n}\n\nexport interface ModuleManifestIdPrefix {\n\tprefix: string;\n\tname: string;\n}\n\nexport interface ModuleManifestEventType {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n\tschema?: PortableJsonSchema;\n}\n\nexport interface ModuleManifestActionStateMachine {\n\tentityType: string;\n\t/** Present only when the binding declares a static target state. */\n\ttargetState?: string;\n}\n\nexport interface ModuleManifestAdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n}\n\nexport interface ModuleManifestAction {\n\tactionId: string;\n\tversion: number;\n\tkind: \"atomic\" | \"saga\";\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\temitsEvents: string[];\n\tpolicies?: string[];\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\teventPhase?: \"before_adapters\" | \"after_adapters\";\n\texecution?: ActionExecutionContract;\n\t/**\n\t * JSON Schema for the action parameters, present only when the action's\n\t * `schema` validator implements {@link JsonSchemaExportableValidator}.\n\t */\n\tparameterSchema?: unknown;\n\tparameterSchemaFormat?: \"json-schema\";\n\tresultSchema?: unknown;\n\tresultSchemaFormat?: \"json-schema\";\n\tstateMachine?: ModuleManifestActionStateMachine;\n\tadapterSteps?: ModuleManifestAdapterStep[];\n}\n\nexport interface ModuleManifestCodePolicy {\n\ttype: \"code\";\n\tpolicyId: string;\n\tversion: number;\n\tpreviewSafe?: boolean;\n}\n\nexport interface ModuleManifestDataPolicy {\n\ttype: \"data\";\n\tpolicyId: string;\n\tpolicyVersion: number;\n\tkind: PolicyKind;\n\tdataDefinition?: DataPolicyDefinition;\n\tcodeEvaluatorPolicyId?: string;\n\tfallback?: PolicyFallbackDefinition;\n}\n\nexport type ModuleManifestPolicy = ModuleManifestCodePolicy | ModuleManifestDataPolicy;\n\nexport interface ModuleManifestStateMachineTransition {\n\tfrom: string;\n\tto: string;\n\tcausedByAction: string;\n\t/** `true` when the transition declares a guard function. The guard itself is never serialized. */\n\thasGuard: boolean;\n}\n\nexport interface ModuleManifestStateMachine {\n\tentityType: string;\n\t/** States in declaration order (`Object.values` order of the definition record). */\n\tstates: StateDefinition[];\n\ttransitions: ModuleManifestStateMachineTransition[];\n}\n\nexport interface ModuleManifestView {\n\tname: string;\n\tversion: string;\n\tshape: PortableJsonSchema;\n\tparameterSchema?: PortableJsonSchema;\n\tconsumes: Array<{ eventType: string; schemaVersions: number[] }>;\n\tscope: \"tenant-space\";\n\tsnapshotVersion: number;\n\tcompatibleSnapshotVersions?: number[];\n\tusage?: ViewContract[\"usage\"];\n}\n\n/**\n * Stable, JSON-serializable description of a {@link FabricModule}'s ontology:\n * object types, subject types, id prefixes, event types, actions, policies,\n * and state machines. Intended for downstream tooling (semantics exporters,\n * docs generators, tool generators) that cannot consume live module code.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields (`handler`, `evaluate`, `guard`,\n * dynamic `targetState`, adapter `getInput`) are never serialized.\n */\nexport interface ModuleManifest {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tcapability?: CapabilityMetadata;\n\tdependencies: ModuleDependency[];\n\tobjectTypes: ModuleManifestObjectType[];\n\tsubjectTypes: string[];\n\tidPrefixes: ModuleManifestIdPrefix[];\n\teventTypes: ModuleManifestEventType[];\n\tactions: ModuleManifestAction[];\n\tpolicies: ModuleManifestPolicy[];\n\tstateMachines: ModuleManifestStateMachine[];\n\tviews: ModuleManifestView[];\n}\n\nexport interface ModuleManifestBundle {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\t/** Manifests in the input module order. */\n\tmodules: ModuleManifest[];\n}\n\n/** Manifest v1 remains accepted by v2 readers; missing v2 fields normalize to absence. */\nexport type ModuleManifestObjectTypeV1 = Omit<\n\tModuleManifestObjectType,\n\t\"schema\" | \"semantics\" | \"relations\" | \"invariants\"\n>;\nexport type ModuleManifestActionV1 = Omit<\n\tModuleManifestAction,\n\t\"resultSchema\" | \"resultSchemaFormat\"\n>;\nexport type ModuleManifestV1 = Omit<\n\tModuleManifest,\n\t\"manifestVersion\" | \"objectTypes\" | \"actions\" | \"views\"\n> & {\n\tmanifestVersion: 1;\n\tobjectTypes: ModuleManifestObjectTypeV1[];\n\tactions: ModuleManifestActionV1[];\n};\nexport type ModuleManifestBundleV1 = Omit<ModuleManifestBundle, \"manifestVersion\" | \"modules\"> & {\n\tmanifestVersion: 1;\n\tmodules: ModuleManifestV1[];\n};\n\nexport function normalizeModuleManifest(\n\tmanifest: ModuleManifest | ModuleManifestV1,\n): ModuleManifest {\n\tconst version: number = manifest.manifestVersion;\n\tif (version !== 1 && version !== MODULE_MANIFEST_VERSION) {\n\t\tthrow new Error(`Unsupported module manifest version: ${String(version)}`);\n\t}\n\treturn {\n\t\t...manifest,\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tviews: \"views\" in manifest && Array.isArray(manifest.views) ? manifest.views : [],\n\t};\n}\n\nexport function normalizeModuleManifestBundle(\n\tbundle: ModuleManifestBundle | ModuleManifestBundleV1,\n): ModuleManifestBundle {\n\tconst version: number = bundle.manifestVersion;\n\tif (version !== 1 && version !== MODULE_MANIFEST_VERSION) {\n\t\tthrow new Error(`Unsupported module manifest bundle version: ${String(version)}`);\n\t}\n\treturn {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tmodules: bundle.modules.map((manifest) => normalizeModuleManifest(manifest)),\n\t};\n}\n\n/**\n * A {@link SchemaValidator} that can also export its parameter schema as JSON\n * Schema (for example a Zod 4 schema via `z.toJSONSchema`). Keeps the platform\n * zero-dependency while letting schema-bearing actions flow into manifests.\n */\nexport interface JsonSchemaExportableValidator extends SchemaValidator {\n\ttoJSONSchema(): Record<string, unknown>;\n}\n\nexport function isJsonSchemaExportableValidator(\n\tschema: SchemaValidator,\n): schema is JsonSchemaExportableValidator {\n\treturn (\n\t\ttypeof (schema as Partial<JsonSchemaExportableValidator>).toJSONSchema === \"function\"\n\t);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction exportDependency(dependency: ModuleDependencyInput): ModuleDependency {\n\tconst namespace = getModuleDependencyNamespace(dependency);\n\tif (typeof dependency === \"string\") {\n\t\treturn { namespace };\n\t}\n\tconst normalized: ModuleDependency = { namespace };\n\tif (dependency.version !== undefined) normalized.version = dependency.version;\n\tif (dependency.optional !== undefined) normalized.optional = dependency.optional;\n\treturn normalized;\n}\n\nfunction exportObjectType(\n\tobjectType: NonNullable<FabricModule[\"objectTypes\"]>[number],\n): ModuleManifestObjectType {\n\tif (typeof objectType === \"string\") {\n\t\treturn { type: objectType };\n\t}\n\tconst normalized: ModuleManifestObjectType = { type: getObjectTypeName(objectType) };\n\tif (objectType.displayName !== undefined) normalized.displayName = objectType.displayName;\n\tif (objectType.idPrefix !== undefined) normalized.idPrefix = objectType.idPrefix;\n\tif (objectType.schema !== undefined) normalized.schema = cloneJson(objectType.schema);\n\tif (objectType.semantics !== undefined) normalized.semantics = cloneJson(objectType.semantics);\n\tif (objectType.relations !== undefined) {\n\t\tnormalized.relations = objectType.relations.map((relation) => ({ ...relation }));\n\t}\n\tif (objectType.invariants !== undefined) {\n\t\tnormalized.invariants = objectType.invariants.map((invariant) => ({ ...invariant }));\n\t}\n\treturn normalized;\n}\n\nfunction cloneJson<T>(value: T): T {\n\tif (Array.isArray(value)) return value.map((item) => cloneJson(item)) as T;\n\tif (value !== null && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>).map(([key, child]) => [key, cloneJson(child)]),\n\t\t) as T;\n\t}\n\treturn value;\n}\n\nfunction exportEventType(\n\teventType: NonNullable<FabricModule[\"eventTypes\"]>[number],\n): ModuleManifestEventType {\n\tif (typeof eventType === \"string\") {\n\t\t// String registrations carry no explicit schema version; the events\n\t\t// registry treats the bare name as the initial version of the type.\n\t\treturn { eventType, schemaVersion: 1 };\n\t}\n\tconst normalized: ModuleManifestEventType = {\n\t\teventType: getEventTypeName(eventType),\n\t\tschemaVersion: eventType.schemaVersion,\n\t};\n\tif (eventType.description !== undefined) normalized.description = eventType.description;\n\tif (eventType.schema !== undefined) normalized.schema = cloneJson(eventType.schema);\n\treturn normalized;\n}\n\nfunction exportAction(action: ActionDefinition): ModuleManifestAction {\n\tconst manifest: ModuleManifestAction = {\n\t\tactionId: action.actionId,\n\t\tversion: action.version,\n\t\tkind: action.kind ?? \"atomic\",\n\t\tidempotent: action.idempotent,\n\t\tmutatesDomain: action.mutatesDomain,\n\t\temitsEvents: [...action.emitsEvents],\n\t};\n\n\tif (action.policies !== undefined) manifest.policies = [...action.policies];\n\tif (action.requiredRoles !== undefined) manifest.requiredRoles = [...action.requiredRoles];\n\tif (action.requiredPermissions !== undefined) {\n\t\tmanifest.requiredPermissions = [...action.requiredPermissions];\n\t}\n\tif (action.eventPhase !== undefined) manifest.eventPhase = action.eventPhase;\n\tif (action.execution !== undefined) manifest.execution = cloneJson(action.execution);\n\n\tif (isJsonSchemaExportableValidator(action.schema)) {\n\t\ttry {\n\t\t\tmanifest.parameterSchema = action.schema.toJSONSchema();\n\t\t\tmanifest.parameterSchemaFormat = \"json-schema\";\n\t\t} catch {\n\t\t\t// Runtime-valid schemas that cannot be represented portably remain executable;\n\t\t\t// build-time consumers see the schema as unavailable rather than crashing export.\n\t\t}\n\t}\n\tif (action.resultSchema && isJsonSchemaExportableValidator(action.resultSchema)) {\n\t\ttry {\n\t\t\tmanifest.resultSchema = action.resultSchema.toJSONSchema();\n\t\t\tmanifest.resultSchemaFormat = \"json-schema\";\n\t\t} catch {\n\t\t\t// See parameter-schema behavior above.\n\t\t}\n\t}\n\n\tif (action.stateMachine !== undefined) {\n\t\tconst binding: ModuleManifestActionStateMachine = {\n\t\t\tentityType: action.stateMachine.entityType,\n\t\t};\n\t\tif (typeof action.stateMachine.targetState === \"string\") {\n\t\t\tbinding.targetState = action.stateMachine.targetState;\n\t\t}\n\t\tmanifest.stateMachine = binding;\n\t}\n\n\tif (action.adapterSteps !== undefined) {\n\t\tmanifest.adapterSteps = action.adapterSteps.map((step) => {\n\t\t\tconst exported: ModuleManifestAdapterStep = {\n\t\t\t\tadapterType: step.adapterType,\n\t\t\t\toperation: step.operation,\n\t\t\t};\n\t\t\tif (step.retryPolicy !== undefined) exported.retryPolicy = { ...step.retryPolicy };\n\t\t\treturn exported;\n\t\t});\n\t}\n\n\treturn manifest;\n}\n\nfunction exportPolicy(policy: unknown): ModuleManifestPolicy | undefined {\n\tif (!isRecord(policy) || typeof policy.policyId !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\t// Code evaluator: identified by its `evaluate` function (never serialized).\n\tif (typeof policy.evaluate === \"function\") {\n\t\tconst exported: ModuleManifestCodePolicy = {\n\t\t\ttype: \"code\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tversion: typeof policy.version === \"number\" ? policy.version : 1,\n\t\t};\n\t\tif (typeof policy.previewSafe === \"boolean\") exported.previewSafe = policy.previewSafe;\n\t\treturn exported;\n\t}\n\n\t// Declarative runtime policy definition: pure data, serialized as-is.\n\tif (typeof policy.kind === \"string\" && typeof policy.policyVersion === \"number\") {\n\t\tconst exported: ModuleManifestDataPolicy = {\n\t\t\ttype: \"data\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tkind: policy.kind as PolicyKind,\n\t\t};\n\t\tif (isRecord(policy.dataDefinition)) {\n\t\t\texported.dataDefinition = policy.dataDefinition as unknown as DataPolicyDefinition;\n\t\t}\n\t\tif (typeof policy.codeEvaluatorPolicyId === \"string\") {\n\t\t\texported.codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId;\n\t\t}\n\t\tif (isRecord(policy.fallback)) {\n\t\t\texported.fallback = policy.fallback as unknown as PolicyFallbackDefinition;\n\t\t}\n\t\treturn exported;\n\t}\n\n\t// Unknown policy shape: omit rather than guess.\n\treturn undefined;\n}\n\nfunction exportStateMachine(machine: unknown): ModuleManifestStateMachine | undefined {\n\tif (\n\t\t!isRecord(machine) ||\n\t\ttypeof machine.entityType !== \"string\" ||\n\t\t!isRecord(machine.states) ||\n\t\t!Array.isArray(machine.transitions)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst definition = machine as unknown as StateMachineDefinition;\n\treturn {\n\t\tentityType: definition.entityType,\n\t\tstates: Object.values(definition.states),\n\t\ttransitions: definition.transitions.map((transition) => ({\n\t\t\tfrom: transition.from,\n\t\t\tto: transition.to,\n\t\t\tcausedByAction: transition.causedByAction,\n\t\t\thasGuard: typeof transition.guard === \"function\",\n\t\t})),\n\t};\n}\n\nfunction exportView(view: ViewContract): ModuleManifestView {\n\tconst output: ModuleManifestView = {\n\t\tname: view.name,\n\t\tversion: view.version,\n\t\tshape: cloneJson(view.shape),\n\t\tconsumes: view.consumes.map((consumption) => ({\n\t\t\teventType: consumption.eventType,\n\t\t\tschemaVersions: [...consumption.schemaVersions],\n\t\t})),\n\t\tscope: view.scope,\n\t\tsnapshotVersion: view.snapshotVersion,\n\t};\n\tif (view.parameterSchema !== undefined) output.parameterSchema = cloneJson(view.parameterSchema);\n\tif (view.compatibleSnapshotVersions) output.compatibleSnapshotVersions = [...view.compatibleSnapshotVersions];\n\tif (view.usage) output.usage = cloneJson(view.usage);\n\treturn output;\n}\n\n/**\n * Export a stable, JSON-serializable manifest of a module's ontology.\n *\n * This is a pure function of the module object: it does not read or mutate the\n * global module/action/policy/state-machine registries, and the module does\n * not need to be registered first. Declaration order is preserved everywhere\n * (nothing is sorted), so the same module object always produces a\n * byte-identical `JSON.stringify` result.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields are elided (`handler`,\n * policy `evaluate`, transition `guard` → `hasGuard`, dynamic `targetState`,\n * adapter `getInput`).\n */\nexport function exportModuleManifest(module: FabricModule<unknown>): ModuleManifest {\n\tconst manifest: ModuleManifest = {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tnamespace: module.namespace,\n\t\tdependencies: (module.dependencies ?? []).map(exportDependency),\n\t\tobjectTypes: (module.objectTypes ?? []).map(exportObjectType),\n\t\tsubjectTypes: [...(module.subjectTypes ?? [])],\n\t\tidPrefixes: (module.idPrefixes ?? []).map((registration) => ({\n\t\t\tprefix: registration.prefix,\n\t\t\tname: registration.name,\n\t\t})),\n\t\teventTypes: (module.eventTypes ?? []).map(exportEventType),\n\t\tactions: (module.actions ?? []).map(exportAction),\n\t\tpolicies: (module.policies ?? [])\n\t\t\t.map(exportPolicy)\n\t\t\t.filter((policy): policy is ModuleManifestPolicy => policy !== undefined),\n\t\tstateMachines: (module.stateMachines ?? [])\n\t\t\t.map(exportStateMachine)\n\t\t\t.filter((machine): machine is ModuleManifestStateMachine => machine !== undefined),\n\t\tviews: (module.views ?? []).map(exportView),\n\t};\n\n\tif (module.version !== undefined) manifest.version = module.version;\n\tif (module.displayName !== undefined) manifest.displayName = module.displayName;\n\tif (module.description !== undefined) manifest.description = module.description;\n\tif (module.capability !== undefined) manifest.capability = cloneJson(module.capability);\n\n\treturn manifest;\n}\n\n/**\n * Export manifests for a set of modules, preserving the input order.\n * Like {@link exportModuleManifest}, this is pure and registry-free.\n */\nexport function exportModuleManifestBundle(\n\tmodules: FabricModule<unknown>[],\n): ModuleManifestBundle {\n\treturn {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tmodules: modules.map(exportModuleManifest),\n\t};\n}\n"]}
|