@aventara/core 1.0.0-rc.0 → 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 +2068 -1
- package/ERRORS.md +142 -0
- package/README.md +485 -60
- package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
- 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 +33 -11
- package/dist/adapters/adapter-identifier.d.ts +15 -6
- package/dist/adapters/adapter-identifier.js +6 -1
- package/dist/adapters/adapter-model.d.ts +18 -9
- package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
- package/dist/adapters/adapter-operation.d.ts +21 -6
- package/dist/adapters/adapter-resource.d.ts +23 -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 +59 -29
- 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/{json → avz}/avz.js +150 -8
- package/dist/{json → avz}/index.d.ts +2 -1
- package/dist/{json → avz}/json-shape.registry.d.ts +9 -8
- package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
- package/dist/{json → avz}/zod-issue.translator.js +7 -0
- package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
- 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 +23 -17
- package/dist/compiler/contract.compiler.js +753 -443
- 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/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/any-framework-config.d.ts +19 -12
- package/dist/config/computed-fields.d.ts +62 -0
- package/dist/config/computed-fields.js +73 -0
- package/dist/config/config-diagnostic.d.ts +11 -4
- package/dist/config/config-diagnostic.guidance.d.ts +6 -0
- package/dist/config/config-diagnostic.guidance.js +32 -0
- package/dist/config/config-layer.d.ts +15 -6
- package/dist/config/config.resolver.d.ts +98 -31
- package/dist/config/config.resolver.js +173 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +792 -69
- package/dist/config/define-resource.d.ts +53 -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 +4 -3
- package/dist/config/exact-framework-config.d.ts +325 -0
- package/dist/config/field-compute.resolver.d.ts +21 -0
- package/dist/config/field-compute.resolver.js +123 -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 +148 -39
- 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 +127 -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/access-route.rules.d.ts +10 -0
- package/dist/contracts/access-route.rules.js +45 -0
- package/dist/contracts/capability.d.ts +37 -12
- package/dist/contracts/capability.js +20 -0
- package/dist/contracts/client-contract-structure.validator.d.ts +621 -114
- package/dist/contracts/client-contract-structure.validator.js +189 -10
- package/dist/contracts/contract-access.d.ts +29 -0
- package/dist/contracts/contract-access.js +1 -0
- package/dist/contracts/contract-canonicalizer.d.ts +27 -3
- package/dist/contracts/contract-canonicalizer.js +168 -29
- package/dist/contracts/contract-hash.d.ts +11 -7
- package/dist/contracts/contract-hash.js +4 -3
- 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 +51 -17
- 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 +109 -42
- package/dist/contracts/identifier.d.ts +4 -4
- package/dist/contracts/json-schema.projector.d.ts +11 -0
- package/dist/contracts/json-schema.projector.js +78 -0
- package/dist/contracts/json-shape.d.ts +12 -1
- package/dist/contracts/lifecycle-trait.d.ts +2 -2
- 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 +17 -15
- 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/access-facade.d.ts +116 -0
- package/dist/framework/access-facade.js +120 -0
- package/dist/framework/contract-view.d.ts +315 -145
- package/dist/framework/framework-construction.error.d.ts +21 -11
- package/dist/framework/framework-construction.error.js +20 -4
- package/dist/framework/framework.d.ts +71 -26
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +150 -38
- package/dist/framework/operation-facade.d.ts +192 -54
- package/dist/framework/operation-facade.js +10 -1
- package/dist/index.d.ts +67 -50
- package/dist/index.js +7 -6
- package/dist/internal.d.ts +20 -10
- package/dist/internal.js +9 -1
- package/dist/operations/database-refusal.d.ts +51 -0
- package/dist/operations/database-refusal.js +45 -0
- package/dist/operations/operation-arguments.d.ts +381 -228
- package/dist/operations/operation-call.d.ts +31 -28
- package/dist/operations/operation-identity.d.ts +10 -10
- package/dist/operations/operation-result.d.ts +25 -23
- package/dist/operations/operation-validator-core.d.ts +6 -6
- package/dist/operations/operation-validator-core.js +172 -38
- package/dist/operations/operation-validator.d.ts +10 -10
- package/dist/operations/projection-scope.resolver.d.ts +6 -6
- package/dist/operations/structural-limits.walker.d.ts +7 -7
- package/dist/operations/structural-limits.walker.js +145 -0
- package/dist/operations/validation-code.d.ts +11 -6
- package/dist/operations/validation-code.guidance.d.ts +6 -0
- package/dist/operations/validation-code.guidance.js +90 -0
- package/dist/operations/validation-code.js +4 -0
- package/dist/operations/write-scope.resolver.d.ts +10 -6
- 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 +17 -34
- package/dist/protocol/absent-route.responder.js +53 -20
- package/dist/protocol/contract-document.responder.d.ts +5 -4
- package/dist/protocol/contract-document.responder.js +2 -2
- package/dist/protocol/http-request.decoder.d.ts +33 -13
- package/dist/protocol/http-request.decoder.js +34 -11
- package/dist/protocol/http-request.reader.d.ts +9 -6
- package/dist/protocol/http-request.reader.js +1 -0
- 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-headers.d.ts +3 -3
- package/dist/protocol/protocol-surface.d.ts +10 -5
- package/dist/protocol/protocol-surface.js +7 -0
- package/dist/protocol/protocol.binder.d.ts +66 -28
- package/dist/protocol/protocol.binder.js +16 -10
- package/dist/protocol/protocol.handler.d.ts +34 -14
- package/dist/protocol/protocol.handler.js +122 -18
- package/dist/protocol/unmounted-route.error.d.ts +4 -4
- package/dist/protocol/unmounted-route.error.js +2 -2
- package/dist/runtime/caller-data.copier.d.ts +22 -7
- package/dist/runtime/caller-data.copier.js +30 -17
- package/dist/runtime/caller-data.door.d.ts +18 -11
- package/dist/runtime/caller-data.door.js +6 -4
- package/dist/runtime/computed-read-runtime.d.ts +12 -6
- package/dist/runtime/computed-read-runtime.js +271 -71
- package/dist/runtime/computed-value.error.d.ts +7 -6
- package/dist/runtime/computed-value.error.js +5 -4
- package/dist/runtime/context-executor.runtime.d.ts +60 -0
- package/dist/runtime/context-executor.runtime.js +277 -0
- 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 +34 -79
- package/dist/runtime/create-requirement.js +205 -74
- package/dist/runtime/decimal.d.ts +16 -2
- package/dist/runtime/decimal.js +22 -1
- package/dist/runtime/diagnostics-reporter.d.ts +91 -30
- package/dist/runtime/diagnostics-reporter.js +37 -1
- package/dist/runtime/error-boundary.d.ts +73 -9
- package/dist/runtime/error-boundary.js +57 -19
- 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 +18 -2
- package/dist/runtime/field-check.evaluator.d.ts +27 -0
- package/dist/runtime/field-check.evaluator.js +521 -0
- package/dist/runtime/field-compute.d.ts +65 -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 +37 -0
- package/dist/runtime/field-stage.runtime.js +147 -0
- package/dist/runtime/field-validator.runtime.d.ts +29 -0
- package/dist/runtime/field-validator.runtime.js +126 -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 +68 -8
- 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 +32 -2
- package/dist/runtime/framework-warning.emitter.d.ts +6 -0
- package/dist/runtime/framework-warning.emitter.js +8 -0
- 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 +11 -6
- package/dist/runtime/level-lifecycle.runtime.d.ts +26 -0
- package/dist/runtime/level-lifecycle.runtime.js +40 -0
- package/dist/runtime/misuse-reporter.d.ts +12 -12
- package/dist/runtime/mutation-planner.d.ts +20 -16
- package/dist/runtime/mutation-planner.js +48 -35
- package/dist/runtime/nested-write.walker.d.ts +32 -0
- package/dist/runtime/nested-write.walker.js +73 -0
- 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 +45 -11
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +133 -27
- package/dist/runtime/operation-runtime.js +576 -84
- package/dist/runtime/outcome-mapper.d.ts +17 -5
- package/dist/runtime/outcome-mapper.js +23 -6
- package/dist/runtime/output-validator.d.ts +11 -11
- package/dist/runtime/output-validator.js +3 -3
- package/dist/runtime/owned-execution.registry.d.ts +16 -6
- package/dist/runtime/pipe-output.validator.d.ts +43 -18
- package/dist/runtime/pipe-output.validator.js +15 -13
- package/dist/runtime/pipeline.d.ts +221 -34
- package/dist/runtime/readonly-value.d.ts +47 -0
- package/dist/runtime/readonly-value.js +189 -0
- package/dist/runtime/referential-action.d.ts +1 -1
- package/dist/runtime/request-envelope.validator.d.ts +3 -3
- package/dist/runtime/request-envelope.validator.js +12 -7
- 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 +33 -25
- package/dist/runtime/scalar-runtime.js +105 -38
- package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
- package/dist/runtime/unsent-value.normalizer.js +128 -0
- 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 +8 -3
- package/dist/transactions/operation-fingerprint.js +2 -2
- package/dist/transactions/sql-statement.d.ts +85 -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 +167 -0
- package/dist/transactions/transaction-envelope.d.ts +9 -8
- package/dist/transactions/transaction-integrity-error.d.ts +6 -6
- package/dist/transactions/transaction-integrity-error.js +7 -2
- package/dist/transactions/transaction-plan-assembler.d.ts +30 -13
- package/dist/transactions/transaction-plan-assembler.js +184 -32
- package/dist/transactions/transaction-plan-validator.d.ts +50 -25
- package/dist/transactions/transaction-plan-validator.js +96 -38
- package/dist/transactions/transaction-reference-collector.d.ts +5 -5
- package/dist/transactions/transaction-reference-resolver.d.ts +21 -3
- package/dist/transactions/transaction-reference-resolver.js +26 -14
- package/dist/transactions/transaction-reference-validator.d.ts +74 -4
- package/dist/transactions/transaction-reference-validator.js +129 -71
- package/dist/transactions/transaction-reference.d.ts +14 -14
- package/dist/transactions/transaction-reference.js +5 -0
- package/dist/transactions/transaction-request.d.ts +22 -9
- package/dist/transactions/transaction-response.d.ts +6 -6
- package/dist/transactions/transaction-runtime.d.ts +12 -8
- package/dist/transactions/transaction-runtime.js +218 -50
- package/dist/transactions/transaction-settlement.runtime.d.ts +52 -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 +4 -2
- package/dist/transactions/transaction-slot-writer.js +2 -2
- package/dist/transactions/transaction-stage.runtime.d.ts +83 -0
- package/dist/transactions/transaction-stage.runtime.js +126 -0
- package/package.json +11 -9
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -42
- 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 -42
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/json/avz.d.ts +0 -96
- 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/{json → avz}/index.js +0 -0
- /package/dist/{json → avz}/json-shape.registry.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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { emitFrameworkWarning } from "../runtime/framework-warning.emitter.js";
|
|
2
|
+
import { computeOfLayer } from "./field-compute.resolver.js";
|
|
3
|
+
function layerComputedFields(resources) {
|
|
4
|
+
const result = {};
|
|
5
|
+
const compute = computeOfLayer(resources);
|
|
6
|
+
for (const resource of Object.keys(compute).sort()) {
|
|
7
|
+
const fields = compute[resource] ?? {};
|
|
8
|
+
const create = Object.keys(fields)
|
|
9
|
+
.filter((field) => fields[field]?.create !== undefined)
|
|
10
|
+
.sort();
|
|
11
|
+
const update = Object.keys(fields)
|
|
12
|
+
.filter((field) => fields[field]?.update !== undefined)
|
|
13
|
+
.sort();
|
|
14
|
+
if (create.length === 0 && update.length === 0) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
result[resource] = {
|
|
18
|
+
...(create.length === 0 ? {} : { create }),
|
|
19
|
+
...(update.length === 0 ? {} : { update }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
export function computedFieldsOf(source) {
|
|
25
|
+
return {
|
|
26
|
+
agent: layerComputedFields(source.trees.agent),
|
|
27
|
+
agentExtends: source.agentExtends,
|
|
28
|
+
application: layerComputedFields(source.trees.application),
|
|
29
|
+
client: layerComputedFields(source.trees.client),
|
|
30
|
+
root: layerComputedFields(source.trees.root),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const LAYERS = ["root", "application", "client", "agent"];
|
|
34
|
+
const PHASES = ["create", "update"];
|
|
35
|
+
function missingFrom(left, right) {
|
|
36
|
+
const missing = [];
|
|
37
|
+
for (const layer of LAYERS) {
|
|
38
|
+
for (const [resource, phases] of Object.entries(left[layer])) {
|
|
39
|
+
for (const phase of PHASES) {
|
|
40
|
+
for (const field of phases[phase] ?? []) {
|
|
41
|
+
if (!right[layer][resource]?.[phase]?.includes(field)) {
|
|
42
|
+
missing.push(`${layer} ${resource}.${field} (${phase})`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return missing;
|
|
49
|
+
}
|
|
50
|
+
export function computedFieldsDrift(generated, configured) {
|
|
51
|
+
const drift = [
|
|
52
|
+
...missingFrom(configured, generated).map((entry) => `computed in the configuration, not in the types: ${entry}`),
|
|
53
|
+
...missingFrom(generated, configured).map((entry) => `computed in the types, not in the configuration: ${entry}`),
|
|
54
|
+
];
|
|
55
|
+
if (generated.agentExtends !== configured.agentExtends) {
|
|
56
|
+
drift.push(`the agent layer extends "${configured.agentExtends}", the types say "${generated.agentExtends}"`);
|
|
57
|
+
}
|
|
58
|
+
return drift;
|
|
59
|
+
}
|
|
60
|
+
export const STALE_GENERATED_TYPES_WARNING = "AVENTARA_STALE_GENERATED_TYPES";
|
|
61
|
+
export function warnOnStaleComputedFields(generated, configured) {
|
|
62
|
+
if (generated === undefined) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const drift = computedFieldsDrift(generated, configured);
|
|
66
|
+
if (drift.length === 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const message = `generated types are stale: run aventara:prepare. The computed fields the pre-compute stages are typed with differ from the configuration's:\n${drift
|
|
70
|
+
.map((line) => ` - ${line}`)
|
|
71
|
+
.join("\n")}`;
|
|
72
|
+
emitFrameworkWarning(message, STALE_GENERATED_TYPES_WARNING);
|
|
73
|
+
}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
/** Codes of {@link
|
|
2
|
-
export type
|
|
1
|
+
/** Codes of {@link AvConfigDiagnostic}. */
|
|
2
|
+
export type AvConfigDiagnosticCode = "CONFIG_REQUIRED" | "CONFIG_UNKNOWN_PROPERTY" | "CONFIG_INVALID_TYPE" | "CONFIG_INVALID_VALUE"
|
|
3
|
+
/** An rc.0 key that moved in rc.1; the message names where it lives now. */
|
|
4
|
+
| "CONFIG_MOVED_PROPERTY"
|
|
5
|
+
/**
|
|
6
|
+
* A key only the root may hold, written in `application`, `client` or `agent`: a field's
|
|
7
|
+
* `definition` is the root's, and an overlay only chooses its visibility.
|
|
8
|
+
*/
|
|
9
|
+
| "CONFIG_FORBIDDEN_IN_OVERLAY";
|
|
3
10
|
/** One problem found in a configuration, at its path. */
|
|
4
|
-
export type
|
|
5
|
-
readonly code:
|
|
11
|
+
export type AvConfigDiagnostic = {
|
|
12
|
+
readonly code: AvConfigDiagnosticCode;
|
|
6
13
|
readonly path: string;
|
|
7
14
|
readonly message: string;
|
|
8
15
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ErrorCodeDescription } from "../runtime/error-guidance.js";
|
|
2
|
+
import type { AvConfigDiagnosticCode } from "./config-diagnostic.js";
|
|
3
|
+
/** Meaning, cause and fix of every configuration diagnostic code. */
|
|
4
|
+
export declare const CONFIG_DIAGNOSTIC_GUIDANCE: {
|
|
5
|
+
readonly [C in AvConfigDiagnosticCode]: ErrorCodeDescription;
|
|
6
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const CONFIG_DIAGNOSTIC_GUIDANCE = {
|
|
2
|
+
CONFIG_REQUIRED: {
|
|
3
|
+
message: "A required configuration key is missing.",
|
|
4
|
+
cause: "A key that must be present is absent: api, adapter, or an overlay's exposed when the overlay sets exemptions, or policy.engine or policy.principal when policy is set.",
|
|
5
|
+
fix: "Add the key at the diagnostic's path.",
|
|
6
|
+
},
|
|
7
|
+
CONFIG_UNKNOWN_PROPERTY: {
|
|
8
|
+
message: "Unknown configuration key.",
|
|
9
|
+
cause: "A key the configuration does not define at that place: a typo, or a key written at the wrong level of the tree. `policy` and `prebuilt` are root-only keys; in an overlay they read as unknown.",
|
|
10
|
+
fix: 'Remove it, or move it where it belongs (the configuration reference\'s "Where a key can go").',
|
|
11
|
+
},
|
|
12
|
+
CONFIG_INVALID_TYPE: {
|
|
13
|
+
message: "A configuration key has the wrong type.",
|
|
14
|
+
cause: "A value of the wrong type, or a key set to an explicit undefined.",
|
|
15
|
+
fix: "Give the value the type the reference states; leave a key out rather than setting it to undefined.",
|
|
16
|
+
},
|
|
17
|
+
CONFIG_INVALID_VALUE: {
|
|
18
|
+
message: "A configuration value is not allowed.",
|
|
19
|
+
cause: "A malformed api or mcp path, a negative limit, an unknown transactionsStyle, a format that is not a named zod format, forceTransaction under an effective transactionsStyle \"none\", an after check on any action but update, or a policy engine's governed, paths or afterChecks naming a Resource, field or path the Core Contract does not have, or its unheld naming a Resource the data source's model does not have (the message names the Resource or the rule).",
|
|
20
|
+
fix: "Use a value the message allows.",
|
|
21
|
+
},
|
|
22
|
+
CONFIG_MOVED_PROPERTY: {
|
|
23
|
+
message: "A configuration key moved in rc.1.",
|
|
24
|
+
cause: "Configuration written for 1.0.0-rc.0: restrictions, entrypoint, fields, behaviors, transactions or pipelines.before/after.",
|
|
25
|
+
fix: "Move it where the message says: restrictions to exposed + exemptions, entrypoint to api, fields to `resources.<R>.fields.<f>.definition`, transactions to transactionsStyle, before/after to pipelines.hooks.",
|
|
26
|
+
},
|
|
27
|
+
CONFIG_FORBIDDEN_IN_OVERLAY: {
|
|
28
|
+
message: "A root-only key is written in an overlay.",
|
|
29
|
+
cause: "A field definition in application, client or agent.",
|
|
30
|
+
fix: "Define the field once at the root (`resources.<R>.fields.<f>.definition`); an overlay only chooses its visibility.",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One layer of the configuration: `root` is the configuration's own top level
|
|
3
3
|
* and compiles to the Core Contract; `application` and `client` are overlays
|
|
4
|
-
* on top of it and compile to the Application and Client Contracts
|
|
4
|
+
* on top of it and compile to the Application and Client Contracts; `agent`
|
|
5
|
+
* narrows the layer it extends and compiles to the Agent Contract.
|
|
5
6
|
*/
|
|
6
|
-
export type
|
|
7
|
+
export type AvConfigLayerName = "root" | "application" | "client" | "agent";
|
|
7
8
|
/**
|
|
8
|
-
* The layers a request can come from: `application` (in-process calls)
|
|
9
|
-
* `client` (remote calls)
|
|
10
|
-
*
|
|
9
|
+
* The layers a request can come from: `application` (in-process calls),
|
|
10
|
+
* `client` (remote calls) or `agent` (calls an AI agent makes over MCP). Each
|
|
11
|
+
* sees the root configuration plus its own layer, and `agent` the layer it
|
|
12
|
+
* extends between the two.
|
|
11
13
|
*/
|
|
12
|
-
export type
|
|
14
|
+
export type AvRequestOrigin = Exclude<AvConfigLayerName, "root">;
|
|
15
|
+
/**
|
|
16
|
+
* The layer the `agent` layer starts from (its `extends`): its final view is
|
|
17
|
+
* the agent's parent, and its pipelines run before the agent's.
|
|
18
|
+
*/
|
|
19
|
+
export type AvConfigAgentParent = Exclude<AvConfigLayerName, "agent">;
|
|
20
|
+
/** The origins whose requests carry a protocol identity: remote callers. */
|
|
21
|
+
export type RemoteRequestOrigin = Exclude<AvRequestOrigin, "application">;
|
|
@@ -1,38 +1,105 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type
|
|
10
|
-
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
|
|
1
|
+
import type { AvAdapter } from "../adapters/adapter.interface.js";
|
|
2
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
3
|
+
import type { AvContractClientAccess } from "../contracts/contract-access.js";
|
|
4
|
+
import type { AvTransactionCapability } from "../contracts/transaction-capability.js";
|
|
5
|
+
import type { AvPolicyEngine } from "../policy/policy-engine.js";
|
|
6
|
+
import type { AvDiagnosticsSink } from "../runtime/diagnostics-reporter.js";
|
|
7
|
+
import type { AvMisuseSink } from "../runtime/misuse-reporter.js";
|
|
8
|
+
import type { AvConfigAgentParent } from "./config-layer.js";
|
|
9
|
+
import { type ResolvedComputeConfig } from "./field-compute.resolver.js";
|
|
10
|
+
import type { AvConfig, AvConfigLimits } from "./framework-config.js";
|
|
11
|
+
import type { AvConfigFieldDefinition } from "./framework-field-definition.js";
|
|
12
|
+
import { type ResolvedPipelineTree } from "./pipeline-tree.resolver.js";
|
|
13
|
+
/** The root's `policy`, its engine's passive lists read once. */
|
|
14
|
+
export type ResolvedPolicyConfig = {
|
|
15
|
+
/** Where the engine was configured, for the startup diagnostics' paths. */
|
|
16
|
+
readonly at: "policy.engine" | "access.policy";
|
|
17
|
+
readonly engine: AvPolicyEngine;
|
|
18
|
+
readonly principal: NonNullable<AvConfig["policy"]>["principal"];
|
|
19
|
+
/** The governed fields and relations, by Resource. */
|
|
20
|
+
readonly governed: Readonly<Record<string, readonly string[]>>;
|
|
21
|
+
/** The rule paths, by rule name, each a list of segments. */
|
|
22
|
+
readonly paths: Readonly<Record<string, readonly (readonly string[])[]>>;
|
|
23
|
+
/** The writes whose grants carry an `after` condition, by Resource. */
|
|
24
|
+
readonly afterChecks: Readonly<Record<string, readonly string[]>>;
|
|
25
|
+
/** The Resources the rules read in conditions and decide no read of. */
|
|
26
|
+
readonly unheld: readonly string[];
|
|
27
|
+
};
|
|
28
|
+
/** The root's field definitions, by Resource and field name. */
|
|
29
|
+
export type ResolvedFieldDefinitions = Readonly<Record<string, Readonly<Record<string, AvConfigFieldDefinition>>>>;
|
|
30
|
+
/** One resolved layer of the configuration: root, application, client or agent. */
|
|
31
|
+
export type ResolvedFrameworkLayerConfig = {
|
|
32
|
+
/** The compute stages that run for this layer's operations, chained root first. */
|
|
33
|
+
readonly compute: ResolvedComputeConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Whether this layer's exemptions hide (`true`, the root's default) or grant
|
|
36
|
+
* (`false`); `undefined` for an overlay that states none, which keeps the
|
|
37
|
+
* root's view.
|
|
38
|
+
*/
|
|
39
|
+
readonly exposed: boolean | undefined;
|
|
40
|
+
/** This layer's own `exemptions`, as authored; the compiler checks every name. */
|
|
41
|
+
readonly exemptions: unknown;
|
|
42
|
+
readonly limits: AvConfigLimits | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Every stage that runs for this layer's operations, level by level: the root's
|
|
45
|
+
* registrations, then the overlay's, at each level.
|
|
46
|
+
*/
|
|
47
|
+
readonly pipelines: ResolvedPipelineTree;
|
|
48
|
+
readonly transactionsStyle: AvTransactionCapability | undefined;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The MCP endpoint a Framework serves (`mcp` resolved): its mount path in
|
|
52
|
+
* canonical form, and the authorization its callers present, when it has one.
|
|
53
|
+
*/
|
|
54
|
+
export type AvMcpEndpoint = {
|
|
55
|
+
/** The mount path in its canonical form, as `framework.api` is. */
|
|
56
|
+
readonly path: string;
|
|
57
|
+
readonly authorization?: {
|
|
58
|
+
readonly servers: readonly string[];
|
|
59
|
+
readonly verify: (token: string) => unknown | null | Promise<unknown | null>;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/** The agent layer resolved: a layer, and the layer it extends. */
|
|
63
|
+
export type ResolvedAgentLayerConfig = ResolvedFrameworkLayerConfig & {
|
|
64
|
+
/** The layer whose final view the agent narrows (`extends`; `"client"` when left out). */
|
|
65
|
+
readonly parent: AvConfigAgentParent;
|
|
66
|
+
/** Whether the configuration states `agent` or `mcp`. */
|
|
67
|
+
readonly stated: boolean;
|
|
20
68
|
};
|
|
21
69
|
/** A configuration after defaults and overlays are resolved, before compilation. */
|
|
22
|
-
export type ResolvedFrameworkConfig<M extends
|
|
70
|
+
export type ResolvedFrameworkConfig<M extends AvAdapterModel = AvAdapterModel> = {
|
|
23
71
|
/**
|
|
24
|
-
* The mount path in its canonical form: `""` at the
|
|
25
|
-
* `/seg(/seg)*`.
|
|
72
|
+
* The protocol's mount path (`api`) in its canonical form: `""` at the
|
|
73
|
+
* root, otherwise `/seg(/seg)*`.
|
|
26
74
|
*/
|
|
27
|
-
readonly
|
|
28
|
-
|
|
75
|
+
readonly api: string;
|
|
76
|
+
/** The MCP endpoint, when `mcp` turns it on. */
|
|
77
|
+
readonly mcp: AvMcpEndpoint | undefined;
|
|
78
|
+
readonly adapter: AvAdapter<M>;
|
|
29
79
|
/** The diagnostics sink, from the root configuration only. */
|
|
30
|
-
readonly diagnostics:
|
|
80
|
+
readonly diagnostics: AvDiagnosticsSink | undefined;
|
|
31
81
|
/** The misuse sink, from the root configuration only. */
|
|
32
|
-
readonly misuse:
|
|
33
|
-
|
|
34
|
-
readonly
|
|
35
|
-
|
|
82
|
+
readonly misuse: AvMisuseSink | undefined;
|
|
83
|
+
/** The policy, from the root configuration only; absent, nothing is checked. */
|
|
84
|
+
readonly policy: ResolvedPolicyConfig | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The ClientContract's `access` section: present exactly when `access` is
|
|
87
|
+
* configured, with `url` and `verbs` when its provider has `client`.
|
|
88
|
+
*/
|
|
89
|
+
readonly access: AvContractClientAccess | undefined;
|
|
90
|
+
/** Every field definition, from the root only; the same for all three layers. */
|
|
91
|
+
readonly definitions: ResolvedFieldDefinitions;
|
|
92
|
+
/** Each layer's `resources` tree as authored: the compiler checks its names. */
|
|
93
|
+
readonly trees: {
|
|
94
|
+
readonly root: unknown;
|
|
95
|
+
readonly application: unknown;
|
|
96
|
+
readonly client: unknown;
|
|
97
|
+
readonly agent: unknown;
|
|
98
|
+
};
|
|
99
|
+
readonly root: ResolvedFrameworkLayerConfig;
|
|
100
|
+
readonly application: ResolvedFrameworkLayerConfig;
|
|
101
|
+
readonly client: ResolvedFrameworkLayerConfig;
|
|
102
|
+
readonly agent: ResolvedAgentLayerConfig;
|
|
36
103
|
};
|
|
37
|
-
/** Resolve
|
|
38
|
-
export declare function resolveFrameworkConfig<M extends
|
|
104
|
+
/** Resolve every layer of the configuration without compiling Contracts. */
|
|
105
|
+
export declare function resolveFrameworkConfig<M extends AvAdapterModel>(config: AvConfig<M>): ResolvedFrameworkConfig<M>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AvConstructionError } from "../framework/framework-construction.error.js";
|
|
2
|
+
import { ACCESS_VERB_NAMES, providerVerb, } from "../policy/access-verb.table.js";
|
|
3
|
+
import { mountPathRefusalDiagnostic } from "./config.validator.js";
|
|
3
4
|
import { normalizeEntrypoint } from "./entrypoint.normalizer.js";
|
|
5
|
+
import { chainCompute, computeOfLayer, } from "./field-compute.resolver.js";
|
|
6
|
+
import { resolvePipelineTree, } from "./pipeline-tree.resolver.js";
|
|
4
7
|
const hasOwn = (value, key) => Object.hasOwn(value, key);
|
|
5
8
|
function isPlainRecord(value) {
|
|
6
9
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -39,7 +42,7 @@ function resolveRecord(root, scoped) {
|
|
|
39
42
|
}
|
|
40
43
|
return result;
|
|
41
44
|
}
|
|
42
|
-
function
|
|
45
|
+
function resolveOverride(root, scoped, key) {
|
|
43
46
|
if (scoped === undefined || !hasOwn(scoped, key)) {
|
|
44
47
|
return cloneConfigValue(root[key]);
|
|
45
48
|
}
|
|
@@ -49,63 +52,189 @@ function resolveProperty(root, scoped, key) {
|
|
|
49
52
|
? resolveRecord(rootValue, scopedValue)
|
|
50
53
|
: cloneConfigValue(scopedValue);
|
|
51
54
|
}
|
|
52
|
-
function
|
|
55
|
+
function resolveLayer(root, rootCompute, overlay, scoped) {
|
|
53
56
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
],
|
|
67
|
-
filters: [...(root?.filters ?? []), ...(scoped?.filters ?? [])],
|
|
57
|
+
compute: scoped === undefined
|
|
58
|
+
? rootCompute
|
|
59
|
+
: chainCompute(rootCompute, computeOfLayer(scoped.resources)),
|
|
60
|
+
exposed: overlay
|
|
61
|
+
? scoped?.exposed
|
|
62
|
+
: (root.exposed ?? true),
|
|
63
|
+
exemptions: overlay ? scoped?.exemptions : root.exemptions,
|
|
64
|
+
limits: resolveOverride(root, scoped, "limits"),
|
|
65
|
+
transactionsStyle: resolveOverride(root, scoped, "transactionsStyle"),
|
|
66
|
+
pipelines: scoped === undefined
|
|
67
|
+
? resolvePipelineTree([root])
|
|
68
|
+
: resolvePipelineTree([root, scoped]),
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
+
function resolveAgentLayer(root, parentName, parentOverlay, parent, agent, stated) {
|
|
72
|
+
const effective = {
|
|
73
|
+
limits: parent.limits,
|
|
74
|
+
transactionsStyle: parent.transactionsStyle,
|
|
75
|
+
};
|
|
76
|
+
const chain = [root];
|
|
77
|
+
if (parentName !== "root" && parentOverlay !== undefined) {
|
|
78
|
+
chain.push(parentOverlay);
|
|
79
|
+
}
|
|
80
|
+
if (agent !== undefined) {
|
|
81
|
+
chain.push(agent);
|
|
82
|
+
}
|
|
71
83
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
parent: parentName,
|
|
85
|
+
stated,
|
|
86
|
+
compute: agent === undefined
|
|
87
|
+
? parent.compute
|
|
88
|
+
: chainCompute(parent.compute, computeOfLayer(agent.resources)),
|
|
89
|
+
exposed: agent?.exposed,
|
|
90
|
+
exemptions: agent?.exemptions,
|
|
91
|
+
limits: resolveOverride(effective, agent, "limits"),
|
|
92
|
+
transactionsStyle: resolveOverride(effective, agent, "transactionsStyle"),
|
|
93
|
+
pipelines: resolvePipelineTree(chain),
|
|
78
94
|
};
|
|
79
95
|
}
|
|
80
|
-
function
|
|
81
|
-
const
|
|
96
|
+
function definitionsOf(resources) {
|
|
97
|
+
const result = {};
|
|
98
|
+
if (!isPlainRecord(resources)) {
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
for (const [resourceName, resource] of Object.entries(resources)) {
|
|
102
|
+
if (!isPlainRecord(resource) || !isPlainRecord(resource.fields)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
for (const [fieldName, field] of Object.entries(resource.fields)) {
|
|
106
|
+
if (!isPlainRecord(field) || field.definition === undefined) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
result[resourceName] ??= {};
|
|
110
|
+
result[resourceName][fieldName] =
|
|
111
|
+
field.definition;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
function resolveMountPath(value, path) {
|
|
117
|
+
const normalized = normalizeEntrypoint(value);
|
|
82
118
|
if (!normalized.ok) {
|
|
83
|
-
throw new
|
|
84
|
-
|
|
119
|
+
throw new AvConstructionError("configuration", [
|
|
120
|
+
mountPathRefusalDiagnostic(path, normalized.message),
|
|
85
121
|
]);
|
|
86
122
|
}
|
|
87
123
|
return normalized.path;
|
|
88
124
|
}
|
|
125
|
+
function resolveMcp(mcp) {
|
|
126
|
+
if (mcp === undefined) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
if (typeof mcp === "string") {
|
|
130
|
+
return Object.freeze({ path: resolveMountPath(mcp, "mcp") });
|
|
131
|
+
}
|
|
132
|
+
const path = resolveMountPath(mcp.path, "mcp.path");
|
|
133
|
+
const authorization = mcp.authorization;
|
|
134
|
+
return Object.freeze(authorization === undefined
|
|
135
|
+
? { path }
|
|
136
|
+
: {
|
|
137
|
+
path,
|
|
138
|
+
authorization: Object.freeze({
|
|
139
|
+
servers: Object.freeze([...authorization.servers]),
|
|
140
|
+
verify: authorization.verify,
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function frozenLists(value) {
|
|
145
|
+
if (!isPlainRecord(value)) {
|
|
146
|
+
return Object.freeze({});
|
|
147
|
+
}
|
|
148
|
+
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, names]) => [
|
|
149
|
+
key,
|
|
150
|
+
Object.freeze([...names]),
|
|
151
|
+
])));
|
|
152
|
+
}
|
|
153
|
+
function frozenPathLists(value) {
|
|
154
|
+
if (!isPlainRecord(value)) {
|
|
155
|
+
return Object.freeze({});
|
|
156
|
+
}
|
|
157
|
+
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, paths]) => [
|
|
158
|
+
key,
|
|
159
|
+
Object.freeze(paths.map((path) => Object.freeze([...path]))),
|
|
160
|
+
])));
|
|
161
|
+
}
|
|
162
|
+
const accessPrincipal = ({ $state, }) => $state.me ?? null;
|
|
163
|
+
function resolveAccessSection(access) {
|
|
164
|
+
if (access === undefined) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
const client = access.client;
|
|
168
|
+
if (client === undefined) {
|
|
169
|
+
return {};
|
|
170
|
+
}
|
|
171
|
+
const verbs = {};
|
|
172
|
+
for (const name of ACCESS_VERB_NAMES) {
|
|
173
|
+
const verb = providerVerb(client.verbs, name);
|
|
174
|
+
if (verb !== undefined) {
|
|
175
|
+
const { method, path, args, result } = verb;
|
|
176
|
+
verbs[name] = {
|
|
177
|
+
method,
|
|
178
|
+
path,
|
|
179
|
+
...(args === undefined ? {} : { args: args }),
|
|
180
|
+
result: result,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
url: client.url,
|
|
186
|
+
verbs: verbs,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function resolvePolicy(configured, access) {
|
|
190
|
+
const policy = access === undefined
|
|
191
|
+
? configured
|
|
192
|
+
: { engine: access.policy, principal: accessPrincipal };
|
|
193
|
+
if (policy === undefined) {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
return Object.freeze({
|
|
197
|
+
at: access === undefined ? "policy.engine" : "access.policy",
|
|
198
|
+
engine: policy.engine,
|
|
199
|
+
principal: policy.principal,
|
|
200
|
+
governed: frozenLists(policy.engine.governed),
|
|
201
|
+
paths: frozenPathLists(policy.engine.paths),
|
|
202
|
+
afterChecks: frozenLists(policy.engine.afterChecks),
|
|
203
|
+
unheld: Object.freeze(Array.isArray(policy.engine.unheld) ? [...policy.engine.unheld] : []),
|
|
204
|
+
});
|
|
205
|
+
}
|
|
89
206
|
export function resolveFrameworkConfig(config) {
|
|
90
|
-
const root =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
? { transactions: config.transactions }
|
|
100
|
-
: {}),
|
|
207
|
+
const root = config;
|
|
208
|
+
const application = config.application;
|
|
209
|
+
const client = config.client;
|
|
210
|
+
const agent = config.agent;
|
|
211
|
+
const rootCompute = computeOfLayer(root.resources);
|
|
212
|
+
const layers = {
|
|
213
|
+
root: resolveLayer(root, rootCompute, false),
|
|
214
|
+
application: resolveLayer(root, rootCompute, true, application),
|
|
215
|
+
client: resolveLayer(root, rootCompute, true, client),
|
|
101
216
|
};
|
|
217
|
+
const parent = agent?.extends ?? "client";
|
|
102
218
|
return {
|
|
103
|
-
|
|
219
|
+
api: resolveMountPath(config.api, "api"),
|
|
220
|
+
mcp: resolveMcp(config.mcp),
|
|
104
221
|
adapter: config.adapter,
|
|
105
222
|
diagnostics: config.diagnostics,
|
|
106
223
|
misuse: config.misuse,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
224
|
+
policy: resolvePolicy(config.policy, config.access),
|
|
225
|
+
access: resolveAccessSection(config.access),
|
|
226
|
+
definitions: definitionsOf(root.resources),
|
|
227
|
+
trees: {
|
|
228
|
+
root: root.resources,
|
|
229
|
+
application: application?.resources,
|
|
230
|
+
client: client?.resources,
|
|
231
|
+
agent: agent?.resources,
|
|
232
|
+
},
|
|
233
|
+
...layers,
|
|
234
|
+
agent: resolveAgentLayer(root, parent, parent === "application"
|
|
235
|
+
? application
|
|
236
|
+
: parent === "client"
|
|
237
|
+
? client
|
|
238
|
+
: undefined, layers[parent], agent, agent !== undefined || config.mcp !== undefined),
|
|
110
239
|
};
|
|
111
240
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AvConfigDiagnostic } from "./config-diagnostic.js";
|
|
2
2
|
/**
|
|
3
|
-
* The refusal of
|
|
4
|
-
* normalizer's message: it names the defect and the rule — never the
|
|
5
|
-
* carry credentials.
|
|
3
|
+
* The refusal of a mount path (`api`, `mcp`, `mcp.path`) that is not canonical,
|
|
4
|
+
* from the normalizer's message: it names the defect and the rule — never the
|
|
5
|
+
* value, which may carry credentials.
|
|
6
6
|
*/
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function mountPathRefusalDiagnostic(path: string, message: string): AvConfigDiagnostic;
|
|
8
8
|
/**
|
|
9
9
|
* Checks the structure of a configuration object and reports each problem as
|
|
10
|
-
* a {@link
|
|
10
|
+
* a {@link AvConfigDiagnostic}.
|
|
11
11
|
*/
|
|
12
|
-
export declare function validateFrameworkConfig(value: unknown): readonly
|
|
12
|
+
export declare function validateFrameworkConfig(value: unknown): readonly AvConfigDiagnostic[];
|