@aventara/core 1.0.0-rc.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1140 -0
- package/README.md +224 -57
- package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
- package/dist/adapters/adapter-field.d.ts +11 -11
- package/dist/adapters/adapter-identifier.d.ts +6 -6
- package/dist/adapters/adapter-model.d.ts +9 -9
- package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
- package/dist/adapters/adapter-operation.d.ts +3 -3
- package/dist/adapters/adapter-resource.d.ts +18 -9
- package/dist/adapters/adapter-sql-statement.d.ts +19 -0
- package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
- package/dist/adapters/adapter.interface.d.ts +49 -29
- package/dist/avz/avz-check.factory.d.ts +83 -0
- package/dist/avz/avz-check.factory.js +116 -0
- package/dist/avz/avz-check.registry.d.ts +35 -0
- package/dist/avz/avz-check.registry.js +9 -0
- package/dist/avz/avz.d.ts +203 -0
- package/dist/{json → avz}/avz.js +150 -8
- package/dist/{json → avz}/index.d.ts +2 -1
- package/dist/{json → avz}/json-shape.registry.d.ts +7 -7
- package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
- package/dist/{json → avz}/zod-issue.translator.js +7 -0
- package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
- package/dist/compiler/contract.compiler.d.ts +18 -18
- package/dist/compiler/contract.compiler.js +548 -441
- package/dist/compiler/create-requirements.projector.d.ts +49 -0
- package/dist/compiler/create-requirements.projector.js +423 -0
- package/dist/compiler/field-validator.compiler.d.ts +47 -0
- package/dist/compiler/field-validator.compiler.js +238 -0
- package/dist/config/any-framework-config.d.ts +19 -12
- package/dist/config/config-diagnostic.d.ts +11 -4
- package/dist/config/config-layer.d.ts +15 -6
- package/dist/config/config.resolver.d.ts +74 -31
- package/dist/config/config.resolver.js +108 -44
- package/dist/config/config.validator.d.ts +7 -7
- package/dist/config/config.validator.js +581 -72
- package/dist/config/define-resource.d.ts +57 -0
- package/dist/config/define-resource.js +14 -0
- package/dist/config/effective-fields.d.ts +19 -23
- package/dist/config/entrypoint.normalizer.d.ts +1 -1
- package/dist/config/exact-framework-config.d.ts +280 -0
- package/dist/config/field-compute.resolver.d.ts +19 -0
- package/dist/config/field-compute.resolver.js +115 -0
- package/dist/config/field-pipeline-config.d.ts +47 -0
- package/dist/config/forced-operation.validator.d.ts +10 -0
- package/dist/config/forced-operation.validator.js +66 -0
- package/dist/config/framework-config.d.ts +110 -39
- package/dist/config/framework-exemptions-config.d.ts +91 -0
- package/dist/config/framework-exemptions-config.js +1 -0
- package/dist/config/framework-field-definition.d.ts +78 -0
- package/dist/config/framework-field-definition.js +28 -0
- package/dist/config/framework-resources-config.d.ts +116 -0
- package/dist/config/framework-resources-config.js +1 -0
- package/dist/config/pipeline-config.d.ts +56 -20
- package/dist/config/pipeline-tree.resolver.d.ts +79 -0
- package/dist/config/pipeline-tree.resolver.js +220 -0
- package/dist/config/stage-type.eraser.d.ts +65 -0
- package/dist/config/stage-type.eraser.js +1 -0
- package/dist/contracts/capability.d.ts +11 -11
- package/dist/contracts/client-contract-structure.validator.d.ts +323 -28
- package/dist/contracts/client-contract-structure.validator.js +152 -8
- package/dist/contracts/contract-canonicalizer.d.ts +19 -3
- package/dist/contracts/contract-canonicalizer.js +141 -28
- package/dist/contracts/contract-hash.d.ts +12 -7
- package/dist/contracts/contract-hash.js +3 -2
- package/dist/contracts/contract-limits.d.ts +4 -1
- package/dist/contracts/contract-limits.js +1 -0
- package/dist/contracts/contract-lookup.d.ts +5 -5
- package/dist/contracts/contract-protocol.d.ts +4 -4
- package/dist/contracts/contract.d.ts +24 -16
- package/dist/contracts/create-requirements.d.ts +35 -0
- package/dist/contracts/create-requirements.js +1 -0
- package/dist/contracts/enum-definition.d.ts +1 -1
- package/dist/contracts/field-check.d.ts +101 -0
- package/dist/contracts/field-check.js +1 -0
- package/dist/contracts/field.d.ts +52 -42
- package/dist/contracts/identifier.d.ts +4 -4
- package/dist/contracts/json-shape.d.ts +12 -1
- package/dist/contracts/lifecycle-trait.d.ts +2 -2
- package/dist/contracts/resource-operations.d.ts +28 -28
- package/dist/contracts/resource.d.ts +15 -9
- package/dist/contracts/scalar-value-type.d.ts +15 -15
- package/dist/contracts/scalar.d.ts +3 -3
- package/dist/contracts/transaction-capability.d.ts +1 -1
- package/dist/contracts/wire-scalar-format.d.ts +4 -4
- package/dist/framework/contract-view.d.ts +213 -147
- package/dist/framework/framework-construction.error.d.ts +10 -10
- package/dist/framework/framework-construction.error.js +2 -2
- package/dist/framework/framework.d.ts +47 -23
- package/dist/framework/framework.factory.d.ts +8 -6
- package/dist/framework/framework.factory.js +40 -20
- package/dist/framework/operation-facade.d.ts +123 -52
- package/dist/framework/operation-facade.js +9 -1
- package/dist/index.d.ts +55 -50
- package/dist/index.js +6 -6
- package/dist/internal.d.ts +15 -10
- package/dist/internal.js +3 -1
- package/dist/operations/operation-arguments.d.ts +267 -202
- package/dist/operations/operation-call.d.ts +27 -28
- package/dist/operations/operation-identity.d.ts +10 -10
- package/dist/operations/operation-result.d.ts +21 -21
- package/dist/operations/operation-validator-core.d.ts +6 -6
- package/dist/operations/operation-validator-core.js +13 -2
- package/dist/operations/operation-validator.d.ts +9 -9
- package/dist/operations/projection-scope.resolver.d.ts +6 -6
- package/dist/operations/structural-limits.walker.d.ts +6 -6
- package/dist/operations/structural-limits.walker.js +145 -0
- package/dist/operations/validation-code.d.ts +11 -6
- package/dist/operations/validation-code.js +4 -0
- package/dist/operations/write-scope.resolver.d.ts +6 -6
- package/dist/protocol/absent-route.responder.d.ts +13 -12
- package/dist/protocol/absent-route.responder.js +19 -19
- package/dist/protocol/contract-document.responder.d.ts +3 -3
- package/dist/protocol/contract-document.responder.js +2 -2
- package/dist/protocol/http-request.decoder.d.ts +17 -13
- package/dist/protocol/http-request.decoder.js +10 -10
- package/dist/protocol/http-request.reader.d.ts +3 -3
- package/dist/protocol/http-response.encoder.d.ts +4 -4
- package/dist/protocol/http-response.encoder.js +94 -55
- package/dist/protocol/http-status.table.d.ts +2 -2
- package/dist/protocol/operation-response.guard.d.ts +2 -2
- package/dist/protocol/protocol-surface.d.ts +4 -4
- package/dist/protocol/protocol.binder.d.ts +50 -27
- package/dist/protocol/protocol.binder.js +12 -9
- package/dist/protocol/protocol.handler.d.ts +22 -13
- package/dist/protocol/protocol.handler.js +44 -9
- package/dist/protocol/unmounted-route.error.d.ts +4 -4
- package/dist/protocol/unmounted-route.error.js +2 -2
- package/dist/runtime/caller-data.copier.d.ts +5 -5
- package/dist/runtime/caller-data.copier.js +13 -13
- package/dist/runtime/caller-data.door.d.ts +6 -6
- package/dist/runtime/caller-data.door.js +6 -4
- package/dist/runtime/computed-read-runtime.d.ts +7 -6
- package/dist/runtime/computed-read-runtime.js +61 -48
- package/dist/runtime/computed-value.error.d.ts +6 -6
- package/dist/runtime/computed-value.error.js +3 -3
- package/dist/runtime/context-executor.runtime.d.ts +59 -0
- package/dist/runtime/context-executor.runtime.js +275 -0
- package/dist/runtime/create-requirement.d.ts +10 -81
- package/dist/runtime/create-requirement.js +80 -57
- package/dist/runtime/decimal.d.ts +2 -2
- package/dist/runtime/decimal.js +1 -1
- package/dist/runtime/diagnostics-reporter.d.ts +53 -27
- package/dist/runtime/diagnostics-reporter.js +24 -0
- package/dist/runtime/error-boundary.d.ts +65 -8
- package/dist/runtime/error-boundary.js +45 -19
- package/dist/runtime/execution-options.d.ts +10 -2
- package/dist/runtime/field-check.evaluator.d.ts +29 -0
- package/dist/runtime/field-check.evaluator.js +521 -0
- package/dist/runtime/field-compute.d.ts +64 -0
- package/dist/runtime/field-compute.js +1 -0
- package/dist/runtime/field-stage.plan.d.ts +15 -0
- package/dist/runtime/field-stage.plan.js +27 -0
- package/dist/runtime/field-stage.runtime.d.ts +35 -0
- package/dist/runtime/field-stage.runtime.js +143 -0
- package/dist/runtime/field-validator.runtime.d.ts +11 -0
- package/dist/runtime/field-validator.runtime.js +87 -0
- package/dist/runtime/framework-error-class.table.d.ts +33 -0
- package/dist/runtime/framework-error-class.table.js +25 -0
- package/dist/runtime/framework-error.d.ts +68 -8
- package/dist/runtime/framework-error.factory.d.ts +4 -0
- package/dist/runtime/framework-error.factory.js +15 -0
- package/dist/runtime/framework-error.js +23 -2
- package/dist/runtime/interceptor-next.error.d.ts +5 -0
- package/dist/runtime/interceptor-next.error.js +6 -0
- package/dist/runtime/json-value.d.ts +3 -3
- package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
- package/dist/runtime/level-lifecycle.runtime.js +42 -0
- package/dist/runtime/misuse-reporter.d.ts +12 -12
- package/dist/runtime/mutation-planner.d.ts +19 -10
- package/dist/runtime/mutation-planner.js +54 -30
- package/dist/runtime/nested-write.walker.d.ts +32 -0
- package/dist/runtime/nested-write.walker.js +73 -0
- package/dist/runtime/operation-request.d.ts +33 -6
- package/dist/runtime/operation-response.d.ts +17 -17
- package/dist/runtime/operation-runtime.d.ts +113 -25
- package/dist/runtime/operation-runtime.js +395 -74
- package/dist/runtime/outcome-mapper.d.ts +16 -5
- package/dist/runtime/outcome-mapper.js +23 -6
- package/dist/runtime/output-validator.d.ts +10 -10
- package/dist/runtime/output-validator.js +3 -3
- package/dist/runtime/owned-execution.registry.d.ts +6 -6
- package/dist/runtime/pipe-output.validator.d.ts +33 -18
- package/dist/runtime/pipe-output.validator.js +12 -12
- package/dist/runtime/pipeline.d.ts +196 -34
- package/dist/runtime/readonly-value.d.ts +32 -0
- package/dist/runtime/readonly-value.js +141 -0
- package/dist/runtime/request-envelope.validator.d.ts +3 -3
- package/dist/runtime/request-envelope.validator.js +12 -7
- package/dist/runtime/request-id.d.ts +1 -1
- package/dist/runtime/request-state.d.ts +14 -0
- package/dist/runtime/request-state.js +1 -0
- package/dist/runtime/request-state.resolver.d.ts +12 -0
- package/dist/runtime/request-state.resolver.js +20 -0
- package/dist/runtime/scalar-runtime.d.ts +31 -16
- package/dist/runtime/scalar-runtime.js +16 -18
- package/dist/transactions/deferred-operation.d.ts +35 -20
- package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
- package/dist/transactions/operation-arguments-encoder.js +2 -2
- package/dist/transactions/sql-statement.d.ts +77 -0
- package/dist/transactions/sql-statement.js +47 -0
- package/dist/transactions/sql-statement.validator.d.ts +44 -0
- package/dist/transactions/sql-statement.validator.js +134 -0
- package/dist/transactions/transaction-envelope.d.ts +4 -4
- package/dist/transactions/transaction-integrity-error.d.ts +6 -6
- package/dist/transactions/transaction-integrity-error.js +5 -2
- package/dist/transactions/transaction-plan-assembler.d.ts +21 -11
- package/dist/transactions/transaction-plan-assembler.js +148 -34
- package/dist/transactions/transaction-plan-validator.d.ts +29 -20
- package/dist/transactions/transaction-plan-validator.js +70 -38
- package/dist/transactions/transaction-reference-collector.d.ts +5 -5
- package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
- package/dist/transactions/transaction-reference-resolver.js +26 -14
- package/dist/transactions/transaction-reference-validator.d.ts +34 -4
- package/dist/transactions/transaction-reference-validator.js +58 -26
- package/dist/transactions/transaction-reference.d.ts +13 -13
- package/dist/transactions/transaction-request.d.ts +18 -5
- package/dist/transactions/transaction-response.d.ts +6 -6
- package/dist/transactions/transaction-runtime.d.ts +8 -7
- package/dist/transactions/transaction-runtime.js +166 -50
- package/dist/transactions/transaction-settlement.runtime.d.ts +51 -0
- package/dist/transactions/transaction-settlement.runtime.js +120 -0
- package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
- package/dist/transactions/transaction-slot-path-error.js +2 -2
- package/dist/transactions/transaction-slot-writer.js +2 -2
- package/dist/transactions/transaction-stage.runtime.d.ts +81 -0
- package/dist/transactions/transaction-stage.runtime.js +123 -0
- package/package.json +6 -5
- package/src/runtime/field-check.evaluator.ts +720 -0
- package/dist/config/define-fields.d.ts +0 -42
- package/dist/config/define-fields.js +0 -3
- package/dist/config/framework-behaviors-config.d.ts +0 -30
- package/dist/config/framework-fields-config.d.ts +0 -42
- package/dist/config/framework-restrictions-config.d.ts +0 -142
- package/dist/json/avz.d.ts +0 -96
- package/dist/runtime/field-behavior.d.ts +0 -48
- /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
- /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
- /package/dist/{json → avz}/index.js +0 -0
- /package/dist/{json → avz}/json-shape.registry.js +0 -0
- /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
- /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
|
@@ -1,50 +1,70 @@
|
|
|
1
|
-
import type { CreateRequirementTable } from "../runtime/create-requirement.js";
|
|
2
1
|
import type { ReferentialActionTable } from "../runtime/referential-action.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
2
|
+
import type { AvAdapterModel } from "./adapter-model.js";
|
|
3
|
+
import type { AvAdapterOperationExecutor } from "./adapter-operation-executor.interface.js";
|
|
4
|
+
import type { AvAdapterSqlStatement } from "./adapter-sql-statement.js";
|
|
5
|
+
import type { AvAdapterTransactionExecutor } from "./adapter-transaction-executor.interface.js";
|
|
5
6
|
/** Provider-specific implementation of Aventara discovery and execution. */
|
|
6
|
-
export interface
|
|
7
|
+
export interface AvAdapter<M extends AvAdapterModel = AvAdapterModel> extends AvAdapterOperationExecutor<M> {
|
|
7
8
|
/**
|
|
8
9
|
* What the adapter discovered about the data source, in Aventara's vocabulary.
|
|
9
10
|
* Read once, synchronously, when the framework is constructed.
|
|
10
11
|
*/
|
|
11
12
|
readonly model: M;
|
|
12
13
|
/**
|
|
13
|
-
* Optional referential actions: for each Resource that holds a reference,
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Optional referential actions: for each Resource that holds a reference, every
|
|
15
|
+
* relation holding one: the fields that hold it (`references`) and what deleting a
|
|
16
|
+
* referenced row does to its rows. Read once when the framework is constructed;
|
|
17
|
+
* never part of a Contract or its hash.
|
|
18
|
+
*
|
|
19
|
+
* An edge listed under Resource `R` says that deleting a `target` row does
|
|
20
|
+
* `onDelete` to rows of `R`, and that `R`'s `references` fields hold the relation
|
|
21
|
+
* `field`'s reference.
|
|
17
22
|
*
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
23
|
+
* The same edges say which side of a relation holds its key: a nested `$connect`,
|
|
24
|
+
* `$disconnect` or `$set` on a to-one relation the parent holds runs none of the
|
|
25
|
+
* target's stages, and otherwise runs the target's `update` guards.
|
|
21
26
|
*
|
|
22
|
-
* When absent, no cascade is planned and no transaction plan is refused
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
27
|
+
* When absent, no cascade is planned and no transaction plan is refused because of
|
|
28
|
+
* one (`V1019`); a write that sets a relation and a field holding its reference
|
|
29
|
+
* both is not refused before the store; and every nested `$connect`, `$disconnect`
|
|
30
|
+
* or `$set` runs the target's `update` guards.
|
|
26
31
|
*/
|
|
27
32
|
readonly referentialActions?: ReferentialActionTable;
|
|
28
33
|
/**
|
|
29
|
-
* Optional
|
|
30
|
-
*
|
|
31
|
-
*
|
|
34
|
+
* Optional: `true` when the Adapter runs developer SQL statements: standalone
|
|
35
|
+
* through its own {@link executeSql}, and, when it has `transaction`, inside a
|
|
36
|
+
* transaction through the `executeSql` of the executor that callback is handed
|
|
37
|
+
* (`AvAdapterTransactionExecutor.executeSql`). `framework.appTx.$sql` steps and
|
|
38
|
+
* `ctx.$sql` need it. Read once when the framework is constructed; never part
|
|
39
|
+
* of a Contract or its hash.
|
|
40
|
+
*
|
|
41
|
+
* When absent, a plan holding an `appTx.$sql` step is refused before the
|
|
42
|
+
* transaction opens (`A2002`/`V1006` at the step), and so is every `ctx.$sql`.
|
|
43
|
+
*/
|
|
44
|
+
readonly sqlStatements?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Runs one developer SQL statement outside any transaction, as a plain
|
|
47
|
+
* statement, every value bound as a parameter, and resolves the rows it
|
|
48
|
+
* returned (none for a statement that returns no rows). Present exactly when
|
|
49
|
+
* the Adapter declares `sqlStatements`. `ctx.$sql` outside a transaction runs
|
|
50
|
+
* through it.
|
|
32
51
|
*
|
|
33
|
-
*
|
|
34
|
-
* the
|
|
52
|
+
* A failure is thrown like an operation's: a deliberate `AvError` for an
|
|
53
|
+
* outcome the Adapter classified, anything else to be answered `A3001`.
|
|
35
54
|
*/
|
|
36
|
-
readonly
|
|
55
|
+
executeSql?(statement: AvAdapterSqlStatement): Promise<readonly unknown[]>;
|
|
37
56
|
/**
|
|
38
57
|
* Optional callback transaction capability, required exactly when the
|
|
39
58
|
* discovered model declares `transactions: "interactive"`. The callback
|
|
40
|
-
* receives only a transaction-scoped
|
|
41
|
-
*
|
|
59
|
+
* receives only a transaction-scoped executor, never the provider client
|
|
60
|
+
* itself, and every step of a plan executes through it.
|
|
42
61
|
*
|
|
43
|
-
* The implementation must reject with the exact value `work` threw
|
|
44
|
-
* never a wrapper
|
|
45
|
-
* implied by that rejection.
|
|
46
|
-
*
|
|
47
|
-
* not perform network I/O or unrelated slow work.
|
|
62
|
+
* The implementation must reject with the exact value `work` threw (by identity,
|
|
63
|
+
* never a wrapper) and must not resolve after `work` rejected; rollback is
|
|
64
|
+
* implied by that rejection. Every step's interceptors and hooks, and the touched
|
|
65
|
+
* Resources' transaction stages, run inside `work` while the provider transaction
|
|
66
|
+
* is open, so they must not perform network I/O or unrelated slow work. A step's
|
|
67
|
+
* guards, pipes and validators run before it opens.
|
|
48
68
|
*/
|
|
49
|
-
transaction?<T>(work: (executor:
|
|
69
|
+
transaction?<T>(work: (executor: AvAdapterTransactionExecutor<M>) => Promise<T>): Promise<T>;
|
|
50
70
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type AvZCheck } from "./avz-check.registry.js";
|
|
2
|
+
/** The fields a bound applies to, by the kind of value it was written as. */
|
|
3
|
+
type BoundTarget<Value> = Value extends Date ? "datetime" : Value extends bigint ? "bigint" | "decimal" : "number" | "decimal";
|
|
4
|
+
/** A value below `value`. */
|
|
5
|
+
export declare const lt: <const Value extends number | bigint | Date>(value: Value) => AvZCheck<BoundTarget<Value>>;
|
|
6
|
+
/** A value at most `value`. */
|
|
7
|
+
export declare const lte: <const Value extends number | bigint | Date>(value: Value) => AvZCheck<BoundTarget<Value>>;
|
|
8
|
+
/** A value above `value`. */
|
|
9
|
+
export declare const gt: <const Value extends number | bigint | Date>(value: Value) => AvZCheck<BoundTarget<Value>>;
|
|
10
|
+
/** A value at least `value`. */
|
|
11
|
+
export declare const gte: <const Value extends number | bigint | Date>(value: Value) => AvZCheck<BoundTarget<Value>>;
|
|
12
|
+
/** A value above zero. */
|
|
13
|
+
export declare const positive: () => AvZCheck<"number" | "bigint" | "decimal">;
|
|
14
|
+
/** A value at least zero. */
|
|
15
|
+
export declare const nonnegative: () => AvZCheck<"number" | "bigint" | "decimal">;
|
|
16
|
+
/** A value below zero. */
|
|
17
|
+
export declare const negative: () => AvZCheck<"number" | "bigint" | "decimal">;
|
|
18
|
+
/** A value at most zero. */
|
|
19
|
+
export declare const nonpositive: () => AvZCheck<"number" | "bigint" | "decimal">;
|
|
20
|
+
/** A multiple of `value` (not zero). */
|
|
21
|
+
export declare const multipleOf: <const Value extends number | bigint>(value: Value) => AvZCheck<Value extends bigint ? "bigint" | "decimal" : "number" | "decimal">;
|
|
22
|
+
/** A string of at most `maximum` characters (Unicode code points). */
|
|
23
|
+
export declare const maxLength: (maximum: number) => AvZCheck<"string">;
|
|
24
|
+
/** A string of at least `minimum` characters (Unicode code points). */
|
|
25
|
+
export declare const minLength: (minimum: number) => AvZCheck<"string">;
|
|
26
|
+
/** A string of exactly `length` characters (Unicode code points). */
|
|
27
|
+
export declare const length: (exact: number) => AvZCheck<"string">;
|
|
28
|
+
/** A list of at most `maximum` entries. */
|
|
29
|
+
export declare const maxItems: (maximum: number) => AvZCheck<"list">;
|
|
30
|
+
/** A list of at least `minimum` entries. */
|
|
31
|
+
export declare const minItems: (minimum: number) => AvZCheck<"list">;
|
|
32
|
+
/** Bytes of at most `maximum` in length. */
|
|
33
|
+
export declare const maxSize: (maximum: number) => AvZCheck<"bytes">;
|
|
34
|
+
/** Bytes of at least `minimum` in length. */
|
|
35
|
+
export declare const minSize: (minimum: number) => AvZCheck<"bytes">;
|
|
36
|
+
/** Bytes of exactly `size` in length. */
|
|
37
|
+
export declare const size: (exact: number) => AvZCheck<"bytes">;
|
|
38
|
+
/** A string `pattern` matches (a JavaScript regular expression; its flags count). */
|
|
39
|
+
export declare const regex: (pattern: RegExp) => AvZCheck<"string">;
|
|
40
|
+
/** A string containing `value`. */
|
|
41
|
+
export declare const includes: (value: string) => AvZCheck<"string">;
|
|
42
|
+
/** A string starting with `prefix`. */
|
|
43
|
+
export declare const startsWith: (prefix: string) => AvZCheck<"string">;
|
|
44
|
+
/** A string ending with `suffix`. */
|
|
45
|
+
export declare const endsWith: (suffix: string) => AvZCheck<"string">;
|
|
46
|
+
/** A string with no uppercase letter (A–Z). */
|
|
47
|
+
export declare const lowercase: () => AvZCheck<"string">;
|
|
48
|
+
/** A string with no lowercase letter (a–z). */
|
|
49
|
+
export declare const uppercase: () => AvZCheck<"string">;
|
|
50
|
+
export declare const email: () => AvZCheck<"string">;
|
|
51
|
+
export declare const url: () => AvZCheck<"string">;
|
|
52
|
+
export declare const emoji: () => AvZCheck<"string">;
|
|
53
|
+
export declare const uuid: () => AvZCheck<"string">;
|
|
54
|
+
export declare const guid: () => AvZCheck<"string">;
|
|
55
|
+
export declare const nanoid: () => AvZCheck<"string">;
|
|
56
|
+
export declare const cuid: () => AvZCheck<"string">;
|
|
57
|
+
export declare const cuid2: () => AvZCheck<"string">;
|
|
58
|
+
export declare const ulid: () => AvZCheck<"string">;
|
|
59
|
+
export declare const xid: () => AvZCheck<"string">;
|
|
60
|
+
export declare const ksuid: () => AvZCheck<"string">;
|
|
61
|
+
export declare const ipv4: () => AvZCheck<"string">;
|
|
62
|
+
export declare const ipv6: () => AvZCheck<"string">;
|
|
63
|
+
export declare const cidrv4: () => AvZCheck<"string">;
|
|
64
|
+
export declare const cidrv6: () => AvZCheck<"string">;
|
|
65
|
+
export declare const base64: () => AvZCheck<"string">;
|
|
66
|
+
export declare const base64url: () => AvZCheck<"string">;
|
|
67
|
+
export declare const jsonString: () => AvZCheck<"string">;
|
|
68
|
+
export declare const e164: () => AvZCheck<"string">;
|
|
69
|
+
export declare const creditCard: () => AvZCheck<"string">;
|
|
70
|
+
export declare const iban: () => AvZCheck<"string">;
|
|
71
|
+
export declare const jwt: () => AvZCheck<"string">;
|
|
72
|
+
/** zod's ISO 8601 formats, as `z.iso` names them. */
|
|
73
|
+
export declare const iso: Readonly<{
|
|
74
|
+
/** A date-time in UTC (`Z`), seconds required, any fraction (`z.iso.datetime()`). */
|
|
75
|
+
datetime: () => AvZCheck<"string">;
|
|
76
|
+
/** A calendar date, `YYYY-MM-DD` (`z.iso.date()`). */
|
|
77
|
+
date: () => AvZCheck<"string">;
|
|
78
|
+
/** A time, `HH:MM` with optional seconds and fraction (`z.iso.time()`). */
|
|
79
|
+
time: () => AvZCheck<"string">;
|
|
80
|
+
/** A duration such as `P3DT4H` (`z.iso.duration()`). */
|
|
81
|
+
duration: () => AvZCheck<"string">;
|
|
82
|
+
}>;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { registerAvZCheck, } from "./avz-check.registry.js";
|
|
2
|
+
const CHECK_PROTOTYPE = Object.freeze(Object.create(null));
|
|
3
|
+
function build(data) {
|
|
4
|
+
const check = Object.freeze(Object.assign(Object.create(CHECK_PROTOTYPE), data));
|
|
5
|
+
registerAvZCheck(check, Object.freeze({ ...data }));
|
|
6
|
+
return check;
|
|
7
|
+
}
|
|
8
|
+
function bound(builder, value) {
|
|
9
|
+
if ((typeof value === "number" && Number.isFinite(value)) ||
|
|
10
|
+
typeof value === "bigint" ||
|
|
11
|
+
(value instanceof Date && !Number.isNaN(value.getTime()))) {
|
|
12
|
+
return value instanceof Date ? new Date(value.getTime()) : value;
|
|
13
|
+
}
|
|
14
|
+
throw new TypeError(`AvZ.${builder}: the bound must be a finite number, a bigint or a valid Date.`);
|
|
15
|
+
}
|
|
16
|
+
function count(builder, value) {
|
|
17
|
+
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
throw new TypeError(`AvZ.${builder}: the length must be a non-negative integer.`);
|
|
21
|
+
}
|
|
22
|
+
function text(builder, value) {
|
|
23
|
+
if (typeof value === "string") {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
throw new TypeError(`AvZ.${builder}: the text must be a string.`);
|
|
27
|
+
}
|
|
28
|
+
const range = (builder, check, inclusive) => (value) => build({ check, value: bound(builder, value), inclusive });
|
|
29
|
+
const sign = (check, inclusive) => () => build({ check, value: 0, inclusive });
|
|
30
|
+
export const lt = range("lt", "less_than", false);
|
|
31
|
+
export const lte = range("lte", "less_than", true);
|
|
32
|
+
export const gt = range("gt", "greater_than", false);
|
|
33
|
+
export const gte = range("gte", "greater_than", true);
|
|
34
|
+
export const positive = sign("greater_than", false);
|
|
35
|
+
export const nonnegative = sign("greater_than", true);
|
|
36
|
+
export const negative = sign("less_than", false);
|
|
37
|
+
export const nonpositive = sign("less_than", true);
|
|
38
|
+
export const multipleOf = (value) => {
|
|
39
|
+
const step = bound("multipleOf", value);
|
|
40
|
+
if (step instanceof Date || step === 0 || step === 0n) {
|
|
41
|
+
throw new TypeError("AvZ.multipleOf: the step must be a non-zero finite number or bigint.");
|
|
42
|
+
}
|
|
43
|
+
return build({ check: "multiple_of", value: step });
|
|
44
|
+
};
|
|
45
|
+
export const maxLength = (maximum) => build({ check: "max_length", maximum: count("maxLength", maximum) });
|
|
46
|
+
export const minLength = (minimum) => build({ check: "min_length", minimum: count("minLength", minimum) });
|
|
47
|
+
export const length = (exact) => build({ check: "length_equals", length: count("length", exact) });
|
|
48
|
+
export const maxItems = (maximum) => build({
|
|
49
|
+
check: "max_length",
|
|
50
|
+
maximum: count("maxItems", maximum),
|
|
51
|
+
list: true,
|
|
52
|
+
});
|
|
53
|
+
export const minItems = (minimum) => build({
|
|
54
|
+
check: "min_length",
|
|
55
|
+
minimum: count("minItems", minimum),
|
|
56
|
+
list: true,
|
|
57
|
+
});
|
|
58
|
+
export const maxSize = (maximum) => build({ check: "max_size", maximum: count("maxSize", maximum) });
|
|
59
|
+
export const minSize = (minimum) => build({ check: "min_size", minimum: count("minSize", minimum) });
|
|
60
|
+
export const size = (exact) => build({ check: "size_equals", size: count("size", exact) });
|
|
61
|
+
export const regex = (pattern) => {
|
|
62
|
+
if (!(pattern instanceof RegExp)) {
|
|
63
|
+
throw new TypeError("AvZ.regex: the pattern must be a RegExp.");
|
|
64
|
+
}
|
|
65
|
+
return build({
|
|
66
|
+
check: "string_format",
|
|
67
|
+
format: "regex",
|
|
68
|
+
pattern: { source: pattern.source, flags: pattern.flags },
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export const includes = (value) => build({
|
|
72
|
+
check: "string_format",
|
|
73
|
+
format: "includes",
|
|
74
|
+
includes: text("includes", value),
|
|
75
|
+
});
|
|
76
|
+
export const startsWith = (prefix) => build({
|
|
77
|
+
check: "string_format",
|
|
78
|
+
format: "starts_with",
|
|
79
|
+
prefix: text("startsWith", prefix),
|
|
80
|
+
});
|
|
81
|
+
export const endsWith = (suffix) => build({
|
|
82
|
+
check: "string_format",
|
|
83
|
+
format: "ends_with",
|
|
84
|
+
suffix: text("endsWith", suffix),
|
|
85
|
+
});
|
|
86
|
+
export const lowercase = () => build({ check: "string_format", format: "lowercase" });
|
|
87
|
+
export const uppercase = () => build({ check: "string_format", format: "uppercase" });
|
|
88
|
+
const named = (format) => () => build({ check: "string_format", format });
|
|
89
|
+
export const email = named("email");
|
|
90
|
+
export const url = named("url");
|
|
91
|
+
export const emoji = named("emoji");
|
|
92
|
+
export const uuid = named("uuid");
|
|
93
|
+
export const guid = named("guid");
|
|
94
|
+
export const nanoid = named("nanoid");
|
|
95
|
+
export const cuid = named("cuid");
|
|
96
|
+
export const cuid2 = named("cuid2");
|
|
97
|
+
export const ulid = named("ulid");
|
|
98
|
+
export const xid = named("xid");
|
|
99
|
+
export const ksuid = named("ksuid");
|
|
100
|
+
export const ipv4 = named("ipv4");
|
|
101
|
+
export const ipv6 = named("ipv6");
|
|
102
|
+
export const cidrv4 = named("cidrv4");
|
|
103
|
+
export const cidrv6 = named("cidrv6");
|
|
104
|
+
export const base64 = named("base64");
|
|
105
|
+
export const base64url = named("base64url");
|
|
106
|
+
export const jsonString = named("json_string");
|
|
107
|
+
export const e164 = named("e164");
|
|
108
|
+
export const creditCard = named("credit_card");
|
|
109
|
+
export const iban = named("iban");
|
|
110
|
+
export const jwt = named("jwt");
|
|
111
|
+
export const iso = Object.freeze({
|
|
112
|
+
datetime: named("datetime"),
|
|
113
|
+
date: named("date"),
|
|
114
|
+
time: named("time"),
|
|
115
|
+
duration: named("duration"),
|
|
116
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AvFieldCheck } from "../contracts/field-check.js";
|
|
2
|
+
declare const avzCheckTarget: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* What a check applies to: a field's scalar type (`int` and `float` are
|
|
5
|
+
* `"number"`), a Json Shape node (a string, a number or an integer), or a list's
|
|
6
|
+
* own length (`"list"`).
|
|
7
|
+
*/
|
|
8
|
+
export type AvZCheckTarget = "string" | "number" | "bigint" | "decimal" | "datetime" | "bytes" | "list";
|
|
9
|
+
/**
|
|
10
|
+
* A declarative check built with `AvZ` from `@aventara/core/avz` (`AvZ.maxLength(80)`,
|
|
11
|
+
* `AvZ.email()`, …): a field validator, or a check on a Json Shape node.
|
|
12
|
+
*/
|
|
13
|
+
export interface AvZCheck<Target extends AvZCheckTarget = never> {
|
|
14
|
+
readonly [avzCheckTarget]: (target: Target) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A check as `AvZ` built it: the Contract's form, except that a bound or a step
|
|
18
|
+
* is the value the developer wrote (a number, a bigint or a `Date`) until the
|
|
19
|
+
* compiler writes it in the form of the field it lands on.
|
|
20
|
+
*/
|
|
21
|
+
export type AvZAuthoredCheck = {
|
|
22
|
+
readonly check: "less_than" | "greater_than";
|
|
23
|
+
readonly value: number | bigint | Date;
|
|
24
|
+
readonly inclusive: boolean;
|
|
25
|
+
} | {
|
|
26
|
+
readonly check: "multiple_of";
|
|
27
|
+
readonly value: number | bigint;
|
|
28
|
+
} | Exclude<AvFieldCheck, {
|
|
29
|
+
readonly check: "less_than" | "greater_than" | "multiple_of";
|
|
30
|
+
}>;
|
|
31
|
+
/** Records `check` as built by `AvZ`. For `@aventara/core/avz` only. */
|
|
32
|
+
export declare function registerAvZCheck(check: object, data: AvZAuthoredCheck): void;
|
|
33
|
+
/** The check `value` is, or `undefined` when `AvZ` did not build it. */
|
|
34
|
+
export declare function avzCheckOf(value: unknown): AvZAuthoredCheck | undefined;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { JsonSchemaPrimitive, JsonShape, JsonShapeValue } from "../contracts/json-shape.js";
|
|
2
|
+
import { type AvZCheck } from "./avz-check.registry.js";
|
|
3
|
+
/** The forms a Json Shape takes. */
|
|
4
|
+
export type AvZKind = "string" | "number" | "int" | "boolean" | "null" | "literal" | "enum" | "object" | "array" | "tuple" | "record" | "union" | "discriminatedUnion" | "optional" | "nullable";
|
|
5
|
+
/** The checks a shape of one kind takes: a string's, a number's, a list's length; else none. */
|
|
6
|
+
type AvZShapeCheck<Kind extends AvZKind> = Kind extends "string" ? AvZCheck<"string"> : Kind extends "number" | "int" ? AvZCheck<"number"> : Kind extends "array" ? AvZCheck<"list"> : never;
|
|
7
|
+
/**
|
|
8
|
+
* A Json Shape built with {@link AvZ}: opaque, its `kind` and `check` its only
|
|
9
|
+
* members. Its TypeScript type is `AvZ.infer<typeof shape>`.
|
|
10
|
+
*/
|
|
11
|
+
export interface AvZShape<Value = unknown, Kind extends AvZKind = AvZKind> extends JsonShape<Value> {
|
|
12
|
+
readonly kind: Kind;
|
|
13
|
+
/**
|
|
14
|
+
* The same shape with `checks` added: a string takes length, pattern and
|
|
15
|
+
* format checks, a number or an integer takes bounds and `multipleOf`, an
|
|
16
|
+
* array takes `AvZ.minItems`/`AvZ.maxItems`. No other shape takes any.
|
|
17
|
+
*/
|
|
18
|
+
check(...checks: readonly AvZShapeCheck<Kind>[]): this;
|
|
19
|
+
}
|
|
20
|
+
/** The fields of an object shape, by key. */
|
|
21
|
+
export type AvZFields = {
|
|
22
|
+
readonly [key: string]: AvZShape;
|
|
23
|
+
};
|
|
24
|
+
declare const avzOptionalKey: unique symbol;
|
|
25
|
+
/** Marks a shape whose object key may be left out. Type-level only. */
|
|
26
|
+
interface AvZOptionalKey {
|
|
27
|
+
readonly [avzOptionalKey]: true;
|
|
28
|
+
}
|
|
29
|
+
type FieldKeysOptional<Fields extends AvZFields> = {
|
|
30
|
+
[Key in keyof Fields]: Fields[Key] extends AvZOptionalKey ? Key : never;
|
|
31
|
+
}[keyof Fields];
|
|
32
|
+
type Flatten<T> = {
|
|
33
|
+
[Key in keyof T]: T[Key];
|
|
34
|
+
} & {};
|
|
35
|
+
/** The value an object shape describes. */
|
|
36
|
+
type AvZObjectValue<Fields extends AvZFields> = ObjectValueOf<Fields, FieldKeysOptional<Fields>>;
|
|
37
|
+
type ObjectValueOf<Fields extends AvZFields, Optional extends keyof Fields> = Flatten<{
|
|
38
|
+
-readonly [Key in Exclude<keyof Fields, Optional>]: JsonShapeValue<Fields[Key]>;
|
|
39
|
+
} & {
|
|
40
|
+
-readonly [Key in Optional]?: JsonShapeValue<Fields[Key]>;
|
|
41
|
+
}>;
|
|
42
|
+
/** An object shape: closed, so a key it does not declare is refused. */
|
|
43
|
+
export interface AvZObject<Fields extends AvZFields = AvZFields> extends AvZShape<AvZObjectValue<Fields>, "object"> {
|
|
44
|
+
readonly fields: Fields;
|
|
45
|
+
}
|
|
46
|
+
/** A shape whose object key may be left out. */
|
|
47
|
+
export interface AvZOptional<Inner extends AvZShape = AvZShape> extends AvZShape<JsonShapeValue<Inner> | undefined, "optional">, AvZOptionalKey {
|
|
48
|
+
}
|
|
49
|
+
/** A shape that also admits `null`. */
|
|
50
|
+
export type AvZNullable<Inner extends AvZShape = AvZShape> = AvZShape<JsonShapeValue<Inner> | null, "nullable"> & (Inner extends AvZOptionalKey ? AvZOptionalKey : unknown);
|
|
51
|
+
/** A value a literal shape may hold. */
|
|
52
|
+
export type AvZLiteralValue = JsonSchemaPrimitive;
|
|
53
|
+
/** What keys a record shape: any string, an enum's values or one literal. */
|
|
54
|
+
type AvZRecordKey = AvZShape<string, "string"> | AvZShape<string, "enum"> | AvZShape<string, "literal">;
|
|
55
|
+
/** An option of a discriminated union: an object whose discriminator is a literal or an enum. */
|
|
56
|
+
type AvZDiscriminable<Discriminator extends string> = AvZObject<{
|
|
57
|
+
readonly [Key in Discriminator]: AvZShape<AvZLiteralValue, "literal"> | AvZShape<string, "enum">;
|
|
58
|
+
} & AvZFields>;
|
|
59
|
+
type TupleValue<Items extends readonly AvZShape[]> = {
|
|
60
|
+
-readonly [Index in keyof Items]: JsonShapeValue<Items[Index]>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Builds Json Shapes (the type of a Json field, declared at
|
|
64
|
+
* `resources.<Resource>.fields.<field>.definition.json`) and checks in zod's
|
|
65
|
+
* vocabulary: a field's `validators`, and a shape node's `check(...)`. No
|
|
66
|
+
* refinements, transforms or defaults. Objects are closed: a key the shape does
|
|
67
|
+
* not declare is refused.
|
|
68
|
+
*/
|
|
69
|
+
export declare class AvZ {
|
|
70
|
+
private constructor();
|
|
71
|
+
/** Any string. */
|
|
72
|
+
static readonly string: () => AvZShape<string, "string">;
|
|
73
|
+
/** Any finite number. */
|
|
74
|
+
static readonly number: () => AvZShape<number, "number">;
|
|
75
|
+
/** An integer (a safe one). */
|
|
76
|
+
static readonly int: () => AvZShape<number, "int">;
|
|
77
|
+
/** `true` or `false`. */
|
|
78
|
+
static readonly boolean: () => AvZShape<boolean, "boolean">;
|
|
79
|
+
/** `null`. */
|
|
80
|
+
static readonly null: () => AvZShape<null, "null">;
|
|
81
|
+
/** Exactly `value`: a string, a finite number, a boolean or `null`. */
|
|
82
|
+
static readonly literal: <const Value extends AvZLiteralValue>(value: Value) => AvZShape<Value, "literal">;
|
|
83
|
+
/** One of `values`. */
|
|
84
|
+
static readonly enum: <const Values extends readonly [string, ...string[]]>(values: Values) => AvZShape<Values[number], "enum">;
|
|
85
|
+
/** An object with exactly these keys; `AvZ.optional` marks one that may be left out. */
|
|
86
|
+
static readonly object: <const Fields extends AvZFields>(fields: Fields) => AvZObject<Fields>;
|
|
87
|
+
/** A list of `item`s. */
|
|
88
|
+
static readonly array: <Item extends AvZShape>(item: Item) => AvZShape<JsonShapeValue<Item>[], "array">;
|
|
89
|
+
/** A list of exactly these items, in order. */
|
|
90
|
+
static readonly tuple: <const Items extends readonly [AvZShape, ...AvZShape[]]>(items: Items) => AvZShape<TupleValue<Items>, "tuple">;
|
|
91
|
+
/** An object of `value`s, keyed by any string, an enum's values or a literal. */
|
|
92
|
+
static readonly record: <Key extends AvZRecordKey, Value extends AvZShape>(key: Key, value: Value) => AvZShape<Record<JsonShapeValue<Key>, JsonShapeValue<Value>>, "record">;
|
|
93
|
+
/** Any one of `options`. */
|
|
94
|
+
static readonly union: <const Options extends readonly [AvZShape, AvZShape, ...AvZShape[]]>(options: Options) => AvZShape<JsonShapeValue<Options[number]>, "union">;
|
|
95
|
+
/** One of `options`, told apart by the literal or enum at `discriminator`. */
|
|
96
|
+
static readonly discriminatedUnion: <Discriminator extends string, const Options extends readonly [AvZDiscriminable<Discriminator>, ...AvZDiscriminable<Discriminator>[]]>(discriminator: Discriminator, options: Options) => AvZShape<JsonShapeValue<Options[number]>, "discriminatedUnion">;
|
|
97
|
+
/** An object key that may be left out. */
|
|
98
|
+
static readonly optional: <Inner extends AvZShape>(inner: Inner) => AvZOptional<Inner>;
|
|
99
|
+
/** `inner`, or `null`. */
|
|
100
|
+
static readonly nullable: <Inner extends AvZShape>(inner: Inner) => AvZNullable<Inner>;
|
|
101
|
+
/** A value below `value` (a number, a bigint or a `Date`). */
|
|
102
|
+
static readonly lt: <const Value extends number | bigint | Date>(value: Value) => AvZCheck<Value extends Date ? "datetime" : Value extends bigint ? "bigint" | "decimal" : "number" | "decimal">;
|
|
103
|
+
/** A value at most `value` (a number, a bigint or a `Date`). */
|
|
104
|
+
static readonly lte: <const Value extends number | bigint | Date>(value: Value) => AvZCheck<Value extends Date ? "datetime" : Value extends bigint ? "bigint" | "decimal" : "number" | "decimal">;
|
|
105
|
+
/** A value above `value` (a number, a bigint or a `Date`). */
|
|
106
|
+
static readonly gt: <const Value extends number | bigint | Date>(value: Value) => AvZCheck<Value extends Date ? "datetime" : Value extends bigint ? "bigint" | "decimal" : "number" | "decimal">;
|
|
107
|
+
/** A value at least `value` (a number, a bigint or a `Date`). */
|
|
108
|
+
static readonly gte: <const Value extends number | bigint | Date>(value: Value) => AvZCheck<Value extends Date ? "datetime" : Value extends bigint ? "bigint" | "decimal" : "number" | "decimal">;
|
|
109
|
+
/** A value above zero. */
|
|
110
|
+
static readonly positive: () => AvZCheck<"number" | "bigint" | "decimal">;
|
|
111
|
+
/** A value at least zero. */
|
|
112
|
+
static readonly nonnegative: () => AvZCheck<"number" | "bigint" | "decimal">;
|
|
113
|
+
/** A value below zero. */
|
|
114
|
+
static readonly negative: () => AvZCheck<"number" | "bigint" | "decimal">;
|
|
115
|
+
/** A value at most zero. */
|
|
116
|
+
static readonly nonpositive: () => AvZCheck<"number" | "bigint" | "decimal">;
|
|
117
|
+
/** A multiple of `value`. */
|
|
118
|
+
static readonly multipleOf: <const Value extends number | bigint>(value: Value) => AvZCheck<Value extends bigint ? "bigint" | "decimal" : "number" | "decimal">;
|
|
119
|
+
/** A string of at most `maximum` characters; on a list field, each entry. */
|
|
120
|
+
static readonly maxLength: (maximum: number) => AvZCheck<"string">;
|
|
121
|
+
/** A string of at least `minimum` characters; on a list field, each entry. */
|
|
122
|
+
static readonly minLength: (minimum: number) => AvZCheck<"string">;
|
|
123
|
+
/** A string of exactly `length` characters; on a list field, each entry. */
|
|
124
|
+
static readonly length: (exact: number) => AvZCheck<"string">;
|
|
125
|
+
/** A list of at most `maximum` entries: a list field, or an array shape. */
|
|
126
|
+
static readonly maxItems: (maximum: number) => AvZCheck<"list">;
|
|
127
|
+
/** A list of at least `minimum` entries: a list field, or an array shape. */
|
|
128
|
+
static readonly minItems: (minimum: number) => AvZCheck<"list">;
|
|
129
|
+
/** Bytes of at most `maximum` in length. */
|
|
130
|
+
static readonly maxSize: (maximum: number) => AvZCheck<"bytes">;
|
|
131
|
+
/** Bytes of at least `minimum` in length. */
|
|
132
|
+
static readonly minSize: (minimum: number) => AvZCheck<"bytes">;
|
|
133
|
+
/** Bytes of exactly `size` in length. */
|
|
134
|
+
static readonly size: (exact: number) => AvZCheck<"bytes">;
|
|
135
|
+
/** A string the pattern matches: a JavaScript regular expression, flags included. */
|
|
136
|
+
static readonly regex: (pattern: RegExp) => AvZCheck<"string">;
|
|
137
|
+
/** A string containing `value`. */
|
|
138
|
+
static readonly includes: (value: string) => AvZCheck<"string">;
|
|
139
|
+
/** A string starting with `prefix`. */
|
|
140
|
+
static readonly startsWith: (prefix: string) => AvZCheck<"string">;
|
|
141
|
+
/** A string ending with `suffix`. */
|
|
142
|
+
static readonly endsWith: (suffix: string) => AvZCheck<"string">;
|
|
143
|
+
/** A string with no uppercase letter. */
|
|
144
|
+
static readonly lowercase: () => AvZCheck<"string">;
|
|
145
|
+
/** A string with no lowercase letter. */
|
|
146
|
+
static readonly uppercase: () => AvZCheck<"string">;
|
|
147
|
+
/** An email address. */
|
|
148
|
+
static readonly email: () => AvZCheck<"string">;
|
|
149
|
+
/** A URL. */
|
|
150
|
+
static readonly url: () => AvZCheck<"string">;
|
|
151
|
+
/** Emoji only. */
|
|
152
|
+
static readonly emoji: () => AvZCheck<"string">;
|
|
153
|
+
/** A UUID (any version). */
|
|
154
|
+
static readonly uuid: () => AvZCheck<"string">;
|
|
155
|
+
/** A GUID: any 8-4-4-4-12 hex identifier. */
|
|
156
|
+
static readonly guid: () => AvZCheck<"string">;
|
|
157
|
+
/** A Nano ID. */
|
|
158
|
+
static readonly nanoid: () => AvZCheck<"string">;
|
|
159
|
+
/** A CUID. */
|
|
160
|
+
static readonly cuid: () => AvZCheck<"string">;
|
|
161
|
+
/** A CUID2. */
|
|
162
|
+
static readonly cuid2: () => AvZCheck<"string">;
|
|
163
|
+
/** A ULID. */
|
|
164
|
+
static readonly ulid: () => AvZCheck<"string">;
|
|
165
|
+
/** An XID. */
|
|
166
|
+
static readonly xid: () => AvZCheck<"string">;
|
|
167
|
+
/** A KSUID. */
|
|
168
|
+
static readonly ksuid: () => AvZCheck<"string">;
|
|
169
|
+
/** An IPv4 address. */
|
|
170
|
+
static readonly ipv4: () => AvZCheck<"string">;
|
|
171
|
+
/** An IPv6 address. */
|
|
172
|
+
static readonly ipv6: () => AvZCheck<"string">;
|
|
173
|
+
/** An IPv4 CIDR block. */
|
|
174
|
+
static readonly cidrv4: () => AvZCheck<"string">;
|
|
175
|
+
/** An IPv6 CIDR block. */
|
|
176
|
+
static readonly cidrv6: () => AvZCheck<"string">;
|
|
177
|
+
/** Base64. */
|
|
178
|
+
static readonly base64: () => AvZCheck<"string">;
|
|
179
|
+
/** Base64url. */
|
|
180
|
+
static readonly base64url: () => AvZCheck<"string">;
|
|
181
|
+
/** A string that parses as JSON (zod's `json_string` format). */
|
|
182
|
+
static readonly jsonString: () => AvZCheck<"string">;
|
|
183
|
+
/** An E.164 phone number. */
|
|
184
|
+
static readonly e164: () => AvZCheck<"string">;
|
|
185
|
+
/** A credit card number (Luhn-checked). */
|
|
186
|
+
static readonly creditCard: () => AvZCheck<"string">;
|
|
187
|
+
/** An IBAN (checksum-checked). */
|
|
188
|
+
static readonly iban: () => AvZCheck<"string">;
|
|
189
|
+
/** A JWT. */
|
|
190
|
+
static readonly jwt: () => AvZCheck<"string">;
|
|
191
|
+
/** ISO 8601: `datetime`, `date`, `time` and `duration`. */
|
|
192
|
+
static readonly iso: Readonly<{
|
|
193
|
+
datetime: () => AvZCheck<"string">;
|
|
194
|
+
date: () => AvZCheck<"string">;
|
|
195
|
+
time: () => AvZCheck<"string">;
|
|
196
|
+
duration: () => AvZCheck<"string">;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
export declare namespace AvZ {
|
|
200
|
+
/** The TypeScript type a shape describes. */
|
|
201
|
+
type infer<Shape extends JsonShape> = JsonShapeValue<Shape>;
|
|
202
|
+
}
|
|
203
|
+
export {};
|