@aventara/core 1.0.0-rc.0 → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/CHANGELOG.md +1434 -0
  2. package/ERRORS.md +142 -0
  3. package/README.md +247 -57
  4. package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
  5. package/dist/adapters/adapter-discovery-diagnostic.guidance.d.ts +6 -0
  6. package/dist/adapters/adapter-discovery-diagnostic.guidance.js +7 -0
  7. package/dist/adapters/adapter-field.d.ts +25 -11
  8. package/dist/adapters/adapter-identifier.d.ts +6 -6
  9. package/dist/adapters/adapter-model.d.ts +18 -9
  10. package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
  11. package/dist/adapters/adapter-operation.d.ts +3 -3
  12. package/dist/adapters/adapter-resource.d.ts +18 -9
  13. package/dist/adapters/adapter-sql-statement.d.ts +19 -0
  14. package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
  15. package/dist/adapters/adapter.interface.d.ts +59 -29
  16. package/dist/avz/avz-check.factory.d.ts +83 -0
  17. package/dist/avz/avz-check.factory.js +116 -0
  18. package/dist/avz/avz-check.registry.d.ts +35 -0
  19. package/dist/avz/avz-check.registry.js +9 -0
  20. package/dist/avz/avz.d.ts +203 -0
  21. package/dist/{json → avz}/avz.js +150 -8
  22. package/dist/{json → avz}/index.d.ts +2 -1
  23. package/dist/{json → avz}/json-shape.registry.d.ts +7 -7
  24. package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
  25. package/dist/{json → avz}/zod-issue.translator.js +7 -0
  26. package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
  27. package/dist/compiler/contract-compiler-diagnostic.guidance.d.ts +6 -0
  28. package/dist/compiler/contract-compiler-diagnostic.guidance.js +97 -0
  29. package/dist/compiler/contract.compiler.d.ts +18 -18
  30. package/dist/compiler/contract.compiler.js +637 -442
  31. package/dist/compiler/create-requirements.projector.d.ts +49 -0
  32. package/dist/compiler/create-requirements.projector.js +423 -0
  33. package/dist/compiler/field-validator.compiler.d.ts +47 -0
  34. package/dist/compiler/field-validator.compiler.js +238 -0
  35. package/dist/config/any-framework-config.d.ts +19 -12
  36. package/dist/config/computed-fields.d.ts +62 -0
  37. package/dist/config/computed-fields.js +80 -0
  38. package/dist/config/config-diagnostic.d.ts +11 -4
  39. package/dist/config/config-diagnostic.guidance.d.ts +6 -0
  40. package/dist/config/config-diagnostic.guidance.js +32 -0
  41. package/dist/config/config-layer.d.ts +15 -6
  42. package/dist/config/config.resolver.d.ts +74 -31
  43. package/dist/config/config.resolver.js +108 -44
  44. package/dist/config/config.validator.d.ts +7 -7
  45. package/dist/config/config.validator.js +581 -72
  46. package/dist/config/define-resource.d.ts +57 -0
  47. package/dist/config/define-resource.js +14 -0
  48. package/dist/config/effective-fields.d.ts +19 -23
  49. package/dist/config/entrypoint.normalizer.d.ts +1 -1
  50. package/dist/config/exact-framework-config.d.ts +308 -0
  51. package/dist/config/field-compute.resolver.d.ts +21 -0
  52. package/dist/config/field-compute.resolver.js +123 -0
  53. package/dist/config/field-pipeline-config.d.ts +47 -0
  54. package/dist/config/forced-operation.validator.d.ts +10 -0
  55. package/dist/config/forced-operation.validator.js +66 -0
  56. package/dist/config/framework-config.d.ts +111 -39
  57. package/dist/config/framework-exemptions-config.d.ts +91 -0
  58. package/dist/config/framework-exemptions-config.js +1 -0
  59. package/dist/config/framework-field-definition.d.ts +78 -0
  60. package/dist/config/framework-field-definition.js +28 -0
  61. package/dist/config/framework-resources-config.d.ts +122 -0
  62. package/dist/config/framework-resources-config.js +1 -0
  63. package/dist/config/pipeline-config.d.ts +56 -20
  64. package/dist/config/pipeline-tree.resolver.d.ts +79 -0
  65. package/dist/config/pipeline-tree.resolver.js +220 -0
  66. package/dist/config/stage-type.eraser.d.ts +65 -0
  67. package/dist/config/stage-type.eraser.js +1 -0
  68. package/dist/contracts/capability.d.ts +21 -12
  69. package/dist/contracts/capability.js +2 -0
  70. package/dist/contracts/client-contract-structure.validator.d.ts +388 -63
  71. package/dist/contracts/client-contract-structure.validator.js +156 -10
  72. package/dist/contracts/contract-canonicalizer.d.ts +26 -3
  73. package/dist/contracts/contract-canonicalizer.js +156 -29
  74. package/dist/contracts/contract-hash.d.ts +12 -7
  75. package/dist/contracts/contract-hash.js +3 -2
  76. package/dist/contracts/contract-limits.d.ts +4 -1
  77. package/dist/contracts/contract-limits.js +1 -0
  78. package/dist/contracts/contract-lookup.d.ts +5 -5
  79. package/dist/contracts/contract-protocol.d.ts +4 -4
  80. package/dist/contracts/contract.d.ts +24 -16
  81. package/dist/contracts/create-requirements.d.ts +35 -0
  82. package/dist/contracts/create-requirements.js +1 -0
  83. package/dist/contracts/enum-definition.d.ts +1 -1
  84. package/dist/contracts/field-check.d.ts +101 -0
  85. package/dist/contracts/field-check.js +1 -0
  86. package/dist/contracts/field.d.ts +81 -42
  87. package/dist/contracts/identifier.d.ts +4 -4
  88. package/dist/contracts/json-shape.d.ts +12 -1
  89. package/dist/contracts/lifecycle-trait.d.ts +2 -2
  90. package/dist/contracts/resource-operations.d.ts +28 -28
  91. package/dist/contracts/resource.d.ts +15 -9
  92. package/dist/contracts/scalar-value-type.d.ts +15 -15
  93. package/dist/contracts/scalar.d.ts +3 -3
  94. package/dist/contracts/transaction-capability.d.ts +1 -1
  95. package/dist/contracts/wire-scalar-format.d.ts +4 -4
  96. package/dist/framework/contract-view.d.ts +213 -147
  97. package/dist/framework/framework-construction.error.d.ts +19 -10
  98. package/dist/framework/framework-construction.error.js +7 -3
  99. package/dist/framework/framework.d.ts +47 -23
  100. package/dist/framework/framework.factory.d.ts +8 -6
  101. package/dist/framework/framework.factory.js +49 -22
  102. package/dist/framework/operation-facade.d.ts +123 -52
  103. package/dist/framework/operation-facade.js +9 -1
  104. package/dist/index.d.ts +57 -50
  105. package/dist/index.js +7 -6
  106. package/dist/internal.d.ts +17 -10
  107. package/dist/internal.js +4 -1
  108. package/dist/operations/database-refusal.d.ts +51 -0
  109. package/dist/operations/database-refusal.js +45 -0
  110. package/dist/operations/operation-arguments.d.ts +343 -207
  111. package/dist/operations/operation-call.d.ts +27 -28
  112. package/dist/operations/operation-identity.d.ts +10 -10
  113. package/dist/operations/operation-result.d.ts +21 -21
  114. package/dist/operations/operation-validator-core.d.ts +6 -6
  115. package/dist/operations/operation-validator-core.js +99 -6
  116. package/dist/operations/operation-validator.d.ts +9 -9
  117. package/dist/operations/projection-scope.resolver.d.ts +6 -6
  118. package/dist/operations/structural-limits.walker.d.ts +6 -6
  119. package/dist/operations/structural-limits.walker.js +145 -0
  120. package/dist/operations/validation-code.d.ts +11 -6
  121. package/dist/operations/validation-code.guidance.d.ts +6 -0
  122. package/dist/operations/validation-code.guidance.js +90 -0
  123. package/dist/operations/validation-code.js +4 -0
  124. package/dist/operations/write-scope.resolver.d.ts +10 -6
  125. package/dist/operations/write-scope.resolver.js +2 -0
  126. package/dist/protocol/absent-route.responder.d.ts +13 -12
  127. package/dist/protocol/absent-route.responder.js +19 -19
  128. package/dist/protocol/contract-document.responder.d.ts +3 -3
  129. package/dist/protocol/contract-document.responder.js +2 -2
  130. package/dist/protocol/http-request.decoder.d.ts +17 -13
  131. package/dist/protocol/http-request.decoder.js +10 -10
  132. package/dist/protocol/http-request.reader.d.ts +3 -3
  133. package/dist/protocol/http-response.encoder.d.ts +4 -4
  134. package/dist/protocol/http-response.encoder.js +94 -55
  135. package/dist/protocol/http-status.table.d.ts +2 -2
  136. package/dist/protocol/operation-response.guard.d.ts +2 -2
  137. package/dist/protocol/protocol-surface.d.ts +4 -4
  138. package/dist/protocol/protocol.binder.d.ts +50 -27
  139. package/dist/protocol/protocol.binder.js +12 -9
  140. package/dist/protocol/protocol.handler.d.ts +22 -13
  141. package/dist/protocol/protocol.handler.js +91 -17
  142. package/dist/protocol/unmounted-route.error.d.ts +4 -4
  143. package/dist/protocol/unmounted-route.error.js +2 -2
  144. package/dist/runtime/caller-data.copier.d.ts +22 -5
  145. package/dist/runtime/caller-data.copier.js +31 -14
  146. package/dist/runtime/caller-data.door.d.ts +17 -11
  147. package/dist/runtime/caller-data.door.js +6 -4
  148. package/dist/runtime/computed-read-runtime.d.ts +7 -6
  149. package/dist/runtime/computed-read-runtime.js +76 -50
  150. package/dist/runtime/computed-value.error.d.ts +7 -6
  151. package/dist/runtime/computed-value.error.js +5 -4
  152. package/dist/runtime/context-executor.runtime.d.ts +59 -0
  153. package/dist/runtime/context-executor.runtime.js +275 -0
  154. package/dist/runtime/create-requirement.d.ts +44 -79
  155. package/dist/runtime/create-requirement.js +213 -73
  156. package/dist/runtime/decimal.d.ts +2 -2
  157. package/dist/runtime/decimal.js +1 -1
  158. package/dist/runtime/diagnostics-reporter.d.ts +54 -27
  159. package/dist/runtime/diagnostics-reporter.js +24 -0
  160. package/dist/runtime/error-boundary.d.ts +65 -8
  161. package/dist/runtime/error-boundary.js +49 -19
  162. package/dist/runtime/error-guidance.d.ts +12 -0
  163. package/dist/runtime/error-guidance.js +1 -0
  164. package/dist/runtime/error.catalog.d.ts +49 -0
  165. package/dist/runtime/error.catalog.js +49 -0
  166. package/dist/runtime/execution-options.d.ts +10 -2
  167. package/dist/runtime/field-check.evaluator.d.ts +29 -0
  168. package/dist/runtime/field-check.evaluator.js +521 -0
  169. package/dist/runtime/field-compute.d.ts +64 -0
  170. package/dist/runtime/field-compute.js +1 -0
  171. package/dist/runtime/field-stage.plan.d.ts +15 -0
  172. package/dist/runtime/field-stage.plan.js +27 -0
  173. package/dist/runtime/field-stage.runtime.d.ts +37 -0
  174. package/dist/runtime/field-stage.runtime.js +147 -0
  175. package/dist/runtime/field-validator.runtime.d.ts +19 -0
  176. package/dist/runtime/field-validator.runtime.js +92 -0
  177. package/dist/runtime/framework-error-class.table.d.ts +33 -0
  178. package/dist/runtime/framework-error-class.table.js +25 -0
  179. package/dist/runtime/framework-error.d.ts +68 -8
  180. package/dist/runtime/framework-error.factory.d.ts +4 -0
  181. package/dist/runtime/framework-error.factory.js +15 -0
  182. package/dist/runtime/framework-error.js +23 -2
  183. package/dist/runtime/interceptor-next.error.d.ts +5 -0
  184. package/dist/runtime/interceptor-next.error.js +6 -0
  185. package/dist/runtime/json-value.d.ts +11 -6
  186. package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
  187. package/dist/runtime/level-lifecycle.runtime.js +39 -0
  188. package/dist/runtime/misuse-reporter.d.ts +12 -12
  189. package/dist/runtime/mutation-planner.d.ts +19 -10
  190. package/dist/runtime/mutation-planner.js +48 -35
  191. package/dist/runtime/nested-write.walker.d.ts +32 -0
  192. package/dist/runtime/nested-write.walker.js +73 -0
  193. package/dist/runtime/operation-code.guidance.d.ts +6 -0
  194. package/dist/runtime/operation-code.guidance.js +167 -0
  195. package/dist/runtime/operation-request.d.ts +33 -6
  196. package/dist/runtime/operation-response.d.ts +17 -17
  197. package/dist/runtime/operation-runtime.d.ts +127 -25
  198. package/dist/runtime/operation-runtime.js +441 -78
  199. package/dist/runtime/outcome-mapper.d.ts +16 -5
  200. package/dist/runtime/outcome-mapper.js +23 -6
  201. package/dist/runtime/output-validator.d.ts +10 -10
  202. package/dist/runtime/output-validator.js +3 -3
  203. package/dist/runtime/owned-execution.registry.d.ts +16 -6
  204. package/dist/runtime/pipe-output.validator.d.ts +43 -18
  205. package/dist/runtime/pipe-output.validator.js +15 -13
  206. package/dist/runtime/pipeline.d.ts +223 -34
  207. package/dist/runtime/readonly-value.d.ts +43 -0
  208. package/dist/runtime/readonly-value.js +150 -0
  209. package/dist/runtime/request-envelope.validator.d.ts +3 -3
  210. package/dist/runtime/request-envelope.validator.js +12 -7
  211. package/dist/runtime/request-id.d.ts +1 -1
  212. package/dist/runtime/request-state.d.ts +14 -0
  213. package/dist/runtime/request-state.js +1 -0
  214. package/dist/runtime/request-state.resolver.d.ts +12 -0
  215. package/dist/runtime/request-state.resolver.js +20 -0
  216. package/dist/runtime/scalar-runtime.d.ts +35 -16
  217. package/dist/runtime/scalar-runtime.js +102 -34
  218. package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
  219. package/dist/runtime/unsent-value.normalizer.js +128 -0
  220. package/dist/transactions/deferred-operation.d.ts +35 -20
  221. package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
  222. package/dist/transactions/operation-arguments-encoder.js +2 -2
  223. package/dist/transactions/operation-fingerprint.js +2 -2
  224. package/dist/transactions/sql-statement.d.ts +85 -0
  225. package/dist/transactions/sql-statement.js +47 -0
  226. package/dist/transactions/sql-statement.validator.d.ts +44 -0
  227. package/dist/transactions/sql-statement.validator.js +167 -0
  228. package/dist/transactions/transaction-envelope.d.ts +4 -4
  229. package/dist/transactions/transaction-integrity-error.d.ts +6 -6
  230. package/dist/transactions/transaction-integrity-error.js +5 -2
  231. package/dist/transactions/transaction-plan-assembler.d.ts +21 -11
  232. package/dist/transactions/transaction-plan-assembler.js +169 -32
  233. package/dist/transactions/transaction-plan-validator.d.ts +45 -20
  234. package/dist/transactions/transaction-plan-validator.js +96 -38
  235. package/dist/transactions/transaction-reference-collector.d.ts +5 -5
  236. package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
  237. package/dist/transactions/transaction-reference-resolver.js +26 -14
  238. package/dist/transactions/transaction-reference-validator.d.ts +76 -4
  239. package/dist/transactions/transaction-reference-validator.js +129 -71
  240. package/dist/transactions/transaction-reference.d.ts +13 -13
  241. package/dist/transactions/transaction-reference.js +5 -0
  242. package/dist/transactions/transaction-request.d.ts +18 -5
  243. package/dist/transactions/transaction-response.d.ts +6 -6
  244. package/dist/transactions/transaction-runtime.d.ts +8 -7
  245. package/dist/transactions/transaction-runtime.js +191 -50
  246. package/dist/transactions/transaction-settlement.runtime.d.ts +51 -0
  247. package/dist/transactions/transaction-settlement.runtime.js +120 -0
  248. package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
  249. package/dist/transactions/transaction-slot-path-error.js +2 -2
  250. package/dist/transactions/transaction-slot-writer.js +2 -2
  251. package/dist/transactions/transaction-stage.runtime.d.ts +82 -0
  252. package/dist/transactions/transaction-stage.runtime.js +126 -0
  253. package/package.json +9 -7
  254. package/src/runtime/field-check.evaluator.ts +720 -0
  255. package/dist/config/define-fields.d.ts +0 -42
  256. package/dist/config/define-fields.js +0 -3
  257. package/dist/config/framework-behaviors-config.d.ts +0 -30
  258. package/dist/config/framework-fields-config.d.ts +0 -42
  259. package/dist/config/framework-restrictions-config.d.ts +0 -142
  260. package/dist/json/avz.d.ts +0 -96
  261. package/dist/runtime/field-behavior.d.ts +0 -48
  262. /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
  263. /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
  264. /package/dist/{json → avz}/index.js +0 -0
  265. /package/dist/{json → avz}/json-shape.registry.js +0 -0
  266. /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
  267. /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
@@ -1,29 +1,43 @@
1
- import type { RelationFieldCapabilities, ScalarFieldCapabilities, ScalarFormat } from "../contracts/field.js";
2
- import type { LifecycleTrait } from "../contracts/lifecycle-trait.js";
3
- import type { AdapterModel } from "./adapter-model.js";
1
+ import type { AvRelationFieldCapabilities, AvScalarFieldCapabilities, AvScalarFormat } from "../contracts/field.js";
2
+ import type { AvLifecycleTrait } from "../contracts/lifecycle-trait.js";
3
+ import type { AvAdapterModel } from "./adapter-model.js";
4
4
  /** Provider-observable lifecycle facts available during adapter discovery. */
5
- export type AdapterLifecycleTrait = Extract<LifecycleTrait, "DEFAULTED" | "GENERATED_ON_CREATE" | "GENERATED_ON_UPDATE">;
5
+ export type AvAdapterLifecycleTrait = Extract<AvLifecycleTrait, "DEFAULTED" | "GENERATED_ON_CREATE" | "GENERATED_ON_UPDATE">;
6
6
  /** Scalar-shaped provider field expressed only in Aventara vocabulary. */
7
- export type AdapterScalarField<M extends AdapterModel> = {
7
+ export type AvAdapterScalarField<M extends AvAdapterModel> = {
8
8
  readonly kind: "scalar";
9
9
  readonly type: {
10
10
  readonly scalar: Extract<keyof M["scalars"], string>;
11
11
  } | {
12
12
  readonly enum: Extract<keyof M["enums"], string>;
13
13
  };
14
- readonly format?: ScalarFormat;
14
+ readonly format?: AvScalarFormat;
15
15
  readonly nullable: boolean;
16
16
  readonly list: boolean;
17
- readonly lifecycle: readonly AdapterLifecycleTrait[];
18
- readonly capabilities: ScalarFieldCapabilities;
17
+ readonly lifecycle: readonly AvAdapterLifecycleTrait[];
18
+ readonly capabilities: AvScalarFieldCapabilities;
19
19
  };
20
20
  /** A discovered relation field; the `target` Resource describes the related row. */
21
- export type AdapterRelationField<M extends AdapterModel> = {
21
+ export type AvAdapterRelationField<M extends AvAdapterModel> = {
22
22
  readonly kind: "relation";
23
23
  readonly target: Extract<keyof M["resources"], string>;
24
24
  readonly cardinality: "one" | "many";
25
25
  readonly nullable: boolean;
26
- readonly capabilities: RelationFieldCapabilities;
26
+ readonly capabilities: AvRelationFieldCapabilities;
27
+ /**
28
+ * The target's relation field that is this relation's other end, when the data
29
+ * source pairs them (`User.posts` ↔ `Post.author`; a self-relation's two ends
30
+ * name each other). Absent: no pairing is stated, and no write is read as
31
+ * walking a relation back.
32
+ */
33
+ readonly inverse?: string;
34
+ /**
35
+ * The scalar fields of this Resource that hold the relation's reference, in
36
+ * the order the data source pairs them with the target's key
37
+ * (`Post.author` → `["authorId"]`), on an optional relation as on a required
38
+ * one. Absent on the end that holds no reference (`User.posts`); never empty.
39
+ */
40
+ readonly referenceFields?: readonly [string, ...string[]];
27
41
  };
28
42
  /** One field the adapter discovered: a scalar or a relation. */
29
- export type AdapterField<M extends AdapterModel> = AdapterScalarField<M> | AdapterRelationField<M>;
43
+ export type AvAdapterField<M extends AvAdapterModel> = AvAdapterScalarField<M> | AvAdapterRelationField<M>;
@@ -1,7 +1,7 @@
1
- import type { AdapterField } from "./adapter-field.js";
2
- import type { AdapterModel } from "./adapter-model.js";
1
+ import type { AvAdapterField } from "./adapter-field.js";
2
+ import type { AvAdapterModel } from "./adapter-model.js";
3
3
  /** Keys of `TFields` whose discovered field can be scalar-shaped. */
4
- export type AdapterScalarFieldKey<TFields extends Readonly<Record<string, AdapterField<AdapterModel>>>> = Extract<{
4
+ export type AvAdapterScalarFieldKey<TFields extends Readonly<Record<string, AvAdapterField<AvAdapterModel>>>> = Extract<{
5
5
  [K in keyof TFields]: [
6
6
  Extract<TFields[K], {
7
7
  readonly kind: "scalar";
@@ -9,7 +9,7 @@ export type AdapterScalarFieldKey<TFields extends Readonly<Record<string, Adapte
9
9
  ] extends [never] ? never : K;
10
10
  }[keyof TFields], string>;
11
11
  /** Non-empty scalar-field tuple discovered as provider uniqueness. */
12
- export type AdapterIdentifier<TFields extends Readonly<Record<string, AdapterField<AdapterModel>>>> = readonly [
13
- AdapterScalarFieldKey<TFields>,
14
- ...AdapterScalarFieldKey<TFields>[]
12
+ export type AvAdapterIdentifier<TFields extends Readonly<Record<string, AvAdapterField<AvAdapterModel>>>> = readonly [
13
+ AvAdapterScalarFieldKey<TFields>,
14
+ ...AvAdapterScalarFieldKey<TFields>[]
15
15
  ];
@@ -1,21 +1,22 @@
1
- import type { EnumDefinition } from "../contracts/enum-definition.js";
1
+ import type { AvConfigComputedFields } from "../config/computed-fields.js";
2
+ import type { AvEnumDefinition } from "../contracts/enum-definition.js";
2
3
  import type { ReferenceWriteLimit } from "../contracts/reference-write-limit.js";
3
- import type { ScalarRegistry } from "../contracts/scalar.js";
4
- import type { TransactionCapability } from "../contracts/transaction-capability.js";
5
- import type { AdapterResource } from "./adapter-resource.js";
4
+ import type { AvScalarRegistry } from "../contracts/scalar.js";
5
+ import type { AvTransactionCapability } from "../contracts/transaction-capability.js";
6
+ import type { AvAdapterResource } from "./adapter-resource.js";
6
7
  /**
7
8
  * Canonical provider-discovery facts before framework configuration or
8
9
  * Contract compilation is applied.
9
10
  */
10
- export interface AdapterModel {
11
+ export interface AvAdapterModel {
11
12
  /** The scalar types the data source supports. */
12
- readonly scalars: ScalarRegistry;
13
+ readonly scalars: AvScalarRegistry;
13
14
  /** The enums the data source declares, by name. */
14
- readonly enums: Readonly<Record<string, EnumDefinition>>;
15
+ readonly enums: Readonly<Record<string, AvEnumDefinition>>;
15
16
  /** The discovered Resources, by name. */
16
- readonly resources: Readonly<Record<string, AdapterResource<this>>>;
17
+ readonly resources: Readonly<Record<string, AvAdapterResource<this>>>;
17
18
  /** Whether the adapter can run interactive transactions. */
18
- readonly transactions: TransactionCapability;
19
+ readonly transactions: AvTransactionCapability;
19
20
  /**
20
21
  * `"uniform"` when the data source takes one record's references only one
21
22
  * way at a time: every relation that holds a reference written as a
@@ -23,4 +24,12 @@ export interface AdapterModel {
23
24
  * either way. Compiled into every Contract.
24
25
  */
25
26
  readonly referenceWrites?: ReferenceWriteLimit;
27
+ /**
28
+ * Type-only, never present at runtime: which fields the configuration's write
29
+ * compute fills, as an adapter's generate step read them off the
30
+ * configuration's type. A variant's guards, pipes and filters may leave
31
+ * exactly those out of a create. Absent: any create field may be computed, so
32
+ * those stages require none.
33
+ */
34
+ readonly "~computedFields"?: AvConfigComputedFields;
26
35
  }
@@ -1,10 +1,10 @@
1
- import type { AdapterModel } from "./adapter-model.js";
2
- import type { AdapterOperation } from "./adapter-operation.js";
1
+ import type { AvAdapterModel } from "./adapter-model.js";
2
+ import type { AvAdapterOperation } from "./adapter-operation.js";
3
3
  /**
4
4
  * Executes one operation against the provider, directly or inside a provider
5
5
  * transaction.
6
6
  */
7
- export interface AdapterOperationExecutor<M extends AdapterModel = AdapterModel> {
7
+ export interface AvAdapterOperationExecutor<M extends AvAdapterModel = AvAdapterModel> {
8
8
  /** Runs one validated operation and resolves its raw result. */
9
- execute(operation: AdapterOperation<M>): Promise<unknown>;
9
+ execute(operation: AvAdapterOperation<M>): Promise<unknown>;
10
10
  }
@@ -1,12 +1,12 @@
1
- import type { OperationIdentity } from "../operations/operation-identity.js";
1
+ import type { AvOperationIdentity } from "../operations/operation-identity.js";
2
2
  import type { SemanticOperationArguments } from "../operations/operation-validator.js";
3
- import type { AdapterModel } from "./adapter-model.js";
3
+ import type { AvAdapterModel } from "./adapter-model.js";
4
4
  /**
5
5
  * Provider execution request after framework semantic validation.
6
6
  * Operation identity and arguments remain provider-neutral; adapters receive
7
7
  * only validated semantic argument objects, never raw transport input.
8
8
  */
9
- export type AdapterOperation<M extends AdapterModel = AdapterModel> = OperationIdentity & {
9
+ export type AvAdapterOperation<M extends AvAdapterModel = AvAdapterModel> = AvOperationIdentity & {
10
10
  readonly resource: Extract<keyof M["resources"], string>;
11
11
  readonly arguments: SemanticOperationArguments;
12
12
  };
@@ -1,20 +1,29 @@
1
- import type { ResourceOperations } from "../contracts/resource-operations.js";
2
- import type { AdapterField } from "./adapter-field.js";
3
- import type { AdapterIdentifier } from "./adapter-identifier.js";
4
- import type { AdapterModel } from "./adapter-model.js";
1
+ import type { AvCreateRequirements } from "../contracts/create-requirements.js";
2
+ import type { AvResourceOperations } from "../contracts/resource-operations.js";
3
+ import type { AvAdapterField } from "./adapter-field.js";
4
+ import type { AvAdapterIdentifier } from "./adapter-identifier.js";
5
+ import type { AvAdapterModel } from "./adapter-model.js";
5
6
  /** A discovered Resource's fields, by name. */
6
- export type AdapterFieldMap<M extends AdapterModel> = Readonly<Record<string, AdapterField<M>>>;
7
+ export type AvAdapterFieldMap<M extends AvAdapterModel> = Readonly<Record<string, AvAdapterField<M>>>;
7
8
  /**
8
9
  * The field names the adapter discovered for Resource `R`, before any
9
10
  * configuration adds to them.
10
11
  */
11
- export type AdapterFieldKey<M extends AdapterModel, R extends Extract<keyof M["resources"], string>> = Extract<keyof M["resources"][R]["fields"], string>;
12
+ export type AvAdapterFieldKey<M extends AvAdapterModel, R extends Extract<keyof M["resources"], string>> = Extract<keyof M["resources"][R]["fields"], string>;
12
13
  /** Provider-discovered facts for one Aventara Resource candidate. */
13
- export type AdapterResource<M extends AdapterModel, TFields extends AdapterFieldMap<M> = AdapterFieldMap<M>> = {
14
+ export type AvAdapterResource<M extends AvAdapterModel, TFields extends AvAdapterFieldMap<M> = AvAdapterFieldMap<M>> = {
14
15
  /** The Resource's fields, by name. */
15
16
  readonly fields: TFields;
16
17
  /** The field tuples that identify at most one row. */
17
- readonly identifiers: readonly AdapterIdentifier<TFields>[];
18
+ readonly identifiers: readonly AvAdapterIdentifier<TFields>[];
18
19
  /** The standard operations the data source can run for this Resource. */
19
- readonly operations: ResourceOperations;
20
+ readonly operations: AvResourceOperations;
21
+ /**
22
+ * What a create cannot do without, in the store's own terms: every field it
23
+ * requires, every required to-one relation with its reference fields, and
24
+ * the relation (`parentSupplies`) through which a nested create gets them
25
+ * from its parent. Absent when it requires nothing, or when the adapter
26
+ * cannot say; nothing is then checked or typed before the store.
27
+ */
28
+ readonly createRequirements?: AvCreateRequirements;
20
29
  };
@@ -0,0 +1,19 @@
1
+ import type { AvDecimal } from "../runtime/decimal.js";
2
+ import type { AvJsonValue } from "../runtime/json-value.js";
3
+ /**
4
+ * One value a developer SQL statement binds, after every `$ref` in it was
5
+ * resolved: a primitive, a `Date`, a {@link AvDecimal}, a `Uint8Array`, or a
6
+ * plain object or array, which is a JSON value and is bound as JSON text. Never
7
+ * spliced into the statement's text.
8
+ */
9
+ export type AvAdapterSqlValue = string | number | boolean | bigint | null | Date | AvDecimal | Uint8Array | AvJsonValue;
10
+ /**
11
+ * One developer SQL statement, as `framework.appTx.$sql` wrote it: the static
12
+ * text of its tagged template, and the values written between those pieces, in
13
+ * order. `strings` holds exactly one entry more than `values`. The adapter binds
14
+ * every value as a parameter of the statement; no value ever becomes SQL text.
15
+ */
16
+ export type AvAdapterSqlStatement = {
17
+ readonly strings: readonly string[];
18
+ readonly values: readonly AvAdapterSqlValue[];
19
+ };
@@ -0,0 +1,19 @@
1
+ import type { AvAdapterModel } from "./adapter-model.js";
2
+ import type { AvAdapterOperationExecutor } from "./adapter-operation-executor.interface.js";
3
+ import type { AvAdapterSqlStatement } from "./adapter-sql-statement.js";
4
+ /**
5
+ * What an Adapter's `transaction` callback is handed: the transaction-scoped
6
+ * operation executor, and — when the Adapter declares `sqlStatements` — the
7
+ * statement runner `framework.appTx.$sql` steps run through.
8
+ */
9
+ export interface AvAdapterTransactionExecutor<M extends AvAdapterModel = AvAdapterModel> extends AvAdapterOperationExecutor<M> {
10
+ /**
11
+ * Runs one developer SQL statement on the open transaction, every value bound
12
+ * as a parameter, and resolves the rows it returned (none for a statement that
13
+ * returns no rows). Present exactly when the Adapter declares `sqlStatements`.
14
+ *
15
+ * A failure is thrown like an operation's: a deliberate `AvError` for
16
+ * an outcome the Adapter classified, anything else to be answered `A3001`.
17
+ */
18
+ executeSql?(statement: AvAdapterSqlStatement): Promise<readonly unknown[]>;
19
+ }
@@ -1,50 +1,80 @@
1
- import type { CreateRequirementTable } from "../runtime/create-requirement.js";
1
+ import type { AvConfigComputedFields } from "../config/computed-fields.js";
2
2
  import type { ReferentialActionTable } from "../runtime/referential-action.js";
3
- import type { AdapterModel } from "./adapter-model.js";
4
- import type { AdapterOperationExecutor } from "./adapter-operation-executor.interface.js";
3
+ import type { AvAdapterModel } from "./adapter-model.js";
4
+ import type { AvAdapterOperationExecutor } from "./adapter-operation-executor.interface.js";
5
+ import type { AvAdapterSqlStatement } from "./adapter-sql-statement.js";
6
+ import type { AvAdapterTransactionExecutor } from "./adapter-transaction-executor.interface.js";
5
7
  /** Provider-specific implementation of Aventara discovery and execution. */
6
- export interface Adapter<M extends AdapterModel = AdapterModel> extends AdapterOperationExecutor<M> {
8
+ export interface AvAdapter<M extends AvAdapterModel = AvAdapterModel> extends AvAdapterOperationExecutor<M> {
7
9
  /**
8
10
  * What the adapter discovered about the data source, in Aventara's vocabulary.
9
11
  * Read once, synchronously, when the framework is constructed.
10
12
  */
11
13
  readonly model: M;
12
14
  /**
13
- * Optional referential actions: for each Resource that holds a reference,
14
- * every relation holding one — the fields that hold it (`references`) and
15
- * what deleting a referenced row does to its rows. Read once when the
16
- * framework is constructed; never part of a Contract or its hash.
15
+ * Optional referential actions: for each Resource that holds a reference, every
16
+ * relation holding one: the fields that hold it (`references`) and what deleting a
17
+ * referenced row does to its rows. Read once when the framework is constructed;
18
+ * never part of a Contract or its hash.
19
+ *
20
+ * An edge listed under Resource `R` says that deleting a `target` row does
21
+ * `onDelete` to rows of `R`, and that `R`'s `references` fields hold the relation
22
+ * `field`'s reference.
17
23
  *
18
- * An edge listed under Resource `R` says **deleting a `target` row does
19
- * `onDelete` to rows of `R`**, and that `R`'s `references` fields hold the
20
- * relation `field`'s reference.
24
+ * The same edges say which side of a relation holds its key: a nested `$connect`,
25
+ * `$disconnect` or `$set` on a to-one relation the parent holds runs none of the
26
+ * target's stages, and otherwise runs the target's `update` guards.
21
27
  *
22
- * When absent, no cascade is planned and no transaction plan is refused
23
- * because of one (`V1019`); a write that sets a relation and a field holding
24
- * its reference both is not refused before the store; and a required
25
- * relation can be satisfied only by writing the relation.
28
+ * When absent, no cascade is planned and no transaction plan is refused because of
29
+ * one (`V1019`); a write that sets a relation and a field holding its reference
30
+ * both is not refused before the store; and every nested `$connect`, `$disconnect`
31
+ * or `$set` runs the target's `update` guards.
26
32
  */
27
33
  readonly referentialActions?: ReferentialActionTable;
28
34
  /**
29
- * Optional create requirements: for each Resource, the values its store
30
- * cannot create a row without. Read once when the framework is constructed;
31
- * never part of a Contract or its hash.
35
+ * Optional: which fields the configuration's write compute fills, as the
36
+ * Adapter's generate step read them when it wrote the model's type (the same
37
+ * statement as the type's `"~computedFields"`). When the Framework is
38
+ * constructed it is compared with the configuration, and a difference is a
39
+ * warning that the generated types are stale (`aventara:prepare` regenerates
40
+ * them); it changes no behaviour. Never part of a Contract or its hash.
41
+ */
42
+ readonly computedFields?: AvConfigComputedFields;
43
+ /**
44
+ * Optional: `true` when the Adapter runs developer SQL statements: standalone
45
+ * through its own {@link executeSql}, and, when it has `transaction`, inside a
46
+ * transaction through the `executeSql` of the executor that callback is handed
47
+ * (`AvAdapterTransactionExecutor.executeSql`). `framework.appTx.$sql` steps and
48
+ * `ctx.$sql` need it. Read once when the framework is constructed; never part
49
+ * of a Contract or its hash.
50
+ *
51
+ * When absent, a plan holding an `appTx.$sql` step is refused before the
52
+ * transaction opens (`A2002`/`V1006` at the step), and so is every `ctx.$sql`.
53
+ */
54
+ readonly sqlStatements?: boolean;
55
+ /**
56
+ * Runs one developer SQL statement outside any transaction, as a plain
57
+ * statement, every value bound as a parameter, and resolves the rows it
58
+ * returned (none for a statement that returns no rows). Present exactly when
59
+ * the Adapter declares `sqlStatements`. `ctx.$sql` outside a transaction runs
60
+ * through it.
32
61
  *
33
- * When absent, creates are not checked for missing values before they reach
34
- * the store.
62
+ * A failure is thrown like an operation's: a deliberate `AvError` for an
63
+ * outcome the Adapter classified, anything else to be answered `A3001`.
35
64
  */
36
- readonly createRequirements?: CreateRequirementTable;
65
+ executeSql?(statement: AvAdapterSqlStatement): Promise<readonly unknown[]>;
37
66
  /**
38
67
  * Optional callback transaction capability, required exactly when the
39
68
  * discovered model declares `transactions: "interactive"`. The callback
40
- * receives only a transaction-scoped operation executor, never the provider
41
- * client itself, and every operation of a plan executes through it.
69
+ * receives only a transaction-scoped executor, never the provider client
70
+ * itself, and every step of a plan executes through it.
42
71
  *
43
- * The implementation must reject with the exact value `work` threw — by identity,
44
- * never a wrapper — and must not resolve after `work` rejected; rollback is
45
- * implied by that rejection. Guards, pipes, hooks and interceptors of every plan
46
- * operation run inside `work` while the provider transaction is open, so they must
47
- * not perform network I/O or unrelated slow work.
72
+ * The implementation must reject with the exact value `work` threw (by identity,
73
+ * never a wrapper) and must not resolve after `work` rejected; rollback is
74
+ * implied by that rejection. Every step's interceptors and hooks, and the touched
75
+ * Resources' transaction stages, run inside `work` while the provider transaction
76
+ * is open, so they must not perform network I/O or unrelated slow work. A step's
77
+ * guards, pipes and validators run before it opens.
48
78
  */
49
- transaction?<T>(work: (executor: AdapterOperationExecutor<M>) => Promise<T>): Promise<T>;
79
+ transaction?<T>(work: (executor: AvAdapterTransactionExecutor<M>) => Promise<T>): Promise<T>;
50
80
  }
@@ -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,9 @@
1
+ const checks = new WeakMap();
2
+ export function registerAvZCheck(check, data) {
3
+ checks.set(check, data);
4
+ }
5
+ export function avzCheckOf(value) {
6
+ return typeof value === "object" && value !== null
7
+ ? checks.get(value)
8
+ : undefined;
9
+ }