@aventara/core 1.0.0-rc.1 → 1.0.0-rc.10
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 +943 -16
- package/ERRORS.md +142 -0
- package/README.md +274 -16
- package/dist/adapters/adapter-discovery-diagnostic.guidance.d.ts +6 -0
- package/dist/adapters/adapter-discovery-diagnostic.guidance.js +7 -0
- package/dist/adapters/adapter-field.d.ts +22 -0
- package/dist/adapters/adapter-identifier.d.ts +9 -0
- package/dist/adapters/adapter-identifier.js +6 -1
- package/dist/adapters/adapter-model.d.ts +9 -0
- package/dist/adapters/adapter-operation.d.ts +18 -3
- package/dist/adapters/adapter-resource.d.ts +5 -0
- package/dist/adapters/adapter.interface.d.ts +10 -0
- package/dist/avz/avz.d.ts +1 -1
- package/dist/avz/json-shape.registry.d.ts +2 -1
- package/dist/compiler/contract-compiler-diagnostic.guidance.d.ts +6 -0
- package/dist/compiler/contract-compiler-diagnostic.guidance.js +97 -0
- package/dist/compiler/contract.compiler.d.ts +6 -0
- package/dist/compiler/contract.compiler.js +227 -24
- package/dist/compiler/managed-elsewhere.projector.d.ts +52 -0
- package/dist/compiler/managed-elsewhere.projector.js +179 -0
- package/dist/compiler/managed-elsewhere.validator.d.ts +9 -0
- package/dist/compiler/managed-elsewhere.validator.js +74 -0
- package/dist/config/computed-fields.d.ts +62 -0
- package/dist/config/computed-fields.js +73 -0
- package/dist/config/config-diagnostic.guidance.d.ts +6 -0
- package/dist/config/config-diagnostic.guidance.js +32 -0
- package/dist/config/config.resolver.d.ts +24 -0
- package/dist/config/config.resolver.js +65 -0
- package/dist/config/config.validator.js +222 -8
- package/dist/config/define-resource.d.ts +1 -5
- package/dist/config/entrypoint.normalizer.d.ts +3 -2
- package/dist/config/exact-framework-config.d.ts +67 -22
- package/dist/config/field-compute.resolver.d.ts +2 -0
- package/dist/config/field-compute.resolver.js +8 -0
- package/dist/config/framework-config.d.ts +53 -15
- package/dist/config/framework-resources-config.d.ts +25 -14
- package/dist/config/pipeline-config.d.ts +4 -4
- package/dist/config/pipeline-tree.resolver.d.ts +2 -2
- package/dist/contracts/access-route.rules.d.ts +10 -0
- package/dist/contracts/access-route.rules.js +45 -0
- package/dist/contracts/capability.d.ts +26 -1
- package/dist/contracts/capability.js +20 -0
- package/dist/contracts/client-contract-structure.validator.d.ts +301 -89
- package/dist/contracts/client-contract-structure.validator.js +37 -2
- package/dist/contracts/contract-access.d.ts +29 -0
- package/dist/contracts/contract-access.js +1 -0
- package/dist/contracts/contract-canonicalizer.d.ts +9 -1
- package/dist/contracts/contract-canonicalizer.js +30 -4
- package/dist/contracts/contract-hash.d.ts +0 -1
- package/dist/contracts/contract-hash.js +1 -1
- package/dist/contracts/contract.d.ts +27 -1
- package/dist/contracts/field.d.ts +58 -1
- package/dist/contracts/json-schema.projector.d.ts +11 -0
- package/dist/contracts/json-schema.projector.js +78 -0
- package/dist/contracts/scalar-value-type.d.ts +3 -1
- package/dist/framework/access-facade.d.ts +116 -0
- package/dist/framework/access-facade.js +120 -0
- package/dist/framework/contract-view.d.ts +120 -16
- package/dist/framework/framework-construction.error.d.ts +14 -4
- package/dist/framework/framework-construction.error.js +18 -2
- package/dist/framework/framework.d.ts +26 -5
- package/dist/framework/framework.factory.d.ts +1 -1
- package/dist/framework/framework.factory.js +115 -23
- package/dist/framework/operation-facade.d.ts +80 -13
- package/dist/framework/operation-facade.js +2 -1
- package/dist/index.d.ts +17 -5
- package/dist/index.js +1 -0
- package/dist/internal.d.ts +7 -2
- package/dist/internal.js +6 -0
- package/dist/operations/database-refusal.d.ts +51 -0
- package/dist/operations/database-refusal.js +45 -0
- package/dist/operations/operation-arguments.d.ts +148 -60
- package/dist/operations/operation-call.d.ts +9 -5
- package/dist/operations/operation-result.d.ts +6 -4
- package/dist/operations/operation-validator-core.js +159 -36
- package/dist/operations/operation-validator.d.ts +1 -1
- package/dist/operations/structural-limits.walker.d.ts +1 -1
- package/dist/operations/validation-code.guidance.d.ts +6 -0
- package/dist/operations/validation-code.guidance.js +90 -0
- package/dist/operations/write-scope.resolver.d.ts +4 -0
- package/dist/operations/write-scope.resolver.js +2 -0
- package/dist/policy/access-provider.interface.d.ts +91 -0
- package/dist/policy/access-provider.interface.js +1 -0
- package/dist/policy/access-provider.registry.d.ts +17 -0
- package/dist/policy/access-provider.registry.js +15 -0
- package/dist/policy/access-question.d.ts +20 -0
- package/dist/policy/access-question.js +1 -0
- package/dist/policy/access-question.registry.d.ts +5 -0
- package/dist/policy/access-question.registry.js +19 -0
- package/dist/policy/access-question.runtime.d.ts +36 -0
- package/dist/policy/access-question.runtime.js +297 -0
- package/dist/policy/access-verb.table.d.ts +56 -0
- package/dist/policy/access-verb.table.js +21 -0
- package/dist/policy/access-verbs.d.ts +46 -0
- package/dist/policy/access-verbs.js +1 -0
- package/dist/policy/policy-admission.d.ts +20 -0
- package/dist/policy/policy-admission.js +409 -0
- package/dist/policy/policy-after-update.runtime.d.ts +79 -0
- package/dist/policy/policy-after-update.runtime.js +208 -0
- package/dist/policy/policy-condition.d.ts +15 -0
- package/dist/policy/policy-condition.js +36 -0
- package/dist/policy/policy-engine.d.ts +205 -0
- package/dist/policy/policy-engine.js +1 -0
- package/dist/policy/policy-named-rows.d.ts +18 -0
- package/dist/policy/policy-named-rows.js +51 -0
- package/dist/policy/policy-nested-write.runtime.d.ts +44 -0
- package/dist/policy/policy-nested-write.runtime.js +545 -0
- package/dist/policy/policy-read.runtime.d.ts +81 -0
- package/dist/policy/policy-read.runtime.js +503 -0
- package/dist/policy/policy-reference-write.runtime.d.ts +51 -0
- package/dist/policy/policy-reference-write.runtime.js +345 -0
- package/dist/policy/policy-request.d.ts +41 -0
- package/dist/policy/policy-request.js +63 -0
- package/dist/policy/policy-session.d.ts +106 -0
- package/dist/policy/policy-session.js +295 -0
- package/dist/policy/policy-startup.validator.d.ts +10 -0
- package/dist/policy/policy-startup.validator.js +112 -0
- package/dist/policy/policy-write.runtime.d.ts +39 -0
- package/dist/policy/policy-write.runtime.js +532 -0
- package/dist/prebuilt/core-version.generated.d.ts +2 -0
- package/dist/prebuilt/core-version.generated.js +1 -0
- package/dist/prebuilt/prebuilt-changes.d.ts +29 -0
- package/dist/prebuilt/prebuilt-changes.js +65 -0
- package/dist/prebuilt/prebuilt-contracts.d.ts +40 -0
- package/dist/prebuilt/prebuilt-contracts.emitter.d.ts +16 -0
- package/dist/prebuilt/prebuilt-contracts.emitter.js +50 -0
- package/dist/prebuilt/prebuilt-contracts.js +1 -0
- package/dist/prebuilt/prebuilt-contracts.loader.d.ts +19 -0
- package/dist/prebuilt/prebuilt-contracts.loader.js +77 -0
- package/dist/prebuilt/prebuilt-inputs.fingerprint.d.ts +16 -0
- package/dist/prebuilt/prebuilt-inputs.fingerprint.js +229 -0
- package/dist/protocol/absent-route.responder.d.ts +9 -27
- package/dist/protocol/absent-route.responder.js +36 -3
- package/dist/protocol/contract-document.responder.d.ts +2 -1
- package/dist/protocol/http-request.decoder.d.ts +19 -3
- package/dist/protocol/http-request.decoder.js +24 -1
- package/dist/protocol/http-request.reader.d.ts +6 -3
- package/dist/protocol/http-request.reader.js +1 -0
- package/dist/protocol/http-response.encoder.js +2 -2
- package/dist/protocol/protocol-headers.d.ts +3 -3
- package/dist/protocol/protocol-surface.d.ts +6 -1
- package/dist/protocol/protocol-surface.js +7 -0
- package/dist/protocol/protocol.binder.d.ts +16 -1
- package/dist/protocol/protocol.binder.js +4 -1
- package/dist/protocol/protocol.handler.d.ts +12 -1
- package/dist/protocol/protocol.handler.js +86 -17
- package/dist/runtime/caller-data.copier.d.ts +18 -3
- package/dist/runtime/caller-data.copier.js +21 -8
- package/dist/runtime/caller-data.door.d.ts +13 -6
- package/dist/runtime/computed-read-runtime.d.ts +6 -1
- package/dist/runtime/computed-read-runtime.js +232 -45
- package/dist/runtime/computed-value.error.d.ts +3 -2
- package/dist/runtime/computed-value.error.js +3 -2
- package/dist/runtime/context-executor.runtime.d.ts +4 -3
- package/dist/runtime/context-executor.runtime.js +4 -2
- package/dist/runtime/core-class.brand.d.ts +10 -0
- package/dist/runtime/core-class.brand.js +21 -0
- package/dist/runtime/create-requirement.d.ts +31 -5
- package/dist/runtime/create-requirement.js +129 -21
- package/dist/runtime/decimal.d.ts +14 -0
- package/dist/runtime/decimal.js +21 -0
- package/dist/runtime/diagnostics-reporter.d.ts +44 -9
- package/dist/runtime/diagnostics-reporter.js +13 -1
- package/dist/runtime/error-boundary.d.ts +9 -2
- package/dist/runtime/error-boundary.js +12 -0
- package/dist/runtime/error-guidance.d.ts +12 -0
- package/dist/runtime/error-guidance.js +1 -0
- package/dist/runtime/error.catalog.d.ts +49 -0
- package/dist/runtime/error.catalog.js +49 -0
- package/dist/runtime/execution-options.d.ts +8 -0
- package/dist/runtime/field-check.evaluator.d.ts +0 -2
- package/dist/runtime/field-check.evaluator.js +1 -1
- package/dist/runtime/field-compute.d.ts +11 -10
- package/dist/runtime/field-stage.runtime.d.ts +3 -1
- package/dist/runtime/field-stage.runtime.js +8 -4
- package/dist/runtime/field-validator.runtime.d.ts +19 -1
- package/dist/runtime/field-validator.runtime.js +47 -8
- package/dist/runtime/framework-error.js +9 -0
- package/dist/runtime/framework-warning.emitter.d.ts +6 -0
- package/dist/runtime/framework-warning.emitter.js +8 -0
- package/dist/runtime/json-value.d.ts +10 -5
- package/dist/runtime/level-lifecycle.runtime.d.ts +4 -3
- package/dist/runtime/level-lifecycle.runtime.js +3 -5
- package/dist/runtime/mutation-planner.d.ts +1 -6
- package/dist/runtime/mutation-planner.js +3 -14
- package/dist/runtime/operation-code.guidance.d.ts +6 -0
- package/dist/runtime/operation-code.guidance.js +167 -0
- package/dist/runtime/operation-request.d.ts +16 -9
- package/dist/runtime/operation-runtime.d.ts +35 -17
- package/dist/runtime/operation-runtime.js +220 -49
- package/dist/runtime/outcome-mapper.d.ts +2 -1
- package/dist/runtime/output-validator.d.ts +1 -1
- package/dist/runtime/owned-execution.registry.d.ts +13 -3
- package/dist/runtime/pipe-output.validator.d.ts +10 -0
- package/dist/runtime/pipe-output.validator.js +4 -2
- package/dist/runtime/pipeline.d.ts +47 -22
- package/dist/runtime/readonly-value.d.ts +20 -5
- package/dist/runtime/readonly-value.js +74 -26
- package/dist/runtime/referential-action.d.ts +1 -1
- package/dist/runtime/scalar-runtime.d.ts +4 -11
- package/dist/runtime/scalar-runtime.js +91 -22
- package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
- package/dist/runtime/unsent-value.normalizer.js +128 -0
- package/dist/transactions/operation-arguments-encoder.js +8 -3
- package/dist/transactions/operation-fingerprint.js +2 -2
- package/dist/transactions/sql-statement.d.ts +10 -2
- package/dist/transactions/sql-statement.validator.d.ts +2 -2
- package/dist/transactions/sql-statement.validator.js +38 -5
- package/dist/transactions/transaction-envelope.d.ts +5 -4
- package/dist/transactions/transaction-integrity-error.js +2 -0
- package/dist/transactions/transaction-plan-assembler.d.ts +12 -5
- package/dist/transactions/transaction-plan-assembler.js +48 -10
- package/dist/transactions/transaction-plan-validator.d.ts +23 -7
- package/dist/transactions/transaction-plan-validator.js +27 -1
- package/dist/transactions/transaction-reference-resolver.d.ts +3 -2
- package/dist/transactions/transaction-reference-validator.d.ts +43 -3
- package/dist/transactions/transaction-reference-validator.js +83 -57
- package/dist/transactions/transaction-reference.d.ts +1 -1
- package/dist/transactions/transaction-reference.js +5 -0
- package/dist/transactions/transaction-request.d.ts +8 -8
- package/dist/transactions/transaction-runtime.d.ts +5 -2
- package/dist/transactions/transaction-runtime.js +79 -27
- package/dist/transactions/transaction-settlement.runtime.d.ts +4 -3
- package/dist/transactions/transaction-slot-path-error.js +2 -0
- package/dist/transactions/transaction-stage.runtime.d.ts +5 -3
- package/dist/transactions/transaction-stage.runtime.js +7 -4
- package/package.json +6 -5
- package/src/runtime/field-check.evaluator.ts +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { frozenCopy } from "./readonly-value.js";
|
|
1
2
|
export function isPlainRecord(value) {
|
|
2
3
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3
4
|
return false;
|
|
@@ -5,7 +6,7 @@ export function isPlainRecord(value) {
|
|
|
5
6
|
const prototype = Object.getPrototypeOf(value);
|
|
6
7
|
return prototype === Object.prototype || prototype === null;
|
|
7
8
|
}
|
|
8
|
-
const WRITE_KEYS = {
|
|
9
|
+
export const WRITE_KEYS = {
|
|
9
10
|
create: ["data"],
|
|
10
11
|
update: ["data"],
|
|
11
12
|
upsert: ["create", "update"],
|
|
@@ -104,9 +105,12 @@ export async function pipeSentFields(stages, fields, records, args, select) {
|
|
|
104
105
|
}
|
|
105
106
|
let value = record[field];
|
|
106
107
|
for (const pipe of stages[field]?.pipes ?? []) {
|
|
107
|
-
const
|
|
108
|
+
const told = frozenCopy(value);
|
|
109
|
+
const next = await pipe(told);
|
|
108
110
|
if (next !== undefined) {
|
|
109
|
-
|
|
111
|
+
if (next !== told) {
|
|
112
|
+
value = next;
|
|
113
|
+
}
|
|
110
114
|
changed = true;
|
|
111
115
|
}
|
|
112
116
|
}
|
|
@@ -133,7 +137,7 @@ export async function guardSentFields(stages, fields, records, args, context) {
|
|
|
133
137
|
}
|
|
134
138
|
for (const guard of stages[field]?.guards ?? []) {
|
|
135
139
|
const told = context();
|
|
136
|
-
if ((await guard(record[field], told)) === false) {
|
|
140
|
+
if ((await guard(frozenCopy(record[field]), told)) === false) {
|
|
137
141
|
return false;
|
|
138
142
|
}
|
|
139
143
|
}
|
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import type { AvContract } from "../contracts/contract.js";
|
|
2
2
|
import type { AvValidationIssue } from "../operations/validation-code.js";
|
|
3
|
+
import { AvComputedValueError } from "./computed-value.error.js";
|
|
3
4
|
import { type Path } from "./field-stage.runtime.js";
|
|
4
5
|
import type { OperationExecutionRequest } from "./operation-request.js";
|
|
5
6
|
import type { ReferentialActionTable } from "./referential-action.js";
|
|
7
|
+
/** The write phase of a record: a created row (an upsert's `create` branch too) or an updated one. */
|
|
8
|
+
type WriteStage = "create" | "update";
|
|
9
|
+
/**
|
|
10
|
+
* The fields a judgment leaves for later: a plan step's (or a forced call's)
|
|
11
|
+
* literal values are judged before BEGIN, except a field a write compute stage
|
|
12
|
+
* of that phase may still change, which is judged after write compute.
|
|
13
|
+
*/
|
|
14
|
+
type DeferredField = (resource: string, stage: WriteStage, field: string) => boolean;
|
|
6
15
|
/**
|
|
7
16
|
* Every way the sent fields `select` admits break their validators: the
|
|
8
17
|
* operation's own records, then each nested write target's. Paths are the
|
|
9
18
|
* request's: `argumentsPath` and then the value's place in the arguments.
|
|
10
19
|
*/
|
|
11
|
-
export declare function fieldValidatorIssues(contract: AvContract, references: ReferentialActionTable, request: OperationExecutionRequest, args: unknown, argumentsPath: Path, select: (path: Path) => boolean): readonly AvValidationIssue[];
|
|
20
|
+
export declare function fieldValidatorIssues(contract: AvContract, references: ReferentialActionTable, request: OperationExecutionRequest, args: unknown, argumentsPath: Path, select: (path: Path) => boolean, deferred?: DeferredField): readonly AvValidationIssue[];
|
|
21
|
+
/**
|
|
22
|
+
* The server's defect when a value written to a field the active layer hides
|
|
23
|
+
* breaks its validators or its Json shape, or `undefined`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function hiddenFieldRefusal(contracts: {
|
|
26
|
+
readonly core: AvContract;
|
|
27
|
+
readonly active: AvContract;
|
|
28
|
+
}, references: ReferentialActionTable, request: OperationExecutionRequest, args: unknown, argumentsPath: Path): AvComputedValueError | undefined;
|
|
29
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { validatedFieldsOf, } from "../compiler/field-validator.compiler.js";
|
|
1
|
+
import { hasFieldValidators, validatedFieldsOf, } from "../compiler/field-validator.compiler.js";
|
|
2
|
+
import { AvComputedValueError } from "./computed-value.error.js";
|
|
2
3
|
import { entryCheckIssues, fieldCheckIssues } from "./field-check.evaluator.js";
|
|
3
4
|
import { isPlainRecord, valueAt, writeRecordPathsOf, } from "./field-stage.runtime.js";
|
|
4
5
|
import { nestedWriteTargetsOf } from "./nested-write.walker.js";
|
|
@@ -14,7 +15,10 @@ function rulesOf(contract, compiled, resource, name) {
|
|
|
14
15
|
const field = fields !== undefined && Object.hasOwn(fields, name)
|
|
15
16
|
? fields[name]
|
|
16
17
|
: undefined;
|
|
17
|
-
if (field
|
|
18
|
+
if (field === undefined) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
if (field.kind === "scalar" && field.json !== undefined) {
|
|
18
22
|
return { kind: "shape", field };
|
|
19
23
|
}
|
|
20
24
|
const checks = Object.hasOwn(compiled, name) ? compiled[name] : undefined;
|
|
@@ -36,17 +40,17 @@ function entryIssues(rules, entry, at) {
|
|
|
36
40
|
const { compiled } = rules;
|
|
37
41
|
return entryCheckIssues(compiled.checks, entry, compiled.subject ?? "string", at);
|
|
38
42
|
}
|
|
39
|
-
function recordIssues(contract, resource, records, args, argumentsPath, select) {
|
|
43
|
+
function recordIssues(contract, resource, records, args, argumentsPath, select, deferred) {
|
|
40
44
|
const compiled = validatedFieldsOf(contract, resource);
|
|
41
45
|
const issues = [];
|
|
42
|
-
for (const path of records) {
|
|
46
|
+
for (const { path, stage } of records) {
|
|
43
47
|
const record = valueAt(args, path);
|
|
44
48
|
if (!isPlainRecord(record)) {
|
|
45
49
|
continue;
|
|
46
50
|
}
|
|
47
51
|
for (const name of Object.keys(record)) {
|
|
48
52
|
const rules = rulesOf(contract, compiled, resource, name);
|
|
49
|
-
if (rules === undefined) {
|
|
53
|
+
if (rules === undefined || deferred?.(resource, stage, name) === true) {
|
|
50
54
|
continue;
|
|
51
55
|
}
|
|
52
56
|
const fieldPath = [...path, name];
|
|
@@ -78,10 +82,45 @@ function recordIssues(contract, resource, records, args, argumentsPath, select)
|
|
|
78
82
|
}
|
|
79
83
|
return issues;
|
|
80
84
|
}
|
|
81
|
-
export function fieldValidatorIssues(contract, references, request, args, argumentsPath, select) {
|
|
82
|
-
const issues = recordIssues(contract, request.resource, writeRecordPathsOf(request.family, args)
|
|
85
|
+
export function fieldValidatorIssues(contract, references, request, args, argumentsPath, select, deferred) {
|
|
86
|
+
const issues = recordIssues(contract, request.resource, writeRecordPathsOf(request.family, args).map((path) => ({
|
|
87
|
+
path,
|
|
88
|
+
stage: request.family === "create" || path[0] === "create"
|
|
89
|
+
? "create"
|
|
90
|
+
: "update",
|
|
91
|
+
})), args, argumentsPath, select, deferred);
|
|
83
92
|
for (const target of nestedWriteTargetsOf(contract, references, request, args)) {
|
|
84
|
-
issues.push(...recordIssues(contract, target.resource, target.records
|
|
93
|
+
issues.push(...recordIssues(contract, target.resource, target.records, args, argumentsPath, select, deferred));
|
|
85
94
|
}
|
|
86
95
|
return issues;
|
|
87
96
|
}
|
|
97
|
+
function holdsField(contract, resource, field) {
|
|
98
|
+
const fields = Object.hasOwn(contract.resources, resource)
|
|
99
|
+
? contract.resources[resource]?.fields
|
|
100
|
+
: undefined;
|
|
101
|
+
return fields !== undefined && Object.hasOwn(fields, field);
|
|
102
|
+
}
|
|
103
|
+
export function hiddenFieldRefusal(contracts, references, request, args, argumentsPath) {
|
|
104
|
+
const { core, active } = contracts;
|
|
105
|
+
if (core === active || !hasFieldValidators(core)) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
const judged = [];
|
|
109
|
+
const issues = fieldValidatorIssues(core, references, request, args, argumentsPath, () => true, (resource, stage, field) => {
|
|
110
|
+
if (holdsField(active, resource, field)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
judged.push({ resource, stage, field });
|
|
114
|
+
return false;
|
|
115
|
+
});
|
|
116
|
+
const [first] = issues;
|
|
117
|
+
if (first === undefined) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
const path = first.path ?? [];
|
|
121
|
+
const at = judged.find(({ field }) => path.includes(field)) ?? judged[0];
|
|
122
|
+
if (at === undefined) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
return new AvComputedValueError(at.resource, at.field, at.stage, issues, `compute.${at.stage} on ${at.resource}.${at.field}, a field the ${request.origin} layer hides, returned a value its validators refuse (${first.code}: ${first.message})`);
|
|
126
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandCoreClass } from "./core-class.brand.js";
|
|
1
2
|
export class AvError extends Error {
|
|
2
3
|
name = "AvError";
|
|
3
4
|
code;
|
|
@@ -30,3 +31,11 @@ export class AvProtocolError extends AvError {
|
|
|
30
31
|
export class AvContractMismatchError extends AvError {
|
|
31
32
|
name = "AvContractMismatchError";
|
|
32
33
|
}
|
|
34
|
+
brandCoreClass(AvError, "AvError");
|
|
35
|
+
brandCoreClass(AvValidationError, "AvValidationError");
|
|
36
|
+
brandCoreClass(AvNotFoundError, "AvNotFoundError");
|
|
37
|
+
brandCoreClass(AvConflictError, "AvConflictError");
|
|
38
|
+
brandCoreClass(AvAuthError, "AvAuthError");
|
|
39
|
+
brandCoreClass(AvInternalError, "AvInternalError");
|
|
40
|
+
brandCoreClass(AvProtocolError, "AvProtocolError");
|
|
41
|
+
brandCoreClass(AvContractMismatchError, "AvContractMismatchError");
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emits a framework warning: through `process.emitWarning` (type
|
|
3
|
+
* `AventaraWarning`, `code` as given) where the runtime has it, else through
|
|
4
|
+
* `console.warn`. A warning changes no behaviour.
|
|
5
|
+
*/
|
|
6
|
+
export declare function emitFrameworkWarning(message: string, code: string): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function emitFrameworkWarning(message, code) {
|
|
2
|
+
const emitWarning = globalThis.process?.emitWarning;
|
|
3
|
+
if (typeof emitWarning === "function") {
|
|
4
|
+
emitWarning(message, { type: "AventaraWarning", code });
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
globalThis.console?.warn(`AventaraWarning: ${message}`);
|
|
8
|
+
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A JSON value: the form of the `json` scalar, in arguments and results.
|
|
3
3
|
*
|
|
4
|
-
* A `Date`, a `bigint`, a `Uint8Array`, a {@link AvDecimal}
|
|
5
|
-
* instance
|
|
6
|
-
*
|
|
4
|
+
* A `Date`, a `bigint`, a `Uint8Array`, a {@link AvDecimal} and any other class
|
|
5
|
+
* instance are refused (`V1001`), as are a non-finite `number` (`V1004`) and a
|
|
6
|
+
* cycle (`V1001`). An `undefined` inside the value is what JSON makes of it: a key
|
|
7
|
+
* holding it is left out, an array element holding it (or a hole) is `null`. The
|
|
8
|
+
* type admits a key holding `undefined`, so an object with an optional property is
|
|
9
|
+
* a JSON value; an array element stays typed without it, as JSON has no such
|
|
10
|
+
* value.
|
|
7
11
|
*
|
|
8
|
-
* Results are fresh plain copies, so mutating one is safe
|
|
12
|
+
* Results are fresh plain copies, so mutating one is safe; a result never holds a
|
|
13
|
+
* key whose value is `undefined`.
|
|
9
14
|
*
|
|
10
15
|
* A `json` field's value is this without its top-level `null`: a field-level
|
|
11
16
|
* `null` is the field's absence, which only `nullable: true` admits.
|
|
12
17
|
*/
|
|
13
18
|
export type AvJsonValue = string | number | boolean | null | readonly AvJsonValue[] | {
|
|
14
|
-
readonly [key: string]: AvJsonValue;
|
|
19
|
+
readonly [key: string]: AvJsonValue | undefined;
|
|
15
20
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** One level's lifecycle registrations, as an operation or a transaction level holds them. */
|
|
2
|
-
|
|
2
|
+
type LifecycleLevel<Context> = {
|
|
3
3
|
readonly hooks: {
|
|
4
4
|
readonly before: readonly ((context: Context) => unknown)[];
|
|
5
5
|
readonly after: readonly ((result: unknown, context: Context) => unknown)[];
|
|
@@ -17,9 +17,10 @@ export type NextReuse<Refusal extends Error = Error> = {
|
|
|
17
17
|
* Runs `levels`' lifecycle around `inner`: every interceptor, outer to inner,
|
|
18
18
|
* around every before hook, `inner`, and every after hook. `settle` turns what
|
|
19
19
|
* `inner` or an interceptor below resolved into what the stage above sees (the
|
|
20
|
-
* operation read-materializes it).
|
|
21
|
-
* the result; the result itself goes on to the interceptors, which may answer a
|
|
20
|
+
* operation read-materializes it). Each after hook is told its own deep-frozen
|
|
21
|
+
* copy of the result; the result itself goes on to the interceptors, which may answer a
|
|
22
22
|
* different one. Every `next()` is single use: a second call rejects with
|
|
23
23
|
* `refuse()`'s error, recorded in `reuse`, and runs nothing.
|
|
24
24
|
*/
|
|
25
25
|
export declare function runLevelLifecycle<Context, Refusal extends Error>(levels: readonly LifecycleLevel<Context>[], context: () => Context, inner: () => Promise<unknown>, settle: (result: unknown) => Promise<unknown>, reuse: NextReuse<Refusal>, refuse: () => Refusal): Promise<unknown>;
|
|
26
|
+
export {};
|
|
@@ -20,11 +20,9 @@ export async function runLevelLifecycle(levels, context, inner, settle, reuse, r
|
|
|
20
20
|
}
|
|
21
21
|
const result = await settle(await inner());
|
|
22
22
|
const after = [...levels].reverse().flatMap((level) => level.hooks.after);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
await hook(told, context());
|
|
27
|
-
}
|
|
23
|
+
const settled = after.length > 0 ? frozenCopy(result, true) : undefined;
|
|
24
|
+
for (const [index, hook] of after.entries()) {
|
|
25
|
+
await hook(index === after.length - 1 ? settled : frozenCopy(settled), context());
|
|
28
26
|
}
|
|
29
27
|
return result;
|
|
30
28
|
};
|
|
@@ -10,16 +10,11 @@ import type { OperationExecutionRequest } from "./operation-request.js";
|
|
|
10
10
|
* `application.fields` / `client.fields`, which Core does not carry. Such a field is
|
|
11
11
|
* virtual: its behaviours run and its value is stripped before the Adapter call.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
type WriteContracts = {
|
|
14
14
|
readonly core: AvContractCore;
|
|
15
15
|
readonly active: AvContract;
|
|
16
16
|
};
|
|
17
|
-
type WriteStage = "create" | "update";
|
|
18
17
|
type ContextFactory = (args: unknown) => AvComputeContext;
|
|
19
|
-
export type RelationRecordSite = {
|
|
20
|
-
readonly key: string | undefined;
|
|
21
|
-
readonly stage: WriteStage;
|
|
22
|
-
};
|
|
23
18
|
/**
|
|
24
19
|
* The sole grammar for relation-mutation record operands. Every write pass maps these
|
|
25
20
|
* sites with its own record leaf, leaving identifier-only directives untouched.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { lookupField, lookupResource } from "../contracts/contract-lookup.js";
|
|
2
2
|
import { AvComputedValueError } from "./computed-value.error.js";
|
|
3
3
|
import { replaceAt, valueAt } from "./field-stage.runtime.js";
|
|
4
|
-
import {
|
|
4
|
+
import { frozenCopy } from "./readonly-value.js";
|
|
5
|
+
import { normalizeScalarFieldValue } from "./scalar-runtime.js";
|
|
5
6
|
function writeScalarField(contracts, resourceName, fieldName) {
|
|
6
7
|
const field = lookupField(lookupResource(contracts.core, resourceName), fieldName) ??
|
|
7
8
|
lookupField(lookupResource(contracts.active, resourceName), fieldName);
|
|
@@ -57,7 +58,7 @@ async function computeRecord(contracts, compute, resourceName, stage, data, cont
|
|
|
57
58
|
if (field === undefined) {
|
|
58
59
|
continue;
|
|
59
60
|
}
|
|
60
|
-
const snapshot =
|
|
61
|
+
const snapshot = frozenCopy(logicalData);
|
|
61
62
|
const computed = await callback({
|
|
62
63
|
field: fieldName,
|
|
63
64
|
value: snapshot[fieldName],
|
|
@@ -79,18 +80,6 @@ async function computeRecord(contracts, compute, resourceName, stage, data, cont
|
|
|
79
80
|
if (!validation.ok) {
|
|
80
81
|
throw new AvComputedValueError(resourceName, fieldName, stage, validation.issues);
|
|
81
82
|
}
|
|
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);
|
|
93
|
-
}
|
|
94
83
|
logicalData[fieldName] = validation.value;
|
|
95
84
|
}
|
|
96
85
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ErrorCodeDescription } from "./error-guidance.js";
|
|
2
|
+
import type { AvOperationCode } from "./operation-response.js";
|
|
3
|
+
/** Meaning, cause and fix of every outcome code. */
|
|
4
|
+
export declare const OPERATION_CODE_GUIDANCE: {
|
|
5
|
+
readonly [C in AvOperationCode]: ErrorCodeDescription;
|
|
6
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export const OPERATION_CODE_GUIDANCE = {
|
|
2
|
+
A1000: {
|
|
3
|
+
message: "Success.",
|
|
4
|
+
cause: "A read, a count or another operation without a more specific success code succeeded.",
|
|
5
|
+
fix: "Nothing: the call succeeded.",
|
|
6
|
+
},
|
|
7
|
+
A1001: {
|
|
8
|
+
message: "No match.",
|
|
9
|
+
cause: "A first-style operation (find.first, update.first, delete.first) matched no row; data is null and the generated client resolves null.",
|
|
10
|
+
fix: "Nothing: handle the null result. A unique operation answers A2003 instead.",
|
|
11
|
+
},
|
|
12
|
+
A1002: {
|
|
13
|
+
message: "Created.",
|
|
14
|
+
cause: "create.one created a row.",
|
|
15
|
+
fix: "Nothing: the call succeeded.",
|
|
16
|
+
},
|
|
17
|
+
A1003: {
|
|
18
|
+
message: "Created many.",
|
|
19
|
+
cause: "create.many or create.count created rows.",
|
|
20
|
+
fix: "Nothing: the call succeeded.",
|
|
21
|
+
},
|
|
22
|
+
A1004: {
|
|
23
|
+
message: "Updated.",
|
|
24
|
+
cause: "update.first or update.unique updated a row.",
|
|
25
|
+
fix: "Nothing: the call succeeded.",
|
|
26
|
+
},
|
|
27
|
+
A1005: {
|
|
28
|
+
message: "Updated many.",
|
|
29
|
+
cause: "update.many or update.count updated rows.",
|
|
30
|
+
fix: "Nothing: the call succeeded.",
|
|
31
|
+
},
|
|
32
|
+
A1006: {
|
|
33
|
+
message: "Deleted.",
|
|
34
|
+
cause: "delete.first or delete.unique deleted a row.",
|
|
35
|
+
fix: "Nothing: the call succeeded.",
|
|
36
|
+
},
|
|
37
|
+
A1007: {
|
|
38
|
+
message: "Deleted many.",
|
|
39
|
+
cause: "delete.count deleted rows.",
|
|
40
|
+
fix: "Nothing: the call succeeded.",
|
|
41
|
+
},
|
|
42
|
+
A1008: {
|
|
43
|
+
message: "Upserted.",
|
|
44
|
+
cause: "upsert.unique created or updated a row.",
|
|
45
|
+
fix: "Nothing: the call succeeded.",
|
|
46
|
+
},
|
|
47
|
+
A1009: {
|
|
48
|
+
message: "Transaction committed.",
|
|
49
|
+
cause: "A whole transaction plan committed; data holds one result per step.",
|
|
50
|
+
fix: "Nothing: the plan committed.",
|
|
51
|
+
},
|
|
52
|
+
A2000: {
|
|
53
|
+
message: "Invalid request.",
|
|
54
|
+
cause: "The HTTP request cannot be interpreted: malformed JSON, a body that is not a JSON object, an unknown `/_*` path, a body that does not decode in its Content-Encoding, or a missing Aventara-Protocol-Version or Aventara-Contract-Hash header (the message names it).",
|
|
55
|
+
fix: "Send a JSON object with both identity headers. The generated client does this for you.",
|
|
56
|
+
},
|
|
57
|
+
A2001: {
|
|
58
|
+
message: "Unknown Resource.",
|
|
59
|
+
cause: 'The Resource is not in the caller\'s contract: misspelt, hidden by exposure, or added to the schema after aventara:prepare last ran. cause.message is "The requested Resource is not available." and the issue is V1005 at `["resource"]`.',
|
|
60
|
+
fix: "Use the model's exact name. After a schema change run the adapter's generate step (`npm run aventara:prepare` in a scaffolded project), restart, and regenerate the client. A Resource hidden on purpose is reached from server code (framework.application).",
|
|
61
|
+
},
|
|
62
|
+
A2002: {
|
|
63
|
+
message: "Unknown operation.",
|
|
64
|
+
cause: 'The operation is not available on that Resource: a typo, removed by exposure, an operation the adapter does not offer (such as delete.many), or a ctx.$sql, appTx.$sql or ctx.$transaction the adapter or the layer cannot run. The issue is V1006 at `["family"]` or `["variant"]`.',
|
|
65
|
+
fix: "Call an operation the contract lists (`GET <api>/_contract`), regenerate a stale client, and check the layer's exemptions and transactionsStyle.",
|
|
66
|
+
},
|
|
67
|
+
A2003: {
|
|
68
|
+
message: "Not found.",
|
|
69
|
+
cause: "A unique operation (find.unique, update.unique, delete.unique) matched no row, or a $connect names a record that does not exist. The operation fails, so no after hook runs. Under a policy, a row outside the caller's read scope is a miss too, and so is a single-row update or delete of a row the caller cannot read, so the answer does not reveal that the row exists. A row the caller can read but not change answers A4002.",
|
|
70
|
+
fix: "Catch AvNotFoundError, or use a first-style operation, which answers A1001 with null. Check the $connect identifier.",
|
|
71
|
+
},
|
|
72
|
+
A2004: {
|
|
73
|
+
message: "Validation failed.",
|
|
74
|
+
cause: 'The arguments break a contract rule or a field validator. cause.issues lists each problem by V-code and path; a validator\'s issue also has check and params. The validators judge the values after the pipes and write compute, so a computed value they refuse is here too, at its field. A required create field left out is here (V1000). So is a value the database itself refused: too long for its column or its index, or out of its range (V1004), or holding a character it cannot store or a pattern it cannot read (V1001), with the issue at `["arguments"]`, or at the value where the adapter can place it (a bigint its driver cannot bind), and its message saying what the database refused. So is a record written through a relation that writes that relation, or a field holding its reference, back (V1012, at that field), where the adapter admits no such write.',
|
|
75
|
+
fix: "Fix the argument each issue's path points at, as its V-code says. A field the server must fill takes a compute.create stage. For a value the database refused, send one its column holds. For a nested write that writes its relation back, leave that field out: the parent supplies it.",
|
|
76
|
+
},
|
|
77
|
+
A2005: {
|
|
78
|
+
message: "Contract mismatch.",
|
|
79
|
+
cause: "The caller's Aventara-Contract-Hash is not the server's current one: the schema, the configuration, the limits or the exposure changed, or the client targets another deployment.",
|
|
80
|
+
fix: "Regenerate the client against the running server: `npm run avclient:generate`.",
|
|
81
|
+
},
|
|
82
|
+
A2006: {
|
|
83
|
+
message: "Protocol mismatch.",
|
|
84
|
+
cause: "Aventara-Protocol-Version is not 1.",
|
|
85
|
+
fix: "Send `Aventara-Protocol-Version: 1`, or upgrade the client.",
|
|
86
|
+
},
|
|
87
|
+
A2007: {
|
|
88
|
+
message: "Invalid transaction reference.",
|
|
89
|
+
cause: "A transaction $ref or fingerprint is invalid: the issues are V1010, V1011, V1016, V1017 or V1018, and cause.operation is the step. A $ref with no fingerprint is A2004 / V1000.",
|
|
90
|
+
fix: "Let the generated client or framework.appTx build plans; check the $ref path and that the referenced step comes earlier.",
|
|
91
|
+
},
|
|
92
|
+
A2008: {
|
|
93
|
+
message: "Conflict.",
|
|
94
|
+
cause: "A uniqueness or reference constraint failed: a duplicate value, a missing parent, or a $disconnect or $set that would orphan a required child (also through update.first or a developer SQL statement). Sending it again unchanged fails the same way.",
|
|
95
|
+
fix: "Change the data. For a duplicate, update the existing row or use upsert.unique.",
|
|
96
|
+
},
|
|
97
|
+
A2009: {
|
|
98
|
+
message: "Limit exceeded.",
|
|
99
|
+
cause: "A contract limit was crossed: nesting depth (V1013), list or plan size (V1014), boolean nodes (V1015) or Json value depth (V1021).",
|
|
100
|
+
fix: "Ask for less (paginate, split the plan), or raise the limit under `limits`.",
|
|
101
|
+
},
|
|
102
|
+
A2010: {
|
|
103
|
+
message: "Payload too large.",
|
|
104
|
+
cause: "The decoded request body exceeds maxRequestBytes (default 1048576).",
|
|
105
|
+
fix: "Send less, or raise limits.maxRequestBytes.",
|
|
106
|
+
},
|
|
107
|
+
A2011: {
|
|
108
|
+
message: "Unsupported media type.",
|
|
109
|
+
cause: "The body is not application/json, or its Content-Encoding is not gzip, deflate or br.",
|
|
110
|
+
fix: "Send `Content-Type: application/json`.",
|
|
111
|
+
},
|
|
112
|
+
A2012: {
|
|
113
|
+
message: "Method not allowed.",
|
|
114
|
+
cause: "The HTTP method does not fit the route; the Allow header names the right one (`POST` on operations and `/_transactions`, `GET` on `/_contract`).",
|
|
115
|
+
fix: "Use the method the Allow header names.",
|
|
116
|
+
},
|
|
117
|
+
A2013: {
|
|
118
|
+
message: "Concurrent modification.",
|
|
119
|
+
cause: "A competing writer reached the state first; nothing was written.",
|
|
120
|
+
fix: "Retry. No retry is automatic.",
|
|
121
|
+
},
|
|
122
|
+
A2014: {
|
|
123
|
+
message: "Stale selection.",
|
|
124
|
+
cause: "The selected state changed before the write; nothing was written.",
|
|
125
|
+
fix: "Read again, then retry.",
|
|
126
|
+
},
|
|
127
|
+
A3000: {
|
|
128
|
+
message: "Internal error.",
|
|
129
|
+
cause: 'An unexpected failure on the server: a stage threw an error that is not an AvError, an interceptor called next() twice, a compute stage reached a write through its read-only ctx, a compute stage returned a value of the wrong type, or a compute.create returned undefined for a required field. cause.message is always "Internal framework error."',
|
|
130
|
+
fix: "Read the real error in the diagnostics sink (the root `diagnostics` key) or the server log line for the request id, and fix that stage. To answer with a code of your choice, throw an AvError.",
|
|
131
|
+
},
|
|
132
|
+
A3001: {
|
|
133
|
+
message: "Adapter error.",
|
|
134
|
+
cause: 'A database or ORM failure that is not something the caller can fix. cause.message is always "Adapter execution failed."',
|
|
135
|
+
fix: "Read the raw error in the diagnostics sink; check the database, its connection and the migration state.",
|
|
136
|
+
},
|
|
137
|
+
A3002: {
|
|
138
|
+
message: "Transaction error.",
|
|
139
|
+
cause: "Transaction infrastructure failed (commit or rollback, or the transaction expired or was closed under a step), or a Resource transaction interceptor called next() twice or resolved without calling it.",
|
|
140
|
+
fix: "Read the diagnostics sink. Call next() exactly once in a transaction interceptor; retry an infrastructure failure.",
|
|
141
|
+
},
|
|
142
|
+
A3003: {
|
|
143
|
+
message: "Serialization error.",
|
|
144
|
+
cause: "A result could not be encoded for transport.",
|
|
145
|
+
fix: "Read the diagnostics sink; make compute.read stages and Json values return plain data of the field's type.",
|
|
146
|
+
},
|
|
147
|
+
A3004: {
|
|
148
|
+
message: "Pipe output invalid.",
|
|
149
|
+
cause: 'A server pipe, field pipe or transaction pipe (or write compute) returned arguments the server\'s own contract refuses: a field the Resource does not have, a wrong type, a dropped required field, a reference written together with its relation (V1012), or a changed plan. cause.message is always "A server pipeline produced invalid arguments."',
|
|
150
|
+
fix: "Read the server log line, which names the pipe, the operation and the path, and fix the pipe. A pipe returns a new object of the same shape, or undefined to keep the arguments.",
|
|
151
|
+
},
|
|
152
|
+
A4000: {
|
|
153
|
+
message: "Unauthenticated.",
|
|
154
|
+
cause: 'A guard threw new AvError("A4000", ...): authentication is required or failed. The framework never authenticates by itself.',
|
|
155
|
+
fix: "Send the credentials your guards expect, such as the Authorization header.",
|
|
156
|
+
},
|
|
157
|
+
A4001: {
|
|
158
|
+
message: "Forbidden.",
|
|
159
|
+
cause: 'A guard returned false ("Operation denied by a framework guard."), a field write guard or a nested write\'s target guard included, or a stage threw A4001.',
|
|
160
|
+
fix: "Call as a caller the guard admits, or stop sending the guarded field. To answer another code, throw an AvError from the guard.",
|
|
161
|
+
},
|
|
162
|
+
A4002: {
|
|
163
|
+
message: "Policy denied.",
|
|
164
|
+
cause: "The configuration's policy refused the request: its engine does not allow the operation, a field the request names, writes or returns, a row it reaches, a row it creates, or the row a change leaves (moved out of what the caller reads, or failing its grant's after condition, which rolls the write back); on a database without interactive transactions, a write the policy can only check after it runs; or a stage threw new AvError(\"A4002\", ...).",
|
|
165
|
+
fix: "Read cause.message, which names what the policy refused. Call as a principal the policy allows, leave the refused field or relation out (a governed one is named only where every row grants it), or change only rows the caller may change and still read afterwards.",
|
|
166
|
+
},
|
|
167
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AvOperationIdentity } from "../operations/operation-identity.js";
|
|
2
|
+
import type { PolicySession } from "../policy/policy-session.js";
|
|
2
3
|
import type { AvTransportContext } from "./pipeline.js";
|
|
3
4
|
import type { AvState } from "./request-state.js";
|
|
4
5
|
/**
|
|
5
6
|
* The protocol version and Contract hash a remote caller says it was built for:
|
|
6
7
|
* the Client Contract's for a client, the Agent Contract's for an agent.
|
|
7
8
|
*/
|
|
8
|
-
export type
|
|
9
|
+
export type AvRequestProtocol = {
|
|
9
10
|
readonly version: number;
|
|
10
11
|
readonly hash: string;
|
|
11
12
|
};
|
|
@@ -20,7 +21,7 @@ type RuntimeOperationBase = AvOperationIdentity & {
|
|
|
20
21
|
readonly state?: AvState;
|
|
21
22
|
};
|
|
22
23
|
/** An in-process request, run under the Application Contract. */
|
|
23
|
-
export type
|
|
24
|
+
export type AvApplicationOperationRequest = RuntimeOperationBase & {
|
|
24
25
|
readonly origin: "application";
|
|
25
26
|
readonly protocol?: never;
|
|
26
27
|
readonly transport?: never;
|
|
@@ -29,24 +30,24 @@ export type ApplicationOperationRequest = RuntimeOperationBase & {
|
|
|
29
30
|
* A remote request, run under the Client Contract; `protocol` is the identity
|
|
30
31
|
* the client sent.
|
|
31
32
|
*/
|
|
32
|
-
export type
|
|
33
|
+
export type AvClientOperationRequest = RuntimeOperationBase & {
|
|
33
34
|
readonly origin: "client";
|
|
34
|
-
readonly protocol:
|
|
35
|
+
readonly protocol: AvRequestProtocol;
|
|
35
36
|
readonly transport?: AvTransportContext;
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
39
|
* An AI agent's request, run under the Agent Contract; `protocol` is the
|
|
39
40
|
* identity of the Agent Contract the caller (an MCP server) was built from.
|
|
40
41
|
*/
|
|
41
|
-
export type
|
|
42
|
+
export type AvAgentOperationRequest = RuntimeOperationBase & {
|
|
42
43
|
readonly origin: "agent";
|
|
43
|
-
readonly protocol:
|
|
44
|
+
readonly protocol: AvRequestProtocol;
|
|
44
45
|
readonly transport?: AvTransportContext;
|
|
45
46
|
};
|
|
46
47
|
/** A request from outside the server: a client's or an agent's. */
|
|
47
|
-
export type RemoteOperationRequest =
|
|
48
|
+
export type RemoteOperationRequest = AvClientOperationRequest | AvAgentOperationRequest;
|
|
48
49
|
/** One operation request, as `framework.execute` takes it. */
|
|
49
|
-
export type
|
|
50
|
+
export type AvOperationRequest = AvApplicationOperationRequest | AvClientOperationRequest | AvAgentOperationRequest;
|
|
50
51
|
type WithoutArguments<Request> = Request extends unknown ? Omit<Request, "arguments"> : never;
|
|
51
52
|
/**
|
|
52
53
|
* A request as every stage after the Framework Validation Layer sees it:
|
|
@@ -56,12 +57,18 @@ type WithoutArguments<Request> = Request extends unknown ? Omit<Request, "argume
|
|
|
56
57
|
* unreachable by type. Distributive, so the origin and family/variant
|
|
57
58
|
* correlations survive the omission.
|
|
58
59
|
*/
|
|
59
|
-
export type OperationExecutionRequest = WithoutArguments<
|
|
60
|
+
export type OperationExecutionRequest = WithoutArguments<AvOperationRequest>;
|
|
60
61
|
/**
|
|
61
62
|
* A request whose stages run: its `state` settled once, the seed or the `{}`
|
|
62
63
|
* the runtime made for it, so every stage is told the same object.
|
|
63
64
|
*/
|
|
64
65
|
export type StatefulOperationRequest = OperationExecutionRequest & {
|
|
65
66
|
readonly state: AvState;
|
|
67
|
+
/**
|
|
68
|
+
* The request's policy session, when the policy checks it: a client's or an
|
|
69
|
+
* agent's request, or an application call made `as` a principal. Absent, nothing
|
|
70
|
+
* is checked: an application call, or a call a stage made through `ctx`.
|
|
71
|
+
*/
|
|
72
|
+
readonly policy?: PolicySession;
|
|
66
73
|
};
|
|
67
74
|
export {};
|