@aventara/core 1.0.0-rc.1 → 1.0.0-rc.11

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 (261) hide show
  1. package/CHANGELOG.md +1022 -16
  2. package/ERRORS.md +142 -0
  3. package/README.md +330 -16
  4. package/dist/adapters/adapter-discovery-diagnostic.guidance.d.ts +6 -0
  5. package/dist/adapters/adapter-discovery-diagnostic.guidance.js +7 -0
  6. package/dist/adapters/adapter-field.d.ts +22 -0
  7. package/dist/adapters/adapter-identifier.d.ts +9 -0
  8. package/dist/adapters/adapter-identifier.js +6 -1
  9. package/dist/adapters/adapter-model.d.ts +9 -0
  10. package/dist/adapters/adapter-operation.d.ts +18 -3
  11. package/dist/adapters/adapter-resource.d.ts +5 -0
  12. package/dist/adapters/adapter.interface.d.ts +10 -0
  13. package/dist/avz/avz.d.ts +1 -1
  14. package/dist/avz/json-shape.registry.d.ts +2 -1
  15. package/dist/compiler/contract-compiler-diagnostic.guidance.d.ts +6 -0
  16. package/dist/compiler/contract-compiler-diagnostic.guidance.js +97 -0
  17. package/dist/compiler/contract.compiler.d.ts +6 -0
  18. package/dist/compiler/contract.compiler.js +281 -31
  19. package/dist/compiler/create-requirements.projector.js +1 -3
  20. package/dist/compiler/field-validator.compiler.js +1 -3
  21. package/dist/compiler/managed-elsewhere.projector.d.ts +52 -0
  22. package/dist/compiler/managed-elsewhere.projector.js +179 -0
  23. package/dist/compiler/managed-elsewhere.validator.d.ts +9 -0
  24. package/dist/compiler/managed-elsewhere.validator.js +74 -0
  25. package/dist/config/cache-stage.factory.d.ts +24 -0
  26. package/dist/config/cache-stage.factory.js +3 -0
  27. package/dist/config/computed-fields.d.ts +62 -0
  28. package/dist/config/computed-fields.js +73 -0
  29. package/dist/config/config-diagnostic.guidance.d.ts +6 -0
  30. package/dist/config/config-diagnostic.guidance.js +32 -0
  31. package/dist/config/config.resolver.d.ts +24 -0
  32. package/dist/config/config.resolver.js +66 -7
  33. package/dist/config/config.validator.js +283 -21
  34. package/dist/config/define-resource.d.ts +1 -5
  35. package/dist/config/entrypoint.normalizer.d.ts +3 -2
  36. package/dist/config/exact-framework-config.d.ts +73 -22
  37. package/dist/config/field-compute.resolver.d.ts +2 -0
  38. package/dist/config/field-compute.resolver.js +9 -3
  39. package/dist/config/framework-config.d.ts +53 -15
  40. package/dist/config/framework-resources-config.d.ts +25 -14
  41. package/dist/config/pipeline-config.d.ts +20 -4
  42. package/dist/config/pipeline-tree.resolver.d.ts +2 -2
  43. package/dist/config/pipeline-tree.resolver.js +2 -3
  44. package/dist/contracts/access-route.rules.d.ts +10 -0
  45. package/dist/contracts/access-route.rules.js +45 -0
  46. package/dist/contracts/canonical-json.writer.d.ts +7 -0
  47. package/dist/contracts/canonical-json.writer.js +55 -0
  48. package/dist/contracts/capability.d.ts +26 -1
  49. package/dist/contracts/capability.js +20 -0
  50. package/dist/contracts/client-contract-structure.validator.d.ts +365 -89
  51. package/dist/contracts/client-contract-structure.validator.js +49 -2
  52. package/dist/contracts/contract-access.d.ts +29 -0
  53. package/dist/contracts/contract-access.js +1 -0
  54. package/dist/contracts/contract-canonicalizer.d.ts +9 -1
  55. package/dist/contracts/contract-canonicalizer.js +35 -4
  56. package/dist/contracts/contract-hash.d.ts +0 -1
  57. package/dist/contracts/contract-hash.js +1 -1
  58. package/dist/contracts/contract-limits.d.ts +6 -0
  59. package/dist/contracts/contract-limits.js +2 -0
  60. package/dist/contracts/contract.d.ts +42 -1
  61. package/dist/contracts/field.d.ts +58 -1
  62. package/dist/contracts/json-schema.projector.d.ts +11 -0
  63. package/dist/contracts/json-schema.projector.js +76 -0
  64. package/dist/contracts/scalar-value-type.d.ts +3 -1
  65. package/dist/framework/access-facade.d.ts +116 -0
  66. package/dist/framework/access-facade.js +118 -0
  67. package/dist/framework/contract-view.d.ts +120 -16
  68. package/dist/framework/framework-construction.error.d.ts +14 -4
  69. package/dist/framework/framework-construction.error.js +18 -2
  70. package/dist/framework/framework.d.ts +26 -5
  71. package/dist/framework/framework.factory.d.ts +1 -1
  72. package/dist/framework/framework.factory.js +145 -24
  73. package/dist/framework/operation-facade.d.ts +141 -13
  74. package/dist/framework/operation-facade.js +9 -1
  75. package/dist/framework/operation-set.runner.d.ts +47 -0
  76. package/dist/framework/operation-set.runner.js +168 -0
  77. package/dist/index.d.ts +19 -5
  78. package/dist/index.js +3 -0
  79. package/dist/internal.d.ts +9 -2
  80. package/dist/internal.js +8 -0
  81. package/dist/operations/database-refusal.d.ts +51 -0
  82. package/dist/operations/database-refusal.js +45 -0
  83. package/dist/operations/operation-arguments.d.ts +148 -60
  84. package/dist/operations/operation-call.d.ts +9 -5
  85. package/dist/operations/operation-result.d.ts +6 -4
  86. package/dist/operations/operation-validator-core.js +160 -39
  87. package/dist/operations/operation-validator.d.ts +1 -1
  88. package/dist/operations/structural-limits.walker.d.ts +1 -1
  89. package/dist/operations/structural-limits.walker.js +1 -3
  90. package/dist/operations/validation-code.guidance.d.ts +6 -0
  91. package/dist/operations/validation-code.guidance.js +90 -0
  92. package/dist/operations/write-scope.resolver.d.ts +4 -0
  93. package/dist/operations/write-scope.resolver.js +2 -0
  94. package/dist/policy/access-provider.interface.d.ts +91 -0
  95. package/dist/policy/access-provider.interface.js +1 -0
  96. package/dist/policy/access-provider.registry.d.ts +17 -0
  97. package/dist/policy/access-provider.registry.js +15 -0
  98. package/dist/policy/access-question.d.ts +20 -0
  99. package/dist/policy/access-question.js +1 -0
  100. package/dist/policy/access-question.registry.d.ts +5 -0
  101. package/dist/policy/access-question.registry.js +19 -0
  102. package/dist/policy/access-question.runtime.d.ts +36 -0
  103. package/dist/policy/access-question.runtime.js +295 -0
  104. package/dist/policy/access-verb.table.d.ts +56 -0
  105. package/dist/policy/access-verb.table.js +21 -0
  106. package/dist/policy/access-verbs.d.ts +46 -0
  107. package/dist/policy/access-verbs.js +1 -0
  108. package/dist/policy/policy-admission.d.ts +20 -0
  109. package/dist/policy/policy-admission.js +407 -0
  110. package/dist/policy/policy-after-update.runtime.d.ts +79 -0
  111. package/dist/policy/policy-after-update.runtime.js +206 -0
  112. package/dist/policy/policy-condition.d.ts +15 -0
  113. package/dist/policy/policy-condition.js +36 -0
  114. package/dist/policy/policy-engine.d.ts +205 -0
  115. package/dist/policy/policy-engine.js +1 -0
  116. package/dist/policy/policy-named-rows.d.ts +18 -0
  117. package/dist/policy/policy-named-rows.js +51 -0
  118. package/dist/policy/policy-nested-write.runtime.d.ts +44 -0
  119. package/dist/policy/policy-nested-write.runtime.js +536 -0
  120. package/dist/policy/policy-read.runtime.d.ts +81 -0
  121. package/dist/policy/policy-read.runtime.js +501 -0
  122. package/dist/policy/policy-reference-write.runtime.d.ts +51 -0
  123. package/dist/policy/policy-reference-write.runtime.js +336 -0
  124. package/dist/policy/policy-request.d.ts +72 -0
  125. package/dist/policy/policy-request.js +115 -0
  126. package/dist/policy/policy-session.d.ts +106 -0
  127. package/dist/policy/policy-session.js +293 -0
  128. package/dist/policy/policy-startup.validator.d.ts +10 -0
  129. package/dist/policy/policy-startup.validator.js +112 -0
  130. package/dist/policy/policy-write.runtime.d.ts +39 -0
  131. package/dist/policy/policy-write.runtime.js +530 -0
  132. package/dist/prebuilt/core-version.generated.d.ts +2 -0
  133. package/dist/prebuilt/core-version.generated.js +1 -0
  134. package/dist/prebuilt/prebuilt-changes.d.ts +29 -0
  135. package/dist/prebuilt/prebuilt-changes.js +63 -0
  136. package/dist/prebuilt/prebuilt-contracts.d.ts +40 -0
  137. package/dist/prebuilt/prebuilt-contracts.emitter.d.ts +16 -0
  138. package/dist/prebuilt/prebuilt-contracts.emitter.js +50 -0
  139. package/dist/prebuilt/prebuilt-contracts.js +1 -0
  140. package/dist/prebuilt/prebuilt-contracts.loader.d.ts +19 -0
  141. package/dist/prebuilt/prebuilt-contracts.loader.js +75 -0
  142. package/dist/prebuilt/prebuilt-inputs.fingerprint.d.ts +16 -0
  143. package/dist/prebuilt/prebuilt-inputs.fingerprint.js +227 -0
  144. package/dist/protocol/absent-route.responder.d.ts +49 -14
  145. package/dist/protocol/absent-route.responder.js +92 -15
  146. package/dist/protocol/contract-document.responder.d.ts +9 -1
  147. package/dist/protocol/contract-document.responder.js +3 -2
  148. package/dist/protocol/http-request.decoder.d.ts +52 -3
  149. package/dist/protocol/http-request.decoder.js +45 -6
  150. package/dist/protocol/http-request.reader.d.ts +10 -3
  151. package/dist/protocol/http-request.reader.js +12 -2
  152. package/dist/protocol/http-response.encoder.d.ts +12 -0
  153. package/dist/protocol/http-response.encoder.js +17 -3
  154. package/dist/protocol/operation-response.guard.js +1 -3
  155. package/dist/protocol/operation-set.decoder.d.ts +48 -0
  156. package/dist/protocol/operation-set.decoder.js +185 -0
  157. package/dist/protocol/operation-set.handler.d.ts +27 -0
  158. package/dist/protocol/operation-set.handler.js +179 -0
  159. package/dist/protocol/protocol-headers.d.ts +12 -3
  160. package/dist/protocol/protocol-headers.js +12 -5
  161. package/dist/protocol/protocol-surface.d.ts +16 -3
  162. package/dist/protocol/protocol-surface.js +41 -1
  163. package/dist/protocol/protocol.binder.d.ts +52 -1
  164. package/dist/protocol/protocol.binder.js +6 -1
  165. package/dist/protocol/protocol.handler.d.ts +45 -1
  166. package/dist/protocol/protocol.handler.js +164 -19
  167. package/dist/protocol/read-cache.responder.d.ts +26 -0
  168. package/dist/protocol/read-cache.responder.js +47 -0
  169. package/dist/protocol/read-query.codec.d.ts +34 -0
  170. package/dist/protocol/read-query.codec.js +125 -0
  171. package/dist/runtime/caller-data.copier.d.ts +18 -3
  172. package/dist/runtime/caller-data.copier.js +21 -8
  173. package/dist/runtime/caller-data.door.d.ts +13 -6
  174. package/dist/runtime/computed-read-runtime.d.ts +6 -1
  175. package/dist/runtime/computed-read-runtime.js +229 -48
  176. package/dist/runtime/computed-value.error.d.ts +3 -2
  177. package/dist/runtime/computed-value.error.js +3 -2
  178. package/dist/runtime/context-executor.runtime.d.ts +4 -3
  179. package/dist/runtime/context-executor.runtime.js +4 -2
  180. package/dist/runtime/core-class.brand.d.ts +10 -0
  181. package/dist/runtime/core-class.brand.js +21 -0
  182. package/dist/runtime/create-requirement.d.ts +31 -5
  183. package/dist/runtime/create-requirement.js +130 -24
  184. package/dist/runtime/decimal.d.ts +14 -0
  185. package/dist/runtime/decimal.js +21 -0
  186. package/dist/runtime/diagnostics-reporter.d.ts +49 -9
  187. package/dist/runtime/diagnostics-reporter.js +16 -9
  188. package/dist/runtime/error-boundary.d.ts +9 -2
  189. package/dist/runtime/error-boundary.js +12 -0
  190. package/dist/runtime/error-guidance.d.ts +12 -0
  191. package/dist/runtime/error-guidance.js +1 -0
  192. package/dist/runtime/error.catalog.d.ts +49 -0
  193. package/dist/runtime/error.catalog.js +49 -0
  194. package/dist/runtime/execution-options.d.ts +8 -0
  195. package/dist/runtime/field-check.evaluator.d.ts +0 -2
  196. package/dist/runtime/field-check.evaluator.js +1 -1
  197. package/dist/runtime/field-compute.d.ts +11 -10
  198. package/dist/runtime/field-stage.runtime.d.ts +3 -3
  199. package/dist/runtime/field-stage.runtime.js +9 -11
  200. package/dist/runtime/field-validator.runtime.d.ts +19 -1
  201. package/dist/runtime/field-validator.runtime.js +49 -9
  202. package/dist/runtime/framework-error.js +9 -0
  203. package/dist/runtime/framework-warning.emitter.d.ts +6 -0
  204. package/dist/runtime/framework-warning.emitter.js +8 -0
  205. package/dist/runtime/json-value.d.ts +10 -5
  206. package/dist/runtime/level-lifecycle.runtime.d.ts +4 -3
  207. package/dist/runtime/level-lifecycle.runtime.js +3 -5
  208. package/dist/runtime/mutation-planner.d.ts +1 -6
  209. package/dist/runtime/mutation-planner.js +4 -17
  210. package/dist/runtime/nested-write.walker.js +2 -1
  211. package/dist/runtime/operation-code.guidance.d.ts +6 -0
  212. package/dist/runtime/operation-code.guidance.js +167 -0
  213. package/dist/runtime/operation-request.d.ts +16 -9
  214. package/dist/runtime/operation-runtime.d.ts +35 -17
  215. package/dist/runtime/operation-runtime.js +220 -49
  216. package/dist/runtime/outcome-mapper.d.ts +2 -1
  217. package/dist/runtime/output-validator.d.ts +1 -1
  218. package/dist/runtime/output-validator.js +1 -3
  219. package/dist/runtime/owned-execution.registry.d.ts +34 -4
  220. package/dist/runtime/pipe-output.validator.d.ts +10 -0
  221. package/dist/runtime/pipe-output.validator.js +4 -2
  222. package/dist/runtime/pipeline.d.ts +52 -23
  223. package/dist/runtime/readonly-value.d.ts +20 -5
  224. package/dist/runtime/readonly-value.js +74 -26
  225. package/dist/runtime/record.guard.d.ts +14 -0
  226. package/dist/runtime/record.guard.js +10 -0
  227. package/dist/runtime/referential-action.d.ts +1 -1
  228. package/dist/runtime/request-envelope.validator.js +13 -10
  229. package/dist/runtime/scalar-runtime.d.ts +4 -21
  230. package/dist/runtime/scalar-runtime.js +91 -31
  231. package/dist/runtime/thenable.guard.d.ts +7 -0
  232. package/dist/runtime/thenable.guard.js +5 -0
  233. package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
  234. package/dist/runtime/unsent-value.normalizer.js +129 -0
  235. package/dist/transactions/operation-arguments-encoder.js +9 -10
  236. package/dist/transactions/operation-fingerprint.js +2 -2
  237. package/dist/transactions/sql-statement.d.ts +10 -2
  238. package/dist/transactions/sql-statement.validator.d.ts +2 -2
  239. package/dist/transactions/sql-statement.validator.js +40 -6
  240. package/dist/transactions/transaction-envelope.d.ts +5 -4
  241. package/dist/transactions/transaction-integrity-error.js +2 -0
  242. package/dist/transactions/transaction-plan-assembler.d.ts +12 -5
  243. package/dist/transactions/transaction-plan-assembler.js +49 -17
  244. package/dist/transactions/transaction-plan-validator.d.ts +23 -7
  245. package/dist/transactions/transaction-plan-validator.js +31 -7
  246. package/dist/transactions/transaction-reference-collector.js +8 -10
  247. package/dist/transactions/transaction-reference-resolver.d.ts +3 -2
  248. package/dist/transactions/transaction-reference-resolver.js +1 -3
  249. package/dist/transactions/transaction-reference-validator.d.ts +43 -3
  250. package/dist/transactions/transaction-reference-validator.js +83 -57
  251. package/dist/transactions/transaction-reference.d.ts +1 -1
  252. package/dist/transactions/transaction-reference.js +5 -0
  253. package/dist/transactions/transaction-request.d.ts +8 -8
  254. package/dist/transactions/transaction-runtime.d.ts +5 -2
  255. package/dist/transactions/transaction-runtime.js +108 -27
  256. package/dist/transactions/transaction-settlement.runtime.d.ts +4 -3
  257. package/dist/transactions/transaction-slot-path-error.js +2 -0
  258. package/dist/transactions/transaction-stage.runtime.d.ts +5 -3
  259. package/dist/transactions/transaction-stage.runtime.js +8 -7
  260. package/package.json +6 -5
  261. package/src/runtime/field-check.evaluator.ts +1 -1
@@ -24,6 +24,28 @@ export type AvAdapterRelationField<M extends AvAdapterModel> = {
24
24
  readonly cardinality: "one" | "many";
25
25
  readonly nullable: boolean;
26
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[]];
41
+ /**
42
+ * The target's scalar fields that `referenceFields` name, pair by pair in
43
+ * the same order (`Post.author`: `referenceFields: ["authorId"]`,
44
+ * `references: ["id"]`, so `Post.authorId` holds `User.id`). Stated only
45
+ * beside `referenceFields`, with as many entries; absent on the end that
46
+ * holds no reference, where the other end (`inverse`) states the pairs.
47
+ */
48
+ readonly references?: readonly [string, ...string[]];
27
49
  };
28
50
  /** One field the adapter discovered: a scalar or a relation. */
29
51
  export type AvAdapterField<M extends AvAdapterModel> = AvAdapterScalarField<M> | AvAdapterRelationField<M>;
@@ -13,3 +13,12 @@ export type AvAdapterIdentifier<TFields extends Readonly<Record<string, AvAdapte
13
13
  AvAdapterScalarFieldKey<TFields>,
14
14
  ...AvAdapterScalarFieldKey<TFields>[]
15
15
  ];
16
+ /**
17
+ * The Resource's identifier as the Adapter states it first: in the Adapter's
18
+ * own order (an ORM adapter's is its schema's, so the primary key). The Core
19
+ * Contract sorts identifiers for its hash, so its first one is the
20
+ * alphabetically first (`email` before `id`) and says nothing about which is
21
+ * the primary key; the model keeps the order it declared. Empty for a Resource
22
+ * the model does not hold or that has no identifier.
23
+ */
24
+ export declare function adapterPrimaryIdentifier(model: AvAdapterModel, resource: string): readonly string[];
@@ -1 +1,6 @@
1
- export {};
1
+ export function adapterPrimaryIdentifier(model, resource) {
2
+ const resources = model.resources;
3
+ return ((Object.hasOwn(resources, resource)
4
+ ? resources[resource]?.identifiers?.[0]
5
+ : undefined) ?? []);
6
+ }
@@ -1,3 +1,4 @@
1
+ import type { AvConfigComputedFields } from "../config/computed-fields.js";
1
2
  import type { AvEnumDefinition } from "../contracts/enum-definition.js";
2
3
  import type { ReferenceWriteLimit } from "../contracts/reference-write-limit.js";
3
4
  import type { AvScalarRegistry } from "../contracts/scalar.js";
@@ -23,4 +24,12 @@ export interface AvAdapterModel {
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
  }
@@ -2,9 +2,24 @@ import type { AvOperationIdentity } from "../operations/operation-identity.js";
2
2
  import type { SemanticOperationArguments } from "../operations/operation-validator.js";
3
3
  import type { AvAdapterModel } from "./adapter-model.js";
4
4
  /**
5
- * Provider execution request after framework semantic validation.
6
- * Operation identity and arguments remain provider-neutral; adapters receive
7
- * only validated semantic argument objects, never raw transport input.
5
+ * Provider execution request after framework semantic validation. Operation
6
+ * identity and arguments remain provider-neutral; adapters receive only validated
7
+ * semantic argument objects, never raw transport input.
8
+ *
9
+ * Three shapes exist here only, each an `AND`: a list of conditions in the general
10
+ * `where` grammar the addressed row must also meet.
11
+ *
12
+ * - The flat unique selector of an `update.unique` or a `delete.unique` may carry
13
+ * it. A row the selector names that misses them is a miss (the same `null` as a
14
+ * row that is not there).
15
+ * - A `cursor` may carry it, at the root of a `find.many` and in a to-many
16
+ * relation's arguments. A row the cursor names that misses them is a cursor that
17
+ * names no row: the same answer as a cursor on a row that is not there.
18
+ * - A row the selector names that misses them, or no row, is refused: the adapter
19
+ * fails the operation with `A4002`.
20
+ *
21
+ * An adapter must honour it or refuse the operation, never drop it: dropping it
22
+ * would write a row the conditions exclude, or position a page at one.
8
23
  */
9
24
  export type AvAdapterOperation<M extends AvAdapterModel = AvAdapterModel> = AvOperationIdentity & {
10
25
  readonly resource: Extract<keyof M["resources"], string>;
@@ -26,4 +26,9 @@ export type AvAdapterResource<M extends AvAdapterModel, TFields extends AvAdapte
26
26
  * cannot say; nothing is then checked or typed before the store.
27
27
  */
28
28
  readonly createRequirements?: AvCreateRequirements;
29
+ /**
30
+ * The database schema the store keeps this Resource in (a PostgreSQL schema,
31
+ * say), when the store has schemas and the model names one. Absent otherwise.
32
+ */
33
+ readonly schema?: string;
29
34
  };
@@ -1,3 +1,4 @@
1
+ import type { AvConfigComputedFields } from "../config/computed-fields.js";
1
2
  import type { ReferentialActionTable } from "../runtime/referential-action.js";
2
3
  import type { AvAdapterModel } from "./adapter-model.js";
3
4
  import type { AvAdapterOperationExecutor } from "./adapter-operation-executor.interface.js";
@@ -30,6 +31,15 @@ export interface AvAdapter<M extends AvAdapterModel = AvAdapterModel> extends Av
30
31
  * or `$set` runs the target's `update` guards.
31
32
  */
32
33
  readonly referentialActions?: ReferentialActionTable;
34
+ /**
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;
33
43
  /**
34
44
  * Optional: `true` when the Adapter runs developer SQL statements: standalone
35
45
  * through its own {@link executeSql}, and, when it has `transaction`, inside a
package/dist/avz/avz.d.ts CHANGED
@@ -49,7 +49,7 @@ export interface AvZOptional<Inner extends AvZShape = AvZShape> extends AvZShape
49
49
  /** A shape that also admits `null`. */
50
50
  export type AvZNullable<Inner extends AvZShape = AvZShape> = AvZShape<JsonShapeValue<Inner> | null, "nullable"> & (Inner extends AvZOptionalKey ? AvZOptionalKey : unknown);
51
51
  /** A value a literal shape may hold. */
52
- export type AvZLiteralValue = JsonSchemaPrimitive;
52
+ type AvZLiteralValue = JsonSchemaPrimitive;
53
53
  /** What keys a record shape: any string, an enum's values or one literal. */
54
54
  type AvZRecordKey = AvZShape<string, "string"> | AvZShape<string, "enum"> | AvZShape<string, "literal">;
55
55
  /** An option of a discriminated union: an object whose discriminator is a literal or an enum. */
@@ -3,7 +3,7 @@ import type { AvScalarField } from "../contracts/field.js";
3
3
  import type { JsonSchema } from "../contracts/json-shape.js";
4
4
  import type { AvValidationIssue } from "../operations/validation-code.js";
5
5
  /** What core may do with a Json Shape: read its Contract form, check a value. */
6
- export type JsonShapeRuntime = {
6
+ type JsonShapeRuntime = {
7
7
  /** The shape's Contract form. */
8
8
  readonly schema: JsonSchema;
9
9
  /**
@@ -20,3 +20,4 @@ export declare function jsonShapeOf(value: unknown): JsonShapeRuntime | undefine
20
20
  export declare function bindShapedField(field: AvScalarField<AvContract>, shape: JsonShapeRuntime): void;
21
21
  /** The shape a compiled Contract field enforces, or `undefined`. */
22
22
  export declare function shapeOfField(field: AvScalarField<AvContract>): JsonShapeRuntime | undefined;
23
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { ErrorCodeDescription } from "../runtime/error-guidance.js";
2
+ import type { AvContractCompilerDiagnosticCode } from "./contract-compiler-diagnostic.js";
3
+ /** Meaning, cause and fix of every contract-compilation diagnostic code. */
4
+ export declare const CONTRACT_COMPILER_DIAGNOSTIC_GUIDANCE: {
5
+ readonly [C in AvContractCompilerDiagnosticCode]: ErrorCodeDescription;
6
+ };
@@ -0,0 +1,97 @@
1
+ export const CONTRACT_COMPILER_DIAGNOSTIC_GUIDANCE = {
2
+ COMPILER_UNKNOWN_RESOURCE: {
3
+ message: "Unknown Resource.",
4
+ cause: "A Resource name the adapter's model does not have, in resources or in exemptions; or a client or agent entry for a Resource managed elsewhere, which those layers never have.",
5
+ fix: "Use the model's exact name. After a schema change run `npm run aventara:prepare`. Configure a Resource managed elsewhere at the root or in application only.",
6
+ },
7
+ COMPILER_UNKNOWN_FIELD: {
8
+ message: "Unknown field.",
9
+ cause: "A field that is neither in the schema nor defined at the root.",
10
+ fix: "Fix the name, run aventara:prepare after a schema change, or add the field with a root definition.",
11
+ },
12
+ COMPILER_RELATION_FIELD_CONFIG_UNSUPPORTED: {
13
+ message: "A relation field takes write guards only.",
14
+ cause: "Field pipes or compute on a relation field.",
15
+ fix: "Put the stage on the relation's reference field, or use an operation pipe.",
16
+ },
17
+ COMPILER_INCOMPLETE_FIELD: {
18
+ message: "An added field is incomplete.",
19
+ cause: "A definition that adds a field leaves out type, nullable or list.",
20
+ fix: 'Spell out type, nullable and list, with lifecycle: ["VIRTUAL"] for a field that has no column.',
21
+ },
22
+ COMPILER_STRUCTURAL_FIELD_OVERRIDE: {
23
+ message: "A discovered field's structure was redefined.",
24
+ cause: "A definition on a field the adapter discovered changes its type, format or capabilities.",
25
+ fix: "Restate only its type, nullable and list. Change capabilities through exemptions and the column through the schema.",
26
+ },
27
+ COMPILER_MISSING_SCALAR: {
28
+ message: "Unknown scalar type.",
29
+ cause: "A definition names a scalar type that does not exist.",
30
+ fix: "Use a built-in scalar: string, boolean, int, float, bigint, decimal, datetime, bytes or json.",
31
+ },
32
+ COMPILER_MISSING_ENUM: {
33
+ message: "Unknown enum.",
34
+ cause: "A definition names an enum the model does not have.",
35
+ fix: "Use an enum of the schema, and run aventara:prepare after adding one.",
36
+ },
37
+ COMPILER_DANGLING_RELATION: {
38
+ message: "A visible relation points at a hidden Resource.",
39
+ cause: "A layer hides a Resource but still exposes a relation field that targets it.",
40
+ fix: "Hide the relation field too (`exemptions.resources.<R>.fields.<relation>: true`), or expose the target.",
41
+ },
42
+ COMPILER_UNAVAILABLE_OPERATION: {
43
+ message: "Operation not available.",
44
+ cause: "An operation the adapter does not offer (such as delete.many), or an overlay granting one that its parent hid.",
45
+ fix: "Remove it. To reach an operation from one overlay only, expose it at the root and hide it in the other overlay.",
46
+ },
47
+ COMPILER_UNAVAILABLE_CAPABILITY: {
48
+ message: "Capability not available.",
49
+ cause: "A capability or token the field does not offer, or an overlay (or the agent layer) granting one its parent hid. Overlays only narrow.",
50
+ fix: "Remove it, or expose it in the parent layer and hide it in the layer it must not reach.",
51
+ },
52
+ COMPILER_INVALID_LIFECYCLE: {
53
+ message: "Invalid field lifecycle.",
54
+ cause: "An added field declares a lifecycle other than VIRTUAL, a VIRTUAL field claims a database-generated lifecycle or a provider-side capability, or a definition redefines a discovered field's lifecycle.",
55
+ fix: 'Give an added field lifecycle: ["VIRTUAL"] and only the capabilities it can serve; computed lifecycles come from compute stages.',
56
+ },
57
+ COMPILER_MISSING_READ_COMPUTE: {
58
+ message: "A selectable virtual field has no compute.read.",
59
+ cause: "A VIRTUAL field that can be selected has no pipelines.compute.read stage.",
60
+ fix: "Add a compute.read stage, or make the field write-only with capabilities.select: false.",
61
+ },
62
+ COMPILER_INVALID_COMPUTE_DEPENDENCY: {
63
+ message: "Invalid compute.read dependency.",
64
+ cause: "A dependsOn entry that is not a stored scalar field of the same Resource.",
65
+ fix: "List only stored scalar fields of the Resource in dependsOn.",
66
+ },
67
+ COMPILER_RESERVED_RESOURCE_NAME: {
68
+ message: "Reserved Resource name.",
69
+ cause: "A model name starts with $, which is reserved for the framework's own names (ctx.$sql, $ref), or is the name of a member beside the Resources: all on serverClient (and so on Next.js's avClient), and on a host that adds its own, one of those (on Next.js: tx and transaction on avClient, appTx and transaction on avApp).",
70
+ fix: "Rename the model; the table it maps to can keep its name. A host member's name is also left free when the layer it belongs to hides the Resource.",
71
+ },
72
+ COMPILER_MISSING_IDENTIFIER: {
73
+ message: "A unique operation has no identifier.",
74
+ cause: "A layer exposes a unique variant (find.unique, update.unique, delete.unique, upsert.unique) and no complete identifier of the Resource: a Pick that did not pick one, or an Omit that hid every one.",
75
+ fix: "Expose an identifier field (id, or every field of one unique), or exempt the unique variants.",
76
+ },
77
+ COMPILER_HIDDEN_REQUIRED_FIELD: {
78
+ message: "A layer that creates a Resource hides a required field.",
79
+ cause: "A layer still creates the Resource (a create or upsert variant, or a nested create) while a required field, or a required relation's reference field, is hidden or has its create capability exempted, and no compute.create fills it.",
80
+ fix: "Expose the field, give it a compute.create stage, or exempt the layer's create operations.",
81
+ },
82
+ COMPILER_INVALID_VALIDATOR: {
83
+ message: "A field validator cannot apply.",
84
+ cause: "A validator that is not built with AvZ, does not fit the field's type (AvZ.maxLength on an int, AvZ.maxItems on a field that is not a list), or sits on a relation or Json field.",
85
+ fix: "Use an AvZ check that fits the field's type; a Json field's checks go in its json shape.",
86
+ },
87
+ COMPILER_INVALID_JSON_SHAPE: {
88
+ message: "A Json shape cannot apply.",
89
+ cause: "A json shape on a field that is not a discovered Json field, a shape not built with AvZ, or one that admits null or absence at its top level.",
90
+ fix: "Put the shape on a Json field, build it with AvZ, and keep its top level non-null (the column's nullability decides null).",
91
+ },
92
+ COMPILER_INVALID_CLIENT_CONTRACT: {
93
+ message: "The compiled client contract is invalid.",
94
+ cause: "The finished client contract failed its own structural check: a framework defect.",
95
+ fix: "Report it with the diagnostic's path and message.",
96
+ },
97
+ };
@@ -30,3 +30,9 @@ export type ContractCompilationResult = {
30
30
  * Agent Contract from the view of the layer it extends.
31
31
  */
32
32
  export declare function compileContracts<M extends AvAdapterModel>(model: M, config: ResolvedFrameworkConfig<M>): Promise<ContractCompilationResult>;
33
+ /**
34
+ * Binds Contracts loaded from a prebuilt file to the runtime pieces
35
+ * {@link compileContracts} binds to the ones it compiles, from the live
36
+ * `config` and `model` they were compiled from.
37
+ */
38
+ export declare function bindPrebuiltContracts<M extends AvAdapterModel>(model: M, config: ResolvedFrameworkConfig<M>, contracts: AvContracts): void;