@aventara/core 0.1.0-pilot.4 → 1.0.0-rc.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 +1478 -0
- package/README.md +275 -11
- package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
- package/dist/adapters/adapter-field.d.ts +11 -11
- package/dist/adapters/adapter-identifier.d.ts +6 -6
- package/dist/adapters/adapter-model.d.ts +17 -9
- package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
- package/dist/adapters/adapter-operation.d.ts +3 -3
- package/dist/adapters/adapter-resource.d.ts +18 -9
- package/dist/adapters/adapter-sql-statement.d.ts +19 -0
- package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
- package/dist/adapters/adapter.interface.d.ts +49 -25
- package/dist/avz/avz-check.factory.d.ts +83 -0
- package/dist/avz/avz-check.factory.js +116 -0
- package/dist/avz/avz-check.registry.d.ts +35 -0
- package/dist/avz/avz-check.registry.js +9 -0
- package/dist/avz/avz.d.ts +203 -0
- package/dist/avz/avz.js +354 -0
- package/dist/avz/index.d.ts +7 -0
- package/dist/avz/index.js +1 -0
- package/dist/avz/json-shape.registry.d.ts +22 -0
- package/dist/avz/json-shape.registry.js +16 -0
- package/dist/avz/zod-issue.translator.d.ts +57 -0
- package/dist/avz/zod-issue.translator.js +149 -0
- package/dist/compiler/contract-compiler-diagnostic.d.ts +37 -5
- package/dist/compiler/contract.compiler.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +595 -421
- package/dist/compiler/create-requirements.projector.d.ts +49 -0
- package/dist/compiler/create-requirements.projector.js +423 -0
- package/dist/compiler/field-validator.compiler.d.ts +47 -0
- package/dist/compiler/field-validator.compiler.js +238 -0
- package/dist/config/any-framework-config.d.ts +19 -12
- package/dist/config/config-diagnostic.d.ts +11 -4
- package/dist/config/config-layer.d.ts +15 -6
- package/dist/config/config.resolver.d.ts +75 -29
- package/dist/config/config.resolver.js +109 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +586 -71
- package/dist/config/define-resource.d.ts +57 -0
- package/dist/config/define-resource.js +14 -0
- package/dist/config/effective-fields.d.ts +19 -23
- package/dist/config/entrypoint.normalizer.d.ts +1 -1
- package/dist/config/exact-framework-config.d.ts +280 -0
- package/dist/config/field-compute.resolver.d.ts +19 -0
- package/dist/config/field-compute.resolver.js +115 -0
- package/dist/config/field-pipeline-config.d.ts +47 -0
- package/dist/config/forced-operation.validator.d.ts +10 -0
- package/dist/config/forced-operation.validator.js +66 -0
- package/dist/config/framework-config.d.ts +111 -37
- package/dist/config/framework-exemptions-config.d.ts +91 -0
- package/dist/config/framework-exemptions-config.js +1 -0
- package/dist/config/framework-field-definition.d.ts +78 -0
- package/dist/config/framework-field-definition.js +28 -0
- package/dist/config/framework-resources-config.d.ts +116 -0
- package/dist/config/framework-resources-config.js +1 -0
- package/dist/config/pipeline-config.d.ts +56 -20
- package/dist/config/pipeline-tree.resolver.d.ts +79 -0
- package/dist/config/pipeline-tree.resolver.js +220 -0
- package/dist/config/stage-type.eraser.d.ts +65 -0
- package/dist/config/stage-type.eraser.js +1 -0
- package/dist/contracts/capability.d.ts +11 -11
- package/dist/contracts/client-contract-structure.validator.d.ts +344 -29
- package/dist/contracts/client-contract-structure.validator.js +248 -7
- package/dist/contracts/contract-canonicalizer.d.ts +19 -3
- package/dist/contracts/contract-canonicalizer.js +172 -27
- package/dist/contracts/contract-hash.d.ts +12 -7
- package/dist/contracts/contract-hash.js +3 -2
- package/dist/contracts/contract-limits.d.ts +4 -1
- package/dist/contracts/contract-limits.js +1 -0
- package/dist/contracts/contract-lookup.d.ts +5 -5
- package/dist/contracts/contract-protocol.d.ts +4 -4
- package/dist/contracts/contract.d.ts +31 -16
- package/dist/contracts/create-requirements.d.ts +35 -0
- package/dist/contracts/create-requirements.js +1 -0
- package/dist/contracts/enum-definition.d.ts +1 -1
- package/dist/contracts/field-check.d.ts +101 -0
- package/dist/contracts/field-check.js +1 -0
- package/dist/contracts/field.d.ts +61 -41
- package/dist/contracts/identifier.d.ts +4 -4
- package/dist/contracts/json-shape.d.ts +76 -0
- package/dist/contracts/json-shape.js +1 -0
- package/dist/contracts/lifecycle-trait.d.ts +2 -2
- package/dist/contracts/reference-write-limit.d.ts +7 -0
- package/dist/contracts/reference-write-limit.js +1 -0
- package/dist/contracts/resource-operations.d.ts +28 -28
- package/dist/contracts/resource.d.ts +15 -9
- package/dist/contracts/scalar-value-type.d.ts +25 -14
- package/dist/contracts/scalar.d.ts +3 -3
- package/dist/contracts/transaction-capability.d.ts +1 -1
- package/dist/contracts/wire-scalar-format.d.ts +4 -4
- package/dist/framework/contract-view.d.ts +234 -63
- package/dist/framework/framework-construction.error.d.ts +10 -10
- package/dist/framework/framework-construction.error.js +2 -2
- package/dist/framework/framework.d.ts +50 -24
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +95 -32
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +55 -82
- package/dist/index.js +6 -26
- package/dist/internal.d.ts +40 -0
- package/dist/internal.js +18 -0
- package/dist/operations/operation-arguments.d.ts +316 -201
- package/dist/operations/operation-call.d.ts +27 -28
- package/dist/operations/operation-identity.d.ts +12 -10
- package/dist/operations/operation-identity.js +3 -0
- package/dist/operations/operation-result.d.ts +21 -21
- package/dist/operations/operation-validator-core.d.ts +6 -6
- package/dist/operations/operation-validator-core.js +41 -12
- package/dist/operations/operation-validator.d.ts +24 -9
- package/dist/operations/operation-validator.js +26 -10
- package/dist/operations/projection-scope.resolver.d.ts +7 -7
- package/dist/operations/structural-limits.walker.d.ts +19 -0
- package/dist/operations/structural-limits.walker.js +489 -0
- package/dist/operations/validation-code.d.ts +11 -6
- package/dist/operations/validation-code.js +4 -0
- package/dist/operations/write-scope.resolver.d.ts +6 -6
- package/dist/protocol/absent-route.responder.d.ts +13 -11
- package/dist/protocol/absent-route.responder.js +42 -16
- package/dist/protocol/contract-document.responder.d.ts +3 -3
- package/dist/protocol/contract-document.responder.js +2 -2
- package/dist/protocol/http-request.decoder.d.ts +23 -13
- package/dist/protocol/http-request.decoder.js +19 -11
- package/dist/protocol/http-request.reader.d.ts +3 -3
- package/dist/protocol/http-response.encoder.d.ts +4 -4
- package/dist/protocol/http-response.encoder.js +94 -55
- package/dist/protocol/http-status.table.d.ts +2 -2
- package/dist/protocol/operation-response.guard.d.ts +2 -2
- package/dist/protocol/protocol-surface.d.ts +4 -4
- package/dist/protocol/protocol.binder.d.ts +52 -27
- package/dist/protocol/protocol.binder.js +14 -9
- package/dist/protocol/protocol.handler.d.ts +28 -15
- package/dist/protocol/protocol.handler.js +55 -10
- package/dist/protocol/unmounted-route.error.d.ts +19 -0
- package/dist/protocol/unmounted-route.error.js +10 -0
- package/dist/runtime/caller-data.copier.d.ts +59 -0
- package/dist/runtime/caller-data.copier.js +470 -0
- package/dist/runtime/caller-data.door.d.ts +56 -0
- package/dist/runtime/caller-data.door.js +67 -0
- package/dist/runtime/computed-read-runtime.d.ts +7 -6
- package/dist/runtime/computed-read-runtime.js +61 -55
- package/dist/runtime/computed-value.error.d.ts +13 -0
- package/dist/runtime/computed-value.error.js +9 -0
- package/dist/runtime/context-executor.runtime.d.ts +59 -0
- package/dist/runtime/context-executor.runtime.js +275 -0
- package/dist/runtime/create-requirement.d.ts +22 -57
- package/dist/runtime/create-requirement.js +140 -37
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +64 -22
- package/dist/runtime/diagnostics-reporter.js +35 -4
- package/dist/runtime/error-boundary.d.ts +73 -8
- package/dist/runtime/error-boundary.js +104 -48
- package/dist/runtime/execution-options.d.ts +10 -2
- package/dist/runtime/field-check.evaluator.d.ts +29 -0
- package/dist/runtime/field-check.evaluator.js +521 -0
- package/dist/runtime/field-compute.d.ts +64 -0
- package/dist/runtime/field-compute.js +1 -0
- package/dist/runtime/field-stage.plan.d.ts +15 -0
- package/dist/runtime/field-stage.plan.js +27 -0
- package/dist/runtime/field-stage.runtime.d.ts +35 -0
- package/dist/runtime/field-stage.runtime.js +143 -0
- package/dist/runtime/field-validator.runtime.d.ts +11 -0
- package/dist/runtime/field-validator.runtime.js +87 -0
- package/dist/runtime/framework-error-class.table.d.ts +33 -0
- package/dist/runtime/framework-error-class.table.js +25 -0
- package/dist/runtime/framework-error.d.ts +79 -7
- package/dist/runtime/framework-error.factory.d.ts +4 -0
- package/dist/runtime/framework-error.factory.js +15 -0
- package/dist/runtime/framework-error.js +23 -2
- package/dist/runtime/interceptor-next.error.d.ts +5 -0
- package/dist/runtime/interceptor-next.error.js +6 -0
- package/dist/runtime/json-value.d.ts +3 -3
- package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
- package/dist/runtime/level-lifecycle.runtime.js +42 -0
- package/dist/runtime/misuse-reporter.d.ts +32 -0
- package/dist/runtime/misuse-reporter.js +19 -0
- package/dist/runtime/mutation-planner.d.ts +19 -10
- package/dist/runtime/mutation-planner.js +62 -36
- package/dist/runtime/nested-write.walker.d.ts +32 -0
- package/dist/runtime/nested-write.walker.js +73 -0
- package/dist/runtime/operation-request.d.ts +35 -15
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +125 -30
- package/dist/runtime/operation-runtime.js +423 -83
- package/dist/runtime/outcome-mapper.d.ts +16 -5
- package/dist/runtime/outcome-mapper.js +35 -8
- package/dist/runtime/output-validator.d.ts +16 -6
- package/dist/runtime/output-validator.js +12 -1
- package/dist/runtime/owned-execution.registry.d.ts +13 -0
- package/dist/runtime/owned-execution.registry.js +7 -0
- package/dist/runtime/pipe-output.validator.d.ts +33 -18
- package/dist/runtime/pipe-output.validator.js +12 -12
- package/dist/runtime/pipeline.d.ts +202 -28
- package/dist/runtime/readonly-value.d.ts +32 -0
- package/dist/runtime/readonly-value.js +141 -0
- package/dist/runtime/referential-action.d.ts +7 -0
- package/dist/runtime/request-envelope.validator.d.ts +5 -0
- package/dist/runtime/request-envelope.validator.js +123 -0
- package/dist/runtime/request-id.d.ts +1 -1
- package/dist/runtime/request-state.d.ts +14 -0
- package/dist/runtime/request-state.js +1 -0
- package/dist/runtime/request-state.resolver.d.ts +12 -0
- package/dist/runtime/request-state.resolver.js +20 -0
- package/dist/runtime/scalar-runtime.d.ts +56 -13
- package/dist/runtime/scalar-runtime.js +167 -86
- package/dist/transactions/deferred-operation.d.ts +35 -20
- package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
- package/dist/transactions/operation-arguments-encoder.js +2 -2
- package/dist/transactions/sql-statement.d.ts +77 -0
- package/dist/transactions/sql-statement.js +47 -0
- package/dist/transactions/sql-statement.validator.d.ts +44 -0
- package/dist/transactions/sql-statement.validator.js +134 -0
- package/dist/transactions/transaction-envelope.d.ts +4 -4
- package/dist/transactions/transaction-integrity-error.d.ts +6 -6
- package/dist/transactions/transaction-integrity-error.js +5 -2
- package/dist/transactions/transaction-plan-assembler.d.ts +23 -9
- package/dist/transactions/transaction-plan-assembler.js +195 -82
- package/dist/transactions/transaction-plan-validator.d.ts +53 -21
- package/dist/transactions/transaction-plan-validator.js +246 -163
- package/dist/transactions/transaction-reference-collector.d.ts +30 -0
- package/dist/transactions/transaction-reference-collector.js +204 -0
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +27 -10
- package/dist/transactions/transaction-reference-validator.d.ts +34 -4
- package/dist/transactions/transaction-reference-validator.js +82 -43
- package/dist/transactions/transaction-reference.d.ts +30 -58
- package/dist/transactions/transaction-request.d.ts +20 -7
- package/dist/transactions/transaction-response.d.ts +12 -7
- package/dist/transactions/transaction-response.js +24 -1
- package/dist/transactions/transaction-runtime.d.ts +11 -8
- package/dist/transactions/transaction-runtime.js +167 -50
- package/dist/transactions/transaction-settlement.runtime.d.ts +51 -0
- package/dist/transactions/transaction-settlement.runtime.js +120 -0
- package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
- package/dist/transactions/transaction-slot-path-error.js +2 -2
- package/dist/transactions/transaction-slot-writer.js +2 -2
- package/dist/transactions/transaction-stage.runtime.d.ts +81 -0
- package/dist/transactions/transaction-stage.runtime.js +123 -0
- package/package.json +18 -3
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -35
- package/dist/config/define-fields.js +0 -3
- package/dist/config/framework-behaviors-config.d.ts +0 -30
- package/dist/config/framework-fields-config.d.ts +0 -36
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/operations/operation-boolean-nodes.d.ts +0 -11
- package/dist/operations/operation-boolean-nodes.js +0 -283
- package/dist/operations/operation-nesting.d.ts +0 -8
- package/dist/operations/operation-nesting.js +0 -307
- package/dist/runtime/field-behavior.d.ts +0 -48
- /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
- /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
- /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
- /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lookupField, lookupResource } from "../contracts/contract-lookup.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { normalizeScalarFieldValue } from "./scalar-runtime.js";
|
|
2
|
+
import { AvComputedValueError } from "./computed-value.error.js";
|
|
3
|
+
import { replaceAt, valueAt } from "./field-stage.runtime.js";
|
|
4
|
+
import { jsonShapeIssues, normalizeScalarFieldValue, } from "./scalar-runtime.js";
|
|
5
5
|
function writeScalarField(contracts, resourceName, fieldName) {
|
|
6
6
|
const field = lookupField(lookupResource(contracts.core, resourceName), fieldName) ??
|
|
7
7
|
lookupField(lookupResource(contracts.active, resourceName), fieldName);
|
|
@@ -34,13 +34,7 @@ function cloneRecord(value) {
|
|
|
34
34
|
function relationEntries(value) {
|
|
35
35
|
return Array.isArray(value) ? value : [value];
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
throw new FrameworkError("A3000", {
|
|
39
|
-
message: INTERNAL_FAILURE_MESSAGE,
|
|
40
|
-
issues,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async function computeRecord(contracts, behaviors, request, resourceName, stage, data, contextFactory) {
|
|
37
|
+
async function computeRecord(contracts, compute, resourceName, stage, data, contextFactory) {
|
|
44
38
|
if (!isRecord(data)) {
|
|
45
39
|
return data;
|
|
46
40
|
}
|
|
@@ -49,13 +43,13 @@ async function computeRecord(contracts, behaviors, request, resourceName, stage,
|
|
|
49
43
|
return data;
|
|
50
44
|
}
|
|
51
45
|
const logicalData = cloneRecord(data);
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
for (const [fieldName,
|
|
55
|
-
if (
|
|
46
|
+
const resourceCompute = compute[resourceName];
|
|
47
|
+
if (resourceCompute !== undefined) {
|
|
48
|
+
for (const [fieldName, fieldCompute] of Object.entries(resourceCompute)) {
|
|
49
|
+
if (fieldCompute === undefined) {
|
|
56
50
|
continue;
|
|
57
51
|
}
|
|
58
|
-
const callback =
|
|
52
|
+
const callback = fieldCompute[stage];
|
|
59
53
|
if (typeof callback !== "function") {
|
|
60
54
|
continue;
|
|
61
55
|
}
|
|
@@ -63,31 +57,43 @@ async function computeRecord(contracts, behaviors, request, resourceName, stage,
|
|
|
63
57
|
if (field === undefined) {
|
|
64
58
|
continue;
|
|
65
59
|
}
|
|
60
|
+
const snapshot = Object.freeze({ ...logicalData });
|
|
66
61
|
const computed = await callback({
|
|
67
|
-
scope: request.scope,
|
|
68
|
-
resource: resourceName,
|
|
69
62
|
field: fieldName,
|
|
70
|
-
value:
|
|
71
|
-
data:
|
|
72
|
-
|
|
63
|
+
value: snapshot[fieldName],
|
|
64
|
+
data: snapshot,
|
|
65
|
+
ctx: contextFactory(snapshot),
|
|
73
66
|
});
|
|
74
67
|
if (computed === undefined) {
|
|
75
68
|
continue;
|
|
76
69
|
}
|
|
77
|
-
const validation = normalizeScalarFieldValue(contracts.core, field, computed, "runtime", [
|
|
70
|
+
const validation = normalizeScalarFieldValue(contracts.core, field, computed, "runtime", [
|
|
71
|
+
"resources",
|
|
72
|
+
resourceName,
|
|
73
|
+
"fields",
|
|
74
|
+
fieldName,
|
|
75
|
+
"pipelines",
|
|
76
|
+
"compute",
|
|
77
|
+
stage,
|
|
78
|
+
]);
|
|
78
79
|
if (!validation.ok) {
|
|
79
|
-
|
|
80
|
+
throw new AvComputedValueError(resourceName, fieldName, stage, validation.issues);
|
|
81
|
+
}
|
|
82
|
+
const shapeIssues = jsonShapeIssues(field, validation.value, [
|
|
83
|
+
"resources",
|
|
84
|
+
resourceName,
|
|
85
|
+
"fields",
|
|
86
|
+
fieldName,
|
|
87
|
+
"pipelines",
|
|
88
|
+
"compute",
|
|
89
|
+
stage,
|
|
90
|
+
]);
|
|
91
|
+
if (shapeIssues.length > 0) {
|
|
92
|
+
throw new AvComputedValueError(resourceName, fieldName, stage, shapeIssues);
|
|
80
93
|
}
|
|
81
94
|
logicalData[fieldName] = validation.value;
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
|
-
for (const [fieldName, value] of Object.entries(logicalData)) {
|
|
85
|
-
const field = lookupField(resource, fieldName);
|
|
86
|
-
if (field?.kind !== "relation") {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
logicalData[fieldName] = await mapRelationMutationRecords(field, value, (targetResource, nestedStage, record) => computeRecord(contracts, behaviors, request, targetResource, nestedStage, record, contextFactory));
|
|
90
|
-
}
|
|
91
97
|
return logicalData;
|
|
92
98
|
}
|
|
93
99
|
async function mapRelationMutationRecords(relation, value, leaf) {
|
|
@@ -123,29 +129,49 @@ async function mapRelationMutationRecords(relation, value, leaf) {
|
|
|
123
129
|
}
|
|
124
130
|
return normalized;
|
|
125
131
|
}
|
|
126
|
-
export async function
|
|
127
|
-
if (
|
|
132
|
+
export async function applyWriteCompute(contracts, compute, request, args, contextFactory) {
|
|
133
|
+
if (compute === undefined || !isRecord(args)) {
|
|
128
134
|
return args;
|
|
129
135
|
}
|
|
130
136
|
const logicalArgs = cloneRecord(args);
|
|
131
137
|
if (request.family === "create" && "data" in logicalArgs) {
|
|
132
138
|
logicalArgs.data = Array.isArray(logicalArgs.data)
|
|
133
|
-
? await Promise.all(logicalArgs.data.map((entry) => computeRecord(contracts,
|
|
134
|
-
: await computeRecord(contracts,
|
|
139
|
+
? await Promise.all(logicalArgs.data.map((entry) => computeRecord(contracts, compute, request.resource, "create", entry, contextFactory)))
|
|
140
|
+
: await computeRecord(contracts, compute, request.resource, "create", logicalArgs.data, contextFactory);
|
|
135
141
|
}
|
|
136
142
|
if (request.family === "update" && "data" in logicalArgs) {
|
|
137
|
-
logicalArgs.data = await computeRecord(contracts,
|
|
143
|
+
logicalArgs.data = await computeRecord(contracts, compute, request.resource, "update", logicalArgs.data, contextFactory);
|
|
138
144
|
}
|
|
139
145
|
if (request.family === "upsert") {
|
|
140
146
|
if ("create" in logicalArgs) {
|
|
141
|
-
logicalArgs.create = await computeRecord(contracts,
|
|
147
|
+
logicalArgs.create = await computeRecord(contracts, compute, request.resource, "create", logicalArgs.create, contextFactory);
|
|
142
148
|
}
|
|
143
149
|
if ("update" in logicalArgs) {
|
|
144
|
-
logicalArgs.update = await computeRecord(contracts,
|
|
150
|
+
logicalArgs.update = await computeRecord(contracts, compute, request.resource, "update", logicalArgs.update, contextFactory);
|
|
145
151
|
}
|
|
146
152
|
}
|
|
147
153
|
return logicalArgs;
|
|
148
154
|
}
|
|
155
|
+
export async function applyNestedWriteCompute(contracts, compute, args, targets, context) {
|
|
156
|
+
if (compute === undefined) {
|
|
157
|
+
return args;
|
|
158
|
+
}
|
|
159
|
+
let current = args;
|
|
160
|
+
for (const target of targets) {
|
|
161
|
+
if (!Object.hasOwn(compute, target.resource)) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
for (const site of target.records) {
|
|
165
|
+
const record = valueAt(current, site.path);
|
|
166
|
+
if (!isRecord(record)) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const computed = await computeRecord(contracts, compute, target.resource, site.stage, record, () => context(target, valueAt(current, target.path)));
|
|
170
|
+
current = replaceAt(current, site.path, computed);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return current;
|
|
174
|
+
}
|
|
149
175
|
async function stripVirtualRecord(contracts, resourceName, data) {
|
|
150
176
|
if (!isRecord(data)) {
|
|
151
177
|
return data;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AvContract } from "../contracts/contract.js";
|
|
2
|
+
import type { AvOperationIdentity } from "../operations/operation-identity.js";
|
|
3
|
+
import { type Path } from "./field-stage.runtime.js";
|
|
4
|
+
import type { ReferentialActionTable } from "./referential-action.js";
|
|
5
|
+
/** The family a nested target's stages are told, and its guards are drawn from. */
|
|
6
|
+
export type NestedTargetFamily = "create" | "update" | "delete";
|
|
7
|
+
/** One record of a nested target's data, and the write phase it is. */
|
|
8
|
+
export type NestedRecordSite = {
|
|
9
|
+
/** Where the record sits in the operation's arguments. */
|
|
10
|
+
readonly path: Path;
|
|
11
|
+
/** `create` for a created row (an `$upsert`'s `create` branch too), `update` otherwise. */
|
|
12
|
+
readonly stage: "create" | "update";
|
|
13
|
+
};
|
|
14
|
+
/** One nested write's target, in data order. */
|
|
15
|
+
export type NestedWriteTarget = {
|
|
16
|
+
/** The target Resource. */
|
|
17
|
+
readonly resource: string;
|
|
18
|
+
readonly family: NestedTargetFamily;
|
|
19
|
+
/** Where the directive's entry — the nested payload — sits in the arguments. */
|
|
20
|
+
readonly path: Path;
|
|
21
|
+
/** The entry's data records the target's field stages run on. */
|
|
22
|
+
readonly records: readonly NestedRecordSite[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Every nested write target in an operation's arguments, depth first in data
|
|
26
|
+
* order: a target comes before the targets inside its own data, and before the
|
|
27
|
+
* next directive's. Empty for an operation with no write data. Total over
|
|
28
|
+
* malformed input.
|
|
29
|
+
*/
|
|
30
|
+
export declare function nestedWriteTargetsOf(contract: AvContract, references: ReferentialActionTable, request: AvOperationIdentity & {
|
|
31
|
+
readonly resource: string;
|
|
32
|
+
}, args: unknown): readonly NestedWriteTarget[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { lookupField, lookupResource } from "../contracts/contract-lookup.js";
|
|
2
|
+
import { isPlainRecord, valueAt, writeRecordPathsOf, } from "./field-stage.runtime.js";
|
|
3
|
+
import { isRelationMutationDirective, RELATION_MUTATION_RECORD_SITES, } from "./mutation-planner.js";
|
|
4
|
+
const DIRECTIVE_FAMILY = {
|
|
5
|
+
$create: "create",
|
|
6
|
+
$connectOrCreate: "create",
|
|
7
|
+
$update: "update",
|
|
8
|
+
$upsert: "update",
|
|
9
|
+
$delete: "delete",
|
|
10
|
+
$connect: "relation",
|
|
11
|
+
$disconnect: "relation",
|
|
12
|
+
$set: "relation",
|
|
13
|
+
};
|
|
14
|
+
function holdsReference(references, resource, relation) {
|
|
15
|
+
const edges = Object.hasOwn(references, resource)
|
|
16
|
+
? references[resource]
|
|
17
|
+
: undefined;
|
|
18
|
+
return (Array.isArray(edges) &&
|
|
19
|
+
edges.some((edge) => edge.field === relation));
|
|
20
|
+
}
|
|
21
|
+
function walkRecord(context, resource, path, record) {
|
|
22
|
+
if (!isPlainRecord(record)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const owner = lookupResource(context.contract, resource);
|
|
26
|
+
for (const [key, value] of Object.entries(record)) {
|
|
27
|
+
const field = lookupField(owner, key);
|
|
28
|
+
if (field?.kind !== "relation" || !isPlainRecord(value)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
for (const [directive, operand] of Object.entries(value)) {
|
|
32
|
+
if (!isRelationMutationDirective(directive)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const mapped = DIRECTIVE_FAMILY[directive];
|
|
36
|
+
if (mapped === "relation" &&
|
|
37
|
+
field.cardinality === "one" &&
|
|
38
|
+
holdsReference(context.references, resource, key)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const family = mapped === "relation" ? "update" : mapped;
|
|
42
|
+
const entries = directive !== "$set" && Array.isArray(operand)
|
|
43
|
+
? operand.map((_entry, index) => [index])
|
|
44
|
+
: [[]];
|
|
45
|
+
for (const at of entries) {
|
|
46
|
+
const entryPath = [...path, key, directive, ...at];
|
|
47
|
+
const records = [];
|
|
48
|
+
for (const site of RELATION_MUTATION_RECORD_SITES[directive]) {
|
|
49
|
+
const sitePath = site.key === undefined ? entryPath : [...entryPath, site.key];
|
|
50
|
+
if (isPlainRecord(valueAt(record, sitePath.slice(path.length)))) {
|
|
51
|
+
records.push({ path: sitePath, stage: site.stage });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
context.targets.push({
|
|
55
|
+
resource: field.target,
|
|
56
|
+
family,
|
|
57
|
+
path: entryPath,
|
|
58
|
+
records,
|
|
59
|
+
});
|
|
60
|
+
for (const site of records) {
|
|
61
|
+
walkRecord(context, field.target, site.path, valueAt(record, site.path.slice(path.length)));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function nestedWriteTargetsOf(contract, references, request, args) {
|
|
68
|
+
const context = { contract, references, targets: [] };
|
|
69
|
+
for (const path of writeRecordPathsOf(request.family, args)) {
|
|
70
|
+
walkRecord(context, request.resource, path, valueAt(args, path));
|
|
71
|
+
}
|
|
72
|
+
return context.targets;
|
|
73
|
+
}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { AvOperationIdentity } from "../operations/operation-identity.js";
|
|
2
|
+
import type { AvTransportContext } from "./pipeline.js";
|
|
3
|
+
import type { AvState } from "./request-state.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `ConfigLayer`; kept as an alias so existing consumers keep compiling.
|
|
5
|
+
* The protocol version and Contract hash a remote caller says it was built for:
|
|
6
|
+
* the Client Contract's for a client, the Agent Contract's for an agent.
|
|
8
7
|
*/
|
|
9
|
-
export type OperationScope = RequestOrigin;
|
|
10
|
-
/** The protocol version and ClientContract hash a client says it was built for. */
|
|
11
8
|
export type ClientProtocolIdentity = {
|
|
12
9
|
readonly version: number;
|
|
13
10
|
readonly hash: string;
|
|
14
11
|
};
|
|
15
|
-
type RuntimeOperationBase =
|
|
12
|
+
type RuntimeOperationBase = AvOperationIdentity & {
|
|
16
13
|
readonly resource: string;
|
|
17
14
|
readonly arguments: unknown;
|
|
18
15
|
readonly requestId: string;
|
|
16
|
+
/**
|
|
17
|
+
* The request's `ctx.$state`: every stage of it, and every ctx call they make,
|
|
18
|
+
* shares this one object. Omitted, it is a fresh `{}`.
|
|
19
|
+
*/
|
|
20
|
+
readonly state?: AvState;
|
|
19
21
|
};
|
|
20
22
|
/** An in-process request, run under the Application Contract. */
|
|
21
23
|
export type ApplicationOperationRequest = RuntimeOperationBase & {
|
|
22
|
-
readonly
|
|
24
|
+
readonly origin: "application";
|
|
23
25
|
readonly protocol?: never;
|
|
24
26
|
readonly transport?: never;
|
|
25
27
|
};
|
|
@@ -28,20 +30,38 @@ export type ApplicationOperationRequest = RuntimeOperationBase & {
|
|
|
28
30
|
* the client sent.
|
|
29
31
|
*/
|
|
30
32
|
export type ClientOperationRequest = RuntimeOperationBase & {
|
|
31
|
-
readonly
|
|
33
|
+
readonly origin: "client";
|
|
32
34
|
readonly protocol: ClientProtocolIdentity;
|
|
33
|
-
readonly transport?:
|
|
35
|
+
readonly transport?: AvTransportContext;
|
|
34
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* An AI agent's request, run under the Agent Contract; `protocol` is the
|
|
39
|
+
* identity of the Agent Contract the caller (an MCP server) was built from.
|
|
40
|
+
*/
|
|
41
|
+
export type AgentOperationRequest = RuntimeOperationBase & {
|
|
42
|
+
readonly origin: "agent";
|
|
43
|
+
readonly protocol: ClientProtocolIdentity;
|
|
44
|
+
readonly transport?: AvTransportContext;
|
|
45
|
+
};
|
|
46
|
+
/** A request from outside the server: a client's or an agent's. */
|
|
47
|
+
export type RemoteOperationRequest = ClientOperationRequest | AgentOperationRequest;
|
|
35
48
|
/** One operation request, as `framework.execute` takes it. */
|
|
36
|
-
export type FrameworkOperationRequest = ApplicationOperationRequest | ClientOperationRequest;
|
|
49
|
+
export type FrameworkOperationRequest = ApplicationOperationRequest | ClientOperationRequest | AgentOperationRequest;
|
|
37
50
|
type WithoutArguments<Request> = Request extends unknown ? Omit<Request, "arguments"> : never;
|
|
38
51
|
/**
|
|
39
52
|
* A request as every stage after the Framework Validation Layer sees it:
|
|
40
|
-
* identity,
|
|
53
|
+
* identity, origin, request id and transport, but never `arguments`. Those
|
|
41
54
|
* stages act on the validated arguments passed beside it; the unvalidated
|
|
42
55
|
* view — inside a transaction plan still carrying `$ref` placeholders — is
|
|
43
|
-
* unreachable by type. Distributive, so the
|
|
56
|
+
* unreachable by type. Distributive, so the origin and family/variant
|
|
44
57
|
* correlations survive the omission.
|
|
45
58
|
*/
|
|
46
59
|
export type OperationExecutionRequest = WithoutArguments<FrameworkOperationRequest>;
|
|
60
|
+
/**
|
|
61
|
+
* A request whose stages run: its `state` settled once, the seed or the `{}`
|
|
62
|
+
* the runtime made for it, so every stage is told the same object.
|
|
63
|
+
*/
|
|
64
|
+
export type StatefulOperationRequest = OperationExecutionRequest & {
|
|
65
|
+
readonly state: AvState;
|
|
66
|
+
};
|
|
47
67
|
export {};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AvValidationIssue } from "../operations/validation-code.js";
|
|
2
2
|
/** Every outcome code, as a runtime list. */
|
|
3
3
|
export declare const OPERATION_CODES: readonly ["A1000", "A1001", "A1002", "A1003", "A1004", "A1005", "A1006", "A1007", "A1008", "A1009", "A2000", "A2001", "A2002", "A2003", "A2004", "A2005", "A2006", "A2007", "A2008", "A2009", "A2010", "A2011", "A2012", "A2013", "A2014", "A3000", "A3001", "A3002", "A3003", "A3004", "A4000", "A4001", "A4002"];
|
|
4
4
|
/**
|
|
5
5
|
* Every outcome code: `A1xxx` success, `A2xxx` caller error, `A3xxx` internal
|
|
6
6
|
* failure, `A4xxx` authentication or permission denial.
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
8
|
+
export type AvOperationCode = (typeof OPERATION_CODES)[number];
|
|
9
9
|
/** The success codes, `A1xxx`. */
|
|
10
|
-
export type
|
|
10
|
+
export type AvOperationSuccessCode = Extract<AvOperationCode, `A1${string}`>;
|
|
11
11
|
/** Every outcome code that is not a success. */
|
|
12
|
-
export type
|
|
12
|
+
export type AvOperationErrorCode = Exclude<AvOperationCode, AvOperationSuccessCode>;
|
|
13
13
|
/** Internal-failure family: nothing in the cause is caller-actionable. */
|
|
14
|
-
export type OperationInternalErrorCode = Extract<
|
|
14
|
+
export type OperationInternalErrorCode = Extract<AvOperationErrorCode, `A3${string}`>;
|
|
15
15
|
/** Why a request failed: a message, and the validation issues when there are any. */
|
|
16
|
-
export type
|
|
16
|
+
export type AvCause = {
|
|
17
17
|
readonly message: string;
|
|
18
|
-
readonly issues?: readonly
|
|
18
|
+
readonly issues?: readonly AvValidationIssue[];
|
|
19
19
|
readonly operation?: number;
|
|
20
20
|
};
|
|
21
21
|
/** The response envelope: `{ data, code, cause }`. */
|
|
22
|
-
type OperationResponseEnvelope<TData, TCode extends
|
|
22
|
+
type OperationResponseEnvelope<TData, TCode extends AvOperationCode, TCause extends AvCause | null> = {
|
|
23
23
|
readonly data: TData;
|
|
24
24
|
readonly code: TCode;
|
|
25
25
|
readonly cause: TCause;
|
|
26
26
|
};
|
|
27
27
|
/** Success codes that carry response data (every success code but A1001). */
|
|
28
|
-
export type
|
|
28
|
+
export type AvOperationSuccessDataCode = Exclude<AvOperationSuccessCode, "A1001">;
|
|
29
29
|
/** A success with data: `cause` is `null`. */
|
|
30
|
-
export type
|
|
30
|
+
export type AvOperationSuccessResponse<T> = OperationResponseEnvelope<T, AvOperationSuccessDataCode, null>;
|
|
31
31
|
/** A success with no matching row (`A1001`): `data` and `cause` are `null`. */
|
|
32
|
-
export type
|
|
32
|
+
export type AvOperationNoMatchResponse = OperationResponseEnvelope<null, "A1001", null>;
|
|
33
33
|
/** A failure: `data` is `null` and `cause` says why. */
|
|
34
|
-
export type
|
|
34
|
+
export type AvOperationFailureResponse = OperationResponseEnvelope<null, AvOperationErrorCode, AvCause>;
|
|
35
35
|
/**
|
|
36
36
|
* What an operation answers: success with data, a no-match success (`A1001`),
|
|
37
37
|
* or a failure with a cause.
|
|
38
38
|
*/
|
|
39
|
-
export type
|
|
39
|
+
export type AvOperationResponse<T = unknown> = AvOperationSuccessResponse<T> | AvOperationNoMatchResponse | AvOperationFailureResponse;
|
|
40
40
|
/** Builds a success response with data. */
|
|
41
|
-
export declare function operationSuccess<T>(data: T, code:
|
|
41
|
+
export declare function operationSuccess<T>(data: T, code: AvOperationSuccessDataCode): AvOperationSuccessResponse<T>;
|
|
42
42
|
/** Builds the no-match success arm (A1001). */
|
|
43
|
-
export declare function operationNoMatch():
|
|
43
|
+
export declare function operationNoMatch(): AvOperationNoMatchResponse;
|
|
44
44
|
/** Builds a failure response. */
|
|
45
|
-
export declare function operationFailure(code:
|
|
45
|
+
export declare function operationFailure(code: AvOperationErrorCode, cause: AvCause): AvOperationFailureResponse;
|
|
46
46
|
/** The one generic internal-failure text; every A3000 carries it. */
|
|
47
47
|
export declare const INTERNAL_FAILURE_MESSAGE = "Internal framework error.";
|
|
48
48
|
/** The response every internal failure (`A3000`) answers with. */
|
|
49
|
-
export declare function internalFailure():
|
|
49
|
+
export declare function internalFailure(): AvOperationFailureResponse;
|
|
50
50
|
export {};
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import type { AvAdapter } from "../adapters/adapter.interface.js";
|
|
2
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
3
|
+
import type { AvAdapterOperationExecutor } from "../adapters/adapter-operation-executor.interface.js";
|
|
4
|
+
import type { AvAdapterTransactionExecutor } from "../adapters/adapter-transaction-executor.interface.js";
|
|
5
|
+
import type { AvContracts } from "../compiler/contract.compiler.js";
|
|
5
6
|
import type { ResolvedFrameworkConfig } from "../config/config.resolver.js";
|
|
6
|
-
import type {
|
|
7
|
+
import type { AvRequestOrigin, RemoteRequestOrigin } from "../config/config-layer.js";
|
|
8
|
+
import type { AvContract } from "../contracts/contract.js";
|
|
7
9
|
import type { OperationValidationOptions, SemanticOperationArguments } from "../operations/operation-validator.js";
|
|
8
10
|
import type { FrameworkTransactionRequest } from "../transactions/transaction-request.js";
|
|
9
|
-
import { type
|
|
10
|
-
import type
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
import { type ArgumentsSource } from "./caller-data.door.js";
|
|
12
|
+
import { type ContextExecutor, type ExecutorScope } from "./context-executor.runtime.js";
|
|
13
|
+
import { type RecordWriteFacts } from "./create-requirement.js";
|
|
14
|
+
import { type DiagnosticsReporter } from "./diagnostics-reporter.js";
|
|
15
|
+
import { type OuterFailureLayer } from "./error-boundary.js";
|
|
16
|
+
import { type FieldStagePlan } from "./field-stage.plan.js";
|
|
17
|
+
import type { ClientProtocolIdentity, FrameworkOperationRequest, StatefulOperationRequest } from "./operation-request.js";
|
|
18
|
+
import type { AvOperationFailureResponse, AvOperationResponse } from "./operation-response.js";
|
|
19
|
+
import type { AvState } from "./request-state.js";
|
|
20
|
+
import { type NormalizationWrite } from "./scalar-runtime.js";
|
|
21
|
+
export type OperationRuntimeDependencies<M extends AvAdapterModel> = {
|
|
22
|
+
readonly adapter: AvAdapter<M>;
|
|
23
|
+
readonly contracts: AvContracts;
|
|
16
24
|
readonly config: ResolvedFrameworkConfig<M>;
|
|
17
25
|
};
|
|
18
26
|
/**
|
|
@@ -20,43 +28,130 @@ export type OperationRuntimeDependencies<M extends AdapterModel> = {
|
|
|
20
28
|
* single Adapter call goes through the executor passed beside it, so inside a
|
|
21
29
|
* transaction plan the root Adapter is unreachable by type.
|
|
22
30
|
*/
|
|
23
|
-
export type OperationPipelineDependencies<M extends
|
|
24
|
-
/**
|
|
25
|
-
|
|
31
|
+
export type OperationPipelineDependencies<M extends AvAdapterModel> = Omit<OperationRuntimeDependencies<M>, "adapter"> & {
|
|
32
|
+
/**
|
|
33
|
+
* The Adapter's create requirements and referential edges, read once at
|
|
34
|
+
* construction.
|
|
35
|
+
*/
|
|
36
|
+
readonly recordWrites: RecordWriteFacts;
|
|
37
|
+
/** Builds every stage's ctx: its `$` facts and the executor. */
|
|
38
|
+
readonly contexts: ContextExecutor<M>;
|
|
39
|
+
/** Each origin's field-stage dispatch, planned at construction. */
|
|
40
|
+
readonly fieldStages: {
|
|
41
|
+
readonly [O in AvRequestOrigin]: FieldStagePlan;
|
|
42
|
+
};
|
|
26
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Where one operation's Adapter call runs: standalone, through the Adapter, or
|
|
46
|
+
* inside an open transaction, through its executor.
|
|
47
|
+
*/
|
|
48
|
+
export type OperationBinding<M extends AvAdapterModel> = {
|
|
49
|
+
readonly kind: "standalone";
|
|
50
|
+
readonly executor: AvAdapterOperationExecutor<M>;
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: "transaction";
|
|
53
|
+
readonly executor: AvAdapterTransactionExecutor<M>;
|
|
54
|
+
/**
|
|
55
|
+
* A plan step's (or a forced call's) Resource transaction filters: the
|
|
56
|
+
* outer layer an error the step's own filters leave unhandled is handed
|
|
57
|
+
* to, answered once the transaction interceptors have unwound (the rc.1
|
|
58
|
+
* follow-up ruling; the independent re-check). Absent for a ctx call.
|
|
59
|
+
*/
|
|
60
|
+
readonly outer?: OuterFailureLayer;
|
|
61
|
+
};
|
|
62
|
+
/** `request` with its state settled. */
|
|
63
|
+
export declare function withRequestState<Request extends {
|
|
64
|
+
readonly state?: AvState;
|
|
65
|
+
}>(request: Request): Request & {
|
|
66
|
+
readonly state: AvState;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Builds what every operation's pipeline shares, the ctx executor included: its
|
|
70
|
+
* raw calls run the application's operation path with every developer stage
|
|
71
|
+
* removed.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createPipelineDependencies<M extends AvAdapterModel>(dependencies: OperationRuntimeDependencies<M>, model: M): OperationPipelineDependencies<M>;
|
|
27
74
|
/**
|
|
28
75
|
* The executor core owns no diagnostics channel: the framework factory owns
|
|
29
76
|
* it and hands in one reporter already bound to this request, so every
|
|
30
77
|
* boundary — including the outermost totality guard, which runs outside this
|
|
31
|
-
* function — reports through the same channel.
|
|
78
|
+
* function — reports through the same channel. `source` says whether the
|
|
79
|
+
* request's arguments are the caller's own objects, copied at the door, or data
|
|
80
|
+
* no caller holds (see {@link ArgumentsSource}).
|
|
32
81
|
*/
|
|
33
|
-
export type FrameworkOperationExecutor = (request: FrameworkOperationRequest, report: DiagnosticsReporter) => Promise<
|
|
34
|
-
/** Selects the Contract of the request's
|
|
35
|
-
export declare function activeContract(contracts:
|
|
82
|
+
export type FrameworkOperationExecutor = (request: FrameworkOperationRequest, report: DiagnosticsReporter, source: ArgumentsSource) => Promise<AvOperationResponse>;
|
|
83
|
+
/** Selects the Contract of the request's origin. */
|
|
84
|
+
export declare function activeContract(contracts: AvContracts, request: FrameworkOperationRequest | FrameworkTransactionRequest): AvContract;
|
|
36
85
|
/** Creates the transport-independent operation executor owned by core. */
|
|
37
|
-
export declare function createOperationRuntime<M extends
|
|
86
|
+
export declare function createOperationRuntime<M extends AvAdapterModel>(dependencies: OperationRuntimeDependencies<M>, pipelineDependencies: OperationPipelineDependencies<M>): FrameworkOperationExecutor;
|
|
38
87
|
/** Validates the request-level protocol identity. */
|
|
39
|
-
export declare function validateProtocolIdentity(contracts:
|
|
88
|
+
export declare function validateProtocolIdentity(contracts: AvContracts, request: FrameworkOperationRequest | FrameworkTransactionRequest): AvOperationFailureResponse | undefined;
|
|
40
89
|
/**
|
|
41
|
-
* The stale-client check on one
|
|
42
|
-
* (`A2006`), then the
|
|
90
|
+
* The stale-client check on one remote protocol identity: the protocol version first
|
|
91
|
+
* (`A2006`), then the hash of the origin's Contract (`A2005`): the ClientContract's
|
|
92
|
+
* for a client, the Agent Contract's for an agent. Exact match only. The one
|
|
43
93
|
* implementation — the protocol's decoders and absence answers
|
|
44
94
|
* (`@aventara/core/protocol`) call it too, so a stale client hears the same envelope
|
|
45
95
|
* whichever layer answers.
|
|
46
96
|
*/
|
|
47
|
-
export declare function protocolIdentityFailure(contracts:
|
|
97
|
+
export declare function protocolIdentityFailure(contracts: AvContracts, protocol: ClientProtocolIdentity, origin: RemoteRequestOrigin): AvOperationFailureResponse | undefined;
|
|
48
98
|
export type ValidatedOperationArguments = {
|
|
49
99
|
readonly ok: true;
|
|
50
100
|
readonly arguments: SemanticOperationArguments;
|
|
51
101
|
} | {
|
|
52
102
|
readonly ok: false;
|
|
53
|
-
readonly response:
|
|
103
|
+
readonly response: AvOperationFailureResponse;
|
|
54
104
|
};
|
|
55
105
|
/** Validates one operation's arguments through the Framework Validation Layer. */
|
|
56
|
-
export declare function validateOperationRequest(contract:
|
|
106
|
+
export declare function validateOperationRequest(contract: AvContract, request: FrameworkOperationRequest, options?: OperationValidationOptions, write?: NormalizationWrite): ValidatedOperationArguments;
|
|
107
|
+
/** Every sent field's path: a single call's arguments hold no `$ref`. */
|
|
108
|
+
export declare const EVERY_FIELD: () => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* What admission leaves: the deep-frozen arguments every later stage reads, and
|
|
111
|
+
* whether a pipe or a field pipe changed them; or the answer that refused the
|
|
112
|
+
* operation.
|
|
113
|
+
*/
|
|
114
|
+
export type AdmittedOperation = {
|
|
115
|
+
readonly ok: true;
|
|
116
|
+
readonly args: unknown;
|
|
117
|
+
readonly piped: boolean;
|
|
118
|
+
} | {
|
|
119
|
+
readonly ok: false;
|
|
120
|
+
readonly response: AvOperationFailureResponse;
|
|
121
|
+
};
|
|
122
|
+
/** Which sent values an operation's field stages and validators take, and how its pipe output is checked. */
|
|
123
|
+
export type AdmissionScope = {
|
|
124
|
+
/**
|
|
125
|
+
* The sent values the field pipes and validators take: every one for a single
|
|
126
|
+
* call, a plan step's literal values before BEGIN, its resolved `$ref` values
|
|
127
|
+
* at the step.
|
|
128
|
+
*/
|
|
129
|
+
readonly select: (path: readonly (string | number)[]) => boolean;
|
|
130
|
+
/** Before BEGIN a plan step's `$ref` slots are unresolved: these admit them. */
|
|
131
|
+
readonly validation?: OperationValidationOptions;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Runs an operation's admission — its guards, pipes and validators — and answers
|
|
135
|
+
* the deep-frozen arguments the rest of the operation reads, or the refusal.
|
|
136
|
+
*/
|
|
137
|
+
export declare function admitOperation<M extends AvAdapterModel>(dependencies: OperationPipelineDependencies<M>, request: StatefulOperationRequest, contract: AvContract, args: unknown, argumentsPath: readonly (string | number)[], report: DiagnosticsReporter, scope: ExecutorScope<M>, admission?: AdmissionScope): Promise<AdmittedOperation>;
|
|
138
|
+
/** How a plan step's arguments were changed between their admission and the step. */
|
|
139
|
+
export type StepChanges = {
|
|
140
|
+
/** The sent `$ref` values written at this step: their field stages run now. */
|
|
141
|
+
readonly written: (path: readonly (string | number)[]) => boolean;
|
|
142
|
+
/** A transaction pipe changed the step: every value is judged again. */
|
|
143
|
+
readonly transactionPiped: boolean;
|
|
144
|
+
/** An operation pipe ran before BEGIN on a step with `$ref`s: the resolved arguments are checked again. */
|
|
145
|
+
readonly pipedAroundReferences: boolean;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* A plan step's (or a forced call's) arguments at the step: resolved values
|
|
149
|
+
* through their field stages, and re-checked when a stage changed them.
|
|
150
|
+
*/
|
|
151
|
+
export declare function prepareStep<M extends AvAdapterModel>(dependencies: OperationPipelineDependencies<M>, request: StatefulOperationRequest, contract: AvContract, args: unknown, argumentsPath: readonly (string | number)[], report: DiagnosticsReporter, executor: AvAdapterTransactionExecutor<M>, changes: StepChanges, outer: OuterFailureLayer): Promise<AdmittedOperation>;
|
|
57
152
|
/**
|
|
58
|
-
* Everything after
|
|
59
|
-
* wrapped in the post-validation error boundary. Validation
|
|
60
|
-
* reach this function, so developer filters never see them.
|
|
153
|
+
* Everything after admission: write compute and the lifecycle around the
|
|
154
|
+
* Adapter call, wrapped in the post-validation error boundary. Validation
|
|
155
|
+
* failures never reach this function, so developer filters never see them.
|
|
61
156
|
*/
|
|
62
|
-
export declare function
|
|
157
|
+
export declare function executeAdmittedOperation<M extends AvAdapterModel>(dependencies: OperationPipelineDependencies<M>, request: StatefulOperationRequest, contract: AvContract, admittedArguments: unknown, argumentsPath: readonly (string | number)[], binding: OperationBinding<M>, report: DiagnosticsReporter): Promise<AvOperationResponse>;
|