@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,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { AvContract } from "./contract.js";
|
|
2
|
+
import type { AvField } from "./field.js";
|
|
3
|
+
import type { AvResource } from "./resource.js";
|
|
4
4
|
/**
|
|
5
5
|
* Own-property lookups over Contract registries.
|
|
6
6
|
*
|
|
@@ -12,5 +12,5 @@ import type { Resource } from "./resource.js";
|
|
|
12
12
|
* must go through here so an unknown key is unknown, whatever its name.
|
|
13
13
|
*/
|
|
14
14
|
export declare function lookupOwn<T>(registry: Readonly<Record<string, T>> | undefined, key: string): T | undefined;
|
|
15
|
-
export declare function lookupResource<C extends
|
|
16
|
-
export declare function lookupField<C extends
|
|
15
|
+
export declare function lookupResource<C extends AvContract>(contract: C, resourceName: string): AvResource<C> | undefined;
|
|
16
|
+
export declare function lookupField<C extends AvContract>(resource: AvResource<C> | undefined, fieldName: string): AvField<C> | undefined;
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const AVENTARA_PROTOCOL_VERSION: 1;
|
|
7
7
|
/** A Contract hash: `sha256:` followed by the hex digest. */
|
|
8
|
-
export type
|
|
8
|
+
export type AvContractHash = `sha256:${string}`;
|
|
9
9
|
/** The protocol a Contract is written for. */
|
|
10
|
-
export type
|
|
10
|
+
export type AvContractProtocol = {
|
|
11
11
|
/** The protocol version; see {@link AVENTARA_PROTOCOL_VERSION}. */
|
|
12
12
|
readonly version: typeof AVENTARA_PROTOCOL_VERSION;
|
|
13
13
|
};
|
|
14
14
|
/** A ClientContract's `protocol`: the protocol version and the Contract hash. */
|
|
15
|
-
export type
|
|
16
|
-
readonly hash:
|
|
15
|
+
export type AvContractClientProtocol = AvContractProtocol & {
|
|
16
|
+
readonly hash: AvContractHash;
|
|
17
17
|
};
|
|
@@ -1,33 +1,48 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
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
|
+
import type { ReferenceWriteLimit } from "./reference-write-limit.js";
|
|
5
|
+
import type { AvResource } from "./resource.js";
|
|
6
|
+
import type { AvScalarRegistry } from "./scalar.js";
|
|
7
|
+
import type { AvTransactionCapability } from "./transaction-capability.js";
|
|
7
8
|
/** What every Contract describes: scalars, enums, Resources, limits and transactions. */
|
|
8
|
-
export interface
|
|
9
|
+
export interface AvContract {
|
|
9
10
|
/** The scalar types available. */
|
|
10
|
-
readonly scalars:
|
|
11
|
+
readonly scalars: AvScalarRegistry;
|
|
11
12
|
/** The enums, by name. */
|
|
12
|
-
readonly enums: Readonly<Record<string,
|
|
13
|
+
readonly enums: Readonly<Record<string, AvEnumDefinition>>;
|
|
13
14
|
/** The Resources, by name. */
|
|
14
|
-
readonly resources: Readonly<Record<string,
|
|
15
|
+
readonly resources: Readonly<Record<string, AvResource<this>>>;
|
|
15
16
|
/** The request limits in force. */
|
|
16
|
-
readonly limits:
|
|
17
|
+
readonly limits: AvContractLimits;
|
|
17
18
|
/** Whether interactive transactions are available. */
|
|
18
|
-
readonly transactions:
|
|
19
|
+
readonly transactions: AvTransactionCapability;
|
|
20
|
+
/**
|
|
21
|
+
* `"uniform"` when one record must write the relations that hold a reference
|
|
22
|
+
* either all as relations or all through their reference fields; a record
|
|
23
|
+
* that mixes them is refused with `A2004`. Absent: each relation either way.
|
|
24
|
+
*/
|
|
25
|
+
readonly referenceWrites?: ReferenceWriteLimit;
|
|
19
26
|
}
|
|
20
27
|
/** The Contract compiled from the root configuration. */
|
|
21
|
-
export interface
|
|
28
|
+
export interface AvContractCore extends AvContract {
|
|
22
29
|
}
|
|
23
30
|
/** The Contract in-process calls run under (`framework.application`). */
|
|
24
|
-
export interface
|
|
31
|
+
export interface AvContractApplication extends AvContract {
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* The Contract remote clients run under, published at `GET /_contract` and
|
|
28
35
|
* identified by its hash.
|
|
29
36
|
*/
|
|
30
|
-
export interface
|
|
37
|
+
export interface AvContractClient extends AvContract {
|
|
31
38
|
/** The protocol version and this Contract's hash. */
|
|
32
|
-
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;
|
|
33
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,118 +1,138 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
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";
|
|
4
|
+
import type { JsonSchema } from "./json-shape.js";
|
|
5
|
+
import type { AvLifecycleTrait } from "./lifecycle-trait.js";
|
|
4
6
|
/** A format name that refines a scalar type, carried in the Contract as data. */
|
|
5
|
-
export type
|
|
7
|
+
export type AvScalarFormat = string;
|
|
6
8
|
/** The projection positions a field can be selected in (at least one). */
|
|
7
|
-
export type
|
|
9
|
+
export type AvProjectionScopes = readonly [
|
|
10
|
+
AvProjectionScope,
|
|
11
|
+
...AvProjectionScope[]
|
|
12
|
+
];
|
|
8
13
|
/**
|
|
9
14
|
* The write positions a field can be written in (at least one). A scope list
|
|
10
|
-
* 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}.
|
|
11
16
|
*/
|
|
12
|
-
export type
|
|
17
|
+
export type AvWriteScopes = readonly [AvWriteScope, ...AvWriteScope[]];
|
|
13
18
|
/**
|
|
14
19
|
* Whether a relation can be selected or included: `true`, or the projection
|
|
15
20
|
* positions it can be used in.
|
|
16
21
|
*/
|
|
17
|
-
export type
|
|
22
|
+
export type AvRelationProjectionCapability = boolean | AvProjectionScopes;
|
|
18
23
|
/**
|
|
19
24
|
* The reducers a relation admits, qualified by the projection positions they are
|
|
20
25
|
* admitted in. The reducer list and the scope list are separate facts: `$count` is
|
|
21
26
|
* one of a closed set of reducers, and the scopes say where the reducer may be
|
|
22
27
|
* asked for.
|
|
23
28
|
*/
|
|
24
|
-
export type
|
|
25
|
-
readonly reducers: readonly
|
|
26
|
-
readonly scopes:
|
|
29
|
+
export type AvScopedRelationReducers = {
|
|
30
|
+
readonly reducers: readonly AvRelationReducer[];
|
|
31
|
+
readonly scopes: AvProjectionScopes;
|
|
27
32
|
};
|
|
28
33
|
/**
|
|
29
34
|
* A relation's reducers: a reducer list, or an object with the reducers and
|
|
30
35
|
* the projection positions they apply in.
|
|
31
36
|
*/
|
|
32
|
-
export type
|
|
37
|
+
export type AvRelationReducerCapability = readonly AvRelationReducer[] | AvScopedRelationReducers;
|
|
33
38
|
/**
|
|
34
39
|
* The mutation directives a relation admits at one write stage, and the write
|
|
35
40
|
* positions they are admitted in. `directives: []` means writable with no
|
|
36
41
|
* directive.
|
|
37
42
|
*/
|
|
38
|
-
export type
|
|
39
|
-
readonly directives: readonly
|
|
40
|
-
readonly scopes:
|
|
43
|
+
export type AvScopedRelationMutations = {
|
|
44
|
+
readonly directives: readonly AvRelationMutationDirective[];
|
|
45
|
+
readonly scopes: AvWriteScopes;
|
|
41
46
|
};
|
|
42
47
|
/**
|
|
43
48
|
* A relation's write capability for `create` or `update`: a directive list, or
|
|
44
49
|
* an object with the directives and the write positions they apply in.
|
|
45
50
|
*/
|
|
46
|
-
export type
|
|
51
|
+
export type AvRelationMutationCapability = readonly AvRelationMutationDirective[] | AvScopedRelationMutations;
|
|
47
52
|
/** What can be done with a scalar field. Scalar capabilities apply in every position. */
|
|
48
|
-
export type
|
|
53
|
+
export type AvScalarFieldCapabilities = {
|
|
49
54
|
readonly select?: boolean;
|
|
50
|
-
readonly filter?: readonly
|
|
55
|
+
readonly filter?: readonly AvScalarFilterOperator[];
|
|
51
56
|
readonly order?: boolean;
|
|
52
57
|
readonly orderNulls?: boolean;
|
|
53
|
-
readonly create?: readonly
|
|
54
|
-
readonly update?: readonly
|
|
58
|
+
readonly create?: readonly AvScalarMutationDirective[];
|
|
59
|
+
readonly update?: readonly AvScalarMutationDirective[];
|
|
55
60
|
};
|
|
56
61
|
/** What can be done with a relation field. */
|
|
57
|
-
export type
|
|
58
|
-
readonly select?:
|
|
59
|
-
readonly include?:
|
|
60
|
-
readonly filter?: readonly
|
|
62
|
+
export type AvRelationFieldCapabilities = {
|
|
63
|
+
readonly select?: AvRelationProjectionCapability;
|
|
64
|
+
readonly include?: AvRelationProjectionCapability;
|
|
65
|
+
readonly filter?: readonly AvRelationFilterCapability[];
|
|
61
66
|
readonly order?: boolean;
|
|
62
|
-
readonly pagination?: readonly
|
|
63
|
-
readonly reducers?:
|
|
64
|
-
readonly create?:
|
|
65
|
-
readonly update?:
|
|
67
|
+
readonly pagination?: readonly AvPaginationCapability[];
|
|
68
|
+
readonly reducers?: AvRelationReducerCapability;
|
|
69
|
+
readonly create?: AvRelationMutationCapability;
|
|
70
|
+
readonly update?: AvRelationMutationCapability;
|
|
71
|
+
/**
|
|
72
|
+
* What the `where` of a nested `$update` or `$delete` through this relation may
|
|
73
|
+
* filter: `"scalar"` means the target's scalar fields only, combined with
|
|
74
|
+
* `AND`/`OR`/`NOT`, and no relation filter at any depth. Absent: any filter the
|
|
75
|
+
* target takes.
|
|
76
|
+
*/
|
|
77
|
+
readonly nestedWriteFilter?: "scalar";
|
|
66
78
|
};
|
|
67
79
|
/**
|
|
68
80
|
* The reducers a relation advertises, in any projection position. Use
|
|
69
81
|
* {@link advertisedReducersAt} for one position.
|
|
70
82
|
*/
|
|
71
|
-
export declare function advertisedReducers(capability:
|
|
83
|
+
export declare function advertisedReducers(capability: AvRelationReducerCapability | undefined): readonly AvRelationReducer[] | undefined;
|
|
72
84
|
/** Whether a projection capability holds at one projection position. */
|
|
73
|
-
export declare function holdsAt(capability:
|
|
85
|
+
export declare function holdsAt(capability: AvRelationProjectionCapability | undefined, scope: AvProjectionScope): boolean;
|
|
74
86
|
/**
|
|
75
87
|
* Whether a projection capability holds in **any** projection position. Use
|
|
76
88
|
* {@link holdsAt} when the position is known.
|
|
77
89
|
*/
|
|
78
|
-
export declare function holdsInAnyScope(capability:
|
|
90
|
+
export declare function holdsInAnyScope(capability: AvRelationProjectionCapability | undefined): boolean;
|
|
79
91
|
/**
|
|
80
92
|
* The reducers a relation advertises at one projection position, or
|
|
81
93
|
* `undefined` where it has none there.
|
|
82
94
|
*/
|
|
83
|
-
export declare function advertisedReducersAt(capability:
|
|
95
|
+
export declare function advertisedReducersAt(capability: AvRelationReducerCapability | undefined, scope: AvProjectionScope): readonly AvRelationReducer[] | undefined;
|
|
84
96
|
/**
|
|
85
97
|
* The mutation directives a relation advertises at one write stage, in any
|
|
86
98
|
* write position. `undefined` means the stage is unavailable; `[]` means
|
|
87
99
|
* available with no directive.
|
|
88
100
|
*/
|
|
89
|
-
export declare function advertisedDirectives(capability:
|
|
101
|
+
export declare function advertisedDirectives(capability: AvRelationMutationCapability | undefined): readonly AvRelationMutationDirective[] | undefined;
|
|
90
102
|
/**
|
|
91
103
|
* The mutation directives a relation advertises at one write position, or
|
|
92
104
|
* `undefined` where it is not writable there.
|
|
93
105
|
*/
|
|
94
|
-
export declare function advertisedDirectivesAt(capability:
|
|
106
|
+
export declare function advertisedDirectivesAt(capability: AvRelationMutationCapability | undefined, scope: AvWriteScope): readonly AvRelationMutationDirective[] | undefined;
|
|
95
107
|
/** A scalar field, including an enum-backed one. */
|
|
96
|
-
export type
|
|
108
|
+
export type AvScalarField<C extends AvContract> = {
|
|
97
109
|
readonly kind: "scalar";
|
|
98
110
|
readonly type: {
|
|
99
111
|
readonly scalar: Extract<keyof C["scalars"], string>;
|
|
100
112
|
} | {
|
|
101
113
|
readonly enum: Extract<keyof C["enums"], string>;
|
|
102
114
|
};
|
|
103
|
-
readonly format?:
|
|
115
|
+
readonly format?: AvScalarFormat;
|
|
104
116
|
readonly nullable: boolean;
|
|
105
117
|
readonly list: boolean;
|
|
106
|
-
readonly lifecycle: readonly
|
|
107
|
-
readonly capabilities:
|
|
118
|
+
readonly lifecycle: readonly AvLifecycleTrait[];
|
|
119
|
+
readonly capabilities: AvScalarFieldCapabilities;
|
|
120
|
+
/** A `json` field's shape, as JSON Schema: what every value written to it is. */
|
|
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[];
|
|
108
128
|
};
|
|
109
129
|
/** A relation field; the `target` Resource describes the related row. */
|
|
110
|
-
export type
|
|
130
|
+
export type AvRelationField<C extends AvContract> = {
|
|
111
131
|
readonly kind: "relation";
|
|
112
132
|
readonly target: Extract<keyof C["resources"], string>;
|
|
113
133
|
readonly cardinality: "one" | "many";
|
|
114
134
|
readonly nullable: boolean;
|
|
115
|
-
readonly capabilities:
|
|
135
|
+
readonly capabilities: AvRelationFieldCapabilities;
|
|
116
136
|
};
|
|
117
137
|
/** One field of a Resource: a scalar or a relation. */
|
|
118
|
-
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>[]];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { AvJsonListCheck, AvJsonNumberCheck, AvJsonStringCheck } from "./field-check.js";
|
|
2
|
+
/**
|
|
3
|
+
* The phantom key a Json Shape's TypeScript type travels under. Type-level only:
|
|
4
|
+
* no value ever holds it.
|
|
5
|
+
*/
|
|
6
|
+
declare const jsonShapeValue: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* A Json Shape, as the type system sees it: the TypeScript type `Value` of a
|
|
9
|
+
* value that conforms to it. `AvZ` builds every one; a value from anywhere else —
|
|
10
|
+
* a Zod schema included — is not one.
|
|
11
|
+
*/
|
|
12
|
+
export interface JsonShape<Value = unknown> {
|
|
13
|
+
readonly [jsonShapeValue]: Value;
|
|
14
|
+
}
|
|
15
|
+
/** The TypeScript type a {@link JsonShape} describes. */
|
|
16
|
+
export type JsonShapeValue<Shape extends JsonShape> = Shape[typeof jsonShapeValue];
|
|
17
|
+
/** A JSON primitive: what a `const` names. */
|
|
18
|
+
export type JsonSchemaPrimitive = string | number | boolean | null;
|
|
19
|
+
/**
|
|
20
|
+
* A Json Shape in a Contract: passive JSON Schema (draft 2020-12), restricted to
|
|
21
|
+
* the forms Aventara emits.
|
|
22
|
+
*/
|
|
23
|
+
export type JsonSchema = {
|
|
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[];
|
|
33
|
+
} | {
|
|
34
|
+
readonly const: JsonSchemaPrimitive;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
readonly enum: readonly [string, ...string[]];
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: "object";
|
|
40
|
+
readonly properties: {
|
|
41
|
+
readonly [key: string]: JsonSchema;
|
|
42
|
+
};
|
|
43
|
+
readonly required?: readonly string[];
|
|
44
|
+
readonly additionalProperties: false;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "object";
|
|
47
|
+
readonly additionalProperties: JsonSchema;
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "array";
|
|
50
|
+
readonly items: JsonSchema;
|
|
51
|
+
/** The list's length checks, in the order they were added. */
|
|
52
|
+
readonly checks?: readonly AvJsonListCheck[];
|
|
53
|
+
} | {
|
|
54
|
+
readonly type: "array";
|
|
55
|
+
readonly prefixItems: readonly [JsonSchema, ...JsonSchema[]];
|
|
56
|
+
readonly items: false;
|
|
57
|
+
readonly minItems: number;
|
|
58
|
+
readonly maxItems: number;
|
|
59
|
+
} | {
|
|
60
|
+
readonly anyOf: readonly [JsonSchema, JsonSchema, ...JsonSchema[]];
|
|
61
|
+
} | {
|
|
62
|
+
readonly oneOf: readonly [JsonSchema, ...JsonSchema[]];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The type-level carrier of a shaped Json field's TypeScript type, on the field's
|
|
66
|
+
* `json` member in a typed Contract view. Never present at runtime.
|
|
67
|
+
*/
|
|
68
|
+
export type JsonFieldType<Value> = {
|
|
69
|
+
readonly "~jsonType": Value;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* A shaped Json field's `json` member in a typed Contract view: the schema, and
|
|
73
|
+
* the type it describes.
|
|
74
|
+
*/
|
|
75
|
+
export type ShapedJsonSchema<Value> = JsonSchema & JsonFieldType<Value>;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The limits a data source may put on how one record writes its references. */
|
|
2
|
+
export declare const REFERENCE_WRITE_LIMITS: readonly ["uniform"];
|
|
3
|
+
/**
|
|
4
|
+
* `"uniform"`: one record writes the relations that hold a reference either all
|
|
5
|
+
* as relations or all through their reference fields, never some each way.
|
|
6
|
+
*/
|
|
7
|
+
export type ReferenceWriteLimit = (typeof REFERENCE_WRITE_LIMITS)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const REFERENCE_WRITE_LIMITS = ["uniform"];
|