@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 AvDecimal } from "./decimal.js";
2
+ /** A value `AvDeepReadonly` leaves as it is: a primitive, a function, or a scalar instance. */
3
+ export type AvDeepReadonlyLeaf = string | number | boolean | bigint | symbol | null | undefined | Date | Uint8Array | AvDecimal | ((...args: never[]) => unknown);
4
+ /**
5
+ * Whether array type `T` is an open array (every length: `"array"`) or a tuple
6
+ * (`"tuple"`). A tuple whose only fixed positions are optional ones before a rest
7
+ * element (`[a?, ...b[]]`) has every length too and reads as an array.
8
+ */
9
+ export type ArrayForm<T extends readonly unknown[]> = T extends readonly [] | readonly [unknown, ...unknown[]] | readonly [...unknown[], unknown] ? "tuple" : T extends {
10
+ readonly length: infer Length;
11
+ } ? number extends Length ? "array" : "tuple" : "tuple";
12
+ /**
13
+ * `T` with every property, element and nested property read-only: what a stage
14
+ * that only reads is told. Arrays become read-only arrays, tuples read-only
15
+ * tuples; a `Date`, a `Uint8Array`, an `AvDecimal` and functions are left as
16
+ * they are.
17
+ */
18
+ export type AvDeepReadonly<T> = T extends AvDeepReadonlyLeaf ? T : T extends readonly unknown[] ? ArrayForm<T> extends "array" ? readonly AvDeepReadonly<T[number]>[] : {
19
+ readonly [K in keyof T]: AvDeepReadonly<T[K]>;
20
+ } : T extends object ? {
21
+ readonly [K in keyof T]: AvDeepReadonly<T[K]>;
22
+ } : T;
23
+ /**
24
+ * Freezes `value` in place, every nested plain object and array included, and
25
+ * returns it. Accessor properties are not read. For data the framework owns: the
26
+ * copy taken at the door, a body parsed for this request alone, a pipe's output.
27
+ */
28
+ export declare function deepFreeze<T>(value: T): T;
29
+ /**
30
+ * A deep-frozen copy of `value`'s plain objects and arrays, every `Date` and
31
+ * `Uint8Array` in it copied too, the original left as it is: what a stage that
32
+ * only reads is told — the validated arguments after validation, a result in an
33
+ * after hook — so neither what is written nor the result the caller receives can
34
+ * be changed through it.
35
+ *
36
+ * With `snapshot`, a copied container found to hold no `Date` or `Uint8Array`
37
+ * is remembered as such at once, so a later `frozenCopy` of the copy shares it
38
+ * without walking it: for a copy that is itself copied again for each stage.
39
+ */
40
+ export declare function frozenCopy<T>(value: T, snapshot?: boolean): AvDeepReadonly<T>;
41
+ /**
42
+ * A read-only view of `value`: reads see the live value, nested plain objects
43
+ * and arrays as views too, and any write, definition or deletion throws a
44
+ * `TypeError` naming `subject` (one subject per value: the first view's). The
45
+ * value itself stays writable for its owner.
46
+ */
47
+ export declare function readonlyView<T>(value: T, subject: string): AvDeepReadonly<T>;
@@ -0,0 +1,189 @@
1
+ import { isAvDecimal } from "./decimal.js";
2
+ function isContainer(value) {
3
+ if (value === null || typeof value !== "object") {
4
+ return false;
5
+ }
6
+ if (Array.isArray(value)) {
7
+ return true;
8
+ }
9
+ if (isAvDecimal(value)) {
10
+ return false;
11
+ }
12
+ const prototype = Object.getPrototypeOf(value);
13
+ return prototype === Object.prototype || prototype === null;
14
+ }
15
+ const DEEP_FROZEN = new WeakSet();
16
+ export function deepFreeze(value) {
17
+ if (!isContainer(value) || DEEP_FROZEN.has(value)) {
18
+ return value;
19
+ }
20
+ Object.freeze(value);
21
+ DEEP_FROZEN.add(value);
22
+ for (const key of Reflect.ownKeys(value)) {
23
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
24
+ if (descriptor !== undefined && "value" in descriptor) {
25
+ deepFreeze(descriptor.value);
26
+ }
27
+ }
28
+ return value;
29
+ }
30
+ function scalarCopy(value) {
31
+ if (value instanceof Date) {
32
+ return new Date(value.getTime());
33
+ }
34
+ if (value instanceof Uint8Array) {
35
+ return value.slice();
36
+ }
37
+ return undefined;
38
+ }
39
+ const SCALAR_FREE = new WeakSet();
40
+ function scalarFree(value) {
41
+ return Object.isFrozen(value) && SCALAR_FREE.has(value);
42
+ }
43
+ const WALKING = Symbol("walking");
44
+ function place(target, key, value, enumerable) {
45
+ if (enumerable && typeof key === "string" && !(key in target)) {
46
+ target[key] = value;
47
+ return;
48
+ }
49
+ Object.defineProperty(target, key, {
50
+ value,
51
+ enumerable,
52
+ writable: true,
53
+ configurable: true,
54
+ });
55
+ }
56
+ export function frozenCopy(value, snapshot = false) {
57
+ const scalar = scalarCopy(value);
58
+ if (scalar !== undefined) {
59
+ return scalar;
60
+ }
61
+ if (!isContainer(value) || scalarFree(value)) {
62
+ return value;
63
+ }
64
+ const copies = new Map();
65
+ let cycled = false;
66
+ let holdsScalar = false;
67
+ const copy = (current) => {
68
+ if (current === null || typeof current !== "object") {
69
+ return current;
70
+ }
71
+ const scalar = scalarCopy(current);
72
+ if (scalar !== undefined) {
73
+ holdsScalar = true;
74
+ return scalar;
75
+ }
76
+ if (!isContainer(current) || scalarFree(current)) {
77
+ return current;
78
+ }
79
+ const known = copies.get(current);
80
+ if (known === WALKING) {
81
+ cycled = true;
82
+ return current;
83
+ }
84
+ if (known !== undefined) {
85
+ holdsScalar ||= !scalarFree(known);
86
+ return known;
87
+ }
88
+ copies.set(current, WALKING);
89
+ const outer = holdsScalar;
90
+ holdsScalar = false;
91
+ let changed = !(Object.isFrozen(current) && DEEP_FROZEN.has(current));
92
+ const array = Array.isArray(current);
93
+ const prototype = Object.getPrototypeOf(current);
94
+ const target = array
95
+ ? new Array(current.length)
96
+ : prototype === Object.prototype
97
+ ? {}
98
+ : Object.create(prototype);
99
+ for (const key of Reflect.ownKeys(current)) {
100
+ if (array && key === "length") {
101
+ continue;
102
+ }
103
+ const descriptor = Object.getOwnPropertyDescriptor(current, key);
104
+ if (descriptor === undefined || !("value" in descriptor)) {
105
+ continue;
106
+ }
107
+ const next = copy(descriptor.value);
108
+ changed ||= next !== descriptor.value;
109
+ place(target, key, next, descriptor.enumerable === true);
110
+ }
111
+ const held = holdsScalar;
112
+ holdsScalar = outer || held;
113
+ if (!changed) {
114
+ copies.set(current, current);
115
+ if (!cycled) {
116
+ SCALAR_FREE.add(current);
117
+ }
118
+ return current;
119
+ }
120
+ Object.freeze(target);
121
+ DEEP_FROZEN.add(target);
122
+ if (cycled) {
123
+ for (const key of Reflect.ownKeys(target)) {
124
+ deepFreeze(target[key]);
125
+ }
126
+ }
127
+ if (snapshot && !held && !cycled) {
128
+ SCALAR_FREE.add(target);
129
+ }
130
+ copies.set(current, target);
131
+ return target;
132
+ };
133
+ return copy(value);
134
+ }
135
+ function readOnlyWrite(subject) {
136
+ return new TypeError(`${subject} is read-only here.`);
137
+ }
138
+ const VIEWS = new WeakMap();
139
+ export function readonlyView(value, subject) {
140
+ if (!isContainer(value)) {
141
+ return value;
142
+ }
143
+ const known = VIEWS.get(value);
144
+ if (known !== undefined) {
145
+ return known;
146
+ }
147
+ const real = value;
148
+ const standIn = Array.isArray(value)
149
+ ? []
150
+ : Object.create(Object.getPrototypeOf(value));
151
+ const refuse = () => {
152
+ throw readOnlyWrite(subject);
153
+ };
154
+ const view = new Proxy(standIn, {
155
+ get: (_target, key) => readonlyView(real[key], subject),
156
+ has: (_target, key) => key in real,
157
+ ownKeys: () => Reflect.ownKeys(real),
158
+ getOwnPropertyDescriptor: (target, key) => {
159
+ const descriptor = Reflect.getOwnPropertyDescriptor(real, key);
160
+ if (descriptor === undefined) {
161
+ return undefined;
162
+ }
163
+ if (Reflect.getOwnPropertyDescriptor(target, key)?.configurable === false) {
164
+ return {
165
+ value: descriptor.value,
166
+ enumerable: false,
167
+ writable: true,
168
+ configurable: false,
169
+ };
170
+ }
171
+ return "value" in descriptor
172
+ ? {
173
+ value: readonlyView(descriptor.value, subject),
174
+ enumerable: descriptor.enumerable ?? false,
175
+ writable: false,
176
+ configurable: true,
177
+ }
178
+ : { ...descriptor, configurable: true };
179
+ },
180
+ getPrototypeOf: () => Object.getPrototypeOf(real),
181
+ set: refuse,
182
+ defineProperty: refuse,
183
+ deleteProperty: refuse,
184
+ setPrototypeOf: refuse,
185
+ preventExtensions: refuse,
186
+ });
187
+ VIEWS.set(value, view);
188
+ return view;
189
+ }
@@ -29,7 +29,7 @@ export type ReferentialEdge = {
29
29
  * relation `field` and any of these names the reference twice and is refused;
30
30
  * a required relation may be written through all of them instead.
31
31
  */
32
- readonly references: readonly string[];
32
+ readonly referenceFields: readonly string[];
33
33
  /** What deleting a `target` row does to rows of the ENCLOSING Resource. */
34
34
  readonly onDelete: ReferentialDeleteEffect;
35
35
  };
@@ -1,5 +1,5 @@
1
- import type { ValidationIssue } from "../operations/validation-code.js";
1
+ import type { AvValidationIssue } from "../operations/validation-code.js";
2
2
  /** The issues of one malformed operation request envelope; empty when well formed. */
3
- export declare function validateOperationEnvelope(request: unknown): readonly ValidationIssue[];
3
+ export declare function validateOperationEnvelope(request: unknown): readonly AvValidationIssue[];
4
4
  /** The issues of one malformed transaction request envelope; empty when well formed. */
5
- export declare function validateTransactionEnvelope(request: unknown): readonly ValidationIssue[];
5
+ export declare function validateTransactionEnvelope(request: unknown): readonly AvValidationIssue[];
@@ -1,4 +1,4 @@
1
- const ORIGINS = ["application", "client"];
1
+ const ORIGINS = ["application", "client", "agent"];
2
2
  const OPERATION_IDENTITY_MEMBERS = ["resource", "family", "variant"];
3
3
  export function validateOperationEnvelope(request) {
4
4
  if (!isRecord(request)) {
@@ -29,7 +29,7 @@ function originAndIdentityIssues(request) {
29
29
  issues.push(issue(["origin"], "V1001", "Request origin must be a string."));
30
30
  }
31
31
  else if (!ORIGINS.includes(origin)) {
32
- issues.push(issue(["origin"], "V1002", 'Request origin must be "application" or "client".'));
32
+ issues.push(issue(["origin"], "V1002", 'Request origin must be "application", "client" or "agent".'));
33
33
  }
34
34
  const requestId = request.requestId;
35
35
  if (requestId === undefined || requestId === "") {
@@ -38,8 +38,13 @@ function originAndIdentityIssues(request) {
38
38
  else if (typeof requestId !== "string") {
39
39
  issues.push(issue(["requestId"], "V1001", "Request id must be a string."));
40
40
  }
41
- if (origin === "client") {
42
- issues.push(...protocolIssues(request.protocol));
41
+ const state = request.state;
42
+ if (state !== undefined &&
43
+ (typeof state !== "object" || state === null || Array.isArray(state))) {
44
+ issues.push(issue(["state"], "V1001", "Request state must be an object."));
45
+ }
46
+ if (origin === "client" || origin === "agent") {
47
+ issues.push(...protocolIssues(request.protocol, origin));
43
48
  if (request.transport !== undefined) {
44
49
  issues.push(...transportIssues(request.transport));
45
50
  }
@@ -47,16 +52,16 @@ function originAndIdentityIssues(request) {
47
52
  else if (origin === "application") {
48
53
  for (const member of ["protocol", "transport"]) {
49
54
  if (request[member] !== undefined) {
50
- issues.push(issue([member], "V1005", `Property "${member}" belongs to a client request, not an application one.`));
55
+ issues.push(issue([member], "V1005", `Property "${member}" belongs to a client or agent request, not an application one.`));
51
56
  }
52
57
  }
53
58
  }
54
59
  return issues;
55
60
  }
56
- function protocolIssues(protocol) {
61
+ function protocolIssues(protocol, origin) {
57
62
  if (protocol === undefined) {
58
63
  return [
59
- issue(["protocol"], "V1000", 'Required property "protocol" is missing from a client request.'),
64
+ issue(["protocol"], "V1000", `Required property "protocol" is missing from ${origin === "client" ? "a client" : "an agent"} request.`),
60
65
  ];
61
66
  }
62
67
  if (!isRecord(protocol)) {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The request id of one call or transaction run: the caller's
3
- * `ExecutionOptions.requestId` when it is a non-empty string, otherwise a new
3
+ * `AvExecutionOptions.requestId` when it is a non-empty string, otherwise a new
4
4
  * one. Any other value is ignored.
5
5
  */
6
6
  export declare function requestIdOf(options: unknown): string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The per-request state every stage reads and writes as `ctx.$state`. Empty
3
+ * until the application declares its members by module augmentation:
4
+ *
5
+ * ```ts
6
+ * declare module "@aventara/core" {
7
+ * interface AvState {
8
+ * user?: { id: string; roles: string[] };
9
+ * }
10
+ * }
11
+ * ```
12
+ */
13
+ export interface AvState {
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { AvState } from "./request-state.js";
2
+ /**
3
+ * The state of one request: the seed when it is an object, otherwise a fresh
4
+ * `{}`. A seed that is not an object is ignored, as an unusable request id is.
5
+ */
6
+ export declare function requestStateOf(seed: unknown): AvState;
7
+ /**
8
+ * The state an in-process call's `AvExecutionOptions` seeds, or `undefined`.
9
+ * Read as `unknown`, like the request id: a façade is total for untyped
10
+ * callers, so a getter that throws or a value that is not an object is ignored.
11
+ */
12
+ export declare function stateOptionOf(options: unknown): AvState | undefined;
@@ -0,0 +1,20 @@
1
+ export function requestStateOf(seed) {
2
+ return typeof seed === "object" && seed !== null && !Array.isArray(seed)
3
+ ? seed
4
+ : {};
5
+ }
6
+ export function stateOptionOf(options) {
7
+ if (typeof options !== "object" || options === null) {
8
+ return undefined;
9
+ }
10
+ let state;
11
+ try {
12
+ state = options.state;
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ return typeof state === "object" && state !== null && !Array.isArray(state)
18
+ ? state
19
+ : undefined;
20
+ }
@@ -1,41 +1,57 @@
1
- import type { RequestOrigin } from "../config/config-layer.js";
2
- import type { ScalarFilterOperator } from "../contracts/capability.js";
3
- import type { Contract } from "../contracts/contract.js";
4
- import type { ScalarField } from "../contracts/field.js";
5
- import type { OperationIdentity } from "../operations/operation-identity.js";
1
+ import type { AvRequestOrigin } from "../config/config-layer.js";
2
+ import type { AvContract } from "../contracts/contract.js";
3
+ import type { AvScalarField } from "../contracts/field.js";
4
+ import type { AvOperationIdentity } from "../operations/operation-identity.js";
6
5
  import type { OperationValidationOptions, SemanticOperationArguments } from "../operations/operation-validator.js";
7
- import type { ValidationIssue } from "../operations/validation-code.js";
6
+ import type { AvValidationIssue } from "../operations/validation-code.js";
8
7
  import { type TransactionSlotShape } from "../transactions/transaction-reference.js";
9
- export type ScalarNormalizationResult = {
8
+ type ScalarNormalizationResult = {
10
9
  readonly ok: true;
11
10
  readonly arguments: SemanticOperationArguments;
12
11
  } | {
13
12
  readonly ok: false;
14
- readonly issues: readonly ValidationIssue[];
13
+ readonly issues: readonly AvValidationIssue[];
15
14
  };
16
- export type ScalarValueNormalizationResult = {
15
+ type ScalarValueNormalizationResult = {
17
16
  readonly ok: true;
18
17
  readonly value: unknown;
19
18
  } | {
20
19
  readonly ok: false;
21
- readonly issues: readonly ValidationIssue[];
20
+ readonly issues: readonly AvValidationIssue[];
22
21
  };
23
22
  type Path = readonly (string | number)[];
24
23
  /**
25
24
  * The one discriminant between an argument OBJECT and a VALUE wherever a position
26
25
  * admits both — a filter position above all: a **plain** record is an operator object,
27
- * and anything else — a `Date`, a core `Decimal`, a `Uint8Array` — is a value, which
26
+ * and anything else — a `Date`, a core `AvDecimal`, a `Uint8Array` — is a value, which
28
27
  * equality shorthand then holds to the field's scalar. The validator (`operation-
29
28
  * validator-core.ts`) reads a filter position through this same answer, and an
30
29
  * adapter's filter translation is expected to, so a position cannot be operators to
31
30
  * one reader and a value to another.
32
31
  */
33
32
  export declare function isPlainRecord(value: unknown): value is Readonly<Record<string, unknown>>;
33
+ /** The `V1001` of an `undefined` the request reads with. */
34
+ export declare function unsentReadValueIssue(path: Path): AvValidationIssue;
35
+ /**
36
+ * An operation argument's JSON value is bounded by `maxJsonDepth`, which the
37
+ * structural walk enforces before this runs; a `$sql` step's parameter is not
38
+ * bounded by it. The traversal therefore carries its own stack on the heap: a
39
+ * payload deep enough to exhaust the call stack must still normalize rather
40
+ * than become an internal failure.
41
+ *
42
+ * `seen` holds the ancestors of the value being visited, so a repeated
43
+ * sibling reference is legal and only a genuine cycle is rejected.
44
+ *
45
+ * Every node it emits is typed {@link AvJsonValue}, so the public type and what
46
+ * this traversal produces are one fact: a branch that emitted anything else
47
+ * would not compile.
48
+ */
49
+ export declare function normalizeJsonValue(value: unknown, path: Path, seen: Set<object>): ScalarValueNormalizationResult;
34
50
  /**
35
51
  * Normalizes one field value to Aventara's provider-neutral runtime form.
36
52
  * `runtime` is used for framework-produced values regardless of request origin.
37
53
  */
38
- export declare function normalizeScalarFieldValue(contract: Contract, field: ScalarField<Contract>, value: unknown, origin: RequestOrigin | "runtime", path: Path): ScalarValueNormalizationResult;
54
+ export declare function normalizeScalarFieldValue(contract: AvContract, field: AvScalarField<AvContract>, value: unknown, origin: AvRequestOrigin | "runtime", path: Path): ScalarValueNormalizationResult;
39
55
  /**
40
56
  * Every way a normalized value written to `field` does not conform to the field's
41
57
  * Json Shape, each at its full path; none for an unshaped field or a `null`.
@@ -45,25 +61,17 @@ export declare function normalizeScalarFieldValue(contract: Contract, field: Sca
45
61
  * @throws Error when the field carries a shape no checker is bound to — a Contract
46
62
  * the Framework did not compile.
47
63
  */
48
- export declare function jsonShapeIssues(field: ScalarField<Contract>, value: unknown, path: Path, position?: "value" | "entry"): readonly ValidationIssue[];
64
+ export declare function jsonShapeIssues(field: AvScalarField<AvContract>, value: unknown, path: Path, position?: "value" | "entry"): readonly AvValidationIssue[];
49
65
  /**
50
66
  * Copies one validated runtime value of a scalar field into a value the framework
51
67
  * owns, per scalar codec: `datetime` → a new `Date`, `bytes` → a sliced `Uint8Array`,
52
68
  * `json` → a structured deep copy, and a list → a new array of copied items. `decimal`
53
69
  * keeps its identity, and strings, numbers, booleans, bigints, enum members and `null`
54
70
  * are immutable and returned unchanged. {@link SCALAR_ATOM_COPIERS} is exhaustive over
55
- * {@link BuiltInScalar}, so a new codec cannot reach this function without declaring
71
+ * {@link AvBuiltInScalar}, so a new codec cannot reach this function without declaring
56
72
  * its copy.
57
73
  */
58
- export declare function copyScalarFieldValue(field: ScalarField<Contract>, value: unknown): unknown;
59
- /**
60
- * The operators of a step's own filter whose operand is a reference position, and
61
- * the shape each holds — the one table the normalization below and the reference
62
- * collector (`transaction-reference-collector.ts`) both read. `not` also takes a
63
- * nested operator object. Not here, so never a reference: `mode`, `isEmpty`, `path`
64
- * and a `json` field's `string*`/`array*` operators, which take no field value.
65
- */
66
- export declare const REFERENCE_OPERANDS: Readonly<Partial<Record<ScalarFilterOperator, TransactionSlotShape>>>;
74
+ export declare function copyScalarFieldValue(field: AvScalarField<AvContract>, value: unknown): unknown;
67
75
  /** The shape of `operator`'s operand when it is a reference position. */
68
76
  export declare function referenceOperandShape(operator: string): TransactionSlotShape | undefined;
69
77
  /**
@@ -76,8 +84,8 @@ export type NormalizationWrite = "copy" | "in-place";
76
84
  * Normalizes every scalar leaf in one structurally valid standard operation.
77
85
  * Client wire values are decoded; application values are validated in runtime form.
78
86
  */
79
- export declare function normalizeOperationScalarValues(contract: Contract, request: OperationIdentity & {
87
+ export declare function normalizeOperationScalarValues(contract: AvContract, request: AvOperationIdentity & {
80
88
  readonly resource: string;
81
89
  readonly arguments: SemanticOperationArguments;
82
- }, origin: RequestOrigin, options?: OperationValidationOptions, write?: NormalizationWrite): ScalarNormalizationResult;
90
+ }, origin: AvRequestOrigin, options?: OperationValidationOptions, write?: NormalizationWrite): ScalarNormalizationResult;
83
91
  export {};