@aventara/core 1.0.0-rc.0 → 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 +1140 -0
- package/README.md +224 -57
- 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 +9 -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 -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 +7 -7
- 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.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +548 -441
- 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 +74 -31
- package/dist/config/config.resolver.js +108 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +581 -72
- 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 +110 -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 +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 +323 -28
- package/dist/contracts/client-contract-structure.validator.js +152 -8
- package/dist/contracts/contract-canonicalizer.d.ts +19 -3
- package/dist/contracts/contract-canonicalizer.js +141 -28
- 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 +24 -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 +52 -42
- package/dist/contracts/identifier.d.ts +4 -4
- 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 +15 -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/contract-view.d.ts +213 -147
- 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 +47 -23
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +40 -20
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +55 -50
- package/dist/index.js +6 -6
- package/dist/internal.d.ts +15 -10
- package/dist/internal.js +3 -1
- package/dist/operations/operation-arguments.d.ts +267 -202
- package/dist/operations/operation-call.d.ts +27 -28
- package/dist/operations/operation-identity.d.ts +10 -10
- 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 +13 -2
- package/dist/operations/operation-validator.d.ts +9 -9
- package/dist/operations/projection-scope.resolver.d.ts +6 -6
- package/dist/operations/structural-limits.walker.d.ts +6 -6
- package/dist/operations/structural-limits.walker.js +145 -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 -12
- package/dist/protocol/absent-route.responder.js +19 -19
- 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 +17 -13
- package/dist/protocol/http-request.decoder.js +10 -10
- 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 +50 -27
- package/dist/protocol/protocol.binder.js +12 -9
- package/dist/protocol/protocol.handler.d.ts +22 -13
- package/dist/protocol/protocol.handler.js +44 -9
- 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 +5 -5
- package/dist/runtime/caller-data.copier.js +13 -13
- package/dist/runtime/caller-data.door.d.ts +6 -6
- package/dist/runtime/caller-data.door.js +6 -4
- package/dist/runtime/computed-read-runtime.d.ts +7 -6
- package/dist/runtime/computed-read-runtime.js +61 -48
- package/dist/runtime/computed-value.error.d.ts +6 -6
- package/dist/runtime/computed-value.error.js +3 -3
- 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 +10 -81
- package/dist/runtime/create-requirement.js +80 -57
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +53 -27
- package/dist/runtime/diagnostics-reporter.js +24 -0
- package/dist/runtime/error-boundary.d.ts +65 -8
- package/dist/runtime/error-boundary.js +45 -19
- 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 +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 +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 +12 -12
- package/dist/runtime/mutation-planner.d.ts +19 -10
- package/dist/runtime/mutation-planner.js +54 -30
- 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 +33 -6
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +113 -25
- package/dist/runtime/operation-runtime.js +395 -74
- package/dist/runtime/outcome-mapper.d.ts +16 -5
- package/dist/runtime/outcome-mapper.js +23 -6
- package/dist/runtime/output-validator.d.ts +10 -10
- package/dist/runtime/output-validator.js +3 -3
- package/dist/runtime/owned-execution.registry.d.ts +6 -6
- 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 +196 -34
- package/dist/runtime/readonly-value.d.ts +32 -0
- package/dist/runtime/readonly-value.js +141 -0
- 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 +31 -16
- package/dist/runtime/scalar-runtime.js +16 -18
- 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 +21 -11
- package/dist/transactions/transaction-plan-assembler.js +148 -34
- package/dist/transactions/transaction-plan-validator.d.ts +29 -20
- package/dist/transactions/transaction-plan-validator.js +70 -38
- package/dist/transactions/transaction-reference-collector.d.ts +5 -5
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +26 -14
- package/dist/transactions/transaction-reference-validator.d.ts +34 -4
- package/dist/transactions/transaction-reference-validator.js +58 -26
- package/dist/transactions/transaction-reference.d.ts +13 -13
- package/dist/transactions/transaction-request.d.ts +18 -5
- package/dist/transactions/transaction-response.d.ts +6 -6
- package/dist/transactions/transaction-runtime.d.ts +8 -7
- package/dist/transactions/transaction-runtime.js +166 -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 +6 -5
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -42
- package/dist/config/define-fields.js +0 -3
- package/dist/config/framework-behaviors-config.d.ts +0 -30
- package/dist/config/framework-fields-config.d.ts +0 -42
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/json/avz.d.ts +0 -96
- package/dist/runtime/field-behavior.d.ts +0 -48
- /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
- /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
- /package/dist/{json → avz}/index.js +0 -0
- /package/dist/{json → avz}/json-shape.registry.js +0 -0
- /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
- /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
|
@@ -1,48 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
2
|
+
import type { AvConfigAny } from "../config/any-framework-config.js";
|
|
3
|
+
import type { AvRequestOrigin } from "../config/config-layer.js";
|
|
4
|
+
import type { ErasedResources } from "../config/stage-type.eraser.js";
|
|
5
|
+
import type { AvContractLimits } from "../contracts/contract-limits.js";
|
|
5
6
|
import type { JsonShape, ShapedJsonSchema } from "../contracts/json-shape.js";
|
|
6
|
-
/**
|
|
7
|
-
* Whether `resolveRecord` descends into a value: an object that is no array and
|
|
8
|
-
* no Json Shape.
|
|
9
|
-
*/
|
|
10
|
-
type IsLayeredRecord<T> = [T] extends [readonly unknown[]] ? false : [T] extends [JsonShape] ? false : [T] extends [object] ? true : false;
|
|
11
|
-
/**
|
|
12
|
-
* A root record with a scoped record layered over it: a key the scoped side
|
|
13
|
-
* states wins; when both sides are records they merge, recursively; otherwise
|
|
14
|
-
* the scoped value replaces the root one.
|
|
15
|
-
*/
|
|
16
|
-
type LayeredRecord<Root, Scoped> = {
|
|
17
|
-
readonly [K in keyof Root | keyof Scoped]: K extends keyof Scoped ? K extends keyof Root ? [IsLayeredRecord<Root[K]>, IsLayeredRecord<Scoped[K]>] extends [
|
|
18
|
-
true,
|
|
19
|
-
true
|
|
20
|
-
] ? LayeredRecord<Root[K], Scoped[K]> : Scoped[K] : Scoped[K] : K extends keyof Root ? Root[K] : never;
|
|
21
|
-
};
|
|
22
7
|
/**
|
|
23
8
|
* A record whose keys are literal, or `never`. An absent block, an index-signature
|
|
24
|
-
* record — the `
|
|
25
|
-
* wide `
|
|
9
|
+
* record — the `AvConfigAny` default, or a configuration annotated with the
|
|
10
|
+
* wide `AvConfig<M>` — names no field, so it contributes nothing rather
|
|
26
11
|
* than widening every resource's field set to `string`.
|
|
27
12
|
*/
|
|
28
13
|
type LiteralRecord<T> = unknown extends T ? never : [NonNullable<T>] extends [never] ? never : [NonNullable<T>] extends [object] ? string extends keyof NonNullable<T> ? never : NonNullable<T> : never;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* One configuration block as a derived Contract is compiled from it: the root
|
|
32
|
-
* `Key`, with layer `Layer`'s `Key` layered over it.
|
|
33
|
-
*/
|
|
34
|
-
type LayerBlock<Cfg, Layer extends RequestOrigin, Key extends "fields" | "restrictions"> = LayeredBlocks<LiteralRecord<(Cfg & {
|
|
35
|
-
readonly [K in Key]?: unknown;
|
|
36
|
-
})[Key]>, LiteralRecord<((Cfg & {
|
|
37
|
-
readonly [L in Layer]?: unknown;
|
|
38
|
-
})[Layer] & {
|
|
39
|
-
readonly [K in Key]?: unknown;
|
|
40
|
-
})[Key]>>;
|
|
41
|
-
/** Root's own `Key` block, before any layer is layered over it. */
|
|
42
|
-
type RootBlock<Cfg, Key extends "fields" | "restrictions"> = LiteralRecord<(Cfg & {
|
|
14
|
+
/** The root's own `Key` block. */
|
|
15
|
+
type RootBlock<Cfg, Key extends PropertyKey> = LiteralRecord<(Cfg & {
|
|
43
16
|
readonly [K in Key]?: unknown;
|
|
44
17
|
})[Key]>;
|
|
45
|
-
/**
|
|
18
|
+
/** The root's `resources` block, its stages erased. */
|
|
19
|
+
type ResourcesBlock<Cfg> = ErasedResources<RootBlock<Cfg, "resources">>;
|
|
20
|
+
/** An overlay's `resources` block, its stages erased (see {@link ResourcesBlock}). */
|
|
21
|
+
type OverlayResourcesBlock<Cfg, Layer extends AvRequestOrigin> = ErasedResources<LiteralRecord<(LiteralRecord<OverlayOf<Cfg, Layer>> & {
|
|
22
|
+
readonly resources?: unknown;
|
|
23
|
+
})["resources"]>>;
|
|
24
|
+
/** One key's entry in a block, or `never` when the block has none. */
|
|
46
25
|
type EntryOf<Block, Key> = [Block] extends [never] ? never : Key extends keyof Block ? LiteralRecord<NonNullable<Block[Key]>> : never;
|
|
47
26
|
type ConfiguredCapabilities<FieldConfig> = [FieldConfig] extends [never] ? Record<never, never> : FieldConfig extends {
|
|
48
27
|
readonly capabilities: infer Capabilities;
|
|
@@ -102,148 +81,235 @@ type AddedField<FieldConfig> = {
|
|
|
102
81
|
type AddedFieldKey<ModelFields, ResourceConfig> = [ResourceConfig] extends [
|
|
103
82
|
never
|
|
104
83
|
] ? never : Exclude<Extract<keyof ResourceConfig, string>, keyof ModelFields>;
|
|
84
|
+
/** A field entry's `definition`, or `never` when it states none. */
|
|
85
|
+
type DefinitionOf<FieldEntry> = EntryOf<FieldEntry, "definition">;
|
|
105
86
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
87
|
+
* A Resource's fields before exposure: the model's and the ones the root's
|
|
88
|
+
* definitions add, each with its definition applied.
|
|
108
89
|
*/
|
|
109
|
-
type
|
|
110
|
-
readonly
|
|
111
|
-
}
|
|
90
|
+
type LayeredFields<ModelFields, ResourceConfig> = {
|
|
91
|
+
readonly [F in keyof ModelFields | AddedFieldKey<ModelFields, ResourceConfig>]: F extends keyof ModelFields ? LayeredModelField<ModelFields[F], DefinitionOf<EntryOf<ResourceConfig, F>>> : AddedField<DefinitionOf<EntryOf<ResourceConfig, F>>>;
|
|
92
|
+
};
|
|
112
93
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
94
|
+
* One Resource before exposure: the model's own, with its fields layered and
|
|
95
|
+
* its create requirements less what the layers' compute stages fill.
|
|
115
96
|
*/
|
|
116
|
-
type
|
|
117
|
-
[
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
type
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
readonly scopes: infer Scopes;
|
|
138
|
-
} ? Scopes : MemberScopes<Member>) extends infer Scopes ? [Scopes] extends [never] ? Restriction extends {
|
|
139
|
-
readonly [K in TokenKey]: infer Tokens;
|
|
140
|
-
} ? Tokens : MemberTokens<Member, TokenKey> : Scopes extends readonly [] ? false : {
|
|
141
|
-
readonly [K in TokenKey | "scopes"]: K extends "scopes" ? Scopes : Restriction extends {
|
|
142
|
-
readonly [T in TokenKey]: infer Tokens;
|
|
143
|
-
} ? Tokens : MemberTokens<Member, TokenKey>;
|
|
144
|
-
} : never : Member;
|
|
145
|
-
/** One capability member narrowed by a list (or, on a relation, an object) restriction. */
|
|
146
|
-
type NarrowedMember<Kind, Key, Member, Restriction> = Kind extends "relation" ? Key extends "select" | "include" ? Restriction extends readonly [] ? false : Restriction : Key extends "create" | "update" ? NarrowedScopedTokens<Member, Restriction, "directives"> : Key extends "reducers" ? NarrowedScopedTokens<Member, Restriction, "reducers"> : Restriction : Restriction;
|
|
147
|
-
/** One capability member of a field under its layer's restrictions. */
|
|
148
|
-
type RestrictedMember<Kind, Key, Member, Root, Layered> = IsRestoration<Layered> extends true ? Root extends readonly unknown[] | {
|
|
149
|
-
readonly scopes?: unknown;
|
|
150
|
-
} ? NarrowedMember<Kind, Key, Member, Root> : Member : [Layered] extends [boolean] ? Member : NarrowedMember<Kind, Key, Member, Layered>;
|
|
151
|
-
/** The members a capabilities restriction denies, or narrows to nothing. */
|
|
152
|
-
type DeniedMember<Kind, Own, Root, Layered> = {
|
|
153
|
-
[P in keyof Own]-?: P extends keyof Layered ? IsDenial<Layered[P]> extends true ? P : [
|
|
154
|
-
RestrictedMember<Kind, P, Own[P], P extends keyof Root ? Root[P] : undefined, Layered[P]>
|
|
155
|
-
] extends [false] ? P : never : never;
|
|
156
|
-
}[keyof Own];
|
|
157
|
-
/** A field's capabilities under its layer's restrictions. */
|
|
158
|
-
type RestrictedCapabilities<Kind, Own, Root, Layered> = {
|
|
159
|
-
readonly [P in keyof Own as P extends DeniedMember<Kind, Own, Root, Layered> ? never : P]: P extends keyof Layered ? RestrictedMember<Kind, P, Own[P], P extends keyof Root ? Root[P] : undefined, Layered[P]> : Own[P];
|
|
97
|
+
type LayeredResource<in out Resource, in out ResourceConfig, in out OverlayConfig> = {
|
|
98
|
+
readonly [P in keyof Resource]: P extends "fields" ? LayeredFields<Resource[P], EntryOf<ResourceConfig, "fields">> : P extends "createRequirements" ? RequirementsLessComputed<Exclude<Resource[P], undefined>, ComputedOnCreateKey<EntryOf<ResourceConfig, "fields">> | ComputedOnCreateKey<EntryOf<OverlayConfig, "fields">>> : Resource[P];
|
|
99
|
+
};
|
|
100
|
+
/** The fields of a `fields` block with a `compute.create` stage. */
|
|
101
|
+
type ComputedOnCreateKey<FieldsBlock> = [FieldsBlock] extends [never] ? never : {
|
|
102
|
+
[F in keyof FieldsBlock]-?: NonNullable<FieldsBlock[F]> extends {
|
|
103
|
+
readonly pipelines?: infer Pipelines;
|
|
104
|
+
} ? NonNullable<Pipelines> extends {
|
|
105
|
+
readonly compute?: infer Compute;
|
|
106
|
+
} ? "create" extends keyof NonNullable<Compute> ? F : never : never : never;
|
|
107
|
+
}[keyof FieldsBlock];
|
|
108
|
+
/**
|
|
109
|
+
* A create-requirement statement less `Computed`: a required field leaves
|
|
110
|
+
* `required`, a group's reference field leaves its group, and a group left with
|
|
111
|
+
* none is satisfied and leaves `oneOf`. A member left empty is absent, as the
|
|
112
|
+
* compiler leaves it (`projectCreateRequirements`).
|
|
113
|
+
*/
|
|
114
|
+
type RequirementsLessComputed<Requirements, Computed> = [Computed] extends [
|
|
115
|
+
never
|
|
116
|
+
] ? Requirements : {
|
|
117
|
+
readonly [P in keyof Requirements as P extends "required" | "oneOf" ? LessComputed<P, Requirements[P], Computed> extends readonly [] ? never : P : P]: P extends "required" | "oneOf" ? LessComputed<P, Requirements[P], Computed> : Requirements[P];
|
|
160
118
|
};
|
|
161
|
-
/**
|
|
162
|
-
type
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
119
|
+
/** One member of a statement less `Computed`: its names, or its groups. */
|
|
120
|
+
type LessComputed<Member, List, Computed> = Member extends "required" ? NamesLessComputed<List, Computed> : GroupsLessComputed<List, Computed>;
|
|
121
|
+
/** A name tuple less `Computed`, still a tuple. */
|
|
122
|
+
type NamesLessComputed<Names, Computed> = Names extends readonly [
|
|
123
|
+
infer Head,
|
|
124
|
+
...infer Rest
|
|
125
|
+
] ? Head extends Computed ? NamesLessComputed<Rest, Computed> : readonly [Head, ...NamesLessComputed<Rest, Computed>] : readonly [];
|
|
126
|
+
/** A group tuple less `Computed` reference fields; a group left with none is dropped. */
|
|
127
|
+
type GroupsLessComputed<Groups, Computed> = Groups extends readonly [
|
|
128
|
+
infer Group,
|
|
129
|
+
...infer Rest
|
|
130
|
+
] ? Group extends readonly [infer Relation, ...infer References] ? NamesLessComputed<References, Computed> extends readonly [] ? GroupsLessComputed<Rest, Computed> : readonly [
|
|
131
|
+
readonly [Relation, ...NamesLessComputed<References, Computed>],
|
|
132
|
+
...GroupsLessComputed<Rest, Computed>
|
|
133
|
+
] : GroupsLessComputed<Rest, Computed> : readonly [];
|
|
134
|
+
/** The Resources before exposure: the model, with the root's definitions applied. */
|
|
135
|
+
type LayeredResources<Resources, Block, OverlayBlock> = {
|
|
136
|
+
readonly [R in keyof Resources]: LayeredResource<Resources[R], EntryOf<Block, R>, EntryOf<OverlayBlock, R>>;
|
|
168
137
|
};
|
|
169
138
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* restrictions applied.
|
|
139
|
+
* The style a layer's `exposed` sets: `false` picks, `true` or absent omits, a
|
|
140
|
+
* widened `boolean` keeps the parent's view.
|
|
173
141
|
*/
|
|
174
|
-
type
|
|
175
|
-
|
|
142
|
+
type ExposureStyleOf<Exposed> = [Exposed] extends [false] ? "pick" : [Exposed] extends [true] ? "omit" : unknown extends Exposed ? "omit" : "keep";
|
|
143
|
+
/** A layer's `exposed`, read by indexed access (see {@link RootBlock}). */
|
|
144
|
+
type ExposedOf<Layer> = (Layer & {
|
|
145
|
+
readonly exposed?: unknown;
|
|
146
|
+
})["exposed"];
|
|
147
|
+
/** A layer's `exemptions.resources` block, or `never` when it states none. */
|
|
148
|
+
type ExemptionsOf<Layer> = LiteralRecord<(LiteralRecord<(Layer & {
|
|
149
|
+
readonly exemptions?: unknown;
|
|
150
|
+
})["exemptions"]> & {
|
|
151
|
+
readonly resources?: unknown;
|
|
152
|
+
})["resources"]>;
|
|
153
|
+
/** An overlay's own configuration: `application` or `client`. */
|
|
154
|
+
type OverlayOf<Cfg, Layer extends AvRequestOrigin> = (Cfg & {
|
|
155
|
+
readonly [L in Layer]?: unknown;
|
|
156
|
+
})[Layer];
|
|
157
|
+
/** One key's raw entry in an exemptions block: `true`, a list or an object. */
|
|
158
|
+
type RawEntry<Block, Key> = [Block] extends [never] ? unknown : Key extends keyof Block ? NonNullable<Block[Key]> : unknown;
|
|
159
|
+
/** An entry that exempts its subtree whole under Omit: a literal `true`. */
|
|
160
|
+
type IsWhole<Entry> = [Entry] extends [true] ? true : false;
|
|
161
|
+
/** Whether a Pick entry exempts anything: `true`, `boolean`, a non-empty list or an object. */
|
|
162
|
+
type Grants<Entry> = [Entry] extends [false] ? false : [Entry] extends [boolean] ? true : [Entry] extends [readonly []] ? false : [Entry] extends [object] ? true : false;
|
|
163
|
+
/** The keys of a block whose entry is a literal `true`. */
|
|
164
|
+
type WholeKey<Block> = [Block] extends [never] ? never : {
|
|
165
|
+
[K in keyof Block]-?: IsWhole<NonNullable<Block[K]>> extends true ? K : never;
|
|
166
|
+
}[keyof Block];
|
|
167
|
+
/** Whether any member of an object entry grants (see {@link Grants}). */
|
|
168
|
+
type AnyMemberGrants<Entry, Exclude = never> = true extends {
|
|
169
|
+
[K in keyof Entry]-?: K extends Exclude ? false : Grants<NonNullable<Entry[K]>>;
|
|
170
|
+
}[keyof Entry] ? true : false;
|
|
171
|
+
/** Whether a Pick field entry grants a capability: an object must grant one inside. */
|
|
172
|
+
type FieldGrants<Entry> = [Entry] extends [readonly unknown[]] ? Grants<Entry> : [Entry] extends [boolean] ? Grants<Entry> : [Entry] extends [object] ? AnyMemberGrants<Entry, AdapterLimit> : false;
|
|
173
|
+
/** Whether one family's entry grants a variant. */
|
|
174
|
+
type FamilyGrants<Entry> = [Entry] extends [readonly unknown[]] ? Grants<Entry> : [Entry] extends [boolean] ? Grants<Entry> : [Entry] extends [object] ? AnyMemberGrants<Entry> : false;
|
|
175
|
+
/** Whether an operations entry grants an operation. */
|
|
176
|
+
type OperationsGrant<Entry> = [Entry] extends [readonly unknown[]] ? Grants<Entry> : [Entry] extends [boolean] ? Grants<Entry> : [Entry] extends [object] ? true extends {
|
|
177
|
+
[F in keyof Entry]-?: FamilyGrants<NonNullable<Entry[F]>>;
|
|
178
|
+
}[keyof Entry] ? true : false : false;
|
|
179
|
+
/** Whether a Pick Resource entry grants a field or an operation. */
|
|
180
|
+
type ResourceGrants<Entry> = [Entry] extends [boolean] ? Grants<Entry> : [Entry] extends [object] ? true extends OperationsGrant<NonNullable<OperationsEntryOf<Entry>>> | (true extends {
|
|
181
|
+
[F in keyof FieldsEntryOf<Entry>]-?: FieldGrants<NonNullable<FieldsEntryOf<Entry>[F]>>;
|
|
182
|
+
}[keyof FieldsEntryOf<Entry>] ? true : false) ? true : false : false;
|
|
183
|
+
/** The keys of a Pick `fields` block whose entry grants (see {@link FieldGrants}). */
|
|
184
|
+
type GrantedFieldKey<Block> = [Block] extends [never] ? never : {
|
|
185
|
+
[K in keyof Block]-?: FieldGrants<NonNullable<Block[K]>> extends true ? K : never;
|
|
186
|
+
}[keyof Block];
|
|
187
|
+
/** The keys of a Pick `resources` block whose entry grants (see {@link ResourceGrants}). */
|
|
188
|
+
type GrantedResourceKey<Block> = [Block] extends [never] ? never : {
|
|
189
|
+
[K in keyof Block]-?: ResourceGrants<NonNullable<Block[K]>> extends true ? K : never;
|
|
190
|
+
}[keyof Block];
|
|
191
|
+
/** The names a list entry lists. */
|
|
192
|
+
type Listed<Entry> = Entry extends readonly (infer Name)[] ? Name : never;
|
|
193
|
+
/** A token member's tokens, its qualifier aside. */
|
|
194
|
+
type MemberTokens<Member> = Member extends {
|
|
195
|
+
readonly scopes: unknown;
|
|
196
|
+
} ? {
|
|
197
|
+
[K in keyof Member]: K extends "scopes" ? never : Member[K] extends readonly (infer Token)[] ? Token : never;
|
|
198
|
+
}[keyof Member] : Member extends readonly (infer Token)[] ? Token : never;
|
|
199
|
+
/** A token member with its tokens replaced by `Tokens`, qualifier kept. */
|
|
200
|
+
type WithTokens<Member, Tokens> = Member extends {
|
|
201
|
+
readonly scopes: unknown;
|
|
202
|
+
} ? {
|
|
203
|
+
readonly [K in keyof Member]: K extends "scopes" ? Member[K] : readonly Tokens[];
|
|
204
|
+
} : readonly Tokens[];
|
|
205
|
+
/** One capability member under an Omit object entry: a token list removes those tokens. */
|
|
206
|
+
type OmittedMember<Member, Entry> = Entry extends readonly unknown[] ? WithTokens<Member, Exclude<MemberTokens<Member>, Listed<Entry>>> : Member;
|
|
207
|
+
/** One capability member under a Pick object entry: a token list keeps only those tokens. */
|
|
208
|
+
type PickedMember<Member, Entry> = Entry extends readonly unknown[] ? WithTokens<Member, Extract<MemberTokens<Member>, Listed<Entry>>> : Member;
|
|
209
|
+
/** The capability members no exemption names and a Pick still keeps. */
|
|
210
|
+
type AdapterLimit = "nestedWriteFilter";
|
|
211
|
+
/** A field's capabilities under its exemption, a list of names or an object. */
|
|
212
|
+
type ExemptedCapabilities<Caps, Entry, Style> = Style extends "omit" ? Entry extends readonly unknown[] ? {
|
|
213
|
+
readonly [P in keyof Caps as P extends Listed<Entry> ? never : P]: Caps[P];
|
|
214
|
+
} : {
|
|
215
|
+
readonly [P in keyof Caps as P extends keyof Entry ? IsWhole<Entry[P]> extends true ? never : P : P]: P extends keyof Entry ? OmittedMember<Caps[P], Entry[P]> : Caps[P];
|
|
216
|
+
} : Entry extends readonly unknown[] ? {
|
|
217
|
+
readonly [P in keyof Caps as P extends Listed<Entry> | AdapterLimit ? P : never]: Caps[P];
|
|
218
|
+
} : {
|
|
219
|
+
readonly [P in keyof Caps as P extends AdapterLimit ? P : P extends keyof Entry ? Grants<Entry[P]> extends true ? P : never : never]: P extends keyof Entry ? PickedMember<Caps[P], Entry[P]> : Caps[P];
|
|
220
|
+
};
|
|
221
|
+
/** One field under its exemption: `true` (or `boolean`) keeps the parent's field. */
|
|
222
|
+
type ExemptedField<Field, Entry, Style> = [Entry] extends [boolean] ? Field : {
|
|
223
|
+
readonly [P in keyof Field]: P extends "capabilities" ? ExemptedCapabilities<Field[P], Entry, Style> : Field[P];
|
|
224
|
+
};
|
|
225
|
+
/** A Resource's fields under its exemptions' `fields` block. */
|
|
226
|
+
type ExemptedFields<Fields, Block, Style> = Style extends "omit" ? [Block] extends [never] ? Fields : {
|
|
227
|
+
readonly [F in Exclude<keyof Fields, WholeKey<Block>>]: F extends keyof Block ? ExemptedField<Fields[F], NonNullable<Block[F]>, "omit"> : Fields[F];
|
|
228
|
+
} : {
|
|
229
|
+
readonly [F in Extract<keyof Fields, GrantedFieldKey<Block>>]: ExemptedField<Fields[F], RawEntry<Block, F>, "pick">;
|
|
176
230
|
};
|
|
177
|
-
/** The
|
|
178
|
-
type
|
|
179
|
-
|
|
180
|
-
|
|
231
|
+
/** The fields an exemptions `fields` block leaves a Resource without. */
|
|
232
|
+
type RemovedField<Fields, Block, Style> = Style extends "omit" ? WholeKey<Block> : Exclude<keyof Fields, GrantedFieldKey<Block>>;
|
|
233
|
+
/** One family's entry in an operations entry: `true` for a listed family. */
|
|
234
|
+
type FamilyEntry<Operations, Family> = Operations extends readonly unknown[] ? Family extends Listed<Operations> ? true : unknown : [Operations] extends [boolean] ? Operations : Family extends keyof Operations ? NonNullable<Operations[Family]> : unknown;
|
|
235
|
+
/** The keys of a per-variant object entry set to a literal `true`. */
|
|
236
|
+
type TrueVariant<Entry> = {
|
|
237
|
+
[V in keyof Entry]-?: IsWhole<NonNullable<Entry[V]>> extends true ? V : never;
|
|
238
|
+
}[keyof Entry];
|
|
239
|
+
/** The variants of one family a layer keeps, by its style. */
|
|
240
|
+
type KeptVariant<Family, Entry, Style, UniqueLost> = Exclude<Style extends "omit" ? IsWhole<Entry> extends true ? never : Entry extends readonly unknown[] ? Exclude<keyof Family, Listed<Entry>> : [Entry] extends [boolean] ? keyof Family : Entry extends object ? Exclude<keyof Family, TrueVariant<Entry>> : keyof Family : [Entry] extends [false] ? never : [Entry] extends [boolean] ? keyof Family : Entry extends readonly unknown[] ? Extract<keyof Family, Listed<Entry>> : Entry extends object ? Extract<keyof Family, TrueVariant<Entry>> : never, UniqueLost extends true ? UniqueVariant : never>;
|
|
181
241
|
/** The variants of the unique style, which need an identifier the layer keeps. */
|
|
182
242
|
type UniqueVariant = "unique";
|
|
183
|
-
/**
|
|
184
|
-
|
|
185
|
-
* off, less the unique one when no identifier survives.
|
|
186
|
-
*/
|
|
187
|
-
type AvailableVariant<Family, FamilyRestriction, UniqueLost> = Exclude<keyof Family, DisabledVariant<FamilyRestriction> | (UniqueLost extends true ? UniqueVariant : never)>;
|
|
188
|
-
/** The families with at least one variant the layer advertises. */
|
|
189
|
-
type AvailableFamily<Operations, OperationRestrictions, UniqueLost> = {
|
|
243
|
+
/** The families with at least one variant the layer keeps. */
|
|
244
|
+
type KeptFamily<Operations, Entry, Style, UniqueLost> = {
|
|
190
245
|
[F in keyof Operations]-?: [
|
|
191
|
-
|
|
246
|
+
KeptVariant<NonNullable<Operations[F]>, FamilyEntry<Entry, F>, Style, UniqueLost>
|
|
192
247
|
] extends [never] ? never : F;
|
|
193
248
|
}[keyof Operations];
|
|
194
|
-
/** A Resource's operations under its
|
|
195
|
-
type
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
readonly [F in AvailableFamily<Operations, OperationRestrictions, UniqueLost>]: {
|
|
200
|
-
readonly [V in AvailableVariant<NonNullable<Operations[F]>, EntryOf<OperationRestrictions, F>, UniqueLost>]: NonNullable<Operations[F]>[V];
|
|
249
|
+
/** A Resource's operations under its exemptions' `operations` entry. */
|
|
250
|
+
type ExemptedOperations<Operations, Entry, Style, UniqueLost> = Style extends "omit" ? unknown extends Entry ? UniqueLost extends true ? KeptOperations<Operations, Entry, Style, UniqueLost> : Operations : KeptOperations<Operations, Entry, Style, UniqueLost> : KeptOperations<Operations, Entry, Style, UniqueLost>;
|
|
251
|
+
type KeptOperations<Operations, Entry, Style, UniqueLost> = {
|
|
252
|
+
readonly [F in KeptFamily<Operations, Entry, Style, UniqueLost>]: {
|
|
253
|
+
readonly [V in KeptVariant<NonNullable<Operations[F]>, FamilyEntry<Entry, F>, Style, UniqueLost>]: NonNullable<Operations[F]>[V];
|
|
201
254
|
};
|
|
202
255
|
};
|
|
203
|
-
/** A Resource's identifiers less those naming a
|
|
204
|
-
type KeptIdentifiers<Identifiers,
|
|
205
|
-
/** Whether
|
|
206
|
-
type IdentifiersLost<Identifiers,
|
|
207
|
-
KeptIdentifiers<Identifiers,
|
|
256
|
+
/** A Resource's identifiers less those naming a removed field. */
|
|
257
|
+
type KeptIdentifiers<Identifiers, Removed> = [Removed] extends [never] ? Identifiers : Identifiers extends readonly (infer Identifier)[] ? readonly (Identifier extends readonly (infer Field)[] ? [Extract<Field, Removed>] extends [never] ? Identifier : never : never)[] : Identifiers;
|
|
258
|
+
/** Whether removing fields left a Resource with no identifier at all. */
|
|
259
|
+
type IdentifiersLost<Identifiers, Removed> = [Removed] extends [never] ? false : [
|
|
260
|
+
KeptIdentifiers<Identifiers, Removed> extends readonly (infer Kept)[] ? Kept : never
|
|
208
261
|
] extends [never] ? true : false;
|
|
209
|
-
/**
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
type
|
|
214
|
-
readonly
|
|
262
|
+
/** A Resource's `fields` and `operations` entries, read off its exemption object. */
|
|
263
|
+
type FieldsEntryOf<Entry> = LiteralRecord<(Entry & {
|
|
264
|
+
readonly fields?: unknown;
|
|
265
|
+
})["fields"]>;
|
|
266
|
+
type OperationsEntryOf<Entry> = (Entry & {
|
|
267
|
+
readonly operations?: unknown;
|
|
268
|
+
})["operations"];
|
|
269
|
+
/** One Resource under an object exemption: its fields, operations and identifiers. */
|
|
270
|
+
type ExemptedResourceObject<in out Resource, in out FieldsBlock, in out OperationsEntry, in out Style> = {
|
|
271
|
+
readonly [P in keyof Resource]: P extends "fields" ? ExemptedFields<Resource[P], FieldsBlock, Style> : P extends "operations" ? ExemptedOperations<Resource[P], OperationsEntry, Style, IdentifiersLost<Resource extends {
|
|
215
272
|
readonly identifiers: infer Ids;
|
|
216
|
-
} ? Ids : never,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
* restoration inherits; both `never` for a configuration that restricts nothing.
|
|
222
|
-
*/
|
|
223
|
-
type LayeredResources<Resources, Block, Restrictions, RootRestrictions> = {
|
|
224
|
-
readonly [R in Exclude<keyof Resources, HiddenKey<Restrictions>>]: LayeredResource<Resources[R], EntryOf<Block, R>, EntryOf<Restrictions, R>, EntryOf<RootRestrictions, R>>;
|
|
273
|
+
} ? Ids : never, RemovedField<Resource extends {
|
|
274
|
+
readonly fields: infer Fields;
|
|
275
|
+
} ? Fields : never, FieldsBlock, Style>>> : P extends "identifiers" ? KeptIdentifiers<Resource[P], RemovedField<Resource extends {
|
|
276
|
+
readonly fields: infer Fields;
|
|
277
|
+
} ? Fields : never, FieldsBlock, Style>> : Resource[P];
|
|
225
278
|
};
|
|
279
|
+
/** One Resource under its exemption: `true` (or `boolean`) keeps the parent's. */
|
|
280
|
+
type ExemptedResource<Resource, Entry, Style> = [Entry] extends [boolean] ? Resource : ExemptedResourceObject<Resource, FieldsEntryOf<Entry>, OperationsEntryOf<Entry>, Style>;
|
|
281
|
+
/** A layer's Resources: its parent's, with its exemptions applied in its style. */
|
|
282
|
+
type ExposedResources<Resources, Style, Block> = Style extends "omit" ? [Block] extends [never] ? Resources : {
|
|
283
|
+
readonly [R in Exclude<keyof Resources, WholeKey<Block>>]: R extends keyof Block ? ExemptedResource<Resources[R], NonNullable<Block[R]>, "omit"> : Resources[R];
|
|
284
|
+
} : Style extends "pick" ? {
|
|
285
|
+
readonly [R in Extract<keyof Resources, GrantedResourceKey<Block>>]: ExemptedResource<Resources[R], RawEntry<Block, R>, "pick">;
|
|
286
|
+
} : Resources;
|
|
287
|
+
/** The Resources of the root's final view: what every overlay starts from. */
|
|
288
|
+
export type RootViewResources<M extends AvAdapterModel, Cfg> = ExposedResources<LayeredResources<M["resources"], ResourcesBlock<Cfg>, never>, ExposureStyleOf<ExposedOf<Cfg>>, ExemptionsOf<Cfg>>;
|
|
289
|
+
/** The Resources of an overlay's final view: the root's view, narrowed by it. */
|
|
290
|
+
export type OverlayViewResources<M extends AvAdapterModel, Cfg, Layer extends "application" | "client"> = ExposedResources<ExposedResources<LayeredResources<M["resources"], ResourcesBlock<Cfg>, OverlayResourcesBlock<Cfg, Layer>>, ExposureStyleOf<ExposedOf<Cfg>>, ExemptionsOf<Cfg>>, ExposureStyleOf<ExposedOf<OverlayOf<Cfg, Layer>>>, ExemptionsOf<OverlayOf<Cfg, Layer>>>;
|
|
226
291
|
/**
|
|
227
|
-
* One derived Contract's type: the model, with
|
|
228
|
-
*
|
|
229
|
-
* `RootRestrictions`) applied.
|
|
292
|
+
* One derived Contract's type: the model, with the root's `resources` block
|
|
293
|
+
* applied, then the root's exposure, then the overlay's over the root's view.
|
|
230
294
|
*/
|
|
231
|
-
type DerivedContractView<M extends
|
|
295
|
+
type DerivedContractView<M extends AvAdapterModel, FieldsBlock, RootStyle, RootExemptions, OverlayStyle, OverlayExemptions, OverlayBlock> = {
|
|
232
296
|
readonly scalars: M["scalars"];
|
|
233
297
|
readonly enums: M["enums"];
|
|
234
|
-
readonly resources: LayeredResources<M["resources"], FieldsBlock,
|
|
235
|
-
readonly limits:
|
|
298
|
+
readonly resources: ExposedResources<ExposedResources<LayeredResources<M["resources"], FieldsBlock, OverlayBlock>, RootStyle, RootExemptions>, OverlayStyle, OverlayExemptions>;
|
|
299
|
+
readonly limits: AvContractLimits;
|
|
236
300
|
readonly transactions: M["transactions"];
|
|
237
301
|
};
|
|
238
302
|
/**
|
|
239
303
|
* The Application Contract's type, derived from the adapter model and the
|
|
240
304
|
* configuration.
|
|
241
305
|
*/
|
|
242
|
-
export type
|
|
306
|
+
export type AvContractApplicationView<M extends AvAdapterModel, Cfg = AvConfigAny> = [Cfg] extends [unknown] ? DerivedContractView<M, ResourcesBlock<Cfg>, ExposureStyleOf<ExposedOf<Cfg>>, ExemptionsOf<Cfg>, ExposureStyleOf<ExposedOf<OverlayOf<Cfg, "application">>>, ExemptionsOf<OverlayOf<Cfg, "application">>, OverlayResourcesBlock<Cfg, "application">> : never;
|
|
243
307
|
/**
|
|
244
308
|
* The Client Contract's type, derived from the adapter model and the
|
|
245
309
|
* configuration: what the client layer hides is absent. It types
|
|
246
310
|
* `framework.client` and `framework.clientTx`.
|
|
247
311
|
*/
|
|
248
|
-
export type ClientContractView<M extends
|
|
312
|
+
export type ClientContractView<M extends AvAdapterModel, Cfg = AvConfigAny> = [
|
|
313
|
+
Cfg
|
|
314
|
+
] extends [unknown] ? DerivedContractView<M, ResourcesBlock<Cfg>, ExposureStyleOf<ExposedOf<Cfg>>, ExemptionsOf<Cfg>, ExposureStyleOf<ExposedOf<OverlayOf<Cfg, "client">>>, ExemptionsOf<OverlayOf<Cfg, "client">>, OverlayResourcesBlock<Cfg, "client">> : never;
|
|
249
315
|
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { AvAdapterDiscoveryDiagnostic } from "../adapters/adapter-discovery-diagnostic.js";
|
|
2
|
+
import type { AvContractCompilerDiagnostic } from "../compiler/contract-compiler-diagnostic.js";
|
|
3
|
+
import type { AvConfigDiagnostic } from "../config/config-diagnostic.js";
|
|
4
4
|
/** The construction step that failed. */
|
|
5
|
-
export type
|
|
6
|
-
/** One problem reported by {@link
|
|
7
|
-
export type
|
|
5
|
+
export type AvConstructionStage = "configuration" | "discovery" | "contract-compilation";
|
|
6
|
+
/** One problem reported by {@link AvConstructionError}. */
|
|
7
|
+
export type AvConstructionDiagnostic = AvConfigDiagnostic | AvAdapterDiscoveryDiagnostic | AvContractCompilerDiagnostic;
|
|
8
8
|
/**
|
|
9
9
|
* Thrown by {@link createFramework} when construction fails: `stage` says
|
|
10
10
|
* where, and `diagnostics` lists every problem found there.
|
|
11
11
|
*/
|
|
12
|
-
export declare class
|
|
13
|
-
readonly stage:
|
|
14
|
-
readonly diagnostics: readonly
|
|
15
|
-
constructor(stage:
|
|
12
|
+
export declare class AvConstructionError extends Error {
|
|
13
|
+
readonly stage: AvConstructionStage;
|
|
14
|
+
readonly diagnostics: readonly AvConstructionDiagnostic[];
|
|
15
|
+
constructor(stage: AvConstructionStage, diagnostics: readonly AvConstructionDiagnostic[]);
|
|
16
16
|
}
|
|
@@ -3,12 +3,12 @@ const FRAMEWORK_CONSTRUCTION_MESSAGES = {
|
|
|
3
3
|
discovery: "Aventara adapter discovery validation failed",
|
|
4
4
|
"contract-compilation": "Aventara contract compilation failed",
|
|
5
5
|
};
|
|
6
|
-
export class
|
|
6
|
+
export class AvConstructionError extends Error {
|
|
7
7
|
stage;
|
|
8
8
|
diagnostics;
|
|
9
9
|
constructor(stage, diagnostics) {
|
|
10
10
|
super(FRAMEWORK_CONSTRUCTION_MESSAGES[stage]);
|
|
11
|
-
this.name = "
|
|
11
|
+
this.name = "AvConstructionError";
|
|
12
12
|
this.stage = stage;
|
|
13
13
|
this.diagnostics = [...diagnostics];
|
|
14
14
|
}
|
|
@@ -1,28 +1,41 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
2
|
+
import type { AvContracts } from "../compiler/contract.compiler.js";
|
|
3
|
+
import type { AvConfigAny } from "../config/any-framework-config.js";
|
|
4
|
+
import type { AvMcpEndpoint } from "../config/config.resolver.js";
|
|
4
5
|
import type { FrameworkOperationRequest } from "../runtime/operation-request.js";
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
6
|
+
import type { AvOperationResponse } from "../runtime/operation-response.js";
|
|
7
|
+
import type { AvTransactionRunner } from "../transactions/deferred-operation.js";
|
|
7
8
|
import type { FrameworkTransactionRequest } from "../transactions/transaction-request.js";
|
|
8
|
-
import type {
|
|
9
|
+
import type { AvTransactionResponse } from "../transactions/transaction-response.js";
|
|
9
10
|
import type { ApplicationOperations, ApplicationTransactionBuilders, ClientOperations, ClientTransactionBuilders } from "./operation-facade.js";
|
|
10
11
|
/**
|
|
11
12
|
* One Aventara instance, as returned by {@link createFramework}: its compiled
|
|
12
13
|
* Contracts, typed in-process operations, transaction builders and the
|
|
13
14
|
* untyped `execute` entry a transport calls.
|
|
14
15
|
*/
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
export type AvFramework<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = {
|
|
17
|
+
/**
|
|
18
|
+
* The protocol's mount path (`api`) in its canonical form: `""` at the
|
|
19
|
+
* root, otherwise `/seg(/seg)*`.
|
|
20
|
+
*/
|
|
21
|
+
readonly api: string;
|
|
22
|
+
/**
|
|
23
|
+
* The MCP endpoint `mcp` turns on — its canonical mount path and its
|
|
24
|
+
* authorization — for the host that serves it; `undefined` when MCP is off.
|
|
25
|
+
*/
|
|
26
|
+
readonly mcp: AvMcpEndpoint | undefined;
|
|
27
|
+
readonly contracts: AvContracts;
|
|
18
28
|
/**
|
|
19
29
|
* Typed in-process operations under the Application Contract:
|
|
20
30
|
* `framework.application.<resource>.<family>.<variant>(args, options?)`.
|
|
21
31
|
*
|
|
22
32
|
* Typed from the Application Contract as configured: what the application's
|
|
23
|
-
*
|
|
24
|
-
* validated like any other request.
|
|
25
|
-
*
|
|
33
|
+
* exposure hides, denies or turns off is absent from the types, and a call is
|
|
34
|
+
* validated like any other request. A call resolves the operation's data (a
|
|
35
|
+
* first-style miss is `null`) and throws every failure as the `AvError`
|
|
36
|
+
* subclass of its code's class (`AvValidationError`, `AvNotFoundError`, …).
|
|
37
|
+
* The optional second argument is
|
|
38
|
+
* {@link AvExecutionOptions}.
|
|
26
39
|
*/
|
|
27
40
|
readonly application: ApplicationOperations<M, Cfg>;
|
|
28
41
|
/**
|
|
@@ -33,25 +46,33 @@ export type Framework<M extends AdapterModel = AdapterModel, Cfg = AnyFrameworkC
|
|
|
33
46
|
* as from a generated client, and arguments are read in the wire
|
|
34
47
|
* forms a decoded request body carries, so a transport can pass `req.body` as
|
|
35
48
|
* it is. Each call runs the client pipelines and the same validation as a
|
|
36
|
-
* remote request
|
|
49
|
+
* remote request, and settles like an application call: the data, or the
|
|
50
|
+
* failure thrown.
|
|
37
51
|
*/
|
|
38
52
|
readonly client: ClientOperations<M, Cfg>;
|
|
39
53
|
/**
|
|
40
54
|
* Transaction builders under application rules:
|
|
41
55
|
* `framework.appTx.<resource>.<family>.<variant>(args)` defers one operation
|
|
42
|
-
* into a handle typed `
|
|
56
|
+
* into a handle typed `AvOperation<AvOperationResultFor<…>>` from the Application
|
|
43
57
|
* Contract's view, and runs nothing. A handle exposes `$ref(field)` exactly
|
|
44
58
|
* where its result is one row; the reference is bound to the handle, and its
|
|
45
59
|
* index is bound when {@link transaction} runs the list it is in.
|
|
60
|
+
*
|
|
61
|
+
* `framework.appTx.$sql` defers a developer SQL step, written only as a tagged
|
|
62
|
+
* template whose every interpolated value is bound as a parameter (a `$ref`
|
|
63
|
+
* among them, resolved when the earlier steps have run). It runs in plan order
|
|
64
|
+
* in the same database transaction, with no pipelines around it; its entry in
|
|
65
|
+
* the committed data is its rows, typed by `appTx.$sql<Row>`. It exists only
|
|
66
|
+
* here: `clientTx`, the Client Contract and `/_transactions` have no SQL step.
|
|
46
67
|
*/
|
|
47
68
|
readonly appTx: ApplicationTransactionBuilders<M, Cfg>;
|
|
48
69
|
/**
|
|
49
70
|
* The same builders under ClientContract rules, taking wire-form arguments.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
71
|
+
* A {@link transaction} has one origin: client and application handles never
|
|
72
|
+
* share one (`A2004`/`V1020` at the first step of the other origin).
|
|
52
73
|
*/
|
|
53
74
|
readonly clientTx: ClientTransactionBuilders<M, Cfg>;
|
|
54
|
-
execute(request: FrameworkOperationRequest): Promise<
|
|
75
|
+
execute(request: FrameworkOperationRequest): Promise<AvOperationResponse>;
|
|
55
76
|
/**
|
|
56
77
|
* Validates a whole transaction plan, then runs its operations one after
|
|
57
78
|
* another inside one Adapter transaction. Answers `A1009` with each
|
|
@@ -62,15 +83,18 @@ export type Framework<M extends AdapterModel = AdapterModel, Cfg = AnyFrameworkC
|
|
|
62
83
|
* Guards, pipes, hooks and interceptors run while the transaction is open, so
|
|
63
84
|
* they should not perform network I/O or other slow work.
|
|
64
85
|
*/
|
|
65
|
-
executeTransaction(request: FrameworkTransactionRequest): Promise<
|
|
86
|
+
executeTransaction(request: FrameworkTransactionRequest): Promise<AvTransactionResponse>;
|
|
66
87
|
/**
|
|
67
88
|
* Runs handles from `appTx`/`clientTx` as one transaction:
|
|
68
|
-
* `framework.transaction([h1, h2, …], options?)`. Resolves
|
|
69
|
-
*
|
|
89
|
+
* `framework.transaction([h1, h2, …], options?)`. Resolves each handle's
|
|
90
|
+
* result in plan order, typed per position, once the transaction committed,
|
|
91
|
+
* or throws the failure as the `AvError` subclass of its code's class, with
|
|
92
|
+
* `cause.operation` naming the failing step.
|
|
70
93
|
*
|
|
71
94
|
* Refused before anything runs: an entry that is not one of this Framework's
|
|
72
|
-
* handles, or the same handle twice (`A2004`/`V1001`);
|
|
73
|
-
*
|
|
95
|
+
* handles, or the same handle twice (`A2004`/`V1001`); `appTx` and `clientTx`
|
|
96
|
+
* handles in one list (`A2004`/`V1020`); a `$ref` to a handle not in the list
|
|
97
|
+
* (`A2007`/`V1010`).
|
|
74
98
|
*/
|
|
75
|
-
readonly transaction:
|
|
99
|
+
readonly transaction: AvTransactionRunner;
|
|
76
100
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
2
|
+
import type { AvConfigAny } from "../config/any-framework-config.js";
|
|
3
|
+
import type { AvConfigExact } from "../config/exact-framework-config.js";
|
|
4
|
+
import type { AvConfig } from "../config/framework-config.js";
|
|
5
|
+
import type { ErasedConfig } from "../config/stage-type.eraser.js";
|
|
6
|
+
import type { AvFramework } from "./framework.js";
|
|
5
7
|
/**
|
|
6
8
|
* Creates a Framework: validates the configuration, reads the adapter's
|
|
7
9
|
* model and compiles the Contracts.
|
|
8
10
|
*
|
|
9
|
-
* @throws {@link
|
|
11
|
+
* @throws {@link AvConstructionError} when any of those steps fails.
|
|
10
12
|
*/
|
|
11
|
-
export declare function createFramework<M extends
|
|
13
|
+
export declare function createFramework<M extends AvAdapterModel, const Cfg = AvConfigAny>(config: Cfg & AvConfig<M, Cfg> & AvConfigExact<M, Cfg>): Promise<AvFramework<M, ErasedConfig<Cfg>>>;
|