@cynodia/axiom-compiler 0.8.0-alpha.1 → 0.8.2-alpha.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/dist/normalize.d.ts +24 -1
- package/dist/normalize.js +24 -1
- package/dist/server.js +9 -2
- package/package.json +3 -3
package/dist/normalize.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApplicationGraph, ApplicationIR, ValidationIssue, ValidationResult } from '@cynodia/axiom-core';
|
|
2
|
-
import type { RendererCapabilities } from '@cynodia/axiom-core';
|
|
2
|
+
import type { RendererCapabilities, TriggerRuntimeCapabilities } from '@cynodia/axiom-core';
|
|
3
3
|
export declare class GraphValidationError extends Error {
|
|
4
4
|
readonly problems: ValidationIssue[];
|
|
5
5
|
constructor(result: ValidationResult);
|
|
@@ -21,11 +21,34 @@ export interface CompileOptions {
|
|
|
21
21
|
* rejected at compile time rather than discovered on screen.
|
|
22
22
|
*/
|
|
23
23
|
renderer?: RendererCapabilities;
|
|
24
|
+
/**
|
|
25
|
+
* The trigger runtime the IR is being compiled for. Defaults to the browser's real (empty)
|
|
26
|
+
* capability set, because the browser runtime implements no trigger kind — so a
|
|
27
|
+
* client-authority trigger is rejected at compile time rather than compiled inert.
|
|
28
|
+
*/
|
|
29
|
+
triggerRuntime?: TriggerRuntimeCapabilities;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Validates a graph and normalizes it into the runtime-ready IR: references resolved,
|
|
27
33
|
* lookups indexed, routes pre-compiled and ordered most-specific-first.
|
|
28
34
|
*/
|
|
29
35
|
export declare function compileToIR(graph: ApplicationGraph, options?: CompileOptions): ApplicationIR;
|
|
36
|
+
/**
|
|
37
|
+
* Validates a graph against the same capabilities `compileToIR` compiles for by default —
|
|
38
|
+
* the real browser renderer and the real (empty) browser trigger runtime — without
|
|
39
|
+
* compiling it.
|
|
40
|
+
*
|
|
41
|
+
* `validateGraph(graph)` alone is deliberately target-neutral (spec 8.2 §2-4, §41 of spec5):
|
|
42
|
+
* a graph is never rejected for a renderer or trigger runtime nobody named, the same way
|
|
43
|
+
* `RendererCapabilities` was already optional before triggers existed. That means a bare
|
|
44
|
+
* `validateGraph(graph).valid === true` does not by itself say the graph is executable by a
|
|
45
|
+
* browser — a UI node kind no renderer draws, or a client-authority trigger kind the browser
|
|
46
|
+
* trigger runtime does not execute (`CLIENT_TRIGGER_UNSUPPORTED`), both validate silently
|
|
47
|
+
* under the no-options call. A consumer that wants a validate-only answer reflecting actual
|
|
48
|
+
* browser executability — without compiling the whole IR just to catch a thrown
|
|
49
|
+
* `GraphValidationError` — calls this instead; `compileToIR(graph)`'s own validation step is
|
|
50
|
+
* exactly this call, so the two never disagree.
|
|
51
|
+
*/
|
|
52
|
+
export declare function validateForBrowser(graph: ApplicationGraph, options?: Pick<CompileOptions, 'renderer' | 'triggerRuntime'>): ValidationResult;
|
|
30
53
|
export declare function serializeIR(ir: ApplicationIR): string;
|
|
31
54
|
//# sourceMappingURL=normalize.d.ts.map
|
package/dist/normalize.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { actionAuthority, actionGuards, authorityContext, inferExpressionType, inferLocationType, itemTypeOf, locationFieldIds, locationRootStateId, referencedIds, resolvePresentationMap, semanticContextFromGraph, stateAuthority, validateGraph, } from '@cynodia/axiom-core';
|
|
2
2
|
import { isUINode, stripAuthoringMetadata } from '@cynodia/axiom-core';
|
|
3
|
-
import { BROWSER_RENDERER_CAPABILITIES } from '@cynodia/axiom-runtime';
|
|
3
|
+
import { BROWSER_RENDERER_CAPABILITIES, BROWSER_TRIGGER_CAPABILITIES } from '@cynodia/axiom-runtime';
|
|
4
4
|
export class GraphValidationError extends Error {
|
|
5
5
|
problems;
|
|
6
6
|
constructor(result) {
|
|
@@ -41,6 +41,7 @@ export function compileToIR(graph, options = {}) {
|
|
|
41
41
|
if (options.validate !== false) {
|
|
42
42
|
const result = validateGraph(graph, {
|
|
43
43
|
renderer: options.renderer ?? BROWSER_RENDERER_CAPABILITIES,
|
|
44
|
+
triggerRuntime: options.triggerRuntime ?? BROWSER_TRIGGER_CAPABILITIES,
|
|
44
45
|
});
|
|
45
46
|
if (!result.valid) {
|
|
46
47
|
throw new GraphValidationError(result);
|
|
@@ -259,6 +260,28 @@ export function compileToIR(graph, options = {}) {
|
|
|
259
260
|
triggers,
|
|
260
261
|
};
|
|
261
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Validates a graph against the same capabilities `compileToIR` compiles for by default —
|
|
265
|
+
* the real browser renderer and the real (empty) browser trigger runtime — without
|
|
266
|
+
* compiling it.
|
|
267
|
+
*
|
|
268
|
+
* `validateGraph(graph)` alone is deliberately target-neutral (spec 8.2 §2-4, §41 of spec5):
|
|
269
|
+
* a graph is never rejected for a renderer or trigger runtime nobody named, the same way
|
|
270
|
+
* `RendererCapabilities` was already optional before triggers existed. That means a bare
|
|
271
|
+
* `validateGraph(graph).valid === true` does not by itself say the graph is executable by a
|
|
272
|
+
* browser — a UI node kind no renderer draws, or a client-authority trigger kind the browser
|
|
273
|
+
* trigger runtime does not execute (`CLIENT_TRIGGER_UNSUPPORTED`), both validate silently
|
|
274
|
+
* under the no-options call. A consumer that wants a validate-only answer reflecting actual
|
|
275
|
+
* browser executability — without compiling the whole IR just to catch a thrown
|
|
276
|
+
* `GraphValidationError` — calls this instead; `compileToIR(graph)`'s own validation step is
|
|
277
|
+
* exactly this call, so the two never disagree.
|
|
278
|
+
*/
|
|
279
|
+
export function validateForBrowser(graph, options = {}) {
|
|
280
|
+
return validateGraph(graph, {
|
|
281
|
+
renderer: options.renderer ?? BROWSER_RENDERER_CAPABILITIES,
|
|
282
|
+
triggerRuntime: options.triggerRuntime ?? BROWSER_TRIGGER_CAPABILITIES,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
262
285
|
export function serializeIR(ir) {
|
|
263
286
|
return JSON.stringify(ir);
|
|
264
287
|
}
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { actionAuthority, actionGuards, authorityContext, expressionDefsIn, isObservable, maxContract, requiredServerContract, serverIRExpressions, serverStateClosure, stateAuthority, usesIntegrationVocabulary, validateGraph, } from '@cynodia/axiom-core';
|
|
1
|
+
import { actionAuthority, actionGuards, authorityContext, expressionDefsIn, isObservable, maxContract, requiredServerContract, serverIRExpressions, serverStateClosure, stateAuthority, usesIntegrationVocabulary, usesInvocationVocabulary, usesV4Semantics, validateGraph, } from '@cynodia/axiom-core';
|
|
2
2
|
import { GraphValidationError } from './normalize.js';
|
|
3
3
|
/**
|
|
4
4
|
* Compiles the authoritative half of a graph.
|
|
@@ -131,7 +131,14 @@ export function compileToServerIR(graph, options = {}) {
|
|
|
131
131
|
* one that groups or names an expression, or uses any integration/trigger/event
|
|
132
132
|
* vocabulary, says so, because an older runtime could not execute it.
|
|
133
133
|
*/
|
|
134
|
-
const
|
|
134
|
+
const contractCandidates = [
|
|
135
|
+
carriesDefinitions || usesInvocationVocabulary(document)
|
|
136
|
+
? 'axiom.server.v2'
|
|
137
|
+
: requiredServerContract(serverIRExpressions(document)),
|
|
138
|
+
usesIntegrationVocabulary(document) ? 'axiom.server.v3' : 'axiom.server.v1',
|
|
139
|
+
usesV4Semantics(document) ? 'axiom.server.v4' : 'axiom.server.v1',
|
|
140
|
+
];
|
|
141
|
+
const contract = contractCandidates.reduce(maxContract);
|
|
135
142
|
return { contract, ...document };
|
|
136
143
|
}
|
|
137
144
|
export function serializeServerIR(ir) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cynodia/axiom-compiler",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-alpha.1",
|
|
4
4
|
"description": "Normalizes an Axiom application graph and emits a self-contained page.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AskTech AS",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@cynodia/axiom-core": "0.8.
|
|
35
|
-
"@cynodia/axiom-runtime": "0.8.
|
|
34
|
+
"@cynodia/axiom-core": "0.8.2-alpha.1",
|
|
35
|
+
"@cynodia/axiom-runtime": "0.8.2-alpha.1"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsc -b tsconfig.json tsconfig.test.json",
|