@aventara/core 0.1.0-pilot.4 → 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 +1478 -0
- package/README.md +275 -11
- 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 +17 -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 -25
- 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/avz/avz.js +354 -0
- package/dist/avz/index.d.ts +7 -0
- package/dist/avz/index.js +1 -0
- package/dist/avz/json-shape.registry.d.ts +22 -0
- package/dist/avz/json-shape.registry.js +16 -0
- package/dist/avz/zod-issue.translator.d.ts +57 -0
- package/dist/avz/zod-issue.translator.js +149 -0
- package/dist/compiler/contract-compiler-diagnostic.d.ts +37 -5
- package/dist/compiler/contract.compiler.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +595 -421
- 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 +75 -29
- package/dist/config/config.resolver.js +109 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +586 -71
- 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 +111 -37
- 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 +344 -29
- package/dist/contracts/client-contract-structure.validator.js +248 -7
- package/dist/contracts/contract-canonicalizer.d.ts +19 -3
- package/dist/contracts/contract-canonicalizer.js +172 -27
- 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 +31 -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 +61 -41
- package/dist/contracts/identifier.d.ts +4 -4
- package/dist/contracts/json-shape.d.ts +76 -0
- package/dist/contracts/json-shape.js +1 -0
- package/dist/contracts/lifecycle-trait.d.ts +2 -2
- package/dist/contracts/reference-write-limit.d.ts +7 -0
- package/dist/contracts/reference-write-limit.js +1 -0
- 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 +25 -14
- 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 +234 -63
- 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 +50 -24
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +95 -32
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +55 -82
- package/dist/index.js +6 -26
- package/dist/internal.d.ts +40 -0
- package/dist/internal.js +18 -0
- package/dist/operations/operation-arguments.d.ts +316 -201
- package/dist/operations/operation-call.d.ts +27 -28
- package/dist/operations/operation-identity.d.ts +12 -10
- package/dist/operations/operation-identity.js +3 -0
- 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 +41 -12
- package/dist/operations/operation-validator.d.ts +24 -9
- package/dist/operations/operation-validator.js +26 -10
- package/dist/operations/projection-scope.resolver.d.ts +7 -7
- package/dist/operations/structural-limits.walker.d.ts +19 -0
- package/dist/operations/structural-limits.walker.js +489 -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 -11
- package/dist/protocol/absent-route.responder.js +42 -16
- 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 +23 -13
- package/dist/protocol/http-request.decoder.js +19 -11
- 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 +52 -27
- package/dist/protocol/protocol.binder.js +14 -9
- package/dist/protocol/protocol.handler.d.ts +28 -15
- package/dist/protocol/protocol.handler.js +55 -10
- package/dist/protocol/unmounted-route.error.d.ts +19 -0
- package/dist/protocol/unmounted-route.error.js +10 -0
- package/dist/runtime/caller-data.copier.d.ts +59 -0
- package/dist/runtime/caller-data.copier.js +470 -0
- package/dist/runtime/caller-data.door.d.ts +56 -0
- package/dist/runtime/caller-data.door.js +67 -0
- package/dist/runtime/computed-read-runtime.d.ts +7 -6
- package/dist/runtime/computed-read-runtime.js +61 -55
- package/dist/runtime/computed-value.error.d.ts +13 -0
- package/dist/runtime/computed-value.error.js +9 -0
- 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 +22 -57
- package/dist/runtime/create-requirement.js +140 -37
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +64 -22
- package/dist/runtime/diagnostics-reporter.js +35 -4
- package/dist/runtime/error-boundary.d.ts +73 -8
- package/dist/runtime/error-boundary.js +104 -48
- 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 +79 -7
- 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 +32 -0
- package/dist/runtime/misuse-reporter.js +19 -0
- package/dist/runtime/mutation-planner.d.ts +19 -10
- package/dist/runtime/mutation-planner.js +62 -36
- 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 +35 -15
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +125 -30
- package/dist/runtime/operation-runtime.js +423 -83
- package/dist/runtime/outcome-mapper.d.ts +16 -5
- package/dist/runtime/outcome-mapper.js +35 -8
- package/dist/runtime/output-validator.d.ts +16 -6
- package/dist/runtime/output-validator.js +12 -1
- package/dist/runtime/owned-execution.registry.d.ts +13 -0
- package/dist/runtime/owned-execution.registry.js +7 -0
- 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 +202 -28
- package/dist/runtime/readonly-value.d.ts +32 -0
- package/dist/runtime/readonly-value.js +141 -0
- package/dist/runtime/referential-action.d.ts +7 -0
- package/dist/runtime/request-envelope.validator.d.ts +5 -0
- package/dist/runtime/request-envelope.validator.js +123 -0
- 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 +56 -13
- package/dist/runtime/scalar-runtime.js +167 -86
- 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 +23 -9
- package/dist/transactions/transaction-plan-assembler.js +195 -82
- package/dist/transactions/transaction-plan-validator.d.ts +53 -21
- package/dist/transactions/transaction-plan-validator.js +246 -163
- package/dist/transactions/transaction-reference-collector.d.ts +30 -0
- package/dist/transactions/transaction-reference-collector.js +204 -0
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +27 -10
- package/dist/transactions/transaction-reference-validator.d.ts +34 -4
- package/dist/transactions/transaction-reference-validator.js +82 -43
- package/dist/transactions/transaction-reference.d.ts +30 -58
- package/dist/transactions/transaction-request.d.ts +20 -7
- package/dist/transactions/transaction-response.d.ts +12 -7
- package/dist/transactions/transaction-response.js +24 -1
- package/dist/transactions/transaction-runtime.d.ts +11 -8
- package/dist/transactions/transaction-runtime.js +167 -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 +18 -3
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -35
- 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 -36
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/operations/operation-boolean-nodes.d.ts +0 -11
- package/dist/operations/operation-boolean-nodes.js +0 -283
- package/dist/operations/operation-nesting.d.ts +0 -8
- package/dist/operations/operation-nesting.js +0 -307
- 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/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,27 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
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";
|
|
7
8
|
/** The Resource names of Contract `C`. */
|
|
8
|
-
export type
|
|
9
|
+
export type AvResourceKey<C extends AvContract> = Extract<keyof C["resources"], string>;
|
|
9
10
|
/** The field names of Resource `K` in Contract `C`. */
|
|
10
|
-
export type
|
|
11
|
-
type FieldAt<C extends
|
|
12
|
-
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>, {
|
|
13
14
|
readonly kind: "scalar";
|
|
14
15
|
}>;
|
|
15
|
-
type RelationFieldAt<C extends
|
|
16
|
+
type RelationFieldAt<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>> = Extract<FieldAt<C, K, F>, {
|
|
16
17
|
readonly kind: "relation";
|
|
17
18
|
}>;
|
|
18
|
-
type ScalarFieldKeyOf<C extends
|
|
19
|
-
[F in
|
|
20
|
-
}[
|
|
21
|
-
type RelationFieldKeyOf<C extends
|
|
22
|
-
[F in
|
|
23
|
-
}[
|
|
24
|
-
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 {
|
|
25
26
|
readonly capabilities: infer Capabilities;
|
|
26
27
|
} ? Capabilities : never;
|
|
27
28
|
/** The projection position read when no position applies: `"record"`. */
|
|
@@ -29,15 +30,15 @@ type UnrestrictedProjection = "record";
|
|
|
29
30
|
/** The write position read when no position applies, and the one nested writes use: `"nested"`. */
|
|
30
31
|
type UnrestrictedWrite = "nested";
|
|
31
32
|
/** Whether a capability member's answer holds at one argument scope. */
|
|
32
|
-
type HoldsAtScope<Value, Scope extends
|
|
33
|
+
type HoldsAtScope<Value, Scope extends AvProjectionScope | AvWriteScope> = Value extends {
|
|
33
34
|
readonly scopes: readonly (infer Stated)[];
|
|
34
|
-
} ? Scope extends Stated ? true : false : Value extends
|
|
35
|
+
} ? Scope extends Stated ? true : false : Value extends AvProjectionScopes ? Scope extends Value[number] ? true : false : true;
|
|
35
36
|
/** The tokens a capability member advertises, in any argument position. */
|
|
36
37
|
type AdvertisedTokens<Value> = Value extends {
|
|
37
|
-
readonly scopes: readonly
|
|
38
|
+
readonly scopes: readonly AvWriteScope[];
|
|
38
39
|
readonly directives: readonly (infer Directive)[];
|
|
39
40
|
} ? Directive : Value extends {
|
|
40
|
-
readonly scopes: readonly
|
|
41
|
+
readonly scopes: readonly AvProjectionScope[];
|
|
41
42
|
readonly reducers: readonly (infer Reducer)[];
|
|
42
43
|
} ? Reducer : Value extends readonly (infer Token)[] ? Token : never;
|
|
43
44
|
/**
|
|
@@ -46,136 +47,176 @@ type AdvertisedTokens<Value> = Value extends {
|
|
|
46
47
|
* Presence first, scope second: an absent or `false` member is unavailable
|
|
47
48
|
* everywhere, and only a present one is asked where it holds.
|
|
48
49
|
*/
|
|
49
|
-
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;
|
|
50
51
|
/**
|
|
51
52
|
* The tokens a field advertises for one capability **at one argument scope** —
|
|
52
53
|
* `never` where the member does not hold at that scope, so a token list that
|
|
53
54
|
* holds only in the unrestricted position offers no token in a bulk one.
|
|
54
55
|
*/
|
|
55
|
-
type CapabilityTokens<C extends
|
|
56
|
-
type HasCapabilityToken<C extends
|
|
57
|
-
type RelationTarget<C extends
|
|
58
|
-
type RelationCardinality<C extends
|
|
59
|
-
type RelationNullable<C extends
|
|
60
|
-
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> = {
|
|
61
62
|
[F in Keys]: HasCapability<C, K, F, Capability, Scope> extends true ? F : never;
|
|
62
63
|
}[Keys];
|
|
63
64
|
/**
|
|
64
65
|
* The scalar-form map used when no side of a boundary is named: every built-in
|
|
65
|
-
* value is `unknown`. Pass `
|
|
66
|
+
* value is `unknown`. Pass `AvApplicationScalarForms` or `AvWireScalarForms` to type
|
|
66
67
|
* values. Enum values are their member union under every map.
|
|
67
68
|
*/
|
|
68
69
|
type UnstatedForms = ScalarForms;
|
|
69
70
|
/** Field `F`'s value under `Forms`, the same as in results. */
|
|
70
|
-
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;
|
|
71
72
|
/** One entry of field `F`'s value — the whole value when `F` is not a list. */
|
|
72
|
-
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
|
+
/**
|
|
75
|
+
* A `$ref` to a source whose value fits slot shape `Shape` of field `F`, typed in
|
|
76
|
+
* `ReferenceForms` — the forms a source's final data is read in. `never` when
|
|
77
|
+
* `ReferenceForms` is `never`: no position takes one outside a transaction plan.
|
|
78
|
+
*/
|
|
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>[]>;
|
|
73
80
|
/**
|
|
74
81
|
* A JSON object. Positions that accept both a value and an object of operators
|
|
75
82
|
* read a JSON object as the operators, so their value forms leave it out.
|
|
76
83
|
*/
|
|
77
|
-
type JsonObject = Extract<
|
|
78
|
-
readonly [key: string]:
|
|
84
|
+
type JsonObject = Extract<AvJsonValue, {
|
|
85
|
+
readonly [key: string]: AvJsonValue;
|
|
79
86
|
}>;
|
|
80
87
|
/**
|
|
81
88
|
* The field-independent shape of one scalar filter: any value, or an object of the
|
|
82
89
|
* operator vocabulary.
|
|
83
90
|
*/
|
|
84
|
-
export type ScalarFilterInput = unknown | Readonly<Partial<Record<
|
|
91
|
+
export type ScalarFilterInput = unknown | Readonly<Partial<Record<AvScalarFilterOperator, unknown>>>;
|
|
85
92
|
/**
|
|
86
93
|
* A scalar filter's shorthand equality value: the field's value, minus a JSON
|
|
87
94
|
* object.
|
|
88
95
|
*/
|
|
89
96
|
type ScalarFilterShorthand<Value> = Exclude<Value, JsonObject>;
|
|
90
97
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* one entry; a `json` field's `string*`/`array*` operand a {@link JsonValue};
|
|
94
|
-
* `not` a value or a nested operator object. `mode`, `isEmpty` and `path` are
|
|
95
|
-
* passed to the adapter as given.
|
|
98
|
+
* The `$ref` each slot shape of field `F` takes, by shape: every member `never`
|
|
99
|
+
* outside a transaction plan.
|
|
96
100
|
*/
|
|
97
|
-
type
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
101
|
+
type FieldSlotReferences<C extends AvContract, K extends AvResourceKey<C>, F extends AvFieldKey<C, K>, ReferenceForms extends ScalarForms> = {
|
|
102
|
+
readonly [Shape in TransactionSlotShape]: SlotReference<C, K, F, ReferenceForms, Shape>;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
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
|
+
*/
|
|
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
|
+
/**
|
|
140
|
+
* A scalar filter's operator object: the operators `Operator` names — the ones
|
|
141
|
+
* the field's `filter` member advertises — each with its operand.
|
|
142
|
+
*/
|
|
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 {
|
|
124
155
|
readonly scalar: "json";
|
|
125
|
-
} ?
|
|
126
|
-
|
|
127
|
-
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>> = {
|
|
128
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;
|
|
129
165
|
}[RelationFieldKeyOf<C, K>];
|
|
130
|
-
type ToManyRelationWhereInput<C extends
|
|
131
|
-
type RelationWhereInput<C extends
|
|
132
|
-
type ScalarWhereFields<C extends
|
|
133
|
-
[F in ScalarFilterableKey<C, K>]?: ScalarFilterFor<C, K, F, Forms>;
|
|
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<{
|
|
169
|
+
[F in ScalarFilterableKey<C, K>]?: ScalarFilterFor<C, K, F, Forms, ReferenceForms>;
|
|
134
170
|
}>;
|
|
135
|
-
type RelationWhereFields<C extends
|
|
136
|
-
[F in RelationParentFilterKey<C, K>]?: RelationWhereInput<C, K, F & RelationFieldKeyOf<C, K>, Forms>;
|
|
171
|
+
type RelationWhereFields<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
172
|
+
[F in RelationParentFilterKey<C, K>]?: RelationWhereInput<C, K, F & RelationFieldKeyOf<C, K>, Forms, ReferenceForms>;
|
|
137
173
|
}>;
|
|
138
174
|
/**
|
|
139
175
|
* A `where` argument. `Forms` is the scalar-form map its scalar values are read
|
|
140
|
-
* through; see {@link UnstatedForms} for the default.
|
|
176
|
+
* through; see {@link UnstatedForms} for the default. `ReferenceForms` opens a
|
|
177
|
+
* transaction step's own `where` to `$ref`s, at every depth of it.
|
|
141
178
|
*/
|
|
142
|
-
export type
|
|
143
|
-
AND?: readonly
|
|
144
|
-
OR?: readonly
|
|
145
|
-
NOT?:
|
|
146
|
-
} & ScalarWhereFields<C, K, Forms> & RelationWhereFields<C, K, Forms>>;
|
|
147
|
-
type ActiveIdentifier<C extends
|
|
148
|
-
type IdentifierObject<C extends
|
|
149
|
-
[F in Extract<I[number],
|
|
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>;
|
|
183
|
+
} & ScalarWhereFields<C, K, Forms, ReferenceForms> & RelationWhereFields<C, K, Forms, ReferenceForms>>;
|
|
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">;
|
|
150
187
|
} & {
|
|
151
|
-
[F in Exclude<
|
|
188
|
+
[F in Exclude<AvFieldKey<C, K>, I[number]>]?: never;
|
|
152
189
|
}>;
|
|
153
|
-
/**
|
|
154
|
-
|
|
190
|
+
/**
|
|
191
|
+
* A `where` argument for a unique operation: the values of one identifier. Inside a
|
|
192
|
+
* transaction plan (`ReferenceForms` stated) each value may be a `$ref` to a non-null
|
|
193
|
+
* source of the same type.
|
|
194
|
+
*/
|
|
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;
|
|
155
196
|
/** `"asc"` or `"desc"`. */
|
|
156
|
-
export type
|
|
197
|
+
export type AvSortDirection = "asc" | "desc";
|
|
157
198
|
/** Where `null`s sort: `"first"` or `"last"`. */
|
|
158
|
-
export type
|
|
199
|
+
export type AvNullsOrder = "first" | "last";
|
|
159
200
|
/** How one scalar field sorts: a direction, or a direction and a `nulls` order. */
|
|
160
|
-
export type
|
|
161
|
-
sort:
|
|
162
|
-
nulls:
|
|
201
|
+
export type AvScalarOrderInput = AvSortDirection | Readonly<{
|
|
202
|
+
sort: AvSortDirection;
|
|
203
|
+
nulls: AvNullsOrder;
|
|
163
204
|
}>;
|
|
164
|
-
type OrderableScalarKey<C extends
|
|
165
|
-
type OrderableRelationKey<C extends
|
|
166
|
-
type OrderableFieldKey<C extends
|
|
167
|
-
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;
|
|
168
209
|
/**
|
|
169
210
|
* The `orderBy` value of a relation field: a to-many relation orders by
|
|
170
211
|
* `$count`; a to-one relation takes one entry of the related Resource's
|
|
171
212
|
* `orderBy`, not a list.
|
|
172
213
|
*/
|
|
173
|
-
type RelationOrderForField<C extends
|
|
174
|
-
$count:
|
|
175
|
-
}> : never :
|
|
176
|
-
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;
|
|
177
218
|
/** One `orderBy` precedence entry: exactly one orderable field and its value. */
|
|
178
|
-
export type
|
|
219
|
+
export type AvOrderByEntry<C extends AvContract, K extends AvResourceKey<C>> = {
|
|
179
220
|
[F in OrderableFieldKey<C, K>]: {
|
|
180
221
|
readonly [Only in F]: OrderValue<C, K, Only>;
|
|
181
222
|
} & {
|
|
@@ -183,15 +224,18 @@ export type OrderByEntry<C extends Contract, K extends ResourceKey<C>> = {
|
|
|
183
224
|
};
|
|
184
225
|
}[OrderableFieldKey<C, K>];
|
|
185
226
|
/** An `orderBy` argument: one entry, or a list in order of precedence. */
|
|
186
|
-
export type
|
|
187
|
-
/**
|
|
188
|
-
|
|
189
|
-
|
|
227
|
+
export type AvOrderByInput<C extends AvContract, K extends AvResourceKey<C>> = AvOrderByEntry<C, K> | readonly AvOrderByEntry<C, K>[];
|
|
228
|
+
/**
|
|
229
|
+
* A `cursor` argument: scalar field values of the row the page starts from. Inside
|
|
230
|
+
* a transaction plan each may be a `$ref` to a non-null source of the same type.
|
|
231
|
+
*/
|
|
232
|
+
export type AvCursorInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = Readonly<{
|
|
233
|
+
[F in ScalarFieldKeyOf<C, K>]?: ScalarValueAt<C, K, F, Forms> | SlotReference<C, K, F, ReferenceForms, "nonNullValue">;
|
|
190
234
|
}>;
|
|
191
235
|
/** The scalar fields selectable at one projection position. */
|
|
192
|
-
type SelectableScalarKey<C extends
|
|
193
|
-
type SelectableRelationKey<C extends
|
|
194
|
-
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>;
|
|
195
239
|
/**
|
|
196
240
|
* Whether `$count` may be asked for inside relation `F`'s projection argument.
|
|
197
241
|
*
|
|
@@ -199,27 +243,27 @@ type IncludeRelationKey<C extends Contract, K extends ResourceKey<C>, Scope exte
|
|
|
199
243
|
* unrestricted scope one level in: `{ posts: { select: ["$count"] } }` is the
|
|
200
244
|
* parent's reducer over `F`, so it sits in the parent's argument position. The
|
|
201
245
|
* target's own projection is a separate question and is unrestricted — see
|
|
202
|
-
* {@link
|
|
246
|
+
* {@link AvRelationProjectionInput}.
|
|
203
247
|
*/
|
|
204
|
-
type RelationAllowsCount<C extends
|
|
205
|
-
type NestedWhereArgument<C extends
|
|
206
|
-
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>;
|
|
207
251
|
}> : Readonly<Record<never, never>>;
|
|
208
|
-
type NestedOrderArgument<C extends
|
|
209
|
-
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>>;
|
|
210
254
|
}> : Readonly<Record<never, never>>;
|
|
211
|
-
type NestedPaginationArgument<C extends
|
|
212
|
-
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>;
|
|
213
257
|
}> : Capability extends "limit" ? Readonly<{
|
|
214
258
|
limit?: number;
|
|
215
259
|
}> : Readonly<{
|
|
216
260
|
offset?: number;
|
|
217
261
|
}> : Readonly<Record<never, never>> : Readonly<Record<never, never>>;
|
|
218
|
-
type ProjectionChoice<C extends
|
|
219
|
-
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>;
|
|
220
264
|
include?: never;
|
|
221
265
|
}> | Readonly<{
|
|
222
|
-
include?:
|
|
266
|
+
include?: AvIncludeInput<C, K, Scope, Forms>;
|
|
223
267
|
select?: never;
|
|
224
268
|
}>;
|
|
225
269
|
/**
|
|
@@ -227,72 +271,88 @@ type ProjectionChoice<C extends Contract, K extends ResourceKey<C>, Scope extend
|
|
|
227
271
|
* applies to this entry only; the related rows' own projection is
|
|
228
272
|
* unrestricted.
|
|
229
273
|
*/
|
|
230
|
-
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;
|
|
231
275
|
/**
|
|
232
276
|
* One relation entry of a projection: exactly relation `F` of `Keys`, with its
|
|
233
277
|
* argument object, and every other key of `Keys` absent.
|
|
234
278
|
*/
|
|
235
|
-
type RelationProjectionEntry<C extends
|
|
236
|
-
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>;
|
|
237
281
|
} & {
|
|
238
282
|
readonly [Other in Exclude<Keys, F>]?: never;
|
|
239
283
|
};
|
|
240
|
-
type SelectRelationProjectionEntry<C extends
|
|
284
|
+
type SelectRelationProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, Forms extends ScalarForms> = {
|
|
241
285
|
[F in SelectableRelationKey<C, K, Scope>]: RelationProjectionEntry<C, K, SelectableRelationKey<C, K, Scope>, F, Scope, Forms>;
|
|
242
286
|
}[SelectableRelationKey<C, K, Scope>];
|
|
243
|
-
type IncludeRelationProjectionEntry<C extends
|
|
287
|
+
type IncludeRelationProjectionEntry<C extends AvContract, K extends AvResourceKey<C>, Scope extends AvProjectionScope, Forms extends ScalarForms> = {
|
|
244
288
|
[F in IncludeRelationKey<C, K, Scope>]: RelationProjectionEntry<C, K, IncludeRelationKey<C, K, Scope>, F, Scope, Forms>;
|
|
245
289
|
}[IncludeRelationKey<C, K, Scope>];
|
|
246
290
|
/**
|
|
247
291
|
* One entry of a `select` argument, at one projection position. The default is
|
|
248
292
|
* the unrestricted position.
|
|
249
293
|
*/
|
|
250
|
-
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);
|
|
251
295
|
/** A `select` argument: the fields to return. */
|
|
252
|
-
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>[];
|
|
253
297
|
/** An `include` argument: the relations to return with each row. */
|
|
254
|
-
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>)[];
|
|
255
299
|
/** A scalar update directive and its operand, such as `{ $increment: 1 }`. */
|
|
256
|
-
export type ScalarMutationAction = Readonly<Partial<Record<
|
|
300
|
+
export type ScalarMutationAction = Readonly<Partial<Record<AvScalarMutationDirective, unknown>>>;
|
|
257
301
|
/** A relation write: one or more relation directives and their payloads. */
|
|
258
|
-
export type RelationMutationAction = Readonly<Partial<Record<
|
|
302
|
+
export type RelationMutationAction = Readonly<Partial<Record<AvRelationMutationDirective, unknown>>>;
|
|
259
303
|
/** The scalar fields writable at one stage and write position. */
|
|
260
|
-
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>;
|
|
261
305
|
/**
|
|
262
306
|
* The relations writable at one stage in one write position. The default is
|
|
263
307
|
* the unrestricted position.
|
|
264
308
|
*/
|
|
265
|
-
export type WritableRelationKey<C extends
|
|
266
|
-
type ManyOrOne<C extends
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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;
|
|
311
|
+
/**
|
|
312
|
+
* A `where` of plain fields: each scalar field's filter, combined with
|
|
313
|
+
* `AND`/`OR`/`NOT`, and no relation filter at any depth.
|
|
314
|
+
*/
|
|
315
|
+
type ScalarOnlyWhereInput<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
316
|
+
AND?: readonly ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>[];
|
|
317
|
+
OR?: readonly ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>[];
|
|
318
|
+
NOT?: ScalarOnlyWhereInput<C, K, Forms, ReferenceForms>;
|
|
319
|
+
} & ScalarWhereFields<C, K, Forms, ReferenceForms>>;
|
|
320
|
+
/**
|
|
321
|
+
* The `where` of a nested `$update` or `$delete` through relation `F`: plain fields
|
|
322
|
+
* only where the relation states `nestedWriteFilter: "scalar"`, any filter otherwise.
|
|
323
|
+
*/
|
|
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 {
|
|
325
|
+
readonly nestedWriteFilter: "scalar";
|
|
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]>;
|
|
270
330
|
}>;
|
|
271
|
-
type ToOneUpdateEntry<C extends
|
|
272
|
-
where?:
|
|
273
|
-
data:
|
|
331
|
+
type ToOneUpdateEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
332
|
+
where?: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
333
|
+
data: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms>;
|
|
274
334
|
}>;
|
|
275
|
-
type ToManyUpdateEntry<C extends
|
|
276
|
-
where:
|
|
277
|
-
data:
|
|
335
|
+
type ToManyUpdateEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
336
|
+
where: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
337
|
+
data: AvUpdateDataInput<C, RelationTarget<C, K, F>, UnrestrictedWrite, Forms, ReferenceForms>;
|
|
278
338
|
}>;
|
|
279
|
-
type ToOneDeleteEntry<C extends
|
|
280
|
-
where?:
|
|
339
|
+
type ToOneDeleteEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = true | Readonly<{
|
|
340
|
+
where?: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
281
341
|
}>;
|
|
282
|
-
type ToManyDeleteEntry<C extends
|
|
283
|
-
where:
|
|
342
|
+
type ToManyDeleteEntry<C extends AvContract, K extends AvResourceKey<C>, F extends RelationFieldKeyOf<C, K>, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
343
|
+
where: NestedWriteWhereInput<C, K, F, Forms, ReferenceForms>;
|
|
284
344
|
}>;
|
|
285
|
-
type ToOneUpsertEntry<C extends
|
|
286
|
-
where?:
|
|
287
|
-
create:
|
|
288
|
-
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>;
|
|
289
349
|
}>;
|
|
290
|
-
type ToManyUpsertEntry<C extends
|
|
291
|
-
where:
|
|
292
|
-
create:
|
|
293
|
-
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>;
|
|
294
354
|
}>;
|
|
295
|
-
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;
|
|
296
356
|
declare const NO_ADVERTISED_MEMBER: unique symbol;
|
|
297
357
|
/**
|
|
298
358
|
* A write member that advertises nothing: it accepts `{}` and refuses every key.
|
|
@@ -302,123 +362,178 @@ type NoAdvertisedMember = {
|
|
|
302
362
|
};
|
|
303
363
|
/** `Write`, or {@link NoAdvertisedMember} when `Write` has no keys at all. */
|
|
304
364
|
type RefuseEveryKeyWhenEmpty<Write> = [keyof Write] extends [never] ? NoAdvertisedMember : Write;
|
|
305
|
-
type RelationMutationActionFor<C extends
|
|
306
|
-
[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>;
|
|
307
367
|
}>>>;
|
|
308
368
|
/**
|
|
309
369
|
* One scalar mutation directive's operand: one entry of the field (`$push` on a
|
|
310
370
|
* list also takes a list of them). `$unset`'s operand is passed to the adapter as
|
|
311
371
|
* given.
|
|
312
372
|
*/
|
|
313
|
-
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>;
|
|
314
374
|
/**
|
|
315
375
|
* The directive object a scalar field accepts at one stage, or `never` when it
|
|
316
376
|
* advertises no directive.
|
|
317
377
|
*/
|
|
318
|
-
type ScalarMutationActionFor<C extends
|
|
319
|
-
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>
|
|
320
380
|
] extends [never] ? never : Readonly<{
|
|
321
|
-
[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>;
|
|
322
382
|
}>;
|
|
323
383
|
/**
|
|
324
384
|
* Each writable scalar takes its value under `Forms`, or a directive object of
|
|
325
|
-
* the directives it advertises at this stage
|
|
385
|
+
* the directives it advertises at this stage — or, in a transaction plan's
|
|
386
|
+
* top-level data, a `$ref` to a source of the same type.
|
|
326
387
|
*/
|
|
327
|
-
type ScalarMutationFields<C extends
|
|
328
|
-
[F in WritableScalarKey<C, K, Stage, Scope>]?: ScalarValueAt<C, K, F, Forms> | ScalarMutationActionFor<C, K, F, Stage, Scope, Forms>;
|
|
388
|
+
type ScalarMutationFields<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
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">;
|
|
329
390
|
}>;
|
|
330
|
-
type RelationMutationFields<C extends
|
|
331
|
-
[F in WritableRelationKey<C, K, Stage, Scope>]?: RelationMutationActionFor<C, K, F & RelationFieldKeyOf<C, K>, Stage, Scope, Forms>;
|
|
391
|
+
type RelationMutationFields<C extends AvContract, K extends AvResourceKey<C>, Stage extends "create" | "update", Scope extends AvWriteScope, Forms extends ScalarForms, ReferenceForms extends ScalarForms> = Readonly<{
|
|
392
|
+
[F in WritableRelationKey<C, K, Stage, Scope>]?: RelationMutationActionFor<C, K, F & RelationFieldKeyOf<C, K>, Stage, Scope, Forms, ReferenceForms>;
|
|
332
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;
|
|
333
441
|
/**
|
|
334
442
|
* A `create` data argument, at one write position. A write position applies
|
|
335
443
|
* to the top level only; nested writes use the unrestricted position (see
|
|
336
|
-
* {@link
|
|
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.
|
|
337
452
|
*/
|
|
338
|
-
export type
|
|
339
|
-
/** An `update` data argument, at one write position. See {@link
|
|
340
|
-
export type
|
|
341
|
-
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>;
|
|
342
457
|
/**
|
|
343
458
|
* Every standard operation's argument object, with each argument at its
|
|
344
459
|
* projection or write position.
|
|
345
460
|
*/
|
|
346
|
-
export type
|
|
461
|
+
export type AvOperationArgumentMap<C extends AvContract, K extends AvResourceKey<C>, Forms extends ScalarForms = UnstatedForms, ReferenceForms extends ScalarForms = never> = {
|
|
347
462
|
find: {
|
|
348
463
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
349
|
-
where?:
|
|
350
|
-
orderBy?:
|
|
464
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
465
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
351
466
|
};
|
|
352
467
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
353
|
-
where:
|
|
468
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
354
469
|
};
|
|
355
470
|
many: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
356
|
-
where?:
|
|
357
|
-
orderBy?:
|
|
471
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
472
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
358
473
|
limit?: number;
|
|
359
474
|
offset?: number;
|
|
360
|
-
cursor?:
|
|
475
|
+
cursor?: AvCursorInput<C, K, Forms, ReferenceForms>;
|
|
361
476
|
};
|
|
362
477
|
count: {
|
|
363
|
-
where?:
|
|
478
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
364
479
|
};
|
|
365
480
|
};
|
|
366
481
|
create: {
|
|
367
482
|
one: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
368
|
-
data:
|
|
483
|
+
data: AvCreateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
369
484
|
};
|
|
370
485
|
many: QueryProjectionArgs<C, K, "bulkWrite", Forms> & {
|
|
371
|
-
data: readonly
|
|
486
|
+
data: readonly AvCreateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>[];
|
|
372
487
|
};
|
|
373
488
|
count: {
|
|
374
|
-
data: readonly
|
|
489
|
+
data: readonly AvCreateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>[];
|
|
375
490
|
};
|
|
376
491
|
};
|
|
377
492
|
update: {
|
|
378
493
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
379
|
-
where?:
|
|
380
|
-
orderBy?:
|
|
381
|
-
data:
|
|
494
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
495
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
496
|
+
data: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
382
497
|
};
|
|
383
498
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
384
|
-
where:
|
|
385
|
-
data:
|
|
499
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
500
|
+
data: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
386
501
|
};
|
|
387
502
|
many: QueryProjectionArgs<C, K, "bulkWrite", Forms> & {
|
|
388
|
-
where?:
|
|
389
|
-
data:
|
|
503
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
504
|
+
data: AvUpdateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>;
|
|
390
505
|
};
|
|
391
506
|
count: {
|
|
392
|
-
where?:
|
|
393
|
-
data:
|
|
507
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
508
|
+
data: AvUpdateDataInput<C, K, "bulkWrite", Forms, ReferenceForms>;
|
|
394
509
|
};
|
|
395
510
|
};
|
|
396
511
|
delete: {
|
|
397
512
|
first: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
398
|
-
where?:
|
|
399
|
-
orderBy?:
|
|
513
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
514
|
+
orderBy?: AvOrderByInput<C, K>;
|
|
400
515
|
};
|
|
401
516
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
402
|
-
where:
|
|
517
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
403
518
|
};
|
|
404
519
|
many: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
405
|
-
where?:
|
|
520
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
406
521
|
};
|
|
407
522
|
count: {
|
|
408
|
-
where?:
|
|
523
|
+
where?: AvWhereInput<C, K, Forms, ReferenceForms>;
|
|
409
524
|
};
|
|
410
525
|
};
|
|
411
526
|
upsert: {
|
|
412
527
|
unique: QueryProjectionArgs<C, K, "record", Forms> & {
|
|
413
|
-
where:
|
|
414
|
-
create:
|
|
415
|
-
update:
|
|
528
|
+
where: AvUniqueWhereInput<C, K, Forms, ReferenceForms>;
|
|
529
|
+
create: AvCreateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
530
|
+
update: AvUpdateDataInput<C, K, "nested", Forms, ReferenceForms>;
|
|
416
531
|
};
|
|
417
532
|
};
|
|
418
533
|
};
|
|
419
534
|
/** One standard operation's argument object. */
|
|
420
|
-
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 {
|
|
421
536
|
family: infer F;
|
|
422
537
|
variant: infer V;
|
|
423
|
-
} ? 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;
|
|
424
539
|
export {};
|