@cynodia/axiom-server 0.6.3-alpha.1 → 0.7.0-alpha.2
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/conformance/manifest.json +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server.js +25 -3
- package/package.json +3 -3
- package/schema/protocol.v1.schema.json +1 -1
- package/schema/server-ir.v1.schema.json +1 -1
- package/schema/server-ir.v2.schema.json +1441 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"conformance": "axiom.conformance.v1",
|
|
3
3
|
"contract": "axiom.server.v1",
|
|
4
4
|
"protocol": "axiom.protocol.v1",
|
|
5
|
-
"release": "0.
|
|
5
|
+
"release": "0.7.0-alpha.2",
|
|
6
6
|
"description": "Portable conformance fixtures for the Axiom Server IR. Each entry is a self-contained JSON document: the Server IR, the state to start from, the principals, the invocations to perform and the results required. Running them needs no part of this implementation.",
|
|
7
7
|
"areas": [
|
|
8
8
|
"action guards",
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* ApplicationGraph.
|
|
8
8
|
*/
|
|
9
9
|
export type { ServerIR, ServerIRContract } from '@cynodia/axiom-core';
|
|
10
|
-
export { SERVER_IR_CONTRACT, PRINCIPAL } from '@cynodia/axiom-core';
|
|
10
|
+
export { SERVER_IR_CONTRACT, SERVER_IR_CONTRACTS, SERVER_IR_LATEST_CONTRACT, PRINCIPAL, } from '@cynodia/axiom-core';
|
|
11
11
|
export * from './protocol.js';
|
|
12
12
|
export * from './persistence.js';
|
|
13
13
|
export * from './sqlite-persistence.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SERVER_IR_CONTRACT, PRINCIPAL } from '@cynodia/axiom-core';
|
|
1
|
+
export { SERVER_IR_CONTRACT, SERVER_IR_CONTRACTS, SERVER_IR_LATEST_CONTRACT, PRINCIPAL, } from '@cynodia/axiom-core';
|
|
2
2
|
export * from './protocol.js';
|
|
3
3
|
export * from './persistence.js';
|
|
4
4
|
export * from './sqlite-persistence.js';
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_THEME, PRINCIPAL,
|
|
1
|
+
import { DEFAULT_THEME, PRINCIPAL, SERVER_IR_CONTRACTS, optionalType, entityType, requiredServerContract, serverIRExpressions, validateValueAgainstType, } from '@cynodia/axiom-core';
|
|
2
2
|
import { MemoryElement, createAxiomRuntime, createMemoryHost, valuesEqual } from '@cynodia/axiom-runtime';
|
|
3
3
|
import { createMemoryPersistence } from './persistence.js';
|
|
4
4
|
import { createServerHost } from './host.js';
|
|
@@ -83,8 +83,15 @@ function disclosable(diagnostic) {
|
|
|
83
83
|
return { ...diagnostic, details };
|
|
84
84
|
}
|
|
85
85
|
export function createAxiomServer(options) {
|
|
86
|
-
if (options.ir.contract
|
|
87
|
-
throw new Error(`Unsupported Server IR contract "${String(options.ir.contract)}"; this runtime executes ${
|
|
86
|
+
if (!SERVER_IR_CONTRACTS.includes(String(options.ir.contract))) {
|
|
87
|
+
throw new Error(`Unsupported Server IR contract "${String(options.ir.contract)}"; this runtime executes ${SERVER_IR_CONTRACTS.join(', ')}`);
|
|
88
|
+
}
|
|
89
|
+
// A document may not claim a contract older than the vocabulary it uses. Executing it
|
|
90
|
+
// anyway would make the label meaningless, and the label is what another implementation
|
|
91
|
+
// decides by.
|
|
92
|
+
const understated = understatedContract(options.ir);
|
|
93
|
+
if (understated) {
|
|
94
|
+
throw new Error(`Server IR declares "${String(options.ir.contract)}" but uses ${understated} semantics; label it ${understated}`);
|
|
88
95
|
}
|
|
89
96
|
const ir = options.ir;
|
|
90
97
|
const persistence = options.persistence ?? createMemoryPersistence();
|
|
@@ -465,6 +472,20 @@ export function createAxiomServer(options) {
|
|
|
465
472
|
* runs the ordinary semantic engine over it. Nothing about transactions, constraints or
|
|
466
473
|
* iteration is reimplemented, which is the only way to guarantee the semantics match.
|
|
467
474
|
*/
|
|
475
|
+
/**
|
|
476
|
+
* The contract a document needs, when that is newer than the one it declares.
|
|
477
|
+
*
|
|
478
|
+
* The check runs in the direction that matters: a v2 runtime executing a document labelled
|
|
479
|
+
* v1 would accept vocabulary a v1 runtime elsewhere would refuse, and the two would then
|
|
480
|
+
* disagree about the same file.
|
|
481
|
+
*/
|
|
482
|
+
function understatedContract(ir) {
|
|
483
|
+
const required = ir.expressionDefs
|
|
484
|
+
? 'axiom.server.v2'
|
|
485
|
+
: requiredServerContract(serverIRExpressions(ir));
|
|
486
|
+
const order = SERVER_IR_CONTRACTS;
|
|
487
|
+
return order.indexOf(required) > order.indexOf(String(ir.contract)) ? required : undefined;
|
|
488
|
+
}
|
|
468
489
|
function buildRuntime(ir, host) {
|
|
469
490
|
const nodes = {};
|
|
470
491
|
for (const entity of ir.entities) {
|
|
@@ -509,6 +530,7 @@ function buildRuntime(ir, host) {
|
|
|
509
530
|
uiNodes: {},
|
|
510
531
|
constraints: ir.constraints,
|
|
511
532
|
transitionConstraints: ir.transitionConstraints,
|
|
533
|
+
expressionDefs: ir.expressionDefs ?? {},
|
|
512
534
|
routes: [],
|
|
513
535
|
edges: [],
|
|
514
536
|
locationTypes: {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cynodia/axiom-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.2",
|
|
4
4
|
"description": "Authoritative server runtime that executes an Axiom Server IR.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AskTech AS",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"./schema/*": "./schema/*"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cynodia/axiom-core": "0.
|
|
40
|
-
"@cynodia/axiom-runtime": "0.
|
|
39
|
+
"@cynodia/axiom-core": "0.7.0-alpha.2",
|
|
40
|
+
"@cynodia/axiom-runtime": "0.7.0-alpha.2"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsc -b tsconfig.json tsconfig.test.json",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"title": "Axiom semantic protocol v1",
|
|
5
5
|
"description": "What a client may send an authority and what it may receive back. A client requests semantic operations — \"invoke action X with arguments Y\" — never a mutation program. Nothing here mentions a transport.",
|
|
6
6
|
"contract": "axiom.protocol.v1",
|
|
7
|
-
"release": "0.
|
|
7
|
+
"release": "0.7.0-alpha.2",
|
|
8
8
|
"oneOf": [
|
|
9
9
|
{
|
|
10
10
|
"$ref": "#/$defs/ServerRequest"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"title": "Axiom Server IR v1",
|
|
5
5
|
"description": "The normative structure of an `axiom.server.v1` document. Structure only: what a conforming runtime must *do* with it is the semantic contract, and the conformance fixtures are the executable statement of that.",
|
|
6
6
|
"contract": "axiom.server.v1",
|
|
7
|
-
"release": "0.
|
|
7
|
+
"release": "0.7.0-alpha.2",
|
|
8
8
|
"type": "object",
|
|
9
9
|
"required": [
|
|
10
10
|
"contract",
|