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

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 (338) hide show
  1. package/CHANGELOG.md +2068 -1
  2. package/ERRORS.md +142 -0
  3. package/README.md +485 -60
  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 +33 -11
  8. package/dist/adapters/adapter-identifier.d.ts +15 -6
  9. package/dist/adapters/adapter-identifier.js +6 -1
  10. package/dist/adapters/adapter-model.d.ts +18 -9
  11. package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
  12. package/dist/adapters/adapter-operation.d.ts +21 -6
  13. package/dist/adapters/adapter-resource.d.ts +23 -9
  14. package/dist/adapters/adapter-sql-statement.d.ts +19 -0
  15. package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
  16. package/dist/adapters/adapter.interface.d.ts +59 -29
  17. package/dist/avz/avz-check.factory.d.ts +83 -0
  18. package/dist/avz/avz-check.factory.js +116 -0
  19. package/dist/avz/avz-check.registry.d.ts +35 -0
  20. package/dist/avz/avz-check.registry.js +9 -0
  21. package/dist/avz/avz.d.ts +203 -0
  22. package/dist/{json → avz}/avz.js +150 -8
  23. package/dist/{json → avz}/index.d.ts +2 -1
  24. package/dist/{json → avz}/json-shape.registry.d.ts +9 -8
  25. package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
  26. package/dist/{json → avz}/zod-issue.translator.js +7 -0
  27. package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
  28. package/dist/compiler/contract-compiler-diagnostic.guidance.d.ts +6 -0
  29. package/dist/compiler/contract-compiler-diagnostic.guidance.js +97 -0
  30. package/dist/compiler/contract.compiler.d.ts +23 -17
  31. package/dist/compiler/contract.compiler.js +753 -443
  32. package/dist/compiler/create-requirements.projector.d.ts +49 -0
  33. package/dist/compiler/create-requirements.projector.js +423 -0
  34. package/dist/compiler/field-validator.compiler.d.ts +47 -0
  35. package/dist/compiler/field-validator.compiler.js +238 -0
  36. package/dist/compiler/managed-elsewhere.projector.d.ts +52 -0
  37. package/dist/compiler/managed-elsewhere.projector.js +179 -0
  38. package/dist/compiler/managed-elsewhere.validator.d.ts +9 -0
  39. package/dist/compiler/managed-elsewhere.validator.js +74 -0
  40. package/dist/config/any-framework-config.d.ts +19 -12
  41. package/dist/config/computed-fields.d.ts +62 -0
  42. package/dist/config/computed-fields.js +73 -0
  43. package/dist/config/config-diagnostic.d.ts +11 -4
  44. package/dist/config/config-diagnostic.guidance.d.ts +6 -0
  45. package/dist/config/config-diagnostic.guidance.js +32 -0
  46. package/dist/config/config-layer.d.ts +15 -6
  47. package/dist/config/config.resolver.d.ts +98 -31
  48. package/dist/config/config.resolver.js +173 -44
  49. package/dist/config/config.validator.d.ts +7 -7
  50. package/dist/config/config.validator.js +792 -69
  51. package/dist/config/define-resource.d.ts +53 -0
  52. package/dist/config/define-resource.js +14 -0
  53. package/dist/config/effective-fields.d.ts +19 -23
  54. package/dist/config/entrypoint.normalizer.d.ts +4 -3
  55. package/dist/config/exact-framework-config.d.ts +325 -0
  56. package/dist/config/field-compute.resolver.d.ts +21 -0
  57. package/dist/config/field-compute.resolver.js +123 -0
  58. package/dist/config/field-pipeline-config.d.ts +47 -0
  59. package/dist/config/forced-operation.validator.d.ts +10 -0
  60. package/dist/config/forced-operation.validator.js +66 -0
  61. package/dist/config/framework-config.d.ts +148 -39
  62. package/dist/config/framework-exemptions-config.d.ts +91 -0
  63. package/dist/config/framework-exemptions-config.js +1 -0
  64. package/dist/config/framework-field-definition.d.ts +78 -0
  65. package/dist/config/framework-field-definition.js +28 -0
  66. package/dist/config/framework-resources-config.d.ts +127 -0
  67. package/dist/config/framework-resources-config.js +1 -0
  68. package/dist/config/pipeline-config.d.ts +56 -20
  69. package/dist/config/pipeline-tree.resolver.d.ts +79 -0
  70. package/dist/config/pipeline-tree.resolver.js +220 -0
  71. package/dist/config/stage-type.eraser.d.ts +65 -0
  72. package/dist/config/stage-type.eraser.js +1 -0
  73. package/dist/contracts/access-route.rules.d.ts +10 -0
  74. package/dist/contracts/access-route.rules.js +45 -0
  75. package/dist/contracts/capability.d.ts +37 -12
  76. package/dist/contracts/capability.js +20 -0
  77. package/dist/contracts/client-contract-structure.validator.d.ts +621 -114
  78. package/dist/contracts/client-contract-structure.validator.js +189 -10
  79. package/dist/contracts/contract-access.d.ts +29 -0
  80. package/dist/contracts/contract-access.js +1 -0
  81. package/dist/contracts/contract-canonicalizer.d.ts +27 -3
  82. package/dist/contracts/contract-canonicalizer.js +168 -29
  83. package/dist/contracts/contract-hash.d.ts +11 -7
  84. package/dist/contracts/contract-hash.js +4 -3
  85. package/dist/contracts/contract-limits.d.ts +4 -1
  86. package/dist/contracts/contract-limits.js +1 -0
  87. package/dist/contracts/contract-lookup.d.ts +5 -5
  88. package/dist/contracts/contract-protocol.d.ts +4 -4
  89. package/dist/contracts/contract.d.ts +51 -17
  90. package/dist/contracts/create-requirements.d.ts +35 -0
  91. package/dist/contracts/create-requirements.js +1 -0
  92. package/dist/contracts/enum-definition.d.ts +1 -1
  93. package/dist/contracts/field-check.d.ts +101 -0
  94. package/dist/contracts/field-check.js +1 -0
  95. package/dist/contracts/field.d.ts +109 -42
  96. package/dist/contracts/identifier.d.ts +4 -4
  97. package/dist/contracts/json-schema.projector.d.ts +11 -0
  98. package/dist/contracts/json-schema.projector.js +78 -0
  99. package/dist/contracts/json-shape.d.ts +12 -1
  100. package/dist/contracts/lifecycle-trait.d.ts +2 -2
  101. package/dist/contracts/resource-operations.d.ts +28 -28
  102. package/dist/contracts/resource.d.ts +15 -9
  103. package/dist/contracts/scalar-value-type.d.ts +17 -15
  104. package/dist/contracts/scalar.d.ts +3 -3
  105. package/dist/contracts/transaction-capability.d.ts +1 -1
  106. package/dist/contracts/wire-scalar-format.d.ts +4 -4
  107. package/dist/framework/access-facade.d.ts +116 -0
  108. package/dist/framework/access-facade.js +120 -0
  109. package/dist/framework/contract-view.d.ts +315 -145
  110. package/dist/framework/framework-construction.error.d.ts +21 -11
  111. package/dist/framework/framework-construction.error.js +20 -4
  112. package/dist/framework/framework.d.ts +71 -26
  113. package/dist/framework/framework.factory.d.ts +8 -6
  114. package/dist/framework/framework.factory.js +150 -38
  115. package/dist/framework/operation-facade.d.ts +192 -54
  116. package/dist/framework/operation-facade.js +10 -1
  117. package/dist/index.d.ts +67 -50
  118. package/dist/index.js +7 -6
  119. package/dist/internal.d.ts +20 -10
  120. package/dist/internal.js +9 -1
  121. package/dist/operations/database-refusal.d.ts +51 -0
  122. package/dist/operations/database-refusal.js +45 -0
  123. package/dist/operations/operation-arguments.d.ts +381 -228
  124. package/dist/operations/operation-call.d.ts +31 -28
  125. package/dist/operations/operation-identity.d.ts +10 -10
  126. package/dist/operations/operation-result.d.ts +25 -23
  127. package/dist/operations/operation-validator-core.d.ts +6 -6
  128. package/dist/operations/operation-validator-core.js +172 -38
  129. package/dist/operations/operation-validator.d.ts +10 -10
  130. package/dist/operations/projection-scope.resolver.d.ts +6 -6
  131. package/dist/operations/structural-limits.walker.d.ts +7 -7
  132. package/dist/operations/structural-limits.walker.js +145 -0
  133. package/dist/operations/validation-code.d.ts +11 -6
  134. package/dist/operations/validation-code.guidance.d.ts +6 -0
  135. package/dist/operations/validation-code.guidance.js +90 -0
  136. package/dist/operations/validation-code.js +4 -0
  137. package/dist/operations/write-scope.resolver.d.ts +10 -6
  138. package/dist/operations/write-scope.resolver.js +2 -0
  139. package/dist/policy/access-provider.interface.d.ts +91 -0
  140. package/dist/policy/access-provider.interface.js +1 -0
  141. package/dist/policy/access-provider.registry.d.ts +17 -0
  142. package/dist/policy/access-provider.registry.js +15 -0
  143. package/dist/policy/access-question.d.ts +20 -0
  144. package/dist/policy/access-question.js +1 -0
  145. package/dist/policy/access-question.registry.d.ts +5 -0
  146. package/dist/policy/access-question.registry.js +19 -0
  147. package/dist/policy/access-question.runtime.d.ts +36 -0
  148. package/dist/policy/access-question.runtime.js +297 -0
  149. package/dist/policy/access-verb.table.d.ts +56 -0
  150. package/dist/policy/access-verb.table.js +21 -0
  151. package/dist/policy/access-verbs.d.ts +46 -0
  152. package/dist/policy/access-verbs.js +1 -0
  153. package/dist/policy/policy-admission.d.ts +20 -0
  154. package/dist/policy/policy-admission.js +409 -0
  155. package/dist/policy/policy-after-update.runtime.d.ts +79 -0
  156. package/dist/policy/policy-after-update.runtime.js +208 -0
  157. package/dist/policy/policy-condition.d.ts +15 -0
  158. package/dist/policy/policy-condition.js +36 -0
  159. package/dist/policy/policy-engine.d.ts +205 -0
  160. package/dist/policy/policy-engine.js +1 -0
  161. package/dist/policy/policy-named-rows.d.ts +18 -0
  162. package/dist/policy/policy-named-rows.js +51 -0
  163. package/dist/policy/policy-nested-write.runtime.d.ts +44 -0
  164. package/dist/policy/policy-nested-write.runtime.js +545 -0
  165. package/dist/policy/policy-read.runtime.d.ts +81 -0
  166. package/dist/policy/policy-read.runtime.js +503 -0
  167. package/dist/policy/policy-reference-write.runtime.d.ts +51 -0
  168. package/dist/policy/policy-reference-write.runtime.js +345 -0
  169. package/dist/policy/policy-request.d.ts +41 -0
  170. package/dist/policy/policy-request.js +63 -0
  171. package/dist/policy/policy-session.d.ts +106 -0
  172. package/dist/policy/policy-session.js +295 -0
  173. package/dist/policy/policy-startup.validator.d.ts +10 -0
  174. package/dist/policy/policy-startup.validator.js +112 -0
  175. package/dist/policy/policy-write.runtime.d.ts +39 -0
  176. package/dist/policy/policy-write.runtime.js +532 -0
  177. package/dist/prebuilt/core-version.generated.d.ts +2 -0
  178. package/dist/prebuilt/core-version.generated.js +1 -0
  179. package/dist/prebuilt/prebuilt-changes.d.ts +29 -0
  180. package/dist/prebuilt/prebuilt-changes.js +65 -0
  181. package/dist/prebuilt/prebuilt-contracts.d.ts +40 -0
  182. package/dist/prebuilt/prebuilt-contracts.emitter.d.ts +16 -0
  183. package/dist/prebuilt/prebuilt-contracts.emitter.js +50 -0
  184. package/dist/prebuilt/prebuilt-contracts.js +1 -0
  185. package/dist/prebuilt/prebuilt-contracts.loader.d.ts +19 -0
  186. package/dist/prebuilt/prebuilt-contracts.loader.js +77 -0
  187. package/dist/prebuilt/prebuilt-inputs.fingerprint.d.ts +16 -0
  188. package/dist/prebuilt/prebuilt-inputs.fingerprint.js +229 -0
  189. package/dist/protocol/absent-route.responder.d.ts +17 -34
  190. package/dist/protocol/absent-route.responder.js +53 -20
  191. package/dist/protocol/contract-document.responder.d.ts +5 -4
  192. package/dist/protocol/contract-document.responder.js +2 -2
  193. package/dist/protocol/http-request.decoder.d.ts +33 -13
  194. package/dist/protocol/http-request.decoder.js +34 -11
  195. package/dist/protocol/http-request.reader.d.ts +9 -6
  196. package/dist/protocol/http-request.reader.js +1 -0
  197. package/dist/protocol/http-response.encoder.d.ts +4 -4
  198. package/dist/protocol/http-response.encoder.js +94 -55
  199. package/dist/protocol/http-status.table.d.ts +2 -2
  200. package/dist/protocol/operation-response.guard.d.ts +2 -2
  201. package/dist/protocol/protocol-headers.d.ts +3 -3
  202. package/dist/protocol/protocol-surface.d.ts +10 -5
  203. package/dist/protocol/protocol-surface.js +7 -0
  204. package/dist/protocol/protocol.binder.d.ts +66 -28
  205. package/dist/protocol/protocol.binder.js +16 -10
  206. package/dist/protocol/protocol.handler.d.ts +34 -14
  207. package/dist/protocol/protocol.handler.js +122 -18
  208. package/dist/protocol/unmounted-route.error.d.ts +4 -4
  209. package/dist/protocol/unmounted-route.error.js +2 -2
  210. package/dist/runtime/caller-data.copier.d.ts +22 -7
  211. package/dist/runtime/caller-data.copier.js +30 -17
  212. package/dist/runtime/caller-data.door.d.ts +18 -11
  213. package/dist/runtime/caller-data.door.js +6 -4
  214. package/dist/runtime/computed-read-runtime.d.ts +12 -6
  215. package/dist/runtime/computed-read-runtime.js +271 -71
  216. package/dist/runtime/computed-value.error.d.ts +7 -6
  217. package/dist/runtime/computed-value.error.js +5 -4
  218. package/dist/runtime/context-executor.runtime.d.ts +60 -0
  219. package/dist/runtime/context-executor.runtime.js +277 -0
  220. package/dist/runtime/core-class.brand.d.ts +10 -0
  221. package/dist/runtime/core-class.brand.js +21 -0
  222. package/dist/runtime/create-requirement.d.ts +34 -79
  223. package/dist/runtime/create-requirement.js +205 -74
  224. package/dist/runtime/decimal.d.ts +16 -2
  225. package/dist/runtime/decimal.js +22 -1
  226. package/dist/runtime/diagnostics-reporter.d.ts +91 -30
  227. package/dist/runtime/diagnostics-reporter.js +37 -1
  228. package/dist/runtime/error-boundary.d.ts +73 -9
  229. package/dist/runtime/error-boundary.js +57 -19
  230. package/dist/runtime/error-guidance.d.ts +12 -0
  231. package/dist/runtime/error-guidance.js +1 -0
  232. package/dist/runtime/error.catalog.d.ts +49 -0
  233. package/dist/runtime/error.catalog.js +49 -0
  234. package/dist/runtime/execution-options.d.ts +18 -2
  235. package/dist/runtime/field-check.evaluator.d.ts +27 -0
  236. package/dist/runtime/field-check.evaluator.js +521 -0
  237. package/dist/runtime/field-compute.d.ts +65 -0
  238. package/dist/runtime/field-compute.js +1 -0
  239. package/dist/runtime/field-stage.plan.d.ts +15 -0
  240. package/dist/runtime/field-stage.plan.js +27 -0
  241. package/dist/runtime/field-stage.runtime.d.ts +37 -0
  242. package/dist/runtime/field-stage.runtime.js +147 -0
  243. package/dist/runtime/field-validator.runtime.d.ts +29 -0
  244. package/dist/runtime/field-validator.runtime.js +126 -0
  245. package/dist/runtime/framework-error-class.table.d.ts +33 -0
  246. package/dist/runtime/framework-error-class.table.js +25 -0
  247. package/dist/runtime/framework-error.d.ts +68 -8
  248. package/dist/runtime/framework-error.factory.d.ts +4 -0
  249. package/dist/runtime/framework-error.factory.js +15 -0
  250. package/dist/runtime/framework-error.js +32 -2
  251. package/dist/runtime/framework-warning.emitter.d.ts +6 -0
  252. package/dist/runtime/framework-warning.emitter.js +8 -0
  253. package/dist/runtime/interceptor-next.error.d.ts +5 -0
  254. package/dist/runtime/interceptor-next.error.js +6 -0
  255. package/dist/runtime/json-value.d.ts +11 -6
  256. package/dist/runtime/level-lifecycle.runtime.d.ts +26 -0
  257. package/dist/runtime/level-lifecycle.runtime.js +40 -0
  258. package/dist/runtime/misuse-reporter.d.ts +12 -12
  259. package/dist/runtime/mutation-planner.d.ts +20 -16
  260. package/dist/runtime/mutation-planner.js +48 -35
  261. package/dist/runtime/nested-write.walker.d.ts +32 -0
  262. package/dist/runtime/nested-write.walker.js +73 -0
  263. package/dist/runtime/operation-code.guidance.d.ts +6 -0
  264. package/dist/runtime/operation-code.guidance.js +167 -0
  265. package/dist/runtime/operation-request.d.ts +45 -11
  266. package/dist/runtime/operation-response.d.ts +17 -17
  267. package/dist/runtime/operation-runtime.d.ts +133 -27
  268. package/dist/runtime/operation-runtime.js +576 -84
  269. package/dist/runtime/outcome-mapper.d.ts +17 -5
  270. package/dist/runtime/outcome-mapper.js +23 -6
  271. package/dist/runtime/output-validator.d.ts +11 -11
  272. package/dist/runtime/output-validator.js +3 -3
  273. package/dist/runtime/owned-execution.registry.d.ts +16 -6
  274. package/dist/runtime/pipe-output.validator.d.ts +43 -18
  275. package/dist/runtime/pipe-output.validator.js +15 -13
  276. package/dist/runtime/pipeline.d.ts +221 -34
  277. package/dist/runtime/readonly-value.d.ts +47 -0
  278. package/dist/runtime/readonly-value.js +189 -0
  279. package/dist/runtime/referential-action.d.ts +1 -1
  280. package/dist/runtime/request-envelope.validator.d.ts +3 -3
  281. package/dist/runtime/request-envelope.validator.js +12 -7
  282. package/dist/runtime/request-id.d.ts +1 -1
  283. package/dist/runtime/request-state.d.ts +14 -0
  284. package/dist/runtime/request-state.js +1 -0
  285. package/dist/runtime/request-state.resolver.d.ts +12 -0
  286. package/dist/runtime/request-state.resolver.js +20 -0
  287. package/dist/runtime/scalar-runtime.d.ts +33 -25
  288. package/dist/runtime/scalar-runtime.js +105 -38
  289. package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
  290. package/dist/runtime/unsent-value.normalizer.js +128 -0
  291. package/dist/transactions/deferred-operation.d.ts +35 -20
  292. package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
  293. package/dist/transactions/operation-arguments-encoder.js +8 -3
  294. package/dist/transactions/operation-fingerprint.js +2 -2
  295. package/dist/transactions/sql-statement.d.ts +85 -0
  296. package/dist/transactions/sql-statement.js +47 -0
  297. package/dist/transactions/sql-statement.validator.d.ts +44 -0
  298. package/dist/transactions/sql-statement.validator.js +167 -0
  299. package/dist/transactions/transaction-envelope.d.ts +9 -8
  300. package/dist/transactions/transaction-integrity-error.d.ts +6 -6
  301. package/dist/transactions/transaction-integrity-error.js +7 -2
  302. package/dist/transactions/transaction-plan-assembler.d.ts +30 -13
  303. package/dist/transactions/transaction-plan-assembler.js +184 -32
  304. package/dist/transactions/transaction-plan-validator.d.ts +50 -25
  305. package/dist/transactions/transaction-plan-validator.js +96 -38
  306. package/dist/transactions/transaction-reference-collector.d.ts +5 -5
  307. package/dist/transactions/transaction-reference-resolver.d.ts +21 -3
  308. package/dist/transactions/transaction-reference-resolver.js +26 -14
  309. package/dist/transactions/transaction-reference-validator.d.ts +74 -4
  310. package/dist/transactions/transaction-reference-validator.js +129 -71
  311. package/dist/transactions/transaction-reference.d.ts +14 -14
  312. package/dist/transactions/transaction-reference.js +5 -0
  313. package/dist/transactions/transaction-request.d.ts +22 -9
  314. package/dist/transactions/transaction-response.d.ts +6 -6
  315. package/dist/transactions/transaction-runtime.d.ts +12 -8
  316. package/dist/transactions/transaction-runtime.js +218 -50
  317. package/dist/transactions/transaction-settlement.runtime.d.ts +52 -0
  318. package/dist/transactions/transaction-settlement.runtime.js +120 -0
  319. package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
  320. package/dist/transactions/transaction-slot-path-error.js +4 -2
  321. package/dist/transactions/transaction-slot-writer.js +2 -2
  322. package/dist/transactions/transaction-stage.runtime.d.ts +83 -0
  323. package/dist/transactions/transaction-stage.runtime.js +126 -0
  324. package/package.json +11 -9
  325. package/src/runtime/field-check.evaluator.ts +720 -0
  326. package/dist/config/define-fields.d.ts +0 -42
  327. package/dist/config/define-fields.js +0 -3
  328. package/dist/config/framework-behaviors-config.d.ts +0 -30
  329. package/dist/config/framework-fields-config.d.ts +0 -42
  330. package/dist/config/framework-restrictions-config.d.ts +0 -142
  331. package/dist/json/avz.d.ts +0 -96
  332. package/dist/runtime/field-behavior.d.ts +0 -48
  333. /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
  334. /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
  335. /package/dist/{json → avz}/index.js +0 -0
  336. /package/dist/{json → avz}/json-shape.registry.js +0 -0
  337. /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
  338. /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
@@ -0,0 +1,47 @@
1
+ import type { AvAdapterModel } from "../adapters/adapter-model.js";
2
+ import type { AvZCheck } from "../avz/avz-check.registry.js";
3
+ import type { AvComputeCreate, AvComputeRead, AvComputeUpdate } from "../runtime/field-compute.js";
4
+ import type { AvFieldGuard, AvFieldPipe } from "../runtime/pipeline.js";
5
+ import type { AvConfigAny } from "./any-framework-config.js";
6
+ import type { AvConfigResourceKey } from "./framework-field-definition.js";
7
+ export type { AvZCheck } from "../avz/avz-check.registry.js";
8
+ /**
9
+ * A scalar field's computed values, one stage per phase: `create` and `update`
10
+ * run before the write, `read` on each returned record.
11
+ */
12
+ export type AvFieldCompute<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = {
13
+ /** Computes the value on every create; an upsert's create branch included. */
14
+ readonly create?: AvComputeCreate<M>;
15
+ /** Computes the value on every read of a returned record. */
16
+ readonly read?: AvComputeRead<M, Cfg, R>;
17
+ /** Computes the value on every update; an upsert's update branch included. */
18
+ readonly update?: AvComputeUpdate<M>;
19
+ };
20
+ /**
21
+ * A scalar field's stages: validators, field pipes, compute and write guards.
22
+ * `Check` is the checks the field takes (any, when the field's type is not
23
+ * known here).
24
+ */
25
+ export type AvScalarFieldPipeline<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>, Check extends AvZCheck = AvZCheck> = {
26
+ /**
27
+ * Declarative checks on the value, built with `AvZ` and carried in the Contract;
28
+ * root's, then the overlay's. On a list field `AvZ.minItems` and `AvZ.maxItems`
29
+ * check the list and every other check each entry.
30
+ */
31
+ readonly validators?: readonly Check[];
32
+ /**
33
+ * Pure transforms of the sent value: value in, value out, no context. They run
34
+ * after the operation's pipes and before the validators; in a transaction, on
35
+ * literal values before it opens and on a `$ref` value at its step.
36
+ */
37
+ readonly pipes?: readonly AvFieldPipe[];
38
+ /** The field's computed values. */
39
+ readonly compute?: AvFieldCompute<M, Cfg, R>;
40
+ /** Write-only admission: run when the caller sends the field. */
41
+ readonly guards?: readonly AvFieldGuard<NoInfer<M>, R>[];
42
+ };
43
+ /** A relation field's stages: write guards only. */
44
+ export type AvRelationFieldPipeline<M extends AvAdapterModel = AvAdapterModel, R extends string = AvConfigResourceKey<M>> = {
45
+ /** Write-only admission: run for every write through the relation. */
46
+ readonly guards?: readonly AvFieldGuard<NoInfer<M>, R>[];
47
+ };
@@ -0,0 +1,10 @@
1
+ import type { AvContracts } from "../compiler/contract.compiler.js";
2
+ import type { AvConfigDiagnostic } from "./config-diagnostic.js";
3
+ type LayerRecord = Readonly<Record<string, unknown>>;
4
+ /**
5
+ * The `forceTransaction` settings a forced call could not honour: one
6
+ * `CONFIG_INVALID_VALUE` per configuration path, naming every origin whose
7
+ * Contract offers the operation without transactions.
8
+ */
9
+ export declare function validateForcedOperations(config: LayerRecord, contracts: AvContracts): readonly AvConfigDiagnostic[];
10
+ export {};
@@ -0,0 +1,66 @@
1
+ import { isOperationVariantAvailable } from "../contracts/resource-operations.js";
2
+ import { forcedOperationsOf } from "./pipeline-tree.resolver.js";
3
+ function reachable(contract, resource, family, variant) {
4
+ if (!Object.hasOwn(contract.resources, resource)) {
5
+ return false;
6
+ }
7
+ const operations = contract.resources[resource]?.operations;
8
+ const variants = operations !== undefined && Object.hasOwn(operations, family)
9
+ ? operations[family]
10
+ : undefined;
11
+ if (variants === undefined) {
12
+ return false;
13
+ }
14
+ return variant === undefined
15
+ ? Object.values(variants).some((availability) => isOperationVariantAvailable(availability))
16
+ : Object.hasOwn(variants, variant) &&
17
+ isOperationVariantAvailable(variants[variant]);
18
+ }
19
+ function layerRecord(value) {
20
+ return value !== null && typeof value === "object"
21
+ ? value
22
+ : undefined;
23
+ }
24
+ function layersOf(config, origin) {
25
+ const layers = [];
26
+ const push = (name) => {
27
+ const record = layerRecord(config[name]);
28
+ if (record !== undefined) {
29
+ layers.push({ name, record });
30
+ }
31
+ };
32
+ if (origin === "agent") {
33
+ const parent = layerRecord(config.agent)?.extends ?? "client";
34
+ if (parent === "application" || parent === "client") {
35
+ push(parent);
36
+ }
37
+ }
38
+ push(origin);
39
+ return layers;
40
+ }
41
+ export function validateForcedOperations(config, contracts) {
42
+ const refused = new Map();
43
+ const origins = config.agent !== undefined || config.mcp !== undefined
44
+ ? ["application", "client", "agent"]
45
+ : ["application", "client"];
46
+ for (const origin of origins) {
47
+ const contract = contracts[origin];
48
+ if (contract.transactions !== "none") {
49
+ continue;
50
+ }
51
+ const forced = [
52
+ ...forcedOperationsOf(config, ""),
53
+ ...layersOf(config, origin).flatMap((layer) => forcedOperationsOf(layer.record, `${layer.name}.`)),
54
+ ];
55
+ for (const { path, resource, family, variant } of forced) {
56
+ if (reachable(contract, resource, family, variant)) {
57
+ refused.set(path, [...(refused.get(path) ?? []), origin]);
58
+ }
59
+ }
60
+ }
61
+ return [...refused].map(([path, layers]) => ({
62
+ code: "CONFIG_INVALID_VALUE",
63
+ path,
64
+ message: `${path}: forceTransaction runs a plain call as a one-step transaction, and the effective transactionsStyle of the ${layers.join(" and ")} ${layers.length === 1 ? "layer is" : "layers are"} "none"; set transactionsStyle: "interactive" there (the adapter must offer interactive transactions) or remove forceTransaction`,
65
+ }));
66
+ }
@@ -1,52 +1,161 @@
1
- import type { Adapter } from "../adapters/adapter.interface.js";
2
- import type { AdapterModel } from "../adapters/adapter-model.js";
3
- import type { ContractLimits } from "../contracts/contract-limits.js";
4
- import type { TransactionCapability } from "../contracts/transaction-capability.js";
5
- import type { FrameworkDiagnosticsSink } from "../runtime/diagnostics-reporter.js";
6
- import type { FrameworkMisuseSink } from "../runtime/misuse-reporter.js";
7
- import type { AnyFrameworkConfig } from "./any-framework-config.js";
8
- import type { FrameworkBehaviorsConfig } from "./framework-behaviors-config.js";
9
- import type { FrameworkFieldsConfig } from "./framework-fields-config.js";
10
- import type { FrameworkRestrictionsConfig } from "./framework-restrictions-config.js";
11
- import type { PipelineConfig } from "./pipeline-config.js";
1
+ import type { AvAdapter } from "../adapters/adapter.interface.js";
2
+ import type { AvAdapterModel } from "../adapters/adapter-model.js";
3
+ import type { AvContractLimits } from "../contracts/contract-limits.js";
4
+ import type { AvTransactionCapability } from "../contracts/transaction-capability.js";
5
+ import type { AvAccessProvider } from "../policy/access-provider.interface.js";
6
+ import type { AvPolicyEngine } from "../policy/policy-engine.js";
7
+ import type { AvPrebuiltContracts } from "../prebuilt/prebuilt-contracts.js";
8
+ import type { AvDiagnosticsSink } from "../runtime/diagnostics-reporter.js";
9
+ import type { AvMisuseSink } from "../runtime/misuse-reporter.js";
10
+ import type { AvState } from "../runtime/request-state.js";
11
+ import type { AvConfigAny } from "./any-framework-config.js";
12
+ import type { AvConfigLayerName, AvRequestOrigin } from "./config-layer.js";
13
+ import type { AvConfigExemptions } from "./framework-exemptions-config.js";
14
+ import type { AvConfigLayerKind, AvConfigResources, LayerOfKind } from "./framework-resources-config.js";
15
+ import type { AvPipeline } from "./pipeline-config.js";
12
16
  /**
13
17
  * Request limits to override; each one left out takes its default from
14
18
  * {@link DEFAULT_CONTRACT_LIMITS}.
15
19
  */
16
- export type FrameworkLimitsConfig = Partial<ContractLimits>;
20
+ export type AvConfigLimits = Partial<AvContractLimits>;
17
21
  /**
18
- * Settings available at the root and in the `application` and `client`
19
- * overlays. A setting in an overlay replaces the root's for that origin;
20
- * pipelines are added to the root's instead.
22
+ * The six keys every layer holds: the root, `application`, `client` and
23
+ * `agent`. Stages are added to the root's; `transactionsStyle` and `limits`
24
+ * replace it where an overlay states them; exposure only narrows.
21
25
  */
22
- export type FrameworkScopeConfig<M extends AdapterModel = AdapterModel, Cfg = AnyFrameworkConfig> = {
23
- /** Fields to add to Resources, or details to set on discovered fields. */
24
- readonly fields?: FrameworkFieldsConfig<M>;
25
- /** Computed values and read behaviors, per Resource and field. */
26
- readonly behaviors?: FrameworkBehaviorsConfig<M, Cfg>;
27
- /** What to hide or narrow: Resources, fields, capabilities and operations. */
28
- readonly restrictions?: FrameworkRestrictionsConfig<M, Cfg>;
29
- /** Request limits; see {@link FrameworkLimitsConfig}. */
30
- readonly limits?: FrameworkLimitsConfig;
31
- /** Guards, pipes, hooks, interceptors and filters run around each operation. */
32
- readonly pipelines?: PipelineConfig<NoInfer<M>>;
26
+ export type AvConfigLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, Kind extends AvConfigLayerKind = "root", Layer extends AvConfigLayerName = LayerOfKind<Kind>> = {
27
+ /** Moved: `exposed` + `exemptions`. */
28
+ readonly restrictions?: never;
29
+ /** Moved: `resources.<R>.fields.<f>.pipelines.compute`. */
30
+ readonly behaviors?: never;
31
+ /** Moved: `resources.<R>.fields.<f>.definition`. */
32
+ readonly fields?: never;
33
+ /** Moved: `transactionsStyle`. */
34
+ readonly transactions?: never;
35
+ /**
36
+ * Whether the layer's `exemptions` hide (`true`, the root's default) or are
37
+ * the only entries exposed (`false`). Each layer narrows its parent: the root
38
+ * the adapter's model, an overlay the root's view.
39
+ */
40
+ readonly exposed?: boolean;
33
41
  /** `"none"` turns transactions off; `"interactive"` needs adapter support. */
34
- readonly transactions?: TransactionCapability;
42
+ readonly transactionsStyle?: AvTransactionCapability;
43
+ /** Request limits; see {@link AvConfigLimits}. */
44
+ readonly limits?: AvConfigLimits;
45
+ /** Guards, pipes, hooks, interceptors and filters run around every operation of the layer. */
46
+ readonly pipelines?: AvPipeline<NoInfer<M>>;
47
+ /** The per-Resource tree: stages, operations, transactions and fields. */
48
+ readonly resources?: AvConfigResources<M, Cfg, Kind, Layer>;
49
+ /**
50
+ * The entries that are the opposite of `exposed`. An overlay that sets them
51
+ * states its own `exposed`.
52
+ */
53
+ readonly exemptions?: AvConfigExemptions<M, Cfg>;
35
54
  };
36
55
  /**
37
56
  * The configuration passed to `createFramework`: the adapter, the mount path,
38
- * root settings, and optional `application` and `client` overlays.
57
+ * the root layer, optional `application` and `client` overlays, the optional
58
+ * `agent` layer, and `mcp`.
39
59
  */
40
- export type FrameworkConfig<M extends AdapterModel = AdapterModel, Cfg = AnyFrameworkConfig> = FrameworkScopeConfig<M, Cfg> & {
41
- readonly entrypoint: string;
42
- readonly adapter: Adapter<M>;
43
- readonly diagnostics?: FrameworkDiagnosticsSink;
60
+ export type AvConfig<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = AvConfigLayer<M, Cfg, "root"> & {
61
+ /**
62
+ * Where the protocol's HTTP routes are mounted: `/api` serves
63
+ * `/api/_resources/…`, `/api/_contract` and `/api/_transactions`.
64
+ */
65
+ readonly api: string;
66
+ /** Moved in rc.1: the mount path is `api`. */
67
+ readonly entrypoint?: never;
68
+ /**
69
+ * Turns MCP on: the path the MCP endpoint is mounted at, or the path with the
70
+ * OAuth authorization its callers must present. Its tools are built from the
71
+ * Agent Contract.
72
+ */
73
+ readonly mcp?: AvConfigMcp;
74
+ readonly adapter: AvAdapter<M>;
75
+ /**
76
+ * Contracts compiled ahead of time (the generated `aventaraContracts`), for a
77
+ * fast cold start on serverless and edge platforms. Used only when they were
78
+ * compiled from this configuration and the adapter's model by this core;
79
+ * otherwise the Contracts are compiled at startup, as without it, and a
80
+ * `AVENTARA_PREBUILT_STALE` warning says why.
81
+ */
82
+ readonly prebuilt?: AvPrebuiltContracts;
83
+ /**
84
+ * The policy engine every client and agent request is checked against, and
85
+ * how a request's principal is derived from its `ctx.$state`. Application
86
+ * calls bypass it unless they name a principal (`{ as }`); calls a stage
87
+ * makes through `ctx` always do.
88
+ */
89
+ readonly policy?: {
90
+ readonly engine: AvPolicyEngine;
91
+ /**
92
+ * The request's principal, from its `ctx.$state` and its layer; `null` for
93
+ * an anonymous caller. It may answer with a promise (rc.5), which is
94
+ * awaited; a throw or a rejection answers `A3000`.
95
+ */
96
+ readonly principal: (facts: {
97
+ readonly $state: AvState;
98
+ readonly $origin: AvRequestOrigin;
99
+ }) => unknown;
100
+ };
101
+ /**
102
+ * The access provider (Aventara Access, or one written by hand): its
103
+ * `policy` engine checks every client and agent request, with
104
+ * `ctx.$state.me` as the principal, and the host seeds each request's
105
+ * `ctx.$state` with its `state`. Not together with `policy`, nor with a
106
+ * host's own `state` option.
107
+ */
108
+ readonly access?: AvAccessProvider;
109
+ readonly diagnostics?: AvDiagnosticsSink;
44
110
  /** Told about every caller value refused as unreadable or not plain data. */
45
- readonly misuse?: FrameworkMisuseSink;
46
- readonly application?: FrameworkScopeConfig<M, Cfg>;
47
- readonly client?: FrameworkScopeConfig<M, Cfg>;
111
+ readonly misuse?: AvMisuseSink;
112
+ readonly application?: AvConfigLayer<M, Cfg, "overlay", "application">;
113
+ readonly client?: AvConfigLayer<M, Cfg, "overlay", "client">;
114
+ /**
115
+ * The layer an AI agent's calls run under. It narrows the view of the layer it
116
+ * `extends` (the client's when left out), and its stages run after that
117
+ * layer's. Left out, the agent layer is that view exactly.
118
+ */
119
+ readonly agent?: AvConfigAgentLayer<M, Cfg>;
48
120
  };
49
- export type { AnyFieldsBlock, AnyFrameworkConfig, AnyScopeConfig, } from "./any-framework-config.js";
50
- export type { FrameworkBehaviorsConfig } from "./framework-behaviors-config.js";
51
- export type { FrameworkFieldLifecycleTrait, FrameworkFieldsConfig, FrameworkResourceFieldsConfig, FrameworkResourceKey, FrameworkScalarFieldConfig, FrameworkScalarTypeRef, } from "./framework-fields-config.js";
52
- export type { FrameworkCapabilitySetRestriction, FrameworkFieldRestrictions, FrameworkProjectionScopeRestriction, FrameworkRelationCapabilityRestrictions, FrameworkRelationFieldRestrictions, FrameworkRelationMutationRestriction, FrameworkRelationReducerRestriction, FrameworkResourceFieldRestrictions, FrameworkResourceOperationRestrictions, FrameworkResourceRestrictions, FrameworkRestrictionsConfig, FrameworkScalarCapabilityRestrictions, FrameworkScalarFieldRestrictions, } from "./framework-restrictions-config.js";
121
+ /**
122
+ * The `mcp` key: the MCP endpoint's mount path (`"/mcp"`), or the path with
123
+ * the authorization its callers must present.
124
+ */
125
+ export type AvConfigMcp = string | {
126
+ /** The MCP endpoint's mount path, written as `api` is. */
127
+ readonly path: string;
128
+ /**
129
+ * OAuth for the endpoint. Left out, the endpoint takes no token.
130
+ */
131
+ readonly authorization?: {
132
+ /**
133
+ * The authorization servers (https URLs) a caller obtains its token
134
+ * from, advertised in the endpoint's protected-resource metadata. A
135
+ * server on this machine may be http: `http://127.0.0.1` or
136
+ * `http://[::1]`, with any port and path (not `localhost`).
137
+ */
138
+ readonly servers: readonly string[];
139
+ /**
140
+ * Checks one bearer token: what it resolves to (the caller, say) when
141
+ * the token is good, `null` when it is not.
142
+ */
143
+ readonly verify: (token: string) => unknown | null | Promise<unknown | null>;
144
+ };
145
+ };
146
+ /**
147
+ * The `agent` layer: the six layer keys, and `extends`, the layer whose final
148
+ * view it narrows and whose stages run before its own.
149
+ */
150
+ export type AvConfigAgentLayer<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = AvConfigLayer<M, Cfg, "overlay", "agent"> & {
151
+ /**
152
+ * The layer the agent starts from: `"client"` (the default), `"application"`
153
+ * or `"root"`. The agent never widens it.
154
+ */
155
+ readonly extends?: "client" | "application" | "root";
156
+ };
157
+ export type { AvConfigAny, AvConfigLayerAny, AvConfigResourcesAny, } from "./any-framework-config.js";
158
+ export type { AvFieldCompute, AvRelationFieldPipeline, AvScalarFieldPipeline, AvZCheck, } from "./field-pipeline-config.js";
159
+ export type { AvConfigExemptions, AvConfigOperationsExemption, AvConfigRelationFieldExemption, AvConfigResourceExemption, AvConfigScalarFieldExemption, AvRelationFieldCapabilityName, AvScalarFieldCapabilityName, } from "./framework-exemptions-config.js";
160
+ export type { AvConfigAddedFieldDefinition, AvConfigFieldDefinition, AvConfigFieldLifecycleTrait, AvConfigKnownFieldDefinition, AvConfigResourceKey, AvConfigScalarTypeRef, AvZFormat, } from "./framework-field-definition.js";
161
+ export type { AvConfigFamily, AvConfigLayerKind, AvConfigOperations, AvConfigOverlayField, AvConfigResource, AvConfigResourceFields, AvConfigResources, AvConfigResourceTransactions, AvConfigRootField, AvConfigVariant, } from "./framework-resources-config.js";
@@ -0,0 +1,91 @@
1
+ import type { AvAdapterModel } from "../adapters/adapter-model.js";
2
+ import type { AvAdapterFieldKey } from "../adapters/adapter-resource.js";
3
+ import type { AvPaginationCapability, AvRelationFilterCapability, AvRelationMutationDirective, AvRelationReducer, AvScalarFilterOperator, AvScalarMutationDirective } from "../contracts/capability.js";
4
+ import type { AvConfigAny } from "./any-framework-config.js";
5
+ import type { AvEffectiveFieldKey } from "./effective-fields.js";
6
+ import type { AvConfigResourceKey } from "./framework-field-definition.js";
7
+ /** The capability names a scalar field's exemption can list. */
8
+ export type AvScalarFieldCapabilityName = "select" | "filter" | "order" | "orderNulls" | "create" | "update";
9
+ /** The capability names a relation field's exemption can list. */
10
+ export type AvRelationFieldCapabilityName = "select" | "include" | "filter" | "order" | "pagination" | "reducers" | "create" | "update";
11
+ /** A scalar field's exemption: whole, by capability name, or per capability. */
12
+ export type AvConfigScalarFieldExemption = boolean | readonly AvScalarFieldCapabilityName[] | ({
13
+ readonly select?: boolean;
14
+ readonly filter?: boolean | readonly AvScalarFilterOperator[];
15
+ readonly order?: boolean;
16
+ readonly orderNulls?: boolean;
17
+ readonly create?: boolean | readonly AvScalarMutationDirective[];
18
+ readonly update?: boolean | readonly AvScalarMutationDirective[];
19
+ } & NotAList);
20
+ /** A relation field's exemption: whole, by capability name, or per capability. */
21
+ export type AvConfigRelationFieldExemption = boolean | readonly AvRelationFieldCapabilityName[] | ({
22
+ readonly select?: boolean;
23
+ readonly include?: boolean;
24
+ readonly filter?: boolean | readonly AvRelationFilterCapability[];
25
+ readonly order?: boolean;
26
+ readonly pagination?: boolean | readonly AvPaginationCapability[];
27
+ readonly reducers?: boolean | readonly AvRelationReducer[];
28
+ readonly create?: boolean | readonly AvRelationMutationDirective[];
29
+ readonly update?: boolean | readonly AvRelationMutationDirective[];
30
+ } & NotAList);
31
+ /** The operations of Resource `R`, as the adapter model states them. */
32
+ type ResourceOperationsOf<M extends AvAdapterModel, R extends AvConfigResourceKey<M>> = M["resources"][R]["operations"];
33
+ /** The families Resource `R` offers. */
34
+ type FamilyOf<M extends AvAdapterModel, R extends AvConfigResourceKey<M>> = Extract<keyof ResourceOperationsOf<M, R>, string>;
35
+ /** The variants family `F` of Resource `R` offers. */
36
+ type VariantOf<M extends AvAdapterModel, R extends AvConfigResourceKey<M>, F extends FamilyOf<M, R>> = Extract<keyof NonNullable<ResourceOperationsOf<M, R>[F]>, string>;
37
+ /**
38
+ * A Resource's operations exemption, in the nested form: whole, a list of
39
+ * families, or per family a list of variants or a per-variant object.
40
+ */
41
+ export type AvConfigOperationsExemption<M extends AvAdapterModel = AvAdapterModel, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = boolean | readonly FamilyOf<M, R>[] | ({
42
+ readonly [F in FamilyOf<M, R>]?: boolean | readonly VariantOf<M, R, F>[] | ({
43
+ readonly [V in VariantOf<M, R, F>]?: boolean;
44
+ } & NotAList);
45
+ } & NotAList);
46
+ /** Refuses a list where the object form is meant. */
47
+ type NotAList = {
48
+ readonly [index: number]: never;
49
+ };
50
+ /** The tokens one capability member offers, its position qualifier aside. */
51
+ type MemberToken<Member> = Member extends {
52
+ readonly directives: readonly (infer Token)[];
53
+ } ? Token : Member extends {
54
+ readonly reducers: readonly (infer Token)[];
55
+ } ? Token : Member extends readonly (infer Token)[] ? Token : never;
56
+ /** A token capability's exemption: whole, or the tokens the field offers. */
57
+ type TokenExemption<Caps, K> = K extends keyof Caps ? boolean | readonly MemberToken<NonNullable<Caps[K]>>[] : boolean;
58
+ /** The capability names a discovered scalar's exemption can name: its own, and `select`. */
59
+ type ScalarNameOf<Caps> = Extract<keyof Caps, AvScalarFieldCapabilityName> | "select";
60
+ /** A discovered scalar field's exemption, by its capabilities. */
61
+ type ScalarFieldExemptionOf<Caps> = boolean | readonly ScalarNameOf<Caps>[] | ({
62
+ readonly [K in ScalarNameOf<Caps>]?: K extends "filter" | "create" | "update" ? TokenExemption<Caps, K> : boolean;
63
+ } & NotAList);
64
+ /** The capability names a discovered relation's exemption can name: its own. */
65
+ type RelationNameOf<Caps> = Extract<keyof Caps, AvRelationFieldCapabilityName>;
66
+ /** A discovered relation field's exemption, by its capabilities. */
67
+ type RelationFieldExemptionOf<Caps> = boolean | readonly RelationNameOf<Caps>[] | ({
68
+ readonly [K in RelationNameOf<Caps>]?: K extends "select" | "include" | "order" ? boolean : TokenExemption<Caps, K>;
69
+ } & NotAList);
70
+ /** The exemption shape one effective field name admits. */
71
+ type FieldExemptionFor<M extends AvAdapterModel, R extends AvConfigResourceKey<M>, F extends string> = string extends F ? AvConfigScalarFieldExemption | AvConfigRelationFieldExemption : F extends AvAdapterFieldKey<M, R> ? M["resources"][R]["fields"][F] extends {
72
+ readonly kind: "relation";
73
+ readonly capabilities: infer Caps;
74
+ } ? RelationFieldExemptionOf<Caps> : M["resources"][R]["fields"][F] extends {
75
+ readonly capabilities: infer Caps;
76
+ } ? ScalarFieldExemptionOf<Caps> : AvConfigScalarFieldExemption : AvConfigScalarFieldExemption;
77
+ /** A Resource's exemption: whole, or its operations and fields. No list. */
78
+ export type AvConfigResourceExemption<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny, R extends AvConfigResourceKey<M> = AvConfigResourceKey<M>> = boolean | ({
79
+ readonly operations?: AvConfigOperationsExemption<M, R>;
80
+ readonly fields?: {
81
+ readonly [F in AvEffectiveFieldKey<M, Cfg, R>]?: FieldExemptionFor<M, R, F>;
82
+ };
83
+ } & NotAList);
84
+ /** The entries that are the opposite of a layer's `exposed`. */
85
+ export type AvConfigExemptions<M extends AvAdapterModel = AvAdapterModel, Cfg = AvConfigAny> = {
86
+ /** Per Resource, by the adapter's Resource names. */
87
+ readonly resources?: {
88
+ readonly [R in AvConfigResourceKey<M>]?: AvConfigResourceExemption<M, Cfg, R>;
89
+ };
90
+ };
91
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,78 @@
1
+ import type { AvAdapterModel } from "../adapters/adapter-model.js";
2
+ import type { AvScalarFieldCapabilities } from "../contracts/field.js";
3
+ import type { JsonShape } from "../contracts/json-shape.js";
4
+ import type { AvLifecycleTrait } from "../contracts/lifecycle-trait.js";
5
+ /** The lifecycle traits a configuration may set on a field. */
6
+ export type AvConfigFieldLifecycleTrait = Extract<AvLifecycleTrait, "VIRTUAL">;
7
+ /** The names of the Resources in adapter model `M`. */
8
+ export type AvConfigResourceKey<M extends AvAdapterModel> = Extract<keyof M["resources"], string>;
9
+ /** A scalar type or an enum of adapter model `M`, by name. */
10
+ export type AvConfigScalarTypeRef<M extends AvAdapterModel> = {
11
+ readonly scalar: Extract<keyof M["scalars"], string>;
12
+ } | {
13
+ readonly enum: Extract<keyof M["enums"], string>;
14
+ };
15
+ /** zod's named string formats: the `format` names a configured field may state. */
16
+ export declare const AVZ_FORMATS: readonly ["email", "url", "emoji", "uuid", "guid", "nanoid", "cuid", "cuid2", "ulid", "xid", "ksuid", "datetime", "date", "time", "duration", "ipv4", "ipv6", "cidrv4", "cidrv6", "base64", "base64url", "json_string", "e164", "credit_card", "iban", "jwt"];
17
+ /**
18
+ * One of zod's named string formats. A configured (VIRTUAL) field states its
19
+ * `format` with one of these; any other name is refused.
20
+ */
21
+ export type AvZFormat = (typeof AVZ_FORMATS)[number];
22
+ /**
23
+ * A field's definition: its type, nullability, list-ness, lifecycle, format,
24
+ * capabilities and Json shape. Root only.
25
+ */
26
+ export type AvConfigFieldDefinition<M extends AvAdapterModel = AvAdapterModel> = {
27
+ /** The field's scalar or enum type. A discovered field may only restate its own. */
28
+ readonly type?: AvConfigScalarTypeRef<M>;
29
+ /** Whether the field may be `null`. A discovered field may only restate its own. */
30
+ readonly nullable?: boolean;
31
+ /** Whether the field holds a list. A discovered field may only restate its own. */
32
+ readonly list?: boolean;
33
+ /** `["VIRTUAL"]`: a field the store does not hold. Configured fields only. */
34
+ readonly lifecycle?: readonly AvConfigFieldLifecycleTrait[];
35
+ /** The value's format, one of zod's named formats. Configured fields only. */
36
+ readonly format?: AvZFormat;
37
+ /** What callers may do with the field. Configured fields only. */
38
+ readonly capabilities?: Partial<AvScalarFieldCapabilities>;
39
+ /**
40
+ * A discovered Json field's shape, built with `AvZ` from
41
+ * `@aventara/core/avz`: writes to the field are checked against it, and its
42
+ * value is typed by it.
43
+ */
44
+ readonly json?: JsonShape;
45
+ };
46
+ /**
47
+ * What a definition may say about field `Field` the adapter discovered: restate
48
+ * its `type`, `nullable` and `list`, and give a Json field its shape.
49
+ */
50
+ export type AvConfigKnownFieldDefinition<Field> = {
51
+ readonly type?: Field extends {
52
+ readonly type: infer Type;
53
+ } ? Type : never;
54
+ readonly nullable?: Field extends {
55
+ readonly nullable: infer Nullable;
56
+ } ? Nullable : never;
57
+ readonly list?: Field extends {
58
+ readonly list: infer List;
59
+ } ? List : never;
60
+ readonly lifecycle?: never;
61
+ readonly format?: never;
62
+ readonly capabilities?: never;
63
+ readonly json?: Field extends {
64
+ readonly type: {
65
+ readonly scalar: "json";
66
+ };
67
+ } ? JsonShape : never;
68
+ };
69
+ /**
70
+ * A configured field, which the adapter did not discover: `type`, `nullable` and
71
+ * `list` are required, and it takes no `json` shape.
72
+ */
73
+ export type AvConfigAddedFieldDefinition<M extends AvAdapterModel = AvAdapterModel> = Omit<AvConfigFieldDefinition<M>, "type" | "nullable" | "list" | "json"> & {
74
+ readonly type: AvConfigScalarTypeRef<M>;
75
+ readonly nullable: boolean;
76
+ readonly list: boolean;
77
+ readonly json?: never;
78
+ };
@@ -0,0 +1,28 @@
1
+ export const AVZ_FORMATS = [
2
+ "email",
3
+ "url",
4
+ "emoji",
5
+ "uuid",
6
+ "guid",
7
+ "nanoid",
8
+ "cuid",
9
+ "cuid2",
10
+ "ulid",
11
+ "xid",
12
+ "ksuid",
13
+ "datetime",
14
+ "date",
15
+ "time",
16
+ "duration",
17
+ "ipv4",
18
+ "ipv6",
19
+ "cidrv4",
20
+ "cidrv6",
21
+ "base64",
22
+ "base64url",
23
+ "json_string",
24
+ "e164",
25
+ "credit_card",
26
+ "iban",
27
+ "jwt",
28
+ ];