@fabricorg/compiler 0.2.0 → 0.2.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 +16 -0
- package/README.md +4 -0
- package/dist/index.cjs +97 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +87 -36
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @fabricorg/compiler
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Close final uplift audit gaps: align Host 2.x documentation and migration evidence, surface every
|
|
8
|
+
compiler/generator API to LLM consumers, make memory outbox egress directly usable, sanitize relay
|
|
9
|
+
failures, validate complete archetype state maps, support recursive JSON Schema generation, reject
|
|
10
|
+
cross-platform path traversal, synchronize artifact version stamps, and include package licenses.
|
|
11
|
+
- Classify action audit-event, idempotency, mutation, authorization, policy, capability, dependency,
|
|
12
|
+
subject, and ID-prefix changes instead of reporting them as compatible.
|
|
13
|
+
- Consume Platform as a peer dependency so applications keep a single copy of the public contracts.
|
|
14
|
+
- Fail closed when required invariant references do not resolve, with explicit certification-profile
|
|
15
|
+
evidence for Host-adapter and application-owned enforcement.
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @fabricorg/platform@0.11.1
|
|
18
|
+
|
|
3
19
|
## 0.2.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -4,4 +4,8 @@ Build-time compiler for versioned Fabric module manifests. It normalizes v1/v2 i
|
|
|
4
4
|
stable namespace-ordered IR and SHA-256 manifest digest, runs optional conformance adapters, classifies
|
|
5
5
|
semantic compatibility, and invokes deterministic generator targets.
|
|
6
6
|
|
|
7
|
+
Required invariants fail closed during compilation when their JSON Schema keyword, state machine,
|
|
8
|
+
or policy reference does not resolve. Host-adapter and application-owned evidence is resolved by an
|
|
9
|
+
explicit `CertificationProfile`; declaring application ownership is never treated as proof.
|
|
10
|
+
|
|
7
11
|
It does not load live modules, execute handlers, or run inside `@fabricorg/platform`.
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// index.ts
|
|
@@ -29,8 +39,9 @@ __export(index_exports, {
|
|
|
29
39
|
});
|
|
30
40
|
module.exports = __toCommonJS(index_exports);
|
|
31
41
|
var import_node_crypto = require("crypto");
|
|
42
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
32
43
|
var import_platform = require("@fabricorg/platform");
|
|
33
|
-
var FABRIC_COMPILER_VERSION = "0.1
|
|
44
|
+
var FABRIC_COMPILER_VERSION = "0.2.1";
|
|
34
45
|
var compareCanonicalStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
35
46
|
function stableStringify(value) {
|
|
36
47
|
return JSON.stringify(sortJson(value));
|
|
@@ -52,7 +63,7 @@ function compileManifestBundle(input, options = {}) {
|
|
|
52
63
|
namespaces.add(module2.namespace);
|
|
53
64
|
}
|
|
54
65
|
const modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));
|
|
55
|
-
assertCompilerManifests(modules);
|
|
66
|
+
assertCompilerManifests(modules, options.certificationProfiles ?? []);
|
|
56
67
|
const canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });
|
|
57
68
|
return {
|
|
58
69
|
compilerVersion: FABRIC_COMPILER_VERSION,
|
|
@@ -64,7 +75,9 @@ function compileManifestBundle(input, options = {}) {
|
|
|
64
75
|
)
|
|
65
76
|
};
|
|
66
77
|
}
|
|
67
|
-
function assertCompilerManifests(modules) {
|
|
78
|
+
function assertCompilerManifests(modules, certificationProfiles) {
|
|
79
|
+
const profiles = new Map(certificationProfiles.map((profile) => [profile.id, profile]));
|
|
80
|
+
if (profiles.size !== certificationProfiles.length) throw new Error("Certification profile IDs must be unique.");
|
|
68
81
|
for (const module2 of modules) {
|
|
69
82
|
if (!module2 || !/^[a-z][a-z0-9-]*$/.test(module2.namespace) || !Array.isArray(module2.objectTypes) || !Array.isArray(module2.actions) || !Array.isArray(module2.views)) throw new Error("Compiler input is not a normalized module manifest.");
|
|
70
83
|
}
|
|
@@ -74,10 +87,17 @@ function assertCompilerManifests(modules) {
|
|
|
74
87
|
if (!module2.capability.displayName?.trim() || !module2.capability.description?.trim()) throw new Error(`Module "${module2.namespace}" capability requires displayName and description.`);
|
|
75
88
|
if (!["experimental", "beta", "stable", "deprecated"].includes(module2.capability.stability)) throw new Error(`Module "${module2.namespace}" capability has invalid stability.`);
|
|
76
89
|
}
|
|
90
|
+
const certification = module2.capability?.certification;
|
|
91
|
+
const profile = certification?.required ? profiles.get(certification.profile) : void 0;
|
|
77
92
|
for (const objectType of module2.objectTypes) {
|
|
78
93
|
if (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type "${objectType.type}" in compiler input.`);
|
|
79
94
|
if (objectType.schema) (0, import_platform.assertPortableJsonSchema)(objectType.schema, `${module2.namespace}.${objectType.type}`);
|
|
80
95
|
for (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module2.namespace}.${objectType.type}.${relation.name} targets missing object type "${relation.target}".`);
|
|
96
|
+
for (const invariant of objectType.invariants ?? []) {
|
|
97
|
+
if (invariant.required && !resolvesRequiredInvariant(module2, objectType, invariant, profile)) {
|
|
98
|
+
throw new Error(`Required invariant "${module2.namespace}.${objectType.type}.${invariant.id}" has no resolvable enforcement evidence under certification profile "${certification?.profile ?? "none"}".`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
81
101
|
}
|
|
82
102
|
for (const view of module2.views) {
|
|
83
103
|
if (!view.name.startsWith(`${module2.namespace}/`)) throw new Error(`View "${view.name}" must use module namespace "${module2.namespace}/".`);
|
|
@@ -90,37 +110,72 @@ function assertCompilerManifests(modules) {
|
|
|
90
110
|
}
|
|
91
111
|
}
|
|
92
112
|
}
|
|
113
|
+
function resolvesRequiredInvariant(module2, objectType, invariant, profile) {
|
|
114
|
+
const reference = invariant.enforcementRef?.trim();
|
|
115
|
+
if (!reference) return false;
|
|
116
|
+
if (invariant.enforcement === "json-schema") {
|
|
117
|
+
const requiredMatch = /^#\/required\/([^/]+)$/.exec(reference);
|
|
118
|
+
if (requiredMatch) return Array.isArray(objectType.schema?.required) && objectType.schema.required.includes(decodeJsonPointerToken(requiredMatch[1]));
|
|
119
|
+
const propertyMatch = /^#\/properties\/([^/]+)$/.exec(reference);
|
|
120
|
+
if (propertyMatch) return Boolean(objectType.schema?.properties?.[decodeJsonPointerToken(propertyMatch[1])]);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
if (invariant.enforcement === "state-machine") return module2.stateMachines.some((machine) => machine.entityType === reference);
|
|
124
|
+
if (invariant.enforcement === "policy") return module2.policies.some((policy) => policy.policyId === reference);
|
|
125
|
+
return profile?.resolveInvariant?.({ module: module2, objectType, invariant }) === true;
|
|
126
|
+
}
|
|
127
|
+
function decodeJsonPointerToken(token) {
|
|
128
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
129
|
+
}
|
|
93
130
|
var severityRank = { compatible: 0, potentially_breaking: 1, breaking: 2 };
|
|
94
131
|
function diffModuleManifests(before, after) {
|
|
95
132
|
if (before.namespace !== after.namespace) {
|
|
96
133
|
return report([{ severity: "breaking", path: "namespace", code: "module_renamed", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);
|
|
97
134
|
}
|
|
98
135
|
const changes = [];
|
|
99
|
-
|
|
100
|
-
|
|
136
|
+
if (before.version !== after.version) changes.push({ severity: "potentially_breaking", path: "version", code: "module_version_changed", message: "Module version changed." });
|
|
137
|
+
if (stableStringify(before.capability) !== stableStringify(after.capability)) changes.push({ severity: "potentially_breaking", path: "capability", code: "capability_changed", message: "Capability roles, stability, deprecation, extension slots, or certification metadata changed." });
|
|
138
|
+
diffStringList(before.subjectTypes, after.subjectTypes, "subjectTypes", changes);
|
|
139
|
+
diffNamed(before.idPrefixes, after.idPrefixes, "idPrefixes", "prefix", changes, (oldValue, newValue, path2) => {
|
|
140
|
+
if (stableStringify(oldValue) !== stableStringify(newValue)) changes.push({ severity: "breaking", path: path2, code: "id_prefix_changed", message: "ID prefix ownership changed." });
|
|
141
|
+
});
|
|
142
|
+
if (stableStringify(before.dependencies) !== stableStringify(after.dependencies)) changes.push({ severity: "potentially_breaking", path: "dependencies", code: "module_dependencies_changed", message: "Module dependencies changed." });
|
|
143
|
+
if (stableStringify(before.policies) !== stableStringify(after.policies)) changes.push({ severity: "potentially_breaking", path: "policies", code: "module_policies_changed", message: "Module policy definitions changed." });
|
|
144
|
+
diffNamed(before.objectTypes, after.objectTypes, "objectTypes", "type", changes, (oldValue, newValue, path2) => {
|
|
145
|
+
diffSchema(oldValue.schema, newValue.schema, `${path2}.schema`, changes);
|
|
101
146
|
const oldArchetype = oldValue.semantics?.["fabric.archetype"];
|
|
102
147
|
const newArchetype = newValue.semantics?.["fabric.archetype"];
|
|
103
|
-
if (oldArchetype && !newArchetype) changes.push({ severity: "breaking", path: `${
|
|
104
|
-
else if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: "breaking", path: `${
|
|
105
|
-
diffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${
|
|
148
|
+
if (oldArchetype && !newArchetype) changes.push({ severity: "breaking", path: `${path2}.semantics.fabric.archetype`, code: "archetype_removed", message: "Archetype certification metadata was removed." });
|
|
149
|
+
else if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: "breaking", path: `${path2}.semantics.fabric.archetype`, code: "archetype_mapping_changed", message: "Archetype identity, version, or state mapping changed." });
|
|
150
|
+
diffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path2}.relations`, "name", changes, (oldRelation, newRelation, relationPath) => {
|
|
106
151
|
if (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: "breaking", path: `${relationPath}.cardinality`, code: "relation_cardinality_changed", message: "Relation cardinality changed." });
|
|
107
152
|
if (oldRelation.target !== newRelation.target) changes.push({ severity: "breaking", path: `${relationPath}.target`, code: "relation_target_changed", message: "Relation target changed." });
|
|
108
153
|
if (!oldRelation.required && newRelation.required) changes.push({ severity: "breaking", path: `${relationPath}.required`, code: "relation_became_required", message: "Optional relation became required." });
|
|
109
154
|
if (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: "breaking", path: `${relationPath}.semantics`, code: "relation_ownership_changed", message: "Relation ownership semantics changed." });
|
|
110
155
|
if (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: "breaking", path: `${relationPath}.onTargetDelete`, code: "relation_delete_behavior_changed", message: "Relation deletion behavior changed." });
|
|
111
156
|
});
|
|
112
|
-
diffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${
|
|
157
|
+
diffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path2}.invariants`, "id", changes, (oldInvariant, newInvariant, invariantPath) => {
|
|
113
158
|
if (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: "potentially_breaking", path: invariantPath, code: "invariant_enforcement_changed", message: "Invariant enforcement ownership or reference changed." });
|
|
114
159
|
if (!oldInvariant.required && newInvariant.required) changes.push({ severity: "breaking", path: `${invariantPath}.required`, code: "invariant_became_required", message: "Invariant became required." });
|
|
115
160
|
});
|
|
116
161
|
});
|
|
117
|
-
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue,
|
|
118
|
-
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${
|
|
119
|
-
diffSchema(oldValue.resultSchema, newValue.resultSchema, `${
|
|
162
|
+
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue, path2) => {
|
|
163
|
+
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${path2}.parameterSchema`, changes);
|
|
164
|
+
diffSchema(oldValue.resultSchema, newValue.resultSchema, `${path2}.resultSchema`, changes);
|
|
165
|
+
for (const field of ["version", "kind", "idempotent", "mutatesDomain", "eventPhase"]) {
|
|
166
|
+
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });
|
|
167
|
+
}
|
|
168
|
+
const oldEvents = new Set(oldValue.emitsEvents);
|
|
169
|
+
const newEvents = new Set(newValue.emitsEvents);
|
|
170
|
+
for (const event of oldEvents) if (!newEvents.has(event)) changes.push({ severity: "breaking", path: `${path2}.emitsEvents.${event}`, code: "action_event_removed", message: `Declared action event "${event}" was removed.` });
|
|
171
|
+
for (const event of newEvents) if (!oldEvents.has(event)) changes.push({ severity: "compatible", path: `${path2}.emitsEvents.${event}`, code: "action_event_added", message: `Declared action event "${event}" was added.` });
|
|
172
|
+
for (const field of ["policies", "requiredRoles", "requiredPermissions", "stateMachine", "adapterSteps"]) {
|
|
173
|
+
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "potentially_breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed and requires consumer review.` });
|
|
174
|
+
}
|
|
120
175
|
});
|
|
121
|
-
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue,
|
|
122
|
-
if (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: "breaking", path: `${
|
|
123
|
-
else if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: "potentially_breaking", path: `${
|
|
176
|
+
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue, path2) => {
|
|
177
|
+
if (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: "breaking", path: `${path2}.schemaVersion`, code: "event_version_decreased", message: "Event schema version decreased." });
|
|
178
|
+
else if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: "potentially_breaking", path: `${path2}.schemaVersion`, code: "event_version_changed", message: "Event schema version changed; old consumers require compatibility evidence." });
|
|
124
179
|
});
|
|
125
180
|
const oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));
|
|
126
181
|
const newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));
|
|
@@ -130,54 +185,60 @@ function diffModuleManifests(before, after) {
|
|
|
130
185
|
else diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);
|
|
131
186
|
}
|
|
132
187
|
for (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: "compatible", path: `views.${key}`, code: "view_version_added", message: `View contract "${key}" was added.` });
|
|
133
|
-
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue,
|
|
188
|
+
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue, path2) => {
|
|
134
189
|
const newStates = new Set(newValue.states.map((state) => state.id));
|
|
135
|
-
for (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: "breaking", path: `${
|
|
190
|
+
for (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: "breaking", path: `${path2}.states.${state.id}`, code: "state_removed", message: `State "${state.id}" was removed.` });
|
|
136
191
|
const transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));
|
|
137
|
-
for (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: "breaking", path: `${
|
|
192
|
+
for (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: "breaking", path: `${path2}.transitions.${transition.from}->${transition.to}`, code: "transition_removed", message: "A state transition was removed or remapped." });
|
|
138
193
|
});
|
|
139
194
|
return report(changes);
|
|
140
195
|
}
|
|
141
|
-
function
|
|
196
|
+
function diffStringList(before, after, path2, changes) {
|
|
197
|
+
const oldValues = new Set(before);
|
|
198
|
+
const newValues = new Set(after);
|
|
199
|
+
for (const value of oldValues) if (!newValues.has(value)) changes.push({ severity: "breaking", path: `${path2}.${value}`, code: `${path2}_removed`, message: `Public ${path2} value "${value}" was removed.` });
|
|
200
|
+
for (const value of newValues) if (!oldValues.has(value)) changes.push({ severity: "compatible", path: `${path2}.${value}`, code: `${path2}_added`, message: `Public ${path2} value "${value}" was added.` });
|
|
201
|
+
}
|
|
202
|
+
function diffNamed(before, after, path2, key, changes, compare) {
|
|
142
203
|
const oldMap = new Map(before.map((value) => [String(value[key]), value]));
|
|
143
204
|
const newMap = new Map(after.map((value) => [String(value[key]), value]));
|
|
144
205
|
for (const [name, value] of oldMap) {
|
|
145
206
|
const next = newMap.get(name);
|
|
146
|
-
if (!next) changes.push({ severity: "breaking", path: `${
|
|
147
|
-
else compare(value, next, `${
|
|
207
|
+
if (!next) changes.push({ severity: "breaking", path: `${path2}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} "${name}" was removed.` });
|
|
208
|
+
else compare(value, next, `${path2}.${name}`);
|
|
148
209
|
}
|
|
149
|
-
for (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: "compatible", path: `${
|
|
210
|
+
for (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: "compatible", path: `${path2}.${name}`, code: `${String(key)}_added`, message: `${String(key)} "${name}" was added.` });
|
|
150
211
|
}
|
|
151
|
-
function diffSchema(before, after,
|
|
212
|
+
function diffSchema(before, after, path2, changes) {
|
|
152
213
|
const changeCount = changes.length;
|
|
153
214
|
if (!before && after) {
|
|
154
|
-
changes.push({ severity: "potentially_breaking", path, code: "schema_added", message: "A schema was added to an existing contract." });
|
|
215
|
+
changes.push({ severity: "potentially_breaking", path: path2, code: "schema_added", message: "A schema was added to an existing contract." });
|
|
155
216
|
return;
|
|
156
217
|
}
|
|
157
218
|
if (before && !after) {
|
|
158
|
-
changes.push({ severity: "breaking", path, code: "schema_removed", message: "An existing schema was removed." });
|
|
219
|
+
changes.push({ severity: "breaking", path: path2, code: "schema_removed", message: "An existing schema was removed." });
|
|
159
220
|
return;
|
|
160
221
|
}
|
|
161
222
|
if (!before || !after) return;
|
|
162
223
|
const oldRequired = new Set(before.required ?? []);
|
|
163
|
-
for (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: "breaking", path: `${
|
|
224
|
+
for (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: "breaking", path: `${path2}.required.${required}`, code: "required_property_added", message: `Required property "${required}" was added.` });
|
|
164
225
|
const oldProperties = before.properties ?? {};
|
|
165
226
|
const newProperties = after.properties ?? {};
|
|
166
|
-
for (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: "breaking", path: `${
|
|
167
|
-
for (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? "breaking" : "compatible", path: `${
|
|
227
|
+
for (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: "breaking", path: `${path2}.properties.${property}`, code: "schema_property_removed", message: `Schema property "${property}" was removed.` });
|
|
228
|
+
for (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? "breaking" : "compatible", path: `${path2}.properties.${property}`, code: "schema_property_added", message: `Schema property "${property}" was added.` });
|
|
168
229
|
for (const property of Object.keys(oldProperties)) {
|
|
169
|
-
if (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${
|
|
230
|
+
if (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path2}.properties.${property}`, changes);
|
|
170
231
|
}
|
|
171
|
-
if (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: "breaking", path: `${
|
|
172
|
-
if (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${
|
|
232
|
+
if (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: "breaking", path: `${path2}.additionalProperties`, code: "additional_properties_forbidden", message: "Schema now rejects undeclared properties." });
|
|
233
|
+
if (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path2}.items`, changes);
|
|
173
234
|
for (const keyword of ["minimum", "maximum", "minLength", "maxLength", "pattern"]) {
|
|
174
|
-
if (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: "potentially_breaking", path: `${
|
|
235
|
+
if (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: "potentially_breaking", path: `${path2}.${keyword}`, code: "schema_constraint_changed", message: `Schema constraint "${keyword}" changed.` });
|
|
175
236
|
}
|
|
176
|
-
if (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: "breaking", path: `${
|
|
237
|
+
if (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: "breaking", path: `${path2}.type`, code: "schema_type_changed", message: "Schema type changed." });
|
|
177
238
|
if (before.enum && after.enum && before.enum.some((value) => !after.enum.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {
|
|
178
|
-
changes.push({ severity: "breaking", path: `${
|
|
239
|
+
changes.push({ severity: "breaking", path: `${path2}.enum`, code: "schema_enum_narrowed", message: "Schema enum no longer accepts a previously valid value." });
|
|
179
240
|
}
|
|
180
|
-
if (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: "potentially_breaking", path, code: "schema_changed", message: "Schema changed and requires consumer review." });
|
|
241
|
+
if (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: "potentially_breaking", path: path2, code: "schema_changed", message: "Schema changed and requires consumer review." });
|
|
181
242
|
}
|
|
182
243
|
function report(changes) {
|
|
183
244
|
const highestSeverity = changes.reduce((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, "compatible");
|
|
@@ -187,7 +248,7 @@ async function runGenerator(target, ir) {
|
|
|
187
248
|
const files = await target.generate(ir);
|
|
188
249
|
const paths = /* @__PURE__ */ new Set();
|
|
189
250
|
return [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {
|
|
190
|
-
if (!file.path || file.path.
|
|
251
|
+
if (!file.path || import_node_path.default.isAbsolute(file.path) || import_node_path.default.win32.isAbsolute(file.path) || file.path.includes("\\") || file.path.split("/").includes("..")) throw new Error(`Generator "${target.name}" returned unsafe path "${file.path}".`);
|
|
191
252
|
if (paths.has(file.path)) throw new Error(`Generator "${target.name}" returned duplicate path "${file.path}".`);
|
|
192
253
|
paths.add(file.path);
|
|
193
254
|
return { path: file.path, content: file.content.endsWith("\n") ? file.content : `${file.content}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n\tnormalizeModuleManifestBundle,\n\tassertPortableJsonSchema,\n\ttype ModuleManifest,\n\ttype ModuleManifestBundle,\n\ttype ModuleManifestBundleV1,\n\ttype PortableJsonSchema,\n} from \"@fabricorg/platform\";\n\nexport const FABRIC_COMPILER_VERSION = \"0.1.0\";\nexport const compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface CompilerConformanceAdapter<Finding = unknown> {\n\tid: string;\n\tevaluate(manifest: ModuleManifest): Finding[];\n}\n\nexport interface CompilerConformanceResult<Finding = unknown> {\n\tadapterId: string;\n\tmoduleNamespace: string;\n\tfindings: Finding[];\n}\n\nexport interface FabricCompilerIr {\n\tcompilerVersion: string;\n\tmanifestVersion: number;\n\tmanifestDigest: string;\n\tmodules: ModuleManifest[];\n\tconformance: CompilerConformanceResult[];\n}\n\nexport function stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => compareCanonicalStrings(left, right))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function compileManifestBundle(\n\tinput: ModuleManifestBundle | ModuleManifestBundleV1,\n\toptions: { conformanceAdapters?: CompilerConformanceAdapter[] } = {},\n): FabricCompilerIr {\n\tconst bundle = normalizeModuleManifestBundle(input);\n\tconst namespaces = new Set<string>();\n\tfor (const module of bundle.modules) {\n\t\tif (namespaces.has(module.namespace)) throw new Error(`Duplicate module namespace \"${module.namespace}\" in compiler input.`);\n\t\tnamespaces.add(module.namespace);\n\t}\n\tconst modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));\n\tassertCompilerManifests(modules);\n\tconst canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });\n\treturn {\n\t\tcompilerVersion: FABRIC_COMPILER_VERSION,\n\t\tmanifestVersion: bundle.manifestVersion,\n\t\tmanifestDigest: createHash(\"sha256\").update(canonical).digest(\"hex\"),\n\t\tmodules,\n\t\tconformance: (options.conformanceAdapters ?? []).flatMap((adapter) =>\n\t\t\tmodules.map((module) => ({ adapterId: adapter.id, moduleNamespace: module.namespace, findings: adapter.evaluate(module) })),\n\t\t),\n\t};\n}\n\nfunction assertCompilerManifests(modules: ModuleManifest[]): void {\n\tfor (const module of modules) {\n\t\tif (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error(\"Compiler input is not a normalized module manifest.\");\n\t}\n\tconst targets = new Set(modules.flatMap((module) => module.objectTypes.map((objectType) => `${module.namespace}.${objectType.type}`)));\n\tfor (const module of modules) {\n\t\tif (module.capability) {\n\t\t\tif (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t\tif (![\"experimental\", \"beta\", \"stable\", \"deprecated\"].includes(module.capability.stability)) throw new Error(`Module \"${module.namespace}\" capability has invalid stability.`);\n\t\t}\n\t\tfor (const objectType of module.objectTypes) {\n\t\t\tif (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type \"${objectType.type}\" in compiler input.`);\n\t\t\tif (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);\n\t\t\tfor (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type \"${relation.target}\".`);\n\t\t}\n\t\tfor (const view of module.views) {\n\t\t\tif (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View \"${view.name}\" must use module namespace \"${module.namespace}/\".`);\n\t\t\tassertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);\n\t\t}\n\t\tfor (const action of module.actions) {\n\t\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || ![\"atomic\", \"saga\"].includes(action.kind) || typeof action.idempotent !== \"boolean\" || typeof action.mutatesDomain !== \"boolean\" || !Array.isArray(action.emitsEvents)) throw new Error(`Action \"${action.actionId}\" is not a normalized manifest action.`);\n\t\t\tif (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema as PortableJsonSchema, `Action ${action.actionId} parameters`);\n\t\t\tif (action.resultSchema) assertPortableJsonSchema(action.resultSchema as PortableJsonSchema, `Action ${action.actionId} result`);\n\t\t}\n\t}\n}\n\nexport type CompatibilitySeverity = \"compatible\" | \"potentially_breaking\" | \"breaking\";\nexport interface CompatibilityChange {\n\tseverity: CompatibilitySeverity;\n\tpath: string;\n\tcode: string;\n\tmessage: string;\n}\nexport interface CompatibilityReport {\n\tcompatible: boolean;\n\thighestSeverity: CompatibilitySeverity;\n\tchanges: CompatibilityChange[];\n}\n\nconst severityRank: Record<CompatibilitySeverity, number> = { compatible: 0, potentially_breaking: 1, breaking: 2 };\n\nexport function diffModuleManifests(before: ModuleManifest, after: ModuleManifest): CompatibilityReport {\n\tif (before.namespace !== after.namespace) {\n\t\treturn report([{ severity: \"breaking\", path: \"namespace\", code: \"module_renamed\", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);\n\t}\n\tconst changes: CompatibilityChange[] = [];\n\tdiffNamed(before.objectTypes, after.objectTypes, \"objectTypes\", \"type\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tconst oldArchetype = oldValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tconst newArchetype = newValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tif (oldArchetype && !newArchetype) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_removed\", message: \"Archetype certification metadata was removed.\" });\n\t\telse if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_mapping_changed\", message: \"Archetype identity, version, or state mapping changed.\" });\n\t\tdiffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path}.relations`, \"name\", changes, (oldRelation, newRelation, relationPath) => {\n\t\t\tif (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: \"breaking\", path: `${relationPath}.cardinality`, code: \"relation_cardinality_changed\", message: \"Relation cardinality changed.\" });\n\t\t\tif (oldRelation.target !== newRelation.target) changes.push({ severity: \"breaking\", path: `${relationPath}.target`, code: \"relation_target_changed\", message: \"Relation target changed.\" });\n\t\t\tif (!oldRelation.required && newRelation.required) changes.push({ severity: \"breaking\", path: `${relationPath}.required`, code: \"relation_became_required\", message: \"Optional relation became required.\" });\n\t\t\tif (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: \"breaking\", path: `${relationPath}.semantics`, code: \"relation_ownership_changed\", message: \"Relation ownership semantics changed.\" });\n\t\t\tif (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: \"breaking\", path: `${relationPath}.onTargetDelete`, code: \"relation_delete_behavior_changed\", message: \"Relation deletion behavior changed.\" });\n\t\t});\n\t\tdiffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path}.invariants`, \"id\", changes, (oldInvariant, newInvariant, invariantPath) => {\n\t\t\tif (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: \"potentially_breaking\", path: invariantPath, code: \"invariant_enforcement_changed\", message: \"Invariant enforcement ownership or reference changed.\" });\n\t\t\tif (!oldInvariant.required && newInvariant.required) changes.push({ severity: \"breaking\", path: `${invariantPath}.required`, code: \"invariant_became_required\", message: \"Invariant became required.\" });\n\t\t});\n\t});\n\tdiffNamed(before.actions, after.actions, \"actions\", \"actionId\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.parameterSchema as PortableJsonSchema | undefined, newValue.parameterSchema as PortableJsonSchema | undefined, `${path}.parameterSchema`, changes);\n\t\tdiffSchema(oldValue.resultSchema as PortableJsonSchema | undefined, newValue.resultSchema as PortableJsonSchema | undefined, `${path}.resultSchema`, changes);\n\t});\n\tdiffNamed(before.eventTypes, after.eventTypes, \"eventTypes\", \"eventType\", changes, (oldValue, newValue, path) => {\n\t\tif (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: \"breaking\", path: `${path}.schemaVersion`, code: \"event_version_decreased\", message: \"Event schema version decreased.\" });\n\t\telse if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: \"potentially_breaking\", path: `${path}.schemaVersion`, code: \"event_version_changed\", message: \"Event schema version changed; old consumers require compatibility evidence.\" });\n\t});\n\tconst oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tconst newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tfor (const [key, oldView] of oldViews) {\n\t\tconst newView = newViews.get(key);\n\t\tif (!newView) changes.push({ severity: \"breaking\", path: `views.${key}`, code: \"view_version_removed\", message: `View contract \"${key}\" was removed.` });\n\t\telse diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);\n\t}\n\tfor (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: \"compatible\", path: `views.${key}`, code: \"view_version_added\", message: `View contract \"${key}\" was added.` });\n\tdiffNamed(before.stateMachines, after.stateMachines, \"stateMachines\", \"entityType\", changes, (oldValue, newValue, path) => {\n\t\tconst newStates = new Set(newValue.states.map((state) => state.id));\n\t\tfor (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: \"breaking\", path: `${path}.states.${state.id}`, code: \"state_removed\", message: `State \"${state.id}\" was removed.` });\n\t\tconst transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));\n\t\tfor (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: \"breaking\", path: `${path}.transitions.${transition.from}->${transition.to}`, code: \"transition_removed\", message: \"A state transition was removed or remapped.\" });\n\t});\n\treturn report(changes);\n}\n\nfunction diffNamed<T extends object>(\n\tbefore: T[], after: T[], path: string, key: keyof T, changes: CompatibilityChange[], compare: (before: T, after: T, path: string) => void,\n): void {\n\tconst oldMap = new Map(before.map((value) => [String(value[key]), value]));\n\tconst newMap = new Map(after.map((value) => [String(value[key]), value]));\n\tfor (const [name, value] of oldMap) {\n\t\tconst next = newMap.get(name);\n\t\tif (!next) changes.push({ severity: \"breaking\", path: `${path}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} \"${name}\" was removed.` });\n\t\telse compare(value, next, `${path}.${name}`);\n\t}\n\tfor (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: \"compatible\", path: `${path}.${name}`, code: `${String(key)}_added`, message: `${String(key)} \"${name}\" was added.` });\n}\n\nfunction diffSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst changeCount = changes.length;\n\tif (!before && after) { changes.push({ severity: \"potentially_breaking\", path, code: \"schema_added\", message: \"A schema was added to an existing contract.\" }); return; }\n\tif (before && !after) { changes.push({ severity: \"breaking\", path, code: \"schema_removed\", message: \"An existing schema was removed.\" }); return; }\n\tif (!before || !after) return;\n\tconst oldRequired = new Set(before.required ?? []);\n\tfor (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: \"breaking\", path: `${path}.required.${required}`, code: \"required_property_added\", message: `Required property \"${required}\" was added.` });\n\tconst oldProperties = before.properties ?? {};\n\tconst newProperties = after.properties ?? {};\n\tfor (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: \"breaking\", path: `${path}.properties.${property}`, code: \"schema_property_removed\", message: `Schema property \"${property}\" was removed.` });\n\tfor (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? \"breaking\" : \"compatible\", path: `${path}.properties.${property}`, code: \"schema_property_added\", message: `Schema property \"${property}\" was added.` });\n\tfor (const property of Object.keys(oldProperties)) {\n\t\tif (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path}.properties.${property}`, changes);\n\t}\n\tif (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: \"breaking\", path: `${path}.additionalProperties`, code: \"additional_properties_forbidden\", message: \"Schema now rejects undeclared properties.\" });\n\tif (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path}.items`, changes);\n\tfor (const keyword of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"pattern\"] as const) {\n\t\tif (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${keyword}`, code: \"schema_constraint_changed\", message: `Schema constraint \"${keyword}\" changed.` });\n\t}\n\tif (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: \"breaking\", path: `${path}.type`, code: \"schema_type_changed\", message: \"Schema type changed.\" });\n\tif (before.enum && after.enum && before.enum.some((value) => !after.enum!.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.enum`, code: \"schema_enum_narrowed\", message: \"Schema enum no longer accepts a previously valid value.\" });\n\t}\n\tif (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: \"potentially_breaking\", path, code: \"schema_changed\", message: \"Schema changed and requires consumer review.\" });\n}\n\nfunction report(changes: CompatibilityChange[]): CompatibilityReport {\n\tconst highestSeverity = changes.reduce<CompatibilitySeverity>((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, \"compatible\");\n\treturn { compatible: highestSeverity === \"compatible\", highestSeverity, changes };\n}\n\nexport interface GeneratedFile { path: string; content: string; }\nexport interface GeneratorTarget { name: string; version: string; generate(ir: FabricCompilerIr): GeneratedFile[] | Promise<GeneratedFile[]>; }\n\nexport async function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]> {\n\tconst files = await target.generate(ir);\n\tconst paths = new Set<string>();\n\treturn [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {\n\t\tif (!file.path || file.path.startsWith(\"/\") || file.path.split(\"/\").includes(\"..\")) throw new Error(`Generator \"${target.name}\" returned unsafe path \"${file.path}\".`);\n\t\tif (paths.has(file.path)) throw new Error(`Generator \"${target.name}\" returned duplicate path \"${file.path}\".`);\n\t\tpaths.add(file.path);\n\t\treturn { path: file.path, content: file.content.endsWith(\"\\n\") ? file.content : `${file.content}\\n` };\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,sBAOO;AAEA,IAAM,0BAA0B;AAChC,IAAM,0BAA0B,CAAC,MAAc,UAA0B,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAqBhH,SAAS,gBAAgB,OAAwB;AACvD,SAAO,KAAK,UAAU,SAAS,KAAK,CAAC;AACtC;AAEA,SAAS,SAAS,OAAyB;AAC1C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,QAAQ;AACnD,MAAI,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,OAAO;AAAA,MACb,OAAO,QAAQ,KAAgC,EAC7C,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAM,wBAAwB,MAAM,KAAK,CAAC,EAC9D,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,SAAS,KAAK,CAAC,CAAC;AAAA,IAC/C;AAAA,EACD;AACA,SAAO;AACR;AAEO,SAAS,sBACf,OACA,UAAkE,CAAC,GAChD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SAAS,MAAM,wBAAwB,SAAS,0DAA0D,CAAC;AAAA,EAC9J;AACA,MAAI,gBAAgB,MAAM,MAAM,gBAAgB,KAAK,KAAK,QAAQ,WAAW,YAAa,SAAQ,KAAK,EAAE,UAAU,wBAAwB,MAAM,MAAM,kBAAkB,SAAS,+CAA+C,CAAC;AACnO;AAEA,SAAS,OAAO,SAAqD;AACpE,QAAM,kBAAkB,QAAQ,OAA8B,CAAC,SAAS,WAAW,aAAa,OAAO,QAAQ,IAAI,aAAa,OAAO,IAAI,OAAO,WAAW,SAAS,YAAY;AAClL,SAAO,EAAE,YAAY,oBAAoB,cAAc,iBAAiB,QAAQ;AACjF;AAKA,eAAsB,aAAa,QAAyB,IAAgD;AAC3G,QAAM,QAAQ,MAAM,OAAO,SAAS,EAAE;AACtC,QAAM,QAAQ,oBAAI,IAAY;AAC9B,SAAO,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,UAAU,wBAAwB,KAAK,MAAM,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS;AACrG,QAAI,CAAC,KAAK,QAAQ,KAAK,KAAK,WAAW,GAAG,KAAK,KAAK,KAAK,MAAM,GAAG,EAAE,SAAS,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,2BAA2B,KAAK,IAAI,IAAI;AACrK,QAAI,MAAM,IAAI,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,8BAA8B,KAAK,IAAI,IAAI;AAC9G,UAAM,IAAI,KAAK,IAAI;AACnB,WAAO,EAAE,MAAM,KAAK,MAAM,SAAS,KAAK,QAAQ,SAAS,IAAI,IAAI,KAAK,UAAU,GAAG,KAAK,OAAO;AAAA,EAAK;AAAA,EACrG,CAAC;AACF;","names":["module"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport {\n\tnormalizeModuleManifestBundle,\n\tassertPortableJsonSchema,\n\ttype ModuleManifest,\n\ttype ModuleManifestBundle,\n\ttype ModuleManifestBundleV1,\n\ttype DeclarativeInvariant,\n\ttype PortableJsonSchema,\n} from \"@fabricorg/platform\";\n\nexport const FABRIC_COMPILER_VERSION = \"0.2.1\";\nexport const compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface CompilerConformanceAdapter<Finding = unknown> {\n\tid: string;\n\tevaluate(manifest: ModuleManifest): Finding[];\n}\n\nexport interface CompilerConformanceResult<Finding = unknown> {\n\tadapterId: string;\n\tmoduleNamespace: string;\n\tfindings: Finding[];\n}\n\nexport interface CertificationInvariantContext {\n\tmodule: ModuleManifest;\n\tobjectType: ModuleManifest[\"objectTypes\"][number];\n\tinvariant: DeclarativeInvariant;\n}\n\nexport interface CertificationProfile {\n\tid: string;\n\t/** Resolve evidence owned outside serialized Platform definitions. */\n\tresolveInvariant?(context: CertificationInvariantContext): boolean;\n}\n\nexport interface FabricCompilerIr {\n\tcompilerVersion: string;\n\tmanifestVersion: number;\n\tmanifestDigest: string;\n\tmodules: ModuleManifest[];\n\tconformance: CompilerConformanceResult[];\n}\n\nexport function stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => compareCanonicalStrings(left, right))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function compileManifestBundle(\n\tinput: ModuleManifestBundle | ModuleManifestBundleV1,\n\toptions: { conformanceAdapters?: CompilerConformanceAdapter[]; certificationProfiles?: CertificationProfile[] } = {},\n): FabricCompilerIr {\n\tconst bundle = normalizeModuleManifestBundle(input);\n\tconst namespaces = new Set<string>();\n\tfor (const module of bundle.modules) {\n\t\tif (namespaces.has(module.namespace)) throw new Error(`Duplicate module namespace \"${module.namespace}\" in compiler input.`);\n\t\tnamespaces.add(module.namespace);\n\t}\n\tconst modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));\n\tassertCompilerManifests(modules, options.certificationProfiles ?? []);\n\tconst canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });\n\treturn {\n\t\tcompilerVersion: FABRIC_COMPILER_VERSION,\n\t\tmanifestVersion: bundle.manifestVersion,\n\t\tmanifestDigest: createHash(\"sha256\").update(canonical).digest(\"hex\"),\n\t\tmodules,\n\t\tconformance: (options.conformanceAdapters ?? []).flatMap((adapter) =>\n\t\t\tmodules.map((module) => ({ adapterId: adapter.id, moduleNamespace: module.namespace, findings: adapter.evaluate(module) })),\n\t\t),\n\t};\n}\n\nfunction assertCompilerManifests(modules: ModuleManifest[], certificationProfiles: CertificationProfile[]): void {\n\tconst profiles = new Map(certificationProfiles.map((profile) => [profile.id, profile]));\n\tif (profiles.size !== certificationProfiles.length) throw new Error(\"Certification profile IDs must be unique.\");\n\tfor (const module of modules) {\n\t\tif (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error(\"Compiler input is not a normalized module manifest.\");\n\t}\n\tconst targets = new Set(modules.flatMap((module) => module.objectTypes.map((objectType) => `${module.namespace}.${objectType.type}`)));\n\tfor (const module of modules) {\n\t\tif (module.capability) {\n\t\t\tif (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t\tif (![\"experimental\", \"beta\", \"stable\", \"deprecated\"].includes(module.capability.stability)) throw new Error(`Module \"${module.namespace}\" capability has invalid stability.`);\n\t\t}\n\t\tconst certification = module.capability?.certification;\n\t\tconst profile = certification?.required ? profiles.get(certification.profile) : undefined;\n\t\tfor (const objectType of module.objectTypes) {\n\t\t\tif (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type \"${objectType.type}\" in compiler input.`);\n\t\t\tif (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);\n\t\t\tfor (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type \"${relation.target}\".`);\n\t\t\tfor (const invariant of objectType.invariants ?? []) {\n\t\t\t\tif (invariant.required && !resolvesRequiredInvariant(module, objectType, invariant, profile)) {\n\t\t\t\t\tthrow new Error(`Required invariant \"${module.namespace}.${objectType.type}.${invariant.id}\" has no resolvable enforcement evidence under certification profile \"${certification?.profile ?? \"none\"}\".`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const view of module.views) {\n\t\t\tif (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View \"${view.name}\" must use module namespace \"${module.namespace}/\".`);\n\t\t\tassertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);\n\t\t}\n\t\tfor (const action of module.actions) {\n\t\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || ![\"atomic\", \"saga\"].includes(action.kind) || typeof action.idempotent !== \"boolean\" || typeof action.mutatesDomain !== \"boolean\" || !Array.isArray(action.emitsEvents)) throw new Error(`Action \"${action.actionId}\" is not a normalized manifest action.`);\n\t\t\tif (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema as PortableJsonSchema, `Action ${action.actionId} parameters`);\n\t\t\tif (action.resultSchema) assertPortableJsonSchema(action.resultSchema as PortableJsonSchema, `Action ${action.actionId} result`);\n\t\t}\n\t}\n}\n\nfunction resolvesRequiredInvariant(\n\tmodule: ModuleManifest,\n\tobjectType: ModuleManifest[\"objectTypes\"][number],\n\tinvariant: DeclarativeInvariant,\n\tprofile: CertificationProfile | undefined,\n): boolean {\n\tconst reference = invariant.enforcementRef?.trim();\n\tif (!reference) return false;\n\tif (invariant.enforcement === \"json-schema\") {\n\t\tconst requiredMatch = /^#\\/required\\/([^/]+)$/.exec(reference);\n\t\tif (requiredMatch) return Array.isArray(objectType.schema?.required) && objectType.schema.required.includes(decodeJsonPointerToken(requiredMatch[1]!));\n\t\tconst propertyMatch = /^#\\/properties\\/([^/]+)$/.exec(reference);\n\t\tif (propertyMatch) return Boolean(objectType.schema?.properties?.[decodeJsonPointerToken(propertyMatch[1]!)]);\n\t\treturn false;\n\t}\n\tif (invariant.enforcement === \"state-machine\") return module.stateMachines.some((machine) => machine.entityType === reference);\n\tif (invariant.enforcement === \"policy\") return module.policies.some((policy) => policy.policyId === reference);\n\treturn profile?.resolveInvariant?.({ module, objectType, invariant }) === true;\n}\n\nfunction decodeJsonPointerToken(token: string): string {\n\treturn token.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\nexport type CompatibilitySeverity = \"compatible\" | \"potentially_breaking\" | \"breaking\";\nexport interface CompatibilityChange {\n\tseverity: CompatibilitySeverity;\n\tpath: string;\n\tcode: string;\n\tmessage: string;\n}\nexport interface CompatibilityReport {\n\tcompatible: boolean;\n\thighestSeverity: CompatibilitySeverity;\n\tchanges: CompatibilityChange[];\n}\n\nconst severityRank: Record<CompatibilitySeverity, number> = { compatible: 0, potentially_breaking: 1, breaking: 2 };\n\nexport function diffModuleManifests(before: ModuleManifest, after: ModuleManifest): CompatibilityReport {\n\tif (before.namespace !== after.namespace) {\n\t\treturn report([{ severity: \"breaking\", path: \"namespace\", code: \"module_renamed\", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);\n\t}\n\tconst changes: CompatibilityChange[] = [];\n\tif (before.version !== after.version) changes.push({ severity: \"potentially_breaking\", path: \"version\", code: \"module_version_changed\", message: \"Module version changed.\" });\n\tif (stableStringify(before.capability) !== stableStringify(after.capability)) changes.push({ severity: \"potentially_breaking\", path: \"capability\", code: \"capability_changed\", message: \"Capability roles, stability, deprecation, extension slots, or certification metadata changed.\" });\n\tdiffStringList(before.subjectTypes, after.subjectTypes, \"subjectTypes\", changes);\n\tdiffNamed(before.idPrefixes, after.idPrefixes, \"idPrefixes\", \"prefix\", changes, (oldValue, newValue, path) => {\n\t\tif (stableStringify(oldValue) !== stableStringify(newValue)) changes.push({ severity: \"breaking\", path, code: \"id_prefix_changed\", message: \"ID prefix ownership changed.\" });\n\t});\n\tif (stableStringify(before.dependencies) !== stableStringify(after.dependencies)) changes.push({ severity: \"potentially_breaking\", path: \"dependencies\", code: \"module_dependencies_changed\", message: \"Module dependencies changed.\" });\n\tif (stableStringify(before.policies) !== stableStringify(after.policies)) changes.push({ severity: \"potentially_breaking\", path: \"policies\", code: \"module_policies_changed\", message: \"Module policy definitions changed.\" });\n\tdiffNamed(before.objectTypes, after.objectTypes, \"objectTypes\", \"type\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tconst oldArchetype = oldValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tconst newArchetype = newValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tif (oldArchetype && !newArchetype) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_removed\", message: \"Archetype certification metadata was removed.\" });\n\t\telse if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_mapping_changed\", message: \"Archetype identity, version, or state mapping changed.\" });\n\t\tdiffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path}.relations`, \"name\", changes, (oldRelation, newRelation, relationPath) => {\n\t\t\tif (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: \"breaking\", path: `${relationPath}.cardinality`, code: \"relation_cardinality_changed\", message: \"Relation cardinality changed.\" });\n\t\t\tif (oldRelation.target !== newRelation.target) changes.push({ severity: \"breaking\", path: `${relationPath}.target`, code: \"relation_target_changed\", message: \"Relation target changed.\" });\n\t\t\tif (!oldRelation.required && newRelation.required) changes.push({ severity: \"breaking\", path: `${relationPath}.required`, code: \"relation_became_required\", message: \"Optional relation became required.\" });\n\t\t\tif (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: \"breaking\", path: `${relationPath}.semantics`, code: \"relation_ownership_changed\", message: \"Relation ownership semantics changed.\" });\n\t\t\tif (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: \"breaking\", path: `${relationPath}.onTargetDelete`, code: \"relation_delete_behavior_changed\", message: \"Relation deletion behavior changed.\" });\n\t\t});\n\t\tdiffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path}.invariants`, \"id\", changes, (oldInvariant, newInvariant, invariantPath) => {\n\t\t\tif (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: \"potentially_breaking\", path: invariantPath, code: \"invariant_enforcement_changed\", message: \"Invariant enforcement ownership or reference changed.\" });\n\t\t\tif (!oldInvariant.required && newInvariant.required) changes.push({ severity: \"breaking\", path: `${invariantPath}.required`, code: \"invariant_became_required\", message: \"Invariant became required.\" });\n\t\t});\n\t});\n\tdiffNamed(before.actions, after.actions, \"actions\", \"actionId\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.parameterSchema as PortableJsonSchema | undefined, newValue.parameterSchema as PortableJsonSchema | undefined, `${path}.parameterSchema`, changes);\n\t\tdiffSchema(oldValue.resultSchema as PortableJsonSchema | undefined, newValue.resultSchema as PortableJsonSchema | undefined, `${path}.resultSchema`, changes);\n\t\tfor (const field of [\"version\", \"kind\", \"idempotent\", \"mutatesDomain\", \"eventPhase\"] as const) {\n\t\t\tif (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: \"breaking\", path: `${path}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });\n\t\t}\n\t\tconst oldEvents = new Set(oldValue.emitsEvents);\n\t\tconst newEvents = new Set(newValue.emitsEvents);\n\t\tfor (const event of oldEvents) if (!newEvents.has(event)) changes.push({ severity: \"breaking\", path: `${path}.emitsEvents.${event}`, code: \"action_event_removed\", message: `Declared action event \"${event}\" was removed.` });\n\t\tfor (const event of newEvents) if (!oldEvents.has(event)) changes.push({ severity: \"compatible\", path: `${path}.emitsEvents.${event}`, code: \"action_event_added\", message: `Declared action event \"${event}\" was added.` });\n\t\tfor (const field of [\"policies\", \"requiredRoles\", \"requiredPermissions\", \"stateMachine\", \"adapterSteps\"] as const) {\n\t\t\tif (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed and requires consumer review.` });\n\t\t}\n\t});\n\tdiffNamed(before.eventTypes, after.eventTypes, \"eventTypes\", \"eventType\", changes, (oldValue, newValue, path) => {\n\t\tif (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: \"breaking\", path: `${path}.schemaVersion`, code: \"event_version_decreased\", message: \"Event schema version decreased.\" });\n\t\telse if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: \"potentially_breaking\", path: `${path}.schemaVersion`, code: \"event_version_changed\", message: \"Event schema version changed; old consumers require compatibility evidence.\" });\n\t});\n\tconst oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tconst newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tfor (const [key, oldView] of oldViews) {\n\t\tconst newView = newViews.get(key);\n\t\tif (!newView) changes.push({ severity: \"breaking\", path: `views.${key}`, code: \"view_version_removed\", message: `View contract \"${key}\" was removed.` });\n\t\telse diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);\n\t}\n\tfor (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: \"compatible\", path: `views.${key}`, code: \"view_version_added\", message: `View contract \"${key}\" was added.` });\n\tdiffNamed(before.stateMachines, after.stateMachines, \"stateMachines\", \"entityType\", changes, (oldValue, newValue, path) => {\n\t\tconst newStates = new Set(newValue.states.map((state) => state.id));\n\t\tfor (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: \"breaking\", path: `${path}.states.${state.id}`, code: \"state_removed\", message: `State \"${state.id}\" was removed.` });\n\t\tconst transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));\n\t\tfor (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: \"breaking\", path: `${path}.transitions.${transition.from}->${transition.to}`, code: \"transition_removed\", message: \"A state transition was removed or remapped.\" });\n\t});\n\treturn report(changes);\n}\n\nfunction diffStringList(before: string[], after: string[], path: string, changes: CompatibilityChange[]): void {\n\tconst oldValues = new Set(before);\n\tconst newValues = new Set(after);\n\tfor (const value of oldValues) if (!newValues.has(value)) changes.push({ severity: \"breaking\", path: `${path}.${value}`, code: `${path}_removed`, message: `Public ${path} value \"${value}\" was removed.` });\n\tfor (const value of newValues) if (!oldValues.has(value)) changes.push({ severity: \"compatible\", path: `${path}.${value}`, code: `${path}_added`, message: `Public ${path} value \"${value}\" was added.` });\n}\n\nfunction diffNamed<T extends object>(\n\tbefore: T[], after: T[], path: string, key: keyof T, changes: CompatibilityChange[], compare: (before: T, after: T, path: string) => void,\n): void {\n\tconst oldMap = new Map(before.map((value) => [String(value[key]), value]));\n\tconst newMap = new Map(after.map((value) => [String(value[key]), value]));\n\tfor (const [name, value] of oldMap) {\n\t\tconst next = newMap.get(name);\n\t\tif (!next) changes.push({ severity: \"breaking\", path: `${path}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} \"${name}\" was removed.` });\n\t\telse compare(value, next, `${path}.${name}`);\n\t}\n\tfor (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: \"compatible\", path: `${path}.${name}`, code: `${String(key)}_added`, message: `${String(key)} \"${name}\" was added.` });\n}\n\nfunction diffSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst changeCount = changes.length;\n\tif (!before && after) { changes.push({ severity: \"potentially_breaking\", path, code: \"schema_added\", message: \"A schema was added to an existing contract.\" }); return; }\n\tif (before && !after) { changes.push({ severity: \"breaking\", path, code: \"schema_removed\", message: \"An existing schema was removed.\" }); return; }\n\tif (!before || !after) return;\n\tconst oldRequired = new Set(before.required ?? []);\n\tfor (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: \"breaking\", path: `${path}.required.${required}`, code: \"required_property_added\", message: `Required property \"${required}\" was added.` });\n\tconst oldProperties = before.properties ?? {};\n\tconst newProperties = after.properties ?? {};\n\tfor (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: \"breaking\", path: `${path}.properties.${property}`, code: \"schema_property_removed\", message: `Schema property \"${property}\" was removed.` });\n\tfor (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? \"breaking\" : \"compatible\", path: `${path}.properties.${property}`, code: \"schema_property_added\", message: `Schema property \"${property}\" was added.` });\n\tfor (const property of Object.keys(oldProperties)) {\n\t\tif (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path}.properties.${property}`, changes);\n\t}\n\tif (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: \"breaking\", path: `${path}.additionalProperties`, code: \"additional_properties_forbidden\", message: \"Schema now rejects undeclared properties.\" });\n\tif (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path}.items`, changes);\n\tfor (const keyword of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"pattern\"] as const) {\n\t\tif (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${keyword}`, code: \"schema_constraint_changed\", message: `Schema constraint \"${keyword}\" changed.` });\n\t}\n\tif (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: \"breaking\", path: `${path}.type`, code: \"schema_type_changed\", message: \"Schema type changed.\" });\n\tif (before.enum && after.enum && before.enum.some((value) => !after.enum!.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.enum`, code: \"schema_enum_narrowed\", message: \"Schema enum no longer accepts a previously valid value.\" });\n\t}\n\tif (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: \"potentially_breaking\", path, code: \"schema_changed\", message: \"Schema changed and requires consumer review.\" });\n}\n\nfunction report(changes: CompatibilityChange[]): CompatibilityReport {\n\tconst highestSeverity = changes.reduce<CompatibilitySeverity>((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, \"compatible\");\n\treturn { compatible: highestSeverity === \"compatible\", highestSeverity, changes };\n}\n\nexport interface GeneratedFile { path: string; content: string; }\nexport interface GeneratorTarget { name: string; version: string; generate(ir: FabricCompilerIr): GeneratedFile[] | Promise<GeneratedFile[]>; }\n\nexport async function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]> {\n\tconst files = await target.generate(ir);\n\tconst paths = new Set<string>();\n\treturn [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {\n\t\tif (!file.path || path.isAbsolute(file.path) || path.win32.isAbsolute(file.path) || file.path.includes(\"\\\\\") || file.path.split(\"/\").includes(\"..\")) throw new Error(`Generator \"${target.name}\" returned unsafe path \"${file.path}\".`);\n\t\tif (paths.has(file.path)) throw new Error(`Generator \"${target.name}\" returned duplicate path \"${file.path}\".`);\n\t\tpaths.add(file.path);\n\t\treturn { path: file.path, content: file.content.endsWith(\"\\n\") ? file.content : `${file.content}\\n` };\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,uBAAiB;AACjB,sBAQO;AAEA,IA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K,EAAE,KAAK,CAAC,MAAM,UAAU,wBAAwB,KAAK,MAAM,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS;AACrG,QAAI,CAAC,KAAK,QAAQ,iBAAAA,QAAK,WAAW,KAAK,IAAI,KAAK,iBAAAA,QAAK,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,MAAM,GAAG,EAAE,SAAS,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,2BAA2B,KAAK,IAAI,IAAI;AACtO,QAAI,MAAM,IAAI,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,8BAA8B,KAAK,IAAI,IAAI;AAC9G,UAAM,IAAI,KAAK,IAAI;AACnB,WAAO,EAAE,MAAM,KAAK,MAAM,SAAS,KAAK,QAAQ,SAAS,IAAI,IAAI,KAAK,UAAU,GAAG,KAAK,OAAO;AAAA,EAAK;AAAA,EACrG,CAAC;AACF;","names":["module","path"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ModuleManifest, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
1
|
+
import { ModuleManifest, DeclarativeInvariant, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
2
2
|
|
|
3
|
-
declare const FABRIC_COMPILER_VERSION = "0.1
|
|
3
|
+
declare const FABRIC_COMPILER_VERSION = "0.2.1";
|
|
4
4
|
declare const compareCanonicalStrings: (left: string, right: string) => number;
|
|
5
5
|
interface CompilerConformanceAdapter<Finding = unknown> {
|
|
6
6
|
id: string;
|
|
@@ -11,6 +11,16 @@ interface CompilerConformanceResult<Finding = unknown> {
|
|
|
11
11
|
moduleNamespace: string;
|
|
12
12
|
findings: Finding[];
|
|
13
13
|
}
|
|
14
|
+
interface CertificationInvariantContext {
|
|
15
|
+
module: ModuleManifest;
|
|
16
|
+
objectType: ModuleManifest["objectTypes"][number];
|
|
17
|
+
invariant: DeclarativeInvariant;
|
|
18
|
+
}
|
|
19
|
+
interface CertificationProfile {
|
|
20
|
+
id: string;
|
|
21
|
+
/** Resolve evidence owned outside serialized Platform definitions. */
|
|
22
|
+
resolveInvariant?(context: CertificationInvariantContext): boolean;
|
|
23
|
+
}
|
|
14
24
|
interface FabricCompilerIr {
|
|
15
25
|
compilerVersion: string;
|
|
16
26
|
manifestVersion: number;
|
|
@@ -21,6 +31,7 @@ interface FabricCompilerIr {
|
|
|
21
31
|
declare function stableStringify(value: unknown): string;
|
|
22
32
|
declare function compileManifestBundle(input: ModuleManifestBundle | ModuleManifestBundleV1, options?: {
|
|
23
33
|
conformanceAdapters?: CompilerConformanceAdapter[];
|
|
34
|
+
certificationProfiles?: CertificationProfile[];
|
|
24
35
|
}): FabricCompilerIr;
|
|
25
36
|
type CompatibilitySeverity = "compatible" | "potentially_breaking" | "breaking";
|
|
26
37
|
interface CompatibilityChange {
|
|
@@ -46,4 +57,4 @@ interface GeneratorTarget {
|
|
|
46
57
|
}
|
|
47
58
|
declare function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]>;
|
|
48
59
|
|
|
49
|
-
export { type CompatibilityChange, type CompatibilityReport, type CompatibilitySeverity, type CompilerConformanceAdapter, type CompilerConformanceResult, FABRIC_COMPILER_VERSION, type FabricCompilerIr, type GeneratedFile, type GeneratorTarget, compareCanonicalStrings, compileManifestBundle, diffModuleManifests, runGenerator, stableStringify };
|
|
60
|
+
export { type CertificationInvariantContext, type CertificationProfile, type CompatibilityChange, type CompatibilityReport, type CompatibilitySeverity, type CompilerConformanceAdapter, type CompilerConformanceResult, FABRIC_COMPILER_VERSION, type FabricCompilerIr, type GeneratedFile, type GeneratorTarget, compareCanonicalStrings, compileManifestBundle, diffModuleManifests, runGenerator, stableStringify };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ModuleManifest, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
1
|
+
import { ModuleManifest, DeclarativeInvariant, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
2
2
|
|
|
3
|
-
declare const FABRIC_COMPILER_VERSION = "0.1
|
|
3
|
+
declare const FABRIC_COMPILER_VERSION = "0.2.1";
|
|
4
4
|
declare const compareCanonicalStrings: (left: string, right: string) => number;
|
|
5
5
|
interface CompilerConformanceAdapter<Finding = unknown> {
|
|
6
6
|
id: string;
|
|
@@ -11,6 +11,16 @@ interface CompilerConformanceResult<Finding = unknown> {
|
|
|
11
11
|
moduleNamespace: string;
|
|
12
12
|
findings: Finding[];
|
|
13
13
|
}
|
|
14
|
+
interface CertificationInvariantContext {
|
|
15
|
+
module: ModuleManifest;
|
|
16
|
+
objectType: ModuleManifest["objectTypes"][number];
|
|
17
|
+
invariant: DeclarativeInvariant;
|
|
18
|
+
}
|
|
19
|
+
interface CertificationProfile {
|
|
20
|
+
id: string;
|
|
21
|
+
/** Resolve evidence owned outside serialized Platform definitions. */
|
|
22
|
+
resolveInvariant?(context: CertificationInvariantContext): boolean;
|
|
23
|
+
}
|
|
14
24
|
interface FabricCompilerIr {
|
|
15
25
|
compilerVersion: string;
|
|
16
26
|
manifestVersion: number;
|
|
@@ -21,6 +31,7 @@ interface FabricCompilerIr {
|
|
|
21
31
|
declare function stableStringify(value: unknown): string;
|
|
22
32
|
declare function compileManifestBundle(input: ModuleManifestBundle | ModuleManifestBundleV1, options?: {
|
|
23
33
|
conformanceAdapters?: CompilerConformanceAdapter[];
|
|
34
|
+
certificationProfiles?: CertificationProfile[];
|
|
24
35
|
}): FabricCompilerIr;
|
|
25
36
|
type CompatibilitySeverity = "compatible" | "potentially_breaking" | "breaking";
|
|
26
37
|
interface CompatibilityChange {
|
|
@@ -46,4 +57,4 @@ interface GeneratorTarget {
|
|
|
46
57
|
}
|
|
47
58
|
declare function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]>;
|
|
48
59
|
|
|
49
|
-
export { type CompatibilityChange, type CompatibilityReport, type CompatibilitySeverity, type CompilerConformanceAdapter, type CompilerConformanceResult, FABRIC_COMPILER_VERSION, type FabricCompilerIr, type GeneratedFile, type GeneratorTarget, compareCanonicalStrings, compileManifestBundle, diffModuleManifests, runGenerator, stableStringify };
|
|
60
|
+
export { type CertificationInvariantContext, type CertificationProfile, type CompatibilityChange, type CompatibilityReport, type CompatibilitySeverity, type CompilerConformanceAdapter, type CompilerConformanceResult, FABRIC_COMPILER_VERSION, type FabricCompilerIr, type GeneratedFile, type GeneratorTarget, compareCanonicalStrings, compileManifestBundle, diffModuleManifests, runGenerator, stableStringify };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// index.ts
|
|
2
2
|
import { createHash } from "crypto";
|
|
3
|
+
import path from "path";
|
|
3
4
|
import {
|
|
4
5
|
normalizeModuleManifestBundle,
|
|
5
6
|
assertPortableJsonSchema
|
|
6
7
|
} from "@fabricorg/platform";
|
|
7
|
-
var FABRIC_COMPILER_VERSION = "0.1
|
|
8
|
+
var FABRIC_COMPILER_VERSION = "0.2.1";
|
|
8
9
|
var compareCanonicalStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
9
10
|
function stableStringify(value) {
|
|
10
11
|
return JSON.stringify(sortJson(value));
|
|
@@ -26,7 +27,7 @@ function compileManifestBundle(input, options = {}) {
|
|
|
26
27
|
namespaces.add(module.namespace);
|
|
27
28
|
}
|
|
28
29
|
const modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));
|
|
29
|
-
assertCompilerManifests(modules);
|
|
30
|
+
assertCompilerManifests(modules, options.certificationProfiles ?? []);
|
|
30
31
|
const canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });
|
|
31
32
|
return {
|
|
32
33
|
compilerVersion: FABRIC_COMPILER_VERSION,
|
|
@@ -38,7 +39,9 @@ function compileManifestBundle(input, options = {}) {
|
|
|
38
39
|
)
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
function assertCompilerManifests(modules) {
|
|
42
|
+
function assertCompilerManifests(modules, certificationProfiles) {
|
|
43
|
+
const profiles = new Map(certificationProfiles.map((profile) => [profile.id, profile]));
|
|
44
|
+
if (profiles.size !== certificationProfiles.length) throw new Error("Certification profile IDs must be unique.");
|
|
42
45
|
for (const module of modules) {
|
|
43
46
|
if (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error("Compiler input is not a normalized module manifest.");
|
|
44
47
|
}
|
|
@@ -48,10 +51,17 @@ function assertCompilerManifests(modules) {
|
|
|
48
51
|
if (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module "${module.namespace}" capability requires displayName and description.`);
|
|
49
52
|
if (!["experimental", "beta", "stable", "deprecated"].includes(module.capability.stability)) throw new Error(`Module "${module.namespace}" capability has invalid stability.`);
|
|
50
53
|
}
|
|
54
|
+
const certification = module.capability?.certification;
|
|
55
|
+
const profile = certification?.required ? profiles.get(certification.profile) : void 0;
|
|
51
56
|
for (const objectType of module.objectTypes) {
|
|
52
57
|
if (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type "${objectType.type}" in compiler input.`);
|
|
53
58
|
if (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);
|
|
54
59
|
for (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type "${relation.target}".`);
|
|
60
|
+
for (const invariant of objectType.invariants ?? []) {
|
|
61
|
+
if (invariant.required && !resolvesRequiredInvariant(module, objectType, invariant, profile)) {
|
|
62
|
+
throw new Error(`Required invariant "${module.namespace}.${objectType.type}.${invariant.id}" has no resolvable enforcement evidence under certification profile "${certification?.profile ?? "none"}".`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
55
65
|
}
|
|
56
66
|
for (const view of module.views) {
|
|
57
67
|
if (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View "${view.name}" must use module namespace "${module.namespace}/".`);
|
|
@@ -64,37 +74,72 @@ function assertCompilerManifests(modules) {
|
|
|
64
74
|
}
|
|
65
75
|
}
|
|
66
76
|
}
|
|
77
|
+
function resolvesRequiredInvariant(module, objectType, invariant, profile) {
|
|
78
|
+
const reference = invariant.enforcementRef?.trim();
|
|
79
|
+
if (!reference) return false;
|
|
80
|
+
if (invariant.enforcement === "json-schema") {
|
|
81
|
+
const requiredMatch = /^#\/required\/([^/]+)$/.exec(reference);
|
|
82
|
+
if (requiredMatch) return Array.isArray(objectType.schema?.required) && objectType.schema.required.includes(decodeJsonPointerToken(requiredMatch[1]));
|
|
83
|
+
const propertyMatch = /^#\/properties\/([^/]+)$/.exec(reference);
|
|
84
|
+
if (propertyMatch) return Boolean(objectType.schema?.properties?.[decodeJsonPointerToken(propertyMatch[1])]);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (invariant.enforcement === "state-machine") return module.stateMachines.some((machine) => machine.entityType === reference);
|
|
88
|
+
if (invariant.enforcement === "policy") return module.policies.some((policy) => policy.policyId === reference);
|
|
89
|
+
return profile?.resolveInvariant?.({ module, objectType, invariant }) === true;
|
|
90
|
+
}
|
|
91
|
+
function decodeJsonPointerToken(token) {
|
|
92
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
93
|
+
}
|
|
67
94
|
var severityRank = { compatible: 0, potentially_breaking: 1, breaking: 2 };
|
|
68
95
|
function diffModuleManifests(before, after) {
|
|
69
96
|
if (before.namespace !== after.namespace) {
|
|
70
97
|
return report([{ severity: "breaking", path: "namespace", code: "module_renamed", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);
|
|
71
98
|
}
|
|
72
99
|
const changes = [];
|
|
73
|
-
|
|
74
|
-
|
|
100
|
+
if (before.version !== after.version) changes.push({ severity: "potentially_breaking", path: "version", code: "module_version_changed", message: "Module version changed." });
|
|
101
|
+
if (stableStringify(before.capability) !== stableStringify(after.capability)) changes.push({ severity: "potentially_breaking", path: "capability", code: "capability_changed", message: "Capability roles, stability, deprecation, extension slots, or certification metadata changed." });
|
|
102
|
+
diffStringList(before.subjectTypes, after.subjectTypes, "subjectTypes", changes);
|
|
103
|
+
diffNamed(before.idPrefixes, after.idPrefixes, "idPrefixes", "prefix", changes, (oldValue, newValue, path2) => {
|
|
104
|
+
if (stableStringify(oldValue) !== stableStringify(newValue)) changes.push({ severity: "breaking", path: path2, code: "id_prefix_changed", message: "ID prefix ownership changed." });
|
|
105
|
+
});
|
|
106
|
+
if (stableStringify(before.dependencies) !== stableStringify(after.dependencies)) changes.push({ severity: "potentially_breaking", path: "dependencies", code: "module_dependencies_changed", message: "Module dependencies changed." });
|
|
107
|
+
if (stableStringify(before.policies) !== stableStringify(after.policies)) changes.push({ severity: "potentially_breaking", path: "policies", code: "module_policies_changed", message: "Module policy definitions changed." });
|
|
108
|
+
diffNamed(before.objectTypes, after.objectTypes, "objectTypes", "type", changes, (oldValue, newValue, path2) => {
|
|
109
|
+
diffSchema(oldValue.schema, newValue.schema, `${path2}.schema`, changes);
|
|
75
110
|
const oldArchetype = oldValue.semantics?.["fabric.archetype"];
|
|
76
111
|
const newArchetype = newValue.semantics?.["fabric.archetype"];
|
|
77
|
-
if (oldArchetype && !newArchetype) changes.push({ severity: "breaking", path: `${
|
|
78
|
-
else if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: "breaking", path: `${
|
|
79
|
-
diffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${
|
|
112
|
+
if (oldArchetype && !newArchetype) changes.push({ severity: "breaking", path: `${path2}.semantics.fabric.archetype`, code: "archetype_removed", message: "Archetype certification metadata was removed." });
|
|
113
|
+
else if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: "breaking", path: `${path2}.semantics.fabric.archetype`, code: "archetype_mapping_changed", message: "Archetype identity, version, or state mapping changed." });
|
|
114
|
+
diffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path2}.relations`, "name", changes, (oldRelation, newRelation, relationPath) => {
|
|
80
115
|
if (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: "breaking", path: `${relationPath}.cardinality`, code: "relation_cardinality_changed", message: "Relation cardinality changed." });
|
|
81
116
|
if (oldRelation.target !== newRelation.target) changes.push({ severity: "breaking", path: `${relationPath}.target`, code: "relation_target_changed", message: "Relation target changed." });
|
|
82
117
|
if (!oldRelation.required && newRelation.required) changes.push({ severity: "breaking", path: `${relationPath}.required`, code: "relation_became_required", message: "Optional relation became required." });
|
|
83
118
|
if (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: "breaking", path: `${relationPath}.semantics`, code: "relation_ownership_changed", message: "Relation ownership semantics changed." });
|
|
84
119
|
if (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: "breaking", path: `${relationPath}.onTargetDelete`, code: "relation_delete_behavior_changed", message: "Relation deletion behavior changed." });
|
|
85
120
|
});
|
|
86
|
-
diffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${
|
|
121
|
+
diffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path2}.invariants`, "id", changes, (oldInvariant, newInvariant, invariantPath) => {
|
|
87
122
|
if (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: "potentially_breaking", path: invariantPath, code: "invariant_enforcement_changed", message: "Invariant enforcement ownership or reference changed." });
|
|
88
123
|
if (!oldInvariant.required && newInvariant.required) changes.push({ severity: "breaking", path: `${invariantPath}.required`, code: "invariant_became_required", message: "Invariant became required." });
|
|
89
124
|
});
|
|
90
125
|
});
|
|
91
|
-
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue,
|
|
92
|
-
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${
|
|
93
|
-
diffSchema(oldValue.resultSchema, newValue.resultSchema, `${
|
|
126
|
+
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue, path2) => {
|
|
127
|
+
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${path2}.parameterSchema`, changes);
|
|
128
|
+
diffSchema(oldValue.resultSchema, newValue.resultSchema, `${path2}.resultSchema`, changes);
|
|
129
|
+
for (const field of ["version", "kind", "idempotent", "mutatesDomain", "eventPhase"]) {
|
|
130
|
+
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });
|
|
131
|
+
}
|
|
132
|
+
const oldEvents = new Set(oldValue.emitsEvents);
|
|
133
|
+
const newEvents = new Set(newValue.emitsEvents);
|
|
134
|
+
for (const event of oldEvents) if (!newEvents.has(event)) changes.push({ severity: "breaking", path: `${path2}.emitsEvents.${event}`, code: "action_event_removed", message: `Declared action event "${event}" was removed.` });
|
|
135
|
+
for (const event of newEvents) if (!oldEvents.has(event)) changes.push({ severity: "compatible", path: `${path2}.emitsEvents.${event}`, code: "action_event_added", message: `Declared action event "${event}" was added.` });
|
|
136
|
+
for (const field of ["policies", "requiredRoles", "requiredPermissions", "stateMachine", "adapterSteps"]) {
|
|
137
|
+
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "potentially_breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed and requires consumer review.` });
|
|
138
|
+
}
|
|
94
139
|
});
|
|
95
|
-
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue,
|
|
96
|
-
if (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: "breaking", path: `${
|
|
97
|
-
else if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: "potentially_breaking", path: `${
|
|
140
|
+
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue, path2) => {
|
|
141
|
+
if (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: "breaking", path: `${path2}.schemaVersion`, code: "event_version_decreased", message: "Event schema version decreased." });
|
|
142
|
+
else if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: "potentially_breaking", path: `${path2}.schemaVersion`, code: "event_version_changed", message: "Event schema version changed; old consumers require compatibility evidence." });
|
|
98
143
|
});
|
|
99
144
|
const oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));
|
|
100
145
|
const newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));
|
|
@@ -104,54 +149,60 @@ function diffModuleManifests(before, after) {
|
|
|
104
149
|
else diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);
|
|
105
150
|
}
|
|
106
151
|
for (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: "compatible", path: `views.${key}`, code: "view_version_added", message: `View contract "${key}" was added.` });
|
|
107
|
-
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue,
|
|
152
|
+
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue, path2) => {
|
|
108
153
|
const newStates = new Set(newValue.states.map((state) => state.id));
|
|
109
|
-
for (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: "breaking", path: `${
|
|
154
|
+
for (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: "breaking", path: `${path2}.states.${state.id}`, code: "state_removed", message: `State "${state.id}" was removed.` });
|
|
110
155
|
const transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));
|
|
111
|
-
for (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: "breaking", path: `${
|
|
156
|
+
for (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: "breaking", path: `${path2}.transitions.${transition.from}->${transition.to}`, code: "transition_removed", message: "A state transition was removed or remapped." });
|
|
112
157
|
});
|
|
113
158
|
return report(changes);
|
|
114
159
|
}
|
|
115
|
-
function
|
|
160
|
+
function diffStringList(before, after, path2, changes) {
|
|
161
|
+
const oldValues = new Set(before);
|
|
162
|
+
const newValues = new Set(after);
|
|
163
|
+
for (const value of oldValues) if (!newValues.has(value)) changes.push({ severity: "breaking", path: `${path2}.${value}`, code: `${path2}_removed`, message: `Public ${path2} value "${value}" was removed.` });
|
|
164
|
+
for (const value of newValues) if (!oldValues.has(value)) changes.push({ severity: "compatible", path: `${path2}.${value}`, code: `${path2}_added`, message: `Public ${path2} value "${value}" was added.` });
|
|
165
|
+
}
|
|
166
|
+
function diffNamed(before, after, path2, key, changes, compare) {
|
|
116
167
|
const oldMap = new Map(before.map((value) => [String(value[key]), value]));
|
|
117
168
|
const newMap = new Map(after.map((value) => [String(value[key]), value]));
|
|
118
169
|
for (const [name, value] of oldMap) {
|
|
119
170
|
const next = newMap.get(name);
|
|
120
|
-
if (!next) changes.push({ severity: "breaking", path: `${
|
|
121
|
-
else compare(value, next, `${
|
|
171
|
+
if (!next) changes.push({ severity: "breaking", path: `${path2}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} "${name}" was removed.` });
|
|
172
|
+
else compare(value, next, `${path2}.${name}`);
|
|
122
173
|
}
|
|
123
|
-
for (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: "compatible", path: `${
|
|
174
|
+
for (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: "compatible", path: `${path2}.${name}`, code: `${String(key)}_added`, message: `${String(key)} "${name}" was added.` });
|
|
124
175
|
}
|
|
125
|
-
function diffSchema(before, after,
|
|
176
|
+
function diffSchema(before, after, path2, changes) {
|
|
126
177
|
const changeCount = changes.length;
|
|
127
178
|
if (!before && after) {
|
|
128
|
-
changes.push({ severity: "potentially_breaking", path, code: "schema_added", message: "A schema was added to an existing contract." });
|
|
179
|
+
changes.push({ severity: "potentially_breaking", path: path2, code: "schema_added", message: "A schema was added to an existing contract." });
|
|
129
180
|
return;
|
|
130
181
|
}
|
|
131
182
|
if (before && !after) {
|
|
132
|
-
changes.push({ severity: "breaking", path, code: "schema_removed", message: "An existing schema was removed." });
|
|
183
|
+
changes.push({ severity: "breaking", path: path2, code: "schema_removed", message: "An existing schema was removed." });
|
|
133
184
|
return;
|
|
134
185
|
}
|
|
135
186
|
if (!before || !after) return;
|
|
136
187
|
const oldRequired = new Set(before.required ?? []);
|
|
137
|
-
for (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: "breaking", path: `${
|
|
188
|
+
for (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: "breaking", path: `${path2}.required.${required}`, code: "required_property_added", message: `Required property "${required}" was added.` });
|
|
138
189
|
const oldProperties = before.properties ?? {};
|
|
139
190
|
const newProperties = after.properties ?? {};
|
|
140
|
-
for (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: "breaking", path: `${
|
|
141
|
-
for (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? "breaking" : "compatible", path: `${
|
|
191
|
+
for (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: "breaking", path: `${path2}.properties.${property}`, code: "schema_property_removed", message: `Schema property "${property}" was removed.` });
|
|
192
|
+
for (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? "breaking" : "compatible", path: `${path2}.properties.${property}`, code: "schema_property_added", message: `Schema property "${property}" was added.` });
|
|
142
193
|
for (const property of Object.keys(oldProperties)) {
|
|
143
|
-
if (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${
|
|
194
|
+
if (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path2}.properties.${property}`, changes);
|
|
144
195
|
}
|
|
145
|
-
if (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: "breaking", path: `${
|
|
146
|
-
if (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${
|
|
196
|
+
if (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: "breaking", path: `${path2}.additionalProperties`, code: "additional_properties_forbidden", message: "Schema now rejects undeclared properties." });
|
|
197
|
+
if (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path2}.items`, changes);
|
|
147
198
|
for (const keyword of ["minimum", "maximum", "minLength", "maxLength", "pattern"]) {
|
|
148
|
-
if (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: "potentially_breaking", path: `${
|
|
199
|
+
if (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: "potentially_breaking", path: `${path2}.${keyword}`, code: "schema_constraint_changed", message: `Schema constraint "${keyword}" changed.` });
|
|
149
200
|
}
|
|
150
|
-
if (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: "breaking", path: `${
|
|
201
|
+
if (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: "breaking", path: `${path2}.type`, code: "schema_type_changed", message: "Schema type changed." });
|
|
151
202
|
if (before.enum && after.enum && before.enum.some((value) => !after.enum.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {
|
|
152
|
-
changes.push({ severity: "breaking", path: `${
|
|
203
|
+
changes.push({ severity: "breaking", path: `${path2}.enum`, code: "schema_enum_narrowed", message: "Schema enum no longer accepts a previously valid value." });
|
|
153
204
|
}
|
|
154
|
-
if (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: "potentially_breaking", path, code: "schema_changed", message: "Schema changed and requires consumer review." });
|
|
205
|
+
if (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: "potentially_breaking", path: path2, code: "schema_changed", message: "Schema changed and requires consumer review." });
|
|
155
206
|
}
|
|
156
207
|
function report(changes) {
|
|
157
208
|
const highestSeverity = changes.reduce((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, "compatible");
|
|
@@ -161,7 +212,7 @@ async function runGenerator(target, ir) {
|
|
|
161
212
|
const files = await target.generate(ir);
|
|
162
213
|
const paths = /* @__PURE__ */ new Set();
|
|
163
214
|
return [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {
|
|
164
|
-
if (!file.path || file.path.
|
|
215
|
+
if (!file.path || path.isAbsolute(file.path) || path.win32.isAbsolute(file.path) || file.path.includes("\\") || file.path.split("/").includes("..")) throw new Error(`Generator "${target.name}" returned unsafe path "${file.path}".`);
|
|
165
216
|
if (paths.has(file.path)) throw new Error(`Generator "${target.name}" returned duplicate path "${file.path}".`);
|
|
166
217
|
paths.add(file.path);
|
|
167
218
|
return { path: file.path, content: file.content.endsWith("\n") ? file.content : `${file.content}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n\tnormalizeModuleManifestBundle,\n\tassertPortableJsonSchema,\n\ttype ModuleManifest,\n\ttype ModuleManifestBundle,\n\ttype ModuleManifestBundleV1,\n\ttype PortableJsonSchema,\n} from \"@fabricorg/platform\";\n\nexport const FABRIC_COMPILER_VERSION = \"0.1.0\";\nexport const compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface CompilerConformanceAdapter<Finding = unknown> {\n\tid: string;\n\tevaluate(manifest: ModuleManifest): Finding[];\n}\n\nexport interface CompilerConformanceResult<Finding = unknown> {\n\tadapterId: string;\n\tmoduleNamespace: string;\n\tfindings: Finding[];\n}\n\nexport interface FabricCompilerIr {\n\tcompilerVersion: string;\n\tmanifestVersion: number;\n\tmanifestDigest: string;\n\tmodules: ModuleManifest[];\n\tconformance: CompilerConformanceResult[];\n}\n\nexport function stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => compareCanonicalStrings(left, right))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function compileManifestBundle(\n\tinput: ModuleManifestBundle | ModuleManifestBundleV1,\n\toptions: { conformanceAdapters?: CompilerConformanceAdapter[] } = {},\n): FabricCompilerIr {\n\tconst bundle = normalizeModuleManifestBundle(input);\n\tconst namespaces = new Set<string>();\n\tfor (const module of bundle.modules) {\n\t\tif (namespaces.has(module.namespace)) throw new Error(`Duplicate module namespace \"${module.namespace}\" in compiler input.`);\n\t\tnamespaces.add(module.namespace);\n\t}\n\tconst modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));\n\tassertCompilerManifests(modules);\n\tconst canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });\n\treturn {\n\t\tcompilerVersion: FABRIC_COMPILER_VERSION,\n\t\tmanifestVersion: bundle.manifestVersion,\n\t\tmanifestDigest: createHash(\"sha256\").update(canonical).digest(\"hex\"),\n\t\tmodules,\n\t\tconformance: (options.conformanceAdapters ?? []).flatMap((adapter) =>\n\t\t\tmodules.map((module) => ({ adapterId: adapter.id, moduleNamespace: module.namespace, findings: adapter.evaluate(module) })),\n\t\t),\n\t};\n}\n\nfunction assertCompilerManifests(modules: ModuleManifest[]): void {\n\tfor (const module of modules) {\n\t\tif (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error(\"Compiler input is not a normalized module manifest.\");\n\t}\n\tconst targets = new Set(modules.flatMap((module) => module.objectTypes.map((objectType) => `${module.namespace}.${objectType.type}`)));\n\tfor (const module of modules) {\n\t\tif (module.capability) {\n\t\t\tif (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t\tif (![\"experimental\", \"beta\", \"stable\", \"deprecated\"].includes(module.capability.stability)) throw new Error(`Module \"${module.namespace}\" capability has invalid stability.`);\n\t\t}\n\t\tfor (const objectType of module.objectTypes) {\n\t\t\tif (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type \"${objectType.type}\" in compiler input.`);\n\t\t\tif (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);\n\t\t\tfor (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type \"${relation.target}\".`);\n\t\t}\n\t\tfor (const view of module.views) {\n\t\t\tif (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View \"${view.name}\" must use module namespace \"${module.namespace}/\".`);\n\t\t\tassertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);\n\t\t}\n\t\tfor (const action of module.actions) {\n\t\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || ![\"atomic\", \"saga\"].includes(action.kind) || typeof action.idempotent !== \"boolean\" || typeof action.mutatesDomain !== \"boolean\" || !Array.isArray(action.emitsEvents)) throw new Error(`Action \"${action.actionId}\" is not a normalized manifest action.`);\n\t\t\tif (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema as PortableJsonSchema, `Action ${action.actionId} parameters`);\n\t\t\tif (action.resultSchema) assertPortableJsonSchema(action.resultSchema as PortableJsonSchema, `Action ${action.actionId} result`);\n\t\t}\n\t}\n}\n\nexport type CompatibilitySeverity = \"compatible\" | \"potentially_breaking\" | \"breaking\";\nexport interface CompatibilityChange {\n\tseverity: CompatibilitySeverity;\n\tpath: string;\n\tcode: string;\n\tmessage: string;\n}\nexport interface CompatibilityReport {\n\tcompatible: boolean;\n\thighestSeverity: CompatibilitySeverity;\n\tchanges: CompatibilityChange[];\n}\n\nconst severityRank: Record<CompatibilitySeverity, number> = { compatible: 0, potentially_breaking: 1, breaking: 2 };\n\nexport function diffModuleManifests(before: ModuleManifest, after: ModuleManifest): CompatibilityReport {\n\tif (before.namespace !== after.namespace) {\n\t\treturn report([{ severity: \"breaking\", path: \"namespace\", code: \"module_renamed\", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);\n\t}\n\tconst changes: CompatibilityChange[] = [];\n\tdiffNamed(before.objectTypes, after.objectTypes, \"objectTypes\", \"type\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tconst oldArchetype = oldValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tconst newArchetype = newValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tif (oldArchetype && !newArchetype) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_removed\", message: \"Archetype certification metadata was removed.\" });\n\t\telse if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_mapping_changed\", message: \"Archetype identity, version, or state mapping changed.\" });\n\t\tdiffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path}.relations`, \"name\", changes, (oldRelation, newRelation, relationPath) => {\n\t\t\tif (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: \"breaking\", path: `${relationPath}.cardinality`, code: \"relation_cardinality_changed\", message: \"Relation cardinality changed.\" });\n\t\t\tif (oldRelation.target !== newRelation.target) changes.push({ severity: \"breaking\", path: `${relationPath}.target`, code: \"relation_target_changed\", message: \"Relation target changed.\" });\n\t\t\tif (!oldRelation.required && newRelation.required) changes.push({ severity: \"breaking\", path: `${relationPath}.required`, code: \"relation_became_required\", message: \"Optional relation became required.\" });\n\t\t\tif (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: \"breaking\", path: `${relationPath}.semantics`, code: \"relation_ownership_changed\", message: \"Relation ownership semantics changed.\" });\n\t\t\tif (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: \"breaking\", path: `${relationPath}.onTargetDelete`, code: \"relation_delete_behavior_changed\", message: \"Relation deletion behavior changed.\" });\n\t\t});\n\t\tdiffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path}.invariants`, \"id\", changes, (oldInvariant, newInvariant, invariantPath) => {\n\t\t\tif (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: \"potentially_breaking\", path: invariantPath, code: \"invariant_enforcement_changed\", message: \"Invariant enforcement ownership or reference changed.\" });\n\t\t\tif (!oldInvariant.required && newInvariant.required) changes.push({ severity: \"breaking\", path: `${invariantPath}.required`, code: \"invariant_became_required\", message: \"Invariant became required.\" });\n\t\t});\n\t});\n\tdiffNamed(before.actions, after.actions, \"actions\", \"actionId\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.parameterSchema as PortableJsonSchema | undefined, newValue.parameterSchema as PortableJsonSchema | undefined, `${path}.parameterSchema`, changes);\n\t\tdiffSchema(oldValue.resultSchema as PortableJsonSchema | undefined, newValue.resultSchema as PortableJsonSchema | undefined, `${path}.resultSchema`, changes);\n\t});\n\tdiffNamed(before.eventTypes, after.eventTypes, \"eventTypes\", \"eventType\", changes, (oldValue, newValue, path) => {\n\t\tif (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: \"breaking\", path: `${path}.schemaVersion`, code: \"event_version_decreased\", message: \"Event schema version decreased.\" });\n\t\telse if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: \"potentially_breaking\", path: `${path}.schemaVersion`, code: \"event_version_changed\", message: \"Event schema version changed; old consumers require compatibility evidence.\" });\n\t});\n\tconst oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tconst newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tfor (const [key, oldView] of oldViews) {\n\t\tconst newView = newViews.get(key);\n\t\tif (!newView) changes.push({ severity: \"breaking\", path: `views.${key}`, code: \"view_version_removed\", message: `View contract \"${key}\" was removed.` });\n\t\telse diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);\n\t}\n\tfor (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: \"compatible\", path: `views.${key}`, code: \"view_version_added\", message: `View contract \"${key}\" was added.` });\n\tdiffNamed(before.stateMachines, after.stateMachines, \"stateMachines\", \"entityType\", changes, (oldValue, newValue, path) => {\n\t\tconst newStates = new Set(newValue.states.map((state) => state.id));\n\t\tfor (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: \"breaking\", path: `${path}.states.${state.id}`, code: \"state_removed\", message: `State \"${state.id}\" was removed.` });\n\t\tconst transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));\n\t\tfor (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: \"breaking\", path: `${path}.transitions.${transition.from}->${transition.to}`, code: \"transition_removed\", message: \"A state transition was removed or remapped.\" });\n\t});\n\treturn report(changes);\n}\n\nfunction diffNamed<T extends object>(\n\tbefore: T[], after: T[], path: string, key: keyof T, changes: CompatibilityChange[], compare: (before: T, after: T, path: string) => void,\n): void {\n\tconst oldMap = new Map(before.map((value) => [String(value[key]), value]));\n\tconst newMap = new Map(after.map((value) => [String(value[key]), value]));\n\tfor (const [name, value] of oldMap) {\n\t\tconst next = newMap.get(name);\n\t\tif (!next) changes.push({ severity: \"breaking\", path: `${path}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} \"${name}\" was removed.` });\n\t\telse compare(value, next, `${path}.${name}`);\n\t}\n\tfor (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: \"compatible\", path: `${path}.${name}`, code: `${String(key)}_added`, message: `${String(key)} \"${name}\" was added.` });\n}\n\nfunction diffSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst changeCount = changes.length;\n\tif (!before && after) { changes.push({ severity: \"potentially_breaking\", path, code: \"schema_added\", message: \"A schema was added to an existing contract.\" }); return; }\n\tif (before && !after) { changes.push({ severity: \"breaking\", path, code: \"schema_removed\", message: \"An existing schema was removed.\" }); return; }\n\tif (!before || !after) return;\n\tconst oldRequired = new Set(before.required ?? []);\n\tfor (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: \"breaking\", path: `${path}.required.${required}`, code: \"required_property_added\", message: `Required property \"${required}\" was added.` });\n\tconst oldProperties = before.properties ?? {};\n\tconst newProperties = after.properties ?? {};\n\tfor (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: \"breaking\", path: `${path}.properties.${property}`, code: \"schema_property_removed\", message: `Schema property \"${property}\" was removed.` });\n\tfor (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? \"breaking\" : \"compatible\", path: `${path}.properties.${property}`, code: \"schema_property_added\", message: `Schema property \"${property}\" was added.` });\n\tfor (const property of Object.keys(oldProperties)) {\n\t\tif (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path}.properties.${property}`, changes);\n\t}\n\tif (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: \"breaking\", path: `${path}.additionalProperties`, code: \"additional_properties_forbidden\", message: \"Schema now rejects undeclared properties.\" });\n\tif (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path}.items`, changes);\n\tfor (const keyword of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"pattern\"] as const) {\n\t\tif (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${keyword}`, code: \"schema_constraint_changed\", message: `Schema constraint \"${keyword}\" changed.` });\n\t}\n\tif (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: \"breaking\", path: `${path}.type`, code: \"schema_type_changed\", message: \"Schema type changed.\" });\n\tif (before.enum && after.enum && before.enum.some((value) => !after.enum!.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.enum`, code: \"schema_enum_narrowed\", message: \"Schema enum no longer accepts a previously valid value.\" });\n\t}\n\tif (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: \"potentially_breaking\", path, code: \"schema_changed\", message: \"Schema changed and requires consumer review.\" });\n}\n\nfunction report(changes: CompatibilityChange[]): CompatibilityReport {\n\tconst highestSeverity = changes.reduce<CompatibilitySeverity>((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, \"compatible\");\n\treturn { compatible: highestSeverity === \"compatible\", highestSeverity, changes };\n}\n\nexport interface GeneratedFile { path: string; content: string; }\nexport interface GeneratorTarget { name: string; version: string; generate(ir: FabricCompilerIr): GeneratedFile[] | Promise<GeneratedFile[]>; }\n\nexport async function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]> {\n\tconst files = await target.generate(ir);\n\tconst paths = new Set<string>();\n\treturn [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {\n\t\tif (!file.path || file.path.startsWith(\"/\") || file.path.split(\"/\").includes(\"..\")) throw new Error(`Generator \"${target.name}\" returned unsafe path \"${file.path}\".`);\n\t\tif (paths.has(file.path)) throw new Error(`Generator \"${target.name}\" returned duplicate path \"${file.path}\".`);\n\t\tpaths.add(file.path);\n\t\treturn { path: file.path, content: file.content.endsWith(\"\\n\") ? file.content : `${file.content}\\n` };\n\t});\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B;AAAA,EACC;AAAA,EACA;AAAA,OAKM;AAEA,IAAM,0BAA0B;AAChC,IAAM,0BAA0B,CAAC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AK,KAAK,MAAM,GAAG,EAAE,SAAS,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,2BAA2B,KAAK,IAAI,IAAI;AACrK,QAAI,MAAM,IAAI,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,8BAA8B,KAAK,IAAI,IAAI;AAC9G,UAAM,IAAI,KAAK,IAAI;AACnB,WAAO,EAAE,MAAM,KAAK,MAAM,SAAS,KAAK,QAAQ,SAAS,IAAI,IAAI,KAAK,UAAU,GAAG,KAAK,OAAO;AAAA,EAAK;AAAA,EACrG,CAAC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport {\n\tnormalizeModuleManifestBundle,\n\tassertPortableJsonSchema,\n\ttype ModuleManifest,\n\ttype ModuleManifestBundle,\n\ttype ModuleManifestBundleV1,\n\ttype DeclarativeInvariant,\n\ttype PortableJsonSchema,\n} from \"@fabricorg/platform\";\n\nexport const FABRIC_COMPILER_VERSION = \"0.2.1\";\nexport const compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface CompilerConformanceAdapter<Finding = unknown> {\n\tid: string;\n\tevaluate(manifest: ModuleManifest): Finding[];\n}\n\nexport interface CompilerConformanceResult<Finding = unknown> {\n\tadapterId: string;\n\tmoduleNamespace: string;\n\tfindings: Finding[];\n}\n\nexport interface CertificationInvariantContext {\n\tmodule: ModuleManifest;\n\tobjectType: ModuleManifest[\"objectTypes\"][number];\n\tinvariant: DeclarativeInvariant;\n}\n\nexport interface CertificationProfile {\n\tid: string;\n\t/** Resolve evidence owned outside serialized Platform definitions. */\n\tresolveInvariant?(context: CertificationInvariantContext): boolean;\n}\n\nexport interface FabricCompilerIr {\n\tcompilerVersion: string;\n\tmanifestVersion: number;\n\tmanifestDigest: string;\n\tmodules: ModuleManifest[];\n\tconformance: CompilerConformanceResult[];\n}\n\nexport function stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => compareCanonicalStrings(left, right))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function compileManifestBundle(\n\tinput: ModuleManifestBundle | ModuleManifestBundleV1,\n\toptions: { conformanceAdapters?: CompilerConformanceAdapter[]; certificationProfiles?: CertificationProfile[] } = {},\n): FabricCompilerIr {\n\tconst bundle = normalizeModuleManifestBundle(input);\n\tconst namespaces = new Set<string>();\n\tfor (const module of bundle.modules) {\n\t\tif (namespaces.has(module.namespace)) throw new Error(`Duplicate module namespace \"${module.namespace}\" in compiler input.`);\n\t\tnamespaces.add(module.namespace);\n\t}\n\tconst modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));\n\tassertCompilerManifests(modules, options.certificationProfiles ?? []);\n\tconst canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });\n\treturn {\n\t\tcompilerVersion: FABRIC_COMPILER_VERSION,\n\t\tmanifestVersion: bundle.manifestVersion,\n\t\tmanifestDigest: createHash(\"sha256\").update(canonical).digest(\"hex\"),\n\t\tmodules,\n\t\tconformance: (options.conformanceAdapters ?? []).flatMap((adapter) =>\n\t\t\tmodules.map((module) => ({ adapterId: adapter.id, moduleNamespace: module.namespace, findings: adapter.evaluate(module) })),\n\t\t),\n\t};\n}\n\nfunction assertCompilerManifests(modules: ModuleManifest[], certificationProfiles: CertificationProfile[]): void {\n\tconst profiles = new Map(certificationProfiles.map((profile) => [profile.id, profile]));\n\tif (profiles.size !== certificationProfiles.length) throw new Error(\"Certification profile IDs must be unique.\");\n\tfor (const module of modules) {\n\t\tif (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error(\"Compiler input is not a normalized module manifest.\");\n\t}\n\tconst targets = new Set(modules.flatMap((module) => module.objectTypes.map((objectType) => `${module.namespace}.${objectType.type}`)));\n\tfor (const module of modules) {\n\t\tif (module.capability) {\n\t\t\tif (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t\tif (![\"experimental\", \"beta\", \"stable\", \"deprecated\"].includes(module.capability.stability)) throw new Error(`Module \"${module.namespace}\" capability has invalid stability.`);\n\t\t}\n\t\tconst certification = module.capability?.certification;\n\t\tconst profile = certification?.required ? profiles.get(certification.profile) : undefined;\n\t\tfor (const objectType of module.objectTypes) {\n\t\t\tif (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type \"${objectType.type}\" in compiler input.`);\n\t\t\tif (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);\n\t\t\tfor (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type \"${relation.target}\".`);\n\t\t\tfor (const invariant of objectType.invariants ?? []) {\n\t\t\t\tif (invariant.required && !resolvesRequiredInvariant(module, objectType, invariant, profile)) {\n\t\t\t\t\tthrow new Error(`Required invariant \"${module.namespace}.${objectType.type}.${invariant.id}\" has no resolvable enforcement evidence under certification profile \"${certification?.profile ?? \"none\"}\".`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const view of module.views) {\n\t\t\tif (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View \"${view.name}\" must use module namespace \"${module.namespace}/\".`);\n\t\t\tassertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);\n\t\t}\n\t\tfor (const action of module.actions) {\n\t\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || ![\"atomic\", \"saga\"].includes(action.kind) || typeof action.idempotent !== \"boolean\" || typeof action.mutatesDomain !== \"boolean\" || !Array.isArray(action.emitsEvents)) throw new Error(`Action \"${action.actionId}\" is not a normalized manifest action.`);\n\t\t\tif (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema as PortableJsonSchema, `Action ${action.actionId} parameters`);\n\t\t\tif (action.resultSchema) assertPortableJsonSchema(action.resultSchema as PortableJsonSchema, `Action ${action.actionId} result`);\n\t\t}\n\t}\n}\n\nfunction resolvesRequiredInvariant(\n\tmodule: ModuleManifest,\n\tobjectType: ModuleManifest[\"objectTypes\"][number],\n\tinvariant: DeclarativeInvariant,\n\tprofile: CertificationProfile | undefined,\n): boolean {\n\tconst reference = invariant.enforcementRef?.trim();\n\tif (!reference) return false;\n\tif (invariant.enforcement === \"json-schema\") {\n\t\tconst requiredMatch = /^#\\/required\\/([^/]+)$/.exec(reference);\n\t\tif (requiredMatch) return Array.isArray(objectType.schema?.required) && objectType.schema.required.includes(decodeJsonPointerToken(requiredMatch[1]!));\n\t\tconst propertyMatch = /^#\\/properties\\/([^/]+)$/.exec(reference);\n\t\tif (propertyMatch) return Boolean(objectType.schema?.properties?.[decodeJsonPointerToken(propertyMatch[1]!)]);\n\t\treturn false;\n\t}\n\tif (invariant.enforcement === \"state-machine\") return module.stateMachines.some((machine) => machine.entityType === reference);\n\tif (invariant.enforcement === \"policy\") return module.policies.some((policy) => policy.policyId === reference);\n\treturn profile?.resolveInvariant?.({ module, objectType, invariant }) === true;\n}\n\nfunction decodeJsonPointerToken(token: string): string {\n\treturn token.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\nexport type CompatibilitySeverity = \"compatible\" | \"potentially_breaking\" | \"breaking\";\nexport interface CompatibilityChange {\n\tseverity: CompatibilitySeverity;\n\tpath: string;\n\tcode: string;\n\tmessage: string;\n}\nexport interface CompatibilityReport {\n\tcompatible: boolean;\n\thighestSeverity: CompatibilitySeverity;\n\tchanges: CompatibilityChange[];\n}\n\nconst severityRank: Record<CompatibilitySeverity, number> = { compatible: 0, potentially_breaking: 1, breaking: 2 };\n\nexport function diffModuleManifests(before: ModuleManifest, after: ModuleManifest): CompatibilityReport {\n\tif (before.namespace !== after.namespace) {\n\t\treturn report([{ severity: \"breaking\", path: \"namespace\", code: \"module_renamed\", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);\n\t}\n\tconst changes: CompatibilityChange[] = [];\n\tif (before.version !== after.version) changes.push({ severity: \"potentially_breaking\", path: \"version\", code: \"module_version_changed\", message: \"Module version changed.\" });\n\tif (stableStringify(before.capability) !== stableStringify(after.capability)) changes.push({ severity: \"potentially_breaking\", path: \"capability\", code: \"capability_changed\", message: \"Capability roles, stability, deprecation, extension slots, or certification metadata changed.\" });\n\tdiffStringList(before.subjectTypes, after.subjectTypes, \"subjectTypes\", changes);\n\tdiffNamed(before.idPrefixes, after.idPrefixes, \"idPrefixes\", \"prefix\", changes, (oldValue, newValue, path) => {\n\t\tif (stableStringify(oldValue) !== stableStringify(newValue)) changes.push({ severity: \"breaking\", path, code: \"id_prefix_changed\", message: \"ID prefix ownership changed.\" });\n\t});\n\tif (stableStringify(before.dependencies) !== stableStringify(after.dependencies)) changes.push({ severity: \"potentially_breaking\", path: \"dependencies\", code: \"module_dependencies_changed\", message: \"Module dependencies changed.\" });\n\tif (stableStringify(before.policies) !== stableStringify(after.policies)) changes.push({ severity: \"potentially_breaking\", path: \"policies\", code: \"module_policies_changed\", message: \"Module policy definitions changed.\" });\n\tdiffNamed(before.objectTypes, after.objectTypes, \"objectTypes\", \"type\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tconst oldArchetype = oldValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tconst newArchetype = newValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tif (oldArchetype && !newArchetype) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_removed\", message: \"Archetype certification metadata was removed.\" });\n\t\telse if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_mapping_changed\", message: \"Archetype identity, version, or state mapping changed.\" });\n\t\tdiffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path}.relations`, \"name\", changes, (oldRelation, newRelation, relationPath) => {\n\t\t\tif (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: \"breaking\", path: `${relationPath}.cardinality`, code: \"relation_cardinality_changed\", message: \"Relation cardinality changed.\" });\n\t\t\tif (oldRelation.target !== newRelation.target) changes.push({ severity: \"breaking\", path: `${relationPath}.target`, code: \"relation_target_changed\", message: \"Relation target changed.\" });\n\t\t\tif (!oldRelation.required && newRelation.required) changes.push({ severity: \"breaking\", path: `${relationPath}.required`, code: \"relation_became_required\", message: \"Optional relation became required.\" });\n\t\t\tif (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: \"breaking\", path: `${relationPath}.semantics`, code: \"relation_ownership_changed\", message: \"Relation ownership semantics changed.\" });\n\t\t\tif (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: \"breaking\", path: `${relationPath}.onTargetDelete`, code: \"relation_delete_behavior_changed\", message: \"Relation deletion behavior changed.\" });\n\t\t});\n\t\tdiffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path}.invariants`, \"id\", changes, (oldInvariant, newInvariant, invariantPath) => {\n\t\t\tif (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: \"potentially_breaking\", path: invariantPath, code: \"invariant_enforcement_changed\", message: \"Invariant enforcement ownership or reference changed.\" });\n\t\t\tif (!oldInvariant.required && newInvariant.required) changes.push({ severity: \"breaking\", path: `${invariantPath}.required`, code: \"invariant_became_required\", message: \"Invariant became required.\" });\n\t\t});\n\t});\n\tdiffNamed(before.actions, after.actions, \"actions\", \"actionId\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.parameterSchema as PortableJsonSchema | undefined, newValue.parameterSchema as PortableJsonSchema | undefined, `${path}.parameterSchema`, changes);\n\t\tdiffSchema(oldValue.resultSchema as PortableJsonSchema | undefined, newValue.resultSchema as PortableJsonSchema | undefined, `${path}.resultSchema`, changes);\n\t\tfor (const field of [\"version\", \"kind\", \"idempotent\", \"mutatesDomain\", \"eventPhase\"] as const) {\n\t\t\tif (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: \"breaking\", path: `${path}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });\n\t\t}\n\t\tconst oldEvents = new Set(oldValue.emitsEvents);\n\t\tconst newEvents = new Set(newValue.emitsEvents);\n\t\tfor (const event of oldEvents) if (!newEvents.has(event)) changes.push({ severity: \"breaking\", path: `${path}.emitsEvents.${event}`, code: \"action_event_removed\", message: `Declared action event \"${event}\" was removed.` });\n\t\tfor (const event of newEvents) if (!oldEvents.has(event)) changes.push({ severity: \"compatible\", path: `${path}.emitsEvents.${event}`, code: \"action_event_added\", message: `Declared action event \"${event}\" was added.` });\n\t\tfor (const field of [\"policies\", \"requiredRoles\", \"requiredPermissions\", \"stateMachine\", \"adapterSteps\"] as const) {\n\t\t\tif (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed and requires consumer review.` });\n\t\t}\n\t});\n\tdiffNamed(before.eventTypes, after.eventTypes, \"eventTypes\", \"eventType\", changes, (oldValue, newValue, path) => {\n\t\tif (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: \"breaking\", path: `${path}.schemaVersion`, code: \"event_version_decreased\", message: \"Event schema version decreased.\" });\n\t\telse if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: \"potentially_breaking\", path: `${path}.schemaVersion`, code: \"event_version_changed\", message: \"Event schema version changed; old consumers require compatibility evidence.\" });\n\t});\n\tconst oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tconst newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tfor (const [key, oldView] of oldViews) {\n\t\tconst newView = newViews.get(key);\n\t\tif (!newView) changes.push({ severity: \"breaking\", path: `views.${key}`, code: \"view_version_removed\", message: `View contract \"${key}\" was removed.` });\n\t\telse diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);\n\t}\n\tfor (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: \"compatible\", path: `views.${key}`, code: \"view_version_added\", message: `View contract \"${key}\" was added.` });\n\tdiffNamed(before.stateMachines, after.stateMachines, \"stateMachines\", \"entityType\", changes, (oldValue, newValue, path) => {\n\t\tconst newStates = new Set(newValue.states.map((state) => state.id));\n\t\tfor (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: \"breaking\", path: `${path}.states.${state.id}`, code: \"state_removed\", message: `State \"${state.id}\" was removed.` });\n\t\tconst transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));\n\t\tfor (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: \"breaking\", path: `${path}.transitions.${transition.from}->${transition.to}`, code: \"transition_removed\", message: \"A state transition was removed or remapped.\" });\n\t});\n\treturn report(changes);\n}\n\nfunction diffStringList(before: string[], after: string[], path: string, changes: CompatibilityChange[]): void {\n\tconst oldValues = new Set(before);\n\tconst newValues = new Set(after);\n\tfor (const value of oldValues) if (!newValues.has(value)) changes.push({ severity: \"breaking\", path: `${path}.${value}`, code: `${path}_removed`, message: `Public ${path} value \"${value}\" was removed.` });\n\tfor (const value of newValues) if (!oldValues.has(value)) changes.push({ severity: \"compatible\", path: `${path}.${value}`, code: `${path}_added`, message: `Public ${path} value \"${value}\" was added.` });\n}\n\nfunction diffNamed<T extends object>(\n\tbefore: T[], after: T[], path: string, key: keyof T, changes: CompatibilityChange[], compare: (before: T, after: T, path: string) => void,\n): void {\n\tconst oldMap = new Map(before.map((value) => [String(value[key]), value]));\n\tconst newMap = new Map(after.map((value) => [String(value[key]), value]));\n\tfor (const [name, value] of oldMap) {\n\t\tconst next = newMap.get(name);\n\t\tif (!next) changes.push({ severity: \"breaking\", path: `${path}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} \"${name}\" was removed.` });\n\t\telse compare(value, next, `${path}.${name}`);\n\t}\n\tfor (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: \"compatible\", path: `${path}.${name}`, code: `${String(key)}_added`, message: `${String(key)} \"${name}\" was added.` });\n}\n\nfunction diffSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst changeCount = changes.length;\n\tif (!before && after) { changes.push({ severity: \"potentially_breaking\", path, code: \"schema_added\", message: \"A schema was added to an existing contract.\" }); return; }\n\tif (before && !after) { changes.push({ severity: \"breaking\", path, code: \"schema_removed\", message: \"An existing schema was removed.\" }); return; }\n\tif (!before || !after) return;\n\tconst oldRequired = new Set(before.required ?? []);\n\tfor (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: \"breaking\", path: `${path}.required.${required}`, code: \"required_property_added\", message: `Required property \"${required}\" was added.` });\n\tconst oldProperties = before.properties ?? {};\n\tconst newProperties = after.properties ?? {};\n\tfor (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: \"breaking\", path: `${path}.properties.${property}`, code: \"schema_property_removed\", message: `Schema property \"${property}\" was removed.` });\n\tfor (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? \"breaking\" : \"compatible\", path: `${path}.properties.${property}`, code: \"schema_property_added\", message: `Schema property \"${property}\" was added.` });\n\tfor (const property of Object.keys(oldProperties)) {\n\t\tif (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path}.properties.${property}`, changes);\n\t}\n\tif (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: \"breaking\", path: `${path}.additionalProperties`, code: \"additional_properties_forbidden\", message: \"Schema now rejects undeclared properties.\" });\n\tif (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path}.items`, changes);\n\tfor (const keyword of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"pattern\"] as const) {\n\t\tif (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${keyword}`, code: \"schema_constraint_changed\", message: `Schema constraint \"${keyword}\" changed.` });\n\t}\n\tif (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: \"breaking\", path: `${path}.type`, code: \"schema_type_changed\", message: \"Schema type changed.\" });\n\tif (before.enum && after.enum && before.enum.some((value) => !after.enum!.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.enum`, code: \"schema_enum_narrowed\", message: \"Schema enum no longer accepts a previously valid value.\" });\n\t}\n\tif (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: \"potentially_breaking\", path, code: \"schema_changed\", message: \"Schema changed and requires consumer review.\" });\n}\n\nfunction report(changes: CompatibilityChange[]): CompatibilityReport {\n\tconst highestSeverity = changes.reduce<CompatibilitySeverity>((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, \"compatible\");\n\treturn { compatible: highestSeverity === \"compatible\", highestSeverity, changes };\n}\n\nexport interface GeneratedFile { path: string; content: string; }\nexport interface GeneratorTarget { name: string; version: string; generate(ir: FabricCompilerIr): GeneratedFile[] | Promise<GeneratedFile[]>; }\n\nexport async function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]> {\n\tconst files = await target.generate(ir);\n\tconst paths = new Set<string>();\n\treturn [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {\n\t\tif (!file.path || path.isAbsolute(file.path) || path.win32.isAbsolute(file.path) || file.path.includes(\"\\\\\") || file.path.split(\"/\").includes(\"..\")) throw new Error(`Generator \"${target.name}\" returned unsafe path \"${file.path}\".`);\n\t\tif (paths.has(file.path)) throw new Error(`Generator \"${target.name}\" returned duplicate path \"${file.path}\".`);\n\t\tpaths.add(file.path);\n\t\treturn { path: file.path, content: file.content.endsWith(\"\\n\") ? file.content : `${file.content}\\n` };\n\t});\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AACjB;AAAA,EACC;AAAA,EACA;AAAA,OAMM;AAEA,IAAM,0BAA0B;AAChC,IAAM,0BAA0B,CAAC,MAAc,UAA0B,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAiChH,SAAS,gBAAgB,OAAwB;AACvD,SAAO,KAAK,UAAU,SAAS,KAAK,CAAC;AACtC;AAEA,SAAS,SAAS,OAAyB;AAC1C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,QAAQ;AACnD,MAAI,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,OAAO;AAAA,MACb,OAAO,QAAQ,KAAgC,EAC7C,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAM,wBAAwB,MAAM,KAAK,CAAC,EAC9D,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,SAAS,KAAK,CAAC,CAAC;AAAA,IAC/C;AAAA,EACD;AACA,SAAO;AACR;AAEO,SAAS,sBACf,OACA,UAAkH,CAAC,GAChG;AACnB,QAAM,SAAS,8BAA8B,KAAK;AAClD,QAAM,aAAa,oBAAI,IAAY;AACnC,aAAW,UAAU,OAAO,SAAS;AACpC,QAAI,WAAW,IAAI,OAAO,SAAS,EAAG,OAAM,IAAI,MAAM,+BAA+B,OAAO,SAAS,sBAAsB;AAC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,EAAE,UAAU,wBAAwB,MAAAA,OAAM,MAAM,kBAAkB,SAAS,+CAA+C,CAAC;AACnO;AAEA,SAAS,OAAO,SAAqD;AACpE,QAAM,kBAAkB,QAAQ,OAA8B,CAAC,SAAS,WAAW,aAAa,OAAO,QAAQ,IAAI,aAAa,OAAO,IAAI,OAAO,WAAW,SAAS,YAAY;AAClL,SAAO,EAAE,YAAY,oBAAoB,cAAc,iBAAiB,QAAQ;AACjF;AAKA,eAAsB,aAAa,QAAyB,IAAgD;AAC3G,QAAM,QAAQ,MAAM,OAAO,SAAS,EAAE;AACtC,QAAM,QAAQ,oBAAI,IAAY;AAC9B,SAAO,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,UAAU,wBAAwB,KAAK,MAAM,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS;AACrG,QAAI,CAAC,KAAK,QAAQ,KAAK,WAAW,KAAK,IAAI,KAAK,KAAK,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,MAAM,GAAG,EAAE,SAAS,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,2BAA2B,KAAK,IAAI,IAAI;AACtO,QAAI,MAAM,IAAI,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,8BAA8B,KAAK,IAAI,IAAI;AAC9G,UAAM,IAAI,KAAK,IAAI;AACnB,WAAO,EAAE,MAAM,KAAK,MAAM,SAAS,KAAK,QAAQ,SAAS,IAAI,IAAI,KAAK,UAAU,GAAG,KAAK,OAAO;AAAA,EAAK;AAAA,EACrG,CAAC;AACF;","names":["path"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabricorg/compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Deterministic compiler IR and semantic compatibility analysis for Fabric module manifests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,14 +24,15 @@
|
|
|
24
24
|
"README.md",
|
|
25
25
|
"CHANGELOG.md"
|
|
26
26
|
],
|
|
27
|
-
"
|
|
28
|
-
"@fabricorg/platform": "^0.11.
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@fabricorg/platform": "^0.11.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.10.0",
|
|
32
32
|
"tsup": "^8.5.0",
|
|
33
33
|
"typescript": "^5.7.3",
|
|
34
|
-
"vitest": "^4.1.5"
|
|
34
|
+
"vitest": "^4.1.5",
|
|
35
|
+
"@fabricorg/platform": "^0.11.1"
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
37
38
|
"node": ">=20"
|