@aventara/core 0.1.0-pilot.3 → 0.1.0-pilot.4
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/dist/adapters/adapter-discovery-diagnostic.d.ts +2 -0
- package/dist/adapters/adapter-field.d.ts +3 -26
- package/dist/adapters/adapter-identifier.d.ts +1 -11
- package/dist/adapters/adapter-model.d.ts +4 -0
- package/dist/adapters/adapter-operation-executor.interface.d.ts +5 -1
- package/dist/adapters/adapter-resource.d.ts +7 -28
- package/dist/adapters/adapter.interface.d.ts +21 -26
- package/dist/compiler/contract-compiler-diagnostic.d.ts +2 -0
- package/dist/compiler/contract.compiler.d.ts +11 -22
- package/dist/config/any-framework-config.d.ts +5 -26
- package/dist/config/config-diagnostic.d.ts +2 -0
- package/dist/config/config-layer.d.ts +6 -19
- package/dist/config/config.resolver.d.ts +6 -14
- package/dist/config/config.validator.d.ts +6 -3
- package/dist/config/define-fields.d.ts +6 -46
- package/dist/config/effective-fields.d.ts +6 -29
- package/dist/config/entrypoint.normalizer.d.ts +6 -18
- package/dist/config/framework-behaviors-config.d.ts +11 -10
- package/dist/config/framework-config.d.ts +15 -15
- package/dist/config/framework-fields-config.d.ts +14 -7
- package/dist/config/framework-restrictions-config.d.ts +41 -61
- package/dist/config/pipeline-config.d.ts +7 -17
- package/dist/contracts/capability.d.ts +13 -49
- package/dist/contracts/client-contract-structure.validator.d.ts +7 -53
- package/dist/contracts/contract-canonicalizer.d.ts +4 -6
- package/dist/contracts/contract-hash.d.ts +3 -2
- package/dist/contracts/contract-limits.d.ts +7 -1
- package/dist/contracts/contract-protocol.d.ts +7 -8
- package/dist/contracts/contract.d.ts +13 -4
- package/dist/contracts/enum-definition.d.ts +2 -0
- package/dist/contracts/field.d.ts +30 -167
- package/dist/contracts/identifier.d.ts +1 -16
- package/dist/contracts/lifecycle-trait.d.ts +4 -3
- package/dist/contracts/resource-operations.d.ts +2 -62
- package/dist/contracts/resource.d.ts +2 -0
- package/dist/contracts/scalar-value-type.d.ts +16 -47
- package/dist/contracts/scalar.d.ts +4 -3
- package/dist/contracts/transaction-capability.d.ts +2 -0
- package/dist/contracts/wire-scalar-format.d.ts +6 -21
- package/dist/framework/contract-view.d.ts +30 -113
- package/dist/framework/framework-construction.error.d.ts +6 -1
- package/dist/framework/framework.d.ts +31 -46
- package/dist/framework/framework.factory.d.ts +3 -17
- package/dist/framework/operation-facade.d.ts +3 -7
- package/dist/operations/operation-arguments.d.ts +52 -207
- package/dist/operations/operation-call.d.ts +13 -15
- package/dist/operations/operation-identity.d.ts +4 -2
- package/dist/operations/operation-result.d.ts +15 -61
- package/dist/operations/operation-validator-core.d.ts +5 -4
- package/dist/operations/operation-validator.d.ts +5 -7
- package/dist/operations/projection-scope.resolver.d.ts +0 -10
- package/dist/operations/validation-code.d.ts +5 -17
- package/dist/operations/write-scope.resolver.d.ts +3 -28
- package/dist/protocol/absent-route.responder.d.ts +23 -38
- package/dist/protocol/av-protocol.d.ts +2 -8
- package/dist/protocol/contract-document.responder.d.ts +5 -18
- package/dist/protocol/http-request.decoder.d.ts +12 -59
- package/dist/protocol/http-request.reader.d.ts +5 -5
- package/dist/protocol/http-response.encoder.d.ts +14 -20
- package/dist/protocol/http-status.table.d.ts +0 -8
- package/dist/protocol/index.d.ts +2 -7
- package/dist/protocol/operation-response.guard.d.ts +0 -15
- package/dist/protocol/protocol-failure.d.ts +8 -27
- package/dist/protocol/protocol-headers.d.ts +15 -42
- package/dist/protocol/protocol-surface.d.ts +0 -22
- package/dist/protocol/protocol.binder.d.ts +16 -26
- package/dist/protocol/protocol.handler.d.ts +15 -23
- package/dist/runtime/decimal.d.ts +5 -3
- package/dist/runtime/diagnostics-reporter.d.ts +14 -34
- package/dist/runtime/error-boundary.d.ts +6 -10
- package/dist/runtime/execution-options.d.ts +3 -7
- package/dist/runtime/field-behavior.d.ts +12 -19
- package/dist/runtime/framework-error.d.ts +2 -2
- package/dist/runtime/json-value.d.ts +7 -15
- package/dist/runtime/mutation-planner.d.ts +6 -12
- package/dist/runtime/operation-request.d.ts +7 -0
- package/dist/runtime/operation-response.d.ts +18 -23
- package/dist/runtime/operation-runtime.d.ts +12 -27
- package/dist/runtime/pipeline.d.ts +14 -29
- package/dist/runtime/referential-action.d.ts +1 -26
- package/dist/runtime/request-id.d.ts +3 -10
- package/dist/runtime/scalar-runtime.d.ts +12 -12
- package/dist/transactions/deferred-operation.d.ts +10 -21
- package/dist/transactions/operation-arguments-encoder.d.ts +1 -0
- package/dist/transactions/operation-fingerprint.d.ts +3 -1
- package/dist/transactions/transaction-envelope.d.ts +2 -4
- package/dist/transactions/transaction-integrity-error.d.ts +4 -15
- package/dist/transactions/transaction-plan-assembler.d.ts +1 -0
- package/dist/transactions/transaction-plan-validator.d.ts +3 -17
- package/dist/transactions/transaction-reference-resolver.d.ts +9 -12
- package/dist/transactions/transaction-reference.d.ts +23 -28
- package/dist/transactions/transaction-request.d.ts +3 -5
- package/dist/transactions/transaction-response.d.ts +5 -7
- package/dist/transactions/transaction-runtime.d.ts +3 -3
- package/dist/transactions/transaction-slot-path-error.d.ts +5 -15
- package/dist/transactions/transaction-slot-writer.d.ts +3 -13
- package/package.json +1 -1
|
@@ -5,9 +5,9 @@ import type { ContractLimits } from "../contracts/contract-limits.js";
|
|
|
5
5
|
/** Whether `resolveRecord` descends into a value: an object that is no array. */
|
|
6
6
|
type IsLayeredRecord<T> = [T] extends [readonly unknown[]] ? false : [T] extends [object] ? true : false;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* wins; when both sides are records
|
|
10
|
-
* scoped
|
|
8
|
+
* A root record with a scoped record layered over it: a key the scoped side
|
|
9
|
+
* states wins; when both sides are records they merge, recursively; otherwise
|
|
10
|
+
* the scoped value replaces the root one.
|
|
11
11
|
*/
|
|
12
12
|
type LayeredRecord<Root, Scoped> = {
|
|
13
13
|
readonly [K in keyof Root | keyof Scoped]: K extends keyof Scoped ? K extends keyof Root ? [IsLayeredRecord<Root[K]>, IsLayeredRecord<Scoped[K]>] extends [
|
|
@@ -24,19 +24,8 @@ type LayeredRecord<Root, Scoped> = {
|
|
|
24
24
|
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;
|
|
25
25
|
type LayeredBlocks<Root, Scoped> = [Root] extends [never] ? Scoped : [Scoped] extends [never] ? Root : LayeredRecord<Root, Scoped>;
|
|
26
26
|
/**
|
|
27
|
-
* One configuration block as a derived Contract is compiled from it
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* **Read by indexed access, deliberately not through `effective-fields.ts`'s
|
|
31
|
-
* `FieldsBlockOf`.** That reader (`Cfg extends { fields?: infer Block } ? Block
|
|
32
|
-
* extends AnyFieldsBlock ? … `) is right for a key set, but here it makes
|
|
33
|
-
* TypeScript's variance probe treat `Cfg` as irrelevant to this view, so
|
|
34
|
-
* `Framework<M, A>` and `Framework<M, B>` compare identical whatever their `fields`
|
|
35
|
-
* say — the collapse `framework.factory.test-d.ts`'s non-collapse rows exist to
|
|
36
|
-
* catch, and measured: substituting `FieldsBlockOf` here fails both of them. An
|
|
37
|
-
* indexed access is related only when its object types are, so the probe sees
|
|
38
|
-
* `Cfg`. The rows, not this comment, are the guard: the measurement is
|
|
39
|
-
* TypeScript's, and it can move.
|
|
27
|
+
* One configuration block as a derived Contract is compiled from it: the root
|
|
28
|
+
* `Key`, with layer `Layer`'s `Key` layered over it.
|
|
40
29
|
*/
|
|
41
30
|
type LayerBlock<Cfg, Layer extends RequestOrigin, Key extends "fields" | "restrictions"> = LayeredBlocks<LiteralRecord<(Cfg & {
|
|
42
31
|
readonly [K in Key]?: unknown;
|
|
@@ -51,14 +40,9 @@ type ConfiguredCapabilities<FieldConfig> = [FieldConfig] extends [never] ? Recor
|
|
|
51
40
|
readonly capabilities: infer Capabilities;
|
|
52
41
|
} ? NonNullable<Capabilities> : Record<never, never>;
|
|
53
42
|
/**
|
|
54
|
-
*
|
|
55
|
-
* `true` when neither states
|
|
56
|
-
*
|
|
57
|
-
* The override is the first, homomorphic part — mapped over the field's own
|
|
58
|
-
* members, so a member the model leaves optional stays optional rather than
|
|
59
|
-
* becoming a required `T | undefined` that no Contract admits. The other two parts
|
|
60
|
-
* only ADD keys the first does not have, so intersecting them can never narrow a
|
|
61
|
-
* member (the `true & false` failure is an intersection over a SHARED key).
|
|
43
|
+
* A field's capabilities with the configured ones applied: a configured member
|
|
44
|
+
* replaces the field's own, and `select` defaults to `true` when neither states
|
|
45
|
+
* it.
|
|
62
46
|
*/
|
|
63
47
|
type LayeredCapabilities<Own, Configured> = {
|
|
64
48
|
readonly [P in keyof Own]: P extends keyof Configured ? Configured[P] : Own[P];
|
|
@@ -68,28 +52,20 @@ type LayeredCapabilities<Own, Configured> = {
|
|
|
68
52
|
readonly select: true;
|
|
69
53
|
});
|
|
70
54
|
/**
|
|
71
|
-
*
|
|
72
|
-
* capabilities
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* **A field the layer does not configure, and whose capabilities state `select`,
|
|
76
|
-
* is the model's own field type** — rule 3 changes nothing about it, so the view
|
|
77
|
-
* re-states nothing. That is every field of a typical model but the handful a
|
|
78
|
-
* configuration names, and it is what keeps the view's cost proportional to the
|
|
79
|
-
* configuration rather than to the schema: every reader of a field (each
|
|
80
|
-
* capability question, the `Contract` check a surface asks once) reads the model's
|
|
81
|
-
* literal directly instead of a mapped copy of it.
|
|
55
|
+
* A discovered field as the view sees it: every structural fact from the model,
|
|
56
|
+
* its capabilities with the configuration applied. A relation is the model's
|
|
57
|
+
* own.
|
|
82
58
|
*/
|
|
83
59
|
type LayeredModelField<Field, FieldConfig> = Field extends {
|
|
84
60
|
readonly kind: "scalar";
|
|
85
61
|
} ? [FieldConfig] extends [never] ? Field extends {
|
|
86
62
|
readonly capabilities: infer Capabilities;
|
|
87
63
|
} ? "select" extends keyof Capabilities ? Field : ConfiguredModelField<Field, FieldConfig> : ConfiguredModelField<Field, FieldConfig> : ConfiguredModelField<Field, FieldConfig> : Field;
|
|
88
|
-
/** A
|
|
64
|
+
/** A discovered scalar with its configured capabilities applied, member by member. */
|
|
89
65
|
type ConfiguredModelField<Field, FieldConfig> = {
|
|
90
66
|
readonly [P in keyof Field]: P extends "capabilities" ? LayeredCapabilities<Field[P], ConfiguredCapabilities<FieldConfig>> : Field[P];
|
|
91
67
|
};
|
|
92
|
-
/**
|
|
68
|
+
/** A scalar the configuration adds, exactly as the configuration states it. */
|
|
93
69
|
type AddedField<FieldConfig> = {
|
|
94
70
|
readonly kind: "scalar";
|
|
95
71
|
readonly type: FieldConfig extends {
|
|
@@ -110,86 +86,42 @@ type AddedFieldKey<ModelFields, ResourceConfig> = [ResourceConfig] extends [
|
|
|
110
86
|
never
|
|
111
87
|
] ? never : Exclude<Extract<keyof ResourceConfig, string>, keyof ModelFields>;
|
|
112
88
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* the thing stays in the view and the validation layer answers it.
|
|
89
|
+
* Whether a restriction entry hides what it names: only a literal `hidden: true`
|
|
90
|
+
* does; `false` restores it.
|
|
116
91
|
*/
|
|
117
92
|
type IsHidden<Restriction> = [Restriction] extends [never] ? false : Restriction extends {
|
|
118
93
|
readonly hidden: true;
|
|
119
94
|
} ? true : false;
|
|
120
95
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* **A key set, computed once per block, rather than a per-key test in an `as`
|
|
125
|
-
* clause.** A remapped mapped type (`[K in … as …]`) re-evaluates its `as` for
|
|
126
|
-
* every key whenever any of its keys or members is asked for; a mapped type over
|
|
127
|
-
* `Exclude<keys, HiddenKey<…>>` reads this set once. Measured on the artifact's
|
|
128
|
-
* shape: ≈2,300 instantiations per client-origin call, and the remapped form was
|
|
129
|
-
* the costliest single term of a client-layer surface.
|
|
96
|
+
* The keys a restrictions block hides, or `never` for a view that reads no
|
|
97
|
+
* restrictions.
|
|
130
98
|
*/
|
|
131
99
|
type HiddenKey<Restrictions> = [Restrictions] extends [never] ? never : {
|
|
132
100
|
[K in keyof Restrictions]-?: IsHidden<EntryOf<Restrictions, K>> extends true ? K : never;
|
|
133
101
|
}[keyof Restrictions];
|
|
134
102
|
/**
|
|
135
|
-
* A Resource's fields in the view: the model's
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* **One mapped type, with no conditional around it and no `as` clause.** Every
|
|
139
|
-
* branch here is one more structure TypeScript's variance probe of `Framework`
|
|
140
|
-
* walks — paid by every program that compares two `Framework` types
|
|
141
|
-
* (`Awaited<Promise<Framework<…>>>` is one); a separate branch per case measured
|
|
142
|
-
* at +9,000 instantiations there, and naming the field rule below as an alias at
|
|
143
|
-
* +2,300.
|
|
103
|
+
* A Resource's fields in the view: the model's and the ones the configuration
|
|
104
|
+
* adds, less the ones this view's restrictions hide.
|
|
144
105
|
*/
|
|
145
106
|
type LayeredFields<ModelFields, ResourceConfig, FieldRestrictions> = {
|
|
146
107
|
readonly [F in Exclude<keyof ModelFields | AddedFieldKey<ModelFields, ResourceConfig>, HiddenKey<FieldRestrictions>>]: F extends keyof ModelFields ? LayeredModelField<ModelFields[F], EntryOf<ResourceConfig, F>> : AddedField<EntryOf<ResourceConfig, F>>;
|
|
147
108
|
};
|
|
148
|
-
/**
|
|
149
|
-
* One Resource in the view: the model's own, with its fields layered.
|
|
150
|
-
*
|
|
151
|
-
* **Declared invariant (`in out`) rather than measured.** Comparing two
|
|
152
|
-
* `Framework` types — `Awaited<Promise<Framework<…>>>` does, and so does handing
|
|
153
|
-
* a typed Framework to a host that holds the untyped one — makes TypeScript
|
|
154
|
-
* measure `Framework`'s variance by walking every alias under it with marker
|
|
155
|
-
* types; measured, this alias and the field machinery under it were ≈22,000 of
|
|
156
|
-
* that walk's ≈29,000 instantiations, paid once by every program. Its measured
|
|
157
|
-
* answer was already invariant in all three parameters, so the declaration
|
|
158
|
-
* states the same answer without the walk.
|
|
159
|
-
*
|
|
160
|
-
* **Only here, deliberately.** The measurement also marked `Framework`'s model
|
|
161
|
-
* parameter *unreliable*, and that mark is what lets a typed `Framework<M, Cfg>`
|
|
162
|
-
* still be assigned to the untyped `Framework` (TypeScript then falls back to
|
|
163
|
-
* comparing structure, where every surface of the untyped Framework is opaque).
|
|
164
|
-
* Declaring the variance any higher — on `DerivedContractView` itself — removes
|
|
165
|
-
* the mark, and `transaction-runtime.spec.ts`'s `Promise<Framework>` stops
|
|
166
|
-
* compiling.
|
|
167
|
-
*/
|
|
109
|
+
/** One Resource in the view: the model's own, with its fields layered. */
|
|
168
110
|
type LayeredResource<in out Resource, in out ResourceConfig, in out ResourceRestrictions> = {
|
|
169
111
|
readonly [P in keyof Resource]: P extends "fields" ? LayeredFields<Resource[P], ResourceConfig, EntryOf<ResourceRestrictions, "fields">> : Resource[P];
|
|
170
112
|
};
|
|
171
113
|
/**
|
|
172
|
-
* `Restrictions` is the layered `restrictions` block
|
|
173
|
-
*
|
|
114
|
+
* The Resources in the view. `Restrictions` is the layered `restrictions` block
|
|
115
|
+
* whose `hidden` entries this view applies, or `never` for a view that applies
|
|
116
|
+
* none.
|
|
174
117
|
*/
|
|
175
118
|
type LayeredResources<Resources, Block, Restrictions> = {
|
|
176
119
|
readonly [R in Exclude<keyof Resources, HiddenKey<Restrictions>>]: LayeredResource<Resources[R], EntryOf<Block, R>, EntryOf<Restrictions, R>>;
|
|
177
120
|
};
|
|
178
121
|
/**
|
|
179
|
-
* One derived Contract's
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* **Keyed on the two blocks it reads, never on the configuration.** TypeScript
|
|
184
|
-
* keys an instantiated type on the arguments of the alias it is reached through,
|
|
185
|
-
* so a view instantiated through an alias over `Cfg` is a distinct type for every
|
|
186
|
-
* configuration, and two `Framework`s whose configurations differ only in what
|
|
187
|
-
* the view never reads — a pipeline, a diagnostics sink, the other layer — carry
|
|
188
|
-
* four distinct surfaces that only a structural walk of every operation of every
|
|
189
|
-
* Resource can prove equal. Measured on `transaction-plan-validator.spec.ts`,
|
|
190
|
-
* where two such Frameworks share one array literal: ≈95,000 instantiations for
|
|
191
|
-
* that one line, ≈4,000 keyed on blocks. The two named views below reach this
|
|
192
|
-
* type through a conditional for that reason (see {@link ApplicationContractView}).
|
|
122
|
+
* One derived Contract's type: the model, with a layer's `fields` block applied
|
|
123
|
+
* and, when `Restrictions` is a block rather than `never`, its hidden entries
|
|
124
|
+
* removed.
|
|
193
125
|
*/
|
|
194
126
|
type DerivedContractView<M extends AdapterModel, FieldsBlock, Restrictions> = {
|
|
195
127
|
readonly scalars: M["scalars"];
|
|
@@ -200,28 +132,13 @@ type DerivedContractView<M extends AdapterModel, FieldsBlock, Restrictions> = {
|
|
|
200
132
|
};
|
|
201
133
|
/**
|
|
202
134
|
* The Application Contract's type, derived from the adapter model and the
|
|
203
|
-
* configuration
|
|
204
|
-
*
|
|
205
|
-
* It is fed to the same `OperationArgumentsFor` and `OperationResultFor` a
|
|
206
|
-
* generated client feeds its ClientContract literal to: one derivation, two
|
|
207
|
-
* sources of a Contract type. `limits` is the type every Contract carries; its
|
|
208
|
-
* values are resolved at construction and no derivation reads them.
|
|
209
|
-
*
|
|
210
|
-
* The conditional is always true. It is there so that the view this resolves to is
|
|
211
|
-
* `DerivedContractView` keyed on its blocks: a conditional's resolved branch is
|
|
212
|
-
* the branch's own type, while a plain alias over `Cfg` would key the instantiated
|
|
213
|
-
* view on the whole configuration (see `DerivedContractView`).
|
|
135
|
+
* configuration.
|
|
214
136
|
*/
|
|
215
137
|
export type ApplicationContractView<M extends AdapterModel, Cfg = AnyFrameworkConfig> = [Cfg] extends [unknown] ? DerivedContractView<M, LayerBlock<Cfg, "application", "fields">, never> : never;
|
|
216
138
|
/**
|
|
217
|
-
* The Client Contract's type,
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* `framework.clientTx`).
|
|
221
|
-
*
|
|
222
|
-
* Not exported from the package; a generated client reads the deployed
|
|
223
|
-
* ClientContract literal itself. Resolved through a conditional for the reason
|
|
224
|
-
* {@link ApplicationContractView} gives.
|
|
139
|
+
* The Client Contract's type, derived from the adapter model and the
|
|
140
|
+
* configuration: what the client layer hides is absent. It types
|
|
141
|
+
* `framework.client` and `framework.clientTx`.
|
|
225
142
|
*/
|
|
226
143
|
export type ClientContractView<M extends AdapterModel, Cfg = AnyFrameworkConfig> = [Cfg] extends [unknown] ? DerivedContractView<M, LayerBlock<Cfg, "client", "fields">, LayerBlock<Cfg, "client", "restrictions">> : never;
|
|
227
144
|
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { AdapterDiscoveryDiagnostic } from "../adapters/adapter-discovery-diagnostic.js";
|
|
2
2
|
import type { ContractCompilerDiagnostic } from "../compiler/contract-compiler-diagnostic.js";
|
|
3
3
|
import type { ConfigDiagnostic } from "../config/config-diagnostic.js";
|
|
4
|
+
/** The construction step that failed. */
|
|
4
5
|
export type FrameworkConstructionStage = "configuration" | "discovery" | "contract-compilation";
|
|
6
|
+
/** One problem reported by {@link FrameworkConstructionError}. */
|
|
5
7
|
export type FrameworkConstructionDiagnostic = ConfigDiagnostic | AdapterDiscoveryDiagnostic | ContractCompilerDiagnostic;
|
|
6
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Thrown by {@link createFramework} when construction fails: `stage` says
|
|
10
|
+
* where, and `diagnostics` lists every problem found there.
|
|
11
|
+
*/
|
|
7
12
|
export declare class FrameworkConstructionError extends Error {
|
|
8
13
|
readonly stage: FrameworkConstructionStage;
|
|
9
14
|
readonly diagnostics: readonly FrameworkConstructionDiagnostic[];
|
|
@@ -7,36 +7,31 @@ import type { TransactionRunner } from "../transactions/deferred-operation.js";
|
|
|
7
7
|
import type { FrameworkTransactionRequest } from "../transactions/transaction-request.js";
|
|
8
8
|
import type { TransactionResponse } from "../transactions/transaction-response.js";
|
|
9
9
|
import type { ApplicationOperations, ApplicationTransactionBuilders, ClientOperations, ClientTransactionBuilders } from "./operation-facade.js";
|
|
10
|
+
/**
|
|
11
|
+
* One Aventara instance, as returned by {@link createFramework}: its compiled
|
|
12
|
+
* Contracts, typed in-process operations, transaction builders and the
|
|
13
|
+
* untyped `execute` entry a transport calls.
|
|
14
|
+
*/
|
|
10
15
|
export type Framework<M extends AdapterModel = AdapterModel, Cfg = AnyFrameworkConfig> = {
|
|
11
16
|
readonly entrypoint: string;
|
|
12
17
|
readonly contracts: FrameworkContracts;
|
|
13
18
|
/**
|
|
14
|
-
*
|
|
15
|
-
* `framework.application.<resource>.<family>.<variant>(args)`.
|
|
19
|
+
* Typed in-process operations under the Application Contract:
|
|
20
|
+
* `framework.application.<resource>.<family>.<variant>(args, options?)`.
|
|
16
21
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* `Framework` types. Each call is an application-scope request to {@link execute}
|
|
21
|
-
* — the same totality guard and validation layer — which still refuses what a
|
|
22
|
-
* restriction removed, since restrictions stay invisible to the types.
|
|
23
|
-
*
|
|
24
|
-
* A call's optional second argument is its `ExecutionOptions`: a supplied
|
|
25
|
-
* `requestId` is the request's, in every pipeline context and diagnostic; omitted
|
|
26
|
-
* or empty, a fresh id is minted per call.
|
|
22
|
+
* A call is validated like any other request, so it still refuses what a
|
|
23
|
+
* restriction removed. The optional second argument is
|
|
24
|
+
* {@link ExecutionOptions}.
|
|
27
25
|
*/
|
|
28
26
|
readonly application: ApplicationOperations<M, Cfg>;
|
|
29
27
|
/**
|
|
30
|
-
* The same
|
|
31
|
-
* `framework.client.<resource>.<family>.<variant>(args)`.
|
|
28
|
+
* The same operations under ClientContract rules:
|
|
29
|
+
* `framework.client.<resource>.<family>.<variant>(args, options?)`.
|
|
32
30
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* protocol identity: the Client Contract, the client pipelines, and the same
|
|
38
|
-
* validation layer, which answers whatever a free-flow body says. Takes the
|
|
39
|
-
* same `ExecutionOptions` second argument as {@link application}.
|
|
31
|
+
* What the client layer hides is absent, and arguments are read in the wire
|
|
32
|
+
* forms a decoded request body carries, so a transport can pass `req.body` as
|
|
33
|
+
* it is. Each call runs the client pipelines and the same validation as a
|
|
34
|
+
* remote request.
|
|
40
35
|
*/
|
|
41
36
|
readonly client: ClientOperations<M, Cfg>;
|
|
42
37
|
/**
|
|
@@ -49,41 +44,31 @@ export type Framework<M extends AdapterModel = AdapterModel, Cfg = AnyFrameworkC
|
|
|
49
44
|
*/
|
|
50
45
|
readonly appTx: ApplicationTransactionBuilders<M, Cfg>;
|
|
51
46
|
/**
|
|
52
|
-
* The same builders under ClientContract rules
|
|
53
|
-
*
|
|
54
|
-
*
|
|
47
|
+
* The same builders under ClientContract rules, taking wire-form arguments.
|
|
48
|
+
* Client and application handles may share one {@link transaction}; each step
|
|
49
|
+
* runs under its own handle's rules.
|
|
55
50
|
*/
|
|
56
51
|
readonly clientTx: ClientTransactionBuilders<M, Cfg>;
|
|
57
52
|
execute(request: FrameworkOperationRequest): Promise<OperationResponse>;
|
|
58
53
|
/**
|
|
59
|
-
* Validates a whole transaction plan, then runs its operations
|
|
60
|
-
*
|
|
61
|
-
* operation's final data in plan order, the failing operation's own code
|
|
62
|
-
* `cause.operation` after rollback, or `A3002` when the transaction
|
|
63
|
-
* fails.
|
|
54
|
+
* Validates a whole transaction plan, then runs its operations one after
|
|
55
|
+
* another inside one Adapter transaction. Answers `A1009` with each
|
|
56
|
+
* operation's final data in plan order, the failing operation's own code
|
|
57
|
+
* with `cause.operation` after rollback, or `A3002` when the transaction
|
|
58
|
+
* itself fails. Never rejects.
|
|
64
59
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* Adapter must reject with the exact value its transaction callback threw, by
|
|
68
|
-
* identity.
|
|
60
|
+
* Guards, pipes, hooks and interceptors run while the transaction is open, so
|
|
61
|
+
* they should not perform network I/O or other slow work.
|
|
69
62
|
*/
|
|
70
63
|
executeTransaction(request: FrameworkTransactionRequest): Promise<TransactionResponse>;
|
|
71
64
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* step, and runs the resulting passive plan through the same validation layer and
|
|
76
|
-
* transaction runtime as {@link executeTransaction} — each step under its own
|
|
77
|
-
* handle's origin, its own layer's Contract and pipelines, inside one Adapter
|
|
78
|
-
* transaction. The committed response is typed per position.
|
|
65
|
+
* Runs handles from `appTx`/`clientTx` as one transaction:
|
|
66
|
+
* `framework.transaction([h1, h2, …], options?)`. Resolves the committed
|
|
67
|
+
* response, typed per position, or the failure response. Never rejects.
|
|
79
68
|
*
|
|
80
69
|
* Refused before anything runs: an entry that is not one of this Framework's
|
|
81
|
-
* handles, or the same handle twice (`A2004`/`V1001`); a `$ref` to a handle
|
|
82
|
-
* the list (`A2007`/`V1010`).
|
|
83
|
-
*
|
|
84
|
-
* The optional second argument is the run's `ExecutionOptions`: its `requestId` is
|
|
85
|
-
* every step's, under either origin; omitted or empty, one id is minted for the
|
|
86
|
-
* run. Handles take no options — a handle is not a request.
|
|
70
|
+
* handles, or the same handle twice (`A2004`/`V1001`); a `$ref` to a handle
|
|
71
|
+
* not in the list (`A2007`/`V1010`).
|
|
87
72
|
*/
|
|
88
73
|
readonly transaction: TransactionRunner;
|
|
89
74
|
};
|
|
@@ -3,23 +3,9 @@ import type { AnyFrameworkConfig } from "../config/any-framework-config.js";
|
|
|
3
3
|
import type { FrameworkConfig } from "../config/framework-config.js";
|
|
4
4
|
import type { Framework } from "./framework.js";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Creates a Framework: validates the configuration, reads the adapter's
|
|
7
|
+
* model and compiles the Contracts.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* the obvious `FrameworkConfig<M, Cfg>`. `Cfg` has to appear somewhere the
|
|
11
|
-
* compiler actually infers from; inside `FrameworkConfig`'s body it only ever
|
|
12
|
-
* reaches non-inference positions, so it would fall back to its
|
|
13
|
-
* `AnyFrameworkConfig` default with no error reported anywhere, and every
|
|
14
|
-
* narrowing keyed on the authored configuration would quietly widen. The
|
|
15
|
-
* intersection puts `Cfg` directly against the argument type.
|
|
16
|
-
*
|
|
17
|
-
* `Cfg` is a `const` type parameter for the same reason: it stands for the
|
|
18
|
-
* configuration *as authored*. Without `const`, inferring `Cfg` from an
|
|
19
|
-
* inline configuration literal widens its scalar references away from their
|
|
20
|
-
* literal types, and the widened `Cfg` then loses to the intersection's own
|
|
21
|
-
* `FrameworkConfig` half — a call site that compiles today stops compiling.
|
|
22
|
-
* A configuration passed as an already-annotated variable is unaffected
|
|
23
|
-
* either way.
|
|
9
|
+
* @throws {@link FrameworkConstructionError} when any of those steps fails.
|
|
24
10
|
*/
|
|
25
11
|
export declare function createFramework<M extends AdapterModel, const Cfg = AnyFrameworkConfig>(config: Cfg & FrameworkConfig<M, Cfg>): Promise<Framework<M, Cfg>>;
|
|
@@ -9,13 +9,9 @@ import type { FrameworkOperationRequest } from "../runtime/operation-request.js"
|
|
|
9
9
|
import type { OperationResponse } from "../runtime/operation-response.js";
|
|
10
10
|
import type { ApplicationContractView, ClientContractView } from "./contract-view.js";
|
|
11
11
|
/**
|
|
12
|
-
* A model whose Resource names are not literal — the abstract `AdapterModel`
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `execute`. It is also what keeps a typed `Framework<M, Cfg>` assignable to
|
|
16
|
-
* `Framework` cheaply: deriving every argument and result over a `string`-keyed
|
|
17
|
-
* Contract, for all sixteen operations, measured at ≈250,000 instantiations for
|
|
18
|
-
* nothing a caller could use.
|
|
12
|
+
* A model whose Resource names are not literal — the abstract `AdapterModel` behind
|
|
13
|
+
* the default `Framework` — has no Contract to type a call against, so a surface over
|
|
14
|
+
* it is typed as the opaque object it is, and such a caller uses `execute`.
|
|
19
15
|
*/
|
|
20
16
|
type OpaqueSurface = {
|
|
21
17
|
readonly [resource: string]: unknown;
|