@aventara/core 1.0.0-rc.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1140 -0
- package/README.md +224 -57
- package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
- package/dist/adapters/adapter-field.d.ts +11 -11
- package/dist/adapters/adapter-identifier.d.ts +6 -6
- package/dist/adapters/adapter-model.d.ts +9 -9
- package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
- package/dist/adapters/adapter-operation.d.ts +3 -3
- package/dist/adapters/adapter-resource.d.ts +18 -9
- package/dist/adapters/adapter-sql-statement.d.ts +19 -0
- package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
- package/dist/adapters/adapter.interface.d.ts +49 -29
- package/dist/avz/avz-check.factory.d.ts +83 -0
- package/dist/avz/avz-check.factory.js +116 -0
- package/dist/avz/avz-check.registry.d.ts +35 -0
- package/dist/avz/avz-check.registry.js +9 -0
- package/dist/avz/avz.d.ts +203 -0
- package/dist/{json → avz}/avz.js +150 -8
- package/dist/{json → avz}/index.d.ts +2 -1
- package/dist/{json → avz}/json-shape.registry.d.ts +7 -7
- package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
- package/dist/{json → avz}/zod-issue.translator.js +7 -0
- package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
- package/dist/compiler/contract.compiler.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +548 -441
- package/dist/compiler/create-requirements.projector.d.ts +49 -0
- package/dist/compiler/create-requirements.projector.js +423 -0
- package/dist/compiler/field-validator.compiler.d.ts +47 -0
- package/dist/compiler/field-validator.compiler.js +238 -0
- package/dist/config/any-framework-config.d.ts +19 -12
- package/dist/config/config-diagnostic.d.ts +11 -4
- package/dist/config/config-layer.d.ts +15 -6
- package/dist/config/config.resolver.d.ts +74 -31
- package/dist/config/config.resolver.js +108 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +581 -72
- package/dist/config/define-resource.d.ts +57 -0
- package/dist/config/define-resource.js +14 -0
- package/dist/config/effective-fields.d.ts +19 -23
- package/dist/config/entrypoint.normalizer.d.ts +1 -1
- package/dist/config/exact-framework-config.d.ts +280 -0
- package/dist/config/field-compute.resolver.d.ts +19 -0
- package/dist/config/field-compute.resolver.js +115 -0
- package/dist/config/field-pipeline-config.d.ts +47 -0
- package/dist/config/forced-operation.validator.d.ts +10 -0
- package/dist/config/forced-operation.validator.js +66 -0
- package/dist/config/framework-config.d.ts +110 -39
- package/dist/config/framework-exemptions-config.d.ts +91 -0
- package/dist/config/framework-exemptions-config.js +1 -0
- package/dist/config/framework-field-definition.d.ts +78 -0
- package/dist/config/framework-field-definition.js +28 -0
- package/dist/config/framework-resources-config.d.ts +116 -0
- package/dist/config/framework-resources-config.js +1 -0
- package/dist/config/pipeline-config.d.ts +56 -20
- package/dist/config/pipeline-tree.resolver.d.ts +79 -0
- package/dist/config/pipeline-tree.resolver.js +220 -0
- package/dist/config/stage-type.eraser.d.ts +65 -0
- package/dist/config/stage-type.eraser.js +1 -0
- package/dist/contracts/capability.d.ts +11 -11
- package/dist/contracts/client-contract-structure.validator.d.ts +323 -28
- package/dist/contracts/client-contract-structure.validator.js +152 -8
- package/dist/contracts/contract-canonicalizer.d.ts +19 -3
- package/dist/contracts/contract-canonicalizer.js +141 -28
- package/dist/contracts/contract-hash.d.ts +12 -7
- package/dist/contracts/contract-hash.js +3 -2
- package/dist/contracts/contract-limits.d.ts +4 -1
- package/dist/contracts/contract-limits.js +1 -0
- package/dist/contracts/contract-lookup.d.ts +5 -5
- package/dist/contracts/contract-protocol.d.ts +4 -4
- package/dist/contracts/contract.d.ts +24 -16
- package/dist/contracts/create-requirements.d.ts +35 -0
- package/dist/contracts/create-requirements.js +1 -0
- package/dist/contracts/enum-definition.d.ts +1 -1
- package/dist/contracts/field-check.d.ts +101 -0
- package/dist/contracts/field-check.js +1 -0
- package/dist/contracts/field.d.ts +52 -42
- package/dist/contracts/identifier.d.ts +4 -4
- package/dist/contracts/json-shape.d.ts +12 -1
- package/dist/contracts/lifecycle-trait.d.ts +2 -2
- package/dist/contracts/resource-operations.d.ts +28 -28
- package/dist/contracts/resource.d.ts +15 -9
- package/dist/contracts/scalar-value-type.d.ts +15 -15
- package/dist/contracts/scalar.d.ts +3 -3
- package/dist/contracts/transaction-capability.d.ts +1 -1
- package/dist/contracts/wire-scalar-format.d.ts +4 -4
- package/dist/framework/contract-view.d.ts +213 -147
- package/dist/framework/framework-construction.error.d.ts +10 -10
- package/dist/framework/framework-construction.error.js +2 -2
- package/dist/framework/framework.d.ts +47 -23
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +40 -20
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +55 -50
- package/dist/index.js +6 -6
- package/dist/internal.d.ts +15 -10
- package/dist/internal.js +3 -1
- package/dist/operations/operation-arguments.d.ts +267 -202
- package/dist/operations/operation-call.d.ts +27 -28
- package/dist/operations/operation-identity.d.ts +10 -10
- package/dist/operations/operation-result.d.ts +21 -21
- package/dist/operations/operation-validator-core.d.ts +6 -6
- package/dist/operations/operation-validator-core.js +13 -2
- package/dist/operations/operation-validator.d.ts +9 -9
- package/dist/operations/projection-scope.resolver.d.ts +6 -6
- package/dist/operations/structural-limits.walker.d.ts +6 -6
- package/dist/operations/structural-limits.walker.js +145 -0
- package/dist/operations/validation-code.d.ts +11 -6
- package/dist/operations/validation-code.js +4 -0
- package/dist/operations/write-scope.resolver.d.ts +6 -6
- package/dist/protocol/absent-route.responder.d.ts +13 -12
- package/dist/protocol/absent-route.responder.js +19 -19
- package/dist/protocol/contract-document.responder.d.ts +3 -3
- package/dist/protocol/contract-document.responder.js +2 -2
- package/dist/protocol/http-request.decoder.d.ts +17 -13
- package/dist/protocol/http-request.decoder.js +10 -10
- package/dist/protocol/http-request.reader.d.ts +3 -3
- package/dist/protocol/http-response.encoder.d.ts +4 -4
- package/dist/protocol/http-response.encoder.js +94 -55
- package/dist/protocol/http-status.table.d.ts +2 -2
- package/dist/protocol/operation-response.guard.d.ts +2 -2
- package/dist/protocol/protocol-surface.d.ts +4 -4
- package/dist/protocol/protocol.binder.d.ts +50 -27
- package/dist/protocol/protocol.binder.js +12 -9
- package/dist/protocol/protocol.handler.d.ts +22 -13
- package/dist/protocol/protocol.handler.js +44 -9
- package/dist/protocol/unmounted-route.error.d.ts +4 -4
- package/dist/protocol/unmounted-route.error.js +2 -2
- package/dist/runtime/caller-data.copier.d.ts +5 -5
- package/dist/runtime/caller-data.copier.js +13 -13
- package/dist/runtime/caller-data.door.d.ts +6 -6
- package/dist/runtime/caller-data.door.js +6 -4
- package/dist/runtime/computed-read-runtime.d.ts +7 -6
- package/dist/runtime/computed-read-runtime.js +61 -48
- package/dist/runtime/computed-value.error.d.ts +6 -6
- package/dist/runtime/computed-value.error.js +3 -3
- package/dist/runtime/context-executor.runtime.d.ts +59 -0
- package/dist/runtime/context-executor.runtime.js +275 -0
- package/dist/runtime/create-requirement.d.ts +10 -81
- package/dist/runtime/create-requirement.js +80 -57
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +53 -27
- package/dist/runtime/diagnostics-reporter.js +24 -0
- package/dist/runtime/error-boundary.d.ts +65 -8
- package/dist/runtime/error-boundary.js +45 -19
- package/dist/runtime/execution-options.d.ts +10 -2
- package/dist/runtime/field-check.evaluator.d.ts +29 -0
- package/dist/runtime/field-check.evaluator.js +521 -0
- package/dist/runtime/field-compute.d.ts +64 -0
- package/dist/runtime/field-compute.js +1 -0
- package/dist/runtime/field-stage.plan.d.ts +15 -0
- package/dist/runtime/field-stage.plan.js +27 -0
- package/dist/runtime/field-stage.runtime.d.ts +35 -0
- package/dist/runtime/field-stage.runtime.js +143 -0
- package/dist/runtime/field-validator.runtime.d.ts +11 -0
- package/dist/runtime/field-validator.runtime.js +87 -0
- package/dist/runtime/framework-error-class.table.d.ts +33 -0
- package/dist/runtime/framework-error-class.table.js +25 -0
- package/dist/runtime/framework-error.d.ts +68 -8
- package/dist/runtime/framework-error.factory.d.ts +4 -0
- package/dist/runtime/framework-error.factory.js +15 -0
- package/dist/runtime/framework-error.js +23 -2
- package/dist/runtime/interceptor-next.error.d.ts +5 -0
- package/dist/runtime/interceptor-next.error.js +6 -0
- package/dist/runtime/json-value.d.ts +3 -3
- package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
- package/dist/runtime/level-lifecycle.runtime.js +42 -0
- package/dist/runtime/misuse-reporter.d.ts +12 -12
- package/dist/runtime/mutation-planner.d.ts +19 -10
- package/dist/runtime/mutation-planner.js +54 -30
- package/dist/runtime/nested-write.walker.d.ts +32 -0
- package/dist/runtime/nested-write.walker.js +73 -0
- package/dist/runtime/operation-request.d.ts +33 -6
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +113 -25
- package/dist/runtime/operation-runtime.js +395 -74
- package/dist/runtime/outcome-mapper.d.ts +16 -5
- package/dist/runtime/outcome-mapper.js +23 -6
- package/dist/runtime/output-validator.d.ts +10 -10
- package/dist/runtime/output-validator.js +3 -3
- package/dist/runtime/owned-execution.registry.d.ts +6 -6
- package/dist/runtime/pipe-output.validator.d.ts +33 -18
- package/dist/runtime/pipe-output.validator.js +12 -12
- package/dist/runtime/pipeline.d.ts +196 -34
- package/dist/runtime/readonly-value.d.ts +32 -0
- package/dist/runtime/readonly-value.js +141 -0
- package/dist/runtime/request-envelope.validator.d.ts +3 -3
- package/dist/runtime/request-envelope.validator.js +12 -7
- package/dist/runtime/request-id.d.ts +1 -1
- package/dist/runtime/request-state.d.ts +14 -0
- package/dist/runtime/request-state.js +1 -0
- package/dist/runtime/request-state.resolver.d.ts +12 -0
- package/dist/runtime/request-state.resolver.js +20 -0
- package/dist/runtime/scalar-runtime.d.ts +31 -16
- package/dist/runtime/scalar-runtime.js +16 -18
- package/dist/transactions/deferred-operation.d.ts +35 -20
- package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
- package/dist/transactions/operation-arguments-encoder.js +2 -2
- package/dist/transactions/sql-statement.d.ts +77 -0
- package/dist/transactions/sql-statement.js +47 -0
- package/dist/transactions/sql-statement.validator.d.ts +44 -0
- package/dist/transactions/sql-statement.validator.js +134 -0
- package/dist/transactions/transaction-envelope.d.ts +4 -4
- package/dist/transactions/transaction-integrity-error.d.ts +6 -6
- package/dist/transactions/transaction-integrity-error.js +5 -2
- package/dist/transactions/transaction-plan-assembler.d.ts +21 -11
- package/dist/transactions/transaction-plan-assembler.js +148 -34
- package/dist/transactions/transaction-plan-validator.d.ts +29 -20
- package/dist/transactions/transaction-plan-validator.js +70 -38
- package/dist/transactions/transaction-reference-collector.d.ts +5 -5
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +26 -14
- package/dist/transactions/transaction-reference-validator.d.ts +34 -4
- package/dist/transactions/transaction-reference-validator.js +58 -26
- package/dist/transactions/transaction-reference.d.ts +13 -13
- package/dist/transactions/transaction-request.d.ts +18 -5
- package/dist/transactions/transaction-response.d.ts +6 -6
- package/dist/transactions/transaction-runtime.d.ts +8 -7
- package/dist/transactions/transaction-runtime.js +166 -50
- package/dist/transactions/transaction-settlement.runtime.d.ts +51 -0
- package/dist/transactions/transaction-settlement.runtime.js +120 -0
- package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
- package/dist/transactions/transaction-slot-path-error.js +2 -2
- package/dist/transactions/transaction-slot-writer.js +2 -2
- package/dist/transactions/transaction-stage.runtime.d.ts +81 -0
- package/dist/transactions/transaction-stage.runtime.js +123 -0
- package/package.json +6 -5
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -42
- package/dist/config/define-fields.js +0 -3
- package/dist/config/framework-behaviors-config.d.ts +0 -30
- package/dist/config/framework-fields-config.d.ts +0 -42
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/json/avz.d.ts +0 -96
- package/dist/runtime/field-behavior.d.ts +0 -48
- /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
- /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
- /package/dist/{json → avz}/index.js +0 -0
- /package/dist/{json → avz}/json-shape.registry.js +0 -0
- /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
- /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
|
@@ -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,76 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AvPaginationCapability, AvProjectionScope, AvRelationFilterCapability, AvRelationMutationDirective, AvRelationReducer, AvScalarFilterOperator, AvScalarMutationDirective, AvWriteScope } 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[];
|
|
52
56
|
readonly order?: boolean;
|
|
53
57
|
readonly orderNulls?: boolean;
|
|
54
|
-
readonly create?: readonly
|
|
55
|
-
readonly update?: readonly
|
|
58
|
+
readonly create?: readonly AvScalarMutationDirective[];
|
|
59
|
+
readonly update?: readonly AvScalarMutationDirective[];
|
|
56
60
|
};
|
|
57
61
|
/** What can be done with a relation field. */
|
|
58
|
-
export type
|
|
59
|
-
readonly select?:
|
|
60
|
-
readonly include?:
|
|
61
|
-
readonly filter?: readonly
|
|
62
|
+
export type AvRelationFieldCapabilities = {
|
|
63
|
+
readonly select?: AvRelationProjectionCapability;
|
|
64
|
+
readonly include?: AvRelationProjectionCapability;
|
|
65
|
+
readonly filter?: readonly AvRelationFilterCapability[];
|
|
62
66
|
readonly order?: boolean;
|
|
63
|
-
readonly pagination?: readonly
|
|
64
|
-
readonly reducers?:
|
|
65
|
-
readonly create?:
|
|
66
|
-
readonly update?:
|
|
67
|
+
readonly pagination?: readonly AvPaginationCapability[];
|
|
68
|
+
readonly reducers?: AvRelationReducerCapability;
|
|
69
|
+
readonly create?: AvRelationMutationCapability;
|
|
70
|
+
readonly update?: AvRelationMutationCapability;
|
|
67
71
|
/**
|
|
68
72
|
* What the `where` of a nested `$update` or `$delete` through this relation may
|
|
69
|
-
* filter: `"scalar"`
|
|
73
|
+
* filter: `"scalar"` means the target's scalar fields only, combined with
|
|
70
74
|
* `AND`/`OR`/`NOT`, and no relation filter at any depth. Absent: any filter the
|
|
71
75
|
* target takes.
|
|
72
76
|
*/
|
|
@@ -76,53 +80,59 @@ export type RelationFieldCapabilities = {
|
|
|
76
80
|
* The reducers a relation advertises, in any projection position. Use
|
|
77
81
|
* {@link advertisedReducersAt} for one position.
|
|
78
82
|
*/
|
|
79
|
-
export declare function advertisedReducers(capability:
|
|
83
|
+
export declare function advertisedReducers(capability: AvRelationReducerCapability | undefined): readonly AvRelationReducer[] | undefined;
|
|
80
84
|
/** Whether a projection capability holds at one projection position. */
|
|
81
|
-
export declare function holdsAt(capability:
|
|
85
|
+
export declare function holdsAt(capability: AvRelationProjectionCapability | undefined, scope: AvProjectionScope): boolean;
|
|
82
86
|
/**
|
|
83
87
|
* Whether a projection capability holds in **any** projection position. Use
|
|
84
88
|
* {@link holdsAt} when the position is known.
|
|
85
89
|
*/
|
|
86
|
-
export declare function holdsInAnyScope(capability:
|
|
90
|
+
export declare function holdsInAnyScope(capability: AvRelationProjectionCapability | undefined): boolean;
|
|
87
91
|
/**
|
|
88
92
|
* The reducers a relation advertises at one projection position, or
|
|
89
93
|
* `undefined` where it has none there.
|
|
90
94
|
*/
|
|
91
|
-
export declare function advertisedReducersAt(capability:
|
|
95
|
+
export declare function advertisedReducersAt(capability: AvRelationReducerCapability | undefined, scope: AvProjectionScope): readonly AvRelationReducer[] | undefined;
|
|
92
96
|
/**
|
|
93
97
|
* The mutation directives a relation advertises at one write stage, in any
|
|
94
98
|
* write position. `undefined` means the stage is unavailable; `[]` means
|
|
95
99
|
* available with no directive.
|
|
96
100
|
*/
|
|
97
|
-
export declare function advertisedDirectives(capability:
|
|
101
|
+
export declare function advertisedDirectives(capability: AvRelationMutationCapability | undefined): readonly AvRelationMutationDirective[] | undefined;
|
|
98
102
|
/**
|
|
99
103
|
* The mutation directives a relation advertises at one write position, or
|
|
100
104
|
* `undefined` where it is not writable there.
|
|
101
105
|
*/
|
|
102
|
-
export declare function advertisedDirectivesAt(capability:
|
|
106
|
+
export declare function advertisedDirectivesAt(capability: AvRelationMutationCapability | undefined, scope: AvWriteScope): readonly AvRelationMutationDirective[] | undefined;
|
|
103
107
|
/** A scalar field, including an enum-backed one. */
|
|
104
|
-
export type
|
|
108
|
+
export type AvScalarField<C extends AvContract> = {
|
|
105
109
|
readonly kind: "scalar";
|
|
106
110
|
readonly type: {
|
|
107
111
|
readonly scalar: Extract<keyof C["scalars"], string>;
|
|
108
112
|
} | {
|
|
109
113
|
readonly enum: Extract<keyof C["enums"], string>;
|
|
110
114
|
};
|
|
111
|
-
readonly format?:
|
|
115
|
+
readonly format?: AvScalarFormat;
|
|
112
116
|
readonly nullable: boolean;
|
|
113
117
|
readonly list: boolean;
|
|
114
|
-
readonly lifecycle: readonly
|
|
115
|
-
readonly capabilities:
|
|
118
|
+
readonly lifecycle: readonly AvLifecycleTrait[];
|
|
119
|
+
readonly capabilities: AvScalarFieldCapabilities;
|
|
116
120
|
/** A `json` field's shape, as JSON Schema: what every value written to it is. */
|
|
117
121
|
readonly json?: JsonSchema;
|
|
122
|
+
/**
|
|
123
|
+
* The field's validators: the root's checks, then the overlay's, in
|
|
124
|
+
* registration order. On a list field a check applies to each entry, except a
|
|
125
|
+
* `list: true` length check, which applies to the list.
|
|
126
|
+
*/
|
|
127
|
+
readonly validators?: readonly AvFieldCheck[];
|
|
118
128
|
};
|
|
119
129
|
/** A relation field; the `target` Resource describes the related row. */
|
|
120
|
-
export type
|
|
130
|
+
export type AvRelationField<C extends AvContract> = {
|
|
121
131
|
readonly kind: "relation";
|
|
122
132
|
readonly target: Extract<keyof C["resources"], string>;
|
|
123
133
|
readonly cardinality: "one" | "many";
|
|
124
134
|
readonly nullable: boolean;
|
|
125
|
-
readonly capabilities:
|
|
135
|
+
readonly capabilities: AvRelationFieldCapabilities;
|
|
126
136
|
};
|
|
127
137
|
/** One field of a Resource: a scalar or a relation. */
|
|
128
|
-
export type
|
|
138
|
+
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
|
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import type { AvDecimal } from "../runtime/decimal.js";
|
|
2
|
+
import type { AvJsonValue } from "../runtime/json-value.js";
|
|
3
|
+
import type { AvContract } from "./contract.js";
|
|
4
|
+
import type { AvScalarField } from "./field.js";
|
|
5
5
|
import type { JsonFieldType } from "./json-shape.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { AvBuiltInScalar } from "./scalar.js";
|
|
7
7
|
/**
|
|
8
8
|
* A scalar-form map: the TypeScript type each built-in scalar takes on one side
|
|
9
9
|
* of a boundary. Every built-in must be listed.
|
|
10
10
|
*/
|
|
11
11
|
export type ScalarForms = {
|
|
12
|
-
readonly [Scalar in
|
|
12
|
+
readonly [Scalar in AvBuiltInScalar]: unknown;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* The TypeScript form each built-in scalar takes in process: in results of
|
|
16
16
|
* either origin, and in `framework.application` arguments. `decimal` is
|
|
17
|
-
* Aventara's own {@link
|
|
17
|
+
* Aventara's own {@link AvDecimal}.
|
|
18
18
|
*/
|
|
19
|
-
export type
|
|
19
|
+
export type AvApplicationScalarForms = {
|
|
20
20
|
readonly string: string;
|
|
21
21
|
readonly boolean: boolean;
|
|
22
22
|
readonly int: number;
|
|
23
23
|
readonly float: number;
|
|
24
24
|
readonly bigint: bigint;
|
|
25
|
-
readonly decimal:
|
|
25
|
+
readonly decimal: AvDecimal;
|
|
26
26
|
readonly datetime: Date;
|
|
27
27
|
readonly bytes: Uint8Array;
|
|
28
28
|
/**
|
|
29
29
|
* Any JSON value. A field-level `null` is the field's absence and is allowed
|
|
30
30
|
* only where the field is nullable; a `null` inside the value is JSON's own.
|
|
31
31
|
*/
|
|
32
|
-
readonly json: Exclude<
|
|
32
|
+
readonly json: Exclude<AvJsonValue, null>;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* The encoded forms of the built-in scalars: base-10 bigint strings, decimal strings,
|
|
36
36
|
* canonical ISO-8601 UTC datetimes and RFC 4648 base64 bytes. For a transport or a
|
|
37
37
|
* generated client to pass as `Forms`.
|
|
38
38
|
*/
|
|
39
|
-
export type
|
|
39
|
+
export type AvWireScalarForms = {
|
|
40
40
|
readonly string: string;
|
|
41
41
|
readonly boolean: boolean;
|
|
42
42
|
readonly int: number;
|
|
@@ -46,10 +46,10 @@ export type WireScalarForms = {
|
|
|
46
46
|
readonly datetime: string;
|
|
47
47
|
readonly bytes: string;
|
|
48
48
|
/** The same as in process: a JSON value needs no encoding to cross a JSON wire. */
|
|
49
|
-
readonly json: Exclude<
|
|
49
|
+
readonly json: Exclude<AvJsonValue, null>;
|
|
50
50
|
};
|
|
51
51
|
/** One value of a scalar field, before `list` and `nullable` apply. */
|
|
52
|
-
export type ScalarAtom<C extends
|
|
52
|
+
export type ScalarAtom<C extends AvContract, Type, Forms extends ScalarForms> = Type extends {
|
|
53
53
|
readonly enum: infer Enum extends keyof C["enums"];
|
|
54
54
|
} ? C["enums"][Enum]["values"][number] : Type extends {
|
|
55
55
|
readonly scalar: infer Scalar;
|
|
@@ -58,7 +58,7 @@ export type ScalarAtom<C extends Contract, Type, Forms extends ScalarForms> = Ty
|
|
|
58
58
|
* One value of a scalar field, before `list` and `nullable` apply: its Json
|
|
59
59
|
* Shape's type where the field is shaped, otherwise {@link ScalarAtom}.
|
|
60
60
|
*/
|
|
61
|
-
export type FieldAtom<C extends
|
|
61
|
+
export type FieldAtom<C extends AvContract, Field extends {
|
|
62
62
|
readonly type: unknown;
|
|
63
63
|
readonly json?: unknown;
|
|
64
64
|
}, Forms extends ScalarForms> = Field extends {
|
|
@@ -78,5 +78,5 @@ type ListValue<List, Atom> = [List] extends [false] ? Atom : [List] extends [tru
|
|
|
78
78
|
* - `list: true` → `readonly T[]`, whose entries are never `null`;
|
|
79
79
|
* - `nullable: true` → `| null`, on the whole value, list or not.
|
|
80
80
|
*/
|
|
81
|
-
export type
|
|
81
|
+
export type AvScalarValueType<C extends AvContract, Field extends AvScalarField<C>, Forms extends ScalarForms = AvApplicationScalarForms> = ListValue<Field["list"], FieldAtom<C, Field, Forms>> | (true extends Field["nullable"] ? null : never);
|
|
82
82
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** The built-in scalar types of the Aventara protocol. */
|
|
2
2
|
export declare const BUILT_IN_SCALARS: readonly ["string", "boolean", "int", "float", "bigint", "decimal", "datetime", "bytes", "json"];
|
|
3
3
|
/** One of {@link BUILT_IN_SCALARS}. */
|
|
4
|
-
export type
|
|
4
|
+
export type AvBuiltInScalar = (typeof BUILT_IN_SCALARS)[number];
|
|
5
5
|
/** One entry of a scalar registry. */
|
|
6
|
-
export type
|
|
6
|
+
export type AvScalarDefinition = {
|
|
7
7
|
readonly builtin: true;
|
|
8
8
|
};
|
|
9
9
|
/** The scalar types an adapter model or Contract supports, by name. */
|
|
10
|
-
export type
|
|
10
|
+
export type AvScalarRegistry = Readonly<Record<string, AvScalarDefinition>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** The transaction capabilities. */
|
|
2
2
|
export declare const TRANSACTION_CAPABILITIES: readonly ["none", "interactive"];
|
|
3
3
|
/** `"none"` or `"interactive"`: whether transactions can run. */
|
|
4
|
-
export type
|
|
4
|
+
export type AvTransactionCapability = (typeof TRANSACTION_CAPABILITIES)[number];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AvBuiltInScalar } from "./scalar.js";
|
|
2
|
+
import type { AvApplicationScalarForms, AvWireScalarForms } from "./scalar-value-type.js";
|
|
3
3
|
/**
|
|
4
4
|
* The built-in scalars whose wire form is not their runtime form — the ones a JSON
|
|
5
5
|
* wire carries as a string with a grammar of its own. Derived from the two form maps
|
|
@@ -7,8 +7,8 @@ import type { ApplicationScalarForms, WireScalarForms } from "./scalar-value-typ
|
|
|
7
7
|
* compile below until its grammar is written.
|
|
8
8
|
*/
|
|
9
9
|
type WireEncodedScalar = {
|
|
10
|
-
readonly [S in
|
|
11
|
-
}[
|
|
10
|
+
readonly [S in AvBuiltInScalar]: AvWireScalarForms[S] extends AvApplicationScalarForms[S] ? never : S;
|
|
11
|
+
}[AvBuiltInScalar];
|
|
12
12
|
/**
|
|
13
13
|
* `AvProtocol.scalarFormats` — the wire grammars of protocol version 1, as passive
|
|
14
14
|
* data: one anchored pattern SOURCE string per wire-encoded scalar, in
|