@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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { DiagnosticsReporter } from "./diagnostics-reporter.js";
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
2
|
+
import { AvError } from "./framework-error.js";
|
|
3
|
+
import type { AvCause, AvOperationErrorCode, AvOperationFailureResponse } from "./operation-response.js";
|
|
4
|
+
import type { AvContext } from "./pipeline.js";
|
|
4
5
|
/** Where an unexpected post-validation exception originated. */
|
|
5
|
-
|
|
6
|
+
type FailureOrigin = "adapter" | "runtime";
|
|
6
7
|
/** The one generic Adapter-failure text; every unexpected A3001 carries it. */
|
|
7
8
|
export declare const ADAPTER_FAILURE_MESSAGE = "Adapter execution failed.";
|
|
8
9
|
/** One boundary instance belongs to one operation execution. */
|
|
@@ -39,18 +40,81 @@ export type CallerArgumentsView = {
|
|
|
39
40
|
* framework's text for its code and reported to the diagnostics channel.
|
|
40
41
|
*/
|
|
41
42
|
export declare const MAX_DEVELOPER_ISSUE_MESSAGE_LENGTH = 1000;
|
|
43
|
+
/** The stable outcome a thrower chose, once the boundary has vetted it. */
|
|
44
|
+
type DeliberateOutcome = {
|
|
45
|
+
readonly code: AvOperationErrorCode;
|
|
46
|
+
readonly cause: AvCause;
|
|
47
|
+
/**
|
|
48
|
+
* Every issue code, issue path and developer issue message the boundary could
|
|
49
|
+
* not vouch for, raw and in supplied order.
|
|
50
|
+
*/
|
|
51
|
+
readonly unvouched: readonly unknown[];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The refusal code `error` deliberately carries, vetted as every boundary vets
|
|
55
|
+
* it ({@link vetDeliberateOutcome}): a recognised error code that is no
|
|
56
|
+
* internal (`A3xxx`) one, with a well-formed cause. `undefined` for anything
|
|
57
|
+
* else, which the caller answers as the defect it is.
|
|
58
|
+
*/
|
|
59
|
+
export declare function deliberateRefusalCode(error: unknown): AvOperationErrorCode | undefined;
|
|
42
60
|
/**
|
|
43
61
|
* Final framework sanitization, shared by every boundary. A deliberate
|
|
44
|
-
* {@link
|
|
62
|
+
* {@link AvError} carries its own stable outcome; anything else is
|
|
45
63
|
* replaced by a generic cause so no provider text, stack, path, or secret
|
|
46
64
|
* can cross the response boundary. Total: it never throws.
|
|
47
65
|
*/
|
|
48
|
-
export declare function sanitizeOperationFailure(error: unknown, origin: FailureOrigin, report: DiagnosticsReporter, view: CallerArgumentsView):
|
|
66
|
+
export declare function sanitizeOperationFailure(error: unknown, origin: FailureOrigin, report: DiagnosticsReporter, view: CallerArgumentsView): AvOperationFailureResponse;
|
|
67
|
+
/**
|
|
68
|
+
* A filter over the context its stage is told: an operation's `AvFilter`,
|
|
69
|
+
* or a Resource transaction filter, whose context is the plan.
|
|
70
|
+
*/
|
|
71
|
+
type FilterOf<Context> = (error: unknown, context: Context) => AvError | undefined | Promise<AvError | undefined>;
|
|
49
72
|
/**
|
|
50
73
|
* Post-validation exception flow: effective filters are stored as `[root...,
|
|
51
74
|
* scoped...]`, so reverse iteration tries scoped filters in reverse registration
|
|
52
|
-
* order, then root filters in reverse
|
|
53
|
-
*
|
|
54
|
-
*
|
|
75
|
+
* order, then root filters in reverse. An error they leave unhandled goes to
|
|
76
|
+
* `outer` when there is one (a transaction step's: its Resource transaction
|
|
77
|
+
* filters, run once the transaction interceptors have unwound), else to final
|
|
78
|
+
* sanitization. A filter handles an error only by returning a {@link AvError};
|
|
79
|
+
* returning `undefined` or throwing leaves the original error unhandled.
|
|
55
80
|
*/
|
|
56
|
-
export declare function resolveOperationFailure(error: unknown, filters: readonly
|
|
81
|
+
export declare function resolveOperationFailure<Context = AvContext>(error: unknown, filters: readonly FilterOf<Context>[], context: Context, boundary: AdapterBoundary, report: DiagnosticsReporter, view: CallerArgumentsView, outer?: OuterFailureLayer): Promise<AvOperationFailureResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* An error a step's own filters left unhandled, with what answering it later
|
|
84
|
+
* needs: the caller's arguments as the step held them, the step's Adapter
|
|
85
|
+
* boundary (whose identity says whose words the error is) and its reporter.
|
|
86
|
+
*/
|
|
87
|
+
export type UnhandledFailure = {
|
|
88
|
+
readonly error: unknown;
|
|
89
|
+
readonly view: CallerArgumentsView;
|
|
90
|
+
readonly boundary: AdapterBoundary;
|
|
91
|
+
readonly report: DiagnosticsReporter;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Where a transaction step hands an error its own filters left unhandled. It
|
|
95
|
+
* records the error and answers a provisional failure, which fails the step; the
|
|
96
|
+
* transaction replaces it with the transaction filters' answer.
|
|
97
|
+
*/
|
|
98
|
+
export type OuterFailureLayer = {
|
|
99
|
+
readonly defer: (failure: UnhandledFailure) => AvOperationFailureResponse;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* An unhandled step error through `chain` (the transaction filters, the first
|
|
103
|
+
* that handles it wins), then final sanitization.
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolveUnhandledFailure(failure: UnhandledFailure, chain: FilterChain): Promise<AvOperationFailureResponse>;
|
|
106
|
+
/**
|
|
107
|
+
* A chain of filters and the context they are told, tried in reverse: the first
|
|
108
|
+
* that returns an {@link AvError} handles the error.
|
|
109
|
+
*/
|
|
110
|
+
type FilterChain = {
|
|
111
|
+
readonly attempt: (error: unknown, view: CallerArgumentsView, boundary: AdapterBoundary) => Promise<FilteredOutcome | undefined>;
|
|
112
|
+
};
|
|
113
|
+
/** The chain of `filters` (stored outer to inner, tried in reverse), told `context`. */
|
|
114
|
+
export declare function filterChain<Context>(filters: readonly FilterOf<Context>[], context: Context): FilterChain;
|
|
115
|
+
/** What a filter returned, and the deliberate outcome it vets as. */
|
|
116
|
+
type FilteredOutcome = {
|
|
117
|
+
readonly returned: unknown;
|
|
118
|
+
readonly outcome: DeliberateOutcome;
|
|
119
|
+
};
|
|
120
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { isDatabaseRefusalMessage } from "../operations/database-refusal.js";
|
|
1
2
|
import { VALIDATION_CODE_MESSAGES, VALIDATION_CODES, } from "../operations/validation-code.js";
|
|
2
|
-
import {
|
|
3
|
+
import { AvError } from "./framework-error.js";
|
|
3
4
|
import { INTERNAL_FAILURE_MESSAGE, internalFailure, OPERATION_CODES, operationFailure, } from "./operation-response.js";
|
|
4
5
|
import { PIPE_OUTPUT_FAILURE_MESSAGE } from "./pipe-output.validator.js";
|
|
5
6
|
export const ADAPTER_FAILURE_MESSAGE = "Adapter execution failed.";
|
|
@@ -164,6 +165,9 @@ function projectIssue(value, unvouched, view, author) {
|
|
|
164
165
|
unvouched.push(supplied);
|
|
165
166
|
}
|
|
166
167
|
}
|
|
168
|
+
else if (isDatabaseRefusalMessage(code, supplied)) {
|
|
169
|
+
message = supplied;
|
|
170
|
+
}
|
|
167
171
|
if (rawPath === undefined) {
|
|
168
172
|
return { code, message };
|
|
169
173
|
}
|
|
@@ -207,7 +211,7 @@ function readProperty(value, key) {
|
|
|
207
211
|
}
|
|
208
212
|
function isFrameworkErrorInstance(error) {
|
|
209
213
|
try {
|
|
210
|
-
return error instanceof
|
|
214
|
+
return error instanceof AvError;
|
|
211
215
|
}
|
|
212
216
|
catch {
|
|
213
217
|
return false;
|
|
@@ -238,6 +242,14 @@ function vetDeliberateOutcome(error, view, author) {
|
|
|
238
242
|
const cause = projectCause(rawCause, unvouched, view, author);
|
|
239
243
|
return cause === undefined ? MALFORMED_OUTCOME : { code, cause, unvouched };
|
|
240
244
|
}
|
|
245
|
+
export function deliberateRefusalCode(error) {
|
|
246
|
+
const outcome = vetDeliberateOutcome(error, { path: [], arguments: undefined }, "developer");
|
|
247
|
+
return outcome === undefined ||
|
|
248
|
+
outcome === MALFORMED_OUTCOME ||
|
|
249
|
+
isInternalCode(outcome.code)
|
|
250
|
+
? undefined
|
|
251
|
+
: outcome.code;
|
|
252
|
+
}
|
|
241
253
|
function reportUnvouched(outcome, report) {
|
|
242
254
|
for (const value of outcome.unvouched) {
|
|
243
255
|
report(value, outcome.code);
|
|
@@ -269,24 +281,50 @@ export function sanitizeOperationFailure(error, origin, report, view) {
|
|
|
269
281
|
}
|
|
270
282
|
return deliberateFailure(outcome);
|
|
271
283
|
}
|
|
272
|
-
export async function resolveOperationFailure(error, filters, context, boundary, report, view) {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
284
|
+
export async function resolveOperationFailure(error, filters, context, boundary, report, view, outer) {
|
|
285
|
+
const failure = { error, view, boundary, report };
|
|
286
|
+
const handled = await filterChain(filters, context).attempt(error, view, boundary);
|
|
287
|
+
if (handled !== undefined) {
|
|
288
|
+
return answerHandled(failure, handled);
|
|
289
|
+
}
|
|
290
|
+
return outer === undefined
|
|
291
|
+
? sanitizeUnhandled(failure)
|
|
292
|
+
: outer.defer(failure);
|
|
293
|
+
}
|
|
294
|
+
function answerHandled(failure, handled) {
|
|
295
|
+
if (handled.outcome === MALFORMED_OUTCOME) {
|
|
296
|
+
failure.report(failure.error, "A3000");
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
reportDeliberate(handled.returned, handled.outcome, failure.report);
|
|
288
300
|
}
|
|
289
|
-
return
|
|
301
|
+
return deliberateFailure(handled.outcome);
|
|
302
|
+
}
|
|
303
|
+
function sanitizeUnhandled(failure) {
|
|
304
|
+
return sanitizeOperationFailure(failure.error, failure.boundary.originOf(failure.error), failure.report, failure.view);
|
|
305
|
+
}
|
|
306
|
+
export async function resolveUnhandledFailure(failure, chain) {
|
|
307
|
+
const handled = await chain.attempt(failure.error, failure.view, failure.boundary);
|
|
308
|
+
return handled === undefined
|
|
309
|
+
? sanitizeUnhandled(failure)
|
|
310
|
+
: answerHandled(failure, handled);
|
|
311
|
+
}
|
|
312
|
+
export function filterChain(filters, context) {
|
|
313
|
+
return {
|
|
314
|
+
attempt: async (error, view, boundary) => {
|
|
315
|
+
for (let index = filters.length - 1; index >= 0; index -= 1) {
|
|
316
|
+
const filter = filters[index];
|
|
317
|
+
if (filter === undefined) {
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
const handled = await attemptFilter(filter, error, context, view, boundary);
|
|
321
|
+
if (handled !== undefined) {
|
|
322
|
+
return handled;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return undefined;
|
|
326
|
+
},
|
|
327
|
+
};
|
|
290
328
|
}
|
|
291
329
|
async function attemptFilter(filter, error, context, view, boundary) {
|
|
292
330
|
try {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Why a code is answered, and what the one who meets it should do. */
|
|
2
|
+
export type ErrorCodeGuidance = {
|
|
3
|
+
/** What typically produced the code, in a sentence or two. */
|
|
4
|
+
readonly cause: string;
|
|
5
|
+
/** What to change so it does not happen again. */
|
|
6
|
+
readonly fix: string;
|
|
7
|
+
};
|
|
8
|
+
/** Guidance for a code whose table holds no message of its own. */
|
|
9
|
+
export type ErrorCodeDescription = ErrorCodeGuidance & {
|
|
10
|
+
/** The code's meaning, in one short sentence. */
|
|
11
|
+
readonly message: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AvAdapterDiscoveryDiagnosticCode } from "../adapters/adapter-discovery-diagnostic.js";
|
|
2
|
+
import type { AvContractCompilerDiagnosticCode } from "../compiler/contract-compiler-diagnostic.js";
|
|
3
|
+
import type { AvConfigDiagnosticCode } from "../config/config-diagnostic.js";
|
|
4
|
+
import type { AvConstructionStage } from "../framework/framework-construction.error.js";
|
|
5
|
+
import { type AvValidationCode } from "../operations/validation-code.js";
|
|
6
|
+
import { type AvOperationCode } from "./operation-response.js";
|
|
7
|
+
/**
|
|
8
|
+
* The documentation page every catalog entry links into. Each code has its own
|
|
9
|
+
* anchor there: the code in lower case (`#a2004`, `#config_required`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const ERROR_CODES_DOCS_URL = "https://aventara-framework.vercel.app/docs/error-codes";
|
|
12
|
+
/**
|
|
13
|
+
* What kind of code an entry is: an outcome code's family (`success` `A1xxx`,
|
|
14
|
+
* `request` `A2xxx`, `internal` `A3xxx`, `auth` `A4xxx`), a `validation` issue
|
|
15
|
+
* code (`V1xxx`), or a startup code, by the construction stage that reports it.
|
|
16
|
+
*/
|
|
17
|
+
export type AvErrorKind = "success" | "request" | "internal" | "auth" | "validation" | AvConstructionStage;
|
|
18
|
+
/** Every code the catalog describes: outcome, validation and startup codes. */
|
|
19
|
+
export type AvErrorCatalogCode = AvOperationCode | AvValidationCode | AvConfigDiagnosticCode | AvAdapterDiscoveryDiagnosticCode | AvContractCompilerDiagnosticCode;
|
|
20
|
+
/** One code: what it means, why it happens, what to do, and where it is documented. */
|
|
21
|
+
export type AvErrorCatalogEntry<C extends AvErrorCatalogCode = AvErrorCatalogCode> = {
|
|
22
|
+
readonly code: C;
|
|
23
|
+
readonly kind: AvErrorKind;
|
|
24
|
+
/** Its meaning in one sentence; for a V-code, the framework's message for it. */
|
|
25
|
+
readonly message: string;
|
|
26
|
+
/** What typically produces it. */
|
|
27
|
+
readonly cause: string;
|
|
28
|
+
/** What to change. */
|
|
29
|
+
readonly fix: string;
|
|
30
|
+
/** Its entry on the error-codes page. */
|
|
31
|
+
readonly docs: string;
|
|
32
|
+
};
|
|
33
|
+
/** The error catalog's type: one entry per code. */
|
|
34
|
+
export type AvErrorCatalog = {
|
|
35
|
+
readonly [C in AvErrorCatalogCode]: AvErrorCatalogEntry<C>;
|
|
36
|
+
};
|
|
37
|
+
/** The documentation URL of one code: the error-codes page at its anchor. */
|
|
38
|
+
export declare function errorDocsUrl(code: AvErrorCatalogCode): string;
|
|
39
|
+
/**
|
|
40
|
+
* Every code Aventara answers or refuses with, by code: its `kind`, `message`,
|
|
41
|
+
* `cause`, `fix` and `docs` URL. An operation's `code`, a validation issue's
|
|
42
|
+
* `code` and a startup diagnostic's `code` are all keys of it:
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* AvErrorCatalog[error.code].fix;
|
|
46
|
+
* AvErrorCatalog.V1000.docs; // https://aventara-framework.vercel.app/docs/error-codes#v1000
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const AvErrorCatalog: AvErrorCatalog;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ADAPTER_DISCOVERY_DIAGNOSTIC_GUIDANCE } from "../adapters/adapter-discovery-diagnostic.guidance.js";
|
|
2
|
+
import { CONTRACT_COMPILER_DIAGNOSTIC_GUIDANCE } from "../compiler/contract-compiler-diagnostic.guidance.js";
|
|
3
|
+
import { CONFIG_DIAGNOSTIC_GUIDANCE } from "../config/config-diagnostic.guidance.js";
|
|
4
|
+
import { VALIDATION_CODE_GUIDANCE } from "../operations/validation-code.guidance.js";
|
|
5
|
+
import { VALIDATION_CODE_MESSAGES, VALIDATION_CODES, } from "../operations/validation-code.js";
|
|
6
|
+
import { OPERATION_CODE_GUIDANCE } from "./operation-code.guidance.js";
|
|
7
|
+
import { OPERATION_CODES } from "./operation-response.js";
|
|
8
|
+
export const ERROR_CODES_DOCS_URL = "https://aventara-framework.vercel.app/docs/error-codes";
|
|
9
|
+
export function errorDocsUrl(code) {
|
|
10
|
+
return `${ERROR_CODES_DOCS_URL}#${code.toLowerCase()}`;
|
|
11
|
+
}
|
|
12
|
+
const OUTCOME_KIND = {
|
|
13
|
+
"1": "success",
|
|
14
|
+
"2": "request",
|
|
15
|
+
"3": "internal",
|
|
16
|
+
"4": "auth",
|
|
17
|
+
};
|
|
18
|
+
function entry(code, kind, description) {
|
|
19
|
+
return Object.freeze({
|
|
20
|
+
code,
|
|
21
|
+
kind,
|
|
22
|
+
message: description.message,
|
|
23
|
+
cause: description.cause,
|
|
24
|
+
fix: description.fix,
|
|
25
|
+
docs: errorDocsUrl(code),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function entriesOf(table, kind) {
|
|
29
|
+
return Object.keys(table).map((code) => [
|
|
30
|
+
code,
|
|
31
|
+
entry(code, kind, table[code]),
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
export const AvErrorCatalog = Object.freeze(Object.fromEntries([
|
|
35
|
+
...OPERATION_CODES.map((code) => [
|
|
36
|
+
code,
|
|
37
|
+
entry(code, OUTCOME_KIND[code[1]], OPERATION_CODE_GUIDANCE[code]),
|
|
38
|
+
]),
|
|
39
|
+
...VALIDATION_CODES.map((code) => [
|
|
40
|
+
code,
|
|
41
|
+
entry(code, "validation", {
|
|
42
|
+
message: VALIDATION_CODE_MESSAGES[code],
|
|
43
|
+
...VALIDATION_CODE_GUIDANCE[code],
|
|
44
|
+
}),
|
|
45
|
+
]),
|
|
46
|
+
...entriesOf(CONFIG_DIAGNOSTIC_GUIDANCE, "configuration"),
|
|
47
|
+
...entriesOf(ADAPTER_DISCOVERY_DIAGNOSTIC_GUIDANCE, "discovery"),
|
|
48
|
+
...entriesOf(CONTRACT_COMPILER_DIAGNOSTIC_GUIDANCE, "contract-compilation"),
|
|
49
|
+
]));
|
|
@@ -1,13 +1,29 @@
|
|
|
1
|
+
import type { AvState } from "./request-state.js";
|
|
1
2
|
/**
|
|
2
3
|
* Options for one in-process call: the optional second argument of every
|
|
3
4
|
* `framework.application.*` / `framework.client.*` call and of
|
|
4
5
|
* `framework.transaction`.
|
|
5
6
|
*/
|
|
6
|
-
export type
|
|
7
|
+
export type AvExecutionOptions = {
|
|
7
8
|
/**
|
|
8
9
|
* The id every pipeline context and every diagnostic of this call or run
|
|
9
|
-
* carries
|
|
10
|
+
* carries, such as a correlation id the caller already holds. Omitted, the Framework
|
|
10
11
|
* mints one; the empty string counts as omitted.
|
|
11
12
|
*/
|
|
12
13
|
readonly requestId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The call's or run's `ctx.$state`: the one object every stage of it, and
|
|
16
|
+
* every ctx call those stages make, reads and writes. It is used as it is, not
|
|
17
|
+
* copied, so the caller sees what the stages wrote. Omitted (or not an
|
|
18
|
+
* object), the Framework starts the request with `{}`.
|
|
19
|
+
*/
|
|
20
|
+
readonly state?: AvState & object;
|
|
21
|
+
/**
|
|
22
|
+
* The principal the call or run is checked as by the configuration's
|
|
23
|
+
* `policy`. An application call names one to opt in: left out, it is server
|
|
24
|
+
* code and the policy does not check it. A `framework.client.*` call is
|
|
25
|
+
* checked either way, and `as` replaces the principal `policy.principal`
|
|
26
|
+
* would derive from its state. `null` is the anonymous principal.
|
|
27
|
+
*/
|
|
28
|
+
readonly as?: unknown;
|
|
13
29
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AvFieldCheck } from "../contracts/field-check.js";
|
|
2
|
+
import type { AvValidationIssue } from "../operations/validation-code.js";
|
|
3
|
+
/** What a check judges: the runtime form of the value it is given. */
|
|
4
|
+
export type FieldCheckSubject = "string" | "number" | "bigint" | "decimal" | "datetime" | "bytes";
|
|
5
|
+
/**
|
|
6
|
+
* What a check judges on a field of each scalar type that takes checks; a field
|
|
7
|
+
* of any other type (an enum's) holds a string.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FIELD_CHECK_SUBJECTS: Readonly<Record<string, FieldCheckSubject>>;
|
|
10
|
+
type Path = readonly (string | number)[];
|
|
11
|
+
/**
|
|
12
|
+
* Whether `value` passes `check`; `true` for a value the check does not judge
|
|
13
|
+
* (a value of another form, which validation refused before the checks run).
|
|
14
|
+
*/
|
|
15
|
+
export declare function passesFieldCheck(check: AvFieldCheck, value: unknown, subject: FieldCheckSubject): boolean;
|
|
16
|
+
/** The issue of one failed check at `path`: its V-code, zod's check and its parameters. */
|
|
17
|
+
export declare function fieldCheckIssue(check: AvFieldCheck, subject: FieldCheckSubject, path: Path): AvValidationIssue;
|
|
18
|
+
/**
|
|
19
|
+
* The issues of the checks `value` breaks, one per broken check, in the checks'
|
|
20
|
+
* order. On a list (`list`), a `list: true` length check judges the list at
|
|
21
|
+
* `path` and every other check judges each entry, at its index; `null` is no
|
|
22
|
+
* value and breaks nothing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function fieldCheckIssues(checks: readonly AvFieldCheck[], value: unknown, subject: FieldCheckSubject, path: Path, list: boolean): readonly AvValidationIssue[];
|
|
25
|
+
/** The issues of the checks one value — a whole value, or a list's entry — breaks. */
|
|
26
|
+
export declare function entryCheckIssues(checks: readonly AvFieldCheck[], value: unknown, subject: FieldCheckSubject, path: Path): readonly AvValidationIssue[];
|
|
27
|
+
export {};
|