@aventara/core 1.0.0-rc.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1140 -0
- package/README.md +224 -57
- package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
- package/dist/adapters/adapter-field.d.ts +11 -11
- package/dist/adapters/adapter-identifier.d.ts +6 -6
- package/dist/adapters/adapter-model.d.ts +9 -9
- package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
- package/dist/adapters/adapter-operation.d.ts +3 -3
- package/dist/adapters/adapter-resource.d.ts +18 -9
- package/dist/adapters/adapter-sql-statement.d.ts +19 -0
- package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
- package/dist/adapters/adapter.interface.d.ts +49 -29
- package/dist/avz/avz-check.factory.d.ts +83 -0
- package/dist/avz/avz-check.factory.js +116 -0
- package/dist/avz/avz-check.registry.d.ts +35 -0
- package/dist/avz/avz-check.registry.js +9 -0
- package/dist/avz/avz.d.ts +203 -0
- package/dist/{json → avz}/avz.js +150 -8
- package/dist/{json → avz}/index.d.ts +2 -1
- package/dist/{json → avz}/json-shape.registry.d.ts +7 -7
- package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
- package/dist/{json → avz}/zod-issue.translator.js +7 -0
- package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
- package/dist/compiler/contract.compiler.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +548 -441
- package/dist/compiler/create-requirements.projector.d.ts +49 -0
- package/dist/compiler/create-requirements.projector.js +423 -0
- package/dist/compiler/field-validator.compiler.d.ts +47 -0
- package/dist/compiler/field-validator.compiler.js +238 -0
- package/dist/config/any-framework-config.d.ts +19 -12
- package/dist/config/config-diagnostic.d.ts +11 -4
- package/dist/config/config-layer.d.ts +15 -6
- package/dist/config/config.resolver.d.ts +74 -31
- package/dist/config/config.resolver.js +108 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +581 -72
- package/dist/config/define-resource.d.ts +57 -0
- package/dist/config/define-resource.js +14 -0
- package/dist/config/effective-fields.d.ts +19 -23
- package/dist/config/entrypoint.normalizer.d.ts +1 -1
- package/dist/config/exact-framework-config.d.ts +280 -0
- package/dist/config/field-compute.resolver.d.ts +19 -0
- package/dist/config/field-compute.resolver.js +115 -0
- package/dist/config/field-pipeline-config.d.ts +47 -0
- package/dist/config/forced-operation.validator.d.ts +10 -0
- package/dist/config/forced-operation.validator.js +66 -0
- package/dist/config/framework-config.d.ts +110 -39
- package/dist/config/framework-exemptions-config.d.ts +91 -0
- package/dist/config/framework-exemptions-config.js +1 -0
- package/dist/config/framework-field-definition.d.ts +78 -0
- package/dist/config/framework-field-definition.js +28 -0
- package/dist/config/framework-resources-config.d.ts +116 -0
- package/dist/config/framework-resources-config.js +1 -0
- package/dist/config/pipeline-config.d.ts +56 -20
- package/dist/config/pipeline-tree.resolver.d.ts +79 -0
- package/dist/config/pipeline-tree.resolver.js +220 -0
- package/dist/config/stage-type.eraser.d.ts +65 -0
- package/dist/config/stage-type.eraser.js +1 -0
- package/dist/contracts/capability.d.ts +11 -11
- package/dist/contracts/client-contract-structure.validator.d.ts +323 -28
- package/dist/contracts/client-contract-structure.validator.js +152 -8
- package/dist/contracts/contract-canonicalizer.d.ts +19 -3
- package/dist/contracts/contract-canonicalizer.js +141 -28
- package/dist/contracts/contract-hash.d.ts +12 -7
- package/dist/contracts/contract-hash.js +3 -2
- package/dist/contracts/contract-limits.d.ts +4 -1
- package/dist/contracts/contract-limits.js +1 -0
- package/dist/contracts/contract-lookup.d.ts +5 -5
- package/dist/contracts/contract-protocol.d.ts +4 -4
- package/dist/contracts/contract.d.ts +24 -16
- package/dist/contracts/create-requirements.d.ts +35 -0
- package/dist/contracts/create-requirements.js +1 -0
- package/dist/contracts/enum-definition.d.ts +1 -1
- package/dist/contracts/field-check.d.ts +101 -0
- package/dist/contracts/field-check.js +1 -0
- package/dist/contracts/field.d.ts +52 -42
- package/dist/contracts/identifier.d.ts +4 -4
- package/dist/contracts/json-shape.d.ts +12 -1
- package/dist/contracts/lifecycle-trait.d.ts +2 -2
- package/dist/contracts/resource-operations.d.ts +28 -28
- package/dist/contracts/resource.d.ts +15 -9
- package/dist/contracts/scalar-value-type.d.ts +15 -15
- package/dist/contracts/scalar.d.ts +3 -3
- package/dist/contracts/transaction-capability.d.ts +1 -1
- package/dist/contracts/wire-scalar-format.d.ts +4 -4
- package/dist/framework/contract-view.d.ts +213 -147
- package/dist/framework/framework-construction.error.d.ts +10 -10
- package/dist/framework/framework-construction.error.js +2 -2
- package/dist/framework/framework.d.ts +47 -23
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +40 -20
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +55 -50
- package/dist/index.js +6 -6
- package/dist/internal.d.ts +15 -10
- package/dist/internal.js +3 -1
- package/dist/operations/operation-arguments.d.ts +267 -202
- package/dist/operations/operation-call.d.ts +27 -28
- package/dist/operations/operation-identity.d.ts +10 -10
- package/dist/operations/operation-result.d.ts +21 -21
- package/dist/operations/operation-validator-core.d.ts +6 -6
- package/dist/operations/operation-validator-core.js +13 -2
- package/dist/operations/operation-validator.d.ts +9 -9
- package/dist/operations/projection-scope.resolver.d.ts +6 -6
- package/dist/operations/structural-limits.walker.d.ts +6 -6
- package/dist/operations/structural-limits.walker.js +145 -0
- package/dist/operations/validation-code.d.ts +11 -6
- package/dist/operations/validation-code.js +4 -0
- package/dist/operations/write-scope.resolver.d.ts +6 -6
- package/dist/protocol/absent-route.responder.d.ts +13 -12
- package/dist/protocol/absent-route.responder.js +19 -19
- package/dist/protocol/contract-document.responder.d.ts +3 -3
- package/dist/protocol/contract-document.responder.js +2 -2
- package/dist/protocol/http-request.decoder.d.ts +17 -13
- package/dist/protocol/http-request.decoder.js +10 -10
- package/dist/protocol/http-request.reader.d.ts +3 -3
- package/dist/protocol/http-response.encoder.d.ts +4 -4
- package/dist/protocol/http-response.encoder.js +94 -55
- package/dist/protocol/http-status.table.d.ts +2 -2
- package/dist/protocol/operation-response.guard.d.ts +2 -2
- package/dist/protocol/protocol-surface.d.ts +4 -4
- package/dist/protocol/protocol.binder.d.ts +50 -27
- package/dist/protocol/protocol.binder.js +12 -9
- package/dist/protocol/protocol.handler.d.ts +22 -13
- package/dist/protocol/protocol.handler.js +44 -9
- package/dist/protocol/unmounted-route.error.d.ts +4 -4
- package/dist/protocol/unmounted-route.error.js +2 -2
- package/dist/runtime/caller-data.copier.d.ts +5 -5
- package/dist/runtime/caller-data.copier.js +13 -13
- package/dist/runtime/caller-data.door.d.ts +6 -6
- package/dist/runtime/caller-data.door.js +6 -4
- package/dist/runtime/computed-read-runtime.d.ts +7 -6
- package/dist/runtime/computed-read-runtime.js +61 -48
- package/dist/runtime/computed-value.error.d.ts +6 -6
- package/dist/runtime/computed-value.error.js +3 -3
- package/dist/runtime/context-executor.runtime.d.ts +59 -0
- package/dist/runtime/context-executor.runtime.js +275 -0
- package/dist/runtime/create-requirement.d.ts +10 -81
- package/dist/runtime/create-requirement.js +80 -57
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +53 -27
- package/dist/runtime/diagnostics-reporter.js +24 -0
- package/dist/runtime/error-boundary.d.ts +65 -8
- package/dist/runtime/error-boundary.js +45 -19
- package/dist/runtime/execution-options.d.ts +10 -2
- package/dist/runtime/field-check.evaluator.d.ts +29 -0
- package/dist/runtime/field-check.evaluator.js +521 -0
- package/dist/runtime/field-compute.d.ts +64 -0
- package/dist/runtime/field-compute.js +1 -0
- package/dist/runtime/field-stage.plan.d.ts +15 -0
- package/dist/runtime/field-stage.plan.js +27 -0
- package/dist/runtime/field-stage.runtime.d.ts +35 -0
- package/dist/runtime/field-stage.runtime.js +143 -0
- package/dist/runtime/field-validator.runtime.d.ts +11 -0
- package/dist/runtime/field-validator.runtime.js +87 -0
- package/dist/runtime/framework-error-class.table.d.ts +33 -0
- package/dist/runtime/framework-error-class.table.js +25 -0
- package/dist/runtime/framework-error.d.ts +68 -8
- package/dist/runtime/framework-error.factory.d.ts +4 -0
- package/dist/runtime/framework-error.factory.js +15 -0
- package/dist/runtime/framework-error.js +23 -2
- package/dist/runtime/interceptor-next.error.d.ts +5 -0
- package/dist/runtime/interceptor-next.error.js +6 -0
- package/dist/runtime/json-value.d.ts +3 -3
- package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
- package/dist/runtime/level-lifecycle.runtime.js +42 -0
- package/dist/runtime/misuse-reporter.d.ts +12 -12
- package/dist/runtime/mutation-planner.d.ts +19 -10
- package/dist/runtime/mutation-planner.js +54 -30
- package/dist/runtime/nested-write.walker.d.ts +32 -0
- package/dist/runtime/nested-write.walker.js +73 -0
- package/dist/runtime/operation-request.d.ts +33 -6
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +113 -25
- package/dist/runtime/operation-runtime.js +395 -74
- package/dist/runtime/outcome-mapper.d.ts +16 -5
- package/dist/runtime/outcome-mapper.js +23 -6
- package/dist/runtime/output-validator.d.ts +10 -10
- package/dist/runtime/output-validator.js +3 -3
- package/dist/runtime/owned-execution.registry.d.ts +6 -6
- package/dist/runtime/pipe-output.validator.d.ts +33 -18
- package/dist/runtime/pipe-output.validator.js +12 -12
- package/dist/runtime/pipeline.d.ts +196 -34
- package/dist/runtime/readonly-value.d.ts +32 -0
- package/dist/runtime/readonly-value.js +141 -0
- package/dist/runtime/request-envelope.validator.d.ts +3 -3
- package/dist/runtime/request-envelope.validator.js +12 -7
- package/dist/runtime/request-id.d.ts +1 -1
- package/dist/runtime/request-state.d.ts +14 -0
- package/dist/runtime/request-state.js +1 -0
- package/dist/runtime/request-state.resolver.d.ts +12 -0
- package/dist/runtime/request-state.resolver.js +20 -0
- package/dist/runtime/scalar-runtime.d.ts +31 -16
- package/dist/runtime/scalar-runtime.js +16 -18
- package/dist/transactions/deferred-operation.d.ts +35 -20
- package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
- package/dist/transactions/operation-arguments-encoder.js +2 -2
- package/dist/transactions/sql-statement.d.ts +77 -0
- package/dist/transactions/sql-statement.js +47 -0
- package/dist/transactions/sql-statement.validator.d.ts +44 -0
- package/dist/transactions/sql-statement.validator.js +134 -0
- package/dist/transactions/transaction-envelope.d.ts +4 -4
- package/dist/transactions/transaction-integrity-error.d.ts +6 -6
- package/dist/transactions/transaction-integrity-error.js +5 -2
- package/dist/transactions/transaction-plan-assembler.d.ts +21 -11
- package/dist/transactions/transaction-plan-assembler.js +148 -34
- package/dist/transactions/transaction-plan-validator.d.ts +29 -20
- package/dist/transactions/transaction-plan-validator.js +70 -38
- package/dist/transactions/transaction-reference-collector.d.ts +5 -5
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +26 -14
- package/dist/transactions/transaction-reference-validator.d.ts +34 -4
- package/dist/transactions/transaction-reference-validator.js +58 -26
- package/dist/transactions/transaction-reference.d.ts +13 -13
- package/dist/transactions/transaction-request.d.ts +18 -5
- package/dist/transactions/transaction-response.d.ts +6 -6
- package/dist/transactions/transaction-runtime.d.ts +8 -7
- package/dist/transactions/transaction-runtime.js +166 -50
- package/dist/transactions/transaction-settlement.runtime.d.ts +51 -0
- package/dist/transactions/transaction-settlement.runtime.js +120 -0
- package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
- package/dist/transactions/transaction-slot-path-error.js +2 -2
- package/dist/transactions/transaction-slot-writer.js +2 -2
- package/dist/transactions/transaction-stage.runtime.d.ts +81 -0
- package/dist/transactions/transaction-stage.runtime.js +123 -0
- package/package.json +6 -5
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -42
- package/dist/config/define-fields.js +0 -3
- package/dist/config/framework-behaviors-config.d.ts +0 -30
- package/dist/config/framework-fields-config.d.ts +0 -42
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/json/avz.d.ts +0 -96
- package/dist/runtime/field-behavior.d.ts +0 -48
- /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
- /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
- /package/dist/{json → avz}/index.js +0 -0
- /package/dist/{json → avz}/json-shape.registry.js +0 -0
- /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
- /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
|
@@ -1,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 } 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;
|
|
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,77 @@ 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
|
-
* operands take `null`. Inside a
|
|
111
|
-
* `isEmpty`, `path` and the `json`
|
|
112
|
-
* (`References`).
|
|
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`, `isEmpty` and `path` are passed to the adapter as given.
|
|
110
|
+
* Only `equals`, `not` and the `json` `array*` operands take `null`. Inside a
|
|
111
|
+
* transaction plan every operand but `mode`, `isEmpty`, `path` and the `json`
|
|
112
|
+
* ones may be a `$ref` of the shape it holds (`References`).
|
|
113
113
|
*/
|
|
114
|
-
type
|
|
115
|
-
equals
|
|
116
|
-
not
|
|
117
|
-
in
|
|
118
|
-
notIn
|
|
119
|
-
lt
|
|
120
|
-
lte
|
|
121
|
-
gt
|
|
122
|
-
gte
|
|
123
|
-
contains
|
|
124
|
-
startsWith
|
|
125
|
-
endsWith
|
|
126
|
-
mode
|
|
127
|
-
has
|
|
128
|
-
hasEvery
|
|
129
|
-
hasSome
|
|
130
|
-
isEmpty
|
|
131
|
-
path
|
|
132
|
-
stringContains
|
|
133
|
-
stringStartsWith
|
|
134
|
-
stringEndsWith
|
|
135
|
-
arrayContains
|
|
136
|
-
arrayStartsWith
|
|
137
|
-
arrayEndsWith
|
|
138
|
-
}
|
|
114
|
+
type ScalarFilterOperands<Value, Atom, Json, References extends Readonly<Record<TransactionSlotShape, unknown>>, Operator extends AvScalarFilterOperator> = {
|
|
115
|
+
equals: Value | References["value"];
|
|
116
|
+
not: ("equals" extends Operator ? Exclude<Value, JsonObject> | References["value"] : never) | ScalarFilterOperators<Value, Atom, Json, References, Operator>;
|
|
117
|
+
in: readonly Atom[] | References["entries"];
|
|
118
|
+
notIn: readonly Atom[] | References["entries"];
|
|
119
|
+
lt: Exclude<Value, null> | References["nonNullValue"];
|
|
120
|
+
lte: Exclude<Value, null> | References["nonNullValue"];
|
|
121
|
+
gt: Exclude<Value, null> | References["nonNullValue"];
|
|
122
|
+
gte: Exclude<Value, null> | References["nonNullValue"];
|
|
123
|
+
contains: Exclude<Value, null> | References["nonNullValue"];
|
|
124
|
+
startsWith: Exclude<Value, null> | References["nonNullValue"];
|
|
125
|
+
endsWith: Exclude<Value, null> | References["nonNullValue"];
|
|
126
|
+
mode: unknown;
|
|
127
|
+
has: Atom | References["entry"];
|
|
128
|
+
hasEvery: readonly Atom[] | References["entries"];
|
|
129
|
+
hasSome: readonly Atom[] | References["entries"];
|
|
130
|
+
isEmpty: unknown;
|
|
131
|
+
path: unknown;
|
|
132
|
+
stringContains: Exclude<Json, null>;
|
|
133
|
+
stringStartsWith: Exclude<Json, null>;
|
|
134
|
+
stringEndsWith: Exclude<Json, null>;
|
|
135
|
+
arrayContains: Json;
|
|
136
|
+
arrayStartsWith: Json;
|
|
137
|
+
arrayEndsWith: Json;
|
|
138
|
+
};
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* be a `$ref` (see {@link TransactionSlotShape}): equality to a source nullable only
|
|
143
|
-
* where the field is, a comparison to a non-null source, `in` and the list operators
|
|
144
|
-
* to a list source, `has` to one entry.
|
|
140
|
+
* A scalar filter's operator object: the operators `Operator` names — the ones
|
|
141
|
+
* the field's `filter` member advertises — each with its operand.
|
|
145
142
|
*/
|
|
146
|
-
type
|
|
143
|
+
type ScalarFilterOperators<Value, Atom, Json, References extends Readonly<Record<TransactionSlotShape, unknown>>, Operator extends AvScalarFilterOperator> = Readonly<Partial<Pick<ScalarFilterOperands<Value, Atom, Json, References, Operator>, Operator>>>;
|
|
144
|
+
/** The filter operators field `F` advertises: `never` when it advertises none. */
|
|
145
|
+
type ScalarFilterOperatorAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = Extract<CapabilityTokens<C, K, F, "filter", UnrestrictedProjection>, AvScalarFilterOperator>;
|
|
146
|
+
/**
|
|
147
|
+
* One scalar field's filter under `Forms`: a shorthand value where the field
|
|
148
|
+
* advertises `equals`, or an object of the operators it advertises. Inside a
|
|
149
|
+
* transaction plan the value and every operand that holds a field value may be a
|
|
150
|
+
* `$ref` (see {@link TransactionSlotShape}): equality to a source nullable only
|
|
151
|
+
* where the field is, a comparison to a non-null source, `in` and the list
|
|
152
|
+
* operators to a list source, `has` to one entry.
|
|
153
|
+
*/
|
|
154
|
+
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
155
|
readonly scalar: "json";
|
|
148
|
-
} ?
|
|
149
|
-
|
|
150
|
-
type
|
|
156
|
+
} ? AvJsonValue : ScalarValueAt<C, K, F, Forms>, FieldSlotReferences<C, K, F, ReferenceForms>, ScalarFilterOperatorAt<C, K, F>>;
|
|
157
|
+
/** The scalar fields of `K` a `where` can name: those advertising an operator. */
|
|
158
|
+
type ScalarFilterableKey<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
159
|
+
[F in ScalarFieldKeyOf<C, K>]: [ScalarFilterOperatorAt<C, K, F>] extends [
|
|
160
|
+
never
|
|
161
|
+
] ? never : F;
|
|
162
|
+
}[ScalarFieldKeyOf<C, K>];
|
|
163
|
+
type RelationParentFilterKey<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
151
164
|
[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
165
|
}[RelationFieldKeyOf<C, K>];
|
|
153
|
-
type ToManyRelationWhereInput<C extends
|
|
154
|
-
type RelationWhereInput<C extends
|
|
155
|
-
type ScalarWhereFields<C extends
|
|
166
|
+
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>>>>;
|
|
167
|
+
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>;
|
|
168
|
+
type ScalarWhereFields<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
156
169
|
[F in ScalarFilterableKey<C, K>]?: ScalarFilterFor<C, K, F, Forms, ReferenceForms>;
|
|
157
170
|
}>;
|
|
158
|
-
type RelationWhereFields<C extends
|
|
171
|
+
type RelationWhereFields<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
159
172
|
[F in RelationParentFilterKey<C, K>]?: RelationWhereInput<C, K, F & RelationFieldKeyOf<C, K>, Forms, ReferenceForms>;
|
|
160
173
|
}>;
|
|
161
174
|
/**
|
|
@@ -163,47 +176,47 @@ type RelationWhereFields<C extends Contract, K extends ResourceKey<C>, Forms ext
|
|
|
163
176
|
* through; see {@link UnstatedForms} for the default. `ReferenceForms` opens a
|
|
164
177
|
* transaction step's own `where` to `$ref`s, at every depth of it.
|
|
165
178
|
*/
|
|
166
|
-
export type
|
|
167
|
-
AND?: readonly
|
|
168
|
-
OR?: readonly
|
|
169
|
-
NOT?:
|
|
179
|
+
export type AvWhereInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = Readonly<{
|
|
180
|
+
AND?: readonly AvWhereInput<C, K, Forms, ReferenceForms>[];
|
|
181
|
+
OR?: readonly AvWhereInput<C, K, Forms, ReferenceForms>[];
|
|
182
|
+
NOT?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
170
183
|
} & 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],
|
|
184
|
+
type ActiveIdentifier<C extends AvContract, K extends AvResourceKey<C>> = C["resources"][K]["identifiers"][number];
|
|
185
|
+
type IdentifierObject<C extends AvContract, K extends AvResourceKey<C>, I extends readonly string[], Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
186
|
+
[F in Extract<I[number], AvFieldKey<C, K>>]: ScalarValueAt<C, K, F, Forms> | SlotReference<C, K, F, ReferenceForms, "nonNullValue">;
|
|
174
187
|
} & {
|
|
175
|
-
[F in Exclude<
|
|
188
|
+
[F in Exclude<AvFieldKey<C, K>, I[number]>]?: never;
|
|
176
189
|
}>;
|
|
177
190
|
/**
|
|
178
191
|
* A `where` argument for a unique operation: the values of one identifier. Inside a
|
|
179
192
|
* transaction plan (`ReferenceForms` stated) each value may be a `$ref` to a non-null
|
|
180
193
|
* source of the same type.
|
|
181
194
|
*/
|
|
182
|
-
export type
|
|
195
|
+
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
196
|
/** `"asc"` or `"desc"`. */
|
|
184
|
-
export type
|
|
197
|
+
export type AvSortDirection = "asc" | "desc";
|
|
185
198
|
/** Where `null`s sort: `"first"` or `"last"`. */
|
|
186
|
-
export type
|
|
199
|
+
export type AvNullsOrder = "first" | "last";
|
|
187
200
|
/** How one scalar field sorts: a direction, or a direction and a `nulls` order. */
|
|
188
|
-
export type
|
|
189
|
-
sort:
|
|
190
|
-
nulls:
|
|
201
|
+
export type AvScalarOrderInput = AvSortDirection | Readonly<{
|
|
202
|
+
sort: AvSortDirection;
|
|
203
|
+
nulls: AvNullsOrder;
|
|
191
204
|
}>;
|
|
192
|
-
type OrderableScalarKey<C extends
|
|
193
|
-
type OrderableRelationKey<C extends
|
|
194
|
-
type OrderableFieldKey<C extends
|
|
195
|
-
type ScalarOrderForField<C extends
|
|
205
|
+
type OrderableScalarKey<C extends AvContract, K extends AvResourceKey<C>> = KeysWithCapability<C, K, ScalarFieldKeyOf<C, K>, "order", UnrestrictedProjection>;
|
|
206
|
+
type OrderableRelationKey<C extends AvContract, K extends AvResourceKey<C>> = KeysWithCapability<C, K, RelationFieldKeyOf<C, K>, "order", UnrestrictedProjection>;
|
|
207
|
+
type OrderableFieldKey<C extends AvContract, K extends AvResourceKey<C>> = OrderableScalarKey<C, K> | OrderableRelationKey<C, K>;
|
|
208
|
+
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
209
|
/**
|
|
197
210
|
* The `orderBy` value of a relation field: a to-many relation orders by
|
|
198
211
|
* `$count`; a to-one relation takes one entry of the related Resource's
|
|
199
212
|
* `orderBy`, not a list.
|
|
200
213
|
*/
|
|
201
|
-
type RelationOrderForField<C extends
|
|
202
|
-
$count:
|
|
203
|
-
}> : never :
|
|
204
|
-
type OrderValue<C extends
|
|
214
|
+
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<{
|
|
215
|
+
$count: AvSortDirection;
|
|
216
|
+
}> : never : AvOrderByEntry<C, RelationTarget<C, K, F>>;
|
|
217
|
+
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
218
|
/** One `orderBy` precedence entry: exactly one orderable field and its value. */
|
|
206
|
-
export type
|
|
219
|
+
export type AvOrderByEntry<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
207
220
|
[F in OrderableFieldKey<C, K>]: {
|
|
208
221
|
readonly [Only in F]: OrderValue<C, K, Only>;
|
|
209
222
|
} & {
|
|
@@ -211,18 +224,18 @@ export type OrderByEntry<C extends Contract, K extends ResourceKey<C>> = {
|
|
|
211
224
|
};
|
|
212
225
|
}[OrderableFieldKey<C, K>];
|
|
213
226
|
/** An `orderBy` argument: one entry, or a list in order of precedence. */
|
|
214
|
-
export type
|
|
227
|
+
export type AvOrderByInput<C extends AvContract, K extends AvResourceKey<C>> = AvOrderByEntry<C, K> | readonly AvOrderByEntry<C, K>[];
|
|
215
228
|
/**
|
|
216
229
|
* A `cursor` argument: scalar field values of the row the page starts from. Inside
|
|
217
230
|
* a transaction plan each may be a `$ref` to a non-null source of the same type.
|
|
218
231
|
*/
|
|
219
|
-
export type
|
|
232
|
+
export type AvCursorInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = Readonly<{
|
|
220
233
|
[F in ScalarFieldKeyOf<C, K>]?: ScalarValueAt<C, K, F, Forms> | SlotReference<C, K, F, ReferenceForms, "nonNullValue">;
|
|
221
234
|
}>;
|
|
222
235
|
/** The scalar fields selectable at one projection position. */
|
|
223
|
-
type SelectableScalarKey<C extends
|
|
224
|
-
type SelectableRelationKey<C extends
|
|
225
|
-
type IncludeRelationKey<C extends
|
|
236
|
+
type SelectableScalarKey<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope> = KeysWithCapability<C, K, ScalarFieldKeyOf<C, K>, "select", Scope>;
|
|
237
|
+
type SelectableRelationKey<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope> = KeysWithCapability<C, K, RelationFieldKeyOf<C, K>, "select", Scope>;
|
|
238
|
+
type IncludeRelationKey<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope> = KeysWithCapability<C, K, RelationFieldKeyOf<C, K>, "include", Scope>;
|
|
226
239
|
/**
|
|
227
240
|
* Whether `$count` may be asked for inside relation `F`'s projection argument.
|
|
228
241
|
*
|
|
@@ -230,27 +243,27 @@ type IncludeRelationKey<C extends Contract, K extends ResourceKey<C>, Scope exte
|
|
|
230
243
|
* unrestricted scope one level in: `{ posts: { select: ["$count"] } }` is the
|
|
231
244
|
* parent's reducer over `F`, so it sits in the parent's argument position. The
|
|
232
245
|
* target's own projection is a separate question and is unrestricted — see
|
|
233
|
-
* {@link
|
|
246
|
+
* {@link AvRelationProjectionInput}.
|
|
234
247
|
*/
|
|
235
|
-
type RelationAllowsCount<C extends
|
|
236
|
-
type NestedWhereArgument<C extends
|
|
237
|
-
where?:
|
|
248
|
+
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;
|
|
249
|
+
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<{
|
|
250
|
+
where?: AvWhereInput<C, RelationTarget<C, K, F>, Forms>;
|
|
238
251
|
}> : Readonly<Record<never, never>>;
|
|
239
|
-
type NestedOrderArgument<C extends
|
|
240
|
-
orderBy?:
|
|
252
|
+
type NestedOrderArgument<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>> = HasCapability<C, K, F, "order", UnrestrictedProjection> extends true ? Readonly<{
|
|
253
|
+
orderBy?: AvOrderByInput<C, RelationTarget<C, K, F>>;
|
|
241
254
|
}> : Readonly<Record<never, never>>;
|
|
242
|
-
type NestedPaginationArgument<C extends
|
|
243
|
-
cursor?:
|
|
255
|
+
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<{
|
|
256
|
+
cursor?: AvCursorInput<C, RelationTarget<C, K, F>, Forms>;
|
|
244
257
|
}> : Capability extends "limit" ? Readonly<{
|
|
245
258
|
limit?: number;
|
|
246
259
|
}> : Readonly<{
|
|
247
260
|
offset?: number;
|
|
248
261
|
}> : Readonly<Record<never, never>> : Readonly<Record<never, never>>;
|
|
249
|
-
type ProjectionChoice<C extends
|
|
250
|
-
select?:
|
|
262
|
+
type ProjectionChoice<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, AllowCount extends boolean, Forms extends ScalarForms> = Readonly<{
|
|
263
|
+
select?: AvSelectInput<C, K, Scope, AllowCount, Forms>;
|
|
251
264
|
include?: never;
|
|
252
265
|
}> | Readonly<{
|
|
253
|
-
include?:
|
|
266
|
+
include?: AvIncludeInput<C, K, Scope, Forms>;
|
|
254
267
|
select?: never;
|
|
255
268
|
}>;
|
|
256
269
|
/**
|
|
@@ -258,48 +271,48 @@ type ProjectionChoice<C extends Contract, K extends ResourceKey<C>, Scope extend
|
|
|
258
271
|
* applies to this entry only; the related rows' own projection is
|
|
259
272
|
* unrestricted.
|
|
260
273
|
*/
|
|
261
|
-
export type
|
|
274
|
+
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
275
|
/**
|
|
263
276
|
* One relation entry of a projection: exactly relation `F` of `Keys`, with its
|
|
264
277
|
* argument object, and every other key of `Keys` absent.
|
|
265
278
|
*/
|
|
266
|
-
type RelationProjectionEntry<C extends
|
|
267
|
-
readonly [Only in F]:
|
|
279
|
+
type RelationProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Keys extends RelationFieldKeyOf<C, K>, F extends Keys, Scope extends AvProjectionScope, Forms extends ScalarForms> = {
|
|
280
|
+
readonly [Only in F]: AvRelationProjectionInput<C, K, Only & RelationFieldKeyOf<C, K>, Scope, Forms>;
|
|
268
281
|
} & {
|
|
269
282
|
readonly [Other in Exclude<Keys, F>]?: never;
|
|
270
283
|
};
|
|
271
|
-
type SelectRelationProjectionEntry<C extends
|
|
284
|
+
type SelectRelationProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, Forms extends ScalarForms> = {
|
|
272
285
|
[F in SelectableRelationKey<C, K, Scope>]: RelationProjectionEntry<C, K, SelectableRelationKey<C, K, Scope>, F, Scope, Forms>;
|
|
273
286
|
}[SelectableRelationKey<C, K, Scope>];
|
|
274
|
-
type IncludeRelationProjectionEntry<C extends
|
|
287
|
+
type IncludeRelationProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, Forms extends ScalarForms> = {
|
|
275
288
|
[F in IncludeRelationKey<C, K, Scope>]: RelationProjectionEntry<C, K, IncludeRelationKey<C, K, Scope>, F, Scope, Forms>;
|
|
276
289
|
}[IncludeRelationKey<C, K, Scope>];
|
|
277
290
|
/**
|
|
278
291
|
* One entry of a `select` argument, at one projection position. The default is
|
|
279
292
|
* the unrestricted position.
|
|
280
293
|
*/
|
|
281
|
-
export type
|
|
294
|
+
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
295
|
/** A `select` argument: the fields to return. */
|
|
283
|
-
export type
|
|
296
|
+
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
297
|
/** An `include` argument: the relations to return with each row. */
|
|
285
|
-
export type
|
|
298
|
+
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
299
|
/** A scalar update directive and its operand, such as `{ $increment: 1 }`. */
|
|
287
|
-
export type ScalarMutationAction = Readonly<Partial<Record<
|
|
300
|
+
export type ScalarMutationAction = Readonly<Partial<Record<AvScalarMutationDirective, unknown>>>;
|
|
288
301
|
/** A relation write: one or more relation directives and their payloads. */
|
|
289
|
-
export type RelationMutationAction = Readonly<Partial<Record<
|
|
302
|
+
export type RelationMutationAction = Readonly<Partial<Record<AvRelationMutationDirective, unknown>>>;
|
|
290
303
|
/** The scalar fields writable at one stage and write position. */
|
|
291
|
-
type WritableScalarKey<C extends
|
|
304
|
+
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
305
|
/**
|
|
293
306
|
* The relations writable at one stage in one write position. The default is
|
|
294
307
|
* the unrestricted position.
|
|
295
308
|
*/
|
|
296
|
-
export type WritableRelationKey<C extends
|
|
297
|
-
type ManyOrOne<C extends
|
|
309
|
+
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>;
|
|
310
|
+
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
311
|
/**
|
|
299
312
|
* A `where` of plain fields: each scalar field's filter, combined with
|
|
300
313
|
* `AND`/`OR`/`NOT`, and no relation filter at any depth.
|
|
301
314
|
*/
|
|
302
|
-
type ScalarOnlyWhereInput<C extends
|
|
315
|
+
type ScalarOnlyWhereInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
303
316
|
AND?: readonly ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>[];
|
|
304
317
|
OR?: readonly ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>[];
|
|
305
318
|
NOT?: ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>;
|
|
@@ -308,38 +321,38 @@ type ScalarOnlyWhereInput<C extends Contract, K extends ResourceKey<C>, Forms ex
|
|
|
308
321
|
* The `where` of a nested `$update` or `$delete` through relation `F`: plain fields
|
|
309
322
|
* only where the relation states `nestedWriteFilter: "scalar"`, any filter otherwise.
|
|
310
323
|
*/
|
|
311
|
-
type NestedWriteWhereInput<C extends
|
|
324
|
+
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
325
|
readonly nestedWriteFilter: "scalar";
|
|
313
|
-
} ? ScalarOnlyWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms> :
|
|
314
|
-
type ConnectOrCreateEntry<C extends
|
|
315
|
-
where:
|
|
316
|
-
create:
|
|
326
|
+
} ? ScalarOnlyWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms> : AvWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>;
|
|
327
|
+
type ConnectOrCreateEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
328
|
+
where: AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>;
|
|
329
|
+
create: AvCreateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
317
330
|
}>;
|
|
318
|
-
type ToOneUpdateEntry<C extends
|
|
331
|
+
type ToOneUpdateEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
319
332
|
where?: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
320
|
-
data:
|
|
333
|
+
data: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms>;
|
|
321
334
|
}>;
|
|
322
|
-
type ToManyUpdateEntry<C extends
|
|
335
|
+
type ToManyUpdateEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
323
336
|
where: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
324
|
-
data:
|
|
337
|
+
data: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms>;
|
|
325
338
|
}>;
|
|
326
|
-
type ToOneDeleteEntry<C extends
|
|
339
|
+
type ToOneDeleteEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = true | Readonly<{
|
|
327
340
|
where?: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
328
341
|
}>;
|
|
329
|
-
type ToManyDeleteEntry<C extends
|
|
342
|
+
type ToManyDeleteEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
330
343
|
where: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
331
344
|
}>;
|
|
332
|
-
type ToOneUpsertEntry<C extends
|
|
333
|
-
where?:
|
|
334
|
-
create:
|
|
335
|
-
update:
|
|
345
|
+
type ToOneUpsertEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
346
|
+
where?: AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>;
|
|
347
|
+
create: AvCreateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
348
|
+
update: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms>;
|
|
336
349
|
}>;
|
|
337
|
-
type ToManyUpsertEntry<C extends
|
|
338
|
-
where:
|
|
339
|
-
create:
|
|
340
|
-
update:
|
|
350
|
+
type ToManyUpsertEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
351
|
+
where: AvUniqueWhereInput<C, RelationTarget<C, K, F>, Forms, ReferenceForms>;
|
|
352
|
+
create: AvCreateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms, readonly [K, F]>;
|
|
353
|
+
update: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms>;
|
|
341
354
|
}>;
|
|
342
|
-
type RelationDirectiveValue<C extends
|
|
355
|
+
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
356
|
declare const NO_ADVERTISED_MEMBER: unique symbol;
|
|
344
357
|
/**
|
|
345
358
|
* A write member that advertises nothing: it accepts `{}` and refuses every key.
|
|
@@ -349,126 +362,178 @@ type NoAdvertisedMember = {
|
|
|
349
362
|
};
|
|
350
363
|
/** `Write`, or {@link NoAdvertisedMember} when `Write` has no keys at all. */
|
|
351
364
|
type RefuseEveryKeyWhenEmpty<Write> = [keyof Write] extends [never] ? NoAdvertisedMember : Write;
|
|
352
|
-
type RelationMutationActionFor<C extends
|
|
353
|
-
[Directive in Extract<CapabilityTokens<C, K, F, Stage, Scope>,
|
|
365
|
+
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<{
|
|
366
|
+
[Directive in Extract<CapabilityTokens<C, K, F, Stage, Scope>, AvRelationMutationDirective>]: RelationDirectiveValue<C, K, F, Directive, Forms, ReferenceForms>;
|
|
354
367
|
}>>>;
|
|
355
368
|
/**
|
|
356
369
|
* One scalar mutation directive's operand: one entry of the field (`$push` on a
|
|
357
370
|
* list also takes a list of them). `$unset`'s operand is passed to the adapter as
|
|
358
371
|
* given.
|
|
359
372
|
*/
|
|
360
|
-
type ScalarDirectiveOperand<C extends
|
|
373
|
+
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
374
|
/**
|
|
362
375
|
* The directive object a scalar field accepts at one stage, or `never` when it
|
|
363
376
|
* advertises no directive.
|
|
364
377
|
*/
|
|
365
|
-
type ScalarMutationActionFor<C extends
|
|
366
|
-
Extract<CapabilityTokens<C, K, F, Stage, Scope>,
|
|
378
|
+
type ScalarMutationActionFor<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms> = [
|
|
379
|
+
Extract<CapabilityTokens<C, K, F, Stage, Scope>, AvScalarMutationDirective>
|
|
367
380
|
] extends [never] ? never : Readonly<{
|
|
368
|
-
[Directive in Extract<CapabilityTokens<C, K, F, Stage, Scope>,
|
|
381
|
+
[Directive in Extract<CapabilityTokens<C, K, F, Stage, Scope>, AvScalarMutationDirective>]?: ScalarDirectiveOperand<C, K, F, Directive, Forms>;
|
|
369
382
|
}>;
|
|
370
383
|
/**
|
|
371
384
|
* Each writable scalar takes its value under `Forms`, or a directive object of
|
|
372
385
|
* the directives it advertises at this stage — or, in a transaction plan's
|
|
373
386
|
* top-level data, a `$ref` to a source of the same type.
|
|
374
387
|
*/
|
|
375
|
-
type ScalarMutationFields<C extends
|
|
388
|
+
type ScalarMutationFields<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
376
389
|
[F in WritableScalarKey<C, K, Stage, Scope>]?: ScalarValueAt<C, K, F, Forms> | ScalarMutationActionFor<C, K, F, Stage, Scope, Forms> | SlotReference<C, K, F, ReferenceForms, "value">;
|
|
377
390
|
}>;
|
|
378
|
-
type RelationMutationFields<C extends
|
|
391
|
+
type RelationMutationFields<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
379
392
|
[F in WritableRelationKey<C, K, Stage, Scope>]?: RelationMutationActionFor<C, K, F & RelationFieldKeyOf<C, K>, Stage, Scope, Forms, ReferenceForms>;
|
|
380
393
|
}>;
|
|
394
|
+
/** A relation edge a nested create is reached through: `[parent, relation]`. */
|
|
395
|
+
type ParentEdge = readonly [string, string];
|
|
396
|
+
/** The names a requirement list holds; `never` when the member is absent. */
|
|
397
|
+
type RequirementNames<Requirements, Member extends PropertyKey> = Requirements extends {
|
|
398
|
+
readonly [P in Member]?: infer List;
|
|
399
|
+
} ? List extends readonly (infer Name)[] ? Name : never : never;
|
|
400
|
+
/** Resource `K`'s create requirements, or `never` when its Contract states none. */
|
|
401
|
+
type CreateRequirementsAt<C extends AvContract, K extends AvResourceKey<C>> = "createRequirements" extends keyof C["resources"][K] ? Exclude<C["resources"][K]["createRequirements"], undefined> : never;
|
|
402
|
+
/** The names a create nested through `Via` gets from its parent. */
|
|
403
|
+
type SuppliedThrough<Requirements, Via> = Via extends readonly [
|
|
404
|
+
infer Parent,
|
|
405
|
+
infer Relation
|
|
406
|
+
] ? Requirements extends {
|
|
407
|
+
readonly parentSupplies?: infer Supplies;
|
|
408
|
+
} ? Parent extends keyof Supplies ? Relation extends keyof NonNullable<Supplies[Parent]> ? NonNullable<Supplies[Parent]>[Relation] extends readonly (infer Name)[] ? Name : never : never : never : never : never;
|
|
409
|
+
/** A value that is written: anything but `undefined`. */
|
|
410
|
+
type WrittenValue = NonNullable<unknown> | null;
|
|
411
|
+
/** Keys that must be present: `never` names none. */
|
|
412
|
+
type Present<Keys extends PropertyKey> = [Keys] extends [never] ? unknown : {
|
|
413
|
+
readonly [P in Keys]: WrittenValue;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* One required relation's group: the relation alone, or every reference field
|
|
417
|
+
* together, never both — where this position can write both; the relation
|
|
418
|
+
* alone where it can write the relation but not every reference field; every
|
|
419
|
+
* reference field where it cannot write the relation (a bulk record); nothing
|
|
420
|
+
* where the parent supplies the group.
|
|
421
|
+
*/
|
|
422
|
+
type GroupPresence<Group, Scalars, Relations, Supplied> = Group extends readonly [
|
|
423
|
+
infer Relation extends string,
|
|
424
|
+
...infer References extends readonly string[]
|
|
425
|
+
] ? 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> & {
|
|
426
|
+
readonly [P in References[number]]?: never;
|
|
427
|
+
}) | (Present<References[number]> & {
|
|
428
|
+
readonly [P in Relation]?: never;
|
|
429
|
+
}) : Present<Relation> : Present<References[number]> : unknown : unknown;
|
|
430
|
+
/** Every group of a `oneOf` tuple, each one's presence intersected. */
|
|
431
|
+
type GroupsPresence<Groups, Scalars, Relations, Supplied> = Groups extends readonly [infer Group, ...infer Rest] ? GroupPresence<Group, Scalars, Relations, Supplied> & GroupsPresence<Rest, Scalars, Relations, Supplied> : unknown;
|
|
432
|
+
/**
|
|
433
|
+
* What a create of Resource `K` at write position `Scope` must and must not
|
|
434
|
+
* write: every `required` name it can write, and one side of every `oneOf`
|
|
435
|
+
* group — less what the parent supplies when the create is nested through
|
|
436
|
+
* `Via`. `unknown` (no constraint) when the Contract states nothing.
|
|
437
|
+
*/
|
|
438
|
+
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 {
|
|
439
|
+
readonly oneOf?: infer Groups;
|
|
440
|
+
} ? GroupsPresence<Groups, WritableScalarKey<C, K, "create", Scope>, WritableRelationKey<C, K, "create", Scope>, SuppliedThrough<Requirements, Via>> : unknown) : unknown;
|
|
381
441
|
/**
|
|
382
442
|
* A `create` data argument, at one write position. A write position applies
|
|
383
443
|
* to the top level only; nested writes use the unrestricted position (see
|
|
384
|
-
* {@link
|
|
385
|
-
* positions
|
|
386
|
-
*
|
|
444
|
+
* {@link AvWriteScope}). `ReferenceForms` opens a transaction plan's reference
|
|
445
|
+
* positions (its scalar values and the unique keys its relation directives name)
|
|
446
|
+
* and is never passed to nested data, which holds none.
|
|
447
|
+
*
|
|
448
|
+
* Every field the Contract's `createRequirements` names must be written, and
|
|
449
|
+
* one side of every required relation's group — the relation, or all of its
|
|
450
|
+
* reference fields — never both. `Via` is the `[parent, relation]` a nested
|
|
451
|
+
* create is reached through: what that parent supplies is not required.
|
|
387
452
|
*/
|
|
388
|
-
export type
|
|
389
|
-
/** An `update` data argument, at one write position. See {@link
|
|
390
|
-
export type
|
|
391
|
-
type QueryProjectionArgs<C extends
|
|
453
|
+
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> & RelationMutationFields<C, K, "create", Scope, Forms, ReferenceForms>>> & CreateRequirementPresence<C, K, Scope, Via>;
|
|
454
|
+
/** An `update` data argument, at one write position. See {@link AvCreateDataInput}. */
|
|
455
|
+
export type AvUpdateDataInput<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvWriteScope = 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>>>;
|
|
456
|
+
type QueryProjectionArgs<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, Forms extends ScalarForms> = ProjectionChoice<C, K, Scope, false, Forms>;
|
|
392
457
|
/**
|
|
393
458
|
* Every standard operation's argument object, with each argument at its
|
|
394
459
|
* projection or write position.
|
|
395
460
|
*/
|
|
396
|
-
export type
|
|
461
|
+
export type AvOperationArgumentMap<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = {
|
|
397
462
|
find: {
|
|
398
463
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
399
|
-
where?:
|
|
400
|
-
orderBy?:
|
|
464
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
465
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
401
466
|
};
|
|
402
467
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
403
|
-
where:
|
|
468
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
404
469
|
};
|
|
405
470
|
many: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
406
|
-
where?:
|
|
407
|
-
orderBy?:
|
|
471
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
472
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
408
473
|
limit?: number;
|
|
409
474
|
offset?: number;
|
|
410
|
-
cursor?:
|
|
475
|
+
cursor?: AvCursorInput<C, K, Forms, ReferenceForms>;
|
|
411
476
|
};
|
|
412
477
|
count: {
|
|
413
|
-
where?:
|
|
478
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
414
479
|
};
|
|
415
480
|
};
|
|
416
481
|
create: {
|
|
417
482
|
one: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
418
|
-
data:
|
|
483
|
+
data: AvCreateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
419
484
|
};
|
|
420
485
|
many: QueryProjectionArgs<C, K, "bulkWrite", Forms> & {
|
|
421
|
-
data: readonly
|
|
486
|
+
data: readonly AvCreateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>[];
|
|
422
487
|
};
|
|
423
488
|
count: {
|
|
424
|
-
data: readonly
|
|
489
|
+
data: readonly AvCreateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>[];
|
|
425
490
|
};
|
|
426
491
|
};
|
|
427
492
|
update: {
|
|
428
493
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
429
|
-
where?:
|
|
430
|
-
orderBy?:
|
|
431
|
-
data:
|
|
494
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
495
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
496
|
+
data: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
432
497
|
};
|
|
433
498
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
434
|
-
where:
|
|
435
|
-
data:
|
|
499
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
500
|
+
data: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
436
501
|
};
|
|
437
502
|
many: QueryProjectionArgs<C, K, "bulkWrite", Forms> & {
|
|
438
|
-
where?:
|
|
439
|
-
data:
|
|
503
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
504
|
+
data: AvUpdateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>;
|
|
440
505
|
};
|
|
441
506
|
count: {
|
|
442
|
-
where?:
|
|
443
|
-
data:
|
|
507
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
508
|
+
data: AvUpdateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>;
|
|
444
509
|
};
|
|
445
510
|
};
|
|
446
511
|
delete: {
|
|
447
512
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
448
|
-
where?:
|
|
449
|
-
orderBy?:
|
|
513
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
514
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
450
515
|
};
|
|
451
516
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
452
|
-
where:
|
|
517
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
453
518
|
};
|
|
454
519
|
many: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
455
|
-
where?:
|
|
520
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
456
521
|
};
|
|
457
522
|
count: {
|
|
458
|
-
where?:
|
|
523
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
459
524
|
};
|
|
460
525
|
};
|
|
461
526
|
upsert: {
|
|
462
527
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
463
|
-
where:
|
|
464
|
-
create:
|
|
465
|
-
update:
|
|
528
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
529
|
+
create: AvCreateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
530
|
+
update: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
466
531
|
};
|
|
467
532
|
};
|
|
468
533
|
};
|
|
469
534
|
/** One standard operation's argument object. */
|
|
470
|
-
export type
|
|
535
|
+
export type AvOperationArgumentsFor<C extends AvContract, K extends AvResourceKey<C>, I extends AvOperationIdentity, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = I extends {
|
|
471
536
|
family: infer F;
|
|
472
537
|
variant: infer V;
|
|
473
|
-
} ? F extends keyof
|
|
538
|
+
} ? 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
539
|
export {};
|