@aventara/core 1.0.0-rc.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1434 -0
- package/ERRORS.md +142 -0
- package/README.md +247 -57
- package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
- package/dist/adapters/adapter-discovery-diagnostic.guidance.d.ts +6 -0
- package/dist/adapters/adapter-discovery-diagnostic.guidance.js +7 -0
- package/dist/adapters/adapter-field.d.ts +25 -11
- package/dist/adapters/adapter-identifier.d.ts +6 -6
- package/dist/adapters/adapter-model.d.ts +18 -9
- package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
- package/dist/adapters/adapter-operation.d.ts +3 -3
- package/dist/adapters/adapter-resource.d.ts +18 -9
- package/dist/adapters/adapter-sql-statement.d.ts +19 -0
- package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
- package/dist/adapters/adapter.interface.d.ts +59 -29
- package/dist/avz/avz-check.factory.d.ts +83 -0
- package/dist/avz/avz-check.factory.js +116 -0
- package/dist/avz/avz-check.registry.d.ts +35 -0
- package/dist/avz/avz-check.registry.js +9 -0
- package/dist/avz/avz.d.ts +203 -0
- package/dist/{json → avz}/avz.js +150 -8
- package/dist/{json → avz}/index.d.ts +2 -1
- package/dist/{json → avz}/json-shape.registry.d.ts +7 -7
- package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
- package/dist/{json → avz}/zod-issue.translator.js +7 -0
- package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
- package/dist/compiler/contract-compiler-diagnostic.guidance.d.ts +6 -0
- package/dist/compiler/contract-compiler-diagnostic.guidance.js +97 -0
- package/dist/compiler/contract.compiler.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +637 -442
- package/dist/compiler/create-requirements.projector.d.ts +49 -0
- package/dist/compiler/create-requirements.projector.js +423 -0
- package/dist/compiler/field-validator.compiler.d.ts +47 -0
- package/dist/compiler/field-validator.compiler.js +238 -0
- package/dist/config/any-framework-config.d.ts +19 -12
- package/dist/config/computed-fields.d.ts +62 -0
- package/dist/config/computed-fields.js +80 -0
- package/dist/config/config-diagnostic.d.ts +11 -4
- package/dist/config/config-diagnostic.guidance.d.ts +6 -0
- package/dist/config/config-diagnostic.guidance.js +32 -0
- package/dist/config/config-layer.d.ts +15 -6
- package/dist/config/config.resolver.d.ts +74 -31
- package/dist/config/config.resolver.js +108 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +581 -72
- package/dist/config/define-resource.d.ts +57 -0
- package/dist/config/define-resource.js +14 -0
- package/dist/config/effective-fields.d.ts +19 -23
- package/dist/config/entrypoint.normalizer.d.ts +1 -1
- package/dist/config/exact-framework-config.d.ts +308 -0
- package/dist/config/field-compute.resolver.d.ts +21 -0
- package/dist/config/field-compute.resolver.js +123 -0
- package/dist/config/field-pipeline-config.d.ts +47 -0
- package/dist/config/forced-operation.validator.d.ts +10 -0
- package/dist/config/forced-operation.validator.js +66 -0
- package/dist/config/framework-config.d.ts +111 -39
- package/dist/config/framework-exemptions-config.d.ts +91 -0
- package/dist/config/framework-exemptions-config.js +1 -0
- package/dist/config/framework-field-definition.d.ts +78 -0
- package/dist/config/framework-field-definition.js +28 -0
- package/dist/config/framework-resources-config.d.ts +122 -0
- package/dist/config/framework-resources-config.js +1 -0
- package/dist/config/pipeline-config.d.ts +56 -20
- package/dist/config/pipeline-tree.resolver.d.ts +79 -0
- package/dist/config/pipeline-tree.resolver.js +220 -0
- package/dist/config/stage-type.eraser.d.ts +65 -0
- package/dist/config/stage-type.eraser.js +1 -0
- package/dist/contracts/capability.d.ts +21 -12
- package/dist/contracts/capability.js +2 -0
- package/dist/contracts/client-contract-structure.validator.d.ts +388 -63
- package/dist/contracts/client-contract-structure.validator.js +156 -10
- package/dist/contracts/contract-canonicalizer.d.ts +26 -3
- package/dist/contracts/contract-canonicalizer.js +156 -29
- package/dist/contracts/contract-hash.d.ts +12 -7
- package/dist/contracts/contract-hash.js +3 -2
- package/dist/contracts/contract-limits.d.ts +4 -1
- package/dist/contracts/contract-limits.js +1 -0
- package/dist/contracts/contract-lookup.d.ts +5 -5
- package/dist/contracts/contract-protocol.d.ts +4 -4
- package/dist/contracts/contract.d.ts +24 -16
- package/dist/contracts/create-requirements.d.ts +35 -0
- package/dist/contracts/create-requirements.js +1 -0
- package/dist/contracts/enum-definition.d.ts +1 -1
- package/dist/contracts/field-check.d.ts +101 -0
- package/dist/contracts/field-check.js +1 -0
- package/dist/contracts/field.d.ts +81 -42
- package/dist/contracts/identifier.d.ts +4 -4
- package/dist/contracts/json-shape.d.ts +12 -1
- package/dist/contracts/lifecycle-trait.d.ts +2 -2
- package/dist/contracts/resource-operations.d.ts +28 -28
- package/dist/contracts/resource.d.ts +15 -9
- package/dist/contracts/scalar-value-type.d.ts +15 -15
- package/dist/contracts/scalar.d.ts +3 -3
- package/dist/contracts/transaction-capability.d.ts +1 -1
- package/dist/contracts/wire-scalar-format.d.ts +4 -4
- package/dist/framework/contract-view.d.ts +213 -147
- package/dist/framework/framework-construction.error.d.ts +19 -10
- package/dist/framework/framework-construction.error.js +7 -3
- package/dist/framework/framework.d.ts +47 -23
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +49 -22
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +57 -50
- package/dist/index.js +7 -6
- package/dist/internal.d.ts +17 -10
- package/dist/internal.js +4 -1
- package/dist/operations/database-refusal.d.ts +51 -0
- package/dist/operations/database-refusal.js +45 -0
- package/dist/operations/operation-arguments.d.ts +343 -207
- package/dist/operations/operation-call.d.ts +27 -28
- package/dist/operations/operation-identity.d.ts +10 -10
- package/dist/operations/operation-result.d.ts +21 -21
- package/dist/operations/operation-validator-core.d.ts +6 -6
- package/dist/operations/operation-validator-core.js +99 -6
- package/dist/operations/operation-validator.d.ts +9 -9
- package/dist/operations/projection-scope.resolver.d.ts +6 -6
- package/dist/operations/structural-limits.walker.d.ts +6 -6
- package/dist/operations/structural-limits.walker.js +145 -0
- package/dist/operations/validation-code.d.ts +11 -6
- package/dist/operations/validation-code.guidance.d.ts +6 -0
- package/dist/operations/validation-code.guidance.js +90 -0
- package/dist/operations/validation-code.js +4 -0
- package/dist/operations/write-scope.resolver.d.ts +10 -6
- package/dist/operations/write-scope.resolver.js +2 -0
- package/dist/protocol/absent-route.responder.d.ts +13 -12
- package/dist/protocol/absent-route.responder.js +19 -19
- package/dist/protocol/contract-document.responder.d.ts +3 -3
- package/dist/protocol/contract-document.responder.js +2 -2
- package/dist/protocol/http-request.decoder.d.ts +17 -13
- package/dist/protocol/http-request.decoder.js +10 -10
- package/dist/protocol/http-request.reader.d.ts +3 -3
- package/dist/protocol/http-response.encoder.d.ts +4 -4
- package/dist/protocol/http-response.encoder.js +94 -55
- package/dist/protocol/http-status.table.d.ts +2 -2
- package/dist/protocol/operation-response.guard.d.ts +2 -2
- package/dist/protocol/protocol-surface.d.ts +4 -4
- package/dist/protocol/protocol.binder.d.ts +50 -27
- package/dist/protocol/protocol.binder.js +12 -9
- package/dist/protocol/protocol.handler.d.ts +22 -13
- package/dist/protocol/protocol.handler.js +91 -17
- package/dist/protocol/unmounted-route.error.d.ts +4 -4
- package/dist/protocol/unmounted-route.error.js +2 -2
- package/dist/runtime/caller-data.copier.d.ts +22 -5
- package/dist/runtime/caller-data.copier.js +31 -14
- package/dist/runtime/caller-data.door.d.ts +17 -11
- package/dist/runtime/caller-data.door.js +6 -4
- package/dist/runtime/computed-read-runtime.d.ts +7 -6
- package/dist/runtime/computed-read-runtime.js +76 -50
- package/dist/runtime/computed-value.error.d.ts +7 -6
- package/dist/runtime/computed-value.error.js +5 -4
- package/dist/runtime/context-executor.runtime.d.ts +59 -0
- package/dist/runtime/context-executor.runtime.js +275 -0
- package/dist/runtime/create-requirement.d.ts +44 -79
- package/dist/runtime/create-requirement.js +213 -73
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +54 -27
- package/dist/runtime/diagnostics-reporter.js +24 -0
- package/dist/runtime/error-boundary.d.ts +65 -8
- package/dist/runtime/error-boundary.js +49 -19
- package/dist/runtime/error-guidance.d.ts +12 -0
- package/dist/runtime/error-guidance.js +1 -0
- package/dist/runtime/error.catalog.d.ts +49 -0
- package/dist/runtime/error.catalog.js +49 -0
- package/dist/runtime/execution-options.d.ts +10 -2
- package/dist/runtime/field-check.evaluator.d.ts +29 -0
- package/dist/runtime/field-check.evaluator.js +521 -0
- package/dist/runtime/field-compute.d.ts +64 -0
- package/dist/runtime/field-compute.js +1 -0
- package/dist/runtime/field-stage.plan.d.ts +15 -0
- package/dist/runtime/field-stage.plan.js +27 -0
- package/dist/runtime/field-stage.runtime.d.ts +37 -0
- package/dist/runtime/field-stage.runtime.js +147 -0
- package/dist/runtime/field-validator.runtime.d.ts +19 -0
- package/dist/runtime/field-validator.runtime.js +92 -0
- package/dist/runtime/framework-error-class.table.d.ts +33 -0
- package/dist/runtime/framework-error-class.table.js +25 -0
- package/dist/runtime/framework-error.d.ts +68 -8
- package/dist/runtime/framework-error.factory.d.ts +4 -0
- package/dist/runtime/framework-error.factory.js +15 -0
- package/dist/runtime/framework-error.js +23 -2
- package/dist/runtime/interceptor-next.error.d.ts +5 -0
- package/dist/runtime/interceptor-next.error.js +6 -0
- package/dist/runtime/json-value.d.ts +11 -6
- package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
- package/dist/runtime/level-lifecycle.runtime.js +39 -0
- package/dist/runtime/misuse-reporter.d.ts +12 -12
- package/dist/runtime/mutation-planner.d.ts +19 -10
- package/dist/runtime/mutation-planner.js +48 -35
- package/dist/runtime/nested-write.walker.d.ts +32 -0
- package/dist/runtime/nested-write.walker.js +73 -0
- package/dist/runtime/operation-code.guidance.d.ts +6 -0
- package/dist/runtime/operation-code.guidance.js +167 -0
- package/dist/runtime/operation-request.d.ts +33 -6
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +127 -25
- package/dist/runtime/operation-runtime.js +441 -78
- package/dist/runtime/outcome-mapper.d.ts +16 -5
- package/dist/runtime/outcome-mapper.js +23 -6
- package/dist/runtime/output-validator.d.ts +10 -10
- package/dist/runtime/output-validator.js +3 -3
- package/dist/runtime/owned-execution.registry.d.ts +16 -6
- package/dist/runtime/pipe-output.validator.d.ts +43 -18
- package/dist/runtime/pipe-output.validator.js +15 -13
- package/dist/runtime/pipeline.d.ts +223 -34
- package/dist/runtime/readonly-value.d.ts +43 -0
- package/dist/runtime/readonly-value.js +150 -0
- package/dist/runtime/request-envelope.validator.d.ts +3 -3
- package/dist/runtime/request-envelope.validator.js +12 -7
- package/dist/runtime/request-id.d.ts +1 -1
- package/dist/runtime/request-state.d.ts +14 -0
- package/dist/runtime/request-state.js +1 -0
- package/dist/runtime/request-state.resolver.d.ts +12 -0
- package/dist/runtime/request-state.resolver.js +20 -0
- package/dist/runtime/scalar-runtime.d.ts +35 -16
- package/dist/runtime/scalar-runtime.js +102 -34
- package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
- package/dist/runtime/unsent-value.normalizer.js +128 -0
- package/dist/transactions/deferred-operation.d.ts +35 -20
- package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
- package/dist/transactions/operation-arguments-encoder.js +2 -2
- package/dist/transactions/operation-fingerprint.js +2 -2
- package/dist/transactions/sql-statement.d.ts +85 -0
- package/dist/transactions/sql-statement.js +47 -0
- package/dist/transactions/sql-statement.validator.d.ts +44 -0
- package/dist/transactions/sql-statement.validator.js +167 -0
- package/dist/transactions/transaction-envelope.d.ts +4 -4
- package/dist/transactions/transaction-integrity-error.d.ts +6 -6
- package/dist/transactions/transaction-integrity-error.js +5 -2
- package/dist/transactions/transaction-plan-assembler.d.ts +21 -11
- package/dist/transactions/transaction-plan-assembler.js +169 -32
- package/dist/transactions/transaction-plan-validator.d.ts +45 -20
- package/dist/transactions/transaction-plan-validator.js +96 -38
- package/dist/transactions/transaction-reference-collector.d.ts +5 -5
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +26 -14
- package/dist/transactions/transaction-reference-validator.d.ts +76 -4
- package/dist/transactions/transaction-reference-validator.js +129 -71
- package/dist/transactions/transaction-reference.d.ts +13 -13
- package/dist/transactions/transaction-reference.js +5 -0
- package/dist/transactions/transaction-request.d.ts +18 -5
- package/dist/transactions/transaction-response.d.ts +6 -6
- package/dist/transactions/transaction-runtime.d.ts +8 -7
- package/dist/transactions/transaction-runtime.js +191 -50
- package/dist/transactions/transaction-settlement.runtime.d.ts +51 -0
- package/dist/transactions/transaction-settlement.runtime.js +120 -0
- package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
- package/dist/transactions/transaction-slot-path-error.js +2 -2
- package/dist/transactions/transaction-slot-writer.js +2 -2
- package/dist/transactions/transaction-stage.runtime.d.ts +82 -0
- package/dist/transactions/transaction-stage.runtime.js +126 -0
- package/package.json +9 -7
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -42
- package/dist/config/define-fields.js +0 -3
- package/dist/config/framework-behaviors-config.d.ts +0 -30
- package/dist/config/framework-fields-config.d.ts +0 -42
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/json/avz.d.ts +0 -96
- package/dist/runtime/field-behavior.d.ts +0 -48
- /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
- /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
- /package/dist/{json → avz}/index.js +0 -0
- /package/dist/{json → avz}/json-shape.registry.js +0 -0
- /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
- /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { AvContractLimits } from "./contract-limits.js";
|
|
2
|
+
import type { AvContractClientProtocol } from "./contract-protocol.js";
|
|
3
|
+
import type { AvEnumDefinition } from "./enum-definition.js";
|
|
4
4
|
import type { ReferenceWriteLimit } from "./reference-write-limit.js";
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
5
|
+
import type { AvResource } from "./resource.js";
|
|
6
|
+
import type { AvScalarRegistry } from "./scalar.js";
|
|
7
|
+
import type { AvTransactionCapability } from "./transaction-capability.js";
|
|
8
8
|
/** What every Contract describes: scalars, enums, Resources, limits and transactions. */
|
|
9
|
-
export interface
|
|
9
|
+
export interface AvContract {
|
|
10
10
|
/** The scalar types available. */
|
|
11
|
-
readonly scalars:
|
|
11
|
+
readonly scalars: AvScalarRegistry;
|
|
12
12
|
/** The enums, by name. */
|
|
13
|
-
readonly enums: Readonly<Record<string,
|
|
13
|
+
readonly enums: Readonly<Record<string, AvEnumDefinition>>;
|
|
14
14
|
/** The Resources, by name. */
|
|
15
|
-
readonly resources: Readonly<Record<string,
|
|
15
|
+
readonly resources: Readonly<Record<string, AvResource<this>>>;
|
|
16
16
|
/** The request limits in force. */
|
|
17
|
-
readonly limits:
|
|
17
|
+
readonly limits: AvContractLimits;
|
|
18
18
|
/** Whether interactive transactions are available. */
|
|
19
|
-
readonly transactions:
|
|
19
|
+
readonly transactions: AvTransactionCapability;
|
|
20
20
|
/**
|
|
21
21
|
* `"uniform"` when one record must write the relations that hold a reference
|
|
22
22
|
* either all as relations or all through their reference fields; a record
|
|
@@ -25,16 +25,24 @@ export interface Contract {
|
|
|
25
25
|
readonly referenceWrites?: ReferenceWriteLimit;
|
|
26
26
|
}
|
|
27
27
|
/** The Contract compiled from the root configuration. */
|
|
28
|
-
export interface
|
|
28
|
+
export interface AvContractCore extends AvContract {
|
|
29
29
|
}
|
|
30
30
|
/** The Contract in-process calls run under (`framework.application`). */
|
|
31
|
-
export interface
|
|
31
|
+
export interface AvContractApplication extends AvContract {
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* The Contract remote clients run under, published at `GET /_contract` and
|
|
35
35
|
* identified by its hash.
|
|
36
36
|
*/
|
|
37
|
-
export interface
|
|
37
|
+
export interface AvContractClient extends AvContract {
|
|
38
38
|
/** The protocol version and this Contract's hash. */
|
|
39
|
-
readonly protocol:
|
|
39
|
+
readonly protocol: AvContractClientProtocol;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The Contract an AI agent's calls run under (the `agent` layer), identified by
|
|
43
|
+
* its hash. MCP tools are built from it.
|
|
44
|
+
*/
|
|
45
|
+
export interface AvContractAgent extends AvContract {
|
|
46
|
+
/** The protocol version and this Contract's hash. */
|
|
47
|
+
readonly protocol: AvContractClientProtocol;
|
|
40
48
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A required to-one relation and the scalar fields that hold its reference,
|
|
3
|
+
* relation first: `["author", "authorId"]`. A create writes the relation, or
|
|
4
|
+
* every one of the fields together (`["author", "tenantId", "authorId"]` for a
|
|
5
|
+
* composite reference), never both.
|
|
6
|
+
*/
|
|
7
|
+
export type AvCreateRequirementGroup = readonly [string, string, ...string[]];
|
|
8
|
+
/**
|
|
9
|
+
* What a create of one Resource cannot do without, as the Contract's layer
|
|
10
|
+
* exposes it. Only fields the layer lets a caller write at create appear: a
|
|
11
|
+
* group whose reference fields the layer hides is its relation alone, in
|
|
12
|
+
* `required`; one whose relation it hides is its reference fields, in
|
|
13
|
+
* `required`; a field a compute stage fills at create (`COMPUTED_ON_CREATE`) is
|
|
14
|
+
* not required.
|
|
15
|
+
*/
|
|
16
|
+
export type AvCreateRequirements = {
|
|
17
|
+
/**
|
|
18
|
+
* The fields every create must write: scalars with no default, generated or
|
|
19
|
+
* computed value, and relations whose reference fields the layer hides.
|
|
20
|
+
*/
|
|
21
|
+
readonly required?: readonly [string, ...string[]];
|
|
22
|
+
/** The required relations a create writes either way: see {@link AvCreateRequirementGroup}. */
|
|
23
|
+
readonly oneOf?: readonly [
|
|
24
|
+
AvCreateRequirementGroup,
|
|
25
|
+
...AvCreateRequirementGroup[]
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* By parent Resource, then by its relation: the fields above that a create
|
|
29
|
+
* nested through that relation gets from its parent, so it is not required
|
|
30
|
+
* there. `{ "User": { "posts": ["author", "authorId"] } }`: a post created in
|
|
31
|
+
* `User.posts` needs neither `author` nor `authorId`; a group any of whose
|
|
32
|
+
* fields is listed is satisfied whole.
|
|
33
|
+
*/
|
|
34
|
+
readonly parentSupplies?: Readonly<Record<string, Readonly<Record<string, readonly [string, ...string[]]>>>>;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** The named string formats: what `AvZ.email()`, `AvZ.uuid()` and the rest check. */
|
|
2
|
+
export type AvFieldCheckFormat = "email" | "url" | "emoji" | "uuid" | "guid" | "nanoid" | "cuid" | "cuid2" | "ulid" | "xid" | "ksuid" | "datetime" | "date" | "time" | "duration" | "ipv4" | "ipv6" | "cidrv4" | "cidrv6" | "base64" | "base64url" | "json_string" | "e164" | "credit_card" | "iban" | "jwt";
|
|
3
|
+
/**
|
|
4
|
+
* A bound on a value (`AvZ.lt`, `AvZ.gte`, `AvZ.positive`, …). `value` is a number
|
|
5
|
+
* for an `int` or `float` field and a Json number; for a `bigint`, `decimal` or
|
|
6
|
+
* `datetime` field it is the bound's wire string.
|
|
7
|
+
*/
|
|
8
|
+
export type AvFieldRangeCheck = {
|
|
9
|
+
readonly check: "less_than" | "greater_than";
|
|
10
|
+
readonly value: number | string;
|
|
11
|
+
readonly inclusive: boolean;
|
|
12
|
+
};
|
|
13
|
+
/** `AvZ.multipleOf`: `value` is written as {@link AvFieldRangeCheck}'s is. */
|
|
14
|
+
export type AvFieldMultipleCheck = {
|
|
15
|
+
readonly check: "multiple_of";
|
|
16
|
+
readonly value: number | string;
|
|
17
|
+
};
|
|
18
|
+
/** A length bound: a string's, or with `list: true` a list's. */
|
|
19
|
+
export type AvFieldLengthCheck = {
|
|
20
|
+
readonly check: "max_length";
|
|
21
|
+
readonly maximum: number;
|
|
22
|
+
readonly list?: true;
|
|
23
|
+
} | {
|
|
24
|
+
readonly check: "min_length";
|
|
25
|
+
readonly minimum: number;
|
|
26
|
+
readonly list?: true;
|
|
27
|
+
} | {
|
|
28
|
+
readonly check: "length_equals";
|
|
29
|
+
readonly length: number;
|
|
30
|
+
};
|
|
31
|
+
/** A pattern or a named format a string must match. */
|
|
32
|
+
export type AvFieldFormatCheck = {
|
|
33
|
+
readonly check: "string_format";
|
|
34
|
+
readonly format: "regex";
|
|
35
|
+
/** A JavaScript regular expression: its `source` and its `flags`. */
|
|
36
|
+
readonly pattern: {
|
|
37
|
+
readonly source: string;
|
|
38
|
+
readonly flags: string;
|
|
39
|
+
};
|
|
40
|
+
} | {
|
|
41
|
+
readonly check: "string_format";
|
|
42
|
+
readonly format: "includes";
|
|
43
|
+
readonly includes: string;
|
|
44
|
+
} | {
|
|
45
|
+
readonly check: "string_format";
|
|
46
|
+
readonly format: "starts_with";
|
|
47
|
+
readonly prefix: string;
|
|
48
|
+
} | {
|
|
49
|
+
readonly check: "string_format";
|
|
50
|
+
readonly format: "ends_with";
|
|
51
|
+
readonly suffix: string;
|
|
52
|
+
} | {
|
|
53
|
+
readonly check: "string_format";
|
|
54
|
+
readonly format: "lowercase" | "uppercase" | AvFieldCheckFormat;
|
|
55
|
+
};
|
|
56
|
+
/** A `bytes` value's byte length. */
|
|
57
|
+
export type AvFieldSizeCheck = {
|
|
58
|
+
readonly check: "max_size";
|
|
59
|
+
readonly maximum: number;
|
|
60
|
+
} | {
|
|
61
|
+
readonly check: "min_size";
|
|
62
|
+
readonly minimum: number;
|
|
63
|
+
} | {
|
|
64
|
+
readonly check: "size_equals";
|
|
65
|
+
readonly size: number;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* One field validator as the Contract stores it: its check's name (`check`) and
|
|
69
|
+
* the check's parameters.
|
|
70
|
+
*/
|
|
71
|
+
export type AvFieldCheck = AvFieldRangeCheck | AvFieldMultipleCheck | AvFieldLengthCheck | AvFieldFormatCheck | AvFieldSizeCheck;
|
|
72
|
+
/** The checks a Json Shape's string node may carry: its length, a pattern or a format. */
|
|
73
|
+
export type AvJsonStringCheck = {
|
|
74
|
+
readonly check: "max_length";
|
|
75
|
+
readonly maximum: number;
|
|
76
|
+
} | {
|
|
77
|
+
readonly check: "min_length";
|
|
78
|
+
readonly minimum: number;
|
|
79
|
+
} | {
|
|
80
|
+
readonly check: "length_equals";
|
|
81
|
+
readonly length: number;
|
|
82
|
+
} | AvFieldFormatCheck;
|
|
83
|
+
/** The checks a Json Shape's number or integer node may carry: bounds are numbers. */
|
|
84
|
+
export type AvJsonNumberCheck = {
|
|
85
|
+
readonly check: "less_than" | "greater_than";
|
|
86
|
+
readonly value: number;
|
|
87
|
+
readonly inclusive: boolean;
|
|
88
|
+
} | {
|
|
89
|
+
readonly check: "multiple_of";
|
|
90
|
+
readonly value: number;
|
|
91
|
+
};
|
|
92
|
+
/** The checks a Json Shape's array node may carry: its length. */
|
|
93
|
+
export type AvJsonListCheck = {
|
|
94
|
+
readonly check: "max_length";
|
|
95
|
+
readonly maximum: number;
|
|
96
|
+
readonly list: true;
|
|
97
|
+
} | {
|
|
98
|
+
readonly check: "min_length";
|
|
99
|
+
readonly minimum: number;
|
|
100
|
+
readonly list: true;
|
|
101
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,72 +1,89 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AvPaginationCapability, AvProjectionScope, AvRelationFilterCapability, AvRelationMutationDirective, AvRelationReducer, AvScalarFilterOperator, AvScalarMutationDirective, AvWriteScope, ScalarFilterMode } from "./capability.js";
|
|
2
|
+
import type { AvContract } from "./contract.js";
|
|
3
|
+
import type { AvFieldCheck } from "./field-check.js";
|
|
3
4
|
import type { JsonSchema } from "./json-shape.js";
|
|
4
|
-
import type {
|
|
5
|
+
import type { AvLifecycleTrait } from "./lifecycle-trait.js";
|
|
5
6
|
/** A format name that refines a scalar type, carried in the Contract as data. */
|
|
6
|
-
export type
|
|
7
|
+
export type AvScalarFormat = string;
|
|
7
8
|
/** The projection positions a field can be selected in (at least one). */
|
|
8
|
-
export type
|
|
9
|
+
export type AvProjectionScopes = readonly [
|
|
10
|
+
AvProjectionScope,
|
|
11
|
+
...AvProjectionScope[]
|
|
12
|
+
];
|
|
9
13
|
/**
|
|
10
14
|
* The write positions a field can be written in (at least one). A scope list
|
|
11
|
-
* applies to the top level of a write argument only; see {@link
|
|
15
|
+
* applies to the top level of a write argument only; see {@link AvWriteScope}.
|
|
12
16
|
*/
|
|
13
|
-
export type
|
|
17
|
+
export type AvWriteScopes = readonly [AvWriteScope, ...AvWriteScope[]];
|
|
14
18
|
/**
|
|
15
19
|
* Whether a relation can be selected or included: `true`, or the projection
|
|
16
20
|
* positions it can be used in.
|
|
17
21
|
*/
|
|
18
|
-
export type
|
|
22
|
+
export type AvRelationProjectionCapability = boolean | AvProjectionScopes;
|
|
19
23
|
/**
|
|
20
24
|
* The reducers a relation admits, qualified by the projection positions they are
|
|
21
25
|
* admitted in. The reducer list and the scope list are separate facts: `$count` is
|
|
22
26
|
* one of a closed set of reducers, and the scopes say where the reducer may be
|
|
23
27
|
* asked for.
|
|
24
28
|
*/
|
|
25
|
-
export type
|
|
26
|
-
readonly reducers: readonly
|
|
27
|
-
readonly scopes:
|
|
29
|
+
export type AvScopedRelationReducers = {
|
|
30
|
+
readonly reducers: readonly AvRelationReducer[];
|
|
31
|
+
readonly scopes: AvProjectionScopes;
|
|
28
32
|
};
|
|
29
33
|
/**
|
|
30
34
|
* A relation's reducers: a reducer list, or an object with the reducers and
|
|
31
35
|
* the projection positions they apply in.
|
|
32
36
|
*/
|
|
33
|
-
export type
|
|
37
|
+
export type AvRelationReducerCapability = readonly AvRelationReducer[] | AvScopedRelationReducers;
|
|
34
38
|
/**
|
|
35
39
|
* The mutation directives a relation admits at one write stage, and the write
|
|
36
40
|
* positions they are admitted in. `directives: []` means writable with no
|
|
37
41
|
* directive.
|
|
38
42
|
*/
|
|
39
|
-
export type
|
|
40
|
-
readonly directives: readonly
|
|
41
|
-
readonly scopes:
|
|
43
|
+
export type AvScopedRelationMutations = {
|
|
44
|
+
readonly directives: readonly AvRelationMutationDirective[];
|
|
45
|
+
readonly scopes: AvWriteScopes;
|
|
42
46
|
};
|
|
43
47
|
/**
|
|
44
48
|
* A relation's write capability for `create` or `update`: a directive list, or
|
|
45
49
|
* an object with the directives and the write positions they apply in.
|
|
46
50
|
*/
|
|
47
|
-
export type
|
|
51
|
+
export type AvRelationMutationCapability = readonly AvRelationMutationDirective[] | AvScopedRelationMutations;
|
|
48
52
|
/** What can be done with a scalar field. Scalar capabilities apply in every position. */
|
|
49
|
-
export type
|
|
53
|
+
export type AvScalarFieldCapabilities = {
|
|
50
54
|
readonly select?: boolean;
|
|
51
|
-
readonly filter?: readonly
|
|
55
|
+
readonly filter?: readonly AvScalarFilterOperator[];
|
|
56
|
+
/**
|
|
57
|
+
* The modes the `mode` operator takes on this field: `"default"` (the
|
|
58
|
+
* database's own comparison) always, and `"sensitive"` or `"insensitive"`
|
|
59
|
+
* where the adapter honours them. Present exactly when `filter` offers `mode`.
|
|
60
|
+
*/
|
|
61
|
+
readonly filterModes?: readonly ScalarFilterMode[];
|
|
62
|
+
/**
|
|
63
|
+
* A `json` field's modes when the filter names a `path`: the text compared is
|
|
64
|
+
* the value at that path rather than the whole document, and the database may
|
|
65
|
+
* honour more modes there. Present exactly when `filter` offers `mode` and
|
|
66
|
+
* `path`; without a `path`, `filterModes` applies.
|
|
67
|
+
*/
|
|
68
|
+
readonly pathFilterModes?: readonly ScalarFilterMode[];
|
|
52
69
|
readonly order?: boolean;
|
|
53
70
|
readonly orderNulls?: boolean;
|
|
54
|
-
readonly create?: readonly
|
|
55
|
-
readonly update?: readonly
|
|
71
|
+
readonly create?: readonly AvScalarMutationDirective[];
|
|
72
|
+
readonly update?: readonly AvScalarMutationDirective[];
|
|
56
73
|
};
|
|
57
74
|
/** What can be done with a relation field. */
|
|
58
|
-
export type
|
|
59
|
-
readonly select?:
|
|
60
|
-
readonly include?:
|
|
61
|
-
readonly filter?: readonly
|
|
75
|
+
export type AvRelationFieldCapabilities = {
|
|
76
|
+
readonly select?: AvRelationProjectionCapability;
|
|
77
|
+
readonly include?: AvRelationProjectionCapability;
|
|
78
|
+
readonly filter?: readonly AvRelationFilterCapability[];
|
|
62
79
|
readonly order?: boolean;
|
|
63
|
-
readonly pagination?: readonly
|
|
64
|
-
readonly reducers?:
|
|
65
|
-
readonly create?:
|
|
66
|
-
readonly update?:
|
|
80
|
+
readonly pagination?: readonly AvPaginationCapability[];
|
|
81
|
+
readonly reducers?: AvRelationReducerCapability;
|
|
82
|
+
readonly create?: AvRelationMutationCapability;
|
|
83
|
+
readonly update?: AvRelationMutationCapability;
|
|
67
84
|
/**
|
|
68
85
|
* What the `where` of a nested `$update` or `$delete` through this relation may
|
|
69
|
-
* filter: `"scalar"`
|
|
86
|
+
* filter: `"scalar"` means the target's scalar fields only, combined with
|
|
70
87
|
* `AND`/`OR`/`NOT`, and no relation filter at any depth. Absent: any filter the
|
|
71
88
|
* target takes.
|
|
72
89
|
*/
|
|
@@ -76,53 +93,75 @@ export type RelationFieldCapabilities = {
|
|
|
76
93
|
* The reducers a relation advertises, in any projection position. Use
|
|
77
94
|
* {@link advertisedReducersAt} for one position.
|
|
78
95
|
*/
|
|
79
|
-
export declare function advertisedReducers(capability:
|
|
96
|
+
export declare function advertisedReducers(capability: AvRelationReducerCapability | undefined): readonly AvRelationReducer[] | undefined;
|
|
80
97
|
/** Whether a projection capability holds at one projection position. */
|
|
81
|
-
export declare function holdsAt(capability:
|
|
98
|
+
export declare function holdsAt(capability: AvRelationProjectionCapability | undefined, scope: AvProjectionScope): boolean;
|
|
82
99
|
/**
|
|
83
100
|
* Whether a projection capability holds in **any** projection position. Use
|
|
84
101
|
* {@link holdsAt} when the position is known.
|
|
85
102
|
*/
|
|
86
|
-
export declare function holdsInAnyScope(capability:
|
|
103
|
+
export declare function holdsInAnyScope(capability: AvRelationProjectionCapability | undefined): boolean;
|
|
87
104
|
/**
|
|
88
105
|
* The reducers a relation advertises at one projection position, or
|
|
89
106
|
* `undefined` where it has none there.
|
|
90
107
|
*/
|
|
91
|
-
export declare function advertisedReducersAt(capability:
|
|
108
|
+
export declare function advertisedReducersAt(capability: AvRelationReducerCapability | undefined, scope: AvProjectionScope): readonly AvRelationReducer[] | undefined;
|
|
92
109
|
/**
|
|
93
110
|
* The mutation directives a relation advertises at one write stage, in any
|
|
94
111
|
* write position. `undefined` means the stage is unavailable; `[]` means
|
|
95
112
|
* available with no directive.
|
|
96
113
|
*/
|
|
97
|
-
export declare function advertisedDirectives(capability:
|
|
114
|
+
export declare function advertisedDirectives(capability: AvRelationMutationCapability | undefined): readonly AvRelationMutationDirective[] | undefined;
|
|
98
115
|
/**
|
|
99
116
|
* The mutation directives a relation advertises at one write position, or
|
|
100
117
|
* `undefined` where it is not writable there.
|
|
101
118
|
*/
|
|
102
|
-
export declare function advertisedDirectivesAt(capability:
|
|
119
|
+
export declare function advertisedDirectivesAt(capability: AvRelationMutationCapability | undefined, scope: AvWriteScope): readonly AvRelationMutationDirective[] | undefined;
|
|
103
120
|
/** A scalar field, including an enum-backed one. */
|
|
104
|
-
export type
|
|
121
|
+
export type AvScalarField<C extends AvContract> = {
|
|
105
122
|
readonly kind: "scalar";
|
|
106
123
|
readonly type: {
|
|
107
124
|
readonly scalar: Extract<keyof C["scalars"], string>;
|
|
108
125
|
} | {
|
|
109
126
|
readonly enum: Extract<keyof C["enums"], string>;
|
|
110
127
|
};
|
|
111
|
-
readonly format?:
|
|
128
|
+
readonly format?: AvScalarFormat;
|
|
112
129
|
readonly nullable: boolean;
|
|
113
130
|
readonly list: boolean;
|
|
114
|
-
readonly lifecycle: readonly
|
|
115
|
-
readonly capabilities:
|
|
131
|
+
readonly lifecycle: readonly AvLifecycleTrait[];
|
|
132
|
+
readonly capabilities: AvScalarFieldCapabilities;
|
|
116
133
|
/** A `json` field's shape, as JSON Schema: what every value written to it is. */
|
|
117
134
|
readonly json?: JsonSchema;
|
|
135
|
+
/**
|
|
136
|
+
* The field's validators: the root's checks, then the overlay's, in
|
|
137
|
+
* registration order. On a list field a check applies to each entry, except a
|
|
138
|
+
* `list: true` length check, which applies to the list.
|
|
139
|
+
*/
|
|
140
|
+
readonly validators?: readonly AvFieldCheck[];
|
|
118
141
|
};
|
|
119
142
|
/** A relation field; the `target` Resource describes the related row. */
|
|
120
|
-
export type
|
|
143
|
+
export type AvRelationField<C extends AvContract> = {
|
|
121
144
|
readonly kind: "relation";
|
|
122
145
|
readonly target: Extract<keyof C["resources"], string>;
|
|
123
146
|
readonly cardinality: "one" | "many";
|
|
124
147
|
readonly nullable: boolean;
|
|
125
|
-
readonly capabilities:
|
|
148
|
+
readonly capabilities: AvRelationFieldCapabilities;
|
|
149
|
+
/**
|
|
150
|
+
* The target's relation field that is this relation's other end
|
|
151
|
+
* (`User.posts` ↔ `Post.author`): a record written through this relation sits
|
|
152
|
+
* at that field's `"loopback"` write position. Absent when the adapter states
|
|
153
|
+
* no pairing or the layer hides the other end.
|
|
154
|
+
*/
|
|
155
|
+
readonly inverse?: string;
|
|
156
|
+
/**
|
|
157
|
+
* The scalar fields of this Resource that hold the relation's reference, in the
|
|
158
|
+
* order the data source pairs them with the target's key (`Post.category` has
|
|
159
|
+
* `["categoryId"]`). Writing the relation and one of them in one record names
|
|
160
|
+
* the reference twice; inside a record written through the relation's other
|
|
161
|
+
* end they sit at the `"loopback"` position with it. Absent on the end that
|
|
162
|
+
* holds no reference, and where the layer shows none of them.
|
|
163
|
+
*/
|
|
164
|
+
readonly referenceFields?: readonly [string, ...string[]];
|
|
126
165
|
};
|
|
127
166
|
/** One field of a Resource: a scalar or a relation. */
|
|
128
|
-
export type
|
|
167
|
+
export type AvField<C extends AvContract> = AvScalarField<C> | AvRelationField<C>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AvContract } from "./contract.js";
|
|
2
|
+
import type { AvField } from "./field.js";
|
|
3
3
|
/** Keys of `TFields` whose field can be scalar-shaped. */
|
|
4
|
-
export type
|
|
4
|
+
export type AvScalarFieldKey<TFields extends Readonly<Record<string, AvField<AvContract>>>> = Extract<{
|
|
5
5
|
[K in keyof TFields]: [
|
|
6
6
|
Extract<TFields[K], {
|
|
7
7
|
readonly kind: "scalar";
|
|
@@ -9,4 +9,4 @@ export type ScalarFieldKey<TFields extends Readonly<Record<string, Field<Contrac
|
|
|
9
9
|
] extends [never] ? never : K;
|
|
10
10
|
}[keyof TFields], string>;
|
|
11
11
|
/** Non-empty tuple of scalar field keys that identifies at most one Resource. */
|
|
12
|
-
export type
|
|
12
|
+
export type AvIdentifier<TFields extends Readonly<Record<string, AvField<AvContract>>>> = readonly [AvScalarFieldKey<TFields>, ...AvScalarFieldKey<TFields>[]];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AvJsonListCheck, AvJsonNumberCheck, AvJsonStringCheck } from "./field-check.js";
|
|
1
2
|
/**
|
|
2
3
|
* The phantom key a Json Shape's TypeScript type travels under. Type-level only:
|
|
3
4
|
* no value ever holds it.
|
|
@@ -20,7 +21,15 @@ export type JsonSchemaPrimitive = string | number | boolean | null;
|
|
|
20
21
|
* the forms Aventara emits.
|
|
21
22
|
*/
|
|
22
23
|
export type JsonSchema = {
|
|
23
|
-
readonly type: "
|
|
24
|
+
readonly type: "boolean" | "null";
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
/** The node's checks, in the order they were added. */
|
|
28
|
+
readonly checks?: readonly AvJsonStringCheck[];
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "number" | "integer";
|
|
31
|
+
/** The node's checks, in the order they were added. */
|
|
32
|
+
readonly checks?: readonly AvJsonNumberCheck[];
|
|
24
33
|
} | {
|
|
25
34
|
readonly const: JsonSchemaPrimitive;
|
|
26
35
|
} | {
|
|
@@ -39,6 +48,8 @@ export type JsonSchema = {
|
|
|
39
48
|
} | {
|
|
40
49
|
readonly type: "array";
|
|
41
50
|
readonly items: JsonSchema;
|
|
51
|
+
/** The list's length checks, in the order they were added. */
|
|
52
|
+
readonly checks?: readonly AvJsonListCheck[];
|
|
42
53
|
} | {
|
|
43
54
|
readonly type: "array";
|
|
44
55
|
readonly prefixItems: readonly [JsonSchema, ...JsonSchema[]];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Where a field's value comes from, without saying whether it is writable:
|
|
3
3
|
* `DEFAULTED` and `GENERATED_ON_*` by the data source, `COMPUTED_ON_*` by a
|
|
4
|
-
*
|
|
4
|
+
* compute stage; `VIRTUAL` marks a field that is not stored.
|
|
5
5
|
*/
|
|
6
6
|
export declare const LIFECYCLE_TRAITS: readonly ["DEFAULTED", "GENERATED_ON_CREATE", "GENERATED_ON_UPDATE", "COMPUTED_ON_CREATE", "COMPUTED_ON_UPDATE", "COMPUTED_ON_READ", "VIRTUAL"];
|
|
7
7
|
/** One of {@link LIFECYCLE_TRAITS}. */
|
|
8
|
-
export type
|
|
8
|
+
export type AvLifecycleTrait = (typeof LIFECYCLE_TRAITS)[number];
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AvProjectionScope, AvWriteScope } from "./capability.js";
|
|
2
2
|
/**
|
|
3
3
|
* The argument scopes one advertised operation variant qualifies its arguments
|
|
4
4
|
* with: which projection position its projection arguments sit in, and which write
|
|
5
5
|
* position its data argument sits in.
|
|
6
6
|
*/
|
|
7
|
-
export type
|
|
8
|
-
readonly projection:
|
|
9
|
-
readonly write?:
|
|
7
|
+
export type AvOperationVariantScopes = {
|
|
8
|
+
readonly projection: AvProjectionScope;
|
|
9
|
+
readonly write?: AvWriteScope;
|
|
10
10
|
} | {
|
|
11
|
-
readonly projection?:
|
|
12
|
-
readonly write:
|
|
11
|
+
readonly projection?: AvProjectionScope;
|
|
12
|
+
readonly write: AvWriteScope;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Availability of one standard operation variant: `true` for "available, with no
|
|
16
16
|
* scope qualification stated", or the scopes the variant qualifies its arguments
|
|
17
17
|
* with.
|
|
18
18
|
*/
|
|
19
|
-
export type
|
|
19
|
+
export type AvOperationAvailability = true | AvOperationVariantScopes;
|
|
20
20
|
/** Availability of protocol-defined standard operations for one Resource. */
|
|
21
|
-
export type
|
|
21
|
+
export type AvResourceOperations = {
|
|
22
22
|
readonly find?: {
|
|
23
|
-
readonly first?:
|
|
24
|
-
readonly unique?:
|
|
25
|
-
readonly many?:
|
|
26
|
-
readonly count?:
|
|
23
|
+
readonly first?: AvOperationAvailability;
|
|
24
|
+
readonly unique?: AvOperationAvailability;
|
|
25
|
+
readonly many?: AvOperationAvailability;
|
|
26
|
+
readonly count?: AvOperationAvailability;
|
|
27
27
|
};
|
|
28
28
|
readonly create?: {
|
|
29
|
-
readonly one?:
|
|
30
|
-
readonly many?:
|
|
31
|
-
readonly count?:
|
|
29
|
+
readonly one?: AvOperationAvailability;
|
|
30
|
+
readonly many?: AvOperationAvailability;
|
|
31
|
+
readonly count?: AvOperationAvailability;
|
|
32
32
|
};
|
|
33
33
|
readonly update?: {
|
|
34
|
-
readonly first?:
|
|
35
|
-
readonly unique?:
|
|
36
|
-
readonly many?:
|
|
37
|
-
readonly count?:
|
|
34
|
+
readonly first?: AvOperationAvailability;
|
|
35
|
+
readonly unique?: AvOperationAvailability;
|
|
36
|
+
readonly many?: AvOperationAvailability;
|
|
37
|
+
readonly count?: AvOperationAvailability;
|
|
38
38
|
};
|
|
39
39
|
readonly delete?: {
|
|
40
|
-
readonly first?:
|
|
41
|
-
readonly unique?:
|
|
42
|
-
readonly many?:
|
|
43
|
-
readonly count?:
|
|
40
|
+
readonly first?: AvOperationAvailability;
|
|
41
|
+
readonly unique?: AvOperationAvailability;
|
|
42
|
+
readonly many?: AvOperationAvailability;
|
|
43
|
+
readonly count?: AvOperationAvailability;
|
|
44
44
|
};
|
|
45
45
|
readonly upsert?: {
|
|
46
|
-
readonly unique?:
|
|
46
|
+
readonly unique?: AvOperationAvailability;
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
|
-
* Whether one `
|
|
50
|
+
* Whether one `AvResourceOperations` entry marks its variant available: it is
|
|
51
51
|
* `true` or an argument-position descriptor.
|
|
52
52
|
*/
|
|
53
|
-
export declare function isOperationVariantAvailable(availability: unknown): availability is
|
|
53
|
+
export declare function isOperationVariantAvailable(availability: unknown): availability is AvOperationAvailability;
|
|
54
54
|
/**
|
|
55
55
|
* The projection position one advertised variant's projection arguments sit in.
|
|
56
56
|
*/
|
|
57
|
-
export declare function projectionScopeOf(availability: unknown):
|
|
57
|
+
export declare function projectionScopeOf(availability: unknown): AvProjectionScope;
|
|
58
58
|
/**
|
|
59
59
|
* The write position one advertised variant's data argument sits in, and the write
|
|
60
60
|
* mirror of {@link projectionScopeOf}.
|
|
61
61
|
*/
|
|
62
|
-
export declare function writeScopeOf(availability: unknown):
|
|
62
|
+
export declare function writeScopeOf(availability: unknown): AvWriteScope;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import type { AvContract } from "./contract.js";
|
|
2
|
+
import type { AvCreateRequirements } from "./create-requirements.js";
|
|
3
|
+
import type { AvField } from "./field.js";
|
|
4
|
+
import type { AvIdentifier } from "./identifier.js";
|
|
5
|
+
import type { AvResourceOperations } from "./resource-operations.js";
|
|
5
6
|
/** A Resource's fields, by name. */
|
|
6
|
-
export type
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
export type AvResourceFieldMap<C extends AvContract> = Readonly<Record<string, AvField<C>>>;
|
|
8
|
+
/**
|
|
9
|
+
* One Resource: its fields, identifiers and available operations, and what a
|
|
10
|
+
* create of it cannot do without.
|
|
11
|
+
*/
|
|
12
|
+
export type AvResource<C extends AvContract, TFields extends AvResourceFieldMap<C> = AvResourceFieldMap<C>> = {
|
|
9
13
|
readonly fields: TFields;
|
|
10
|
-
readonly identifiers: readonly
|
|
11
|
-
readonly operations:
|
|
14
|
+
readonly identifiers: readonly AvIdentifier<TFields>[];
|
|
15
|
+
readonly operations: AvResourceOperations;
|
|
16
|
+
/** What a create must write; absent when it requires nothing. */
|
|
17
|
+
readonly createRequirements?: AvCreateRequirements;
|
|
12
18
|
};
|