@aventara/core 1.0.0-rc.0 → 1.0.0-rc.2
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 +1434 -0
- package/ERRORS.md +142 -0
- package/README.md +247 -57
- package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
- package/dist/adapters/adapter-discovery-diagnostic.guidance.d.ts +6 -0
- package/dist/adapters/adapter-discovery-diagnostic.guidance.js +7 -0
- package/dist/adapters/adapter-field.d.ts +25 -11
- package/dist/adapters/adapter-identifier.d.ts +6 -6
- package/dist/adapters/adapter-model.d.ts +18 -9
- package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
- package/dist/adapters/adapter-operation.d.ts +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 +59 -29
- package/dist/avz/avz-check.factory.d.ts +83 -0
- package/dist/avz/avz-check.factory.js +116 -0
- package/dist/avz/avz-check.registry.d.ts +35 -0
- package/dist/avz/avz-check.registry.js +9 -0
- package/dist/avz/avz.d.ts +203 -0
- package/dist/{json → avz}/avz.js +150 -8
- package/dist/{json → avz}/index.d.ts +2 -1
- package/dist/{json → avz}/json-shape.registry.d.ts +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-diagnostic.guidance.d.ts +6 -0
- package/dist/compiler/contract-compiler-diagnostic.guidance.js +97 -0
- package/dist/compiler/contract.compiler.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +637 -442
- 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/computed-fields.d.ts +62 -0
- package/dist/config/computed-fields.js +80 -0
- package/dist/config/config-diagnostic.d.ts +11 -4
- package/dist/config/config-diagnostic.guidance.d.ts +6 -0
- package/dist/config/config-diagnostic.guidance.js +32 -0
- package/dist/config/config-layer.d.ts +15 -6
- package/dist/config/config.resolver.d.ts +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 +308 -0
- package/dist/config/field-compute.resolver.d.ts +21 -0
- package/dist/config/field-compute.resolver.js +123 -0
- package/dist/config/field-pipeline-config.d.ts +47 -0
- package/dist/config/forced-operation.validator.d.ts +10 -0
- package/dist/config/forced-operation.validator.js +66 -0
- package/dist/config/framework-config.d.ts +111 -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 +122 -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 +21 -12
- package/dist/contracts/capability.js +2 -0
- package/dist/contracts/client-contract-structure.validator.d.ts +388 -63
- package/dist/contracts/client-contract-structure.validator.js +156 -10
- package/dist/contracts/contract-canonicalizer.d.ts +26 -3
- package/dist/contracts/contract-canonicalizer.js +156 -29
- 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 +81 -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 +19 -10
- package/dist/framework/framework-construction.error.js +7 -3
- package/dist/framework/framework.d.ts +47 -23
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +49 -22
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +57 -50
- package/dist/index.js +7 -6
- package/dist/internal.d.ts +17 -10
- package/dist/internal.js +4 -1
- package/dist/operations/database-refusal.d.ts +51 -0
- package/dist/operations/database-refusal.js +45 -0
- package/dist/operations/operation-arguments.d.ts +343 -207
- 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 +99 -6
- 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.guidance.d.ts +6 -0
- package/dist/operations/validation-code.guidance.js +90 -0
- package/dist/operations/validation-code.js +4 -0
- package/dist/operations/write-scope.resolver.d.ts +10 -6
- package/dist/operations/write-scope.resolver.js +2 -0
- package/dist/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 +91 -17
- package/dist/protocol/unmounted-route.error.d.ts +4 -4
- package/dist/protocol/unmounted-route.error.js +2 -2
- package/dist/runtime/caller-data.copier.d.ts +22 -5
- package/dist/runtime/caller-data.copier.js +31 -14
- package/dist/runtime/caller-data.door.d.ts +17 -11
- 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 +76 -50
- package/dist/runtime/computed-value.error.d.ts +7 -6
- package/dist/runtime/computed-value.error.js +5 -4
- package/dist/runtime/context-executor.runtime.d.ts +59 -0
- package/dist/runtime/context-executor.runtime.js +275 -0
- package/dist/runtime/create-requirement.d.ts +44 -79
- package/dist/runtime/create-requirement.js +213 -73
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +54 -27
- package/dist/runtime/diagnostics-reporter.js +24 -0
- package/dist/runtime/error-boundary.d.ts +65 -8
- package/dist/runtime/error-boundary.js +49 -19
- package/dist/runtime/error-guidance.d.ts +12 -0
- package/dist/runtime/error-guidance.js +1 -0
- package/dist/runtime/error.catalog.d.ts +49 -0
- package/dist/runtime/error.catalog.js +49 -0
- package/dist/runtime/execution-options.d.ts +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 +37 -0
- package/dist/runtime/field-stage.runtime.js +147 -0
- package/dist/runtime/field-validator.runtime.d.ts +19 -0
- package/dist/runtime/field-validator.runtime.js +92 -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 +11 -6
- package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
- package/dist/runtime/level-lifecycle.runtime.js +39 -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 +48 -35
- package/dist/runtime/nested-write.walker.d.ts +32 -0
- package/dist/runtime/nested-write.walker.js +73 -0
- package/dist/runtime/operation-code.guidance.d.ts +6 -0
- package/dist/runtime/operation-code.guidance.js +167 -0
- package/dist/runtime/operation-request.d.ts +33 -6
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +127 -25
- package/dist/runtime/operation-runtime.js +441 -78
- 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 +16 -6
- package/dist/runtime/pipe-output.validator.d.ts +43 -18
- package/dist/runtime/pipe-output.validator.js +15 -13
- package/dist/runtime/pipeline.d.ts +223 -34
- package/dist/runtime/readonly-value.d.ts +43 -0
- package/dist/runtime/readonly-value.js +150 -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 +35 -16
- package/dist/runtime/scalar-runtime.js +102 -34
- package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
- package/dist/runtime/unsent-value.normalizer.js +128 -0
- package/dist/transactions/deferred-operation.d.ts +35 -20
- package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
- package/dist/transactions/operation-arguments-encoder.js +2 -2
- package/dist/transactions/operation-fingerprint.js +2 -2
- package/dist/transactions/sql-statement.d.ts +85 -0
- package/dist/transactions/sql-statement.js +47 -0
- package/dist/transactions/sql-statement.validator.d.ts +44 -0
- package/dist/transactions/sql-statement.validator.js +167 -0
- package/dist/transactions/transaction-envelope.d.ts +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 +169 -32
- package/dist/transactions/transaction-plan-validator.d.ts +45 -20
- package/dist/transactions/transaction-plan-validator.js +96 -38
- package/dist/transactions/transaction-reference-collector.d.ts +5 -5
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +26 -14
- package/dist/transactions/transaction-reference-validator.d.ts +76 -4
- package/dist/transactions/transaction-reference-validator.js +129 -71
- package/dist/transactions/transaction-reference.d.ts +13 -13
- package/dist/transactions/transaction-reference.js +5 -0
- 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 +191 -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 +82 -0
- package/dist/transactions/transaction-stage.runtime.js +126 -0
- package/package.json +9 -7
- 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,28 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { FieldAtom, ScalarForms
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
1
|
+
import type { AvProjectionScope, AvRelationMutationDirective, AvScalarFilterOperator, AvScalarMutationDirective, AvWriteScope, ScalarFilterMode } from "../contracts/capability.js";
|
|
2
|
+
import type { AvContract } from "../contracts/contract.js";
|
|
3
|
+
import type { AvProjectionScopes, AvScalarField } from "../contracts/field.js";
|
|
4
|
+
import type { AvScalarValueType, FieldAtom, ScalarForms } from "../contracts/scalar-value-type.js";
|
|
5
|
+
import type { AvJsonValue } from "../runtime/json-value.js";
|
|
6
|
+
import type { AvTransactionReference, TransactionSlotShape } from "../transactions/transaction-reference.js";
|
|
7
|
+
import type { AvOperationIdentity } from "./operation-identity.js";
|
|
8
8
|
/** The Resource names of Contract `C`. */
|
|
9
|
-
export type
|
|
9
|
+
export type AvResourceKey<C extends AvContract> = Extract<keyof C["resources"], string>;
|
|
10
10
|
/** The field names of Resource `K` in Contract `C`. */
|
|
11
|
-
export type
|
|
12
|
-
type FieldAt<C extends
|
|
13
|
-
type ScalarFieldAt<C extends
|
|
11
|
+
export type AvFieldKey<C extends AvContract, K extends AvResourceKey<C>> = Extract<keyof C["resources"][K]["fields"], string>;
|
|
12
|
+
type FieldAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = C["resources"][K]["fields"][F];
|
|
13
|
+
type ScalarFieldAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = Extract<FieldAt<C, K, F>, {
|
|
14
14
|
readonly kind: "scalar";
|
|
15
15
|
}>;
|
|
16
|
-
type RelationFieldAt<C extends
|
|
16
|
+
type RelationFieldAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = Extract<FieldAt<C, K, F>, {
|
|
17
17
|
readonly kind: "relation";
|
|
18
18
|
}>;
|
|
19
|
-
type ScalarFieldKeyOf<C extends
|
|
20
|
-
[F in
|
|
21
|
-
}[
|
|
22
|
-
type RelationFieldKeyOf<C extends
|
|
23
|
-
[F in
|
|
24
|
-
}[
|
|
25
|
-
type CapabilitiesOf<C extends
|
|
19
|
+
type ScalarFieldKeyOf<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
20
|
+
[F in AvFieldKey<C, K>]: ScalarFieldAt<C, K, F> extends never ? never : F;
|
|
21
|
+
}[AvFieldKey<C, K>];
|
|
22
|
+
type RelationFieldKeyOf<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
23
|
+
[F in AvFieldKey<C, K>]: RelationFieldAt<C, K, F> extends never ? never : F;
|
|
24
|
+
}[AvFieldKey<C, K>];
|
|
25
|
+
type CapabilitiesOf<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = FieldAt<C, K, F> extends {
|
|
26
26
|
readonly capabilities: infer Capabilities;
|
|
27
27
|
} ? Capabilities : never;
|
|
28
28
|
/** The projection position read when no position applies: `"record"`. */
|
|
@@ -30,15 +30,15 @@ type UnrestrictedProjection = "record";
|
|
|
30
30
|
/** The write position read when no position applies, and the one nested writes use: `"nested"`. */
|
|
31
31
|
type UnrestrictedWrite = "nested";
|
|
32
32
|
/** Whether a capability member's answer holds at one argument scope. */
|
|
33
|
-
type HoldsAtScope<Value, Scope extends
|
|
33
|
+
type HoldsAtScope<Value, Scope extends AvProjectionScope | AvWriteScope> = Value extends {
|
|
34
34
|
readonly scopes: readonly (infer Stated)[];
|
|
35
|
-
} ? Scope extends Stated ? true : false : Value extends
|
|
35
|
+
} ? Scope extends Stated ? true : false : Value extends AvProjectionScopes ? Scope extends Value[number] ? true : false : true;
|
|
36
36
|
/** The tokens a capability member advertises, in any argument position. */
|
|
37
37
|
type AdvertisedTokens<Value> = Value extends {
|
|
38
|
-
readonly scopes: readonly
|
|
38
|
+
readonly scopes: readonly AvWriteScope[];
|
|
39
39
|
readonly directives: readonly (infer Directive)[];
|
|
40
40
|
} ? Directive : Value extends {
|
|
41
|
-
readonly scopes: readonly
|
|
41
|
+
readonly scopes: readonly AvProjectionScope[];
|
|
42
42
|
readonly reducers: readonly (infer Reducer)[];
|
|
43
43
|
} ? Reducer : Value extends readonly (infer Token)[] ? Token : never;
|
|
44
44
|
/**
|
|
@@ -47,48 +47,48 @@ type AdvertisedTokens<Value> = Value extends {
|
|
|
47
47
|
* Presence first, scope second: an absent or `false` member is unavailable
|
|
48
48
|
* everywhere, and only a present one is asked where it holds.
|
|
49
49
|
*/
|
|
50
|
-
type HasCapability<C extends
|
|
50
|
+
type HasCapability<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Capability extends PropertyKey, Scope extends AvProjectionScope | AvWriteScope> = Capability extends keyof CapabilitiesOf<C, K, F> ? CapabilitiesOf<C, K, F>[Capability] extends false | undefined ? false : HoldsAtScope<CapabilitiesOf<C, K, F>[Capability], Scope> : false;
|
|
51
51
|
/**
|
|
52
52
|
* The tokens a field advertises for one capability **at one argument scope** —
|
|
53
53
|
* `never` where the member does not hold at that scope, so a token list that
|
|
54
54
|
* holds only in the unrestricted position offers no token in a bulk one.
|
|
55
55
|
*/
|
|
56
|
-
type CapabilityTokens<C extends
|
|
57
|
-
type HasCapabilityToken<C extends
|
|
58
|
-
type RelationTarget<C extends
|
|
59
|
-
type RelationCardinality<C extends
|
|
60
|
-
type RelationNullable<C extends
|
|
61
|
-
type KeysWithCapability<C extends
|
|
56
|
+
type CapabilityTokens<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Capability extends PropertyKey, Scope extends AvProjectionScope | AvWriteScope> = Capability extends keyof CapabilitiesOf<C, K, F> ? HoldsAtScope<CapabilitiesOf<C, K, F>[Capability], Scope> extends true ? AdvertisedTokens<CapabilitiesOf<C, K, F>[Capability]> : never : never;
|
|
57
|
+
type HasCapabilityToken<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Capability extends PropertyKey, Scope extends AvProjectionScope | AvWriteScope, Token> = Token extends CapabilityTokens<C, K, F, Capability, Scope> ? true : false;
|
|
58
|
+
type RelationTarget<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>> = Extract<RelationFieldAt<C, K, F>["target"], AvResourceKey<C>>;
|
|
59
|
+
type RelationCardinality<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>> = RelationFieldAt<C, K, F>["cardinality"];
|
|
60
|
+
type RelationNullable<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>> = RelationFieldAt<C, K, F>["nullable"];
|
|
61
|
+
type KeysWithCapability<C extends AvContract, K extends AvResourceKey<C>, Keys extends AvFieldKey<C, K>, Capability extends PropertyKey, Scope extends AvProjectionScope | AvWriteScope> = {
|
|
62
62
|
[F in Keys]: HasCapability<C, K, F, Capability, Scope> extends true ? F : never;
|
|
63
63
|
}[Keys];
|
|
64
64
|
/**
|
|
65
65
|
* The scalar-form map used when no side of a boundary is named: every built-in
|
|
66
|
-
* value is `unknown`. Pass `
|
|
66
|
+
* value is `unknown`. Pass `AvApplicationScalarForms` or `AvWireScalarForms` to type
|
|
67
67
|
* values. Enum values are their member union under every map.
|
|
68
68
|
*/
|
|
69
69
|
type UnstatedForms = ScalarForms;
|
|
70
70
|
/** Field `F`'s value under `Forms`, the same as in results. */
|
|
71
|
-
type ScalarValueAt<C extends
|
|
71
|
+
type ScalarValueAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Forms extends ScalarForms> = ScalarFieldAt<C, K, F> extends infer Field extends AvScalarField<C> ? AvScalarValueType<C, Field, Forms> : never;
|
|
72
72
|
/** One entry of field `F`'s value — the whole value when `F` is not a list. */
|
|
73
|
-
type ScalarAtomAt<C extends
|
|
73
|
+
type ScalarAtomAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Forms extends ScalarForms> = FieldAtom<C, ScalarFieldAt<C, K, F>, Forms>;
|
|
74
74
|
/**
|
|
75
75
|
* A `$ref` to a source whose value fits slot shape `Shape` of field `F`, typed in
|
|
76
76
|
* `ReferenceForms` — the forms a source's final data is read in. `never` when
|
|
77
77
|
* `ReferenceForms` is `never`: no position takes one outside a transaction plan.
|
|
78
78
|
*/
|
|
79
|
-
type SlotReference<C extends
|
|
79
|
+
type SlotReference<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, ReferenceForms extends ScalarForms, Shape extends TransactionSlotShape> = [ReferenceForms] extends [never] ? never : AvTransactionReference<Shape extends "value" ? ScalarValueAt<C, K, F, ReferenceForms> : Shape extends "nonNullValue" ? Exclude<ScalarValueAt<C, K, F, ReferenceForms>, null> : Shape extends "entry" ? ScalarAtomAt<C, K, F, ReferenceForms> : readonly ScalarAtomAt<C, K, F, ReferenceForms>[]>;
|
|
80
80
|
/**
|
|
81
81
|
* A JSON object. Positions that accept both a value and an object of operators
|
|
82
82
|
* read a JSON object as the operators, so their value forms leave it out.
|
|
83
83
|
*/
|
|
84
|
-
type JsonObject = Extract<
|
|
85
|
-
readonly [key: string]:
|
|
84
|
+
type JsonObject = Extract<AvJsonValue, {
|
|
85
|
+
readonly [key: string]: AvJsonValue | undefined;
|
|
86
86
|
}>;
|
|
87
87
|
/**
|
|
88
88
|
* The field-independent shape of one scalar filter: any value, or an object of the
|
|
89
89
|
* operator vocabulary.
|
|
90
90
|
*/
|
|
91
|
-
export type ScalarFilterInput = unknown | Readonly<Partial<Record<
|
|
91
|
+
export type ScalarFilterInput = unknown | Readonly<Partial<Record<AvScalarFilterOperator, unknown>>>;
|
|
92
92
|
/**
|
|
93
93
|
* A scalar filter's shorthand equality value: the field's value, minus a JSON
|
|
94
94
|
* object.
|
|
@@ -98,64 +98,121 @@ type ScalarFilterShorthand<Value> = Exclude<Value, JsonObject>;
|
|
|
98
98
|
* The `$ref` each slot shape of field `F` takes, by shape: every member `never`
|
|
99
99
|
* outside a transaction plan.
|
|
100
100
|
*/
|
|
101
|
-
type FieldSlotReferences<C extends
|
|
101
|
+
type FieldSlotReferences<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, ReferenceForms extends ScalarForms> = {
|
|
102
102
|
readonly [Shape in TransactionSlotShape]: SlotReference<C, K, F, ReferenceForms, Shape>;
|
|
103
103
|
};
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
106
|
-
* value; `in`, `notIn`, `hasEvery` and `hasSome` take a list of entries;
|
|
107
|
-
* one entry; a `json` field's `string*`/`array*` operand a
|
|
108
|
-
* `not` a
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
105
|
+
* Every scalar filter operator's operand: a comparison operand is the field's
|
|
106
|
+
* whole value; `in`, `notIn`, `hasEvery` and `hasSome` take a list of entries;
|
|
107
|
+
* `has` one entry; a `json` field's `string*`/`array*` operand a
|
|
108
|
+
* {@link AvJsonValue}; `not` a nested operator object of the same operators, or
|
|
109
|
+
* a value where `equals` is one of them. `mode` takes one of the modes the
|
|
110
|
+
* field offers at this level (`LevelMode`), `isEmpty` a boolean, `path` a list of
|
|
111
|
+
* JSON keys and a `json` field's `string*` operand a string: none of these is a
|
|
112
|
+
* value of the field. Only `equals`, `not` and the `json` `array*` operands take
|
|
113
|
+
* `null`. Inside a transaction plan every
|
|
114
|
+
* operand but `mode`, `isEmpty`, `path` and the `json` ones may be a `$ref` of
|
|
115
|
+
* the shape it holds (`References`).
|
|
116
|
+
*/
|
|
117
|
+
type ScalarFilterOperands<Value, Atom, Json, References extends Readonly<Record<TransactionSlotShape, unknown>>, Operator extends AvScalarFilterOperator, Mode extends ScalarFilterMode, PathMode extends ScalarFilterMode, LevelMode extends ScalarFilterMode> = {
|
|
118
|
+
equals: Value | References["value"];
|
|
119
|
+
not: NegatedValue<Value, References, Operator> | ScalarFilterOperators<Value, Atom, Json, References, Operator, Mode, PathMode>;
|
|
120
|
+
in: readonly Atom[] | References["entries"];
|
|
121
|
+
notIn: readonly Atom[] | References["entries"];
|
|
122
|
+
lt: Exclude<Value, null> | References["nonNullValue"];
|
|
123
|
+
lte: Exclude<Value, null> | References["nonNullValue"];
|
|
124
|
+
gt: Exclude<Value, null> | References["nonNullValue"];
|
|
125
|
+
gte: Exclude<Value, null> | References["nonNullValue"];
|
|
126
|
+
contains: Exclude<Value, null> | References["nonNullValue"];
|
|
127
|
+
startsWith: Exclude<Value, null> | References["nonNullValue"];
|
|
128
|
+
endsWith: Exclude<Value, null> | References["nonNullValue"];
|
|
129
|
+
mode: LevelMode;
|
|
130
|
+
has: Atom | References["entry"];
|
|
131
|
+
hasEvery: readonly Atom[] | References["entries"];
|
|
132
|
+
hasSome: readonly Atom[] | References["entries"];
|
|
133
|
+
isEmpty: boolean;
|
|
134
|
+
path: readonly string[];
|
|
135
|
+
stringContains: string;
|
|
136
|
+
stringStartsWith: string;
|
|
137
|
+
stringEndsWith: string;
|
|
138
|
+
arrayContains: Json;
|
|
139
|
+
arrayStartsWith: Json;
|
|
140
|
+
arrayEndsWith: Json;
|
|
141
|
+
};
|
|
139
142
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
143
|
+
* A scalar filter's operator object: the operators `Operator` names — the ones
|
|
144
|
+
* the field's `filter` member advertises — each with its operand. Where `path`
|
|
145
|
+
* is one of them, an object that names it takes `PathMode`, and one that does
|
|
146
|
+
* not takes `Mode`. An object that names `mode` or `path` names a comparing
|
|
147
|
+
* operator beside it.
|
|
145
148
|
*/
|
|
146
|
-
type
|
|
149
|
+
type ScalarFilterOperators<Value, Atom, Json, References extends Readonly<Record<TransactionSlotShape, unknown>>, Operator extends AvScalarFilterOperator, Mode extends ScalarFilterMode, PathMode extends ScalarFilterMode> = ScalarFilterLevel<ReadonlyOperands<Value, Atom, Json, References, Operator, Mode, PathMode, Mode>, Operator, Mode, NegatedValue<Value, References, Operator>, "path" extends Operator ? {
|
|
150
|
+
readonly path?: never;
|
|
151
|
+
} : unknown> | ("path" extends Operator ? ScalarFilterOperatorsAtPath<ReadonlyOperands<Value, Atom, Json, References, Operator, Mode, PathMode, PathMode>, Operator, PathMode, NegatedValue<Value, References, Operator>> : never);
|
|
152
|
+
/** {@link ScalarFilterOperands}, each operand read-only. */
|
|
153
|
+
type ReadonlyOperands<Value, Atom, Json, References extends Readonly<Record<TransactionSlotShape, unknown>>, Operator extends AvScalarFilterOperator, Mode extends ScalarFilterMode, PathMode extends ScalarFilterMode, LevelMode extends ScalarFilterMode> = Readonly<ScalarFilterOperands<Value, Atom, Json, References, Operator, Mode, PathMode, LevelMode>>;
|
|
154
|
+
/** The operators of a level that compare something: all but `mode` and `path`. */
|
|
155
|
+
type ComparingOperator<Operator extends AvScalarFilterOperator> = Exclude<Operator, "mode" | "path">;
|
|
156
|
+
/** `not`'s value arm: equality negated, offered only where `equals` is. */
|
|
157
|
+
type NegatedValue<Value, References extends Readonly<Record<TransactionSlotShape, unknown>>, Operator extends AvScalarFilterOperator> = "equals" extends Operator ? Exclude<Value, JsonObject> | References["value"] : never;
|
|
158
|
+
/** A level's comparing operators, each optional. */
|
|
159
|
+
type ComparingOperators<Operands extends Readonly<Record<AvScalarFilterOperator, unknown>>, Operator extends AvScalarFilterOperator> = Partial<Pick<Operands, ComparingOperator<Operator>>>;
|
|
160
|
+
/**
|
|
161
|
+
* A level's comparing operators with at least one of them present; `not` is
|
|
162
|
+
* one only with a value (an object under `not` compares at its own level).
|
|
163
|
+
*/
|
|
164
|
+
type SomeComparingOperator<Operands extends Readonly<Record<AvScalarFilterOperator, unknown>>, Operator extends AvScalarFilterOperator, Negated> = ({
|
|
165
|
+
[Key in Exclude<ComparingOperator<Operator>, "not">]-?: Pick<Operands, Key>;
|
|
166
|
+
}[Exclude<ComparingOperator<Operator>, "not">] & ComparingOperators<Operands, Operator>) | ("not" extends Operator ? {
|
|
167
|
+
readonly not: Negated;
|
|
168
|
+
} & Partial<Pick<Operands, Exclude<ComparingOperator<Operator>, "not">>> : never);
|
|
169
|
+
/**
|
|
170
|
+
* One operator object that names no `path`: without `mode`, any of its comparing
|
|
171
|
+
* operators; with `mode` (one of `Mode`), at least one of them.
|
|
172
|
+
*/
|
|
173
|
+
type ScalarFilterLevel<Operands extends Readonly<Record<AvScalarFilterOperator, unknown>>, Operator extends AvScalarFilterOperator, Mode extends ScalarFilterMode, Negated, PathKey> = ("mode" extends Operator ? (ComparingOperators<Operands, Operator> & {
|
|
174
|
+
readonly mode?: never;
|
|
175
|
+
}) | (SomeComparingOperator<Operands, Operator, Negated> & {
|
|
176
|
+
readonly mode?: Mode;
|
|
177
|
+
}) : ComparingOperators<Operands, Operator>) & PathKey;
|
|
178
|
+
/** An operator object that names `path`: `PathMode`, and a comparing operator. */
|
|
179
|
+
type ScalarFilterOperatorsAtPath<Operands extends Readonly<Record<AvScalarFilterOperator, unknown>>, Operator extends AvScalarFilterOperator, PathMode extends ScalarFilterMode, Negated> = SomeComparingOperator<Operands, Operator, Negated> & {
|
|
180
|
+
readonly path: readonly string[];
|
|
181
|
+
} & ("mode" extends Operator ? {
|
|
182
|
+
readonly mode?: PathMode;
|
|
183
|
+
} : unknown);
|
|
184
|
+
/** The filter operators field `F` advertises: `never` when it advertises none. */
|
|
185
|
+
type ScalarFilterOperatorAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = Extract<CapabilityTokens<C, K, F, "filter", UnrestrictedProjection>, AvScalarFilterOperator>;
|
|
186
|
+
/** The `mode` operands field `F` takes in an operator object without `path`. */
|
|
187
|
+
type ScalarFilterModeAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = "default" | Extract<CapabilityTokens<C, K, F, "filterModes", UnrestrictedProjection>, ScalarFilterMode>;
|
|
188
|
+
/** The `mode` operands field `F` takes in an operator object that names `path`. */
|
|
189
|
+
type ScalarPathFilterModeAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = "pathFilterModes" extends keyof CapabilitiesOf<C, K, F> ? "default" | Extract<CapabilityTokens<C, K, F, "pathFilterModes", UnrestrictedProjection>, ScalarFilterMode> : ScalarFilterModeAt<C, K, F>;
|
|
190
|
+
/**
|
|
191
|
+
* One scalar field's filter under `Forms`: a shorthand value where the field
|
|
192
|
+
* advertises `equals`, or an object of the operators it advertises. Inside a
|
|
193
|
+
* transaction plan the value and every operand that holds a field value may be a
|
|
194
|
+
* `$ref` (see {@link TransactionSlotShape}): equality to a source nullable only
|
|
195
|
+
* where the field is, a comparison to a non-null source, `in` and the list
|
|
196
|
+
* operators to a list source, `has` to one entry.
|
|
197
|
+
*/
|
|
198
|
+
type ScalarFilterFor<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = ("equals" extends ScalarFilterOperatorAt<C, K, F> ? ScalarFilterShorthand<ScalarValueAt<C, K, F, Forms>> | SlotReference<C, K, F, ReferenceForms, "value"> : never) | ScalarFilterOperators<ScalarValueAt<C, K, F, Forms>, ScalarAtomAt<C, K, F, Forms>, ScalarFieldAt<C, K, F>["type"] extends {
|
|
147
199
|
readonly scalar: "json";
|
|
148
|
-
} ?
|
|
149
|
-
|
|
150
|
-
type
|
|
200
|
+
} ? AvJsonValue : ScalarValueAt<C, K, F, Forms>, FieldSlotReferences<C, K, F, ReferenceForms>, ScalarFilterOperatorAt<C, K, F>, ScalarFilterModeAt<C, K, F>, ScalarPathFilterModeAt<C, K, F>>;
|
|
201
|
+
/** The scalar fields of `K` a `where` can name: those advertising an operator. */
|
|
202
|
+
type ScalarFilterableKey<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
203
|
+
[F in ScalarFieldKeyOf<C, K>]: [ScalarFilterOperatorAt<C, K, F>] extends [
|
|
204
|
+
never
|
|
205
|
+
] ? never : F;
|
|
206
|
+
}[ScalarFieldKeyOf<C, K>];
|
|
207
|
+
type RelationParentFilterKey<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
151
208
|
[F in RelationFieldKeyOf<C, K>]: RelationCardinality<C, K, F> extends "one" ? HasCapabilityToken<C, K, F, "filter", UnrestrictedProjection, "match"> extends true ? F : HasCapabilityToken<C, K, F, "filter", UnrestrictedProjection, "null"> extends true ? F : never : Extract<CapabilityTokens<C, K, F, "filter", UnrestrictedProjection>, "some" | "every" | "none"> extends never ? never : F;
|
|
152
209
|
}[RelationFieldKeyOf<C, K>];
|
|
153
|
-
type ToManyRelationWhereInput<C extends
|
|
154
|
-
type RelationWhereInput<C extends
|
|
155
|
-
type ScalarWhereFields<C extends
|
|
210
|
+
type ToManyRelationWhereInput<C extends AvContract, K extends AvResourceKey<C>, F extends RelationParentFilterKey<C, K> & RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<Partial<Record<Extract<CapabilityTokens<C, K, F, "filter", UnrestrictedProjection>, "some" | "every" | "none">, AvWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>>>>;
|
|
211
|
+
type RelationWhereInput<C extends AvContract, K extends AvResourceKey<C>, F extends RelationParentFilterKey<C, K> & RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = RelationCardinality<C, K, F> extends "one" ? (HasCapabilityToken<C, K, F, "filter", UnrestrictedProjection, "match"> extends true ? AvWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms> : never) | (RelationNullable<C, K, F> extends true ? HasCapabilityToken<C, K, F, "filter", UnrestrictedProjection, "null"> extends true ? null : never : never) : ToManyRelationWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
212
|
+
type ScalarWhereFields<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
156
213
|
[F in ScalarFilterableKey<C, K>]?: ScalarFilterFor<C, K, F, Forms, ReferenceForms>;
|
|
157
214
|
}>;
|
|
158
|
-
type RelationWhereFields<C extends
|
|
215
|
+
type RelationWhereFields<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
159
216
|
[F in RelationParentFilterKey<C, K>]?: RelationWhereInput<C, K, F & RelationFieldKeyOf<C, K>, Forms, ReferenceForms>;
|
|
160
217
|
}>;
|
|
161
218
|
/**
|
|
@@ -163,47 +220,47 @@ type RelationWhereFields<C extends Contract, K extends ResourceKey<C>, Forms ext
|
|
|
163
220
|
* through; see {@link UnstatedForms} for the default. `ReferenceForms` opens a
|
|
164
221
|
* transaction step's own `where` to `$ref`s, at every depth of it.
|
|
165
222
|
*/
|
|
166
|
-
export type
|
|
167
|
-
AND?: readonly
|
|
168
|
-
OR?: readonly
|
|
169
|
-
NOT?:
|
|
223
|
+
export type AvWhereInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = Readonly<{
|
|
224
|
+
AND?: readonly AvWhereInput<C, K, Forms, ReferenceForms>[];
|
|
225
|
+
OR?: readonly AvWhereInput<C, K, Forms, ReferenceForms>[];
|
|
226
|
+
NOT?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
170
227
|
} & ScalarWhereFields<C, K, Forms, ReferenceForms> & RelationWhereFields<C, K, Forms, ReferenceForms>>;
|
|
171
|
-
type ActiveIdentifier<C extends
|
|
172
|
-
type IdentifierObject<C extends
|
|
173
|
-
[F in Extract<I[number],
|
|
228
|
+
type ActiveIdentifier<C extends AvContract, K extends AvResourceKey<C>> = C["resources"][K]["identifiers"][number];
|
|
229
|
+
type IdentifierObject<C extends AvContract, K extends AvResourceKey<C>, I extends readonly string[], Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
230
|
+
[F in Extract<I[number], AvFieldKey<C, K>>]: ScalarValueAt<C, K, F, Forms> | SlotReference<C, K, F, ReferenceForms, "nonNullValue">;
|
|
174
231
|
} & {
|
|
175
|
-
[F in Exclude<
|
|
232
|
+
[F in Exclude<AvFieldKey<C, K>, I[number]>]?: never;
|
|
176
233
|
}>;
|
|
177
234
|
/**
|
|
178
235
|
* A `where` argument for a unique operation: the values of one identifier. Inside a
|
|
179
236
|
* transaction plan (`ReferenceForms` stated) each value may be a `$ref` to a non-null
|
|
180
237
|
* source of the same type.
|
|
181
238
|
*/
|
|
182
|
-
export type
|
|
239
|
+
export type AvUniqueWhereInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = ActiveIdentifier<C, K> extends infer I ? I extends readonly string[] ? IdentifierObject<C, K, I, Forms, ReferenceForms> : never : never;
|
|
183
240
|
/** `"asc"` or `"desc"`. */
|
|
184
|
-
export type
|
|
241
|
+
export type AvSortDirection = "asc" | "desc";
|
|
185
242
|
/** Where `null`s sort: `"first"` or `"last"`. */
|
|
186
|
-
export type
|
|
243
|
+
export type AvNullsOrder = "first" | "last";
|
|
187
244
|
/** How one scalar field sorts: a direction, or a direction and a `nulls` order. */
|
|
188
|
-
export type
|
|
189
|
-
sort:
|
|
190
|
-
nulls:
|
|
245
|
+
export type AvScalarOrderInput = AvSortDirection | Readonly<{
|
|
246
|
+
sort: AvSortDirection;
|
|
247
|
+
nulls: AvNullsOrder;
|
|
191
248
|
}>;
|
|
192
|
-
type OrderableScalarKey<C extends
|
|
193
|
-
type OrderableRelationKey<C extends
|
|
194
|
-
type OrderableFieldKey<C extends
|
|
195
|
-
type ScalarOrderForField<C extends
|
|
249
|
+
type OrderableScalarKey<C extends AvContract, K extends AvResourceKey<C>> = KeysWithCapability<C, K, ScalarFieldKeyOf<C, K>, "order", UnrestrictedProjection>;
|
|
250
|
+
type OrderableRelationKey<C extends AvContract, K extends AvResourceKey<C>> = KeysWithCapability<C, K, RelationFieldKeyOf<C, K>, "order", UnrestrictedProjection>;
|
|
251
|
+
type OrderableFieldKey<C extends AvContract, K extends AvResourceKey<C>> = OrderableScalarKey<C, K> | OrderableRelationKey<C, K>;
|
|
252
|
+
type ScalarOrderForField<C extends AvContract, K extends AvResourceKey<C>, F extends OrderableScalarKey<C, K>> = ScalarFieldAt<C, K, F>["nullable"] extends true ? HasCapability<C, K, F, "orderNulls", UnrestrictedProjection> extends true ? AvScalarOrderInput : AvSortDirection : AvSortDirection;
|
|
196
253
|
/**
|
|
197
254
|
* The `orderBy` value of a relation field: a to-many relation orders by
|
|
198
255
|
* `$count`; a to-one relation takes one entry of the related Resource's
|
|
199
256
|
* `orderBy`, not a list.
|
|
200
257
|
*/
|
|
201
|
-
type RelationOrderForField<C extends
|
|
202
|
-
$count:
|
|
203
|
-
}> : never :
|
|
204
|
-
type OrderValue<C extends
|
|
258
|
+
type RelationOrderForField<C extends AvContract, K extends AvResourceKey<C>, F extends OrderableRelationKey<C, K> & RelationFieldKeyOf<C, K>> = RelationCardinality<C, K, F> extends "many" ? HasCapabilityToken<C, K, F, "reducers", UnrestrictedProjection, "$count"> extends true ? Readonly<{
|
|
259
|
+
$count: AvSortDirection;
|
|
260
|
+
}> : never : AvOrderByEntry<C, RelationTarget<C, K, F>>;
|
|
261
|
+
type OrderValue<C extends AvContract, K extends AvResourceKey<C>, F extends OrderableFieldKey<C, K>> = F extends OrderableScalarKey<C, K> ? ScalarOrderForField<C, K, F> : F extends OrderableRelationKey<C, K> & RelationFieldKeyOf<C, K> ? RelationOrderForField<C, K, F> : never;
|
|
205
262
|
/** One `orderBy` precedence entry: exactly one orderable field and its value. */
|
|
206
|
-
export type
|
|
263
|
+
export type AvOrderByEntry<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
207
264
|
[F in OrderableFieldKey<C, K>]: {
|
|
208
265
|
readonly [Only in F]: OrderValue<C, K, Only>;
|
|
209
266
|
} & {
|
|
@@ -211,18 +268,18 @@ export type OrderByEntry<C extends Contract, K extends ResourceKey<C>> = {
|
|
|
211
268
|
};
|
|
212
269
|
}[OrderableFieldKey<C, K>];
|
|
213
270
|
/** An `orderBy` argument: one entry, or a list in order of precedence. */
|
|
214
|
-
export type
|
|
271
|
+
export type AvOrderByInput<C extends AvContract, K extends AvResourceKey<C>> = AvOrderByEntry<C, K> | readonly AvOrderByEntry<C, K>[];
|
|
215
272
|
/**
|
|
216
273
|
* A `cursor` argument: scalar field values of the row the page starts from. Inside
|
|
217
274
|
* a transaction plan each may be a `$ref` to a non-null source of the same type.
|
|
218
275
|
*/
|
|
219
|
-
export type
|
|
276
|
+
export type AvCursorInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = Readonly<{
|
|
220
277
|
[F in ScalarFieldKeyOf<C, K>]?: ScalarValueAt<C, K, F, Forms> | SlotReference<C, K, F, ReferenceForms, "nonNullValue">;
|
|
221
278
|
}>;
|
|
222
279
|
/** The scalar fields selectable at one projection position. */
|
|
223
|
-
type SelectableScalarKey<C extends
|
|
224
|
-
type SelectableRelationKey<C extends
|
|
225
|
-
type IncludeRelationKey<C extends
|
|
280
|
+
type SelectableScalarKey<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope> = KeysWithCapability<C, K, ScalarFieldKeyOf<C, K>, "select", Scope>;
|
|
281
|
+
type SelectableRelationKey<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope> = KeysWithCapability<C, K, RelationFieldKeyOf<C, K>, "select", Scope>;
|
|
282
|
+
type IncludeRelationKey<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope> = KeysWithCapability<C, K, RelationFieldKeyOf<C, K>, "include", Scope>;
|
|
226
283
|
/**
|
|
227
284
|
* Whether `$count` may be asked for inside relation `F`'s projection argument.
|
|
228
285
|
*
|
|
@@ -230,27 +287,27 @@ type IncludeRelationKey<C extends Contract, K extends ResourceKey<C>, Scope exte
|
|
|
230
287
|
* unrestricted scope one level in: `{ posts: { select: ["$count"] } }` is the
|
|
231
288
|
* parent's reducer over `F`, so it sits in the parent's argument position. The
|
|
232
289
|
* target's own projection is a separate question and is unrestricted — see
|
|
233
|
-
* {@link
|
|
290
|
+
* {@link AvRelationProjectionInput}.
|
|
234
291
|
*/
|
|
235
|
-
type RelationAllowsCount<C extends
|
|
236
|
-
type NestedWhereArgument<C extends
|
|
237
|
-
where?:
|
|
292
|
+
type RelationAllowsCount<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Scope extends AvProjectionScope> = RelationCardinality<C, K, F> extends "many" ? HasCapabilityToken<C, K, F, "reducers", Scope, "$count"> : false;
|
|
293
|
+
type NestedWhereArgument<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms> = HasCapabilityToken<C, K, F, "filter", UnrestrictedProjection, "nested"> extends true ? Readonly<{
|
|
294
|
+
where?: AvWhereInput<C, RelationTarget<C, K, F>, Forms>;
|
|
238
295
|
}> : Readonly<Record<never, never>>;
|
|
239
|
-
type NestedOrderArgument<C extends
|
|
240
|
-
orderBy?:
|
|
296
|
+
type NestedOrderArgument<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>> = HasCapability<C, K, F, "order", UnrestrictedProjection> extends true ? Readonly<{
|
|
297
|
+
orderBy?: AvOrderByInput<C, RelationTarget<C, K, F>>;
|
|
241
298
|
}> : Readonly<Record<never, never>>;
|
|
242
|
-
type NestedPaginationArgument<C extends
|
|
243
|
-
cursor?:
|
|
299
|
+
type NestedPaginationArgument<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Capability extends "limit" | "offset" | "cursor", Forms extends ScalarForms> = RelationCardinality<C, K, F> extends "many" ? HasCapabilityToken<C, K, F, "pagination", UnrestrictedProjection, Capability> extends true ? Capability extends "cursor" ? Readonly<{
|
|
300
|
+
cursor?: AvCursorInput<C, RelationTarget<C, K, F>, Forms>;
|
|
244
301
|
}> : Capability extends "limit" ? Readonly<{
|
|
245
302
|
limit?: number;
|
|
246
303
|
}> : Readonly<{
|
|
247
304
|
offset?: number;
|
|
248
305
|
}> : Readonly<Record<never, never>> : Readonly<Record<never, never>>;
|
|
249
|
-
type ProjectionChoice<C extends
|
|
250
|
-
select?:
|
|
306
|
+
type ProjectionChoice<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, AllowCount extends boolean, Forms extends ScalarForms> = Readonly<{
|
|
307
|
+
select?: AvSelectInput<C, K, Scope, AllowCount, Forms>;
|
|
251
308
|
include?: never;
|
|
252
309
|
}> | Readonly<{
|
|
253
|
-
include?:
|
|
310
|
+
include?: AvIncludeInput<C, K, Scope, Forms>;
|
|
254
311
|
select?: never;
|
|
255
312
|
}>;
|
|
256
313
|
/**
|
|
@@ -258,48 +315,48 @@ type ProjectionChoice<C extends Contract, K extends ResourceKey<C>, Scope extend
|
|
|
258
315
|
* applies to this entry only; the related rows' own projection is
|
|
259
316
|
* unrestricted.
|
|
260
317
|
*/
|
|
261
|
-
export type
|
|
318
|
+
export type AvRelationProjectionInput<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K> = RelationFieldKeyOf<C, K>, Scope extends AvProjectionScope = UnrestrictedProjection, Forms extends ScalarForms = UnstatedForms> = F extends RelationFieldKeyOf<C, K> ? Readonly<NestedWhereArgument<C, K, F, Forms> & NestedOrderArgument<C, K, F> & NestedPaginationArgument<C, K, F, "limit", Forms> & NestedPaginationArgument<C, K, F, "offset", Forms> & NestedPaginationArgument<C, K, F, "cursor", Forms> & ProjectionChoice<C, RelationTarget<C, K, F>, UnrestrictedProjection, RelationAllowsCount<C, K, F, Scope>, Forms>> : never;
|
|
262
319
|
/**
|
|
263
320
|
* One relation entry of a projection: exactly relation `F` of `Keys`, with its
|
|
264
321
|
* argument object, and every other key of `Keys` absent.
|
|
265
322
|
*/
|
|
266
|
-
type RelationProjectionEntry<C extends
|
|
267
|
-
readonly [Only in F]:
|
|
323
|
+
type RelationProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Keys extends RelationFieldKeyOf<C, K>, F extends Keys, Scope extends AvProjectionScope, Forms extends ScalarForms> = {
|
|
324
|
+
readonly [Only in F]: AvRelationProjectionInput<C, K, Only & RelationFieldKeyOf<C, K>, Scope, Forms>;
|
|
268
325
|
} & {
|
|
269
326
|
readonly [Other in Exclude<Keys, F>]?: never;
|
|
270
327
|
};
|
|
271
|
-
type SelectRelationProjectionEntry<C extends
|
|
328
|
+
type SelectRelationProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, Forms extends ScalarForms> = {
|
|
272
329
|
[F in SelectableRelationKey<C, K, Scope>]: RelationProjectionEntry<C, K, SelectableRelationKey<C, K, Scope>, F, Scope, Forms>;
|
|
273
330
|
}[SelectableRelationKey<C, K, Scope>];
|
|
274
|
-
type IncludeRelationProjectionEntry<C extends
|
|
331
|
+
type IncludeRelationProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, Forms extends ScalarForms> = {
|
|
275
332
|
[F in IncludeRelationKey<C, K, Scope>]: RelationProjectionEntry<C, K, IncludeRelationKey<C, K, Scope>, F, Scope, Forms>;
|
|
276
333
|
}[IncludeRelationKey<C, K, Scope>];
|
|
277
334
|
/**
|
|
278
335
|
* One entry of a `select` argument, at one projection position. The default is
|
|
279
336
|
* the unrestricted position.
|
|
280
337
|
*/
|
|
281
|
-
export type
|
|
338
|
+
export type AvProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope = UnrestrictedProjection, AllowCount extends boolean = false, Forms extends ScalarForms = UnstatedForms> = SelectableScalarKey<C, K, Scope> | SelectableRelationKey<C, K, Scope> | SelectRelationProjectionEntry<C, K, Scope, Forms> | (AllowCount extends true ? "$count" : never);
|
|
282
339
|
/** A `select` argument: the fields to return. */
|
|
283
|
-
export type
|
|
340
|
+
export type AvSelectInput<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope = UnrestrictedProjection, AllowCount extends boolean = false, Forms extends ScalarForms = UnstatedForms> = readonly AvProjectionEntry<C, K, Scope, AllowCount, Forms>[];
|
|
284
341
|
/** An `include` argument: the relations to return with each row. */
|
|
285
|
-
export type
|
|
342
|
+
export type AvIncludeInput<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope = UnrestrictedProjection, Forms extends ScalarForms = UnstatedForms> = readonly (IncludeRelationKey<C, K, Scope> | IncludeRelationProjectionEntry<C, K, Scope, Forms>)[];
|
|
286
343
|
/** A scalar update directive and its operand, such as `{ $increment: 1 }`. */
|
|
287
|
-
export type ScalarMutationAction = Readonly<Partial<Record<
|
|
344
|
+
export type ScalarMutationAction = Readonly<Partial<Record<AvScalarMutationDirective, unknown>>>;
|
|
288
345
|
/** A relation write: one or more relation directives and their payloads. */
|
|
289
|
-
export type RelationMutationAction = Readonly<Partial<Record<
|
|
346
|
+
export type RelationMutationAction = Readonly<Partial<Record<AvRelationMutationDirective, unknown>>>;
|
|
290
347
|
/** The scalar fields writable at one stage and write position. */
|
|
291
|
-
type WritableScalarKey<C extends
|
|
348
|
+
type WritableScalarKey<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Scope extends AvWriteScope> = KeysWithCapability<C, K, ScalarFieldKeyOf<C, K>, Stage, Scope>;
|
|
292
349
|
/**
|
|
293
350
|
* The relations writable at one stage in one write position. The default is
|
|
294
351
|
* the unrestricted position.
|
|
295
352
|
*/
|
|
296
|
-
export type WritableRelationKey<C extends
|
|
297
|
-
type ManyOrOne<C extends
|
|
353
|
+
export type WritableRelationKey<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Scope extends AvWriteScope = UnrestrictedWrite> = KeysWithCapability<C, K, RelationFieldKeyOf<C, K>, Stage, Scope>;
|
|
354
|
+
type ManyOrOne<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Value> = RelationCardinality<C, K, F> extends "many" ? Value | readonly Value[] : Value;
|
|
298
355
|
/**
|
|
299
356
|
* A `where` of plain fields: each scalar field's filter, combined with
|
|
300
357
|
* `AND`/`OR`/`NOT`, and no relation filter at any depth.
|
|
301
358
|
*/
|
|
302
|
-
type ScalarOnlyWhereInput<C extends
|
|
359
|
+
type ScalarOnlyWhereInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
303
360
|
AND?: readonly ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>[];
|
|
304
361
|
OR?: readonly ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>[];
|
|
305
362
|
NOT?: ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>;
|
|
@@ -308,38 +365,38 @@ type ScalarOnlyWhereInput<C extends Contract, K extends ResourceKey<C>, Forms ex
|
|
|
308
365
|
* The `where` of a nested `$update` or `$delete` through relation `F`: plain fields
|
|
309
366
|
* only where the relation states `nestedWriteFilter: "scalar"`, any filter otherwise.
|
|
310
367
|
*/
|
|
311
|
-
type NestedWriteWhereInput<C extends
|
|
368
|
+
type NestedWriteWhereInput<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = CapabilitiesOf<C, K, F> extends {
|
|
312
369
|
readonly nestedWriteFilter: "scalar";
|
|
313
|
-
} ? ScalarOnlyWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms> :
|
|
314
|
-
type ConnectOrCreateEntry<C extends
|
|
315
|
-
where:
|
|
316
|
-
create:
|
|
370
|
+
} ? ScalarOnlyWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms> : AvWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>;
|
|
371
|
+
type ConnectOrCreateEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
372
|
+
where: AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>;
|
|
373
|
+
create: AvCreateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
317
374
|
}>;
|
|
318
|
-
type ToOneUpdateEntry<C extends
|
|
375
|
+
type ToOneUpdateEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
319
376
|
where?: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
320
|
-
data:
|
|
377
|
+
data: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
321
378
|
}>;
|
|
322
|
-
type ToManyUpdateEntry<C extends
|
|
379
|
+
type ToManyUpdateEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
323
380
|
where: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
324
|
-
data:
|
|
381
|
+
data: AvUpdateDataInput<C, RelationTarget<C, K, F>, "bulkWrite", Forms, ReferenceForms, readonly [K, F]>;
|
|
325
382
|
}>;
|
|
326
|
-
type ToOneDeleteEntry<C extends
|
|
383
|
+
type ToOneDeleteEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = true | Readonly<{
|
|
327
384
|
where?: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
328
385
|
}>;
|
|
329
|
-
type ToManyDeleteEntry<C extends
|
|
386
|
+
type ToManyDeleteEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
330
387
|
where: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
331
388
|
}>;
|
|
332
|
-
type ToOneUpsertEntry<C extends
|
|
333
|
-
where?:
|
|
334
|
-
create:
|
|
335
|
-
update:
|
|
389
|
+
type ToOneUpsertEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
390
|
+
where?: AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>;
|
|
391
|
+
create: AvCreateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
392
|
+
update: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
336
393
|
}>;
|
|
337
|
-
type ToManyUpsertEntry<C extends
|
|
338
|
-
where:
|
|
339
|
-
create:
|
|
340
|
-
update:
|
|
394
|
+
type ToManyUpsertEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
395
|
+
where: AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>;
|
|
396
|
+
create: AvCreateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
397
|
+
update: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
341
398
|
}>;
|
|
342
|
-
type RelationDirectiveValue<C extends
|
|
399
|
+
type RelationDirectiveValue<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Directive extends AvRelationMutationDirective, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Directive extends "$create" ? ManyOrOne<C, K, F, AvCreateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>> : Directive extends "$connect" ? ManyOrOne<C, K, F, AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>> : Directive extends "$connectOrCreate" ? ManyOrOne<C, K, F, ConnectOrCreateEntry<C, K, F, Forms, ReferenceForms>> : Directive extends "$disconnect" ? RelationCardinality<C, K, F> extends "one" ? true : AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms> | readonly AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>[] : Directive extends "$set" ? RelationCardinality<C, K, F> extends "one" ? AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms> | null : readonly AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>[] : Directive extends "$update" ? RelationCardinality<C, K, F> extends "one" ? ToOneUpdateEntry<C, K, F, Forms, ReferenceForms> : ManyOrOne<C, K, F, ToManyUpdateEntry<C, K, F, Forms, ReferenceForms>> : Directive extends "$delete" ? RelationCardinality<C, K, F> extends "one" ? ToOneDeleteEntry<C, K, F, Forms, ReferenceForms> : ManyOrOne<C, K, F, ToManyDeleteEntry<C, K, F, Forms, ReferenceForms>> : Directive extends "$upsert" ? RelationCardinality<C, K, F> extends "one" ? ToOneUpsertEntry<C, K, F, Forms, ReferenceForms> : ManyOrOne<C, K, F, ToManyUpsertEntry<C, K, F, Forms, ReferenceForms>> : never;
|
|
343
400
|
declare const NO_ADVERTISED_MEMBER: unique symbol;
|
|
344
401
|
/**
|
|
345
402
|
* A write member that advertises nothing: it accepts `{}` and refuses every key.
|
|
@@ -349,126 +406,205 @@ type NoAdvertisedMember = {
|
|
|
349
406
|
};
|
|
350
407
|
/** `Write`, or {@link NoAdvertisedMember} when `Write` has no keys at all. */
|
|
351
408
|
type RefuseEveryKeyWhenEmpty<Write> = [keyof Write] extends [never] ? NoAdvertisedMember : Write;
|
|
352
|
-
type RelationMutationActionFor<C extends
|
|
353
|
-
[Directive in Extract<CapabilityTokens<C, K, F, Stage, Scope>,
|
|
409
|
+
type RelationMutationActionFor<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = RefuseEveryKeyWhenEmpty<Readonly<Partial<{
|
|
410
|
+
[Directive in Extract<CapabilityTokens<C, K, F, Stage, Scope>, AvRelationMutationDirective>]: RelationDirectiveValue<C, K, F, Directive, Forms, ReferenceForms>;
|
|
354
411
|
}>>>;
|
|
355
412
|
/**
|
|
356
413
|
* One scalar mutation directive's operand: one entry of the field (`$push` on a
|
|
357
414
|
* list also takes a list of them). `$unset`'s operand is passed to the adapter as
|
|
358
415
|
* given.
|
|
359
416
|
*/
|
|
360
|
-
type ScalarDirectiveOperand<C extends
|
|
417
|
+
type ScalarDirectiveOperand<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Directive extends AvScalarMutationDirective, Forms extends ScalarForms> = Directive extends "$unset" ? unknown : Directive extends "$push" ? [ScalarFieldAt<C, K, F>["list"]] extends [false] ? ScalarAtomAt<C, K, F, Forms> : ScalarAtomAt<C, K, F, Forms> | readonly ScalarAtomAt<C, K, F, Forms>[] : ScalarAtomAt<C, K, F, Forms>;
|
|
361
418
|
/**
|
|
362
419
|
* The directive object a scalar field accepts at one stage, or `never` when it
|
|
363
420
|
* advertises no directive.
|
|
364
421
|
*/
|
|
365
|
-
type ScalarMutationActionFor<C extends
|
|
366
|
-
Extract<CapabilityTokens<C, K, F, Stage, Scope>,
|
|
367
|
-
] extends [never] ? never :
|
|
368
|
-
|
|
369
|
-
|
|
422
|
+
type ScalarMutationActionFor<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms> = [
|
|
423
|
+
Extract<CapabilityTokens<C, K, F, Stage, Scope>, AvScalarMutationDirective>
|
|
424
|
+
] extends [never] ? never : OneDirective<Extract<CapabilityTokens<C, K, F, Stage, Scope>, AvScalarMutationDirective>, C, K, F, Forms>;
|
|
425
|
+
type OneDirective<Tokens extends AvScalarMutationDirective, C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Forms extends ScalarForms> = {
|
|
426
|
+
[Directive in Tokens]: Readonly<{
|
|
427
|
+
[Key in Directive]: ScalarDirectiveOperand<C, K, F, Key, Forms>;
|
|
428
|
+
} & {
|
|
429
|
+
[Other in Exclude<Tokens, Directive>]?: never;
|
|
430
|
+
}>;
|
|
431
|
+
}[Tokens];
|
|
370
432
|
/**
|
|
371
433
|
* Each writable scalar takes its value under `Forms`, or a directive object of
|
|
372
434
|
* the directives it advertises at this stage — or, in a transaction plan's
|
|
373
435
|
* top-level data, a `$ref` to a source of the same type.
|
|
374
436
|
*/
|
|
375
|
-
type ScalarMutationFields<C extends
|
|
376
|
-
[F in WritableScalarKey<C, K, Stage, Scope
|
|
437
|
+
type ScalarMutationFields<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms, ReferenceForms extends ScalarForms, Via extends ParentEdge = never> = Readonly<{
|
|
438
|
+
[F in Exclude<WritableScalarKey<C, K, Stage, Scope>, LoopbackRefused<C, K, Stage, Via>>]?: ScalarValueAt<C, K, F, Forms> | ScalarMutationActionFor<C, K, F, Stage, Scope, Forms> | SlotReference<C, K, F, ReferenceForms, "value">;
|
|
377
439
|
}>;
|
|
378
|
-
type RelationMutationFields<C extends
|
|
379
|
-
[F in WritableRelationKey<C, K, Stage, Scope
|
|
440
|
+
type RelationMutationFields<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms, ReferenceForms extends ScalarForms, Via extends ParentEdge = never> = Readonly<{
|
|
441
|
+
[F in Exclude<WritableRelationKey<C, K, Stage, Scope>, LoopbackRefused<C, K, Stage, Via>>]?: RelationMutationActionFor<C, K, F & RelationFieldKeyOf<C, K>, Stage, Scope, Forms, ReferenceForms>;
|
|
380
442
|
}>;
|
|
443
|
+
/** A relation edge a nested create is reached through: `[parent, relation]`. */
|
|
444
|
+
type ParentEdge = readonly [string, string];
|
|
445
|
+
/** The other end of `Via`'s relation, as the Contract pairs it; `never` when it does not. */
|
|
446
|
+
type LoopbackOf<C extends AvContract, Via> = Via extends readonly [
|
|
447
|
+
infer Parent,
|
|
448
|
+
infer Relation
|
|
449
|
+
] ? Parent extends AvResourceKey<C> ? Relation extends keyof C["resources"][Parent]["fields"] ? C["resources"][Parent]["fields"][Relation] extends {
|
|
450
|
+
readonly inverse: infer Inverse extends string;
|
|
451
|
+
} ? Inverse : never : never : never : never;
|
|
452
|
+
/** The fields `K`'s relation `Relation` states hold its reference; `never` when it states none. */
|
|
453
|
+
type ReferenceFieldsOf<C extends AvContract, K extends AvResourceKey<C>, Relation extends string> = Relation extends keyof C["resources"][K]["fields"] ? C["resources"][K]["fields"][Relation] extends {
|
|
454
|
+
readonly referenceFields: readonly (infer Field extends string)[];
|
|
455
|
+
} ? Field : never : never;
|
|
456
|
+
/**
|
|
457
|
+
* The members a record of `K` reached through `Via` cannot write at `Stage`:
|
|
458
|
+
* the other end of `Via`'s relation and the fields that hold its reference,
|
|
459
|
+
* unless the Contract admits that relation at the `"loopback"` position.
|
|
460
|
+
*/
|
|
461
|
+
type LoopbackRefused<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Via> = [Via] extends [never] ? never : LoopbackOf<C, Via> extends infer Loopback extends string ? [
|
|
462
|
+
Extract<Loopback, WritableRelationKey<C, K, Stage, "loopback">>
|
|
463
|
+
] extends [never] ? Loopback | ReferenceFieldsOf<C, K, Loopback> : never : never;
|
|
464
|
+
/** The names a requirement list holds; `never` when the member is absent. */
|
|
465
|
+
type RequirementNames<Requirements, Member extends PropertyKey> = Requirements extends {
|
|
466
|
+
readonly [P in Member]?: infer List;
|
|
467
|
+
} ? List extends readonly (infer Name)[] ? Name : never : never;
|
|
468
|
+
/** Resource `K`'s create requirements, or `never` when its Contract states none. */
|
|
469
|
+
type CreateRequirementsAt<C extends AvContract, K extends AvResourceKey<C>> = "createRequirements" extends keyof C["resources"][K] ? Exclude<C["resources"][K]["createRequirements"], undefined> : never;
|
|
470
|
+
/** The names a create nested through `Via` gets from its parent. */
|
|
471
|
+
type SuppliedThrough<Requirements, Via> = Via extends readonly [
|
|
472
|
+
infer Parent,
|
|
473
|
+
infer Relation
|
|
474
|
+
] ? Requirements extends {
|
|
475
|
+
readonly parentSupplies?: infer Supplies;
|
|
476
|
+
} ? Parent extends keyof Supplies ? Relation extends keyof NonNullable<Supplies[Parent]> ? NonNullable<Supplies[Parent]>[Relation] extends readonly (infer Name)[] ? Name : never : never : never : never : never;
|
|
477
|
+
/** A value that is written: anything but `undefined`. */
|
|
478
|
+
type WrittenValue = NonNullable<unknown> | null;
|
|
479
|
+
/** Keys that must be present: `never` names none. */
|
|
480
|
+
type Present<Keys extends PropertyKey> = [Keys] extends [never] ? unknown : {
|
|
481
|
+
readonly [P in Keys]: WrittenValue;
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* One required relation's group: the relation alone, or every reference field
|
|
485
|
+
* together, never both — where this position can write both; the relation
|
|
486
|
+
* alone where it can write the relation but not every reference field; every
|
|
487
|
+
* reference field where it cannot write the relation (a bulk record); nothing
|
|
488
|
+
* where the parent supplies the group.
|
|
489
|
+
*/
|
|
490
|
+
type GroupPresence<Group, Scalars, Relations, Supplied> = Group extends readonly [
|
|
491
|
+
infer Relation extends string,
|
|
492
|
+
...infer References extends readonly string[]
|
|
493
|
+
] ? string extends Relation ? unknown : [References[number]] extends [never] ? unknown : [Extract<Relation | References[number], Supplied>] extends [never] ? Relation extends Relations ? [Exclude<References[number], Scalars>] extends [never] ? (Present<Relation> & {
|
|
494
|
+
readonly [P in References[number]]?: never;
|
|
495
|
+
}) | (Present<References[number]> & {
|
|
496
|
+
readonly [P in Relation]?: never;
|
|
497
|
+
}) : Present<Relation> : Present<References[number]> : unknown : unknown;
|
|
498
|
+
/** Every group of a `oneOf` tuple, each one's presence intersected. */
|
|
499
|
+
type GroupsPresence<Groups, Scalars, Relations, Supplied> = Groups extends readonly [infer Group, ...infer Rest] ? GroupPresence<Group, Scalars, Relations, Supplied> & GroupsPresence<Rest, Scalars, Relations, Supplied> : unknown;
|
|
500
|
+
/**
|
|
501
|
+
* What a create of Resource `K` at write position `Scope` must and must not
|
|
502
|
+
* write: every `required` name it can write, and one side of every `oneOf`
|
|
503
|
+
* group — less what the parent supplies when the create is nested through
|
|
504
|
+
* `Via`. `unknown` (no constraint) when the Contract states nothing.
|
|
505
|
+
*/
|
|
506
|
+
type CreateRequirementPresence<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvWriteScope, Via> = [CreateRequirementsAt<C, K>] extends [never] ? unknown : CreateRequirementsAt<C, K> extends infer Requirements ? string extends RequirementNames<Requirements, "required"> ? unknown : Present<Exclude<Extract<RequirementNames<Requirements, "required">, WritableScalarKey<C, K, "create", Scope> | WritableRelationKey<C, K, "create", Scope>>, SuppliedThrough<Requirements, Via>>> & (Requirements extends {
|
|
507
|
+
readonly oneOf?: infer Groups;
|
|
508
|
+
} ? GroupsPresence<Groups, WritableScalarKey<C, K, "create", Scope>, WritableRelationKey<C, K, "create", Scope>, SuppliedThrough<Requirements, Via>> : unknown) : unknown;
|
|
381
509
|
/**
|
|
382
510
|
* A `create` data argument, at one write position. A write position applies
|
|
383
511
|
* to the top level only; nested writes use the unrestricted position (see
|
|
384
|
-
* {@link
|
|
385
|
-
* positions
|
|
386
|
-
*
|
|
512
|
+
* {@link AvWriteScope}). `ReferenceForms` opens a transaction plan's reference
|
|
513
|
+
* positions (its scalar values and the unique keys its relation directives name)
|
|
514
|
+
* and is never passed to nested data, which holds none.
|
|
515
|
+
*
|
|
516
|
+
* Every field the Contract's `createRequirements` names must be written, and
|
|
517
|
+
* one side of every required relation's group — the relation, or all of its
|
|
518
|
+
* reference fields — never both. `Via` is the `[parent, relation]` a nested
|
|
519
|
+
* create is reached through: what that parent supplies is not required.
|
|
520
|
+
*/
|
|
521
|
+
export type AvCreateDataInput<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvWriteScope = UnrestrictedWrite, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never, Via extends ParentEdge = never> = RefuseEveryKeyWhenEmpty<Readonly<ScalarMutationFields<C, K, "create", Scope, Forms, ReferenceForms, Via> & RelationMutationFields<C, K, "create", Scope, Forms, ReferenceForms, Via>>> & CreateRequirementPresence<C, K, Scope, Via>;
|
|
522
|
+
/**
|
|
523
|
+
* An `update` data argument, at one write position. See {@link AvCreateDataInput};
|
|
524
|
+
* `Via` is the `[parent, relation]` a nested update is reached through.
|
|
387
525
|
*/
|
|
388
|
-
export type
|
|
389
|
-
|
|
390
|
-
export type UpdateDataInput<C extends Contract, K extends ResourceKey<C>, Scope extends WriteScope = UnrestrictedWrite, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = RefuseEveryKeyWhenEmpty<Readonly<ScalarMutationFields<C, K, "update", Scope, Forms, ReferenceForms> & RelationMutationFields<C, K, "update", Scope, Forms, ReferenceForms>>>;
|
|
391
|
-
type QueryProjectionArgs<C extends Contract, K extends ResourceKey<C>, Scope extends ProjectionScope, Forms extends ScalarForms> = ProjectionChoice<C, K, Scope, false, Forms>;
|
|
526
|
+
export type AvUpdateDataInput<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvWriteScope = UnrestrictedWrite, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never, Via extends ParentEdge = never> = RefuseEveryKeyWhenEmpty<Readonly<ScalarMutationFields<C, K, "update", Scope, Forms, ReferenceForms, Via> & RelationMutationFields<C, K, "update", Scope, Forms, ReferenceForms, Via>>>;
|
|
527
|
+
type QueryProjectionArgs<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, Forms extends ScalarForms> = ProjectionChoice<C, K, Scope, false, Forms>;
|
|
392
528
|
/**
|
|
393
529
|
* Every standard operation's argument object, with each argument at its
|
|
394
530
|
* projection or write position.
|
|
395
531
|
*/
|
|
396
|
-
export type
|
|
532
|
+
export type AvOperationArgumentMap<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = {
|
|
397
533
|
find: {
|
|
398
534
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
399
|
-
where?:
|
|
400
|
-
orderBy?:
|
|
535
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
536
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
401
537
|
};
|
|
402
538
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
403
|
-
where:
|
|
539
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
404
540
|
};
|
|
405
541
|
many: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
406
|
-
where?:
|
|
407
|
-
orderBy?:
|
|
542
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
543
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
408
544
|
limit?: number;
|
|
409
545
|
offset?: number;
|
|
410
|
-
cursor?:
|
|
546
|
+
cursor?: AvCursorInput<C, K, Forms, ReferenceForms>;
|
|
411
547
|
};
|
|
412
548
|
count: {
|
|
413
|
-
where?:
|
|
549
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
414
550
|
};
|
|
415
551
|
};
|
|
416
552
|
create: {
|
|
417
553
|
one: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
418
|
-
data:
|
|
554
|
+
data: AvCreateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
419
555
|
};
|
|
420
556
|
many: QueryProjectionArgs<C, K, "bulkWrite", Forms> & {
|
|
421
|
-
data: readonly
|
|
557
|
+
data: readonly AvCreateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>[];
|
|
422
558
|
};
|
|
423
559
|
count: {
|
|
424
|
-
data: readonly
|
|
560
|
+
data: readonly AvCreateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>[];
|
|
425
561
|
};
|
|
426
562
|
};
|
|
427
563
|
update: {
|
|
428
564
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
429
|
-
where?:
|
|
430
|
-
orderBy?:
|
|
431
|
-
data:
|
|
565
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
566
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
567
|
+
data: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
432
568
|
};
|
|
433
569
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
434
|
-
where:
|
|
435
|
-
data:
|
|
570
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
571
|
+
data: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
436
572
|
};
|
|
437
573
|
many: QueryProjectionArgs<C, K, "bulkWrite", Forms> & {
|
|
438
|
-
where?:
|
|
439
|
-
data:
|
|
574
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
575
|
+
data: AvUpdateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>;
|
|
440
576
|
};
|
|
441
577
|
count: {
|
|
442
|
-
where?:
|
|
443
|
-
data:
|
|
578
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
579
|
+
data: AvUpdateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>;
|
|
444
580
|
};
|
|
445
581
|
};
|
|
446
582
|
delete: {
|
|
447
583
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
448
|
-
where?:
|
|
449
|
-
orderBy?:
|
|
584
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
585
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
450
586
|
};
|
|
451
587
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
452
|
-
where:
|
|
588
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
453
589
|
};
|
|
454
590
|
many: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
455
|
-
where?:
|
|
591
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
456
592
|
};
|
|
457
593
|
count: {
|
|
458
|
-
where?:
|
|
594
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
459
595
|
};
|
|
460
596
|
};
|
|
461
597
|
upsert: {
|
|
462
598
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
463
|
-
where:
|
|
464
|
-
create:
|
|
465
|
-
update:
|
|
599
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
600
|
+
create: AvCreateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
601
|
+
update: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
466
602
|
};
|
|
467
603
|
};
|
|
468
604
|
};
|
|
469
605
|
/** One standard operation's argument object. */
|
|
470
|
-
export type
|
|
606
|
+
export type AvOperationArgumentsFor<C extends AvContract, K extends AvResourceKey<C>, I extends AvOperationIdentity, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = I extends {
|
|
471
607
|
family: infer F;
|
|
472
608
|
variant: infer V;
|
|
473
|
-
} ? F extends keyof
|
|
609
|
+
} ? F extends keyof AvOperationArgumentMap<C, K, Forms, ReferenceForms> ? V extends keyof AvOperationArgumentMap<C, K, Forms, ReferenceForms>[F] ? AvOperationArgumentMap<C, K, Forms, ReferenceForms>[F][V] : never : never : never;
|
|
474
610
|
export {};
|