@aventara/core 0.1.0-pilot.4 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1478 -0
- package/README.md +275 -11
- package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
- package/dist/adapters/adapter-field.d.ts +11 -11
- package/dist/adapters/adapter-identifier.d.ts +6 -6
- package/dist/adapters/adapter-model.d.ts +17 -9
- package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
- package/dist/adapters/adapter-operation.d.ts +3 -3
- package/dist/adapters/adapter-resource.d.ts +18 -9
- package/dist/adapters/adapter-sql-statement.d.ts +19 -0
- package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
- package/dist/adapters/adapter.interface.d.ts +49 -25
- package/dist/avz/avz-check.factory.d.ts +83 -0
- package/dist/avz/avz-check.factory.js +116 -0
- package/dist/avz/avz-check.registry.d.ts +35 -0
- package/dist/avz/avz-check.registry.js +9 -0
- package/dist/avz/avz.d.ts +203 -0
- package/dist/avz/avz.js +354 -0
- package/dist/avz/index.d.ts +7 -0
- package/dist/avz/index.js +1 -0
- package/dist/avz/json-shape.registry.d.ts +22 -0
- package/dist/avz/json-shape.registry.js +16 -0
- package/dist/avz/zod-issue.translator.d.ts +57 -0
- package/dist/avz/zod-issue.translator.js +149 -0
- package/dist/compiler/contract-compiler-diagnostic.d.ts +37 -5
- package/dist/compiler/contract.compiler.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +595 -421
- package/dist/compiler/create-requirements.projector.d.ts +49 -0
- package/dist/compiler/create-requirements.projector.js +423 -0
- package/dist/compiler/field-validator.compiler.d.ts +47 -0
- package/dist/compiler/field-validator.compiler.js +238 -0
- package/dist/config/any-framework-config.d.ts +19 -12
- package/dist/config/config-diagnostic.d.ts +11 -4
- package/dist/config/config-layer.d.ts +15 -6
- package/dist/config/config.resolver.d.ts +75 -29
- package/dist/config/config.resolver.js +109 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +586 -71
- package/dist/config/define-resource.d.ts +57 -0
- package/dist/config/define-resource.js +14 -0
- package/dist/config/effective-fields.d.ts +19 -23
- package/dist/config/entrypoint.normalizer.d.ts +1 -1
- package/dist/config/exact-framework-config.d.ts +280 -0
- package/dist/config/field-compute.resolver.d.ts +19 -0
- package/dist/config/field-compute.resolver.js +115 -0
- package/dist/config/field-pipeline-config.d.ts +47 -0
- package/dist/config/forced-operation.validator.d.ts +10 -0
- package/dist/config/forced-operation.validator.js +66 -0
- package/dist/config/framework-config.d.ts +111 -37
- package/dist/config/framework-exemptions-config.d.ts +91 -0
- package/dist/config/framework-exemptions-config.js +1 -0
- package/dist/config/framework-field-definition.d.ts +78 -0
- package/dist/config/framework-field-definition.js +28 -0
- package/dist/config/framework-resources-config.d.ts +116 -0
- package/dist/config/framework-resources-config.js +1 -0
- package/dist/config/pipeline-config.d.ts +56 -20
- package/dist/config/pipeline-tree.resolver.d.ts +79 -0
- package/dist/config/pipeline-tree.resolver.js +220 -0
- package/dist/config/stage-type.eraser.d.ts +65 -0
- package/dist/config/stage-type.eraser.js +1 -0
- package/dist/contracts/capability.d.ts +11 -11
- package/dist/contracts/client-contract-structure.validator.d.ts +344 -29
- package/dist/contracts/client-contract-structure.validator.js +248 -7
- package/dist/contracts/contract-canonicalizer.d.ts +19 -3
- package/dist/contracts/contract-canonicalizer.js +172 -27
- package/dist/contracts/contract-hash.d.ts +12 -7
- package/dist/contracts/contract-hash.js +3 -2
- package/dist/contracts/contract-limits.d.ts +4 -1
- package/dist/contracts/contract-limits.js +1 -0
- package/dist/contracts/contract-lookup.d.ts +5 -5
- package/dist/contracts/contract-protocol.d.ts +4 -4
- package/dist/contracts/contract.d.ts +31 -16
- package/dist/contracts/create-requirements.d.ts +35 -0
- package/dist/contracts/create-requirements.js +1 -0
- package/dist/contracts/enum-definition.d.ts +1 -1
- package/dist/contracts/field-check.d.ts +101 -0
- package/dist/contracts/field-check.js +1 -0
- package/dist/contracts/field.d.ts +61 -41
- package/dist/contracts/identifier.d.ts +4 -4
- package/dist/contracts/json-shape.d.ts +76 -0
- package/dist/contracts/json-shape.js +1 -0
- package/dist/contracts/lifecycle-trait.d.ts +2 -2
- package/dist/contracts/reference-write-limit.d.ts +7 -0
- package/dist/contracts/reference-write-limit.js +1 -0
- package/dist/contracts/resource-operations.d.ts +28 -28
- package/dist/contracts/resource.d.ts +15 -9
- package/dist/contracts/scalar-value-type.d.ts +25 -14
- package/dist/contracts/scalar.d.ts +3 -3
- package/dist/contracts/transaction-capability.d.ts +1 -1
- package/dist/contracts/wire-scalar-format.d.ts +4 -4
- package/dist/framework/contract-view.d.ts +234 -63
- package/dist/framework/framework-construction.error.d.ts +10 -10
- package/dist/framework/framework-construction.error.js +2 -2
- package/dist/framework/framework.d.ts +50 -24
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +95 -32
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +55 -82
- package/dist/index.js +6 -26
- package/dist/internal.d.ts +40 -0
- package/dist/internal.js +18 -0
- package/dist/operations/operation-arguments.d.ts +316 -201
- package/dist/operations/operation-call.d.ts +27 -28
- package/dist/operations/operation-identity.d.ts +12 -10
- package/dist/operations/operation-identity.js +3 -0
- package/dist/operations/operation-result.d.ts +21 -21
- package/dist/operations/operation-validator-core.d.ts +6 -6
- package/dist/operations/operation-validator-core.js +41 -12
- package/dist/operations/operation-validator.d.ts +24 -9
- package/dist/operations/operation-validator.js +26 -10
- package/dist/operations/projection-scope.resolver.d.ts +7 -7
- package/dist/operations/structural-limits.walker.d.ts +19 -0
- package/dist/operations/structural-limits.walker.js +489 -0
- package/dist/operations/validation-code.d.ts +11 -6
- package/dist/operations/validation-code.js +4 -0
- package/dist/operations/write-scope.resolver.d.ts +6 -6
- package/dist/protocol/absent-route.responder.d.ts +13 -11
- package/dist/protocol/absent-route.responder.js +42 -16
- package/dist/protocol/contract-document.responder.d.ts +3 -3
- package/dist/protocol/contract-document.responder.js +2 -2
- package/dist/protocol/http-request.decoder.d.ts +23 -13
- package/dist/protocol/http-request.decoder.js +19 -11
- package/dist/protocol/http-request.reader.d.ts +3 -3
- package/dist/protocol/http-response.encoder.d.ts +4 -4
- package/dist/protocol/http-response.encoder.js +94 -55
- package/dist/protocol/http-status.table.d.ts +2 -2
- package/dist/protocol/operation-response.guard.d.ts +2 -2
- package/dist/protocol/protocol-surface.d.ts +4 -4
- package/dist/protocol/protocol.binder.d.ts +52 -27
- package/dist/protocol/protocol.binder.js +14 -9
- package/dist/protocol/protocol.handler.d.ts +28 -15
- package/dist/protocol/protocol.handler.js +55 -10
- package/dist/protocol/unmounted-route.error.d.ts +19 -0
- package/dist/protocol/unmounted-route.error.js +10 -0
- package/dist/runtime/caller-data.copier.d.ts +59 -0
- package/dist/runtime/caller-data.copier.js +470 -0
- package/dist/runtime/caller-data.door.d.ts +56 -0
- package/dist/runtime/caller-data.door.js +67 -0
- package/dist/runtime/computed-read-runtime.d.ts +7 -6
- package/dist/runtime/computed-read-runtime.js +61 -55
- package/dist/runtime/computed-value.error.d.ts +13 -0
- package/dist/runtime/computed-value.error.js +9 -0
- package/dist/runtime/context-executor.runtime.d.ts +59 -0
- package/dist/runtime/context-executor.runtime.js +275 -0
- package/dist/runtime/create-requirement.d.ts +22 -57
- package/dist/runtime/create-requirement.js +140 -37
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +64 -22
- package/dist/runtime/diagnostics-reporter.js +35 -4
- package/dist/runtime/error-boundary.d.ts +73 -8
- package/dist/runtime/error-boundary.js +104 -48
- package/dist/runtime/execution-options.d.ts +10 -2
- package/dist/runtime/field-check.evaluator.d.ts +29 -0
- package/dist/runtime/field-check.evaluator.js +521 -0
- package/dist/runtime/field-compute.d.ts +64 -0
- package/dist/runtime/field-compute.js +1 -0
- package/dist/runtime/field-stage.plan.d.ts +15 -0
- package/dist/runtime/field-stage.plan.js +27 -0
- package/dist/runtime/field-stage.runtime.d.ts +35 -0
- package/dist/runtime/field-stage.runtime.js +143 -0
- package/dist/runtime/field-validator.runtime.d.ts +11 -0
- package/dist/runtime/field-validator.runtime.js +87 -0
- package/dist/runtime/framework-error-class.table.d.ts +33 -0
- package/dist/runtime/framework-error-class.table.js +25 -0
- package/dist/runtime/framework-error.d.ts +79 -7
- package/dist/runtime/framework-error.factory.d.ts +4 -0
- package/dist/runtime/framework-error.factory.js +15 -0
- package/dist/runtime/framework-error.js +23 -2
- package/dist/runtime/interceptor-next.error.d.ts +5 -0
- package/dist/runtime/interceptor-next.error.js +6 -0
- package/dist/runtime/json-value.d.ts +3 -3
- package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
- package/dist/runtime/level-lifecycle.runtime.js +42 -0
- package/dist/runtime/misuse-reporter.d.ts +32 -0
- package/dist/runtime/misuse-reporter.js +19 -0
- package/dist/runtime/mutation-planner.d.ts +19 -10
- package/dist/runtime/mutation-planner.js +62 -36
- package/dist/runtime/nested-write.walker.d.ts +32 -0
- package/dist/runtime/nested-write.walker.js +73 -0
- package/dist/runtime/operation-request.d.ts +35 -15
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +125 -30
- package/dist/runtime/operation-runtime.js +423 -83
- package/dist/runtime/outcome-mapper.d.ts +16 -5
- package/dist/runtime/outcome-mapper.js +35 -8
- package/dist/runtime/output-validator.d.ts +16 -6
- package/dist/runtime/output-validator.js +12 -1
- package/dist/runtime/owned-execution.registry.d.ts +13 -0
- package/dist/runtime/owned-execution.registry.js +7 -0
- package/dist/runtime/pipe-output.validator.d.ts +33 -18
- package/dist/runtime/pipe-output.validator.js +12 -12
- package/dist/runtime/pipeline.d.ts +202 -28
- package/dist/runtime/readonly-value.d.ts +32 -0
- package/dist/runtime/readonly-value.js +141 -0
- package/dist/runtime/referential-action.d.ts +7 -0
- package/dist/runtime/request-envelope.validator.d.ts +5 -0
- package/dist/runtime/request-envelope.validator.js +123 -0
- package/dist/runtime/request-id.d.ts +1 -1
- package/dist/runtime/request-state.d.ts +14 -0
- package/dist/runtime/request-state.js +1 -0
- package/dist/runtime/request-state.resolver.d.ts +12 -0
- package/dist/runtime/request-state.resolver.js +20 -0
- package/dist/runtime/scalar-runtime.d.ts +56 -13
- package/dist/runtime/scalar-runtime.js +167 -86
- package/dist/transactions/deferred-operation.d.ts +35 -20
- package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
- package/dist/transactions/operation-arguments-encoder.js +2 -2
- package/dist/transactions/sql-statement.d.ts +77 -0
- package/dist/transactions/sql-statement.js +47 -0
- package/dist/transactions/sql-statement.validator.d.ts +44 -0
- package/dist/transactions/sql-statement.validator.js +134 -0
- package/dist/transactions/transaction-envelope.d.ts +4 -4
- package/dist/transactions/transaction-integrity-error.d.ts +6 -6
- package/dist/transactions/transaction-integrity-error.js +5 -2
- package/dist/transactions/transaction-plan-assembler.d.ts +23 -9
- package/dist/transactions/transaction-plan-assembler.js +195 -82
- package/dist/transactions/transaction-plan-validator.d.ts +53 -21
- package/dist/transactions/transaction-plan-validator.js +246 -163
- package/dist/transactions/transaction-reference-collector.d.ts +30 -0
- package/dist/transactions/transaction-reference-collector.js +204 -0
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +27 -10
- package/dist/transactions/transaction-reference-validator.d.ts +34 -4
- package/dist/transactions/transaction-reference-validator.js +82 -43
- package/dist/transactions/transaction-reference.d.ts +30 -58
- package/dist/transactions/transaction-request.d.ts +20 -7
- package/dist/transactions/transaction-response.d.ts +12 -7
- package/dist/transactions/transaction-response.js +24 -1
- package/dist/transactions/transaction-runtime.d.ts +11 -8
- package/dist/transactions/transaction-runtime.js +167 -50
- package/dist/transactions/transaction-settlement.runtime.d.ts +51 -0
- package/dist/transactions/transaction-settlement.runtime.js +120 -0
- package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
- package/dist/transactions/transaction-slot-path-error.js +2 -2
- package/dist/transactions/transaction-slot-writer.js +2 -2
- package/dist/transactions/transaction-stage.runtime.d.ts +81 -0
- package/dist/transactions/transaction-stage.runtime.js +123 -0
- package/package.json +18 -3
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -35
- package/dist/config/define-fields.js +0 -3
- package/dist/config/framework-behaviors-config.d.ts +0 -30
- package/dist/config/framework-fields-config.d.ts +0 -36
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/operations/operation-boolean-nodes.d.ts +0 -11
- package/dist/operations/operation-boolean-nodes.js +0 -283
- package/dist/operations/operation-nesting.d.ts +0 -8
- package/dist/operations/operation-nesting.js +0 -307
- package/dist/runtime/field-behavior.d.ts +0 -48
- /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
- /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
- /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
- /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isOperationVariantAvailable } from "../contracts/resource-operations.js";
|
|
2
|
+
import { forcedOperationsOf } from "./pipeline-tree.resolver.js";
|
|
3
|
+
function reachable(contract, resource, family, variant) {
|
|
4
|
+
if (!Object.hasOwn(contract.resources, resource)) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
const operations = contract.resources[resource]?.operations;
|
|
8
|
+
const variants = operations !== undefined && Object.hasOwn(operations, family)
|
|
9
|
+
? operations[family]
|
|
10
|
+
: undefined;
|
|
11
|
+
if (variants === undefined) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return variant === undefined
|
|
15
|
+
? Object.values(variants).some((availability) => isOperationVariantAvailable(availability))
|
|
16
|
+
: Object.hasOwn(variants, variant) &&
|
|
17
|
+
isOperationVariantAvailable(variants[variant]);
|
|
18
|
+
}
|
|
19
|
+
function layerRecord(value) {
|
|
20
|
+
return value !== null && typeof value === "object"
|
|
21
|
+
? value
|
|
22
|
+
: undefined;
|
|
23
|
+
}
|
|
24
|
+
function layersOf(config, origin) {
|
|
25
|
+
const layers = [];
|
|
26
|
+
const push = (name) => {
|
|
27
|
+
const record = layerRecord(config[name]);
|
|
28
|
+
if (record !== undefined) {
|
|
29
|
+
layers.push({ name, record });
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
if (origin === "agent") {
|
|
33
|
+
const parent = layerRecord(config.agent)?.extends ?? "client";
|
|
34
|
+
if (parent === "application" || parent === "client") {
|
|
35
|
+
push(parent);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
push(origin);
|
|
39
|
+
return layers;
|
|
40
|
+
}
|
|
41
|
+
export function validateForcedOperations(config, contracts) {
|
|
42
|
+
const refused = new Map();
|
|
43
|
+
const origins = config.agent !== undefined || config.mcp !== undefined
|
|
44
|
+
? ["application", "client", "agent"]
|
|
45
|
+
: ["application", "client"];
|
|
46
|
+
for (const origin of origins) {
|
|
47
|
+
const contract = contracts[origin];
|
|
48
|
+
if (contract.transactions !== "none") {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const forced = [
|
|
52
|
+
...forcedOperationsOf(config, ""),
|
|
53
|
+
...layersOf(config, origin).flatMap((layer) => forcedOperationsOf(layer.record, `${layer.name}.`)),
|
|
54
|
+
];
|
|
55
|
+
for (const { path, resource, family, variant } of forced) {
|
|
56
|
+
if (reachable(contract, resource, family, variant)) {
|
|
57
|
+
refused.set(path, [...(refused.get(path) ?? []), origin]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return [...refused].map(([path, layers]) => ({
|
|
62
|
+
code: "CONFIG_INVALID_VALUE",
|
|
63
|
+
path,
|
|
64
|
+
message: `${path}: forceTransaction runs a plain call as a one-step transaction, and the effective transactionsStyle of the ${layers.join(" and ")} ${layers.length === 1 ? "layer is" : "layers are"} "none"; set transactionsStyle: "interactive" there (the adapter must offer interactive transactions) or remove forceTransaction`,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
@@ -1,49 +1,123 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
1
|
+
import type { AvAdapter } from "../adapters/adapter.interface.js";
|
|
2
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
3
|
+
import type { AvContractLimits } from "../contracts/contract-limits.js";
|
|
4
|
+
import type { AvTransactionCapability } from "../contracts/transaction-capability.js";
|
|
5
|
+
import type { AvDiagnosticsSink } from "../runtime/diagnostics-reporter.js";
|
|
6
|
+
import type { AvMisuseSink } from "../runtime/misuse-reporter.js";
|
|
7
|
+
import type { AvConfigAny } from "./any-framework-config.js";
|
|
8
|
+
import type { AvConfigExemptions } from "./framework-exemptions-config.js";
|
|
9
|
+
import type { AvConfigLayerKind, AvConfigResources } from "./framework-resources-config.js";
|
|
10
|
+
import type { AvPipeline } from "./pipeline-config.js";
|
|
11
11
|
/**
|
|
12
12
|
* Request limits to override; each one left out takes its default from
|
|
13
13
|
* {@link DEFAULT_CONTRACT_LIMITS}.
|
|
14
14
|
*/
|
|
15
|
-
export type
|
|
15
|
+
export type AvConfigLimits = Partial<AvContractLimits>;
|
|
16
|
+
/** rc.0's layer keys, each refused with its rc.1 location. */
|
|
17
|
+
type MovedLayerKeys = {
|
|
18
|
+
/** Moved: `exposed` + `exemptions`. */
|
|
19
|
+
readonly restrictions?: never;
|
|
20
|
+
/** Moved: `resources.<R>.fields.<f>.pipelines.compute`. */
|
|
21
|
+
readonly behaviors?: never;
|
|
22
|
+
/** Moved: `resources.<R>.fields.<f>.definition`. */
|
|
23
|
+
readonly fields?: never;
|
|
24
|
+
/** Moved: `transactionsStyle`. */
|
|
25
|
+
readonly transactions?: never;
|
|
26
|
+
};
|
|
16
27
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
28
|
+
* The six keys every layer holds: the root, `application`, `client` and
|
|
29
|
+
* `agent`. Stages are added to the root's; `transactionsStyle` and `limits`
|
|
30
|
+
* replace it where an overlay states them; exposure only narrows.
|
|
20
31
|
*/
|
|
21
|
-
export type
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
readonly
|
|
28
|
-
/** Request limits; see {@link FrameworkLimitsConfig}. */
|
|
29
|
-
readonly limits?: FrameworkLimitsConfig;
|
|
30
|
-
/** Guards, pipes, hooks, interceptors and filters run around each operation. */
|
|
31
|
-
readonly pipelines?: PipelineConfig<M>;
|
|
32
|
+
export type AvConfigLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, Kind extends AvConfigLayerKind = "root"> = MovedLayerKeys & {
|
|
33
|
+
/**
|
|
34
|
+
* Whether the layer's `exemptions` hide (`true`, the root's default) or are
|
|
35
|
+
* the only entries exposed (`false`). Each layer narrows its parent: the root
|
|
36
|
+
* the adapter's model, an overlay the root's view.
|
|
37
|
+
*/
|
|
38
|
+
readonly exposed?: boolean;
|
|
32
39
|
/** `"none"` turns transactions off; `"interactive"` needs adapter support. */
|
|
33
|
-
readonly
|
|
40
|
+
readonly transactionsStyle?: AvTransactionCapability;
|
|
41
|
+
/** Request limits; see {@link AvConfigLimits}. */
|
|
42
|
+
readonly limits?: AvConfigLimits;
|
|
43
|
+
/** Guards, pipes, hooks, interceptors and filters run around every operation of the layer. */
|
|
44
|
+
readonly pipelines?: AvPipeline<NoInfer<M>>;
|
|
45
|
+
/** The per-Resource tree: stages, operations, transactions and fields. */
|
|
46
|
+
readonly resources?: AvConfigResources<M, Cfg, Kind>;
|
|
47
|
+
/**
|
|
48
|
+
* The entries that are the opposite of `exposed`. An overlay that sets them
|
|
49
|
+
* states its own `exposed`.
|
|
50
|
+
*/
|
|
51
|
+
readonly exemptions?: AvConfigExemptions<M, Cfg>;
|
|
34
52
|
};
|
|
35
53
|
/**
|
|
36
54
|
* The configuration passed to `createFramework`: the adapter, the mount path,
|
|
37
|
-
* root
|
|
55
|
+
* the root layer, optional `application` and `client` overlays, the optional
|
|
56
|
+
* `agent` layer, and `mcp`.
|
|
57
|
+
*/
|
|
58
|
+
export type AvConfig<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = AvConfigLayer<M, Cfg, "root"> & {
|
|
59
|
+
/**
|
|
60
|
+
* Where the protocol's HTTP routes are mounted: `/api` serves
|
|
61
|
+
* `/api/_resources/…`, `/api/_contract` and `/api/_transactions`.
|
|
62
|
+
*/
|
|
63
|
+
readonly api: string;
|
|
64
|
+
/** Moved in rc.1: the mount path is `api`. */
|
|
65
|
+
readonly entrypoint?: never;
|
|
66
|
+
/**
|
|
67
|
+
* Turns MCP on: the path the MCP endpoint is mounted at, or the path with the
|
|
68
|
+
* OAuth authorization its callers must present. Its tools are built from the
|
|
69
|
+
* Agent Contract.
|
|
70
|
+
*/
|
|
71
|
+
readonly mcp?: AvConfigMcp;
|
|
72
|
+
readonly adapter: AvAdapter<M>;
|
|
73
|
+
readonly diagnostics?: AvDiagnosticsSink;
|
|
74
|
+
/** Told about every caller value refused as unreadable or not plain data. */
|
|
75
|
+
readonly misuse?: AvMisuseSink;
|
|
76
|
+
readonly application?: AvConfigLayer<M, Cfg, "overlay">;
|
|
77
|
+
readonly client?: AvConfigLayer<M, Cfg, "overlay">;
|
|
78
|
+
/**
|
|
79
|
+
* The layer an AI agent's calls run under. It narrows the view of the layer it
|
|
80
|
+
* `extends` (the client's when left out), and its stages run after that
|
|
81
|
+
* layer's. Left out, the agent layer is that view exactly.
|
|
82
|
+
*/
|
|
83
|
+
readonly agent?: AvConfigAgentLayer<M, Cfg>;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* The `mcp` key: the MCP endpoint's mount path (`"/mcp"`), or the path with
|
|
87
|
+
* the authorization its callers must present.
|
|
88
|
+
*/
|
|
89
|
+
export type AvConfigMcp = string | {
|
|
90
|
+
/** The MCP endpoint's mount path, written as `api` is. */
|
|
91
|
+
readonly path: string;
|
|
92
|
+
/**
|
|
93
|
+
* OAuth for the endpoint. Left out, the endpoint takes no token.
|
|
94
|
+
*/
|
|
95
|
+
readonly authorization?: {
|
|
96
|
+
/**
|
|
97
|
+
* The authorization servers (https URLs) a caller obtains its token
|
|
98
|
+
* from, advertised in the endpoint's protected-resource metadata.
|
|
99
|
+
*/
|
|
100
|
+
readonly servers: readonly string[];
|
|
101
|
+
/**
|
|
102
|
+
* Checks one bearer token: what it resolves to (the caller, say) when
|
|
103
|
+
* the token is good, `null` when it is not.
|
|
104
|
+
*/
|
|
105
|
+
readonly verify: (token: string) => unknown | null | Promise<unknown | null>;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* The `agent` layer: the six layer keys, and `extends`, the layer whose final
|
|
110
|
+
* view it narrows and whose stages run before its own.
|
|
38
111
|
*/
|
|
39
|
-
export type
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
readonly
|
|
112
|
+
export type AvConfigAgentLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = AvConfigLayer<M, Cfg, "overlay"> & {
|
|
113
|
+
/**
|
|
114
|
+
* The layer the agent starts from: `"client"` (the default), `"application"`
|
|
115
|
+
* or `"root"`. The agent never widens it.
|
|
116
|
+
*/
|
|
117
|
+
readonly extends?: "client" | "application" | "root";
|
|
45
118
|
};
|
|
46
|
-
export type {
|
|
47
|
-
export type {
|
|
48
|
-
export type {
|
|
49
|
-
export type {
|
|
119
|
+
export type { AvConfigAny, AvConfigLayerAny, AvConfigResourcesAny, } from "./any-framework-config.js";
|
|
120
|
+
export type { AvFieldCompute, AvRelationFieldPipeline, AvScalarFieldPipeline, AvZCheck, } from "./field-pipeline-config.js";
|
|
121
|
+
export type { AvConfigExemptions, AvConfigOperationsExemption, AvConfigRelationFieldExemption, AvConfigResourceExemption, AvConfigScalarFieldExemption, AvRelationFieldCapabilityName, AvScalarFieldCapabilityName, } from "./framework-exemptions-config.js";
|
|
122
|
+
export type { AvConfigAddedFieldDefinition, AvConfigFieldDefinition, AvConfigFieldLifecycleTrait, AvConfigKnownFieldDefinition, AvConfigResourceKey, AvConfigScalarTypeRef, AvZFormat, } from "./framework-field-definition.js";
|
|
123
|
+
export type { AvConfigFamily, AvConfigLayerKind, AvConfigOperations, AvConfigOverlayField, AvConfigResource, AvConfigResourceFields, AvConfigResources, AvConfigResourceTransactions, AvConfigRootField, AvConfigVariant, } from "./framework-resources-config.js";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
2
|
+
import type { AvAdapterFieldKey } from "../adapters/adapter-resource.js";
|
|
3
|
+
import type { AvPaginationCapability, AvRelationFilterCapability, AvRelationMutationDirective, AvRelationReducer, AvScalarFilterOperator, AvScalarMutationDirective } from "../contracts/capability.js";
|
|
4
|
+
import type { AvConfigAny } from "./any-framework-config.js";
|
|
5
|
+
import type { AvEffectiveFieldKey } from "./effective-fields.js";
|
|
6
|
+
import type { AvConfigResourceKey } from "./framework-field-definition.js";
|
|
7
|
+
/** The capability names a scalar field's exemption can list. */
|
|
8
|
+
export type AvScalarFieldCapabilityName = "select" | "filter" | "order" | "orderNulls" | "create" | "update";
|
|
9
|
+
/** The capability names a relation field's exemption can list. */
|
|
10
|
+
export type AvRelationFieldCapabilityName = "select" | "include" | "filter" | "order" | "pagination" | "reducers" | "create" | "update";
|
|
11
|
+
/** A scalar field's exemption: whole, by capability name, or per capability. */
|
|
12
|
+
export type AvConfigScalarFieldExemption = boolean | readonly AvScalarFieldCapabilityName[] | ({
|
|
13
|
+
readonly select?: boolean;
|
|
14
|
+
readonly filter?: boolean | readonly AvScalarFilterOperator[];
|
|
15
|
+
readonly order?: boolean;
|
|
16
|
+
readonly orderNulls?: boolean;
|
|
17
|
+
readonly create?: boolean | readonly AvScalarMutationDirective[];
|
|
18
|
+
readonly update?: boolean | readonly AvScalarMutationDirective[];
|
|
19
|
+
} & NotAList);
|
|
20
|
+
/** A relation field's exemption: whole, by capability name, or per capability. */
|
|
21
|
+
export type AvConfigRelationFieldExemption = boolean | readonly AvRelationFieldCapabilityName[] | ({
|
|
22
|
+
readonly select?: boolean;
|
|
23
|
+
readonly include?: boolean;
|
|
24
|
+
readonly filter?: boolean | readonly AvRelationFilterCapability[];
|
|
25
|
+
readonly order?: boolean;
|
|
26
|
+
readonly pagination?: boolean | readonly AvPaginationCapability[];
|
|
27
|
+
readonly reducers?: boolean | readonly AvRelationReducer[];
|
|
28
|
+
readonly create?: boolean | readonly AvRelationMutationDirective[];
|
|
29
|
+
readonly update?: boolean | readonly AvRelationMutationDirective[];
|
|
30
|
+
} & NotAList);
|
|
31
|
+
/** The operations of Resource `R`, as the adapter model states them. */
|
|
32
|
+
type ResourceOperationsOf<M extends AvAdapterModel, R extends AvConfigResourceKey<M>> = M["resources"][R]["operations"];
|
|
33
|
+
/** The families Resource `R` offers. */
|
|
34
|
+
type FamilyOf<M extends AvAdapterModel, R extends AvConfigResourceKey<M>> = Extract<keyof ResourceOperationsOf<M, R>, string>;
|
|
35
|
+
/** The variants family `F` of Resource `R` offers. */
|
|
36
|
+
type VariantOf<M extends AvAdapterModel, R extends AvConfigResourceKey<M>, F extends FamilyOf<M, R>> = Extract<keyof NonNullable<ResourceOperationsOf<M, R>[F]>, string>;
|
|
37
|
+
/**
|
|
38
|
+
* A Resource's operations exemption, in the nested form: whole, a list of
|
|
39
|
+
* families, or per family a list of variants or a per-variant object.
|
|
40
|
+
*/
|
|
41
|
+
export type AvConfigOperationsExemption<M extends AvAdapterModel = AvAdapterModel, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = boolean | readonly FamilyOf<M, R>[] | ({
|
|
42
|
+
readonly [F in FamilyOf<M, R>]?: boolean | readonly VariantOf<M, R, F>[] | ({
|
|
43
|
+
readonly [V in VariantOf<M, R, F>]?: boolean;
|
|
44
|
+
} & NotAList);
|
|
45
|
+
} & NotAList);
|
|
46
|
+
/** Refuses a list where the object form is meant. */
|
|
47
|
+
type NotAList = {
|
|
48
|
+
readonly [index: number]: never;
|
|
49
|
+
};
|
|
50
|
+
/** The tokens one capability member offers, its position qualifier aside. */
|
|
51
|
+
type MemberToken<Member> = Member extends {
|
|
52
|
+
readonly directives: readonly (infer Token)[];
|
|
53
|
+
} ? Token : Member extends {
|
|
54
|
+
readonly reducers: readonly (infer Token)[];
|
|
55
|
+
} ? Token : Member extends readonly (infer Token)[] ? Token : never;
|
|
56
|
+
/** A token capability's exemption: whole, or the tokens the field offers. */
|
|
57
|
+
type TokenExemption<Caps, K> = K extends keyof Caps ? boolean | readonly MemberToken<NonNullable<Caps[K]>>[] : boolean;
|
|
58
|
+
/** The capability names a discovered scalar's exemption can name: its own, and `select`. */
|
|
59
|
+
type ScalarNameOf<Caps> = Extract<keyof Caps, AvScalarFieldCapabilityName> | "select";
|
|
60
|
+
/** A discovered scalar field's exemption, by its capabilities. */
|
|
61
|
+
type ScalarFieldExemptionOf<Caps> = boolean | readonly ScalarNameOf<Caps>[] | ({
|
|
62
|
+
readonly [K in ScalarNameOf<Caps>]?: K extends "filter" | "create" | "update" ? TokenExemption<Caps, K> : boolean;
|
|
63
|
+
} & NotAList);
|
|
64
|
+
/** The capability names a discovered relation's exemption can name: its own. */
|
|
65
|
+
type RelationNameOf<Caps> = Extract<keyof Caps, AvRelationFieldCapabilityName>;
|
|
66
|
+
/** A discovered relation field's exemption, by its capabilities. */
|
|
67
|
+
type RelationFieldExemptionOf<Caps> = boolean | readonly RelationNameOf<Caps>[] | ({
|
|
68
|
+
readonly [K in RelationNameOf<Caps>]?: K extends "select" | "include" | "order" ? boolean : TokenExemption<Caps, K>;
|
|
69
|
+
} & NotAList);
|
|
70
|
+
/** The exemption shape one effective field name admits. */
|
|
71
|
+
type FieldExemptionFor<M extends AvAdapterModel, R extends AvConfigResourceKey<M>, F extends string> = string extends F ? AvConfigScalarFieldExemption | AvConfigRelationFieldExemption : F extends AvAdapterFieldKey<M, R> ? M["resources"][R]["fields"][F] extends {
|
|
72
|
+
readonly kind: "relation";
|
|
73
|
+
readonly capabilities: infer Caps;
|
|
74
|
+
} ? RelationFieldExemptionOf<Caps> : M["resources"][R]["fields"][F] extends {
|
|
75
|
+
readonly capabilities: infer Caps;
|
|
76
|
+
} ? ScalarFieldExemptionOf<Caps> : AvConfigScalarFieldExemption : AvConfigScalarFieldExemption;
|
|
77
|
+
/** A Resource's exemption: whole, or its operations and fields. No list. */
|
|
78
|
+
export type AvConfigResourceExemption<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = boolean | ({
|
|
79
|
+
readonly operations?: AvConfigOperationsExemption<M, R>;
|
|
80
|
+
readonly fields?: {
|
|
81
|
+
readonly [F in AvEffectiveFieldKey<M, Cfg, R>]?: FieldExemptionFor<M, R, F>;
|
|
82
|
+
};
|
|
83
|
+
} & NotAList);
|
|
84
|
+
/** The entries that are the opposite of a layer's `exposed`. */
|
|
85
|
+
export type AvConfigExemptions<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = {
|
|
86
|
+
/** Per Resource, by the adapter's Resource names. */
|
|
87
|
+
readonly resources?: {
|
|
88
|
+
readonly [R in AvConfigResourceKey<M>]?: AvConfigResourceExemption<M, Cfg, R>;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
2
|
+
import type { AvScalarFieldCapabilities } from "../contracts/field.js";
|
|
3
|
+
import type { JsonShape } from "../contracts/json-shape.js";
|
|
4
|
+
import type { AvLifecycleTrait } from "../contracts/lifecycle-trait.js";
|
|
5
|
+
/** The lifecycle traits a configuration may set on a field. */
|
|
6
|
+
export type AvConfigFieldLifecycleTrait = Extract<AvLifecycleTrait, "VIRTUAL">;
|
|
7
|
+
/** The names of the Resources in adapter model `M`. */
|
|
8
|
+
export type AvConfigResourceKey<M extends AvAdapterModel> = Extract<keyof M["resources"], string>;
|
|
9
|
+
/** A scalar type or an enum of adapter model `M`, by name. */
|
|
10
|
+
export type AvConfigScalarTypeRef<M extends AvAdapterModel> = {
|
|
11
|
+
readonly scalar: Extract<keyof M["scalars"], string>;
|
|
12
|
+
} | {
|
|
13
|
+
readonly enum: Extract<keyof M["enums"], string>;
|
|
14
|
+
};
|
|
15
|
+
/** zod's named string formats: the `format` names a configured field may state. */
|
|
16
|
+
export declare const AVZ_FORMATS: readonly ["email", "url", "emoji", "uuid", "guid", "nanoid", "cuid", "cuid2", "ulid", "xid", "ksuid", "datetime", "date", "time", "duration", "ipv4", "ipv6", "cidrv4", "cidrv6", "base64", "base64url", "json_string", "e164", "credit_card", "iban", "jwt"];
|
|
17
|
+
/**
|
|
18
|
+
* One of zod's named string formats. A configured (VIRTUAL) field states its
|
|
19
|
+
* `format` with one of these; any other name is refused.
|
|
20
|
+
*/
|
|
21
|
+
export type AvZFormat = (typeof AVZ_FORMATS)[number];
|
|
22
|
+
/**
|
|
23
|
+
* A field's definition: its type, nullability, list-ness, lifecycle, format,
|
|
24
|
+
* capabilities and Json shape. Root only.
|
|
25
|
+
*/
|
|
26
|
+
export type AvConfigFieldDefinition<M extends AvAdapterModel = AvAdapterModel> = {
|
|
27
|
+
/** The field's scalar or enum type. A discovered field may only restate its own. */
|
|
28
|
+
readonly type?: AvConfigScalarTypeRef<M>;
|
|
29
|
+
/** Whether the field may be `null`. A discovered field may only restate its own. */
|
|
30
|
+
readonly nullable?: boolean;
|
|
31
|
+
/** Whether the field holds a list. A discovered field may only restate its own. */
|
|
32
|
+
readonly list?: boolean;
|
|
33
|
+
/** `["VIRTUAL"]`: a field the store does not hold. Configured fields only. */
|
|
34
|
+
readonly lifecycle?: readonly AvConfigFieldLifecycleTrait[];
|
|
35
|
+
/** The value's format, one of zod's named formats. Configured fields only. */
|
|
36
|
+
readonly format?: AvZFormat;
|
|
37
|
+
/** What callers may do with the field. Configured fields only. */
|
|
38
|
+
readonly capabilities?: Partial<AvScalarFieldCapabilities>;
|
|
39
|
+
/**
|
|
40
|
+
* A discovered Json field's shape, built with `AvZ` from
|
|
41
|
+
* `@aventara/core/avz`: writes to the field are checked against it, and its
|
|
42
|
+
* value is typed by it.
|
|
43
|
+
*/
|
|
44
|
+
readonly json?: JsonShape;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* What a definition may say about field `Field` the adapter discovered: restate
|
|
48
|
+
* its `type`, `nullable` and `list`, and give a Json field its shape.
|
|
49
|
+
*/
|
|
50
|
+
export type AvConfigKnownFieldDefinition<Field> = {
|
|
51
|
+
readonly type?: Field extends {
|
|
52
|
+
readonly type: infer Type;
|
|
53
|
+
} ? Type : never;
|
|
54
|
+
readonly nullable?: Field extends {
|
|
55
|
+
readonly nullable: infer Nullable;
|
|
56
|
+
} ? Nullable : never;
|
|
57
|
+
readonly list?: Field extends {
|
|
58
|
+
readonly list: infer List;
|
|
59
|
+
} ? List : never;
|
|
60
|
+
readonly lifecycle?: never;
|
|
61
|
+
readonly format?: never;
|
|
62
|
+
readonly capabilities?: never;
|
|
63
|
+
readonly json?: Field extends {
|
|
64
|
+
readonly type: {
|
|
65
|
+
readonly scalar: "json";
|
|
66
|
+
};
|
|
67
|
+
} ? JsonShape : never;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* A configured field, which the adapter did not discover: `type`, `nullable` and
|
|
71
|
+
* `list` are required, and it takes no `json` shape.
|
|
72
|
+
*/
|
|
73
|
+
export type AvConfigAddedFieldDefinition<M extends AvAdapterModel = AvAdapterModel> = Omit<AvConfigFieldDefinition<M>, "type" | "nullable" | "list" | "json"> & {
|
|
74
|
+
readonly type: AvConfigScalarTypeRef<M>;
|
|
75
|
+
readonly nullable: boolean;
|
|
76
|
+
readonly list: boolean;
|
|
77
|
+
readonly json?: never;
|
|
78
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const AVZ_FORMATS = [
|
|
2
|
+
"email",
|
|
3
|
+
"url",
|
|
4
|
+
"emoji",
|
|
5
|
+
"uuid",
|
|
6
|
+
"guid",
|
|
7
|
+
"nanoid",
|
|
8
|
+
"cuid",
|
|
9
|
+
"cuid2",
|
|
10
|
+
"ulid",
|
|
11
|
+
"xid",
|
|
12
|
+
"ksuid",
|
|
13
|
+
"datetime",
|
|
14
|
+
"date",
|
|
15
|
+
"time",
|
|
16
|
+
"duration",
|
|
17
|
+
"ipv4",
|
|
18
|
+
"ipv6",
|
|
19
|
+
"cidrv4",
|
|
20
|
+
"cidrv6",
|
|
21
|
+
"base64",
|
|
22
|
+
"base64url",
|
|
23
|
+
"json_string",
|
|
24
|
+
"e164",
|
|
25
|
+
"credit_card",
|
|
26
|
+
"iban",
|
|
27
|
+
"jwt",
|
|
28
|
+
];
|
|
@@ -0,0 +1,116 @@
|
|
|
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 { AvStageArguments } from "../runtime/pipeline.js";
|
|
6
|
+
import type { AvConfigAny } from "./any-framework-config.js";
|
|
7
|
+
import type { AvEffectiveFieldKey } from "./effective-fields.js";
|
|
8
|
+
import type { AvRelationFieldPipeline, AvScalarFieldPipeline } from "./field-pipeline-config.js";
|
|
9
|
+
import type { AvConfigAddedFieldDefinition, AvConfigFieldDefinition, AvConfigKnownFieldDefinition, AvConfigResourceKey } from "./framework-field-definition.js";
|
|
10
|
+
import type { AvPipeline, AvTransactionPipeline } from "./pipeline-config.js";
|
|
11
|
+
/**
|
|
12
|
+
* Whether a layer is the root, where fields are defined, or an overlay
|
|
13
|
+
* (`application`, `client`), which registers stages on them but never defines one.
|
|
14
|
+
*/
|
|
15
|
+
export type AvConfigLayerKind = "root" | "overlay";
|
|
16
|
+
/** One operation variant's level: its stages and `forceTransaction`. */
|
|
17
|
+
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>>> = {
|
|
18
|
+
/**
|
|
19
|
+
* Stages that run for this one operation: at a variant, `ctx.$args` (and a
|
|
20
|
+
* pipe's arguments) are typed as the operation's arguments.
|
|
21
|
+
*/
|
|
22
|
+
readonly pipelines?: AvPipeline<NoInfer<M>, R, F, V, A>;
|
|
23
|
+
/** Runs a plain call of this operation as a one-step transaction. */
|
|
24
|
+
readonly forceTransaction?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** The variants a family's stages are told: its own, and `"one"` for a nested target. */
|
|
27
|
+
type FamilyStageVariant<F extends AvOperationFamily, V extends string> = F extends "create" | "update" | "delete" ? V | "one" : V;
|
|
28
|
+
/**
|
|
29
|
+
* One operation family's level: stages and `forceTransaction` for every variant
|
|
30
|
+
* of it, and each variant's own level by name.
|
|
31
|
+
*/
|
|
32
|
+
export type AvConfigFamily<M extends AvAdapterModel = AvAdapterModel, Variants = {
|
|
33
|
+
readonly [V in "first" | "unique" | "many" | "count" | "one"]?: unknown;
|
|
34
|
+
}, R extends string = AvConfigResourceKey<M>, F extends AvOperationFamily = AvOperationFamily> = AvConfigVariant<M, R, F, FamilyStageVariant<F, Extract<keyof NonNullable<Variants>, string>>, unknown> & {
|
|
35
|
+
readonly [V in Extract<keyof NonNullable<Variants>, string>]?: AvConfigVariant<M, R, F, V> | undefined;
|
|
36
|
+
};
|
|
37
|
+
/** A Resource's families, as the adapter model offers them, each with its level. */
|
|
38
|
+
export type AvConfigOperations<M extends AvAdapterModel = AvAdapterModel, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = {
|
|
39
|
+
readonly [F in Extract<keyof M["resources"][R]["operations"], AvOperationFamily>]?: AvConfigFamily<M, M["resources"][R]["operations"][F], R, F>;
|
|
40
|
+
};
|
|
41
|
+
/** A Resource's transaction level. */
|
|
42
|
+
export type AvConfigResourceTransactions<M extends AvAdapterModel = AvAdapterModel> = {
|
|
43
|
+
/** Stages that run once per transaction with a top-level step on the Resource. */
|
|
44
|
+
readonly pipelines?: AvTransactionPipeline<NoInfer<M>>;
|
|
45
|
+
};
|
|
46
|
+
/** A field's entry at the root: its definition and its stages. */
|
|
47
|
+
export type AvConfigRootField<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = {
|
|
48
|
+
/** What the field is. Root only. */
|
|
49
|
+
readonly definition?: AvConfigFieldDefinition<M>;
|
|
50
|
+
/** The field's stages. */
|
|
51
|
+
readonly pipelines?: AvScalarFieldPipeline<M, Cfg, R>;
|
|
52
|
+
};
|
|
53
|
+
/** A field's entry in an overlay: its stages only. */
|
|
54
|
+
export type AvConfigOverlayField<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = {
|
|
55
|
+
/** The field's stages, added to the root's. */
|
|
56
|
+
readonly pipelines?: AvScalarFieldPipeline<M, Cfg, R>;
|
|
57
|
+
};
|
|
58
|
+
/** The checks a scalar type takes, or `never`. */
|
|
59
|
+
type ScalarChecks<Scalar> = Scalar extends "string" ? AvZCheck<"string"> : Scalar extends "int" | "float" ? AvZCheck<"number"> : Scalar extends "bigint" | "decimal" | "datetime" | "bytes" ? AvZCheck<Scalar> : never;
|
|
60
|
+
/** The checks a discovered scalar field takes: its type's, and a list's length. */
|
|
61
|
+
type FieldCheckOf<Field> = Field extends {
|
|
62
|
+
readonly type: infer Type;
|
|
63
|
+
readonly list: infer List;
|
|
64
|
+
} ? (Type extends {
|
|
65
|
+
readonly scalar: infer Scalar;
|
|
66
|
+
} ? string extends Scalar ? AvZCheck : ScalarChecks<Scalar> : never) | (false extends List ? never : AvZCheck<"list">) : AvZCheck;
|
|
67
|
+
/** A discovered scalar field's stages, its `validators` typed by the field. */
|
|
68
|
+
type KnownScalarFieldPipeline<M extends AvAdapterModel, Cfg, R extends AvConfigResourceKey<M>, Field> = Field extends {
|
|
69
|
+
readonly type: {
|
|
70
|
+
readonly scalar: "json";
|
|
71
|
+
};
|
|
72
|
+
} ? Omit<AvScalarFieldPipeline<M, Cfg, R>, "validators"> & {
|
|
73
|
+
/** A Json field's checks are in its shape (`definition.json`). */
|
|
74
|
+
readonly validators?: never;
|
|
75
|
+
} : AvScalarFieldPipeline<M, Cfg, R, FieldCheckOf<Field>>;
|
|
76
|
+
/** The root entry one effective field name admits. */
|
|
77
|
+
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 {
|
|
78
|
+
readonly kind: "relation";
|
|
79
|
+
} ? {
|
|
80
|
+
readonly definition?: never;
|
|
81
|
+
readonly pipelines?: AvRelationFieldPipeline<M, R>;
|
|
82
|
+
} : {
|
|
83
|
+
readonly definition?: AvConfigKnownFieldDefinition<M["resources"][R]["fields"][F]>;
|
|
84
|
+
readonly pipelines?: KnownScalarFieldPipeline<M, Cfg, R, M["resources"][R]["fields"][F]>;
|
|
85
|
+
} : {
|
|
86
|
+
readonly definition: AvConfigAddedFieldDefinition<M>;
|
|
87
|
+
readonly pipelines?: AvScalarFieldPipeline<M, Cfg, R>;
|
|
88
|
+
};
|
|
89
|
+
/** The overlay entry one effective field name admits. */
|
|
90
|
+
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 {
|
|
91
|
+
readonly kind: "relation";
|
|
92
|
+
} ? {
|
|
93
|
+
readonly pipelines?: AvRelationFieldPipeline<M, R>;
|
|
94
|
+
} : {
|
|
95
|
+
readonly pipelines?: KnownScalarFieldPipeline<M, Cfg, R, M["resources"][R]["fields"][F]>;
|
|
96
|
+
} : AvConfigOverlayField<M, Cfg, R>;
|
|
97
|
+
/** A Resource's fields at one layer, keyed by its effective field names. */
|
|
98
|
+
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"> = {
|
|
99
|
+
readonly [F in AvEffectiveFieldKey<M, Cfg, R>]?: Kind extends "root" ? RootFieldConfigFor<M, Cfg, R, F> : OverlayFieldConfigFor<M, Cfg, R, F>;
|
|
100
|
+
};
|
|
101
|
+
/** One Resource's tree: its stages, operations, transactions and fields. */
|
|
102
|
+
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"> = {
|
|
103
|
+
/** Stages that run for every operation of this Resource. */
|
|
104
|
+
readonly pipelines?: AvPipeline<NoInfer<M>, R>;
|
|
105
|
+
/** Per family, and per variant under its family. */
|
|
106
|
+
readonly operations?: AvConfigOperations<M, R>;
|
|
107
|
+
/** Stages that run once per transaction with a top-level step on this Resource. */
|
|
108
|
+
readonly transactions?: AvConfigResourceTransactions<M>;
|
|
109
|
+
/** Per field: its definition (root only) and its stages. */
|
|
110
|
+
readonly fields?: AvConfigResourceFields<M, Cfg, R, Kind>;
|
|
111
|
+
};
|
|
112
|
+
/** The `resources` tree of one layer, keyed by the adapter's Resource names. */
|
|
113
|
+
export type AvConfigResources<in out M extends AvAdapterModel = AvAdapterModel, in out Cfg = AvConfigAny, in out Kind extends AvConfigLayerKind = "root"> = {
|
|
114
|
+
readonly [R in AvConfigResourceKey<M>]?: AvConfigResource<M, Cfg, R, Kind>;
|
|
115
|
+
};
|
|
116
|
+
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> = {
|
|
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, A>[];
|
|
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, A>[];
|
|
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, A>[];
|
|
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
|
};
|