@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,127 @@
|
|
|
1
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
2
|
+
import type { AvAdapterFieldKey } from "../adapters/adapter-resource.js";
|
|
3
|
+
import type { AvZCheck } from "../avz/avz-check.registry.js";
|
|
4
|
+
import type { AvOperationFamily } from "../operations/operation-identity.js";
|
|
5
|
+
import type { AvPreComputeStageArguments, AvStageArguments } from "../runtime/pipeline.js";
|
|
6
|
+
import type { AvConfigAny } from "./any-framework-config.js";
|
|
7
|
+
import type { AvPreComputeLift } from "./computed-fields.js";
|
|
8
|
+
import type { AvConfigLayerName } from "./config-layer.js";
|
|
9
|
+
import type { AvEffectiveFieldKey } from "./effective-fields.js";
|
|
10
|
+
import type { AvRelationFieldPipeline, AvScalarFieldPipeline } from "./field-pipeline-config.js";
|
|
11
|
+
import type { AvConfigAddedFieldDefinition, AvConfigFieldDefinition, AvConfigKnownFieldDefinition, AvConfigResourceKey } from "./framework-field-definition.js";
|
|
12
|
+
import type { AvPipeline, AvTransactionPipeline } from "./pipeline-config.js";
|
|
13
|
+
/**
|
|
14
|
+
* Whether a layer is the root, where fields are defined, or an overlay
|
|
15
|
+
* (`application`, `client`), which registers stages on them but never defines one.
|
|
16
|
+
*/
|
|
17
|
+
export type AvConfigLayerKind = "root" | "overlay";
|
|
18
|
+
/** One operation variant's level: its stages and `forceTransaction`. */
|
|
19
|
+
export type AvConfigVariant<M extends AvAdapterModel = AvAdapterModel, R extends string = AvConfigResourceKey<M>, F extends AvOperationFamily = AvOperationFamily, V extends string = string, A = NoInfer<AvStageArguments<M, R, F, V>>, PreCompute = NoInfer<AvPreComputeStageArguments<M, R, F, V>>> = {
|
|
20
|
+
/**
|
|
21
|
+
* Stages that run for this one operation: at a variant, `ctx.$args` (and a
|
|
22
|
+
* pipe's arguments) are typed as the operation's arguments; in a guard, a
|
|
23
|
+
* pipe or a filter a create may lack the fields `compute.create` fills
|
|
24
|
+
* (write compute runs after them).
|
|
25
|
+
*/
|
|
26
|
+
readonly pipelines?: AvPipeline<NoInfer<M>, R, F, V, A, PreCompute>;
|
|
27
|
+
/** Runs a plain call of this operation as a one-step transaction. */
|
|
28
|
+
readonly forceTransaction?: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* One operation family's level: stages and `forceTransaction` for every variant
|
|
32
|
+
* of it, and each variant's own level by name.
|
|
33
|
+
*/
|
|
34
|
+
export type AvConfigFamily<M extends AvAdapterModel = AvAdapterModel, Variants = {
|
|
35
|
+
readonly [V in "first" | "unique" | "many" | "count" | "one"]?: unknown;
|
|
36
|
+
}, R extends string = AvConfigResourceKey<M>, F extends AvOperationFamily = AvOperationFamily, Layer extends AvConfigLayerName = "root"> = AvConfigVariant<M, R, F, F extends "create" | "update" | "delete" ? Extract<keyof NonNullable<Variants>, string> | "one" : Extract<keyof NonNullable<Variants>, string>, unknown, unknown> & {
|
|
37
|
+
readonly [V in Extract<keyof NonNullable<Variants>, string>]?: AvConfigVariant<M, R, F, V, NoInfer<AvStageArguments<M, R, F, V>>, NoInfer<AvPreComputeStageArguments<M, R, F, V, AvPreComputeLift<M, Layer>>>> | undefined;
|
|
38
|
+
};
|
|
39
|
+
/** A Resource's families, as the adapter model offers them, each with its level. */
|
|
40
|
+
export type AvConfigOperations<M extends AvAdapterModel = AvAdapterModel, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>, Layer extends AvConfigLayerName = "root"> = {
|
|
41
|
+
readonly [F in Extract<keyof M["resources"][R]["operations"], AvOperationFamily>]?: AvConfigFamily<M, M["resources"][R]["operations"][F], R, F, Layer>;
|
|
42
|
+
};
|
|
43
|
+
/** A Resource's transaction level. */
|
|
44
|
+
export type AvConfigResourceTransactions<M extends AvAdapterModel = AvAdapterModel> = {
|
|
45
|
+
/** Stages that run once per transaction with a top-level step on the Resource. */
|
|
46
|
+
readonly pipelines?: AvTransactionPipeline<NoInfer<M>>;
|
|
47
|
+
};
|
|
48
|
+
/** A field's entry at the root: its definition and its stages. */
|
|
49
|
+
export type AvConfigRootField<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = {
|
|
50
|
+
/** What the field is. Root only. */
|
|
51
|
+
readonly definition?: AvConfigFieldDefinition<M>;
|
|
52
|
+
/** The field's stages. */
|
|
53
|
+
readonly pipelines?: AvScalarFieldPipeline<M, Cfg, R>;
|
|
54
|
+
};
|
|
55
|
+
/** A field's entry in an overlay: its stages only. */
|
|
56
|
+
export type AvConfigOverlayField<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = {
|
|
57
|
+
/** The field's stages, added to the root's. */
|
|
58
|
+
readonly pipelines?: AvScalarFieldPipeline<M, Cfg, R>;
|
|
59
|
+
};
|
|
60
|
+
/** The checks a scalar type takes, or `never`. */
|
|
61
|
+
type ScalarChecks<Scalar> = Scalar extends "string" ? AvZCheck<"string"> : Scalar extends "int" | "float" ? AvZCheck<"number"> : Scalar extends "bigint" | "decimal" | "datetime" | "bytes" ? AvZCheck<Scalar> : never;
|
|
62
|
+
/** The checks a discovered scalar field takes: its type's, and a list's length. */
|
|
63
|
+
type FieldCheckOf<Field> = Field extends {
|
|
64
|
+
readonly type: infer Type;
|
|
65
|
+
readonly list: infer List;
|
|
66
|
+
} ? (Type extends {
|
|
67
|
+
readonly scalar: infer Scalar;
|
|
68
|
+
} ? string extends Scalar ? AvZCheck : ScalarChecks<Scalar> : never) | (false extends List ? never : AvZCheck<"list">) : AvZCheck;
|
|
69
|
+
/** A discovered scalar field's stages, its `validators` typed by the field. */
|
|
70
|
+
type KnownScalarFieldPipeline<M extends AvAdapterModel, Cfg, R extends AvConfigResourceKey<M>, Field> = Field extends {
|
|
71
|
+
readonly type: {
|
|
72
|
+
readonly scalar: "json";
|
|
73
|
+
};
|
|
74
|
+
} ? Omit<AvScalarFieldPipeline<M, Cfg, R>, "validators"> & {
|
|
75
|
+
/** A Json field's checks are in its shape (`definition.json`). */
|
|
76
|
+
readonly validators?: never;
|
|
77
|
+
} : AvScalarFieldPipeline<M, Cfg, R, FieldCheckOf<Field>>;
|
|
78
|
+
/** The root entry one effective field name admits. */
|
|
79
|
+
type RootFieldConfigFor<M extends AvAdapterModel, Cfg, R extends AvConfigResourceKey<M>, F extends string> = string extends F ? AvConfigRootField<M, Cfg, R> : F extends AvAdapterFieldKey<M, R> ? M["resources"][R]["fields"][F] extends {
|
|
80
|
+
readonly kind: "relation";
|
|
81
|
+
} ? {
|
|
82
|
+
readonly definition?: never;
|
|
83
|
+
readonly pipelines?: AvRelationFieldPipeline<M, R>;
|
|
84
|
+
} : {
|
|
85
|
+
readonly definition?: AvConfigKnownFieldDefinition<M["resources"][R]["fields"][F]>;
|
|
86
|
+
readonly pipelines?: KnownScalarFieldPipeline<M, Cfg, R, M["resources"][R]["fields"][F]>;
|
|
87
|
+
} : {
|
|
88
|
+
readonly definition: AvConfigAddedFieldDefinition<M>;
|
|
89
|
+
readonly pipelines?: AvScalarFieldPipeline<M, Cfg, R>;
|
|
90
|
+
};
|
|
91
|
+
/** The overlay entry one effective field name admits. */
|
|
92
|
+
type OverlayFieldConfigFor<M extends AvAdapterModel, Cfg, R extends AvConfigResourceKey<M>, F extends string> = string extends F ? AvConfigOverlayField<M, Cfg, R> : F extends AvAdapterFieldKey<M, R> ? M["resources"][R]["fields"][F] extends {
|
|
93
|
+
readonly kind: "relation";
|
|
94
|
+
} ? {
|
|
95
|
+
readonly pipelines?: AvRelationFieldPipeline<M, R>;
|
|
96
|
+
} : {
|
|
97
|
+
readonly pipelines?: KnownScalarFieldPipeline<M, Cfg, R, M["resources"][R]["fields"][F]>;
|
|
98
|
+
} : AvConfigOverlayField<M, Cfg, R>;
|
|
99
|
+
/** A Resource's fields at one layer, keyed by its effective field names. */
|
|
100
|
+
export type AvConfigResourceFields<in out M extends AvAdapterModel = AvAdapterModel, in out Cfg = AvConfigAny, in out R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>, Kind extends AvConfigLayerKind = "root"> = {
|
|
101
|
+
readonly [F in AvEffectiveFieldKey<M, Cfg, R>]?: Kind extends "root" ? RootFieldConfigFor<M, Cfg, R, F> : OverlayFieldConfigFor<M, Cfg, R, F>;
|
|
102
|
+
};
|
|
103
|
+
/** One Resource's tree: its stages, operations, transactions and fields. */
|
|
104
|
+
export type AvConfigResource<in out M extends AvAdapterModel = AvAdapterModel, in out Cfg = AvConfigAny, in out R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>, Kind extends AvConfigLayerKind = "root", Layer extends AvConfigLayerName = LayerOfKind<Kind>> = {
|
|
105
|
+
/** Stages that run for every operation of this Resource. */
|
|
106
|
+
readonly pipelines?: AvPipeline<NoInfer<M>, R>;
|
|
107
|
+
/** Per family, and per variant under its family. */
|
|
108
|
+
readonly operations?: AvConfigOperations<M, R, Layer>;
|
|
109
|
+
/** Stages that run once per transaction with a top-level step on this Resource. */
|
|
110
|
+
readonly transactions?: AvConfigResourceTransactions<M>;
|
|
111
|
+
/** Per field: its definition (root only) and its stages. */
|
|
112
|
+
readonly fields?: AvConfigResourceFields<M, Cfg, R, Kind>;
|
|
113
|
+
/**
|
|
114
|
+
* `true`: another service owns this Resource's table and migrates it. It is
|
|
115
|
+
* read and joined, never written: it has no write operation, no nested write
|
|
116
|
+
* reaches its rows, and the client and agent Contracts leave it out, with
|
|
117
|
+
* every relation to it. Root only.
|
|
118
|
+
*/
|
|
119
|
+
readonly managedElsewhere?: Kind extends "root" ? boolean : never;
|
|
120
|
+
};
|
|
121
|
+
/** The `resources` tree of one layer, keyed by the adapter's Resource names. */
|
|
122
|
+
export type AvConfigResources<in out M extends AvAdapterModel = AvAdapterModel, in out Cfg = AvConfigAny, in out Kind extends AvConfigLayerKind = "root", in out Layer extends AvConfigLayerName = LayerOfKind<Kind>> = {
|
|
123
|
+
readonly [R in AvConfigResourceKey<M>]?: AvConfigResource<M, Cfg, R, Kind, Layer>;
|
|
124
|
+
};
|
|
125
|
+
/** The layers a tree of kind `Kind` may be written in, when it names none. */
|
|
126
|
+
export type LayerOfKind<Kind extends AvConfigLayerKind> = Kind extends "root" ? "root" : Exclude<AvConfigLayerName, "root">;
|
|
127
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,29 +1,65 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
2
|
+
import type { AvOperationFamily } from "../operations/operation-identity.js";
|
|
3
|
+
import type { AvAfterHook, AvBeforeHook, AvFilter, AvGuard, AvInterceptor, AvPipe, AvTransactionAfterHook, AvTransactionBeforeHook, AvTransactionFilter, AvTransactionGuard, AvTransactionInterceptor, AvTransactionPipe } from "../runtime/pipeline.js";
|
|
4
|
+
import type { AvConfigResourceKey } from "./framework-field-definition.js";
|
|
5
|
+
/**
|
|
6
|
+
* Pipeline registrations for one level of the configuration: a layer, a
|
|
7
|
+
* Resource, a family or a variant. See {@link AvContext}.
|
|
8
|
+
*/
|
|
9
|
+
export type AvPipeline<M extends AvAdapterModel = AvAdapterModel, R extends string = AvConfigResourceKey<M>, F extends AvOperationFamily = AvOperationFamily, V extends string = string, A = unknown, PreCompute = A> = {
|
|
5
10
|
/** Run first; a guard returning `false` denies the operation with `A4001`. */
|
|
6
|
-
readonly guards?: readonly
|
|
11
|
+
readonly guards?: readonly AvGuard<M, R, F, V, PreCompute>[];
|
|
7
12
|
/** Run in order on the arguments; a pipe may return replacement arguments. */
|
|
8
|
-
readonly pipes?: readonly
|
|
9
|
-
/**
|
|
13
|
+
readonly pipes?: readonly AvPipe<M, R, F, V, PreCompute>[];
|
|
14
|
+
/**
|
|
15
|
+
* Run around the operation, inside every level's interceptors: `before`
|
|
16
|
+
* hooks outer to inner, `after` hooks inner to outer.
|
|
17
|
+
*/
|
|
10
18
|
readonly hooks?: {
|
|
11
|
-
readonly before?: readonly
|
|
12
|
-
readonly after?: readonly
|
|
19
|
+
readonly before?: readonly AvBeforeHook<M, R, F, V, A>[];
|
|
20
|
+
readonly after?: readonly AvAfterHook<M, R, F, V, A>[];
|
|
13
21
|
};
|
|
14
|
-
/** Wrap
|
|
15
|
-
readonly interceptors?: readonly
|
|
16
|
-
/** Turn a thrown error into a {@link
|
|
17
|
-
readonly filters?: readonly
|
|
22
|
+
/** Wrap everything below this level; each calls `next()` to continue. */
|
|
23
|
+
readonly interceptors?: readonly AvInterceptor<M, R, F, V, A>[];
|
|
24
|
+
/** Turn a thrown error into a {@link AvError} outcome. */
|
|
25
|
+
readonly filters?: readonly AvFilter<M, R, F, V, PreCompute>[];
|
|
18
26
|
};
|
|
19
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* A Resource's transaction stages: they run once per transaction with a
|
|
29
|
+
* top-level step on the Resource, inside it, and see the whole plan.
|
|
30
|
+
*/
|
|
31
|
+
export type AvTransactionPipeline<M extends AvAdapterModel = AvAdapterModel> = {
|
|
32
|
+
readonly guards?: readonly AvTransactionGuard<M>[];
|
|
33
|
+
readonly pipes?: readonly AvTransactionPipe<M>[];
|
|
34
|
+
readonly hooks?: {
|
|
35
|
+
readonly before?: readonly AvTransactionBeforeHook<M>[];
|
|
36
|
+
readonly after?: readonly AvTransactionAfterHook<M>[];
|
|
37
|
+
};
|
|
38
|
+
readonly interceptors?: readonly AvTransactionInterceptor<M>[];
|
|
39
|
+
readonly filters?: readonly AvTransactionFilter<M>[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* One level's registrations, as one layer states them: the unit the pipeline
|
|
43
|
+
* tree composes (`pipeline-tree.resolver.ts`).
|
|
44
|
+
*/
|
|
20
45
|
export type ResolvedPipelineConfig = {
|
|
21
|
-
readonly guards: readonly
|
|
22
|
-
readonly pipes: readonly
|
|
46
|
+
readonly guards: readonly AvGuard[];
|
|
47
|
+
readonly pipes: readonly AvPipe[];
|
|
48
|
+
readonly hooks: {
|
|
49
|
+
readonly before: readonly AvBeforeHook[];
|
|
50
|
+
readonly after: readonly AvAfterHook[];
|
|
51
|
+
};
|
|
52
|
+
readonly interceptors: readonly AvInterceptor[];
|
|
53
|
+
readonly filters: readonly AvFilter[];
|
|
54
|
+
};
|
|
55
|
+
/** One layer's registrations on one Resource's transactions. */
|
|
56
|
+
export type ResolvedTransactionPipelineConfig = {
|
|
57
|
+
readonly guards: readonly AvTransactionGuard[];
|
|
58
|
+
readonly pipes: readonly AvTransactionPipe[];
|
|
23
59
|
readonly hooks: {
|
|
24
|
-
readonly before: readonly
|
|
25
|
-
readonly after: readonly
|
|
60
|
+
readonly before: readonly AvTransactionBeforeHook[];
|
|
61
|
+
readonly after: readonly AvTransactionAfterHook[];
|
|
26
62
|
};
|
|
27
|
-
readonly interceptors: readonly
|
|
28
|
-
readonly filters: readonly
|
|
63
|
+
readonly interceptors: readonly AvTransactionInterceptor[];
|
|
64
|
+
readonly filters: readonly AvTransactionFilter[];
|
|
29
65
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { AvOperationIdentity } from "../operations/operation-identity.js";
|
|
2
|
+
import type { AvFieldGuard, AvFieldPipe } from "../runtime/pipeline.js";
|
|
3
|
+
import type { ResolvedPipelineConfig, ResolvedTransactionPipelineConfig } from "./pipeline-config.js";
|
|
4
|
+
/** One variant's levels and whether a layer forces it. */
|
|
5
|
+
type ResolvedVariantPipelines = {
|
|
6
|
+
readonly pipelines: readonly ResolvedPipelineConfig[];
|
|
7
|
+
readonly forceTransaction: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** One family's levels, its variants' and whether a layer forces the family. */
|
|
10
|
+
type ResolvedFamilyPipelines = ResolvedVariantPipelines & {
|
|
11
|
+
readonly variants: Readonly<Record<string, ResolvedVariantPipelines>>;
|
|
12
|
+
};
|
|
13
|
+
/** One field's stages for one origin: the root's, then the overlay's. */
|
|
14
|
+
export type ResolvedFieldStages = {
|
|
15
|
+
readonly pipes: readonly AvFieldPipe[];
|
|
16
|
+
readonly guards: readonly AvFieldGuard[];
|
|
17
|
+
/**
|
|
18
|
+
* The field's validators as authored, root's then overlay's: the Contract compiler
|
|
19
|
+
* checks and compiles them; the runtime reads the compiled form
|
|
20
|
+
* (`field-validator.registry.ts`).
|
|
21
|
+
*/
|
|
22
|
+
readonly validators: readonly unknown[];
|
|
23
|
+
};
|
|
24
|
+
/** One Resource's levels for one origin. */
|
|
25
|
+
export type ResolvedResourcePipelines = {
|
|
26
|
+
readonly pipelines: readonly ResolvedPipelineConfig[];
|
|
27
|
+
readonly families: Readonly<Record<string, ResolvedFamilyPipelines>>;
|
|
28
|
+
readonly transactions: readonly ResolvedTransactionPipelineConfig[];
|
|
29
|
+
readonly fields: Readonly<Record<string, ResolvedFieldStages>>;
|
|
30
|
+
};
|
|
31
|
+
/** Every stage that runs for one origin, by level. */
|
|
32
|
+
export type ResolvedPipelineTree = {
|
|
33
|
+
readonly layer: readonly ResolvedPipelineConfig[];
|
|
34
|
+
readonly resources: Readonly<Record<string, ResolvedResourcePipelines>>;
|
|
35
|
+
};
|
|
36
|
+
type UnknownRecord = Readonly<Record<string, unknown>>;
|
|
37
|
+
/**
|
|
38
|
+
* The pipeline tree of one origin: each layer's registrations in turn, at every
|
|
39
|
+
* level — the root's, then the overlay's; for the agent, the root's, then the
|
|
40
|
+
* overlay it extends, then its own. The root layer alone (the Core Contract's)
|
|
41
|
+
* is one layer.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolvePipelineTree(layers: readonly UnknownRecord[]): ResolvedPipelineTree;
|
|
44
|
+
/** The tree a raw ctx call runs over: `tree`'s field pipes, and nothing else. */
|
|
45
|
+
export declare function rawPipelineTree(tree: ResolvedPipelineTree): ResolvedPipelineTree;
|
|
46
|
+
/**
|
|
47
|
+
* The levels of one operation, outer to inner: root layer, overlay layer, root
|
|
48
|
+
* Resource, overlay Resource, root family, overlay family, root variant, overlay
|
|
49
|
+
* variant. A level no layer states is left out.
|
|
50
|
+
*/
|
|
51
|
+
export declare function operationLevels(tree: ResolvedPipelineTree, operation: AvOperationIdentity & {
|
|
52
|
+
readonly resource: string;
|
|
53
|
+
}): readonly ResolvedPipelineConfig[];
|
|
54
|
+
/**
|
|
55
|
+
* The levels a nested write's target runs, outer to inner: root Resource,
|
|
56
|
+
* overlay Resource, root family, overlay family. A level no layer states is
|
|
57
|
+
* left out.
|
|
58
|
+
*/
|
|
59
|
+
export declare function nestedTargetLevels(tree: ResolvedPipelineTree, resource: string, family: string): readonly ResolvedPipelineConfig[];
|
|
60
|
+
/** Whether a layer sets `forceTransaction` on the operation's family or variant. */
|
|
61
|
+
export declare function isForcedOperation(tree: ResolvedPipelineTree, operation: AvOperationIdentity & {
|
|
62
|
+
readonly resource: string;
|
|
63
|
+
}): boolean;
|
|
64
|
+
/** The field stages registered on one Resource's fields, by field name. */
|
|
65
|
+
export declare function fieldStagesOf(tree: ResolvedPipelineTree, resource: string): Readonly<Record<string, ResolvedFieldStages>>;
|
|
66
|
+
/** One Resource's transaction levels: the root's, then the overlay's. */
|
|
67
|
+
export declare function transactionLevelsOf(tree: ResolvedPipelineTree, resource: string): readonly ResolvedTransactionPipelineConfig[];
|
|
68
|
+
/**
|
|
69
|
+
* Every `forceTransaction` the tree states, as the configuration paths that set
|
|
70
|
+
* it (`resources.R.operations.F[.V]`), with the operation each one forces. Read
|
|
71
|
+
* once at construction, for the startup check against `transactionsStyle`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function forcedOperationsOf(layer: UnknownRecord, prefix: string): readonly {
|
|
74
|
+
readonly path: string;
|
|
75
|
+
readonly resource: string;
|
|
76
|
+
readonly family: string;
|
|
77
|
+
readonly variant: string | undefined;
|
|
78
|
+
}[];
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
function isRecord(value) {
|
|
2
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
function own(record, key) {
|
|
5
|
+
return record !== undefined && Object.hasOwn(record, key)
|
|
6
|
+
? record[key]
|
|
7
|
+
: undefined;
|
|
8
|
+
}
|
|
9
|
+
function list(value) {
|
|
10
|
+
return Array.isArray(value) ? [...value] : [];
|
|
11
|
+
}
|
|
12
|
+
function levelOf(value) {
|
|
13
|
+
if (!isRecord(value)) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const pipeline = value;
|
|
17
|
+
return {
|
|
18
|
+
guards: list(pipeline.guards),
|
|
19
|
+
pipes: list(pipeline.pipes),
|
|
20
|
+
hooks: {
|
|
21
|
+
before: list(pipeline.hooks?.before),
|
|
22
|
+
after: list(pipeline.hooks?.after),
|
|
23
|
+
},
|
|
24
|
+
interceptors: list(pipeline.interceptors),
|
|
25
|
+
filters: list(pipeline.filters),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function transactionLevelOf(value) {
|
|
29
|
+
if (!isRecord(value)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const pipeline = value;
|
|
33
|
+
return {
|
|
34
|
+
guards: list(pipeline.guards),
|
|
35
|
+
pipes: list(pipeline.pipes),
|
|
36
|
+
hooks: {
|
|
37
|
+
before: list(pipeline.hooks?.before),
|
|
38
|
+
after: list(pipeline.hooks?.after),
|
|
39
|
+
},
|
|
40
|
+
interceptors: list(pipeline.interceptors),
|
|
41
|
+
filters: list(pipeline.filters),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function levels(layers, read) {
|
|
45
|
+
return layers.flatMap((layer) => {
|
|
46
|
+
const level = read(layer);
|
|
47
|
+
return level === undefined ? [] : [level];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function child(value, key) {
|
|
51
|
+
return isRecord(value) && Object.hasOwn(value, key) ? value[key] : undefined;
|
|
52
|
+
}
|
|
53
|
+
function forced(layers) {
|
|
54
|
+
return layers.some((layer) => child(layer, "forceTransaction") === true);
|
|
55
|
+
}
|
|
56
|
+
function keysOf(layers, skip) {
|
|
57
|
+
const keys = new Set();
|
|
58
|
+
for (const layer of layers) {
|
|
59
|
+
if (!isRecord(layer)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
for (const key of Object.keys(layer)) {
|
|
63
|
+
if (skip?.has(key) !== true) {
|
|
64
|
+
keys.add(key);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return keys;
|
|
69
|
+
}
|
|
70
|
+
const FAMILY_LEVEL_KEYS = new Set(["pipelines", "forceTransaction"]);
|
|
71
|
+
function resolveVariant(layers) {
|
|
72
|
+
return {
|
|
73
|
+
pipelines: levels(layers, (layer) => levelOf(child(layer, "pipelines"))),
|
|
74
|
+
forceTransaction: forced(layers),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function resolveFamily(layers) {
|
|
78
|
+
const variants = {};
|
|
79
|
+
for (const variant of keysOf(layers, FAMILY_LEVEL_KEYS)) {
|
|
80
|
+
variants[variant] = resolveVariant(layers.map((layer) => child(layer, variant)));
|
|
81
|
+
}
|
|
82
|
+
return { ...resolveVariant(layers), variants };
|
|
83
|
+
}
|
|
84
|
+
function resolveFields(layers) {
|
|
85
|
+
const fields = {};
|
|
86
|
+
for (const field of keysOf(layers)) {
|
|
87
|
+
const pipelines = layers.map((layer) => child(child(layer, field), "pipelines"));
|
|
88
|
+
const pipes = pipelines.flatMap((stage) => list(child(stage, "pipes")));
|
|
89
|
+
const guards = pipelines.flatMap((stage) => list(child(stage, "guards")));
|
|
90
|
+
const validators = pipelines.flatMap((stage) => list(child(stage, "validators")));
|
|
91
|
+
if (pipes.length > 0 || guards.length > 0 || validators.length > 0) {
|
|
92
|
+
fields[field] = { pipes, guards, validators };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return fields;
|
|
96
|
+
}
|
|
97
|
+
function resolveResource(layers) {
|
|
98
|
+
const operations = layers.map((layer) => child(layer, "operations"));
|
|
99
|
+
const families = {};
|
|
100
|
+
for (const family of keysOf(operations)) {
|
|
101
|
+
families[family] = resolveFamily(operations.map((layer) => child(layer, family)));
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
pipelines: levels(layers, (layer) => levelOf(child(layer, "pipelines"))),
|
|
105
|
+
families,
|
|
106
|
+
transactions: levels(layers, (layer) => transactionLevelOf(child(child(layer, "transactions"), "pipelines"))),
|
|
107
|
+
fields: resolveFields(layers.map((layer) => child(layer, "fields"))),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export function resolvePipelineTree(layers) {
|
|
111
|
+
const trees = layers.map((layer) => child(layer, "resources"));
|
|
112
|
+
const resources = {};
|
|
113
|
+
for (const resource of keysOf(trees)) {
|
|
114
|
+
resources[resource] = resolveResource(trees.map((tree) => child(tree, resource)));
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
layer: levels(layers, (layer) => levelOf(child(layer, "pipelines"))),
|
|
118
|
+
resources,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const NO_LEVELS = Object.freeze([]);
|
|
122
|
+
export function rawPipelineTree(tree) {
|
|
123
|
+
const resources = {};
|
|
124
|
+
for (const [name, resource] of Object.entries(tree.resources)) {
|
|
125
|
+
const fields = {};
|
|
126
|
+
for (const [field, stages] of Object.entries(resource.fields)) {
|
|
127
|
+
if (stages.pipes.length > 0) {
|
|
128
|
+
fields[field] = {
|
|
129
|
+
pipes: stages.pipes,
|
|
130
|
+
guards: [],
|
|
131
|
+
validators: stages.validators,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
resources[name] = {
|
|
136
|
+
pipelines: NO_LEVELS,
|
|
137
|
+
families: {},
|
|
138
|
+
transactions: [],
|
|
139
|
+
fields,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return { layer: NO_LEVELS, resources };
|
|
143
|
+
}
|
|
144
|
+
export function operationLevels(tree, operation) {
|
|
145
|
+
const resource = own(tree.resources, operation.resource);
|
|
146
|
+
if (resource === undefined) {
|
|
147
|
+
return tree.layer;
|
|
148
|
+
}
|
|
149
|
+
const family = own(resource.families, operation.family);
|
|
150
|
+
const variant = own(family?.variants, operation.variant);
|
|
151
|
+
return [
|
|
152
|
+
...tree.layer,
|
|
153
|
+
...resource.pipelines,
|
|
154
|
+
...(family?.pipelines ?? NO_LEVELS),
|
|
155
|
+
...(variant?.pipelines ?? NO_LEVELS),
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
export function nestedTargetLevels(tree, resource, family) {
|
|
159
|
+
const found = own(tree.resources, resource);
|
|
160
|
+
if (found === undefined) {
|
|
161
|
+
return NO_LEVELS;
|
|
162
|
+
}
|
|
163
|
+
return [
|
|
164
|
+
...found.pipelines,
|
|
165
|
+
...(own(found.families, family)?.pipelines ?? NO_LEVELS),
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
export function isForcedOperation(tree, operation) {
|
|
169
|
+
const family = own(own(tree.resources, operation.resource)?.families, operation.family);
|
|
170
|
+
return (family?.forceTransaction === true ||
|
|
171
|
+
own(family?.variants, operation.variant)?.forceTransaction === true);
|
|
172
|
+
}
|
|
173
|
+
const NO_FIELDS = Object.freeze({});
|
|
174
|
+
export function fieldStagesOf(tree, resource) {
|
|
175
|
+
return own(tree.resources, resource)?.fields ?? NO_FIELDS;
|
|
176
|
+
}
|
|
177
|
+
export function transactionLevelsOf(tree, resource) {
|
|
178
|
+
return own(tree.resources, resource)?.transactions ?? [];
|
|
179
|
+
}
|
|
180
|
+
export function forcedOperationsOf(layer, prefix) {
|
|
181
|
+
const found = [];
|
|
182
|
+
const resources = child(layer, "resources");
|
|
183
|
+
if (!isRecord(resources)) {
|
|
184
|
+
return found;
|
|
185
|
+
}
|
|
186
|
+
for (const [resource, entry] of Object.entries(resources)) {
|
|
187
|
+
const operations = child(entry, "operations");
|
|
188
|
+
if (!isRecord(operations)) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
for (const [family, level] of Object.entries(operations)) {
|
|
192
|
+
const familyPath = `${prefix}resources.${resource}.operations.${family}`;
|
|
193
|
+
if (child(level, "forceTransaction") === true) {
|
|
194
|
+
found.push({
|
|
195
|
+
path: `${familyPath}.forceTransaction`,
|
|
196
|
+
resource,
|
|
197
|
+
family,
|
|
198
|
+
variant: undefined,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (!isRecord(level)) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
for (const [variant, variantLevel] of Object.entries(level)) {
|
|
205
|
+
if (FAMILY_LEVEL_KEYS.has(variant)) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (child(variantLevel, "forceTransaction") === true) {
|
|
209
|
+
found.push({
|
|
210
|
+
path: `${familyPath}.${variant}.forceTransaction`,
|
|
211
|
+
resource,
|
|
212
|
+
family,
|
|
213
|
+
variant,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return found;
|
|
220
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AvComputeCreate, AvComputeRead, AvComputeUpdate } from "../runtime/field-compute.js";
|
|
2
|
+
import type { AvScalarFieldPipeline } from "./field-pipeline-config.js";
|
|
3
|
+
import type { AvPipeline, AvTransactionPipeline } from "./pipeline-config.js";
|
|
4
|
+
/** Stage lists of one `pipelines` value as `Wide` states them; `validators` kept. */
|
|
5
|
+
type ErasedPipelines<P, Wide> = P extends object ? {
|
|
6
|
+
[K in keyof P]: K extends "validators" ? P[K] : K extends "compute" ? ErasedCompute<P[K]> : K extends "hooks" ? ErasedStageGroup<P[K], NonNullable<Wide[K & keyof Wide]>> : K extends keyof Wide ? NonNullable<Wide[K]> : P[K];
|
|
7
|
+
} : P;
|
|
8
|
+
/** `hooks`, by phase (`before`, `after`). */
|
|
9
|
+
type ErasedStageGroup<G, Wide> = G extends object ? {
|
|
10
|
+
[K in keyof G]: K extends keyof Wide ? NonNullable<Wide[K]> : G[K];
|
|
11
|
+
} : G;
|
|
12
|
+
/** A field's `compute`, by phase; a read stage's `dependsOn` kept. */
|
|
13
|
+
type ErasedCompute<C> = C extends object ? {
|
|
14
|
+
[K in keyof C]: K extends "create" ? AvComputeCreate : K extends "update" ? AvComputeUpdate : K extends "read" ? C[K] extends {
|
|
15
|
+
readonly compute: unknown;
|
|
16
|
+
} ? {
|
|
17
|
+
[D in keyof C[K]]: D extends "compute" ? ComputeReadStage : C[K][D];
|
|
18
|
+
} : ComputeReadStage : C[K];
|
|
19
|
+
} : C;
|
|
20
|
+
/** A read compute stage's function form, for any model. */
|
|
21
|
+
type ComputeReadStage = Parameters<Extract<AvComputeRead, (context: never) => unknown>>[0] extends infer Context ? (context: Context) => unknown : never;
|
|
22
|
+
/** A variant's level: its `pipelines` erased, `forceTransaction` kept. */
|
|
23
|
+
type ErasedVariant<V> = V extends object ? {
|
|
24
|
+
[K in keyof V]: K extends "pipelines" ? ErasedPipelines<V[K], AvPipeline> : V[K];
|
|
25
|
+
} : V;
|
|
26
|
+
/** A family's level: its own `pipelines` and each variant's. */
|
|
27
|
+
type ErasedFamily<F> = F extends object ? {
|
|
28
|
+
[K in keyof F]: K extends "pipelines" ? ErasedPipelines<F[K], AvPipeline> : K extends "forceTransaction" ? F[K] : ErasedVariant<F[K]>;
|
|
29
|
+
} : F;
|
|
30
|
+
/** A field's entry: its `definition` kept, its `pipelines` erased. */
|
|
31
|
+
type ErasedField<Field> = Field extends object ? {
|
|
32
|
+
[K in keyof Field]: K extends "pipelines" ? ErasedPipelines<Field[K], AvScalarFieldPipeline> : Field[K];
|
|
33
|
+
} : Field;
|
|
34
|
+
/**
|
|
35
|
+
* One Resource's block with every stage stated by its public type for any model.
|
|
36
|
+
*/
|
|
37
|
+
export type ErasedResourceBlock<B> = B extends object ? {
|
|
38
|
+
[K in keyof B]: K extends "pipelines" ? ErasedPipelines<B[K], AvPipeline> : K extends "operations" ? {
|
|
39
|
+
[F in keyof B[K]]: ErasedFamily<B[K][F]>;
|
|
40
|
+
} : K extends "transactions" ? {
|
|
41
|
+
[T in keyof B[K]]: T extends "pipelines" ? ErasedPipelines<B[K][T], AvTransactionPipeline> : B[K][T];
|
|
42
|
+
} : K extends "fields" ? {
|
|
43
|
+
[Name in keyof B[K]]: ErasedField<B[K][Name]>;
|
|
44
|
+
} : B[K];
|
|
45
|
+
} : B;
|
|
46
|
+
/** A Resource's overlay blocks (`application`, `client`, `agent`), each erased. */
|
|
47
|
+
export type ErasedOverlayBlocks<Overlays> = Overlays extends object ? {
|
|
48
|
+
[L in keyof Overlays]: ErasedResourceBlock<Overlays[L]>;
|
|
49
|
+
} : Overlays;
|
|
50
|
+
/** A `resources` tree: each Resource's block erased. */
|
|
51
|
+
export type ErasedResources<Resources> = Resources extends object ? {
|
|
52
|
+
[R in keyof Resources]: ErasedResourceBlock<Resources[R]>;
|
|
53
|
+
} : Resources;
|
|
54
|
+
/** One layer (the root's keys, `application`, `client`, `agent`): its stages erased. */
|
|
55
|
+
type ErasedLayer<Layer> = Layer extends object ? {
|
|
56
|
+
[K in keyof Layer]: K extends "pipelines" ? ErasedPipelines<Layer[K], AvPipeline> : K extends "resources" ? ErasedResources<Layer[K]> : Layer[K];
|
|
57
|
+
} : Layer;
|
|
58
|
+
/**
|
|
59
|
+
* An authored configuration with every stage stated by its public type for any
|
|
60
|
+
* model: the `Cfg` a Framework carries (see the note above).
|
|
61
|
+
*/
|
|
62
|
+
export type ErasedConfig<Cfg> = Cfg extends object ? {
|
|
63
|
+
[K in keyof Cfg]: K extends "pipelines" ? ErasedPipelines<Cfg[K], AvPipeline> : K extends "resources" ? ErasedResources<Cfg[K]> : K extends "application" | "client" | "agent" ? ErasedLayer<Cfg[K]> : Cfg[K];
|
|
64
|
+
} : Cfg;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An absolute `http:`/`https:` URL, or a root-relative path other than `"/"`:
|
|
3
|
+
* never `//host`, a backslash, a control character, a space or a dot segment.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isAccessUrl(value: unknown): value is string;
|
|
6
|
+
/**
|
|
7
|
+
* A verb's path under the section's `url`: starting with one `/`, never a
|
|
8
|
+
* backslash, a control character, a space or a dot segment.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isAccessPath(value: unknown): value is string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function hasControlOrSpace(value) {
|
|
2
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
3
|
+
const code = value.charCodeAt(index);
|
|
4
|
+
if (code <= 0x20 || code === 0x7f) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i;
|
|
11
|
+
function hasDotSegment(path) {
|
|
12
|
+
const end = path.search(/[?#]/);
|
|
13
|
+
return (end === -1 ? path : path.slice(0, end))
|
|
14
|
+
.split("/")
|
|
15
|
+
.some((segment) => DOT_SEGMENT.test(segment));
|
|
16
|
+
}
|
|
17
|
+
export function isAccessUrl(value) {
|
|
18
|
+
if (typeof value !== "string" ||
|
|
19
|
+
value.includes("\\") ||
|
|
20
|
+
hasControlOrSpace(value)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (value.startsWith("/")) {
|
|
24
|
+
return value !== "/" && !value.startsWith("//") && !hasDotSegment(value);
|
|
25
|
+
}
|
|
26
|
+
const authority = /^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(value)?.[0];
|
|
27
|
+
if (authority === undefined || hasDotSegment(value.slice(authority.length))) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const { protocol } = new URL(value);
|
|
32
|
+
return protocol === "https:" || protocol === "http:";
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function isAccessPath(value) {
|
|
39
|
+
return (typeof value === "string" &&
|
|
40
|
+
value.startsWith("/") &&
|
|
41
|
+
!value.startsWith("//") &&
|
|
42
|
+
!value.includes("\\") &&
|
|
43
|
+
!hasControlOrSpace(value) &&
|
|
44
|
+
!hasDotSegment(value));
|
|
45
|
+
}
|