@aventara/core 1.0.0-rc.1 → 1.0.0-rc.3
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 +341 -1
- package/ERRORS.md +142 -0
- package/README.md +24 -1
- package/dist/adapters/adapter-discovery-diagnostic.guidance.d.ts +6 -0
- package/dist/adapters/adapter-discovery-diagnostic.guidance.js +7 -0
- package/dist/adapters/adapter-field.d.ts +14 -0
- package/dist/adapters/adapter-model.d.ts +9 -0
- package/dist/adapters/adapter.interface.d.ts +10 -0
- package/dist/compiler/contract-compiler-diagnostic.guidance.d.ts +6 -0
- package/dist/compiler/contract-compiler-diagnostic.guidance.js +97 -0
- package/dist/compiler/contract.compiler.js +94 -6
- package/dist/config/computed-fields.d.ts +62 -0
- package/dist/config/computed-fields.js +80 -0
- package/dist/config/config-diagnostic.guidance.d.ts +6 -0
- package/dist/config/config-diagnostic.guidance.js +32 -0
- package/dist/config/define-resource.d.ts +1 -1
- package/dist/config/exact-framework-config.d.ts +50 -20
- package/dist/config/field-compute.resolver.d.ts +2 -0
- package/dist/config/field-compute.resolver.js +8 -0
- package/dist/config/framework-config.d.ts +7 -6
- package/dist/config/framework-resources-config.d.ts +18 -12
- package/dist/config/pipeline-config.d.ts +4 -4
- package/dist/contracts/capability.d.ts +10 -1
- package/dist/contracts/capability.js +2 -0
- package/dist/contracts/client-contract-structure.validator.d.ts +65 -35
- package/dist/contracts/client-contract-structure.validator.js +4 -2
- package/dist/contracts/contract-canonicalizer.d.ts +7 -0
- package/dist/contracts/contract-canonicalizer.js +18 -4
- package/dist/contracts/field.d.ts +30 -1
- package/dist/framework/contract-view.d.ts +4 -4
- package/dist/framework/framework-construction.error.d.ts +12 -3
- package/dist/framework/framework-construction.error.js +5 -1
- package/dist/framework/framework.factory.d.ts +1 -1
- package/dist/framework/framework.factory.js +9 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +1 -0
- package/dist/operations/database-refusal.d.ts +51 -0
- package/dist/operations/database-refusal.js +45 -0
- package/dist/operations/operation-arguments.d.ts +102 -31
- package/dist/operations/operation-validator-core.js +145 -36
- package/dist/operations/validation-code.guidance.d.ts +6 -0
- package/dist/operations/validation-code.guidance.js +90 -0
- package/dist/operations/write-scope.resolver.d.ts +4 -0
- package/dist/operations/write-scope.resolver.js +2 -0
- package/dist/protocol/protocol.handler.js +55 -16
- package/dist/runtime/caller-data.copier.d.ts +17 -0
- package/dist/runtime/caller-data.copier.js +18 -1
- package/dist/runtime/caller-data.door.d.ts +11 -5
- package/dist/runtime/computed-read-runtime.js +15 -2
- package/dist/runtime/computed-value.error.d.ts +3 -2
- package/dist/runtime/computed-value.error.js +3 -2
- package/dist/runtime/create-requirement.d.ts +41 -5
- package/dist/runtime/create-requirement.js +137 -20
- package/dist/runtime/diagnostics-reporter.d.ts +2 -1
- package/dist/runtime/error-boundary.js +4 -0
- package/dist/runtime/error-guidance.d.ts +12 -0
- package/dist/runtime/error-guidance.js +1 -0
- package/dist/runtime/error.catalog.d.ts +49 -0
- package/dist/runtime/error.catalog.js +49 -0
- package/dist/runtime/field-stage.runtime.d.ts +2 -0
- package/dist/runtime/field-stage.runtime.js +8 -4
- package/dist/runtime/field-validator.runtime.d.ts +18 -1
- package/dist/runtime/field-validator.runtime.js +47 -8
- package/dist/runtime/json-value.d.ts +10 -5
- package/dist/runtime/level-lifecycle.runtime.d.ts +2 -2
- package/dist/runtime/level-lifecycle.runtime.js +2 -5
- package/dist/runtime/mutation-planner.js +3 -14
- package/dist/runtime/operation-code.guidance.d.ts +6 -0
- package/dist/runtime/operation-code.guidance.js +167 -0
- package/dist/runtime/operation-runtime.d.ts +20 -6
- package/dist/runtime/operation-runtime.js +82 -36
- package/dist/runtime/owned-execution.registry.d.ts +12 -2
- package/dist/runtime/pipe-output.validator.d.ts +10 -0
- package/dist/runtime/pipe-output.validator.js +4 -2
- package/dist/runtime/pipeline.d.ts +35 -8
- package/dist/runtime/readonly-value.d.ts +14 -3
- package/dist/runtime/readonly-value.js +10 -1
- package/dist/runtime/scalar-runtime.d.ts +5 -1
- package/dist/runtime/scalar-runtime.js +86 -16
- package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
- package/dist/runtime/unsent-value.normalizer.js +128 -0
- package/dist/transactions/operation-fingerprint.js +2 -2
- package/dist/transactions/sql-statement.d.ts +8 -0
- package/dist/transactions/sql-statement.validator.js +36 -3
- package/dist/transactions/transaction-plan-assembler.d.ts +1 -1
- package/dist/transactions/transaction-plan-assembler.js +33 -10
- package/dist/transactions/transaction-plan-validator.d.ts +16 -0
- package/dist/transactions/transaction-plan-validator.js +27 -1
- package/dist/transactions/transaction-reference-validator.d.ts +42 -0
- package/dist/transactions/transaction-reference-validator.js +82 -56
- package/dist/transactions/transaction-reference.js +5 -0
- package/dist/transactions/transaction-runtime.js +47 -22
- package/dist/transactions/transaction-stage.runtime.d.ts +2 -1
- package/dist/transactions/transaction-stage.runtime.js +7 -4
- package/package.json +4 -3
|
@@ -103,9 +103,11 @@ type TokenOf<Member> = Member extends {
|
|
|
103
103
|
} ? {
|
|
104
104
|
[K in keyof Member]: K extends "scopes" ? never : Member[K] extends readonly (infer Token)[] ? Token : never;
|
|
105
105
|
}[keyof Member] : Member extends readonly (infer Token)[] ? Token : never;
|
|
106
|
+
/** The capability members an exemption never names. */
|
|
107
|
+
type AdapterStatedMember = "nestedWriteFilter" | "filterModes" | "pathFilterModes";
|
|
106
108
|
/** A field's exemption against its capabilities: their names, and each one's tokens. */
|
|
107
|
-
type CapabilityExemptionSchema<Caps> = ListOf<Exclude<keyof Caps,
|
|
108
|
-
readonly [K in Exclude<keyof Caps,
|
|
109
|
+
type CapabilityExemptionSchema<Caps> = ListOf<Exclude<keyof Caps, AdapterStatedMember>> & {
|
|
110
|
+
readonly [K in Exclude<keyof Caps, AdapterStatedMember>]-?: ListOf<TokenOf<NonNullable<Caps[K]>>>;
|
|
109
111
|
};
|
|
110
112
|
type FieldExemptionSchema<M extends AvAdapterModel, R extends AvConfigResourceKey<M>, F> = F extends AvAdapterFieldKey<M, R> ? M["resources"][R]["fields"][F] extends {
|
|
111
113
|
readonly kind: "relation";
|
|
@@ -131,33 +133,58 @@ type ExemptionsSchema<M extends AvAdapterModel, Cfg> = {
|
|
|
131
133
|
};
|
|
132
134
|
};
|
|
133
135
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
declare const refusal: unique symbol;
|
|
137
|
+
/** What a level refuses an unknown key for: `layer` cannot expose it, `parent` hid it, under `at`. */
|
|
138
|
+
type Refusal<Layer extends string, Parent extends string, At extends string> = {
|
|
139
|
+
readonly [refusal]: {
|
|
140
|
+
readonly layer: Layer;
|
|
141
|
+
readonly parent: Parent;
|
|
142
|
+
readonly at: At;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
/** The sentence a refused key `K` holding `Value` is typed as; `never` for an entry written `false`. */
|
|
146
|
+
type RefusalOf<Info, K, Value> = [Value] extends [false] ? never : Info extends {
|
|
147
|
+
readonly layer: infer Layer extends string;
|
|
148
|
+
readonly parent: infer Parent extends string;
|
|
149
|
+
readonly at: infer At extends string;
|
|
150
|
+
} ? Value extends readonly unknown[] ? {
|
|
151
|
+
readonly [S in `Error: ${Layer} cannot expose '${At}${K & string}': hidden by ${Parent}`]: true;
|
|
152
|
+
} : readonly [
|
|
153
|
+
`Error: ${Layer} cannot expose '${At}${K & string}': hidden by ${Parent}`
|
|
154
|
+
] : never;
|
|
155
|
+
/** A Pick layer's operations exemption, a family or variant its parent hid refused by name. */
|
|
156
|
+
type PickOperationsSchema<Ops, Layer extends string, Parent extends string, R extends string> = ListOf<keyof Ops> & {
|
|
157
|
+
readonly [F in keyof Ops]-?: ListOf<keyof NonNullable<Ops[F]>> & {
|
|
158
|
+
readonly [V in keyof NonNullable<Ops[F]>]: Leaf;
|
|
159
|
+
} & Refusal<Layer, Parent, `${R}.${F & string}.`>;
|
|
160
|
+
} & Refusal<Layer, Parent, `${R}.`>;
|
|
161
|
+
/** The fields of one Resource of a view. */
|
|
162
|
+
type ViewFields<Resource> = Resource extends {
|
|
163
|
+
readonly fields: infer Fields;
|
|
164
|
+
} ? Fields : never;
|
|
165
|
+
/** A Pick layer's exemptions, against its parent's view. */
|
|
166
|
+
type PickExemptionsSchema<Resources, Layer extends string, Parent extends string> = {
|
|
136
167
|
readonly resources: {
|
|
137
168
|
readonly [R in keyof Resources]: {
|
|
138
|
-
readonly operations:
|
|
169
|
+
readonly operations: PickOperationsSchema<Resources[R] extends {
|
|
139
170
|
readonly operations: infer Ops;
|
|
140
|
-
} ? Ops : never>;
|
|
171
|
+
} ? Ops : never, Layer, Parent, R & string>;
|
|
141
172
|
readonly fields: {
|
|
142
|
-
readonly [F in keyof
|
|
143
|
-
readonly fields: infer Fields;
|
|
144
|
-
} ? Fields : never)]: CapabilityExemptionSchema<(Resources[R] extends {
|
|
145
|
-
readonly fields: infer Fields;
|
|
146
|
-
} ? Fields : never)[F] extends {
|
|
173
|
+
readonly [F in keyof ViewFields<Resources[R]>]: CapabilityExemptionSchema<ViewFields<Resources[R]>[F] extends {
|
|
147
174
|
readonly capabilities: infer Caps;
|
|
148
|
-
} ? Caps : never
|
|
149
|
-
}
|
|
175
|
+
} ? Caps : never> & Refusal<Layer, Parent, `${R & string}.${F & string}.`>;
|
|
176
|
+
} & Refusal<Layer, Parent, `${R & string}.`>;
|
|
150
177
|
};
|
|
151
|
-
}
|
|
178
|
+
} & Refusal<Layer, Parent, "">;
|
|
152
179
|
};
|
|
153
180
|
/** A layer's own configuration: `application`, `client` or `agent`. */
|
|
154
181
|
type OverlayOf<Cfg, Layer extends "application" | "client" | "agent"> = (Cfg & {
|
|
155
182
|
readonly [L in Layer]?: unknown;
|
|
156
183
|
})[Layer];
|
|
157
184
|
/** An overlay's exemptions schema, by the overlay's own `exposed`. */
|
|
158
|
-
type OverlayExemptionsSchema<M extends AvAdapterModel, Cfg, Overlay> = Overlay extends {
|
|
185
|
+
type OverlayExemptionsSchema<M extends AvAdapterModel, Cfg, Overlay, Layer extends "application" | "client"> = Overlay extends {
|
|
159
186
|
readonly exposed: false;
|
|
160
|
-
} ? PickExemptionsSchema<RootViewResources<M, Cfg
|
|
187
|
+
} ? PickExemptionsSchema<RootViewResources<M, Cfg>, Layer, "root"> : ExemptionsSchema<M, Cfg>;
|
|
161
188
|
type LayerKeysSchema = {
|
|
162
189
|
readonly exposed: Leaf;
|
|
163
190
|
readonly transactionsStyle: Leaf;
|
|
@@ -183,7 +210,7 @@ type OverlaySchema<M extends AvAdapterModel, Cfg, Layer extends "application" |
|
|
|
183
210
|
readonly resources: {
|
|
184
211
|
readonly [R in AvConfigResourceKey<M>]: ResourceSchema<M, R, FieldsSchema<M, R, "overlay", AvEffectiveFieldKey<M, Cfg, R>>>;
|
|
185
212
|
};
|
|
186
|
-
readonly exemptions: OverlayExemptionsSchema<M, Cfg, OverlayOf<Cfg, Layer
|
|
213
|
+
readonly exemptions: OverlayExemptionsSchema<M, Cfg, OverlayOf<Cfg, Layer>, Layer>;
|
|
187
214
|
};
|
|
188
215
|
type McpSchema = {
|
|
189
216
|
readonly path: Leaf;
|
|
@@ -197,7 +224,7 @@ type AgentParentOf<Cfg> = OverlayOf<Cfg, "agent"> extends {
|
|
|
197
224
|
readonly extends: infer Parent;
|
|
198
225
|
} ? Parent : "client";
|
|
199
226
|
/** A Pick agent's exemptions, against the view of the layer it extends. */
|
|
200
|
-
type AgentPickExemptionsSchema<M extends AvAdapterModel, Cfg, Parent> = Parent extends "application" | "client" ? [Parent] extends ["application"] | ["client"] ? PickExemptionsSchema<OverlayViewResources<M, Cfg, Parent
|
|
227
|
+
type AgentPickExemptionsSchema<M extends AvAdapterModel, Cfg, Parent> = Parent extends "application" | "client" ? [Parent] extends ["application"] | ["client"] ? PickExemptionsSchema<OverlayViewResources<M, Cfg, Parent>, "agent", Parent> : PickExemptionsSchema<RootViewResources<M, Cfg>, "agent", "root"> : PickExemptionsSchema<RootViewResources<M, Cfg>, "agent", "root">;
|
|
201
228
|
type AgentSchema<M extends AvAdapterModel, Cfg> = LayerKeysSchema & {
|
|
202
229
|
readonly extends: Leaf;
|
|
203
230
|
readonly resources: {
|
|
@@ -219,9 +246,12 @@ type RootSchema<M extends AvAdapterModel, Cfg> = LayerKeysSchema & {
|
|
|
219
246
|
readonly client: OverlaySchema<M, Cfg, "client">;
|
|
220
247
|
readonly agent: AgentSchema<M, Cfg>;
|
|
221
248
|
};
|
|
222
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* `V` with every key schema `S` lacks mapped to `never`, or to the sentence a
|
|
251
|
+
* refusing level states; every leaf `unknown`.
|
|
252
|
+
*/
|
|
223
253
|
type Exact<S, V> = [S] extends [Leaf] ? unknown : V extends readonly unknown[] ? S extends ListOf<infer Names> ? readonly Names[] : unknown : V extends (...args: any) => any ? unknown : V extends object ? string extends keyof V ? unknown : {
|
|
224
|
-
readonly [K in keyof V]: K extends keyof S ? Exact<S[K], V[K]> : typeof otherKeys extends keyof S ? Exact<S[typeof otherKeys], V[K]> : never;
|
|
254
|
+
readonly [K in keyof V]: K extends keyof S ? Exact<S[K], V[K]> : typeof otherKeys extends keyof S ? Exact<S[typeof otherKeys], V[K]> : typeof refusal extends keyof S ? RefusalOf<S[typeof refusal], K, V[K]> : never;
|
|
225
255
|
} : unknown;
|
|
226
256
|
/**
|
|
227
257
|
* The authored configuration `Cfg`, checked key by key: a key no level of the
|
|
@@ -17,3 +17,5 @@ export declare function computeOfLayer(resources: unknown): ResolvedComputeConfi
|
|
|
17
17
|
* chained phase by phase. Nothing is disabled from below.
|
|
18
18
|
*/
|
|
19
19
|
export declare function chainCompute(root: ResolvedComputeConfig, overlay: ResolvedComputeConfig): ResolvedComputeConfig;
|
|
20
|
+
/** The fields of `resource` with a `compute.create` stage in `compute`. */
|
|
21
|
+
export declare function createComputedFields(compute: ResolvedComputeConfig, resource: string): ReadonlySet<string>;
|
|
@@ -113,3 +113,11 @@ export function chainCompute(root, overlay) {
|
|
|
113
113
|
}
|
|
114
114
|
return result;
|
|
115
115
|
}
|
|
116
|
+
export function createComputedFields(compute, resource) {
|
|
117
|
+
const fields = Object.hasOwn(compute, resource)
|
|
118
|
+
? compute[resource]
|
|
119
|
+
: undefined;
|
|
120
|
+
return new Set(Object.entries(fields ?? {})
|
|
121
|
+
.filter(([, phases]) => phases.create !== undefined)
|
|
122
|
+
.map(([field]) => field));
|
|
123
|
+
}
|
|
@@ -5,8 +5,9 @@ import type { AvTransactionCapability } from "../contracts/transaction-capabilit
|
|
|
5
5
|
import type { AvDiagnosticsSink } from "../runtime/diagnostics-reporter.js";
|
|
6
6
|
import type { AvMisuseSink } from "../runtime/misuse-reporter.js";
|
|
7
7
|
import type { AvConfigAny } from "./any-framework-config.js";
|
|
8
|
+
import type { AvConfigLayerName } from "./config-layer.js";
|
|
8
9
|
import type { AvConfigExemptions } from "./framework-exemptions-config.js";
|
|
9
|
-
import type { AvConfigLayerKind, AvConfigResources } from "./framework-resources-config.js";
|
|
10
|
+
import type { AvConfigLayerKind, AvConfigResources, LayerOfKind } from "./framework-resources-config.js";
|
|
10
11
|
import type { AvPipeline } from "./pipeline-config.js";
|
|
11
12
|
/**
|
|
12
13
|
* Request limits to override; each one left out takes its default from
|
|
@@ -29,7 +30,7 @@ type MovedLayerKeys = {
|
|
|
29
30
|
* `agent`. Stages are added to the root's; `transactionsStyle` and `limits`
|
|
30
31
|
* replace it where an overlay states them; exposure only narrows.
|
|
31
32
|
*/
|
|
32
|
-
export type AvConfigLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, Kind extends AvConfigLayerKind = "root"
|
|
33
|
+
export type AvConfigLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, Kind extends AvConfigLayerKind = "root", Layer extends AvConfigLayerName = LayerOfKind<Kind>> = MovedLayerKeys & {
|
|
33
34
|
/**
|
|
34
35
|
* Whether the layer's `exemptions` hide (`true`, the root's default) or are
|
|
35
36
|
* the only entries exposed (`false`). Each layer narrows its parent: the root
|
|
@@ -43,7 +44,7 @@ export type AvConfigLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvCon
|
|
|
43
44
|
/** Guards, pipes, hooks, interceptors and filters run around every operation of the layer. */
|
|
44
45
|
readonly pipelines?: AvPipeline<NoInfer<M>>;
|
|
45
46
|
/** The per-Resource tree: stages, operations, transactions and fields. */
|
|
46
|
-
readonly resources?: AvConfigResources<M, Cfg, Kind>;
|
|
47
|
+
readonly resources?: AvConfigResources<M, Cfg, Kind, Layer>;
|
|
47
48
|
/**
|
|
48
49
|
* The entries that are the opposite of `exposed`. An overlay that sets them
|
|
49
50
|
* states its own `exposed`.
|
|
@@ -73,8 +74,8 @@ export type AvConfig<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAn
|
|
|
73
74
|
readonly diagnostics?: AvDiagnosticsSink;
|
|
74
75
|
/** Told about every caller value refused as unreadable or not plain data. */
|
|
75
76
|
readonly misuse?: AvMisuseSink;
|
|
76
|
-
readonly application?: AvConfigLayer<M, Cfg, "overlay">;
|
|
77
|
-
readonly client?: AvConfigLayer<M, Cfg, "overlay">;
|
|
77
|
+
readonly application?: AvConfigLayer<M, Cfg, "overlay", "application">;
|
|
78
|
+
readonly client?: AvConfigLayer<M, Cfg, "overlay", "client">;
|
|
78
79
|
/**
|
|
79
80
|
* The layer an AI agent's calls run under. It narrows the view of the layer it
|
|
80
81
|
* `extends` (the client's when left out), and its stages run after that
|
|
@@ -109,7 +110,7 @@ export type AvConfigMcp = string | {
|
|
|
109
110
|
* The `agent` layer: the six layer keys, and `extends`, the layer whose final
|
|
110
111
|
* view it narrows and whose stages run before its own.
|
|
111
112
|
*/
|
|
112
|
-
export type AvConfigAgentLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = AvConfigLayer<M, Cfg, "overlay"> & {
|
|
113
|
+
export type AvConfigAgentLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = AvConfigLayer<M, Cfg, "overlay", "agent"> & {
|
|
113
114
|
/**
|
|
114
115
|
* The layer the agent starts from: `"client"` (the default), `"application"`
|
|
115
116
|
* or `"root"`. The agent never widens it.
|
|
@@ -2,8 +2,10 @@ import type { AvAdapterModel } from "../adapters/adapter-model.js";
|
|
|
2
2
|
import type { AvAdapterFieldKey } from "../adapters/adapter-resource.js";
|
|
3
3
|
import type { AvZCheck } from "../avz/avz-check.registry.js";
|
|
4
4
|
import type { AvOperationFamily } from "../operations/operation-identity.js";
|
|
5
|
-
import type { AvStageArguments } from "../runtime/pipeline.js";
|
|
5
|
+
import type { AvPreComputeStageArguments, AvStageArguments } from "../runtime/pipeline.js";
|
|
6
6
|
import type { AvConfigAny } from "./any-framework-config.js";
|
|
7
|
+
import type { AvPreComputeLift } from "./computed-fields.js";
|
|
8
|
+
import type { AvConfigLayerName } from "./config-layer.js";
|
|
7
9
|
import type { AvEffectiveFieldKey } from "./effective-fields.js";
|
|
8
10
|
import type { AvRelationFieldPipeline, AvScalarFieldPipeline } from "./field-pipeline-config.js";
|
|
9
11
|
import type { AvConfigAddedFieldDefinition, AvConfigFieldDefinition, AvConfigKnownFieldDefinition, AvConfigResourceKey } from "./framework-field-definition.js";
|
|
@@ -14,12 +16,14 @@ import type { AvPipeline, AvTransactionPipeline } from "./pipeline-config.js";
|
|
|
14
16
|
*/
|
|
15
17
|
export type AvConfigLayerKind = "root" | "overlay";
|
|
16
18
|
/** 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>>> = {
|
|
19
|
+
export type AvConfigVariant<M extends AvAdapterModel = AvAdapterModel, R extends string = AvConfigResourceKey<M>, F extends AvOperationFamily = AvOperationFamily, V extends string = string, A = NoInfer<AvStageArguments<M, R, F, V>>, PreCompute = NoInfer<AvPreComputeStageArguments<M, R, F, V>>> = {
|
|
18
20
|
/**
|
|
19
21
|
* 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
|
|
22
|
+
* pipe's arguments) are typed as the operation's arguments; in a guard, a
|
|
23
|
+
* pipe or a filter a create may lack the fields `compute.create` fills
|
|
24
|
+
* (write compute runs after them).
|
|
21
25
|
*/
|
|
22
|
-
readonly pipelines?: AvPipeline<NoInfer<M>, R, F, V, A>;
|
|
26
|
+
readonly pipelines?: AvPipeline<NoInfer<M>, R, F, V, A, PreCompute>;
|
|
23
27
|
/** Runs a plain call of this operation as a one-step transaction. */
|
|
24
28
|
readonly forceTransaction?: boolean;
|
|
25
29
|
};
|
|
@@ -31,12 +35,12 @@ type FamilyStageVariant<F extends AvOperationFamily, V extends string> = F exten
|
|
|
31
35
|
*/
|
|
32
36
|
export type AvConfigFamily<M extends AvAdapterModel = AvAdapterModel, Variants = {
|
|
33
37
|
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
|
|
38
|
+
}, R extends string = AvConfigResourceKey<M>, F extends AvOperationFamily = AvOperationFamily, Layer extends AvConfigLayerName = "root"> = AvConfigVariant<M, R, F, FamilyStageVariant<F, Extract<keyof NonNullable<Variants>, string>>, unknown, unknown> & {
|
|
39
|
+
readonly [V in Extract<keyof NonNullable<Variants>, string>]?: AvConfigVariant<M, R, F, V, NoInfer<AvStageArguments<M, R, F, V>>, NoInfer<AvPreComputeStageArguments<M, R, F, V, AvPreComputeLift<M, Layer>>>> | undefined;
|
|
36
40
|
};
|
|
37
41
|
/** 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>;
|
|
42
|
+
export type AvConfigOperations<M extends AvAdapterModel = AvAdapterModel, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>, Layer extends AvConfigLayerName = "root"> = {
|
|
43
|
+
readonly [F in Extract<keyof M["resources"][R]["operations"], AvOperationFamily>]?: AvConfigFamily<M, M["resources"][R]["operations"][F], R, F, Layer>;
|
|
40
44
|
};
|
|
41
45
|
/** A Resource's transaction level. */
|
|
42
46
|
export type AvConfigResourceTransactions<M extends AvAdapterModel = AvAdapterModel> = {
|
|
@@ -99,18 +103,20 @@ export type AvConfigResourceFields<in out M extends AvAdapterModel = AvAdapterMo
|
|
|
99
103
|
readonly [F in AvEffectiveFieldKey<M, Cfg, R>]?: Kind extends "root" ? RootFieldConfigFor<M, Cfg, R, F> : OverlayFieldConfigFor<M, Cfg, R, F>;
|
|
100
104
|
};
|
|
101
105
|
/** 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"
|
|
106
|
+
export type AvConfigResource<in out M extends AvAdapterModel = AvAdapterModel, in out Cfg = AvConfigAny, in out R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>, Kind extends AvConfigLayerKind = "root", Layer extends AvConfigLayerName = LayerOfKind<Kind>> = {
|
|
103
107
|
/** Stages that run for every operation of this Resource. */
|
|
104
108
|
readonly pipelines?: AvPipeline<NoInfer<M>, R>;
|
|
105
109
|
/** Per family, and per variant under its family. */
|
|
106
|
-
readonly operations?: AvConfigOperations<M, R>;
|
|
110
|
+
readonly operations?: AvConfigOperations<M, R, Layer>;
|
|
107
111
|
/** Stages that run once per transaction with a top-level step on this Resource. */
|
|
108
112
|
readonly transactions?: AvConfigResourceTransactions<M>;
|
|
109
113
|
/** Per field: its definition (root only) and its stages. */
|
|
110
114
|
readonly fields?: AvConfigResourceFields<M, Cfg, R, Kind>;
|
|
111
115
|
};
|
|
112
116
|
/** 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>;
|
|
117
|
+
export type AvConfigResources<in out M extends AvAdapterModel = AvAdapterModel, in out Cfg = AvConfigAny, in out Kind extends AvConfigLayerKind = "root", in out Layer extends AvConfigLayerName = LayerOfKind<Kind>> = {
|
|
118
|
+
readonly [R in AvConfigResourceKey<M>]?: AvConfigResource<M, Cfg, R, Kind, Layer>;
|
|
115
119
|
};
|
|
120
|
+
/** The layers a tree of kind `Kind` may be written in, when it names none. */
|
|
121
|
+
export type LayerOfKind<Kind extends AvConfigLayerKind> = Kind extends "root" ? "root" : Exclude<AvConfigLayerName, "root">;
|
|
116
122
|
export {};
|
|
@@ -6,11 +6,11 @@ import type { AvConfigResourceKey } from "./framework-field-definition.js";
|
|
|
6
6
|
* Pipeline registrations for one level of the configuration: a layer, a
|
|
7
7
|
* Resource, a family or a variant. See {@link AvContext}.
|
|
8
8
|
*/
|
|
9
|
-
export type AvPipeline<M extends AvAdapterModel = AvAdapterModel, R extends string = AvConfigResourceKey<M>, F extends AvOperationFamily = AvOperationFamily, V extends string = string, A = unknown> = {
|
|
9
|
+
export type AvPipeline<M extends AvAdapterModel = AvAdapterModel, R extends string = AvConfigResourceKey<M>, F extends AvOperationFamily = AvOperationFamily, V extends string = string, A = unknown, PreCompute = A> = {
|
|
10
10
|
/** Run first; a guard returning `false` denies the operation with `A4001`. */
|
|
11
|
-
readonly guards?: readonly AvGuard<M, R, F, V,
|
|
11
|
+
readonly guards?: readonly AvGuard<M, R, F, V, PreCompute>[];
|
|
12
12
|
/** Run in order on the arguments; a pipe may return replacement arguments. */
|
|
13
|
-
readonly pipes?: readonly AvPipe<M, R, F, V,
|
|
13
|
+
readonly pipes?: readonly AvPipe<M, R, F, V, PreCompute>[];
|
|
14
14
|
/**
|
|
15
15
|
* Run around the operation, inside every level's interceptors: `before`
|
|
16
16
|
* hooks outer to inner, `after` hooks inner to outer.
|
|
@@ -22,7 +22,7 @@ export type AvPipeline<M extends AvAdapterModel = AvAdapterModel, R extends stri
|
|
|
22
22
|
/** Wrap everything below this level; each calls `next()` to continue. */
|
|
23
23
|
readonly interceptors?: readonly AvInterceptor<M, R, F, V, A>[];
|
|
24
24
|
/** Turn a thrown error into a {@link AvError} outcome. */
|
|
25
|
-
readonly filters?: readonly AvFilter<M, R, F, V,
|
|
25
|
+
readonly filters?: readonly AvFilter<M, R, F, V, PreCompute>[];
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* A Resource's transaction stages: they run once per transaction with a
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
/** The operators a scalar field can be filtered with. */
|
|
2
2
|
export type AvScalarFilterOperator = "equals" | "not" | "in" | "notIn" | "lt" | "lte" | "gt" | "gte" | "contains" | "startsWith" | "endsWith" | "mode" | "has" | "hasEvery" | "hasSome" | "isEmpty" | "path" | "stringContains" | "stringStartsWith" | "stringEndsWith" | "arrayContains" | "arrayStartsWith" | "arrayEndsWith";
|
|
3
|
+
/**
|
|
4
|
+
* The case-sensitivity a text filter's `mode` asks for. `"default"` is whatever
|
|
5
|
+
* the database's own comparison does and is always available; `"sensitive"` and
|
|
6
|
+
* `"insensitive"` are an explicit promise, available on a field only where its
|
|
7
|
+
* `filterModes` lists them.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FILTER_MODES: readonly ["default", "sensitive", "insensitive"];
|
|
10
|
+
/** @see FILTER_MODES, the axis this union is derived from. */
|
|
11
|
+
export type ScalarFilterMode = (typeof FILTER_MODES)[number];
|
|
3
12
|
/** What an update can do to a scalar value besides setting it. */
|
|
4
13
|
export type AvScalarMutationDirective = "$increment" | "$decrement" | "$multiply" | "$divide" | "$push" | "$unset";
|
|
5
14
|
/** How a relation can be filtered on. */
|
|
@@ -24,6 +33,6 @@ export type AvProjectionScope = (typeof PROJECTION_SCOPES)[number];
|
|
|
24
33
|
* not the operation that carries it. The write counterpart of
|
|
25
34
|
* {@link AvProjectionScope}.
|
|
26
35
|
*/
|
|
27
|
-
export declare const WRITE_SCOPES: readonly ["nested", "bulkWrite"];
|
|
36
|
+
export declare const WRITE_SCOPES: readonly ["nested", "bulkWrite", "loopback"];
|
|
28
37
|
/** @see WRITE_SCOPES, the axis this union is derived from. */
|
|
29
38
|
export type AvWriteScope = (typeof WRITE_SCOPES)[number];
|